Hoa Nguyen has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/36215 )

Change subject: cpu-o3,stats: Update stats style for mem_dep_unit.hh
......................................................................

cpu-o3,stats: Update stats style for mem_dep_unit.hh

Change-Id: I9bd8e9bc331f5d57c1b6320a87b14e9b94465148
Signed-off-by: Hoa Nguyen <hoangu...@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36215
Reviewed-by: Daniel Carvalho <oda...@yahoo.com.br>
Maintainer: Bobby R. Bruce <bbr...@ucdavis.edu>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/cpu/o3/inst_queue_impl.hh
M src/cpu/o3/mem_dep_unit.hh
M src/cpu/o3/mem_dep_unit_impl.hh
3 files changed, 41 insertions(+), 40 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/cpu/o3/inst_queue_impl.hh b/src/cpu/o3/inst_queue_impl.hh
index 5041ab4..44af654 100644
--- a/src/cpu/o3/inst_queue_impl.hh
+++ b/src/cpu/o3/inst_queue_impl.hh
@@ -114,7 +114,7 @@

     //Initialize Mem Dependence Units
     for (ThreadID tid = 0; tid < Impl::MaxThreads; tid++) {
-        memDepUnit[tid].init(params, tid);
+        memDepUnit[tid].init(params, tid, cpu_ptr);
         memDepUnit[tid].setIQ(this);
     }

diff --git a/src/cpu/o3/mem_dep_unit.hh b/src/cpu/o3/mem_dep_unit.hh
index ebeb702..f4c0f8f 100644
--- a/src/cpu/o3/mem_dep_unit.hh
+++ b/src/cpu/o3/mem_dep_unit.hh
@@ -85,6 +85,7 @@
   public:
     typedef typename Impl::DynInstPtr DynInstPtr;
     typedef typename Impl::DynInstConstPtr DynInstConstPtr;
+    typedef typename Impl::O3CPU O3CPU;

     /** Empty constructor. Must call init() prior to using in this case. */
     MemDepUnit();
@@ -99,10 +100,7 @@
     std::string name() const { return _name; }

     /** Initializes the unit with parameters and a thread id. */
-    void init(const DerivO3CPUParams &params, ThreadID tid);
-
-    /** Registers statistics. */
-    void regStats();
+    void init(const DerivO3CPUParams &params, ThreadID tid, O3CPU *cpu);

     /** Determine if we are drained. */
     bool isDrained() const;
@@ -279,15 +277,20 @@

     /** The thread id of this memory dependence unit. */
     int id;
-
-    /** Stat for number of inserted loads. */
-    Stats::Scalar insertedLoads;
-    /** Stat for number of inserted stores. */
-    Stats::Scalar insertedStores;
- /** Stat for number of conflicting loads that had to wait for a store. */
-    Stats::Scalar conflictingLoads;
- /** Stat for number of conflicting stores that had to wait for a store. */
-    Stats::Scalar conflictingStores;
+    struct MemDepUnitStats : public Stats::Group
+    {
+        MemDepUnitStats(Stats::Group *parent);
+        /** Stat for number of inserted loads. */
+        Stats::Scalar insertedLoads;
+        /** Stat for number of inserted stores. */
+        Stats::Scalar insertedStores;
+        /** Stat for number of conflicting loads that had to wait for a
+         *  store. */
+        Stats::Scalar conflictingLoads;
+        /** Stat for number of conflicting stores that had to wait for a
+         *  store. */
+        Stats::Scalar conflictingStores;
+    } stats;
 };

 #endif // __CPU_O3_MEM_DEP_UNIT_HH__
diff --git a/src/cpu/o3/mem_dep_unit_impl.hh b/src/cpu/o3/mem_dep_unit_impl.hh
index 7af0469..bd8faf8 100644
--- a/src/cpu/o3/mem_dep_unit_impl.hh
+++ b/src/cpu/o3/mem_dep_unit_impl.hh
@@ -42,6 +42,7 @@
 #define __CPU_O3_MEM_DEP_UNIT_IMPL_HH__

 #include <map>
+#include <memory>
 #include <vector>

 #include "base/debug.hh"
@@ -52,7 +53,8 @@

 template <class MemDepPred, class Impl>
 MemDepUnit<MemDepPred, Impl>::MemDepUnit()
-    : iqPtr(NULL)
+    : iqPtr(NULL),
+      stats(nullptr)
 {
 }

@@ -61,7 +63,8 @@
     : _name(params.name + ".memdepunit"),
       depPred(params.store_set_clear_period, params.SSITSize,
               params.LFSTSize),
-      iqPtr(NULL)
+      iqPtr(NULL),
+      stats(nullptr)
 {
     DPRINTF(MemDepUnit, "Creating MemDepUnit object.\n");
 }
@@ -94,7 +97,7 @@
 template <class MemDepPred, class Impl>
 void
 MemDepUnit<MemDepPred, Impl>::init(
-        const DerivO3CPUParams &params, ThreadID tid)
+        const DerivO3CPUParams &params, ThreadID tid, O3CPU *cpu)
 {
     DPRINTF(MemDepUnit, "Creating MemDepUnit %i object.\n",tid);

@@ -103,27 +106,22 @@

     depPred.init(params.store_set_clear_period, params.SSITSize,
             params.LFSTSize);
+
+    std::string stats_group_name = csprintf("MemDepUnit__%i", tid);
+    cpu->addStatGroup(stats_group_name.c_str(), &stats);
 }

 template <class MemDepPred, class Impl>
-void
-MemDepUnit<MemDepPred, Impl>::regStats()
+MemDepUnit<MemDepPred, Impl>::
+MemDepUnitStats::MemDepUnitStats(Stats::Group *parent)
+    : Stats::Group(parent),
+      ADD_STAT(insertedLoads,
+               "Number of loads inserted to the mem dependence unit."),
+      ADD_STAT(insertedStores,
+               "Number of stores inserted to the mem dependence unit."),
+      ADD_STAT(conflictingLoads, "Number of conflicting loads."),
+      ADD_STAT(conflictingStores, "Number of conflicting stores.")
 {
-    insertedLoads
-        .name(name() + ".insertedLoads")
-        .desc("Number of loads inserted to the mem dependence unit.");
-
-    insertedStores
-        .name(name() + ".insertedStores")
-        .desc("Number of stores inserted to the mem dependence unit.");
-
-    conflictingLoads
-        .name(name() + ".conflictingLoads")
-        .desc("Number of conflicting loads.");
-
-    conflictingStores
-        .name(name() + ".conflictingStores")
-        .desc("Number of conflicting stores.");
 }

 template <class MemDepPred, class Impl>
@@ -289,9 +287,9 @@
         inst_entry->memDeps = store_entries.size();

         if (inst->isLoad()) {
-            ++conflictingLoads;
+            ++stats.conflictingLoads;
         } else {
-            ++conflictingStores;
+            ++stats.conflictingStores;
         }
     }

@@ -304,9 +302,9 @@

depPred.insertStore(inst->instAddr(), inst->seqNum, inst->threadNumber);

-        ++insertedStores;
+        ++stats.insertedStores;
     } else if (inst->isLoad()) {
-        ++insertedLoads;
+        ++stats.insertedLoads;
     } else {
         panic("Unknown type! (most likely a barrier).");
     }
@@ -326,9 +324,9 @@

depPred.insertStore(inst->instAddr(), inst->seqNum, inst->threadNumber);

-        ++insertedStores;
+        ++stats.insertedStores;
     } else if (inst->isLoad()) {
-        ++insertedLoads;
+        ++stats.insertedLoads;
     } else {
         panic("Unknown type! (most likely a barrier).");
     }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/36215
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: I9bd8e9bc331f5d57c1b6320a87b14e9b94465148
Gerrit-Change-Number: 36215
Gerrit-PatchSet: 18
Gerrit-Owner: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Hoa Nguyen <hoangu...@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
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to