changeset 436a74146cbc in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=436a74146cbc
description:
stats: allow printing vectors on a single line
This patch adds a new flag to specify if the data values for a given
vector
should be printed in one line in the stats.txt file. The default
behavior
will be to print the data in multiple lines. It makes changes to print
functions to enforce this behavior.
diffstat:
src/base/stats/info.hh | 2 +
src/base/stats/text.cc | 55 ++++++++++++++++++++++++++++++++++++-------------
2 files changed, 42 insertions(+), 15 deletions(-)
diffs (109 lines):
diff -r 69bd8491175a -r 436a74146cbc src/base/stats/info.hh
--- a/src/base/stats/info.hh Sat Jun 08 21:57:02 2013 -0500
+++ b/src/base/stats/info.hh Sun Jun 09 07:29:57 2013 -0500
@@ -57,6 +57,8 @@
const FlagsType nozero = 0x0100;
/** Don't print if this is NAN */
const FlagsType nonan = 0x0200;
+/** Print all values on a single line. Useful only for histograms. */
+const FlagsType oneline = 0x0400;
/** Mask of flags that can't be set directly */
const FlagsType __reserved = init | display;
diff -r 69bd8491175a -r 436a74146cbc src/base/stats/text.cc
--- a/src/base/stats/text.cc Sat Jun 08 21:57:02 2013 -0500
+++ b/src/base/stats/text.cc Sun Jun 09 07:29:57 2013 -0500
@@ -194,7 +194,7 @@
Result cdf;
void update(Result val, Result total);
- void operator()(ostream &stream) const;
+ void operator()(ostream &stream, bool oneLine = false) const;
};
void
@@ -208,7 +208,7 @@
}
void
-ScalarPrint::operator()(ostream &stream) const
+ScalarPrint::operator()(ostream &stream, bool oneLine) const
{
if ((flags.isSet(nozero) && value == 0.0) ||
(flags.isSet(nonan) && std::isnan(value)))
@@ -222,14 +222,19 @@
if (!std::isnan(cdf))
ccprintf(cdfstr, "%.2f%%", cdf * 100.0);
- ccprintf(stream, "%-40s %12s %10s %10s", name,
- ValueToString(value, precision), pdfstr.str(), cdfstr.str());
+ if (oneLine) {
+ ccprintf(stream, " |%12s %10s %10s",
+ ValueToString(value, precision), pdfstr.str(), cdfstr.str());
+ } else {
+ ccprintf(stream, "%-40s %12s %10s %10s", name,
+ ValueToString(value, precision), pdfstr.str(), cdfstr.str());
- if (descriptions) {
- if (!desc.empty())
- ccprintf(stream, " # %s", desc);
+ if (descriptions) {
+ if (!desc.empty())
+ ccprintf(stream, " # %s", desc);
+ }
+ stream << endl;
}
- stream << endl;
}
struct VectorPrint
@@ -279,15 +284,31 @@
return;
}
- for (off_type i = 0; i < _size; ++i) {
- if (havesub && (i >= subnames.size() || subnames[i].empty()))
- continue;
+ if ((!flags.isSet(nozero)) || (total != 0)) {
+ if (flags.isSet(oneline)) {
+ ccprintf(stream, "%-40s", name);
+ print.flags = print.flags & (~nozero);
+ }
- print.name = base + (havesub ? subnames[i] : to_string(i));
- print.desc = subdescs.empty() ? desc : subdescs[i];
+ for (off_type i = 0; i < _size; ++i) {
+ if (havesub && (i >= subnames.size() || subnames[i].empty()))
+ continue;
- print.update(vec[i], _total);
- print(stream);
+ print.name = base + (havesub ? subnames[i] : to_string(i));
+ print.desc = subdescs.empty() ? desc : subdescs[i];
+
+ print.update(vec[i], _total);
+ print(stream, flags.isSet(oneline));
+ }
+
+ if (flags.isSet(oneline)) {
+ if (descriptions) {
+ if (!desc.empty())
+ ccprintf(stream, " # %s", desc);
+ }
+
+ stream << endl;
+ }
}
if (flags.isSet(::Stats::total)) {
@@ -298,6 +319,10 @@
print.value = total;
print(stream);
}
+
+ if (flags.isSet(oneline) && ((!flags.isSet(nozero)) || (total != 0))) {
+ stream << endl;
+ }
}
struct DistPrint
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev