cpu-minor: convert fetch2 to new style stats
authoreavivi <eavivi@ucdavis.edu>
Wed, 2 Sep 2020 17:35:27 +0000 (10:35 -0700)
committerJason Lowe-Power <power.jg@gmail.com>
Wed, 9 Sep 2020 00:45:55 +0000 (00:45 +0000)
Change-Id: Idfe0f1f256c93209fe51140b9cab3b454153c597
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33975
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/minor/fetch2.cc
src/cpu/minor/fetch2.hh
src/cpu/minor/pipeline.cc
src/cpu/minor/pipeline.hh

index d090eddd5d527b23dbf14f2d3dd2c007deb1d09f..c43b2f8ecf744b48608c1a53c308c957523154d1 100644 (file)
@@ -69,7 +69,7 @@ Fetch2::Fetch2(const std::string &name,
     processMoreThanOneInput(params.fetch2CycleInput),
     branchPredictor(*params.branchPred),
     fetchInfo(params.numThreads),
-    threadPriority(0)
+    threadPriority(0), stats(&cpu_)
 {
     if (outputWidth < 1)
         fatal("%s: decodeInputWidth must be >= 1 (%d)\n", name, outputWidth);
@@ -413,17 +413,17 @@ Fetch2::evaluate()
 
                     // Collect some basic inst class stats
                     if (decoded_inst->isLoad())
-                        loadInstructions++;
+                        stats.loadInstructions++;
                     else if (decoded_inst->isStore())
-                        storeInstructions++;
+                        stats.storeInstructions++;
                     else if (decoded_inst->isAtomic())
-                        amoInstructions++;
+                        stats.amoInstructions++;
                     else if (decoded_inst->isVector())
-                        vecInstructions++;
+                        stats.vecInstructions++;
                     else if (decoded_inst->isFloating())
-                        fpInstructions++;
+                        stats.fpInstructions++;
                     else if (decoded_inst->isInteger())
-                        intInstructions++;
+                        stats.intInstructions++;
 
                     DPRINTF(Fetch, "Instruction extracted from line %s"
                         " lineWidth: %d output_index: %d inputIndex: %d"
@@ -602,40 +602,33 @@ Fetch2::isDrained()
            (*predictionOut.inputWire).isBubble();
 }
 
-void
-Fetch2::regStats()
+Fetch2::Fetch2Stats::Fetch2Stats(MinorCPU *cpu)
+      : Stats::Group(cpu, "fetch2"),
+      ADD_STAT(intInstructions,
+       "Number of integer instructions successfully decoded"),
+      ADD_STAT(fpInstructions,
+       "Number of floating point instructions successfully decoded"),
+      ADD_STAT(vecInstructions,
+       "Number of SIMD instructions successfully decoded"),
+      ADD_STAT(loadInstructions,
+       "Number of memory load instructions successfully decoded"),
+      ADD_STAT(storeInstructions,
+       "Number of memory store instructions successfully decoded"),
+      ADD_STAT(amoInstructions,
+       "Number of memory atomic instructions successfully decoded")
 {
-    using namespace Stats;
-
-    intInstructions
-        .name(name() + ".int_instructions")
-        .desc("Number of integer instructions successfully decoded")
-        .flags(total);
-
-    fpInstructions
-        .name(name() + ".fp_instructions")
-        .desc("Number of floating point instructions successfully decoded")
-        .flags(total);
-
-    vecInstructions
-        .name(name() + ".vec_instructions")
-        .desc("Number of SIMD instructions successfully decoded")
-        .flags(total);
-
-    loadInstructions
-        .name(name() + ".load_instructions")
-        .desc("Number of memory load instructions successfully decoded")
-        .flags(total);
-
-    storeInstructions
-        .name(name() + ".store_instructions")
-        .desc("Number of memory store instructions successfully decoded")
-        .flags(total);
-
-    amoInstructions
-        .name(name() + ".amo_instructions")
-        .desc("Number of memory atomic instructions successfully decoded")
-        .flags(total);
+        intInstructions
+            .flags(Stats::total);
+        fpInstructions
+            .flags(Stats::total);
+        vecInstructions
+            .flags(Stats::total);
+        loadInstructions
+            .flags(Stats::total);
+        storeInstructions
+            .flags(Stats::total);
+        amoInstructions
+            .flags(Stats::total);
 }
 
 void
index d9726a990961e560c74e7406a5761216c287600f..3196e4e07053267c9d4d0f9b1af847d575aa50af 100644 (file)
@@ -163,13 +163,17 @@ class Fetch2 : public Named
     std::vector<Fetch2ThreadInfo> fetchInfo;
     ThreadID threadPriority;
 
-    /** Stats */
-    Stats::Scalar intInstructions;
-    Stats::Scalar fpInstructions;
-    Stats::Scalar vecInstructions;
-    Stats::Scalar loadInstructions;
-    Stats::Scalar storeInstructions;
-    Stats::Scalar amoInstructions;
+    struct Fetch2Stats : public Stats::Group
+    {
+        Fetch2Stats(MinorCPU *cpu);
+        /** Stats */
+        Stats::Scalar intInstructions;
+        Stats::Scalar fpInstructions;
+        Stats::Scalar vecInstructions;
+        Stats::Scalar loadInstructions;
+        Stats::Scalar storeInstructions;
+        Stats::Scalar amoInstructions;
+    } stats;
 
   protected:
     /** Get a piece of data to work on from the inputBuffer, or 0 if there
@@ -212,7 +216,6 @@ class Fetch2 : public Named
 
     void minorTrace() const;
 
-    void regStats();
 
     /** Is this stage drained?  For Fetch2, draining is initiated by
      *  Execute halting Fetch1 causing Fetch2 to naturally drain.
index efde76a57aac05637bc5c1e8e621c04286ea8e60..29dbf8b16776ed83d4364c1ac4c0c5925dba78dd 100644 (file)
@@ -103,14 +103,6 @@ Pipeline::Pipeline(MinorCPU &cpu_, MinorCPUParams &params) :
     }
 }
 
-void
-Pipeline::regStats()
-{
-    Ticked::regStats();
-
-    fetch2.regStats();
-}
-
 void
 Pipeline::minorTrace() const
 {
index 485ae78746a19799e3dfa653fa1f70e9dfc347ac..caf8355fb29ad87ece72e918ee3bf2fd76efad62 100644 (file)
@@ -126,9 +126,6 @@ class Pipeline : public Ticked
 
     void minorTrace() const;
 
-    /** Stats registering */
-    void regStats();
-
     /** Functions below here are BaseCPU operations passed on to pipeline
      *  stages */