Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/13415

Change subject: mem-cache: Virtualize block print
......................................................................

mem-cache: Virtualize block print

Encapsulate and virtualize block print, so that relevant
information can be easily printed anywhere.

Change-Id: I91109c29c126755183a0fd2b4446f5335e64076b
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/mem/cache/base.cc
M src/mem/cache/blk.hh
M src/mem/cache/sector_blk.cc
M src/mem/cache/sector_blk.hh
M src/mem/cache/tags/base.cc
M src/mem/cache/tags/base_set_assoc.hh
M src/mem/cache/tags/fa_lru.cc
M src/mem/cache/tags/fa_lru.hh
M src/mem/cache/tags/sector_tags.cc
9 files changed, 38 insertions(+), 15 deletions(-)



diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index 736f167..0eeb192 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -52,6 +52,7 @@
 #include "base/logging.hh"
 #include "debug/Cache.hh"
 #include "debug/CachePort.hh"
+#include "debug/CacheRepl.hh"
 #include "debug/CacheVerbose.hh"
 #include "mem/cache/mshr.hh"
 #include "mem/cache/prefetch/base.hh"
@@ -1237,6 +1238,9 @@
     if (!victim)
         return nullptr;

+    // Print victim block's information
+    DPRINTF(CacheRepl, "Replacement victim: %s\n", victim->print());
+
     // Check for transient state allocations. If any of the entries listed
     // for eviction has a transient state, the allocation fails
     for (const auto& blk : evict_blks) {
diff --git a/src/mem/cache/blk.hh b/src/mem/cache/blk.hh
index cc6d905..6d91e55 100644
--- a/src/mem/cache/blk.hh
+++ b/src/mem/cache/blk.hh
@@ -292,12 +292,12 @@
     }

     /**
-     * Pretty-print a tag, and interpret state bits to readable form
+ * Pretty-print tag, set and way, and interpret state bits to readable form
      * including mapping to a MOESI state.
      *
      * @return string with basic state information
      */
-    std::string print() const
+    virtual std::string print() const
     {
         /**
          *  state       M   O   E   S   I
@@ -334,8 +334,9 @@
           default:    s = 'T'; break; // @TODO add other types
         }
return csprintf("state: %x (%c) valid: %d writable: %d readable: %d "
-                        "dirty: %d tag: %x", status, s, isValid(),
-                        isWritable(), isReadable(), isDirty(), tag);
+ "dirty: %d | tag: %#x set: %#x way: %#x", status, s, + isValid(), isWritable(), isReadable(), isDirty(), tag,
+                        getSet(), getWay());
     }

     /**
diff --git a/src/mem/cache/sector_blk.cc b/src/mem/cache/sector_blk.cc
index 07d9e95..5607f4c 100644
--- a/src/mem/cache/sector_blk.cc
+++ b/src/mem/cache/sector_blk.cc
@@ -37,6 +37,7 @@

 #include <cassert>

+#include "base/cprintf.hh"
 #include "base/logging.hh"

 void
@@ -86,6 +87,13 @@
     _sectorBlk->setTag(tag);
 }

+std::string
+SectorSubBlk::print() const
+{
+    return csprintf("%s sector offset: %#x", CacheBlk::print(),
+                    getSectorOffset());
+}
+
 bool
 SectorBlk::isValid() const
 {
diff --git a/src/mem/cache/sector_blk.hh b/src/mem/cache/sector_blk.hh
index f8f8cd5..66d83a2 100644
--- a/src/mem/cache/sector_blk.hh
+++ b/src/mem/cache/sector_blk.hh
@@ -114,6 +114,13 @@
      */
void insert(const Addr tag, const bool is_secure, const int src_master_ID,
                 const uint32_t task_ID) override;
+
+    /**
+     * Pretty-print sector offset and other CacheBlk information.
+     *
+     * @return string with basic state information
+     */
+    std::string print() const override;
 };

 /**
diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc
index dddb8c7..965e4ba 100644
--- a/src/mem/cache/tags/base.cc
+++ b/src/mem/cache/tags/base.cc
@@ -201,8 +201,7 @@

     auto print_blk = [&str](CacheBlk &blk) {
         if (blk.isValid())
-            str += csprintf("\tset: %x, way: %x %s\n", blk.getSet(),
-                            blk.getWay(), blk.print());
+            str += csprintf("\tBlock: %s\n", blk.print());
     };
     forEachBlk(print_blk);

diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh
index 01bfa05..11c0c8d 100644
--- a/src/mem/cache/tags/base_set_assoc.hh
+++ b/src/mem/cache/tags/base_set_assoc.hh
@@ -54,7 +54,6 @@

 #include "base/logging.hh"
 #include "base/types.hh"
-#include "debug/CacheRepl.hh"
 #include "mem/cache/base.hh"
 #include "mem/cache/blk.hh"
 #include "mem/cache/replacement_policies/base.hh"
@@ -187,9 +186,6 @@
         // There is only one eviction for this replacement
         evict_blks.push_back(victim);

- DPRINTF(CacheRepl, "set %x, way %x: selecting blk for replacement\n",
-                victim->getSet(), victim->getWay());
-
         return victim;
     }

diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc
index fa7c659..319d560 100644
--- a/src/mem/cache/tags/fa_lru.cc
+++ b/src/mem/cache/tags/fa_lru.cc
@@ -57,6 +57,12 @@
 #include "base/logging.hh"
 #include "mem/cache/base.hh"

+std::string
+FALRUBlk::print() const
+{
+ return csprintf("%s inCachesMask: %#x", CacheBlk::print(), inCachesMask);
+}
+
 FALRU::FALRU(const Params *p)
     : BaseTags(p),

diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh
index 0d9a8d4..c2f9834 100644
--- a/src/mem/cache/tags/fa_lru.hh
+++ b/src/mem/cache/tags/fa_lru.hh
@@ -92,6 +92,13 @@

     /** A bit mask of the caches that fit this block. */
     CachesMask inCachesMask;
+
+    /**
+     * Pretty-print inCachesMask and other CacheBlk information.
+     *
+     * @return string with basic state information
+     */
+    std::string print() const override;
 };

 /**
diff --git a/src/mem/cache/tags/sector_tags.cc b/src/mem/cache/tags/sector_tags.cc
index f256807..e993e29 100644
--- a/src/mem/cache/tags/sector_tags.cc
+++ b/src/mem/cache/tags/sector_tags.cc
@@ -42,7 +42,6 @@
 #include "base/intmath.hh"
 #include "base/logging.hh"
 #include "base/types.hh"
-#include "debug/CacheRepl.hh"
 #include "mem/cache/base.hh"
 #include "mem/cache/replacement_policies/base.hh"
 #include "mem/cache/tags/indexing_policies/base.hh"
@@ -277,10 +276,6 @@
         }
     }

-    DPRINTF(CacheRepl, "set %x, way %x, sector offset %x: selecting blk " \
-            "for replacement\n", victim->getSet(), victim->getWay(),
-            victim->getSectorOffset());
-
     return victim;
 }


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/13415
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I91109c29c126755183a0fd2b4446f5335e64076b
Gerrit-Change-Number: 13415
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to