diff options
author | Sascha Bischoff <sascha.bischoff@arm.com> | 2013-08-19 03:52:29 -0400 |
---|---|---|
committer | Sascha Bischoff <sascha.bischoff@arm.com> | 2013-08-19 03:52:29 -0400 |
commit | 6211c24a969735ecc9c83fceb59386c7d636253d (patch) | |
tree | 0b9069a68ad0f08d739689600006c713a23fa2e0 /src/base/stats | |
parent | e7e17f92db8b249aaf99eb93a2447937d78270d5 (diff) | |
download | gem5-6211c24a969735ecc9c83fceb59386c7d636253d.tar.xz |
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 (limited to 'src/base/stats')
-rw-r--r-- | src/base/stats/text.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc index 3909c96ed..3b06dc121 100644 --- a/src/base/stats/text.cc +++ b/src/base/stats/text.cc @@ -249,6 +249,7 @@ struct VectorPrint int precision; VResult vec; Result total; + bool forceSubnames = false; void operator()(ostream &stream) const; }; @@ -279,6 +280,11 @@ VectorPrint::operator()(std::ostream &stream) const 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 @@ Text::visit(const Vector2dInfo &info) 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 @@ Text::visit(const Vector2dInfo &info) } 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 @@ Text::visit(const Vector2dInfo &info) 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 @@ Text::visit(const Vector2dInfo &info) 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); } } |