Bobby Bruce has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/67394?usp=email )

Change subject: cpu-o3: Move general fetch stats to BaseCPU::FetchCPUStats
......................................................................

cpu-o3: Move general fetch stats to BaseCPU::FetchCPUStats

The stats moved are from fetch.hh and fetch.cc of O3. Stat branches is
now tracked by numBranches. Stat branchRate is now tracked by
branchRate in FetchCPUStats. Stat rate is tracked by fetchRate. Stat
insts is tracked by numInsts. Stat icacheStallCycles is tracked by
icacheStallCycles in FetchCPUStats.

Change-Id: I48313614edd078631df4ef6b00982c335798fcb1
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67394
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Bobby Bruce <bbr...@ucdavis.edu>
---
M src/cpu/base.cc
M src/cpu/base.hh
M src/cpu/o3/fetch.cc
M src/cpu/o3/fetch.hh
4 files changed, 41 insertions(+), 39 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved
  Jason Lowe-Power: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index fa30e4b..490e489 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -196,8 +196,15 @@
     executeStats.reserve(numThreads);
     commitStats.reserve(numThreads);
     for (int i = 0; i < numThreads; i++) {
-        fetchStats.emplace_back(new FetchCPUStats(this, i));
+        // create fetchStat object for thread i and set rate formulas
+        FetchCPUStats* fetchStatptr = new FetchCPUStats(this, i);
+ fetchStatptr->fetchRate = fetchStatptr->numInsts / baseStats.numCycles;
+        fetchStatptr->branchRate = fetchStatptr->numBranches /
+            baseStats.numCycles;
+        fetchStats.emplace_back(fetchStatptr);
+
         executeStats.emplace_back(new ExecuteCPUStats(this, i));
+
         // create commitStat object for thread i and set ipc, cpi formulas
         CommitCPUStats* commitStatptr = new CommitCPUStats(this, i);
         commitStatptr->ipc = commitStatptr->numInsts / baseStats.numCycles;
@@ -862,15 +869,31 @@
              "Number of instructions fetched (thread level)"),
     ADD_STAT(numOps, statistics::units::Count::get(),
              "Number of ops (including micro ops) fetched (thread level)"),
+    ADD_STAT(fetchRate, statistics::units::Rate<
+             statistics::units::Count, statistics::units::Cycle>::get(),
+             "Number of inst fetches per cycle"),
     ADD_STAT(numBranches, statistics::units::Count::get(),
              "Number of branches fetched"),
+    ADD_STAT(branchRate, statistics::units::Ratio::get(),
+             "Number of branch fetches per cycle"),
+    ADD_STAT(icacheStallCycles, statistics::units::Cycle::get(),
+             "ICache total stall cycles"),
     ADD_STAT(numFetchSuspends, statistics::units::Count::get(),
              "Number of times Execute suspended instruction fetching")

 {
+    fetchRate
+        .flags(statistics::total);
+
     numBranches
         .prereq(numBranches);

+    branchRate
+        .flags(statistics::total);
+
+    icacheStallCycles
+        .prereq(icacheStallCycles);
+
 }

 // means it is incremented in a vector indexing and not directly
@@ -981,6 +1004,9 @@
     ADD_STAT(committedControl, statistics::units::Count::get(),
              "Class of control type instructions committed")
 {
+    numInsts
+        .prereq(numInsts);
+
     cpi.precision(6);
     ipc.precision(6);

diff --git a/src/cpu/base.hh b/src/cpu/base.hh
index a9af865..5d0d3ca 100644
--- a/src/cpu/base.hh
+++ b/src/cpu/base.hh
@@ -695,9 +695,18 @@
         /* Total number of operations fetched */
         statistics::Scalar numOps;

+        /* Number of instruction fetched per cycle. */
+        statistics::Formula fetchRate;
+
         /* Total number of branches fetched */
         statistics::Scalar numBranches;

+        /* Number of branch fetches per cycle. */
+        statistics::Formula branchRate;
+
+        /* Number of cycles stalled due to an icache miss */
+        statistics::Scalar icacheStallCycles;
+
         /* Number of times fetch was asked to suspend by Execute */
         statistics::Scalar numFetchSuspends;

diff --git a/src/cpu/o3/fetch.cc b/src/cpu/o3/fetch.cc
index d3cdd2c..f5fc6c6 100644
--- a/src/cpu/o3/fetch.cc
+++ b/src/cpu/o3/fetch.cc
@@ -158,12 +158,6 @@

 Fetch::FetchStatGroup::FetchStatGroup(CPU *cpu, Fetch *fetch)
     : statistics::Group(cpu, "fetch"),
-    ADD_STAT(icacheStallCycles, statistics::units::Cycle::get(),
-             "Number of cycles fetch is stalled on an Icache miss"),
-    ADD_STAT(insts, statistics::units::Count::get(),
-             "Number of instructions fetch has processed"),
-    ADD_STAT(branches, statistics::units::Count::get(),
-             "Number of branches that fetch encountered"),
     ADD_STAT(predictedBranches, statistics::units::Count::get(),
              "Number of branches that fetch has predicted taken"),
     ADD_STAT(cycles, statistics::units::Cycle::get(),
@@ -200,21 +194,8 @@
              "Number of instructions fetched each cycle (Total)"),
     ADD_STAT(idleRate, statistics::units::Ratio::get(),
              "Ratio of cycles fetch was idle",
-             idleCycles / cpu->baseStats.numCycles),
-    ADD_STAT(branchRate, statistics::units::Ratio::get(),
-             "Number of branch fetches per cycle",
-             branches / cpu->baseStats.numCycles),
-    ADD_STAT(rate, statistics::units::Rate<
- statistics::units::Count, statistics::units::Cycle>::get(),
-             "Number of inst fetches per cycle",
-             insts / cpu->baseStats.numCycles)
+             idleCycles / cpu->baseStats.numCycles)
 {
-        icacheStallCycles
-            .prereq(icacheStallCycles);
-        insts
-            .prereq(insts);
-        branches
-            .prereq(branches);
         predictedBranches
             .prereq(predictedBranches);
         cycles
@@ -252,10 +233,6 @@
             .flags(statistics::pdf);
         idleRate
             .prereq(idleRate);
-        branchRate
-            .flags(statistics::total);
-        rate
-            .flags(statistics::total);
 }
 void
 Fetch::setTimeBuffer(TimeBuffer<TimeStruct> *time_buffer)
@@ -540,7 +517,7 @@
     inst->setPredTarg(next_pc);
     inst->setPredTaken(predict_taken);

-    ++fetchStats.branches;
+    cpu->fetchStats[tid]->numBranches++;

     if (predict_taken) {
         ++fetchStats.predictedBranches;
@@ -1146,7 +1123,7 @@
             fetchCacheLine(fetchAddr, tid, this_pc.instAddr());

             if (fetchStatus[tid] == IcacheWaitResponse)
-                ++fetchStats.icacheStallCycles;
+                cpu->fetchStats[tid]->icacheStallCycles++;
             else if (fetchStatus[tid] == ItlbWait)
                 ++fetchStats.tlbCycles;
             else
@@ -1242,7 +1219,7 @@
                     staticInst = dec_ptr->decode(this_pc);

                     // Increment stat of fetched instructions.
-                    ++fetchStats.insts;
+                    cpu->fetchStats[tid]->numInsts++;

                     if (staticInst->isMacroop()) {
                         curMacroop = staticInst;
@@ -1572,7 +1549,7 @@
         ++fetchStats.squashCycles;
         DPRINTF(Fetch, "[tid:%i] Fetch is squashing!\n", tid);
     } else if (fetchStatus[tid] == IcacheWaitResponse) {
-        ++fetchStats.icacheStallCycles;
+        cpu->fetchStats[tid]->icacheStallCycles++;
         DPRINTF(Fetch, "[tid:%i] Fetch is waiting cache response!\n",
                 tid);
     } else if (fetchStatus[tid] == ItlbWait) {
diff --git a/src/cpu/o3/fetch.hh b/src/cpu/o3/fetch.hh
index cd31191..6add314 100644
--- a/src/cpu/o3/fetch.hh
+++ b/src/cpu/o3/fetch.hh
@@ -533,12 +533,6 @@
         FetchStatGroup(CPU *cpu, Fetch *fetch);
         // @todo: Consider making these
         // vectors and tracking on a per thread basis.
- /** Stat for total number of cycles stalled due to an icache miss. */
-        statistics::Scalar icacheStallCycles;
-        /** Stat for total number of fetched instructions. */
-        statistics::Scalar insts;
-        /** Total number of fetched branches. */
-        statistics::Scalar branches;
         /** Stat for total number of predicted branches. */
         statistics::Scalar predictedBranches;
         /** Stat for total number of cycles spent fetching. */
@@ -581,10 +575,6 @@
         statistics::Distribution nisnDist;
         /** Rate of how often fetch was idle. */
         statistics::Formula idleRate;
-        /** Number of branch fetches per cycle. */
-        statistics::Formula branchRate;
-        /** Number of instruction fetched per cycle. */
-        statistics::Formula rate;
     } fetchStats;
 };


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/67394?usp=email 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: I48313614edd078631df4ef6b00982c335798fcb1
Gerrit-Change-Number: 67394
Gerrit-PatchSet: 6
Gerrit-Owner: Melissa Jost <melissakj...@gmail.com>
Gerrit-Reviewer: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to