mem-cache: Use CacheBlk parameter on address regeneration
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Tue, 6 Mar 2018 10:48:21 +0000 (11:48 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Fri, 9 Mar 2018 09:50:56 +0000 (09:50 +0000)
Skewed caches need to know the way to regenerate a block address.

Change-Id: I62c61ac9509eff2f37bad36862751956db7a6e40
Reviewed-on: https://gem5-review.googlesource.com/8782
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/cache/cache.cc
src/mem/cache/tags/base.hh
src/mem/cache/tags/base_set_assoc.hh
src/mem/cache/tags/fa_lru.hh
src/mem/cache/tags/lru.cc
src/mem/cache/tags/random_repl.cc

index 7bf073419807c6bc1e7fce0ebb35106484d96e05..85c96772c9aca45b3cae886edbcdf343cc5480ae 100644 (file)
@@ -1659,8 +1659,8 @@ Cache::writebackBlk(CacheBlk *blk)
 
     writebacks[Request::wbMasterId]++;
 
-    Request *req = new Request(tags->regenerateBlkAddr(blk->tag, blk->set),
-                               blkSize, 0, Request::wbMasterId);
+    Request *req = new Request(tags->regenerateBlkAddr(blk), blkSize, 0,
+                               Request::wbMasterId);
     if (blk->isSecure())
         req->setFlags(Request::SECURE);
 
@@ -1694,8 +1694,8 @@ Cache::writebackBlk(CacheBlk *blk)
 PacketPtr
 Cache::writecleanBlk(CacheBlk *blk, Request::Flags dest, PacketId id)
 {
-    Request *req = new Request(tags->regenerateBlkAddr(blk->tag, blk->set),
-                               blkSize, 0, Request::wbMasterId);
+    Request *req = new Request(tags->regenerateBlkAddr(blk), blkSize, 0,
+                               Request::wbMasterId);
     if (blk->isSecure()) {
         req->setFlags(Request::SECURE);
     }
@@ -1737,7 +1737,7 @@ Cache::cleanEvictBlk(CacheBlk *blk)
     assert(blk && blk->isValid() && !blk->isDirty());
     // Creating a zero sized write, a message to the snoop filter
     Request *req =
-        new Request(tags->regenerateBlkAddr(blk->tag, blk->set), blkSize, 0,
+        new Request(tags->regenerateBlkAddr(blk), blkSize, 0,
                     Request::wbMasterId);
     if (blk->isSecure())
         req->setFlags(Request::SECURE);
@@ -1780,8 +1780,8 @@ Cache::writebackVisitor(CacheBlk &blk)
     if (blk.isDirty()) {
         assert(blk.isValid());
 
-        Request request(tags->regenerateBlkAddr(blk.tag, blk.set),
-                        blkSize, 0, Request::funcMasterId);
+        Request request(tags->regenerateBlkAddr(&blk), blkSize, 0,
+                        Request::funcMasterId);
         request.taskId(blk.task_id);
         if (blk.isSecure()) {
             request.setFlags(Request::SECURE);
@@ -1823,7 +1823,7 @@ Cache::allocateBlock(Addr addr, bool is_secure, PacketList &writebacks)
         return nullptr;
 
     if (blk->isValid()) {
-        Addr repl_addr = tags->regenerateBlkAddr(blk->tag, blk->set);
+        Addr repl_addr = tags->regenerateBlkAddr(blk);
         MSHR *repl_mshr = mshrQueue.findMatch(repl_addr, blk->isSecure());
         if (repl_mshr) {
             // must be an outstanding upgrade request
index dfd8aeb62258cce5371e524f5f09c0b32a2ed148..9e7242c1b14aceca2f28a44b24197818ba505b14 100644 (file)
@@ -255,7 +255,13 @@ class BaseTags : public ClockedObject
 
     virtual void insertBlock(PacketPtr pkt, CacheBlk *blk) = 0;
 
-    virtual Addr regenerateBlkAddr(Addr tag, unsigned set) const = 0;
+    /**
+     * Regenerate the block address.
+     *
+     * @param block The block.
+     * @return the block address.
+     */
+    virtual Addr regenerateBlkAddr(const CacheBlk* blk) const = 0;
 
     virtual CacheBlk* findVictim(Addr addr) = 0;
 
index 835b0cfd4592eeebb5950f8b5ccde34ea2653e79..1fd739110fc1ed7c19e83c4b43fcc7a644d0201f 100644 (file)
@@ -301,14 +301,14 @@ public:
     }
 
     /**
-     * Regenerate the block address from the tag.
-     * @param tag The tag of the block.
-     * @param set The set of the block.
-     * @return The block address.
+     * Regenerate the block address from the tag and set.
+     *
+     * @param block The block.
+     * @return the block address.
      */
-    Addr regenerateBlkAddr(Addr tag, unsigned set) const override
+    Addr regenerateBlkAddr(const CacheBlk* blk) const override
     {
-        return ((tag << tagShift) | ((Addr)set << setShift));
+        return ((blk->tag << tagShift) | ((Addr)blk->set << setShift));
     }
 
     /**
index a266fb516c86e69c0c166a371cb95f26225631bb..559f56e2813f8ecfda52b4e9d1e3334c3783285a 100644 (file)
@@ -242,14 +242,14 @@ public:
     }
 
     /**
-     * Regenerate the block address from the tag and the set.
-     * @param tag The tag of the block.
-     * @param set The set the block belongs to.
+     * Regenerate the block address from the tag.
+     *
+     * @param block The block.
      * @return the block address.
      */
-    Addr regenerateBlkAddr(Addr tag, unsigned set) const override
+    Addr regenerateBlkAddr(const CacheBlk* blk) const override
     {
-        return (tag);
+        return blk->tag;
     }
 
     /**
index 5fc48b96360e076b986669d7c83ed901181c211d..4302a8de624f8419524066111032d12397b46ae2 100644 (file)
@@ -64,7 +64,7 @@ LRU::accessBlock(Addr addr, bool is_secure, Cycles &lat)
         // move this block to head of the MRU list
         sets[blk->set].moveToHead(blk);
         DPRINTF(CacheRepl, "set %x: moving blk %x (%s) to MRU\n",
-                blk->set, regenerateBlkAddr(blk->tag, blk->set),
+                blk->set, regenerateBlkAddr(blk),
                 is_secure ? "s" : "ns");
     }
 
@@ -88,7 +88,7 @@ LRU::findVictim(Addr addr)
 
     if (blk && blk->isValid()) {
         DPRINTF(CacheRepl, "set %x: selecting blk %x for replacement\n",
-                set, regenerateBlkAddr(blk->tag, set));
+                set, regenerateBlkAddr(blk));
     }
 
     return blk;
index c06b120963b80093343f4f30ce302a7c62795e07..aa5f6fcb973ff10124f755a1bd53176ab2be3250 100644 (file)
@@ -86,7 +86,7 @@ RandomRepl::findVictim(Addr addr)
         assert(blk->way < allocAssoc);
 
         DPRINTF(CacheRepl, "set %x: selecting blk %x for replacement\n",
-                blk->set, regenerateBlkAddr(blk->tag, blk->set));
+                blk->set, regenerateBlkAddr(blk));
     }
 
     return blk;