mem-cache: Fix set and way of sub-entries
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Tue, 30 Jul 2019 07:41:14 +0000 (09:41 +0200)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Wed, 31 Jul 2019 08:21:52 +0000 (08:21 +0000)
Set and way of sub-entries were not being set previously.
They must be set after the sub-blocks have been assigned
to the main block.

Change-Id: I7b6921b8437b29c472d691cd78cf20f2bb6c7e07
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19669
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/replacement_policies/replaceable_entry.hh
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/sector_tags.cc

index bf54e22649637efbaacb370ba568ee5bedaafa92..dffa4cf106d90a8078782812a16acd6a9fba20b8 100644 (file)
@@ -76,7 +76,9 @@ class ReplaceableEntry
      * @param set The set of this entry.
      * @param way The way of this entry.
      */
-    void setPosition(const uint32_t set, const uint32_t way) {
+    virtual void
+    setPosition(const uint32_t set, const uint32_t way)
+    {
         _set = set;
         _way = way;
     }
index 0896a1b9aa8d3c973a8633abc22e3326720ba5cf..1394be8554d99aa13589212816b5f38e094bbd0b 100644 (file)
@@ -67,9 +67,6 @@ CompressedTags::tagsInit()
         // allocation conditions
         superblock->setBlkSize(blkSize);
 
-        // Link block to indexing policy
-        indexingPolicy->setEntry(superblock, superblock_index);
-
         // Associate a replacement data entry to the block
         superblock->replacementData = replacementPolicy->instantiateEntry();
 
@@ -97,6 +94,9 @@ CompressedTags::tagsInit()
             // Update block index
             ++blk_index;
         }
+
+        // Link block to indexing policy
+        indexingPolicy->setEntry(superblock, superblock_index);
     }
 }
 
index 93b1961d8ab0f6f2abcddac7dbd6dbfde48d6dcb..7e4468dc35681d6a8f2a83f24ccf8cc84dfb6dc7 100644 (file)
@@ -167,3 +167,12 @@ SectorBlk::setSecure()
 {
     _secureBit = true;
 }
+
+void
+SectorBlk::setPosition(const uint32_t set, const uint32_t way)
+{
+    ReplaceableEntry::setPosition(set, way);
+    for (auto& blk : blks) {
+        blk->setPosition(set, way);
+    }
+}
index ca0d9a80693ce59a22ddce97d912356053225df8..a30fb817c7af08c3db68308a283df2ddd40f83ba 100644 (file)
@@ -214,6 +214,14 @@ class SectorBlk : public ReplaceableEntry
      * Set secure bit.
      */
     void setSecure();
+
+    /**
+     * Sets the position of the sub-entries, besides its own.
+     *
+     * @param set The set of this entry and sub-entries.
+     * @param way The way of this entry and sub-entries.
+     */
+    void setPosition(const uint32_t set, const uint32_t way) override;
 };
 
 #endif //__MEM_CACHE_TAGS_SECTOR_BLK_HH__
index 535badb8d7feb15891aed791b594d222a821ee66..1098885c239510cf8223e085d3e5772b2a1edf1f 100644 (file)
@@ -77,9 +77,6 @@ SectorTags::tagsInit()
         // Locate next cache sector
         SectorBlk* sec_blk = &secBlks[sec_blk_index];
 
-        // Link block to indexing policy
-        indexingPolicy->setEntry(sec_blk, sec_blk_index);
-
         // Associate a replacement data entry to the sector
         sec_blk->replacementData = replacementPolicy->instantiateEntry();
 
@@ -107,6 +104,9 @@ SectorTags::tagsInit()
             // Update block index
             ++blk_index;
         }
+
+        // Link block to indexing policy
+        indexingPolicy->setEntry(sec_blk, sec_blk_index);
     }
 }