mem: Use new-style stats in the XBar models
authorAndreas Sandberg <andreas.sandberg@arm.com>
Mon, 23 Sep 2019 17:18:28 +0000 (18:18 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Mon, 30 Sep 2019 12:34:16 +0000 (12:34 +0000)
Migrate to new-world stats with an explicit hierarchy in all of the
XBar models.

Change-Id: I18b6746a1303ca415638e6d382fb4757607f1123
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21141
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/coherent_xbar.cc
src/mem/noncoherent_xbar.cc
src/mem/noncoherent_xbar.hh
src/mem/xbar.cc
src/mem/xbar.hh

index a339500a874250da27f8e7efdea46e8bed8def10..713c6421b011c996ffd132665bb0a96d63062995 100644 (file)
@@ -62,7 +62,11 @@ CoherentXBar::CoherentXBar(const CoherentXBarParams *p)
       maxOutstandingSnoopCheck(p->max_outstanding_snoops),
       maxRoutingTableSizeCheck(p->max_routing_table_size),
       pointOfCoherency(p->point_of_coherency),
-      pointOfUnification(p->point_of_unification)
+      pointOfUnification(p->point_of_unification),
+
+      snoops(this, "snoops", "Total snoops (count)"),
+      snoopTraffic(this, "snoopTraffic", "Total snoop traffic (bytes)"),
+      snoopFanout(this, "snoop_fanout", "Request fanout histogram")
 {
     // create the ports based on the size of the master and slave
     // vector ports, and the presence of the default port, the ports
@@ -72,9 +76,9 @@ CoherentXBar::CoherentXBar(const CoherentXBarParams *p)
         MasterPort* bp = new CoherentXBarMasterPort(portName, *this, i);
         masterPorts.push_back(bp);
         reqLayers.push_back(new ReqLayer(*bp, *this,
-                                         csprintf(".reqLayer%d", i)));
+                                         csprintf("reqLayer%d", i)));
         snoopLayers.push_back(
-                new SnoopRespLayer(*bp, *this, csprintf(".snoopLayer%d", i)));
+                new SnoopRespLayer(*bp, *this, csprintf("snoopLayer%d", i)));
     }
 
     // see if we have a default slave device connected and if so add
@@ -85,10 +89,10 @@ CoherentXBar::CoherentXBar(const CoherentXBarParams *p)
         MasterPort* bp = new CoherentXBarMasterPort(portName, *this,
                                                     defaultPortID);
         masterPorts.push_back(bp);
-        reqLayers.push_back(new ReqLayer(*bp, *this, csprintf(".reqLayer%d",
+        reqLayers.push_back(new ReqLayer(*bp, *this, csprintf("reqLayer%d",
                                          defaultPortID)));
         snoopLayers.push_back(new SnoopRespLayer(*bp, *this,
-                                                 csprintf(".snoopLayer%d",
+                                                 csprintf("snoopLayer%d",
                                                           defaultPortID)));
     }
 
@@ -98,7 +102,7 @@ CoherentXBar::CoherentXBar(const CoherentXBarParams *p)
         QueuedSlavePort* bp = new CoherentXBarSlavePort(portName, *this, i);
         slavePorts.push_back(bp);
         respLayers.push_back(new RespLayer(*bp, *this,
-                                           csprintf(".respLayer%d", i)));
+                                           csprintf("respLayer%d", i)));
         snoopRespPorts.push_back(new SnoopRespPort(*bp, *this));
     }
 }
@@ -1104,30 +1108,9 @@ CoherentXBar::forwardPacket(const PacketPtr pkt)
 void
 CoherentXBar::regStats()
 {
-    // register the stats of the base class and our layers
     BaseXBar::regStats();
-    for (auto l: reqLayers)
-        l->regStats();
-    for (auto l: respLayers)
-        l->regStats();
-    for (auto l: snoopLayers)
-        l->regStats();
-
-    snoops
-        .name(name() + ".snoops")
-        .desc("Total snoops (count)")
-    ;
-
-    snoopTraffic
-        .name(name() + ".snoopTraffic")
-        .desc("Total snoop traffic (bytes)")
-    ;
-
-    snoopFanout
-        .init(0, snoopPorts.size(), 1)
-        .name(name() + ".snoop_fanout")
-        .desc("Request fanout histogram")
-    ;
+
+    snoopFanout.init(0, snoopPorts.size(), 1);
 }
 
 CoherentXBar *
index 730c2b22671ab49e63bddc85443adab2cd49a887..0de953306d026bf7ead0769cecb5b8457c578940 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2015, 2018 ARM Limited
+ * Copyright (c) 2011-2015, 2018-2019 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -65,7 +65,7 @@ NoncoherentXBar::NoncoherentXBar(const NoncoherentXBarParams *p)
         MasterPort* bp = new NoncoherentXBarMasterPort(portName, *this, i);
         masterPorts.push_back(bp);
         reqLayers.push_back(new ReqLayer(*bp, *this,
-                                         csprintf(".reqLayer%d", i)));
+                                         csprintf("reqLayer%d", i)));
     }
 
     // see if we have a default slave device connected and if so add
@@ -76,7 +76,7 @@ NoncoherentXBar::NoncoherentXBar(const NoncoherentXBarParams *p)
         MasterPort* bp = new NoncoherentXBarMasterPort(portName, *this,
                                                       defaultPortID);
         masterPorts.push_back(bp);
-        reqLayers.push_back(new ReqLayer(*bp, *this, csprintf(".reqLayer%d",
+        reqLayers.push_back(new ReqLayer(*bp, *this, csprintf("reqLayer%d",
                                                               defaultPortID)));
     }
 
@@ -86,7 +86,7 @@ NoncoherentXBar::NoncoherentXBar(const NoncoherentXBarParams *p)
         QueuedSlavePort* bp = new NoncoherentXBarSlavePort(portName, *this, i);
         slavePorts.push_back(bp);
         respLayers.push_back(new RespLayer(*bp, *this,
-                                           csprintf(".respLayer%d", i)));
+                                           csprintf("respLayer%d", i)));
     }
 }
 
@@ -317,14 +317,3 @@ NoncoherentXBarParams::create()
 {
     return new NoncoherentXBar(this);
 }
-
-void
-NoncoherentXBar::regStats()
-{
-    // register the stats of the base class and our layers
-    BaseXBar::regStats();
-    for (auto l: reqLayers)
-        l->regStats();
-    for (auto l: respLayers)
-        l->regStats();
-}
index 4f72cef4d6f89360e29f9f17bff56adf62764545..d8f35e4e1ab2053ff87a5523476f6e84f6fba27d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2015 ARM Limited
+ * Copyright (c) 2011-2015, 2019 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -187,9 +187,6 @@ class NoncoherentXBar : public BaseXBar
     NoncoherentXBar(const NoncoherentXBarParams *p);
 
     virtual ~NoncoherentXBar();
-
-    void regStats() override;
-    Stats::Scalar totPktSize;
 };
 
 #endif //__MEM_NONCOHERENT_XBAR_HH__
index 16f0e21dd31b78e41dc03c0b69ff333807abfdb7..5efb2c947d49e028158fe5bbd46ec71c30e2c000 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2015, 2018 ARM Limited
+ * Copyright (c) 2011-2015, 2018-2019 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -64,8 +64,15 @@ BaseXBar::BaseXBar(const BaseXBarParams *p)
       gotAddrRanges(p->port_default_connection_count +
                           p->port_master_connection_count, false),
       gotAllAddrRanges(false), defaultPortID(InvalidPortID),
-      useDefaultRange(p->use_default_range)
-{}
+      useDefaultRange(p->use_default_range),
+
+      transDist(this, "trans_dist", "Transaction distribution"),
+      pktCount(this, "pkt_count",
+                   "Packet count per connected master and slave (bytes)"),
+      pktSize(this, "pkt_size",
+              "Cumulative packet size per connected master and slave (bytes)")
+{
+}
 
 BaseXBar::~BaseXBar()
 {
@@ -133,9 +140,20 @@ BaseXBar::calcPacketTiming(PacketPtr pkt, Tick header_delay)
 template <typename SrcType, typename DstType>
 BaseXBar::Layer<SrcType, DstType>::Layer(DstType& _port, BaseXBar& _xbar,
                                        const std::string& _name) :
-    port(_port), xbar(_xbar), _name(_name), state(IDLE),
-    waitingForPeer(NULL), releaseEvent([this]{ releaseLayer(); }, name())
+    Stats::Group(&_xbar, _name.c_str()),
+    port(_port), xbar(_xbar), _name(xbar.name() + "." + _name), state(IDLE),
+    waitingForPeer(NULL), releaseEvent([this]{ releaseLayer(); }, name()),
+    ADD_STAT(occupancy, "Layer occupancy (ticks)"),
+    ADD_STAT(utilization, "Layer utilization (%)")
 {
+    occupancy
+        .flags(Stats::nozero);
+
+    utilization
+        .precision(1)
+        .flags(Stats::nozero);
+
+    utilization = 100 * occupancy / simTicks;
 }
 
 template <typename SrcType, typename DstType>
@@ -527,8 +545,6 @@ BaseXBar::regStats()
 
     transDist
         .init(MemCmd::NUM_MEM_CMDS)
-        .name(name() + ".trans_dist")
-        .desc("Transaction distribution")
         .flags(nozero);
 
     // get the string representation of the commands
@@ -540,14 +556,10 @@ BaseXBar::regStats()
 
     pktCount
         .init(slavePorts.size(), masterPorts.size())
-        .name(name() + ".pkt_count")
-        .desc("Packet count per connected master and slave (bytes)")
         .flags(total | nozero | nonan);
 
     pktSize
         .init(slavePorts.size(), masterPorts.size())
-        .name(name() + ".pkt_size")
-        .desc("Cumulative packet size per connected master and slave (bytes)")
         .flags(total | nozero | nonan);
 
     // both the packet count and total size are two-dimensional
@@ -581,26 +593,6 @@ BaseXBar::Layer<SrcType, DstType>::drain()
     }
 }
 
-template <typename SrcType, typename DstType>
-void
-BaseXBar::Layer<SrcType, DstType>::regStats()
-{
-    using namespace Stats;
-
-    occupancy
-        .name(name() + ".occupancy")
-        .desc("Layer occupancy (ticks)")
-        .flags(nozero);
-
-    utilization
-        .name(name() + ".utilization")
-        .desc("Layer utilization (%)")
-        .precision(1)
-        .flags(nozero);
-
-    utilization = 100 * occupancy / simTicks;
-}
-
 /**
  * Crossbar layer template instantiations. Could be removed with _impl.hh
  * file, but since there are only two given options (MasterPort and
index 8de7af46f7690d82f1e313e516e57e59dae1e6b7..1ec846d62be30f2dc8aa771031d72653e57f8d5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2015, 2018 ARM Limited
+ * Copyright (c) 2011-2015, 2018-2019 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -90,7 +90,7 @@ class BaseXBar : public ClockedObject
      * ports, whereas a response layer holds master ports.
      */
     template <typename SrcType, typename DstType>
-    class Layer : public Drainable
+    class Layer : public Drainable, public Stats::Group
     {
 
       public:
@@ -116,7 +116,7 @@ class BaseXBar : public ClockedObject
          */
         DrainState drain() override;
 
-        const std::string name() const { return xbar.name() + _name; }
+        const std::string name() const { return _name; }
 
 
         /**
@@ -166,8 +166,6 @@ class BaseXBar : public ClockedObject
          */
         void recvRetry();
 
-        void regStats();
-
       protected:
 
         /**