mem: Convert CommMonitor to the new stat framework
authorAndreas Sandberg <andreas.sandberg@arm.com>
Fri, 28 Jun 2019 11:10:36 +0000 (12:10 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Thu, 29 Aug 2019 09:01:38 +0000 (09:01 +0000)
Change-Id: I851c29909f3e6923c0233505a4d0f2d266bc254f
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19371
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
src/mem/comm_monitor.cc
src/mem/comm_monitor.hh

index 24457c9f01f94ae610f3e462bc03d8b3b4ac9d8c..bcde3e5162169115b0eec3749ccfd216fb259f3d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, 2015, 2018 ARM Limited
+ * Copyright (c) 2012-2013, 2015, 2018-2019 ARM Limited
  * Copyright (c) 2016 Google Inc.
  * Copyright (c) 2017, Centre National de la Recherche Scientifique
  * All rights reserved.
@@ -55,7 +55,7 @@ CommMonitor::CommMonitor(Params* params)
       samplePeriodicEvent([this]{ samplePeriodic(); }, name()),
       samplePeriodTicks(params->sample_period),
       samplePeriod(params->sample_period / SimClock::Float::s),
-      stats(params)
+      stats(this, params)
 {
     DPRINTF(CommMonitor,
             "Created monitor %s with sample period %d ticks (%f ms)\n",
@@ -107,6 +107,141 @@ CommMonitor::recvFunctionalSnoop(PacketPtr pkt)
     slavePort.sendFunctionalSnoop(pkt);
 }
 
+CommMonitor::MonitorStats::MonitorStats(Stats::Group *parent,
+                                        const CommMonitorParams *params)
+    : Stats::Group(parent),
+
+      disableBurstLengthHists(params->disable_burst_length_hists),
+      ADD_STAT(readBurstLengthHist,
+               "Histogram of burst lengths of transmitted packets"),
+      ADD_STAT(writeBurstLengthHist,
+               "Histogram of burst lengths of transmitted packets"),
+
+      disableBandwidthHists(params->disable_bandwidth_hists),
+      readBytes(0),
+      ADD_STAT(readBandwidthHist,
+               "Histogram of read bandwidth per sample period (bytes/s)"),
+      ADD_STAT(totalReadBytes, "Number of bytes read"),
+      ADD_STAT(averageReadBandwidth, "Average read bandwidth (bytes/s)",
+               totalReadBytes / simSeconds),
+
+      writtenBytes(0),
+      ADD_STAT(writeBandwidthHist, "Histogram of write bandwidth (bytes/s)"),
+      ADD_STAT(totalWrittenBytes, "Number of bytes written"),
+      ADD_STAT(averageWriteBandwidth, "Average write bandwidth (bytes/s)",
+               totalWrittenBytes / simSeconds),
+
+      disableLatencyHists(params->disable_latency_hists),
+      ADD_STAT(readLatencyHist, "Read request-response latency"),
+      ADD_STAT(writeLatencyHist, "Write request-response latency"),
+
+      disableITTDists(params->disable_itt_dists),
+      ADD_STAT(ittReadRead, "Read-to-read inter transaction time"),
+      ADD_STAT(ittWriteWrite , "Write-to-write inter transaction time"),
+      ADD_STAT(ittReqReq, "Request-to-request inter transaction time"),
+      timeOfLastRead(0), timeOfLastWrite(0), timeOfLastReq(0),
+
+      disableOutstandingHists(params->disable_outstanding_hists),
+      ADD_STAT(outstandingReadsHist, "Outstanding read transactions"),
+      outstandingReadReqs(0),
+      ADD_STAT(outstandingWritesHist, "Outstanding write transactions"),
+      outstandingWriteReqs(0),
+
+      disableTransactionHists(params->disable_transaction_hists),
+      ADD_STAT(readTransHist,
+               "Histogram of read transactions per sample period"),
+      readTrans(0),
+      ADD_STAT(writeTransHist,
+               "Histogram of write transactions per sample period"),
+      writeTrans(0),
+
+      disableAddrDists(params->disable_addr_dists),
+      readAddrMask(params->read_addr_mask),
+      writeAddrMask(params->write_addr_mask),
+      ADD_STAT(readAddrDist, "Read address distribution"),
+      ADD_STAT(writeAddrDist, "Write address distribution")
+{
+    using namespace Stats;
+
+    readBurstLengthHist
+        .init(params->burst_length_bins)
+        .flags(disableBurstLengthHists ? nozero : pdf);
+
+    writeBurstLengthHist
+        .init(params->burst_length_bins)
+        .flags(disableBurstLengthHists ? nozero : pdf);
+
+    // Stats based on received responses
+    readBandwidthHist
+        .init(params->bandwidth_bins)
+        .flags(disableBandwidthHists ? nozero : pdf);
+
+    averageReadBandwidth
+        .flags(disableBandwidthHists ? nozero : pdf);
+
+    totalReadBytes
+        .flags(disableBandwidthHists ? nozero : pdf);
+
+    // Stats based on successfully sent requests
+    writeBandwidthHist
+        .init(params->bandwidth_bins)
+        .flags(disableBandwidthHists ? (pdf | nozero) : pdf);
+
+    averageWriteBandwidth
+        .flags(disableBandwidthHists ? nozero : pdf);
+
+    totalWrittenBytes
+        .flags(disableBandwidthHists ? nozero : pdf);
+
+
+    readLatencyHist
+        .init(params->latency_bins)
+        .flags(disableLatencyHists ? nozero : pdf);
+
+    writeLatencyHist
+        .init(params->latency_bins)
+        .flags(disableLatencyHists ? nozero : pdf);
+
+    ittReadRead
+        .init(1, params->itt_max_bin, params->itt_max_bin /
+              params->itt_bins)
+        .flags(disableITTDists ? nozero : pdf);
+
+    ittWriteWrite
+        .init(1, params->itt_max_bin, params->itt_max_bin /
+              params->itt_bins)
+        .flags(disableITTDists ? nozero : pdf);
+
+    ittReqReq
+        .init(1, params->itt_max_bin, params->itt_max_bin /
+              params->itt_bins)
+        .flags(disableITTDists ? nozero : pdf);
+
+    outstandingReadsHist
+        .init(params->outstanding_bins)
+        .flags(disableOutstandingHists ? nozero : pdf);
+
+    outstandingWritesHist
+        .init(params->outstanding_bins)
+        .flags(disableOutstandingHists ? nozero : pdf);
+
+    readTransHist
+        .init(params->transaction_bins)
+        .flags(disableTransactionHists ? nozero : pdf);
+
+    writeTransHist
+        .init(params->transaction_bins)
+        .flags(disableTransactionHists ? nozero : pdf);
+
+    readAddrDist
+        .init(0)
+        .flags(disableAddrDists ? nozero : pdf);
+
+    writeAddrDist
+        .init(0)
+        .flags(disableAddrDists ? nozero : pdf);
+}
+
 void
 CommMonitor::MonitorStats::updateReqStats(
     const ProbePoints::PacketInfo& pkt_info, bool is_atomic,
@@ -379,134 +514,6 @@ CommMonitor::recvRangeChange()
     slavePort.sendRangeChange();
 }
 
-void
-CommMonitor::regStats()
-{
-    SimObject::regStats();
-
-    // Initialise all the monitor stats
-    using namespace Stats;
-
-    stats.readBurstLengthHist
-        .init(params()->burst_length_bins)
-        .name(name() + ".readBurstLengthHist")
-        .desc("Histogram of burst lengths of transmitted packets")
-        .flags(stats.disableBurstLengthHists ? nozero : pdf);
-
-    stats.writeBurstLengthHist
-        .init(params()->burst_length_bins)
-        .name(name() + ".writeBurstLengthHist")
-        .desc("Histogram of burst lengths of transmitted packets")
-        .flags(stats.disableBurstLengthHists ? nozero : pdf);
-
-    // Stats based on received responses
-    stats.readBandwidthHist
-        .init(params()->bandwidth_bins)
-        .name(name() + ".readBandwidthHist")
-        .desc("Histogram of read bandwidth per sample period (bytes/s)")
-        .flags(stats.disableBandwidthHists ? nozero : pdf);
-
-    stats.averageReadBW
-        .name(name() + ".averageReadBandwidth")
-        .desc("Average read bandwidth (bytes/s)")
-        .flags(stats.disableBandwidthHists ? nozero : pdf);
-
-    stats.totalReadBytes
-        .name(name() + ".totalReadBytes")
-        .desc("Number of bytes read")
-        .flags(stats.disableBandwidthHists ? nozero : pdf);
-
-    stats.averageReadBW = stats.totalReadBytes / simSeconds;
-
-    // Stats based on successfully sent requests
-    stats.writeBandwidthHist
-        .init(params()->bandwidth_bins)
-        .name(name() + ".writeBandwidthHist")
-        .desc("Histogram of write bandwidth (bytes/s)")
-        .flags(stats.disableBandwidthHists ? (pdf | nozero) : pdf);
-
-    stats.averageWriteBW
-        .name(name() + ".averageWriteBandwidth")
-        .desc("Average write bandwidth (bytes/s)")
-        .flags(stats.disableBandwidthHists ? nozero : pdf);
-
-    stats.totalWrittenBytes
-        .name(name() + ".totalWrittenBytes")
-        .desc("Number of bytes written")
-        .flags(stats.disableBandwidthHists ? nozero : pdf);
-
-    stats.averageWriteBW = stats.totalWrittenBytes / simSeconds;
-
-    stats.readLatencyHist
-        .init(params()->latency_bins)
-        .name(name() + ".readLatencyHist")
-        .desc("Read request-response latency")
-        .flags(stats.disableLatencyHists ? nozero : pdf);
-
-    stats.writeLatencyHist
-        .init(params()->latency_bins)
-        .name(name() + ".writeLatencyHist")
-        .desc("Write request-response latency")
-        .flags(stats.disableLatencyHists ? nozero : pdf);
-
-    stats.ittReadRead
-        .init(1, params()->itt_max_bin, params()->itt_max_bin /
-              params()->itt_bins)
-        .name(name() + ".ittReadRead")
-        .desc("Read-to-read inter transaction time")
-        .flags(stats.disableITTDists ? nozero : pdf);
-
-    stats.ittWriteWrite
-        .init(1, params()->itt_max_bin, params()->itt_max_bin /
-              params()->itt_bins)
-        .name(name() + ".ittWriteWrite")
-        .desc("Write-to-write inter transaction time")
-        .flags(stats.disableITTDists ? nozero : pdf);
-
-    stats.ittReqReq
-        .init(1, params()->itt_max_bin, params()->itt_max_bin /
-              params()->itt_bins)
-        .name(name() + ".ittReqReq")
-        .desc("Request-to-request inter transaction time")
-        .flags(stats.disableITTDists ? nozero : pdf);
-
-    stats.outstandingReadsHist
-        .init(params()->outstanding_bins)
-        .name(name() + ".outstandingReadsHist")
-        .desc("Outstanding read transactions")
-        .flags(stats.disableOutstandingHists ? nozero : pdf);
-
-    stats.outstandingWritesHist
-        .init(params()->outstanding_bins)
-        .name(name() + ".outstandingWritesHist")
-        .desc("Outstanding write transactions")
-        .flags(stats.disableOutstandingHists ? nozero : pdf);
-
-    stats.readTransHist
-        .init(params()->transaction_bins)
-        .name(name() + ".readTransHist")
-        .desc("Histogram of read transactions per sample period")
-        .flags(stats.disableTransactionHists ? nozero : pdf);
-
-    stats.writeTransHist
-        .init(params()->transaction_bins)
-        .name(name() + ".writeTransHist")
-        .desc("Histogram of write transactions per sample period")
-        .flags(stats.disableTransactionHists ? nozero : pdf);
-
-    stats.readAddrDist
-        .init(0)
-        .name(name() + ".readAddrDist")
-        .desc("Read address distribution")
-        .flags(stats.disableAddrDists ? nozero : pdf);
-
-    stats.writeAddrDist
-        .init(0)
-        .name(name() + ".writeAddrDist")
-        .desc("Write address distribution")
-        .flags(stats.disableAddrDists ? nozero : pdf);
-}
-
 void
 CommMonitor::samplePeriodic()
 {
index 350155924c6f1d87d623681be8fd19807fbecd7a..7d86836ae11dd230e850b1590b09c782f4ee567a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, 2015, 2018 ARM Limited
+ * Copyright (c) 2012-2013, 2015, 2018-2019 ARM Limited
  * Copyright (c) 2016 Google Inc.
  * Copyright (c) 2017, Centre National de la Recherche Scientifique
  * All rights reserved.
@@ -80,7 +80,6 @@ class CommMonitor : public SimObject
     CommMonitor(Params* params);
 
     void init() override;
-    void regStats() override;
     void startup() override;
     void regProbePoints() override;
 
@@ -275,9 +274,8 @@ class CommMonitor : public SimObject
     bool tryTiming(PacketPtr pkt);
 
     /** Stats declarations, all in a struct for convenience. */
-    struct MonitorStats
+    struct MonitorStats : public Stats::Group
     {
-
         /** Disable flag for burst length histograms **/
         bool disableBurstLengthHists;
 
@@ -296,8 +294,8 @@ class CommMonitor : public SimObject
          */
         unsigned int readBytes;
         Stats::Histogram readBandwidthHist;
-        Stats::Formula averageReadBW;
         Stats::Scalar totalReadBytes;
+        Stats::Formula averageReadBandwidth;
 
         /**
          * Histogram for write bandwidth per sample window. The
@@ -305,8 +303,8 @@ class CommMonitor : public SimObject
          */
         unsigned int writtenBytes;
         Stats::Histogram writeBandwidthHist;
-        Stats::Formula averageWriteBW;
         Stats::Scalar totalWrittenBytes;
+        Stats::Formula averageWriteBandwidth;
 
         /** Disable flag for latency histograms. */
         bool disableLatencyHists;
@@ -389,21 +387,7 @@ class CommMonitor : public SimObject
          * that are not statistics themselves, but used to control the
          * stats or track values during a sample period.
          */
-        MonitorStats(const CommMonitorParams* params) :
-            disableBurstLengthHists(params->disable_burst_length_hists),
-            disableBandwidthHists(params->disable_bandwidth_hists),
-            readBytes(0), writtenBytes(0),
-            disableLatencyHists(params->disable_latency_hists),
-            disableITTDists(params->disable_itt_dists),
-            timeOfLastRead(0), timeOfLastWrite(0), timeOfLastReq(0),
-            disableOutstandingHists(params->disable_outstanding_hists),
-            outstandingReadReqs(0), outstandingWriteReqs(0),
-            disableTransactionHists(params->disable_transaction_hists),
-            readTrans(0), writeTrans(0),
-            disableAddrDists(params->disable_addr_dists),
-            readAddrMask(params->read_addr_mask),
-            writeAddrMask(params->write_addr_mask)
-        { }
+        MonitorStats(Stats::Group *parent, const CommMonitorParams* params);
 
         void updateReqStats(const ProbePoints::PacketInfo& pkt, bool is_atomic,
                             bool expects_response);