1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
/*
* Copyright (c) 2003-2005 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
#ifndef __BASE_STATS_INFO_HH__
#define __BASE_STATS_INFO_HH__
#include "base/stats/types.hh"
#include "base/flags.hh"
namespace Stats {
typedef uint16_t FlagsType;
typedef ::Flags<FlagsType> Flags;
/** Nothing extra to print. */
const FlagsType none = 0x0000;
/** This Stat is Initialized */
const FlagsType init = 0x0001;
/** Print this stat. */
const FlagsType display = 0x0002;
/** Print the total. */
const FlagsType total = 0x0010;
/** Print the percent of the total that this entry represents. */
const FlagsType pdf = 0x0020;
/** Print the cumulative percentage of total upto this entry. */
const FlagsType cdf = 0x0040;
/** Print the distribution. */
const FlagsType dist = 0x0080;
/** Don't print if this is zero. */
const FlagsType nozero = 0x0100;
/** Don't print if this is NAN */
const FlagsType nonan = 0x0200;
/** Mask of flags that can't be set directly */
const FlagsType __reserved = init | display;
struct StorageParams;
struct Output;
class Info
{
public:
/** The name of the stat. */
std::string name;
/** The separator string used for vectors, dist, etc. */
static std::string separatorString;
/** The description of the stat. */
std::string desc;
/** The formatting flags. */
Flags flags;
/** The display precision. */
int precision;
/** A pointer to a prerequisite Stat. */
const Info *prereq;
/**
* A unique stat ID for each stat in the simulator.
* Can be used externally for lookups as well as for debugging.
*/
static int id_count;
int id;
public:
const StorageParams *storageParams;
public:
Info();
virtual ~Info();
/** Set the name of this statistic */
void setName(const std::string &name);
void setSeparator(std::string _sep) { separatorString = _sep;}
/**
* Check that this stat has been set up properly and is ready for
* use
* @return true for success
*/
virtual bool check() const = 0;
bool baseCheck() const;
/**
* Enable the stat for use
*/
virtual void enable();
/**
* Prepare the stat for dumping.
*/
virtual void prepare() = 0;
/**
* Reset the stat to the default state.
*/
virtual void reset() = 0;
/**
* @return true if this stat has a value and satisfies its
* requirement as a prereq
*/
virtual bool zero() const = 0;
/**
* Visitor entry for outputing statistics data
*/
virtual void visit(Output &visitor) = 0;
/**
* Checks if the first stat's name is alphabetically less than the second.
* This function breaks names up at periods and considers each subname
* separately.
* @param stat1 The first stat.
* @param stat2 The second stat.
* @return stat1's name is alphabetically before stat2's
*/
static bool less(Info *stat1, Info *stat2);
};
class ScalarInfo : public Info
{
public:
virtual Counter value() const = 0;
virtual Result result() const = 0;
virtual Result total() const = 0;
};
class VectorInfo : public Info
{
public:
/** Names and descriptions of subfields. */
std::vector<std::string> subnames;
std::vector<std::string> subdescs;
public:
void enable();
public:
virtual size_type size() const = 0;
virtual const VCounter &value() const = 0;
virtual const VResult &result() const = 0;
virtual Result total() const = 0;
};
enum DistType { Deviation, Dist, Hist };
struct DistData
{
DistType type;
Counter min;
Counter max;
Counter bucket_size;
Counter min_val;
Counter max_val;
Counter underflow;
Counter overflow;
VCounter cvec;
Counter sum;
Counter squares;
Counter samples;
};
class DistInfo : public Info
{
public:
/** Local storage for the entry values, used for printing. */
DistData data;
};
class VectorDistInfo : public Info
{
public:
std::vector<DistData> data;
/** Names and descriptions of subfields. */
std::vector<std::string> subnames;
std::vector<std::string> subdescs;
void enable();
protected:
/** Local storage for the entry values, used for printing. */
mutable VResult rvec;
public:
virtual size_type size() const = 0;
};
class Vector2dInfo : public Info
{
public:
/** Names and descriptions of subfields. */
std::vector<std::string> subnames;
std::vector<std::string> subdescs;
std::vector<std::string> y_subnames;
size_type x;
size_type y;
/** Local storage for the entry values, used for printing. */
mutable VCounter cvec;
void enable();
};
class FormulaInfo : public VectorInfo
{
public:
virtual std::string str() const = 0;
};
/** Data structure of sparse histogram */
struct SparseHistData
{
MCounter cmap;
Counter samples;
};
class SparseHistInfo : public Info
{
public:
/** Local storage for the entry values, used for printing. */
SparseHistData data;
};
} // namespace Stats
#endif // __BASE_STATS_INFO_HH__
|