cpu,stats: Fix incorrect stat names of ThreadStateStats
authorHoa Nguyen <hoanguyen@ucdavis.edu>
Sat, 17 Oct 2020 10:48:22 +0000 (03:48 -0700)
committerBobby R. Bruce <bbruce@ucdavis.edu>
Sat, 14 Nov 2020 01:58:56 +0000 (01:58 +0000)
Previously, ThreadStateStats uses ThreadState::threadId() to
determine the name of the stats. However, in the ThreadState
constructor, ThreadStateStats is initialized before ThreadState
is intialized. As a result, the name of ThreadStateStats has
a wrong ThreadID.

This commit uses ThreadID instead of ThreadState to determine
the name of the stats.

This causes a name collision between ThreadStateStats and
ExecContextStats as both have the name of "thread_[tid]".
Ideally, those stats should be merged to the BaseSimpleCPU.
However, both ThreadStateStats and ExecContextStats have
a stat named numInsts. So, for now, ExecContextStats will
have a name of "exec_context.thread_[tid]", while ThreadStateStats
keeps its name.

Change-Id: If9a21549f98bd6e3ce6dc29bdf183e8fd5f51a67
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37455
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
src/cpu/thread_state.cc
src/cpu/thread_state.hh

index a142f5741c7ee6834e203c665bd0f3eed68e5e9b..5e59eb258af9e02640bd41d15c5f1c82201ece3e 100644 (file)
@@ -39,7 +39,7 @@
 #include "sim/system.hh"
 
 ThreadState::ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process)
-    : numInst(0), numOp(0), threadStats(cpu, this),
+    : numInst(0), numOp(0), threadStats(cpu, _tid),
       numLoad(0), startNumLoad(0),
       _status(ThreadContext::Halted), baseCpu(cpu),
       _contextId(0), _threadId(_tid), lastActivate(0), lastSuspend(0),
@@ -119,8 +119,8 @@ ThreadState::getVirtProxy()
 }
 
 ThreadState::ThreadStateStats::ThreadStateStats(BaseCPU *cpu,
-                                                ThreadState *thread)
-      : Stats::Group(cpu, csprintf("thread%i", thread->threadId()).c_str()),
+                                                const ThreadID& tid)
+      : Stats::Group(cpu, csprintf("thread_%i", tid).c_str()),
       ADD_STAT(numInsts, "Number of Instructions committed"),
       ADD_STAT(numOps, "Number of Ops committed"),
       ADD_STAT(numMemRefs, "Number of Memory References")
index 3ac473dce7f9ae81868bdb2bb464e24e515fb319..53817c8401ff5dbd9930ae1bcc159d4a486e765d 100644 (file)
@@ -111,7 +111,7 @@ struct ThreadState : public Serializable {
     // Defining the stat group
     struct ThreadStateStats : public Stats::Group
     {
-        ThreadStateStats(BaseCPU *cpu, ThreadState *thread);
+        ThreadStateStats(BaseCPU *cpu, const ThreadID& thread);
         /** Stat for number instructions committed. */
         Stats::Scalar numInsts;
         /** Stat for number ops (including micro ops) committed. */