cpu: convert thread_state to new style stats
authoreavivi <eavivi@ucdavis.edu>
Wed, 26 Aug 2020 00:18:28 +0000 (17:18 -0700)
committerEden Avivi <eavivi@ucdavis.edu>
Thu, 3 Sep 2020 18:59:18 +0000 (18:59 +0000)
Change-Id: Ib8cc8633ca5fced63918a7a6d10e15126f7c7459
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33400
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/execute.cc
src/cpu/o3/cpu.cc
src/cpu/thread_state.cc
src/cpu/thread_state.hh

index 3c94531ecc6da202eddf41db00e021d4e78d2035..45ca00233a55041d7f2ce967291a4426b1b260e6 100644 (file)
@@ -865,7 +865,7 @@ Execute::doInstCommitAccounting(MinorDynInstPtr inst)
     if (!inst->staticInst->isMicroop() || inst->staticInst->isLastMicroop())
     {
         thread->numInst++;
-        thread->numInsts++;
+        thread->threadStats.numInsts++;
         cpu.stats.numInsts++;
         cpu.system->totalNumInsts++;
 
@@ -873,7 +873,7 @@ Execute::doInstCommitAccounting(MinorDynInstPtr inst)
         thread->comInstEventQueue.serviceEvents(thread->numInst);
     }
     thread->numOp++;
-    thread->numOps++;
+    thread->threadStats.numOps++;
     cpu.stats.numOps++;
     cpu.stats.committedInstType[inst->id.threadId]
                                [inst->staticInst->opClass()]++;
index a525ea4c24cf4079ff0ce7cf9a08ee787e1320d2..562a3324bdd5cedb99d03d48634723e496b92a1d 100644 (file)
@@ -1512,7 +1512,7 @@ FullO3CPU<Impl>::instDone(ThreadID tid, const DynInstPtr &inst)
     // Keep an instruction count.
     if (!inst->isMicroop() || inst->isLastMicroop()) {
         thread[tid]->numInst++;
-        thread[tid]->numInsts++;
+        thread[tid]->threadStats.numInsts++;
         committedInsts[tid]++;
         system->totalNumInsts++;
 
@@ -1520,7 +1520,7 @@ FullO3CPU<Impl>::instDone(ThreadID tid, const DynInstPtr &inst)
         thread[tid]->comInstEventQueue.serviceEvents(thread[tid]->numInst);
     }
     thread[tid]->numOp++;
-    thread[tid]->numOps++;
+    thread[tid]->threadStats.numOps++;
     committedOps[tid]++;
 
     probeInstCommit(inst->staticInst, inst->instAddr());
index f681abc576cf422466bd29aa04750c857d0f1344..a142f5741c7ee6834e203c665bd0f3eed68e5e9b 100644 (file)
@@ -39,7 +39,8 @@
 #include "sim/system.hh"
 
 ThreadState::ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process)
-    : numInst(0), numOp(0), numLoad(0), startNumLoad(0),
+    : numInst(0), numOp(0), threadStats(cpu, this),
+      numLoad(0), startNumLoad(0),
       _status(ThreadContext::Halted), baseCpu(cpu),
       _contextId(0), _threadId(_tid), lastActivate(0), lastSuspend(0),
       process(_process), physProxy(NULL), virtProxy(NULL),
@@ -116,3 +117,13 @@ ThreadState::getVirtProxy()
     assert(virtProxy != NULL);
     return *virtProxy;
 }
+
+ThreadState::ThreadStateStats::ThreadStateStats(BaseCPU *cpu,
+                                                ThreadState *thread)
+      : Stats::Group(cpu, csprintf("thread%i", thread->threadId()).c_str()),
+      ADD_STAT(numInsts, "Number of Instructions committed"),
+      ADD_STAT(numOps, "Number of Ops committed"),
+      ADD_STAT(numMemRefs, "Number of Memory References")
+{
+
+}
index 1cc92a1750f80e5d5cfcd7d0b9484b47d185ecb2..3ac473dce7f9ae81868bdb2bb464e24e515fb319 100644 (file)
@@ -106,14 +106,19 @@ struct ThreadState : public Serializable {
 
     /** Number of instructions committed. */
     Counter numInst;
-    /** Stat for number instructions committed. */
-    Stats::Scalar numInsts;
-    /** Number of ops (including micro ops) committed. */
+     /** Number of ops (including micro ops) committed. */
     Counter numOp;
-    /** Stat for number ops (including micro ops) committed. */
-    Stats::Scalar numOps;
-    /** Stat for number of memory references. */
-    Stats::Scalar numMemRefs;
+    // Defining the stat group
+    struct ThreadStateStats : public Stats::Group
+    {
+        ThreadStateStats(BaseCPU *cpu, ThreadState *thread);
+        /** Stat for number instructions committed. */
+        Stats::Scalar numInsts;
+        /** Stat for number ops (including micro ops) committed. */
+        Stats::Scalar numOps;
+        /** Stat for number of memory references. */
+        Stats::Scalar numMemRefs;
+    } threadStats;
 
     /** Number of simulated loads, used for tracking events based on
      * the number of loads committed.