cpu-minor,stats: Update stats style of MinorCPU
authorHoa Nguyen <hoanguyen@ucdavis.edu>
Thu, 15 Oct 2020 02:40:26 +0000 (19:40 -0700)
committerHoa Nguyen <hoanguyen@ucdavis.edu>
Thu, 19 Nov 2020 22:46:48 +0000 (22:46 +0000)
Change-Id: Id14e6816cc82603459bf68461ae40bf2b63080eb
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36075
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/cpu/minor/cpu.cc
src/cpu/minor/stats.cc
src/cpu/minor/stats.hh

index de742563075679fef059db0718e0ff5f55e614db..0af81c53bef0fce8ee5fa1f3871937d4337e5161 100644 (file)
@@ -47,7 +47,8 @@
 
 MinorCPU::MinorCPU(const MinorCPUParams &params) :
     BaseCPU(params),
-    threadPolicy(params.threadPolicy)
+    threadPolicy(params.threadPolicy),
+    stats(this)
 {
     /* This is only written for one thread at the moment */
     Minor::MinorThread *thread;
@@ -118,7 +119,6 @@ void
 MinorCPU::regStats()
 {
     BaseCPU::regStats();
-    stats.regStats(name(), *this);
     pipeline->regStats();
 }
 
index 5de820d3bb5f607e7fc3d1e4f5d51394740fbabb..b43a4a1d695987096cb9575a4be9a03ccb3fb6c7 100644 (file)
 namespace Minor
 {
 
-MinorStats::MinorStats()
-{ }
-
-void
-MinorStats::regStats(const std::string &name, BaseCPU &baseCpu)
+MinorStats::MinorStats(BaseCPU *base_cpu)
+    : Stats::Group(base_cpu),
+    ADD_STAT(numInsts, "Number of instructions committed"),
+    ADD_STAT(numOps, "Number of ops (including micro ops) committed"),
+    ADD_STAT(numDiscardedOps,
+             "Number of ops (including micro ops) which were discarded before "
+             "commit"),
+    ADD_STAT(numFetchSuspends,
+             "Number of times Execute suspended instruction fetching"),
+    ADD_STAT(quiesceCycles,
+             "Total number of cycles that CPU has spent quiesced or waiting "
+             "for an interrupt"),
+    ADD_STAT(cpi, "CPI: cycles per instruction"),
+    ADD_STAT(ipc, "IPC: instructions per cycle"),
+    ADD_STAT(committedInstType, "Class of committed instruction")
 {
-    numInsts
-        .name(name + ".committedInsts")
-        .desc("Number of instructions committed");
-
-    numOps
-        .name(name + ".committedOps")
-        .desc("Number of ops (including micro ops) committed");
-
-    numDiscardedOps
-        .name(name + ".discardedOps")
-        .desc("Number of ops (including micro ops) which were discarded "
-            "before commit");
-
-    numFetchSuspends
-        .name(name + ".numFetchSuspends")
-        .desc("Number of times Execute suspended instruction fetching");
-
-    quiesceCycles
-        .name(name + ".quiesceCycles")
-        .desc("Total number of cycles that CPU has spent quiesced or waiting "
-              "for an interrupt")
-        .prereq(quiesceCycles);
+    quiesceCycles.prereq(quiesceCycles);
 
-    cpi
-        .name(name + ".cpi")
-        .desc("CPI: cycles per instruction")
-        .precision(6);
-    cpi = baseCpu.numCycles / numInsts;
+    cpi.precision(6);
+    cpi = base_cpu->numCycles / numInsts;
 
-    ipc
-        .name(name + ".ipc")
-        .desc("IPC: instructions per cycle")
-        .precision(6);
-    ipc = numInsts / baseCpu.numCycles;
+    ipc.precision(6);
+    ipc = numInsts / base_cpu->numCycles;
 
     committedInstType
-        .init(baseCpu.numThreads, Enums::Num_OpClass)
-        .name(name + ".op_class")
-        .desc("Class of committed instruction")
+        .init(base_cpu->numThreads, Enums::Num_OpClass)
         .flags(Stats::total | Stats::pdf | Stats::dist);
     committedInstType.ysubnames(Enums::OpClassStrings);
 }
index 3ee678aa764f786315e168e37b1f265ad136f334..e42b56f827961003baa8856ca546e597dad0cac0 100644 (file)
@@ -52,9 +52,10 @@ namespace Minor
 {
 
 /** Currently unused stats class. */
-class MinorStats
+struct MinorStats : public Stats::Group
 {
-  public:
+    MinorStats(BaseCPU *parent);
+
     /** Number of simulated instructions */
     Stats::Scalar numInsts;
 
@@ -77,11 +78,6 @@ class MinorStats
     /** Number of instructions by type (OpClass) */
     Stats::Vector2d committedInstType;
 
-  public:
-    MinorStats();
-
-  public:
-    void regStats(const std::string &name, BaseCPU &baseCpu);
 };
 
 }