From: Daniel R. Carvalho Date: Tue, 6 Mar 2018 10:48:21 +0000 (+0100) Subject: mem-cache: Use CacheBlk parameter on address regeneration X-Git-Tag: v19.0.0.0~2245 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ee16a95ec8a7f2d207320670a135065981033f61;p=gem5.git mem-cache: Use CacheBlk parameter on address regeneration 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 Maintainer: Nikos Nikoleris --- diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc index 7bf073419..85c96772c 100644 --- a/src/mem/cache/cache.cc +++ b/src/mem/cache/cache.cc @@ -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 diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh index dfd8aeb62..9e7242c1b 100644 --- a/src/mem/cache/tags/base.hh +++ b/src/mem/cache/tags/base.hh @@ -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; diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh index 835b0cfd4..1fd739110 100644 --- a/src/mem/cache/tags/base_set_assoc.hh +++ b/src/mem/cache/tags/base_set_assoc.hh @@ -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)); } /** diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh index a266fb516..559f56e28 100644 --- a/src/mem/cache/tags/fa_lru.hh +++ b/src/mem/cache/tags/fa_lru.hh @@ -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; } /** diff --git a/src/mem/cache/tags/lru.cc b/src/mem/cache/tags/lru.cc index 5fc48b963..4302a8de6 100644 --- a/src/mem/cache/tags/lru.cc +++ b/src/mem/cache/tags/lru.cc @@ -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; diff --git a/src/mem/cache/tags/random_repl.cc b/src/mem/cache/tags/random_repl.cc index c06b12096..aa5f6fcb9 100644 --- a/src/mem/cache/tags/random_repl.cc +++ b/src/mem/cache/tags/random_repl.cc @@ -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;