gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
43namespace gem5
44{
45
46namespace statistics
47{
48
49typedef uint16_t FlagsType;
51
53const FlagsType none = 0x0000;
55const FlagsType init = 0x0001;
57const FlagsType display = 0x0002;
59const FlagsType total = 0x0010;
61const FlagsType pdf = 0x0020;
63const FlagsType cdf = 0x0040;
65const FlagsType dist = 0x0080;
67const FlagsType nozero = 0x0100;
69const FlagsType nonan = 0x0200;
71const FlagsType oneline = 0x0400;
72
75
76struct StorageParams;
77struct Output;
78
79class Info
80{
81 public:
83 std::string name;
85 static std::string separatorString;
89 std::string desc;
95 const Info *prereq;
100 static int id_count;
101 int id;
102
103 private:
104 std::unique_ptr<const StorageParams> storageParams;
105
106 public:
107 Info();
108 virtual ~Info();
109
117 void setName(const std::string &name, bool old_style=true);
118
119 void setSeparator(std::string _sep) { separatorString = _sep;}
120
126 StorageParams const* getStorageParams() const;
128 void setStorageParams(const StorageParams *const params);
129
135 virtual bool check() const = 0;
136 bool baseCheck() const;
137
141 virtual void enable();
142
146 virtual void prepare() = 0;
147
151 virtual void reset() = 0;
152
157 virtual bool zero() const = 0;
158
162 virtual void visit(Output &visitor) = 0;
163
172 static bool less(Info *stat1, Info *stat2);
173};
174
175class ScalarInfo : public Info
176{
177 public:
178 virtual Counter value() const = 0;
179 virtual Result result() const = 0;
180 virtual Result total() const = 0;
181};
182
183class VectorInfo : public Info
184{
185 public:
189
190 public:
191 void enable();
192
193 public:
194 virtual size_type size() const = 0;
195 virtual const VCounter &value() const = 0;
196 virtual const VResult &result() const = 0;
197 virtual Result total() const = 0;
198};
199
200class DistInfo : public Info
201{
202 public:
205};
206
207class VectorDistInfo : public Info
208{
209 public:
211
215 void enable();
216
217 protected:
219 mutable VResult rvec;
220
221 public:
222 virtual size_type size() const = 0;
223};
224
243
245{
246 public:
247 virtual std::string str() const = 0;
248};
249
250class SparseHistInfo : public Info
251{
252 public:
255};
256
257typedef std::map<std::string, Info *> NameMapType;
259
260} // namespace statistics
261} // namespace gem5
262
263#endif // __BASE_STATS_INFO_HH__
Wrapper that groups a few flag bits under the same undelying container.
Definition flags.hh:45
DistData data
Local storage for the entry values, used for printing.
Definition info.hh:204
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:127
std::unique_ptr< const StorageParams > storageParams
Definition info.hh:104
virtual ~Info()
Definition info.cc:79
Flags flags
The formatting flags.
Definition info.hh:91
StorageParams const * getStorageParams() const
Getter for the storage params.
Definition info.cc:84
const units::Base * unit
The unit of the stat.
Definition info.hh:87
virtual void enable()
Enable the stat for use.
Definition info.cc:192
void setStorageParams(const StorageParams *const params)
Setter for the storage params.
Definition info.cc:90
std::string name
The name of the stat.
Definition info.hh:83
std::string desc
The description of the stat.
Definition info.hh:89
static int id_count
A unique stat ID for each stat in the simulator.
Definition info.hh:100
virtual bool zero() const =0
static std::string separatorString
The separator string used for vectors, dist, etc.
Definition info.hh:85
virtual void prepare()=0
Prepare the stat for dumping.
int precision
The display precision.
Definition info.hh:93
bool baseCheck() const
Definition info.cc:172
const Info * prereq
A pointer to a prerequisite Stat.
Definition info.hh:95
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:146
void setSeparator(std::string _sep)
Definition info.hh:119
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:254
void enable()
Enable the stat for use.
Definition info.cc:217
std::vector< std::string > subdescs
Definition info.hh:230
std::vector< std::string > y_subnames
Definition info.hh:231
std::vector< std::string > subnames
Names and descriptions of subfields.
Definition info.hh:229
VCounter cvec
Local storage for the entry values, used for printing.
Definition info.hh:237
virtual Result total() const =0
VResult rvec
Local storage for the entry values, used for printing.
Definition info.hh:219
virtual size_type size() const =0
void enable()
Enable the stat for use.
Definition info.cc:207
std::vector< std::string > subdescs
Definition info.hh:214
std::vector< DistData > data
Definition info.hh:210
std::vector< std::string > subnames
Names and descriptions of subfields.
Definition info.hh:213
virtual const VResult & result() const =0
virtual Result total() const =0
void enable()
Enable the stat for use.
Definition info.cc:197
virtual size_type size() const =0
virtual const VCounter & value() const =0
std::vector< std::string > subdescs
Definition info.hh:188
std::vector< std::string > subnames
Names and descriptions of subfields.
Definition info.hh:187
The Base class is the parent class of all unit classes.
Definition units.hh:121
static Unspecified * get()
Definition units.hh:327
STL vector class.
Definition stl.hh:37
unsigned int size_type
Definition types.hh:59
const FlagsType init
This Stat is Initialized.
Definition info.hh:55
const FlagsType pdf
Print the percent of the total that this entry represents.
Definition info.hh:61
NameMapType & nameMap()
Definition info.cc:65
const FlagsType nonan
Don't print if this is NAN.
Definition info.hh:69
uint16_t FlagsType
Definition info.hh:49
const FlagsType oneline
Print all values on a single line.
Definition info.hh:71
const FlagsType nozero
Don't print if this is zero.
Definition info.hh:67
const FlagsType total
Print the total.
Definition info.hh:59
double Counter
All counters are of 64-bit values.
Definition types.hh:46
gem5::Flags< FlagsType > Flags
Definition info.hh:50
std::map< std::string, Info * > NameMapType
Definition info.hh:257
const FlagsType display
Print this stat.
Definition info.hh:57
const FlagsType cdf
Print the cumulative percentage of total upto this entry.
Definition info.hh:63
const FlagsType dist
Print the distribution.
Definition info.hh:65
const FlagsType none
Nothing extra to print.
Definition info.hh:53
const FlagsType __reserved
Mask of flags that can't be set directly.
Definition info.hh:74
double Result
All results are doubles.
Definition types.hh:55
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
General container for distribution data.
Definition types.hh:66
Data structure of sparse histogram.
Definition types.hh:85

Generated on Tue Jun 18 2024 16:24:01 for gem5 by doxygen 1.11.0