changeset 4807b780ed0a in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=4807b780ed0a
description:
stats: Fix issue when printing 2D vectors
This patch addresses an issue with the text-based stats output which
resulted in Vector2D stats being printed without subnames in the event
that one of the dimensions was of length 1.
This patch also fixes the total printing for the 2D vector. Previously
totals were printed without explicitly stating that a total was being
printed. This has been rectified in this patch.
diffstat:
src/base/stats/text.cc | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diffs (68 lines):
diff -r f47274776aa0 -r 4807b780ed0a src/base/stats/text.cc
--- a/src/base/stats/text.cc Mon Aug 19 03:52:28 2013 -0400
+++ b/src/base/stats/text.cc Mon Aug 19 03:52:29 2013 -0400
@@ -249,6 +249,7 @@
int precision;
VResult vec;
Result total;
+ bool forceSubnames = false;
void operator()(ostream &stream) const;
};
@@ -279,6 +280,11 @@
bool havesub = !subnames.empty();
if (_size == 1) {
+ // If forceSubnames is set, get the first subname (or index in
+ // the case where there are no subnames) and append it to the
+ // base name.
+ if (forceSubnames)
+ print.name = base + (havesub ? subnames[0] : to_string(0));
print.value = vec[0];
print(stream);
return;
@@ -550,6 +556,7 @@
print.separatorString = info.separatorString;
print.descriptions = descriptions;
print.precision = info.precision;
+ print.forceSubnames = true;
if (!info.subnames.empty()) {
for (off_type i = 0; i < info.x; ++i)
@@ -558,7 +565,7 @@
}
VResult tot_vec(info.y);
- Result super_total = 0.0;
+ VResult super_total(1, 0.0);
for (off_type i = 0; i < info.x; ++i) {
if (havesub && (i >= info.subnames.size() || info.subnames[i].empty()))
continue;
@@ -571,7 +578,7 @@
yvec[j] = info.cvec[iy + j];
tot_vec[j] += yvec[j];
total += yvec[j];
- super_total += yvec[j];
+ super_total[0] += yvec[j];
}
print.name = info.name + "_" +
@@ -582,11 +589,16 @@
print(*stream);
}
+ // Create a subname for printing the total
+ vector<string> total_subname;
+ total_subname.push_back("total");
+
if (info.flags.isSet(::Stats::total) && (info.x > 1)) {
print.name = info.name;
+ print.subnames = total_subname;
print.desc = info.desc;
- print.vec = tot_vec;
- print.total = super_total;
+ print.vec = super_total;
+ print.flags = print.flags & ~total;
print(*stream);
}
}
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev