42#define _GLIBCPP_USE_C99 1
66constexpr auto Nan = std::numeric_limits<float>::quiet_NaN();
76 : mystream(false), stream(NULL), descriptions(false), spaces(false)
103 panic(
"stream already set!");
108 fatal(
"Unable to open output stream for writing\n");
115 panic(
"stream already set!");
118 stream =
new std::ofstream(file.c_str(), std::ios::trunc);
120 fatal(
"Unable to open statistics file for writing\n");
132 ccprintf(*
stream,
"\n---------- Begin Simulation Statistics ----------\n");
138 ccprintf(*
stream,
"\n---------- End Simulation Statistics ----------\n");
164 assert(!
path.empty());
183 std::stringstream
val;
187 val.precision(precision);
188 else if (value == rint(value))
191 val.unsetf(std::ios::showpoint);
192 val.setf(std::ios::fixed);
216 bool enable_descriptions, std::string _desc,
217 bool enable_units, std::string unit_str,
265 void operator()(std::ostream &stream,
bool oneLine =
false)
const;
285 std::stringstream pdfstr, cdfstr;
299 if (
spaces || pdfstr.rdbuf()->in_avail())
301 if (
spaces || cdfstr.rdbuf()->in_avail())
353 print.
pdf = _total ? 0.0 : Nan;
354 print.
cdf = _total ? 0.0 : Nan;
537 std::stringstream namestr;
544 namestr <<
"-" << high;
546 print.
name = namestr.str();
644 bool havesub =
false;
677 yvec[j] = info.
cvec[iy + j];
678 tot_vec[j] += yvec[j];
684 (havesub ? info.
subnames[
i] : std::to_string(
i)));
694 total_subname.push_back(
"total");
781 MCounter::const_iterator it;
783 std::stringstream namestr;
786 namestr <<(*it).first;
787 print.
name = namestr.str();
788 print.
value = (*it).second;
804initText(
const std::string &filename,
bool desc,
bool spaces)
807 static bool connected =
false;
OutputStream * findOrCreate(const std::string &name, bool binary=false)
std::ostream * stream() const
Get the output underlying output stream.
Flags flags
The formatting flags.
const units::Base * unit
The unit of the stat.
std::string name
The name of the stat.
std::string desc
The description of the stat.
virtual bool zero() const =0
static std::string separatorString
The separator string used for vectors, dist, etc.
int precision
The display precision.
const Info * prereq
A pointer to a prerequisite Stat.
virtual Result result() const =0
bool noOutput(const Info &info)
std::string statName(const std::string &name) const
void beginGroup(const char *name) override
std::stack< std::string > path
bool valid() const override
void open(std::ostream &stream)
void visit(const ScalarInfo &info) override
std::vector< std::string > y_subnames
std::vector< std::string > subnames
Names and descriptions of subfields.
VCounter cvec
Local storage for the entry values, used for printing.
virtual Result total() const =0
virtual size_type size() const =0
std::vector< std::string > subdescs
std::vector< std::string > subnames
Names and descriptions of subfields.
virtual const VResult & result() const =0
virtual Result total() const =0
virtual size_type size() const =0
std::vector< std::string > subdescs
std::vector< std::string > subnames
Names and descriptions of subfields.
virtual std::string getUnitString() const =0
bool isSet(Type mask) const
Verifies whether any bit matching the given mask is set.
#define panic(...)
This implements a cprintf based panic() function.
#define fatal(...)
This implements a cprintf based fatal() function.
const FlagsType init
This Stat is Initialized.
std::vector< Result > VResult
vector of results.
const FlagsType pdf
Print the percent of the total that this entry represents.
const FlagsType nonan
Don't print if this is NAN.
std::string ValueToString(Result value, int precision)
const FlagsType oneline
Print all values on a single line.
const FlagsType nozero
Don't print if this is zero.
const FlagsType total
Print the total.
double Counter
All counters are of 64-bit values.
const FlagsType display
Print this stat.
const FlagsType cdf
Print the cumulative percentage of total upto this entry.
std::list< Info * > & statsList()
double Result
All results are doubles.
Output * initText(const std::string &filename, bool desc, bool spaces)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::string csprintf(const char *format, const Args &...args)
void ccprintf(cp::Print &print)
constexpr bool isnan(gem5::AMDGPU::fp16_e5m10_info a)
BasePrint(bool _spaces=false)
void printUnits(std::ostream &stream) const
void setup(std::string _name, Flags _flags, int _precision, bool enable_descriptions, std::string _desc, bool enable_units, std::string unit_str, bool enable_spaces)
General container for distribution data.
void operator()(std::ostream &stream) const
std::string separatorString
void init(const Text *text, const Info &info)
DistPrint(const Text *text, const DistInfo &info)
void operator()(std::ostream &stream, bool oneLine=false) const
void update(Result val, Result total)
Data structure of sparse histogram.
std::string separatorString
const SparseHistData & data
void init(const Text *text, const Info &info)
void operator()(std::ostream &stream) const
SparseHistPrint(const Text *text, const SparseHistInfo &info)
void operator()(std::ostream &stream) const
std::string separatorString
std::vector< std::string > subdescs
std::vector< std::string > subnames
const std::string & name()