stats: remove simplescalar compatibility for printing

This commit is contained in:
Nathan Binkert 2009-04-22 10:25:14 -07:00
parent 61a68371be
commit ca3d82b38a
5 changed files with 76 additions and 191 deletions

View file

@ -57,11 +57,9 @@ const StatFlags dist = 0x00000080;
const StatFlags nozero = 0x00000100; const StatFlags nozero = 0x00000100;
/** Don't print if this is NAN */ /** Don't print if this is NAN */
const StatFlags nonan = 0x00000200; const StatFlags nonan = 0x00000200;
/** Used for SS compatability. */
const StatFlags __substat = 0x80000000;
/** Mask of flags that can't be set directly */ /** Mask of flags that can't be set directly */
const StatFlags __reserved = init | print | __substat; const StatFlags __reserved = init | print;
enum DisplayMode enum DisplayMode
{ {

View file

@ -73,18 +73,18 @@ __nan()
namespace Stats { namespace Stats {
Text::Text() Text::Text()
: mystream(false), stream(NULL), compat(false), descriptions(false) : mystream(false), stream(NULL), descriptions(false)
{ {
} }
Text::Text(std::ostream &stream) Text::Text(std::ostream &stream)
: mystream(false), stream(NULL), compat(false), descriptions(false) : mystream(false), stream(NULL), descriptions(false)
{ {
open(stream); open(stream);
} }
Text::Text(const std::string &file) Text::Text(const std::string &file)
: mystream(false), stream(NULL), compat(false), descriptions(false) : mystream(false), stream(NULL), descriptions(false)
{ {
open(file); open(file);
} }
@ -152,7 +152,7 @@ Text::noOutput(const Info &info)
} }
string string
ValueToString(Result value, int precision, bool compat) ValueToString(Result value, int precision)
{ {
stringstream val; stringstream val;
@ -166,7 +166,7 @@ ValueToString(Result value, int precision, bool compat)
val.setf(ios::fixed); val.setf(ios::fixed);
val << value; val << value;
} else { } else {
val << (compat ? "<err: div-0>" : "no value"); val << "no_value";
} }
return val.str(); return val.str();
@ -178,7 +178,6 @@ struct ScalarPrint
string name; string name;
string desc; string desc;
StatFlags flags; StatFlags flags;
bool compat;
bool descriptions; bool descriptions;
int precision; int precision;
Result pdf; Result pdf;
@ -202,13 +201,8 @@ ScalarPrint::operator()(ostream &stream) const
if (!isnan(cdf)) if (!isnan(cdf))
ccprintf(cdfstr, "%.2f%%", cdf * 100.0); ccprintf(cdfstr, "%.2f%%", cdf * 100.0);
if (compat && flags & __substat) { ccprintf(stream, "%-40s %12s %10s %10s", name,
ccprintf(stream, "%32s %12s %10s %10s", name, ValueToString(value, precision), pdfstr, cdfstr);
ValueToString(value, precision, compat), pdfstr, cdfstr);
} else {
ccprintf(stream, "%-40s %12s %10s %10s", name,
ValueToString(value, precision, compat), pdfstr, cdfstr);
}
if (descriptions) { if (descriptions) {
if (!desc.empty()) if (!desc.empty())
@ -224,7 +218,6 @@ struct VectorPrint
vector<string> subnames; vector<string> subnames;
vector<string> subdescs; vector<string> subdescs;
StatFlags flags; StatFlags flags;
bool compat;
bool descriptions; bool descriptions;
int precision; int precision;
VResult vec; VResult vec;
@ -245,12 +238,11 @@ VectorPrint::operator()(std::ostream &stream) const
} }
} }
string base = name + (compat ? "_" : "::"); string base = name + "::";
ScalarPrint print; ScalarPrint print;
print.name = name; print.name = name;
print.desc = desc; print.desc = desc;
print.compat = compat;
print.precision = precision; print.precision = precision;
print.descriptions = descriptions; print.descriptions = descriptions;
print.flags = flags; print.flags = flags;
@ -262,83 +254,32 @@ VectorPrint::operator()(std::ostream &stream) const
if (_size == 1) { if (_size == 1) {
print.value = vec[0]; print.value = vec[0];
print(stream); print(stream);
} else if (!compat) { return;
for (off_type i = 0; i < _size; ++i) { }
if (havesub && (i >= subnames.size() || subnames[i].empty()))
continue;
print.name = base + (havesub ? subnames[i] : to_string(i)); for (off_type i = 0; i < _size; ++i) {
print.desc = subdescs.empty() ? desc : subdescs[i]; if (havesub && (i >= subnames.size() || subnames[i].empty()))
print.value = vec[i]; continue;
if (_total && (flags & pdf)) { print.name = base + (havesub ? subnames[i] : to_string(i));
print.pdf = vec[i] / _total; print.desc = subdescs.empty() ? desc : subdescs[i];
print.cdf += print.pdf; print.value = vec[i];
}
print(stream); if (_total && flags & pdf) {
print.pdf = vec[i] / _total;
print.cdf += print.pdf;
} }
if (flags & ::Stats::total) { print(stream);
print.name = base + "total"; }
print.desc = desc;
print.value = total;
print(stream);
}
} else {
if (flags & ::Stats::total) {
print.value = total;
print(stream);
}
Result _pdf = 0.0; if (flags & ::Stats::total) {
Result _cdf = 0.0; print.pdf = NAN;
if (flags & dist) { print.cdf = NAN;
ccprintf(stream, "%s.start_dist\n", name); print.name = base + "total";
for (off_type i = 0; i < _size; ++i) { print.desc = desc;
print.name = havesub ? subnames[i] : to_string(i); print.value = total;
print.desc = subdescs.empty() ? desc : subdescs[i]; print(stream);
print.flags |= __substat;
print.value = vec[i];
if (_total) {
_pdf = vec[i] / _total;
_cdf += _pdf;
}
if (flags & pdf)
print.pdf = _pdf;
if (flags & cdf)
print.cdf = _cdf;
print(stream);
}
ccprintf(stream, "%s.end_dist\n", name);
} else {
for (off_type i = 0; i < _size; ++i) {
if (havesub && subnames[i].empty())
continue;
print.name = base;
print.name += havesub ? subnames[i] : to_string(i);
print.desc = subdescs.empty() ? desc : subdescs[i];
print.value = vec[i];
if (_total) {
_pdf = vec[i] / _total;
_cdf += _pdf;
} else {
_pdf = _cdf = NAN;
}
if (flags & pdf) {
print.pdf = _pdf;
print.cdf = _cdf;
}
print(stream);
}
}
} }
} }
@ -347,7 +288,6 @@ struct DistPrint
string name; string name;
string desc; string desc;
StatFlags flags; StatFlags flags;
bool compat;
bool descriptions; bool descriptions;
int precision; int precision;
@ -390,7 +330,6 @@ DistPrint::init(const Text *text, const Info &info, const DistParams *params)
desc = info.desc; desc = info.desc;
flags = info.flags; flags = info.flags;
precision = info.precision; precision = info.precision;
compat = text->compat;
descriptions = text->descriptions; descriptions = text->descriptions;
fancy = params->fancy; fancy = params->fancy;
@ -410,11 +349,10 @@ DistPrint::operator()(ostream &stream) const
if (fancy) { if (fancy) {
ScalarPrint print; ScalarPrint print;
string base = name + (compat ? "_" : "::"); string base = name + "::";
print.precision = precision; print.precision = precision;
print.flags = flags; print.flags = flags;
print.compat = compat;
print.descriptions = descriptions; print.descriptions = descriptions;
print.desc = desc; print.desc = desc;
print.pdf = NAN; print.pdf = NAN;
@ -443,24 +381,16 @@ DistPrint::operator()(ostream &stream) const
total += data.cvec[i]; total += data.cvec[i];
total += data.overflow; total += data.overflow;
string base = name + (compat ? "." : "::"); string base = name + "::";
ScalarPrint print; ScalarPrint print;
print.desc = compat ? "" : desc; print.desc = desc;
print.flags = flags; print.flags = flags;
print.compat = compat;
print.descriptions = descriptions; print.descriptions = descriptions;
print.precision = precision; print.precision = precision;
print.pdf = NAN; print.pdf = NAN;
print.cdf = NAN; print.cdf = NAN;
if (compat) {
ccprintf(stream, "%-42s", base + "start_dist");
if (descriptions && !desc.empty())
ccprintf(stream, " # %s", desc);
stream << endl;
}
print.name = base + "samples"; print.name = base + "samples";
print.value = data.samples; print.value = data.samples;
print(stream); print(stream);
@ -469,100 +399,62 @@ DistPrint::operator()(ostream &stream) const
print.value = data.min_val; print.value = data.min_val;
print(stream); print(stream);
if (!compat || data.underflow > 0.0) { print.name = base + "underflows";
print.name = base + "underflows"; print.value = data.underflow;
print.value = data.underflow; if (total) {
if (!compat && total) { print.pdf = data.underflow / total;
print.pdf = data.underflow / total; print.cdf += print.pdf;
}
print(stream);
for (off_type i = 0; i < size; ++i) {
stringstream namestr;
namestr << base;
Counter low = i * bucket_size + min;
Counter high = ::min(low + bucket_size, max);
namestr << low;
if (low < high)
namestr << "-" << high;
print.name = namestr.str();
print.value = data.cvec[i];
if (total) {
print.pdf = data.cvec[i] / total;
print.cdf += print.pdf; print.cdf += print.pdf;
} }
print(stream); print(stream);
} }
if (!compat) { print.name = base + "overflows";
for (off_type i = 0; i < size; ++i) { print.value = data.overflow;
stringstream namestr; if (total) {
namestr << base; print.pdf = data.overflow / total;
print.cdf += print.pdf;
Counter low = i * bucket_size + min;
Counter high = ::min(low + bucket_size, max);
namestr << low;
if (low < high)
namestr << "-" << high;
print.name = namestr.str();
print.value = data.cvec[i];
if (total) {
print.pdf = data.cvec[i] / total;
print.cdf += print.pdf;
}
print(stream);
}
} else { } else {
Counter _min; print.pdf = NAN;
Result _pdf; print.cdf = NAN;
Result _cdf = 0.0;
print.flags = flags | __substat;
for (off_type i = 0; i < size; ++i) {
if ((flags & nozero && data.cvec[i] == 0.0) ||
(flags & nonan && isnan(data.cvec[i])))
continue;
_min = i * bucket_size + min;
_pdf = data.cvec[i] / total * 100.0;
_cdf += _pdf;
print.name = ValueToString(_min, 0, compat);
print.value = data.cvec[i];
print.pdf = (flags & pdf) ? _pdf : NAN;
print.cdf = (flags & cdf) ? _cdf : NAN;
print(stream);
}
print.flags = flags;
}
if (!compat || data.overflow > 0.0) {
print.name = base + "overflows";
print.value = data.overflow;
if (!compat && total) {
print.pdf = data.overflow / total;
print.cdf += print.pdf;
} else {
print.pdf = NAN;
print.cdf = NAN;
}
print(stream);
} }
print(stream);
print.pdf = NAN; print.pdf = NAN;
print.cdf = NAN; print.cdf = NAN;
if (!compat) { print.name = base + "total";
print.name = base + "total"; print.value = total;
print.value = total; print(stream);
print(stream);
}
print.name = base + "max_value"; print.name = base + "max_value";
print.value = data.max_val; print.value = data.max_val;
print(stream); print(stream);
if (!compat && data.samples != 0) { print.name = base + "mean";
print.name = base + "mean"; print.value = data.sum / data.samples;
print.value = data.sum / data.samples; print(stream);
print(stream);
print.name = base + "stdev"; print.name = base + "stdev";
print.value = stdev; print.value = stdev;
print(stream); print(stream);
}
if (compat)
ccprintf(stream, "%send_dist\n\n", base);
} }
void void
@ -576,7 +468,6 @@ Text::visit(const ScalarInfoBase &info)
print.name = info.name; print.name = info.name;
print.desc = info.desc; print.desc = info.desc;
print.flags = info.flags; print.flags = info.flags;
print.compat = compat;
print.descriptions = descriptions; print.descriptions = descriptions;
print.precision = info.precision; print.precision = info.precision;
print.pdf = NAN; print.pdf = NAN;
@ -597,7 +488,6 @@ Text::visit(const VectorInfoBase &info)
print.name = info.name; print.name = info.name;
print.desc = info.desc; print.desc = info.desc;
print.flags = info.flags; print.flags = info.flags;
print.compat = compat;
print.descriptions = descriptions; print.descriptions = descriptions;
print.precision = info.precision; print.precision = info.precision;
print.vec = info.result(); print.vec = info.result();
@ -635,7 +525,6 @@ Text::visit(const Vector2dInfoBase &info)
print.subnames = info.y_subnames; print.subnames = info.y_subnames;
print.flags = info.flags; print.flags = info.flags;
print.compat = compat;
print.descriptions = descriptions; print.descriptions = descriptions;
print.precision = info.precision; print.precision = info.precision;
@ -708,7 +597,7 @@ Text::visit(const FormulaInfoBase &info)
} }
bool bool
initText(const string &filename, bool desc, bool compat) initText(const string &filename, bool desc)
{ {
static Text text; static Text text;
static bool connected = false; static bool connected = false;
@ -720,7 +609,6 @@ initText(const string &filename, bool desc, bool compat)
text.open(*simout.find(filename)); text.open(*simout.find(filename));
text.descriptions = desc; text.descriptions = desc;
text.compat = compat;
OutputList.push_back(&text); OutputList.push_back(&text);
connected = true; connected = true;

View file

@ -49,7 +49,6 @@ class Text : public Output
bool noOutput(const Info &info); bool noOutput(const Info &info);
public: public:
bool compat;
bool descriptions; bool descriptions;
public: public:
@ -77,7 +76,7 @@ class Text : public Output
virtual void event(const std::string &event) {} virtual void event(const std::string &event) {}
}; };
bool initText(const std::string &filename, bool desc=true, bool compat=true); bool initText(const std::string &filename, bool desc);
/* namespace Stats */ } /* namespace Stats */ }

View file

@ -30,8 +30,8 @@ import internal
from internal.stats import StatEvent as event from internal.stats import StatEvent as event
def initText(filename, desc=True, compat=True): def initText(filename, desc=True):
internal.stats.initText(filename, desc, compat) internal.stats.initText(filename, desc)
def initMySQL(host, database, user='', passwd='', project='test', name='test', def initMySQL(host, database, user='', passwd='', project='test', name='test',
sample='0'): sample='0'):

View file

@ -41,7 +41,7 @@
namespace Stats { namespace Stats {
void initSimStats(); void initSimStats();
void initText(const std::string &filename, bool desc=true, bool compat=true); void initText(const std::string &filename, bool desc);
void initMySQL(std::string host, std::string database, std::string user, void initMySQL(std::string host, std::string database, std::string user,
std::string passwd, std::string project, std::string name, std::string passwd, std::string project, std::string name,
std::string sample); std::string sample);