gem5  v22.1.0.0
info.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2005 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __BASE_STATS_INFO_HH__
30 #define __BASE_STATS_INFO_HH__
31 
32 #include <cstdint>
33 #include <map>
34 #include <memory>
35 #include <string>
36 #include <vector>
37 
38 #include "base/compiler.hh"
39 #include "base/flags.hh"
40 #include "base/stats/types.hh"
41 #include "base/stats/units.hh"
42 
43 namespace gem5
44 {
45 
46 GEM5_DEPRECATED_NAMESPACE(Stats, statistics);
47 namespace statistics
48 {
49 
50 typedef uint16_t FlagsType;
52 
54 const FlagsType none = 0x0000;
56 const FlagsType init = 0x0001;
58 const FlagsType display = 0x0002;
60 const FlagsType total = 0x0010;
62 const FlagsType pdf = 0x0020;
64 const FlagsType cdf = 0x0040;
66 const FlagsType dist = 0x0080;
68 const FlagsType nozero = 0x0100;
70 const FlagsType nonan = 0x0200;
72 const FlagsType oneline = 0x0400;
73 
76 
77 struct StorageParams;
78 struct Output;
79 
80 class Info
81 {
82  public:
84  std::string name;
86  static std::string separatorString;
90  std::string desc;
94  int precision;
96  const Info *prereq;
101  static int id_count;
102  int id;
103 
104  private:
105  std::unique_ptr<const StorageParams> storageParams;
106 
107  public:
108  Info();
109  virtual ~Info();
110 
118  void setName(const std::string &name, bool old_style=true);
119 
120  void setSeparator(std::string _sep) { separatorString = _sep;}
121 
127  StorageParams const* getStorageParams() const;
129  void setStorageParams(const StorageParams *const params);
130 
136  virtual bool check() const = 0;
137  bool baseCheck() const;
138 
142  virtual void enable();
143 
147  virtual void prepare() = 0;
148 
152  virtual void reset() = 0;
153 
158  virtual bool zero() const = 0;
159 
163  virtual void visit(Output &visitor) = 0;
164 
173  static bool less(Info *stat1, Info *stat2);
174 };
175 
176 class ScalarInfo : public Info
177 {
178  public:
179  virtual Counter value() const = 0;
180  virtual Result result() const = 0;
181  virtual Result total() const = 0;
182 };
183 
184 class VectorInfo : public Info
185 {
186  public:
190 
191  public:
192  void enable();
193 
194  public:
195  virtual size_type size() const = 0;
196  virtual const VCounter &value() const = 0;
197  virtual const VResult &result() const = 0;
198  virtual Result total() const = 0;
199 };
200 
201 class DistInfo : public Info
202 {
203  public:
206 };
207 
208 class VectorDistInfo : public Info
209 {
210  public:
212 
216  void enable();
217 
218  protected:
220  mutable VResult rvec;
221 
222  public:
223  virtual size_type size() const = 0;
224 };
225 
226 class Vector2dInfo : public Info
227 {
228  public:
233 
236 
238  mutable VCounter cvec;
239 
240  void enable();
241 
242  virtual Result total() const = 0;
243 };
244 
245 class FormulaInfo : public VectorInfo
246 {
247  public:
248  virtual std::string str() const = 0;
249 };
250 
251 class SparseHistInfo : public Info
252 {
253  public:
256 };
257 
258 typedef std::map<std::string, Info *> NameMapType;
260 
261 } // namespace statistics
262 } // namespace gem5
263 
264 #endif // __BASE_STATS_INFO_HH__
DistData data
Local storage for the entry values, used for printing.
Definition: info.hh:205
virtual std::string str() const =0
void setName(const std::string &name, bool old_style=true)
Set the name of this statistic.
Definition: info.cc:128
std::unique_ptr< const StorageParams > storageParams
Definition: info.hh:105
virtual ~Info()
Definition: info.cc:80
Flags flags
The formatting flags.
Definition: info.hh:92
StorageParams const * getStorageParams() const
Getter for the storage params.
Definition: info.cc:85
const units::Base * unit
The unit of the stat.
Definition: info.hh:88
virtual void enable()
Enable the stat for use.
Definition: info.cc:195
void setStorageParams(const StorageParams *const params)
Setter for the storage params.
Definition: info.cc:91
std::string name
The name of the stat.
Definition: info.hh:84
std::string desc
The description of the stat.
Definition: info.hh:90
static int id_count
A unique stat ID for each stat in the simulator.
Definition: info.hh:101
virtual bool zero() const =0
static std::string separatorString
The separator string used for vectors, dist, etc.
Definition: info.hh:86
virtual void prepare()=0
Prepare the stat for dumping.
int precision
The display precision.
Definition: info.hh:94
bool baseCheck() const
Definition: info.cc:173
const Info * prereq
A pointer to a prerequisite Stat.
Definition: info.hh:96
virtual void reset()=0
Reset the stat to the default state.
virtual void visit(Output &visitor)=0
Visitor entry for outputing statistics data.
static bool less(Info *stat1, Info *stat2)
Checks if the first stat's name is alphabetically less than the second.
Definition: info.cc:147
void setSeparator(std::string _sep)
Definition: info.hh:120
virtual bool check() const =0
Check that this stat has been set up properly and is ready for use.
virtual Result total() const =0
virtual Result result() const =0
virtual Counter value() const =0
SparseHistData data
Local storage for the entry values, used for printing.
Definition: info.hh:255
void enable()
Enable the stat for use.
Definition: info.cc:220
std::vector< std::string > subdescs
Definition: info.hh:231
std::vector< std::string > y_subnames
Definition: info.hh:232
std::vector< std::string > subnames
Names and descriptions of subfields.
Definition: info.hh:230
VCounter cvec
Local storage for the entry values, used for printing.
Definition: info.hh:238
virtual Result total() const =0
VResult rvec
Local storage for the entry values, used for printing.
Definition: info.hh:220
virtual size_type size() const =0
void enable()
Enable the stat for use.
Definition: info.cc:210
std::vector< std::string > subdescs
Definition: info.hh:215
std::vector< DistData > data
Definition: info.hh:211
std::vector< std::string > subnames
Names and descriptions of subfields.
Definition: info.hh:214
virtual const VCounter & value() const =0
virtual Result total() const =0
void enable()
Enable the stat for use.
Definition: info.cc:200
virtual size_type size() const =0
virtual const VResult & result() const =0
std::vector< std::string > subdescs
Definition: info.hh:189
std::vector< std::string > subnames
Names and descriptions of subfields.
Definition: info.hh:188
The Base class is the parent class of all unit classes.
Definition: units.hh:123
static Unspecified * get()
Definition: units.hh:329
unsigned int size_type
Definition: types.hh:60
const FlagsType init
This Stat is Initialized.
Definition: info.hh:56
const FlagsType pdf
Print the percent of the total that this entry represents.
Definition: info.hh:62
NameMapType & nameMap()
Definition: info.cc:66
const FlagsType nonan
Don't print if this is NAN.
Definition: info.hh:70
uint16_t FlagsType
Definition: info.hh:50
const FlagsType oneline
Print all values on a single line.
Definition: info.hh:72
const FlagsType nozero
Don't print if this is zero.
Definition: info.hh:68
const FlagsType total
Print the total.
Definition: info.hh:60
double Counter
All counters are of 64-bit values.
Definition: types.hh:47
gem5::Flags< FlagsType > Flags
Definition: info.hh:51
std::map< std::string, Info * > NameMapType
Definition: info.hh:258
const FlagsType display
Print this stat.
Definition: info.hh:58
const FlagsType cdf
Print the cumulative percentage of total upto this entry.
Definition: info.hh:64
const FlagsType dist
Print the distribution.
Definition: info.hh:66
const FlagsType none
Nothing extra to print.
Definition: info.hh:54
const FlagsType __reserved
Mask of flags that can't be set directly.
Definition: info.hh:75
double Result
All results are doubles.
Definition: types.hh:56
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
General container for distribution data.
Definition: types.hh:67
Data structure of sparse histogram.
Definition: types.hh:86

Generated on Wed Dec 21 2022 10:22:29 for gem5 by doxygen 1.9.1