Hoa Nguyen has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/40622 )

Change subject: base-stats: Print Units in Stats dump
......................................................................

base-stats: Print Units in Stats dump

Change-Id: I8fba4f19805c3149175ff730d014383dcaa1bf81
Signed-off-by: Hoa Nguyen <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40622
Reviewed-by: Daniel Carvalho <[email protected]>
Reviewed-by: Bobby R. Bruce <[email protected]>
Maintainer: Bobby R. Bruce <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/base/stats/text.cc
M src/base/stats/text.hh
2 files changed, 39 insertions(+), 0 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc
index 79bd0f0..3ca0259 100644
--- a/src/base/stats/text.cc
+++ b/src/base/stats/text.cc
@@ -223,9 +223,11 @@
     Result value;
     std::string name;
     std::string desc;
+    std::string unitStr;
     Flags flags;
     bool descriptions;
     bool spaces;
+    bool units;
     int precision;
     Result pdf;
     Result cdf;
@@ -291,6 +293,9 @@
             if (!desc.empty())
                 ccprintf(stream, " # %s", desc);
         }
+        if (units && !unitStr.empty()) {
+            ccprintf(stream, " (%s)", unitStr);
+        }
         stream << std::endl;
     }
 }
@@ -300,9 +305,11 @@
     std::string name;
     std::string separatorString;
     std::string desc;
+    std::string unitStr;
     std::vector<std::string> subnames;
     std::vector<std::string> subdescs;
     Flags flags;
+    bool units;
     bool descriptions;
     bool spaces;
     int precision;
@@ -339,8 +346,10 @@
     ScalarPrint print(spaces);
     print.name = name;
     print.desc = desc;
+    print.unitStr = unitStr;
     print.precision = precision;
     print.descriptions = descriptions;
+    print.units = units;
     print.flags = flags;
     print.pdf = _total ? 0.0 : NAN;
     print.cdf = _total ? 0.0 : NAN;
@@ -370,6 +379,7 @@

print.name = base + (havesub ? subnames[i] : std::to_string(i));
             print.desc = subdescs.empty() ? desc : subdescs[i];
+            print.unitStr = unitStr;

             print.update(vec[i], _total);
             print(stream, flags.isSet(oneline));
@@ -380,6 +390,9 @@
                 if (!desc.empty())
                     ccprintf(stream, " # %s", desc);
             }
+            if (units && !unitStr.empty()) {
+                ccprintf(stream, " (%s)", unitStr);
+            }
             stream << std::endl;
         }
     }
@@ -389,6 +402,7 @@
         print.cdf = NAN;
         print.name = base + "total";
         print.desc = desc;
+        print.unitStr = unitStr;
         print.value = total;
         print(stream);
     }
@@ -399,7 +413,9 @@
     std::string name;
     std::string separatorString;
     std::string desc;
+    std::string unitStr;
     Flags flags;
+    bool units;
     bool descriptions;
     bool spaces;
     int precision;
@@ -430,6 +446,8 @@

     if (!info.subdescs[i].empty())
         desc = info.subdescs[i];
+
+    unitStr = info.unit->getUnitString();
 }

 void
@@ -438,9 +456,11 @@
     name = text->statName(info.name);
     separatorString = info.separatorString;
     desc = info.desc;
+    unitStr = info.unit->getUnitString();
     flags = info.flags;
     precision = info.precision;
     descriptions = text->descriptions;
+    units = text->units;
     spaces = text->spaces;
     if (spaces) {
         nameSpaces = 40;
@@ -460,6 +480,7 @@
     print.flags = flags;
     print.descriptions = descriptions;
     print.desc = desc;
+    print.unitStr = unitStr;
     print.pdf = NAN;
     print.cdf = NAN;

@@ -547,6 +568,9 @@
             if (!desc.empty())
                 ccprintf(stream, " # %s", desc);
         }
+        if (units && !unitStr.empty()) {
+            ccprintf(stream, " (%s)", unitStr);
+        }
         stream << std::endl;
     }

@@ -586,8 +610,10 @@
     print.value = info.result();
     print.name = statName(info.name);
     print.desc = info.desc;
+    print.unitStr = info.unit->getUnitString();
     print.flags = info.flags;
     print.descriptions = descriptions;
+    print.units = units;
     print.precision = info.precision;
     print.pdf = NAN;
     print.cdf = NAN;
@@ -607,8 +633,10 @@
     print.name = statName(info.name);
     print.separatorString = info.separatorString;
     print.desc = info.desc;
+    print.unitStr = info.unit->getUnitString();
     print.flags = info.flags;
     print.descriptions = descriptions;
+    print.units = units;
     print.precision = info.precision;
     print.vec = info.result();
     print.total = info.total();
@@ -655,6 +683,7 @@
     print.flags = info.flags;
     print.separatorString = info.separatorString;
     print.descriptions = descriptions;
+    print.units = units;
     print.precision = info.precision;
     print.forceSubnames = true;

@@ -683,6 +712,7 @@
             info.name + "_" +
             (havesub ? info.subnames[i] : std::to_string(i)));
         print.desc = info.desc;
+        print.unitStr = info.unit->getUnitString();
         print.vec = yvec;
         print.total = total;
         print(*stream);
@@ -696,6 +726,7 @@
         print.name = statName(info.name);
         print.subnames = total_subname;
         print.desc = info.desc;
+        print.unitStr = info.unit->getUnitString();
         print.vec = VResult(1, info.total());
         print.flags = print.flags & ~total;
         print(*stream);
@@ -739,8 +770,10 @@
     std::string name;
     std::string separatorString;
     std::string desc;
+    std::string unitStr;
     Flags flags;
     bool descriptions;
+    bool units;
     bool spaces;
     int precision;

@@ -765,9 +798,11 @@
     name = text->statName(info.name);
     separatorString = info.separatorString;
     desc = info.desc;
+    unitStr = info.unit->getUnitString();
     flags = info.flags;
     precision = info.precision;
     descriptions = text->descriptions;
+    units = text->units;
     spaces = text->spaces;
 }

@@ -781,7 +816,9 @@
     print.precision = precision;
     print.flags = flags;
     print.descriptions = descriptions;
+    print.units = units;
     print.desc = desc;
+    print.unitStr = unitStr;
     print.pdf = NAN;
     print.cdf = NAN;

@@ -820,6 +857,7 @@
     if (!connected) {
         text.open(*simout.findOrCreate(filename)->stream());
         text.descriptions = desc;
+        text.units = desc; // the units are printed if descs are
         text.spaces = spaces;
         connected = true;
     }
diff --git a/src/base/stats/text.hh b/src/base/stats/text.hh
index 5762fd9..d5ee7f7 100644
--- a/src/base/stats/text.hh
+++ b/src/base/stats/text.hh
@@ -64,6 +64,7 @@
     bool noOutput(const Info &info);

   public:
+    bool units;
     bool descriptions;
     bool spaces;


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40622
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I8fba4f19805c3149175ff730d014383dcaa1bf81
Gerrit-Change-Number: 40622
Gerrit-PatchSet: 16
Gerrit-Owner: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to