mem-cache: Override print function of sector and super blocks
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Mon, 3 Jun 2019 13:37:58 +0000 (15:37 +0200)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Thu, 12 Nov 2020 21:46:43 +0000 (21:46 +0000)
Pass management of printing sector and super block's contents to them.

Change-Id: Ided8d404450a0fa39127ac7d2d6578d95691f509
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36582
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/cache/tags/compressed_tags.cc
src/mem/cache/tags/sector_blk.cc
src/mem/cache/tags/sector_blk.hh
src/mem/cache/tags/super_blk.cc
src/mem/cache/tags/super_blk.hh

index f71dedacd730cbf6734aecff41530878bf5cbd25..33d822a55c81555fafb52502324eea27f536c32b 100644 (file)
@@ -150,12 +150,8 @@ CompressedTags::findVictim(Addr addr, const bool is_secure,
         assert(!victim->isValid());
 
         // Print all co-allocated blocks
-        DPRINTF(CacheComp, "Co-Allocation: offset %d with blocks\n", offset);
-        for (const auto& blk : victim_superblock->blks){
-            if (blk->isValid()) {
-                DPRINTFR(CacheComp, "\t[%s]\n", blk->print());
-            }
-        }
+        DPRINTF(CacheComp, "Co-Allocation: offset %d of %s\n", offset,
+                victim_superblock->print());
     }
 
     // Update number of sub-blocks evicted due to a replacement
index f738e0222602fcdd121738bcc1dca6fa7619c0c2..c1c5f6aaf6f8ecfa6ffd53fc2245412a1ee69923 100644 (file)
@@ -150,3 +150,16 @@ SectorBlk::setPosition(const uint32_t set, const uint32_t way)
         blk->setPosition(set, way);
     }
 }
+
+std::string
+SectorBlk::print() const
+{
+    std::string sub_blk_print;
+    for (const auto& sub_blk : blks) {
+        if (sub_blk->isValid()) {
+            sub_blk_print += "\t[" + sub_blk->print() + "]\n";
+        }
+    }
+    return csprintf("%s valid sub-blks (%d):\n%s",
+        TaggedEntry::print(), getNumValid(), sub_blk_print);
+}
index 049f49b58687df747011749cc1cb6c6feca6ce62..ba3245027571d9c723c4bff9f4f86245ed30cbdb 100644 (file)
@@ -177,6 +177,13 @@ class SectorBlk : public TaggedEntry
      * @param way The way of this entry and sub-entries.
      */
     void setPosition(const uint32_t set, const uint32_t way) override;
+
+    /**
+     * Print relevant information for this sector block and its sub-blocks.
+     *
+     * @return A string with the contents of the sector block.
+     */
+    std::string print() const override;
 };
 
 #endif //__MEM_CACHE_TAGS_SECTOR_BLK_HH__
index d81cbc313fade7c88aa81c6e2a0a70a5b59d5759..9a1de45cf129c67de505bee08f4fe335d577f23e 100644 (file)
@@ -236,3 +236,9 @@ SuperBlk::setCompressionFactor(const uint8_t compression_factor)
         compressionFactor = compression_factor;
     }
 }
+
+std::string
+SuperBlk::print() const
+{
+    return csprintf("CF: %d %s", getCompressionFactor(), SectorBlk::print());
+}
index d98c14e19c04c5ece8e4d232deaf1adb14a9fa05..64d73bdf07a13c1460992d19110785d4196a6bc4 100644 (file)
@@ -236,6 +236,8 @@ class SuperBlk : public SectorBlk
     void setCompressionFactor(const uint8_t compression_factor);
 
     void invalidate() override;
+
+    std::string print() const override;
 };
 
 #endif //__MEM_CACHE_TAGS_SUPER_BLK_HH__