mem: convert base prefetcher and queued to new style stats
authoreavivi <eavivi@ucdavis.edu>
Wed, 26 Aug 2020 17:28:28 +0000 (10:28 -0700)
committerEden Avivi <eavivi@ucdavis.edu>
Mon, 31 Aug 2020 16:36:53 +0000 (16:36 +0000)
Base and Queued inside src/mem/cache/prefetch converted

Change-Id: I3d5907b58efefc4d8522b89f073507f2548bff2f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33475
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/cache/prefetch/base.cc
src/mem/cache/prefetch/base.hh
src/mem/cache/prefetch/queued.cc
src/mem/cache/prefetch/queued.hh

index d4223aacd355ab19b85dc340891309517d771aba..4e484e5e6da9eccd6573bad2ff2b8066c8083269 100644 (file)
@@ -94,7 +94,8 @@ Base::Base(const BasePrefetcherParams *p)
       onWrite(p->on_write), onData(p->on_data), onInst(p->on_inst),
       masterId(p->sys->getMasterId(this)), pageBytes(p->sys->getPageBytes()),
       prefetchOnAccess(p->prefetch_on_access),
-      useVirtualAddresses(p->use_virtual_addresses), issuedPrefetches(0),
+      useVirtualAddresses(p->use_virtual_addresses),
+      prefetchStats(this), issuedPrefetches(0),
       usefulPrefetches(0), tlb(nullptr)
 {
 }
@@ -109,19 +110,13 @@ Base::setCache(BaseCache *_cache)
     blkSize = cache->getBlockSize();
     lBlkSize = floorLog2(blkSize);
 }
-
-void
-Base::regStats()
+Base::StatGroup::StatGroup(Stats::Group *parent)
+    : Stats::Group(parent),
+    ADD_STAT(pfIssued, "number of hwpf issued")
 {
-    ClockedObject::regStats();
-
-    pfIssued
-        .name(name() + ".num_hwpf_issued")
-        .desc("number of hwpf issued")
-        ;
-
 }
 
+
 bool
 Base::observeAccess(const PacketPtr &pkt, bool miss) const
 {
index 783fb011e5e22512d0f133b17a233713e93375f0..5f7ad81d5a8122ed2939cab688f25f7da06c3f00 100644 (file)
@@ -49,6 +49,7 @@
 #include <cstdint>
 
 #include "arch/generic/tlb.hh"
+#include "arch/isa_traits.hh"
 #include "base/statistics.hh"
 #include "base/types.hh"
 #include "mem/packet.hh"
@@ -317,8 +318,11 @@ class Base : public ClockedObject
     Addr pageOffset(Addr a) const;
     /** Build the address of the i-th block inside the page */
     Addr pageIthBlockAddress(Addr page, uint32_t i) const;
-
-    Stats::Scalar pfIssued;
+    struct StatGroup : public Stats::Group
+    {
+        StatGroup(Stats::Group *parent);
+        Stats::Scalar pfIssued;
+    } prefetchStats;
 
     /** Total prefetches issued */
     uint64_t issuedPrefetches;
@@ -348,10 +352,6 @@ class Base : public ClockedObject
 
     virtual Tick nextPrefetchReadyTime() const = 0;
 
-    /**
-     * Register local statistics.
-     */
-    void regStats() override;
 
     /**
      * Register probe points for this object.
index c2ae090d37c142a58c2c9abc969a7107d40ec7fd..6b89c2b16ce016a0b8fe7f3a083926c759361881 100644 (file)
@@ -97,7 +97,7 @@ Queued::Queued(const QueuedPrefetcherParams *p)
       latency(p->latency), queueSquash(p->queue_squash),
       queueFilter(p->queue_filter), cacheSnoop(p->cache_snoop),
       tagPrefetch(p->tag_prefetch),
-      throttleControlPct(p->throttle_control_percentage)
+      throttleControlPct(p->throttle_control_percentage), statsQueued(this)
 {
 }
 
@@ -174,13 +174,13 @@ Queued::notify(const PacketPtr &pkt, const PrefetchInfo &pfi)
         addr_prio.first = blockAddress(addr_prio.first);
 
         if (!samePage(addr_prio.first, pfi.getAddr())) {
-            pfSpanPage += 1;
+            statsQueued.pfSpanPage += 1;
         }
 
         bool can_cross_page = (tlb != nullptr);
         if (can_cross_page || samePage(addr_prio.first, pfi.getAddr())) {
             PrefetchInfo new_pfi(pfi,addr_prio.first);
-            pfIdentified++;
+            statsQueued.pfIdentified++;
             DPRINTF(HWPrefetch, "Found a pf candidate addr: %#x, "
                     "inserting into prefetch queue.\n", new_pfi.getAddr());
             // Create and insert the request
@@ -214,7 +214,7 @@ Queued::getPacket()
     PacketPtr pkt = pfq.front().pkt;
     pfq.pop_front();
 
-    pfIssued++;
+    prefetchStats.pfIssued++;
     issuedPrefetches += 1;
     assert(pkt != nullptr);
     DPRINTF(HWPrefetch, "Generating prefetch for %#x.\n", pkt->getAddr());
@@ -222,31 +222,17 @@ Queued::getPacket()
     processMissingTranslations(queueSize - pfq.size());
     return pkt;
 }
-
-void
-Queued::regStats()
+Queued::QueuedStats::QueuedStats(Stats::Group *parent)
+    : Stats::Group(parent),
+    ADD_STAT(pfIdentified, "number of prefetch candidates identified"),
+    ADD_STAT(pfBufferHit,
+     "number of redundant prefetches already in prefetch queue"),
+    ADD_STAT(pfInCache,
+     "number of redundant prefetches already in cache/mshr dropped"),
+    ADD_STAT(pfRemovedFull,
+     "number of prefetches dropped due to prefetch queue size"),
+    ADD_STAT(pfSpanPage, "number of prefetches that crossed the page")
 {
-    Base::regStats();
-
-    pfIdentified
-        .name(name() + ".pfIdentified")
-        .desc("number of prefetch candidates identified");
-
-    pfBufferHit
-        .name(name() + ".pfBufferHit")
-        .desc("number of redundant prefetches already in prefetch queue");
-
-    pfInCache
-        .name(name() + ".pfInCache")
-        .desc("number of redundant prefetches already in cache/mshr dropped");
-
-    pfRemovedFull
-        .name(name() + ".pfRemovedFull")
-        .desc("number of prefetches dropped due to prefetch queue size");
-
-    pfSpanPage
-        .name(name() + ".pfSpanPage")
-        .desc("number of prefetches that crossed the page");
 }
 
 
@@ -285,7 +271,7 @@ Queued::translationComplete(DeferredPacket *dp, bool failed)
         // check if this prefetch is already redundant
         if (cacheSnoop && (inCache(target_paddr, it->pfInfo.isSecure()) ||
                     inMissQueue(target_paddr, it->pfInfo.isSecure()))) {
-            pfInCache++;
+            statsQueued.pfInCache++;
             DPRINTF(HWPrefetch, "Dropping redundant in "
                     "cache/MSHR prefetch addr:%#x\n", target_paddr);
         } else {
@@ -314,7 +300,7 @@ Queued::alreadyInQueue(std::list<DeferredPacket> &queue,
 
     /* If the address is already in the queue, update priority and leave */
     if (it != queue.end()) {
-        pfBufferHit++;
+        statsQueued.pfBufferHit++;
         if (it->priority < priority) {
             /* Update priority value and position in the queue */
             it->priority = priority;
@@ -421,7 +407,7 @@ Queued::insert(const PacketPtr &pkt, PrefetchInfo &new_pfi,
     if (has_target_pa && cacheSnoop &&
             (inCache(target_paddr, new_pfi.isSecure()) ||
             inMissQueue(target_paddr, new_pfi.isSecure()))) {
-        pfInCache++;
+        statsQueued.pfInCache++;
         DPRINTF(HWPrefetch, "Dropping redundant in "
                 "cache/MSHR prefetch addr:%#x\n", target_paddr);
         return;
@@ -452,7 +438,7 @@ Queued::addToQueue(std::list<DeferredPacket> &queue,
 {
     /* Verify prefetch buffer space for request */
     if (queue.size() == queueSize) {
-        pfRemovedFull++;
+        statsQueued.pfRemovedFull++;
         /* Lowest priority packet */
         iterator it = queue.end();
         panic_if (it == queue.begin(),
index 5af9093cd63d544d58f2bb1fcc8a0359c366f6d1..96cf311c8cc1843dec0e70482395be1149c1d1e6 100644 (file)
@@ -167,13 +167,16 @@ class Queued : public Base
     /** Percentage of requests that can be throttled */
     const unsigned int throttleControlPct;
 
-    // STATS
-    Stats::Scalar pfIdentified;
-    Stats::Scalar pfBufferHit;
-    Stats::Scalar pfInCache;
-    Stats::Scalar pfRemovedFull;
-    Stats::Scalar pfSpanPage;
-
+    struct QueuedStats : public Stats::Group
+    {
+        QueuedStats(Stats::Group *parent);
+        // STATS
+        Stats::Scalar pfIdentified;
+        Stats::Scalar pfBufferHit;
+        Stats::Scalar pfInCache;
+        Stats::Scalar pfRemovedFull;
+        Stats::Scalar pfSpanPage;
+    } statsQueued;
   public:
     using AddrPriority = std::pair<Addr, int32_t>;
 
@@ -193,8 +196,6 @@ class Queued : public Base
         return pfq.empty() ? MaxTick : pfq.front().tick;
     }
 
-    void regStats() override;
-
   private:
 
     /**