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

Change subject: mem,stats: Update stats style for FALRU
......................................................................

mem,stats: Update stats style for FALRU

Change-Id: I67a202eb974a31851fbbce0f15b5377ba726bc1c
Signed-off-by: Hoa Nguyen <hoangu...@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36475
Reviewed-by: Daniel Carvalho <oda...@yahoo.com.br>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/mem/cache/tags/fa_lru.cc
M src/mem/cache/tags/fa_lru.hh
2 files changed, 48 insertions(+), 71 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved
  Jason Lowe-Power: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc
index 79019fc..e61a280 100644
--- a/src/mem/cache/tags/fa_lru.cc
+++ b/src/mem/cache/tags/fa_lru.cc
@@ -63,7 +63,7 @@
 FALRU::FALRU(const Params &p)
     : BaseTags(p),

-      cacheTracking(p.min_tracked_cache_size, size, blkSize)
+      cacheTracking(p.min_tracked_cache_size, size, blkSize, this)
 {
     if (!isPowerOf2(blkSize))
         fatal("cache block size (in bytes) `%d' must be a power of two",
@@ -107,13 +107,6 @@
 }

 void
-FALRU::regStats()
-{
-    BaseTags::regStats();
-    cacheTracking.regStats(name());
-}
-
-void
 FALRU::invalidate(CacheBlk *blk)
 {
     // Erase block entry reference in the hash table
@@ -286,6 +279,51 @@
 }

 void
+printSize(std::ostream &stream, size_t size)
+{
+    static const char *SIZES[] = { "B", "kB", "MB", "GB", "TB", "ZB" };
+    int div = 0;
+    while (size >= 1024 && div < (sizeof SIZES / sizeof *SIZES)) {
+        div++;
+        size >>= 10;
+    }
+    stream << size << SIZES[div];
+}
+
+FALRU::CacheTracking::CacheTracking(unsigned min_size, unsigned max_size,
+ unsigned block_size, Stats::Group *parent)
+    : Stats::Group(parent),
+      blkSize(block_size),
+      minTrackedSize(min_size),
+      numTrackedCaches(max_size > min_size ?
+                       floorLog2(max_size) - floorLog2(min_size) : 0),
+      inAllCachesMask(mask(numTrackedCaches)),
+      boundaries(numTrackedCaches),
+      ADD_STAT(hits, "The number of hits in each cache size."),
+      ADD_STAT(misses, "The number of misses in each cache size."),
+      ADD_STAT(accesses, "The number of accesses to the FA LRU cache.")
+{
+    fatal_if(numTrackedCaches > sizeof(CachesMask) * 8,
+             "Not enough bits (%s) in type CachesMask type to keep "
+             "track of %d caches\n", sizeof(CachesMask),
+             numTrackedCaches);
+
+    hits
+        .init(numTrackedCaches + 1);
+    misses
+        .init(numTrackedCaches + 1);
+
+    for (unsigned i = 0; i < numTrackedCaches + 1; ++i) {
+      std::stringstream size_str;
+      printSize(size_str, minTrackedSize << i);
+      hits.subname(i, size_str.str());
+      hits.subdesc(i, "Hits in a " + size_str.str() + " cache");
+      misses.subname(i, size_str.str());
+      misses.subdesc(i, "Misses in a " + size_str.str() + " cache");
+    }
+}
+
+void
FALRU::CacheTracking::check(const FALRUBlk *head, const FALRUBlk *tail) const
 {
 #ifdef FALRU_DEBUG
@@ -412,42 +450,3 @@
     accesses++;
 }

-void
-printSize(std::ostream &stream, size_t size)
-{
-    static const char *SIZES[] = { "B", "kB", "MB", "GB", "TB", "ZB" };
-    int div = 0;
-    while (size >= 1024 && div < (sizeof SIZES / sizeof *SIZES)) {
-        div++;
-        size >>= 10;
-    }
-    stream << size << SIZES[div];
-}
-
-void
-FALRU::CacheTracking::regStats(std::string name)
-{
-    hits
-        .init(numTrackedCaches + 1)
-        .name(name + ".falru_hits")
-        .desc("The number of hits in each cache size.")
-        ;
-    misses
-        .init(numTrackedCaches + 1)
-        .name(name + ".falru_misses")
-        .desc("The number of misses in each cache size.")
-        ;
-    accesses
-        .name(name + ".falru_accesses")
-        .desc("The number of accesses to the FA LRU cache.")
-        ;
-
-    for (unsigned i = 0; i < numTrackedCaches + 1; ++i) {
-        std::stringstream size_str;
-        printSize(size_str, minTrackedSize << i);
-        hits.subname(i, size_str.str());
-        hits.subdesc(i, "Hits in a " + size_str.str() + " cache");
-        misses.subname(i, size_str.str());
-        misses.subdesc(i, "Misses in a " + size_str.str() + " cache");
-    }
-}
diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh
index f24ac0e..1d7e45a 100644
--- a/src/mem/cache/tags/fa_lru.hh
+++ b/src/mem/cache/tags/fa_lru.hh
@@ -162,11 +162,6 @@
     void tagsInit() override;

     /**
-     * Register the stats for this object.
-     */
-    void regStats() override;
-
-    /**
      * Invalidate a cache block.
      * @param blk The block to invalidate.
      */
@@ -278,23 +273,11 @@
      * caches from a set minimum size of interest up to the actual
      * cache size.
      */
-    class CacheTracking
+    class CacheTracking : public Stats::Group
     {
       public:
         CacheTracking(unsigned min_size, unsigned max_size,
-                      unsigned block_size)
-            : blkSize(block_size),
-              minTrackedSize(min_size),
-              numTrackedCaches(max_size > min_size ?
- floorLog2(max_size) - floorLog2(min_size) : 0),
-              inAllCachesMask(mask(numTrackedCaches)),
-              boundaries(numTrackedCaches)
-        {
-            fatal_if(numTrackedCaches > sizeof(CachesMask) * 8,
- "Not enough bits (%s) in type CachesMask type to keep "
-                     "track of %d caches\n", sizeof(CachesMask),
-                     numTrackedCaches);
-        }
+                      unsigned block_size, Stats::Group *parent);

         /**
          * Initialiaze cache blocks and the tracking mechanism
@@ -352,11 +335,6 @@
          */
         void check(const FALRUBlk *head, const FALRUBlk *tail) const;

-        /**
-         * Register the stats for this object.
-         */
-        void regStats(std::string name);
-
       private:
         /** The size of the cache block */
         const unsigned blkSize;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/36475
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: I67a202eb974a31851fbbce0f15b5377ba726bc1c
Gerrit-Change-Number: 36475
Gerrit-PatchSet: 20
Gerrit-Owner: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.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