Hoa Nguyen has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/38075 )

Change subject: mem-ruby: Update stats of AbstractController and derived classes
......................................................................

mem-ruby: Update stats of AbstractController and derived classes

Change-Id: Ibe04e33a6cf09b453564592d29293b354d0d33c9
Signed-off-by: Hoa Nguyen <[email protected]>
---
M src/mem/ruby/slicc_interface/AbstractController.cc
M src/mem/ruby/slicc_interface/AbstractController.hh
M src/mem/slicc/symbols/StateMachine.py
3 files changed, 76 insertions(+), 60 deletions(-)



diff --git a/src/mem/ruby/slicc_interface/AbstractController.cc b/src/mem/ruby/slicc_interface/AbstractController.cc
index 1e8d8e0..bf234bd 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.cc
+++ b/src/mem/ruby/slicc_interface/AbstractController.cc
@@ -56,7 +56,8 @@
       m_buffer_size(p.buffer_size), m_recycle_latency(p.recycle_latency),
       m_mandatory_queue_latency(p.mandatory_queue_latency),
       memoryPort(csprintf("%s.memory", name()), this),
-      addrRanges(p.addr_ranges.begin(), p.addr_ranges.end())
+      addrRanges(p.addr_ranges.begin(), p.addr_ranges.end()),
+      stats(this)
 {
     if (m_version == 0) {
         // Combine the statistics from all controllers
@@ -68,11 +69,11 @@
 void
 AbstractController::init()
 {
-    m_delayHistogram.init(10);
+    stats.m_delayHistogram.init(10);
     uint32_t size = Network::getNumberOfVirtualNetworks();
     for (uint32_t i = 0; i < size; i++) {
-        m_delayVCHistogram.push_back(new Stats::Histogram());
-        m_delayVCHistogram[i]->init(10);
+        stats.m_delayVCHistogram.push_back(new Stats::Histogram(this));
+        stats.m_delayVCHistogram[i]->init(10);
     }

     if (getMemReqQueue()) {
@@ -106,10 +107,10 @@
 void
 AbstractController::resetStats()
 {
-    m_delayHistogram.reset();
+    stats.m_delayHistogram.reset();
     uint32_t size = Network::getNumberOfVirtualNetworks();
     for (uint32_t i = 0; i < size; i++) {
-        m_delayVCHistogram[i]->reset();
+        stats.m_delayVCHistogram[i]->reset();
     }
 }

@@ -117,19 +118,14 @@
 AbstractController::regStats()
 {
     ClockedObject::regStats();
-
-    m_fully_busy_cycles
-        .name(name() + ".fully_busy_cycles")
-        .desc("cycles for which number of transistions == max transitions")
-        .flags(Stats::nozero);
 }

 void
 AbstractController::profileMsgDelay(uint32_t virtualNetwork, Cycles delay)
 {
-    assert(virtualNetwork < m_delayVCHistogram.size());
-    m_delayHistogram.sample(delay);
-    m_delayVCHistogram[virtualNetwork]->sample(delay);
+    assert(virtualNetwork < stats.m_delayVCHistogram.size());
+    stats.m_delayHistogram.sample(delay);
+    stats.m_delayVCHistogram[virtualNetwork]->sample(delay);
 }

 void
@@ -423,3 +419,15 @@
     : RequestPort(_name, _controller, id), controller(_controller)
 {
 }
+
+AbstractController::
+ControllerStats::ControllerStats(Stats::Group *parent)
+    : Stats::Group(parent, "Controller"),
+      m_fully_busy_cycles(this, "fully_busy_cycles",
+                          "cycles for which number of transistions == max "
+                          "transitions"),
+      m_delayHistogram(this, "delay_histogram")
+{
+    m_fully_busy_cycles
+        .flags(Stats::nozero);
+}
diff --git a/src/mem/ruby/slicc_interface/AbstractController.hh b/src/mem/ruby/slicc_interface/AbstractController.hh
index 8e19195..ce81de0 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.hh
+++ b/src/mem/ruby/slicc_interface/AbstractController.hh
@@ -151,9 +151,9 @@
     MachineID getMachineID() const { return m_machineID; }
     RequestorID getRequestorId() const { return m_id; }

-    Stats::Histogram& getDelayHist() { return m_delayHistogram; }
+    Stats::Histogram& getDelayHist() { return stats.m_delayHistogram; }
     Stats::Histogram& getDelayVCHist(uint32_t index)
-    { return *(m_delayVCHistogram[index]); }
+    { return *(stats.m_delayVCHistogram[index]); }

     bool respondsTo(Addr addr)
     {
@@ -204,14 +204,6 @@
     std::unordered_map<Addr, TransMapPair> m_inTrans;
     std::unordered_map<Addr, TransMapPair> m_outTrans;

-    // Initialized by the SLICC compiler for all combinations of event and
-    // states. Only histograms with samples will appear in the stats
- std::vector<std::vector<std::vector<Stats::Histogram*>>> m_inTransLatHist;
-
-    // Initialized by the SLICC compiler for all events.
-    // Only histograms with samples will appear in the stats.
-    std::vector<Stats::Histogram*> m_outTransLatHist;
-
     /**
* Profiles an event that initiates a protocol transactions for a specific
      * line (e.g. events triggered by incoming request messages).
@@ -241,10 +233,10 @@
     {
         auto iter = m_inTrans.find(addr);
         assert(iter != m_inTrans.end());
-        m_inTransLatHist[iter->second.transaction]
-                        [iter->second.state]
-                        [(unsigned)finalState]->sample(
-                          ticksToCycles(curTick() - iter->second.time));
+        stats.m_inTransLatHist[iter->second.transaction]
+                              [iter->second.state]
+                              [(unsigned)finalState]->sample(
+ ticksToCycles(curTick() - iter->second.time));
        m_inTrans.erase(iter);
     }

@@ -272,7 +264,7 @@
     {
         auto iter = m_outTrans.find(addr);
         assert(iter != m_outTrans.end());
-        m_outTransLatHist[iter->second.transaction]->sample(
+        stats.m_outTransLatHist[iter->second.transaction]->sample(
             ticksToCycles(curTick() - iter->second.time));
         m_outTrans.erase(iter);
     }
@@ -308,15 +300,6 @@
     Cycles m_recycle_latency;
     const Cycles m_mandatory_queue_latency;

-    //! Counter for the number of cycles when the transitions carried out
-    //! were equal to the maximum allowed
-    Stats::Scalar m_fully_busy_cycles;
-
-    //! Histogram for profiling delay for the messages this controller
-    //! cares for
-    Stats::Histogram m_delayHistogram;
-    std::vector<Stats::Histogram *> m_delayVCHistogram;
-
     /**
      * Port that forwards requests and receives responses from the
      * memory controller.
@@ -363,6 +346,30 @@

     NetDest downstreamDestinations;

+  public:
+    struct ControllerStats : public Stats::Group
+    {
+        ControllerStats(Stats::Group *parent);
+
+ // Initialized by the SLICC compiler for all combinations of event and
+        // states. Only histograms with samples will appear in the stats
+        std::vector<std::vector<std::vector<Stats::Histogram*>>>
+          m_inTransLatHist;
+
+        // Initialized by the SLICC compiler for all events.
+        // Only histograms with samples will appear in the stats.
+        std::vector<Stats::Histogram*> m_outTransLatHist;
+
+ //! Counter for the number of cycles when the transitions carried out
+        //! were equal to the maximum allowed
+        Stats::Scalar m_fully_busy_cycles;
+
+        //! Histogram for profiling delay for the messages this controller
+        //! cares for
+        Stats::Histogram m_delayHistogram;
+        std::vector<Stats::Histogram *> m_delayVCHistogram;
+    } stats;
+
 };

 #endif // __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index c4601bb..b47dc1f 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -818,10 +818,11 @@
     if (m_version == 0) {
         for (${ident}_Event event = ${ident}_Event_FIRST;
              event < ${ident}_Event_NUM; ++event) {
-            Stats::Vector *t = new Stats::Vector();
+            std::string stat_name =
+                "${c_ident}." + ${ident}_Event_to_string(event);
+            Stats::Vector *t =
+                new Stats::Vector(&stats, stat_name.c_str());
             t->init(m_num_controllers);
-            t->name(params().ruby_system->name() + ".${c_ident}." +
-                ${ident}_Event_to_string(event));
             t->flags(Stats::pdf | Stats::total | Stats::oneline |
                      Stats::nozero);

@@ -835,13 +836,12 @@

             for (${ident}_Event event = ${ident}_Event_FIRST;
                  event < ${ident}_Event_NUM; ++event) {
-
-                Stats::Vector *t = new Stats::Vector();
+                std::string stat_name = "${c_ident}." +
+                    ${ident}_State_to_string(state) +
+                    "." + ${ident}_Event_to_string(event);
+                Stats::Vector *t =
+                    new Stats::Vector(&stats, stat_name.c_str());
                 t->init(m_num_controllers);
-                t->name(params().ruby_system->name() + ".${c_ident}." +
-                        ${ident}_State_to_string(state) +
-                        "." + ${ident}_Event_to_string(event));
-
                 t->flags(Stats::pdf | Stats::total | Stats::oneline |
                          Stats::nozero);
                 transVec[state].push_back(t);
@@ -850,29 +850,30 @@
     }
     for (${ident}_Event event = ${ident}_Event_FIRST;
                  event < ${ident}_Event_NUM; ++event) {
-        Stats::Histogram* t = new Stats::Histogram;
-        m_outTransLatHist.push_back(t);
+        std::string stat_name =
+            "outTransLatHist." + ${ident}_Event_to_string(event);
+ Stats::Histogram* t = new Stats::Histogram(&stats, stat_name.c_str());
+        stats.m_outTransLatHist.push_back(t);
         t->init(5);
-        t->name(name() + ".outTransLatHist." +
-                    ${ident}_Event_to_string(event));
         t->flags(Stats::pdf | Stats::total |
                  Stats::oneline | Stats::nozero);
     }
     for (${ident}_Event event = ${ident}_Event_FIRST;
                  event < ${ident}_Event_NUM; ++event) {
-        m_inTransLatHist.emplace_back();
+        stats.m_inTransLatHist.emplace_back();
         for (${ident}_State initial_state = ${ident}_State_FIRST;
              initial_state < ${ident}_State_NUM; ++initial_state) {
-            m_inTransLatHist.back().emplace_back();
+            stats.m_inTransLatHist.back().emplace_back();
             for (${ident}_State final_state = ${ident}_State_FIRST;
                  final_state < ${ident}_State_NUM; ++final_state) {
-                Stats::Histogram* t = new Stats::Histogram;
-                m_inTransLatHist.back().back().push_back(t);
+                std::string stat_name = "inTransLatHist." +
+                    ${ident}_Event_to_string(event) + "." +
+                    ${ident}_State_to_string(initial_state) + "." +
+                    ${ident}_State_to_string(final_state);
+                Stats::Histogram* t =
+                    new Stats::Histogram(&stats, stat_name.c_str());
+                stats.m_inTransLatHist.back().back().push_back(t);
                 t->init(5);
-                t->name(name() + ".inTransLatHist." +
-                            ${ident}_Event_to_string(event) + "." +
-                            ${ident}_State_to_string(initial_state) + "." +
-                            ${ident}_State_to_string(final_state));
                 t->flags(Stats::pdf | Stats::total |
                          Stats::oneline | Stats::nozero);
             }
@@ -1231,7 +1232,7 @@
         assert(counter <= m_transitions_per_cycle);
         if (counter == m_transitions_per_cycle) {
             // Count how often we are fully utilized
-            m_fully_busy_cycles++;
+            stats.m_fully_busy_cycles++;

             // Wakeup in another cycle and try again
             scheduleEvent(Cycles(1));

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/38075
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: Ibe04e33a6cf09b453564592d29293b354d0d33c9
Gerrit-Change-Number: 38075
Gerrit-PatchSet: 1
Gerrit-Owner: Hoa Nguyen <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to