16129Snate@binkert.org/* 26129Snate@binkert.org * Copyright (c) 2003-2005 The Regents of The University of Michigan 36129Snate@binkert.org * All rights reserved. 46129Snate@binkert.org * 56129Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66129Snate@binkert.org * modification, are permitted provided that the following conditions are 76129Snate@binkert.org * met: redistributions of source code must retain the above copyright 86129Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96129Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106129Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116129Snate@binkert.org * documentation and/or other materials provided with the distribution; 126129Snate@binkert.org * neither the name of the copyright holders nor the names of its 136129Snate@binkert.org * contributors may be used to endorse or promote products derived from 146129Snate@binkert.org * this software without specific prior written permission. 156129Snate@binkert.org * 166129Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176129Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186129Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196129Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206129Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216129Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226129Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236129Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246129Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256129Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266129Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276129Snate@binkert.org * 286129Snate@binkert.org * Authors: Nathan Binkert 296129Snate@binkert.org */ 306129Snate@binkert.org 316169Snate@binkert.org#ifndef __BASE_STATS_INFO_HH__ 326169Snate@binkert.org#define __BASE_STATS_INFO_HH__ 336169Snate@binkert.org 348229Snate@binkert.org#include "base/stats/types.hh" 356130Snate@binkert.org#include "base/flags.hh" 366129Snate@binkert.org 376129Snate@binkert.orgnamespace Stats { 386129Snate@binkert.org 3914266Sandreas.sandberg@arm.comclass Group; 4014266Sandreas.sandberg@arm.com 416130Snate@binkert.orgtypedef uint16_t FlagsType; 426130Snate@binkert.orgtypedef ::Flags<FlagsType> Flags; 436130Snate@binkert.org 446130Snate@binkert.org/** Nothing extra to print. */ 456130Snate@binkert.orgconst FlagsType none = 0x0000; 466130Snate@binkert.org/** This Stat is Initialized */ 476130Snate@binkert.orgconst FlagsType init = 0x0001; 486130Snate@binkert.org/** Print this stat. */ 497462Snate@binkert.orgconst FlagsType display = 0x0002; 506130Snate@binkert.org/** Print the total. */ 516130Snate@binkert.orgconst FlagsType total = 0x0010; 526130Snate@binkert.org/** Print the percent of the total that this entry represents. */ 536130Snate@binkert.orgconst FlagsType pdf = 0x0020; 546130Snate@binkert.org/** Print the cumulative percentage of total upto this entry. */ 556130Snate@binkert.orgconst FlagsType cdf = 0x0040; 566130Snate@binkert.org/** Print the distribution. */ 576130Snate@binkert.orgconst FlagsType dist = 0x0080; 586130Snate@binkert.org/** Don't print if this is zero. */ 596130Snate@binkert.orgconst FlagsType nozero = 0x0100; 606130Snate@binkert.org/** Don't print if this is NAN */ 616130Snate@binkert.orgconst FlagsType nonan = 0x0200; 629743Snilay@cs.wisc.edu/** Print all values on a single line. Useful only for histograms. */ 639743Snilay@cs.wisc.educonst FlagsType oneline = 0x0400; 646130Snate@binkert.org 656130Snate@binkert.org/** Mask of flags that can't be set directly */ 667462Snate@binkert.orgconst FlagsType __reserved = init | display; 676130Snate@binkert.org 687505Snate@binkert.orgstruct StorageParams; 698296Snate@binkert.orgstruct Output; 706129Snate@binkert.org 716129Snate@binkert.orgclass Info 726129Snate@binkert.org{ 736129Snate@binkert.org public: 746129Snate@binkert.org /** The name of the stat. */ 756129Snate@binkert.org std::string name; 768243Sbradley.danofsky@amd.com /** The separator string used for vectors, dist, etc. */ 778243Sbradley.danofsky@amd.com static std::string separatorString; 786129Snate@binkert.org /** The description of the stat. */ 796129Snate@binkert.org std::string desc; 806129Snate@binkert.org /** The formatting flags. */ 816130Snate@binkert.org Flags flags; 826129Snate@binkert.org /** The display precision. */ 836129Snate@binkert.org int precision; 846129Snate@binkert.org /** A pointer to a prerequisite Stat. */ 856129Snate@binkert.org const Info *prereq; 866129Snate@binkert.org /** 876129Snate@binkert.org * A unique stat ID for each stat in the simulator. 886129Snate@binkert.org * Can be used externally for lookups as well as for debugging. 896129Snate@binkert.org */ 906129Snate@binkert.org static int id_count; 916129Snate@binkert.org int id; 926129Snate@binkert.org 936129Snate@binkert.org public: 946129Snate@binkert.org const StorageParams *storageParams; 956129Snate@binkert.org 966129Snate@binkert.org public: 976129Snate@binkert.org Info(); 986129Snate@binkert.org virtual ~Info(); 996129Snate@binkert.org 1006129Snate@binkert.org /** Set the name of this statistic */ 1016129Snate@binkert.org void setName(const std::string &name); 10214266Sandreas.sandberg@arm.com void setName(const Group *parent, const std::string &name); 1038243Sbradley.danofsky@amd.com void setSeparator(std::string _sep) { separatorString = _sep;} 1046129Snate@binkert.org 1056129Snate@binkert.org /** 1066129Snate@binkert.org * Check that this stat has been set up properly and is ready for 1076129Snate@binkert.org * use 1086129Snate@binkert.org * @return true for success 1096129Snate@binkert.org */ 1106129Snate@binkert.org virtual bool check() const = 0; 1116129Snate@binkert.org bool baseCheck() const; 1126129Snate@binkert.org 1136129Snate@binkert.org /** 1146129Snate@binkert.org * Enable the stat for use 1156129Snate@binkert.org */ 1166129Snate@binkert.org virtual void enable(); 1176129Snate@binkert.org 1186129Snate@binkert.org /** 1196129Snate@binkert.org * Prepare the stat for dumping. 1206129Snate@binkert.org */ 1216129Snate@binkert.org virtual void prepare() = 0; 1226129Snate@binkert.org 1236129Snate@binkert.org /** 1246129Snate@binkert.org * Reset the stat to the default state. 1256129Snate@binkert.org */ 1266129Snate@binkert.org virtual void reset() = 0; 1276129Snate@binkert.org 1286129Snate@binkert.org /** 1296129Snate@binkert.org * @return true if this stat has a value and satisfies its 1306129Snate@binkert.org * requirement as a prereq 1316129Snate@binkert.org */ 1326129Snate@binkert.org virtual bool zero() const = 0; 1336129Snate@binkert.org 1346129Snate@binkert.org /** 1356129Snate@binkert.org * Visitor entry for outputing statistics data 1366129Snate@binkert.org */ 1378296Snate@binkert.org virtual void visit(Output &visitor) = 0; 1386129Snate@binkert.org 1396129Snate@binkert.org /** 1406129Snate@binkert.org * Checks if the first stat's name is alphabetically less than the second. 1416129Snate@binkert.org * This function breaks names up at periods and considers each subname 1426129Snate@binkert.org * separately. 1436129Snate@binkert.org * @param stat1 The first stat. 1446129Snate@binkert.org * @param stat2 The second stat. 1456129Snate@binkert.org * @return stat1's name is alphabetically before stat2's 1466129Snate@binkert.org */ 1476129Snate@binkert.org static bool less(Info *stat1, Info *stat2); 1486129Snate@binkert.org}; 1496129Snate@binkert.org 1506129Snate@binkert.orgclass ScalarInfo : public Info 1516129Snate@binkert.org{ 1526129Snate@binkert.org public: 1536129Snate@binkert.org virtual Counter value() const = 0; 1546129Snate@binkert.org virtual Result result() const = 0; 1556129Snate@binkert.org virtual Result total() const = 0; 1566129Snate@binkert.org}; 1576129Snate@binkert.org 1586129Snate@binkert.orgclass VectorInfo : public Info 1596129Snate@binkert.org{ 1606129Snate@binkert.org public: 1616129Snate@binkert.org /** Names and descriptions of subfields. */ 1626129Snate@binkert.org std::vector<std::string> subnames; 1636129Snate@binkert.org std::vector<std::string> subdescs; 1646129Snate@binkert.org 1656129Snate@binkert.org public: 1666129Snate@binkert.org void enable(); 1676129Snate@binkert.org 1686129Snate@binkert.org public: 1696129Snate@binkert.org virtual size_type size() const = 0; 1706129Snate@binkert.org virtual const VCounter &value() const = 0; 1716129Snate@binkert.org virtual const VResult &result() const = 0; 1726129Snate@binkert.org virtual Result total() const = 0; 1736129Snate@binkert.org}; 1746129Snate@binkert.org 1757831Snate@binkert.orgenum DistType { Deviation, Dist, Hist }; 1767505Snate@binkert.org 1776129Snate@binkert.orgstruct DistData 1786129Snate@binkert.org{ 1797505Snate@binkert.org DistType type; 1807505Snate@binkert.org Counter min; 1817505Snate@binkert.org Counter max; 1827505Snate@binkert.org Counter bucket_size; 1837505Snate@binkert.org 1846129Snate@binkert.org Counter min_val; 1856129Snate@binkert.org Counter max_val; 1866129Snate@binkert.org Counter underflow; 1876129Snate@binkert.org Counter overflow; 1886129Snate@binkert.org VCounter cvec; 1896129Snate@binkert.org Counter sum; 1906129Snate@binkert.org Counter squares; 1918666SPrakash.Ramrakhyani@arm.com Counter logs; 1926129Snate@binkert.org Counter samples; 1936129Snate@binkert.org}; 1946129Snate@binkert.org 1956129Snate@binkert.orgclass DistInfo : public Info 1966129Snate@binkert.org{ 1976129Snate@binkert.org public: 1986129Snate@binkert.org /** Local storage for the entry values, used for printing. */ 1996129Snate@binkert.org DistData data; 2006129Snate@binkert.org}; 2016129Snate@binkert.org 2026129Snate@binkert.orgclass VectorDistInfo : public Info 2036129Snate@binkert.org{ 2046129Snate@binkert.org public: 2056129Snate@binkert.org std::vector<DistData> data; 2066129Snate@binkert.org 2076129Snate@binkert.org /** Names and descriptions of subfields. */ 2086129Snate@binkert.org std::vector<std::string> subnames; 2096129Snate@binkert.org std::vector<std::string> subdescs; 2106129Snate@binkert.org void enable(); 2116129Snate@binkert.org 2126129Snate@binkert.org protected: 2136129Snate@binkert.org /** Local storage for the entry values, used for printing. */ 2146129Snate@binkert.org mutable VResult rvec; 2156129Snate@binkert.org 2166129Snate@binkert.org public: 2176129Snate@binkert.org virtual size_type size() const = 0; 2186129Snate@binkert.org}; 2196129Snate@binkert.org 2206129Snate@binkert.orgclass Vector2dInfo : public Info 2216129Snate@binkert.org{ 2226129Snate@binkert.org public: 2236129Snate@binkert.org /** Names and descriptions of subfields. */ 2246129Snate@binkert.org std::vector<std::string> subnames; 2256129Snate@binkert.org std::vector<std::string> subdescs; 2266129Snate@binkert.org std::vector<std::string> y_subnames; 2276129Snate@binkert.org 2286129Snate@binkert.org size_type x; 2296129Snate@binkert.org size_type y; 2306129Snate@binkert.org 2316129Snate@binkert.org /** Local storage for the entry values, used for printing. */ 2326129Snate@binkert.org mutable VCounter cvec; 2336129Snate@binkert.org 2346129Snate@binkert.org void enable(); 23511565Sdavid.guillen@arm.com 23611565Sdavid.guillen@arm.com virtual Result total() const = 0; 2376129Snate@binkert.org}; 2386129Snate@binkert.org 2396129Snate@binkert.orgclass FormulaInfo : public VectorInfo 2406129Snate@binkert.org{ 2416129Snate@binkert.org public: 2426129Snate@binkert.org virtual std::string str() const = 0; 2436129Snate@binkert.org}; 2446129Snate@binkert.org 2458514SThomas.Grass@ARM.com/** Data structure of sparse histogram */ 2468514SThomas.Grass@ARM.comstruct SparseHistData 2478514SThomas.Grass@ARM.com{ 2488514SThomas.Grass@ARM.com MCounter cmap; 2498514SThomas.Grass@ARM.com Counter samples; 2508514SThomas.Grass@ARM.com}; 2518514SThomas.Grass@ARM.com 2528514SThomas.Grass@ARM.com 2538514SThomas.Grass@ARM.comclass SparseHistInfo : public Info 2548514SThomas.Grass@ARM.com{ 2558514SThomas.Grass@ARM.com public: 2568514SThomas.Grass@ARM.com /** Local storage for the entry values, used for printing. */ 2578514SThomas.Grass@ARM.com SparseHistData data; 2588514SThomas.Grass@ARM.com}; 2596129Snate@binkert.org 2607811Ssteve.reinhardt@amd.com} // namespace Stats 2616169Snate@binkert.org 2626169Snate@binkert.org#endif // __BASE_STATS_INFO_HH__ 263