cpu: convert statistical_corrector to new style stats
authorEmily Brickey <esbrickey@ucdavis.edu>
Tue, 1 Sep 2020 21:52:59 +0000 (14:52 -0700)
committerEmily Brickey <esbrickey@ucdavis.edu>
Thu, 3 Sep 2020 18:14:53 +0000 (18:14 +0000)
Change-Id: Id9e075fb45babeeafe65105679c8bf2135823d41
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33936
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/cpu/pred/statistical_corrector.cc
src/cpu/pred/statistical_corrector.hh

index 8ddae9be23f568f0effdb5e0a1e458a56a44735d..305959504046cfb57c55a3f79d3d14854684b97b 100644 (file)
@@ -65,7 +65,8 @@
     extraWeightsWidth(p->extraWeightsWidth),
     scCountersWidth(p->scCountersWidth),
     firstH(0),
-    secondH(0)
+    secondH(0),
+    stats(this)
 {
     wb.resize(1 << logSizeUps, 4);
 
@@ -376,9 +377,9 @@ void
 StatisticalCorrector::updateStats(bool taken, BranchInfo *bi)
 {
     if (taken == bi->scPred) {
-        scPredictorCorrect++;
+        stats.correct++;
     } else {
-        scPredictorWrong++;
+        stats.wrong++;
     }
 }
 
@@ -396,16 +397,12 @@ StatisticalCorrector::getSizeInBits() const
     return 0;
 }
 
-void
-StatisticalCorrector::regStats()
+StatisticalCorrector::StatisticalCorrectorStats::StatisticalCorrectorStats(
+    Stats::Group *parent)
+    : Stats::Group(parent),
+      ADD_STAT(correct, "Number of time the SC predictor is the"
+          " provider and the prediction is correct"),
+      ADD_STAT(wrong, "Number of time the SC predictor is the"
+          " provider and the prediction is wrong")
 {
-    scPredictorCorrect
-        .name(name() + ".scPredictorCorrect")
-        .desc("Number of time the SC predictor is the provider and "
-              "the prediction is correct");
-
-    scPredictorWrong
-        .name(name() + ".scPredictorWrong")
-        .desc("Number of time the SC predictor is the provider and "
-              "the prediction is wrong");
 }
index 2e8e502403f08cf78d18793666994bfa481740cb..b61f0d8fecf807a65701507a6bde106259ef0e5d 100644 (file)
@@ -182,9 +182,12 @@ class StatisticalCorrector : public SimObject
     int8_t firstH;
     int8_t secondH;
 
-    // stats
-    Stats::Scalar scPredictorCorrect;
-    Stats::Scalar scPredictorWrong;
+    struct StatisticalCorrectorStats : public Stats::Group {
+        StatisticalCorrectorStats(Stats::Group *parent);
+        Stats::Scalar correct;
+        Stats::Scalar wrong;
+    } stats;
+
   public:
     struct BranchInfo
     {
@@ -260,7 +263,6 @@ class StatisticalCorrector : public SimObject
         int64_t phist) = 0;
 
     void init() override;
-    void regStats() override;
     void updateStats(bool taken, BranchInfo *bi);
 
     virtual void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken,