Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/8782
Change subject: mem-cache: Add way to address block regeneration
......................................................................
mem-cache: Add way to address block regeneration
Skewed caches need to know the way to regenerate a block address.
Change-Id: I62c61ac9509eff2f37bad36862751956db7a6e40
---
M src/mem/cache/blk.hh
M src/mem/cache/cache.cc
M src/mem/cache/tags/base.hh
M src/mem/cache/tags/base_set_assoc.hh
M src/mem/cache/tags/fa_lru.hh
M src/mem/cache/tags/lru.cc
M src/mem/cache/tags/random_repl.cc
7 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/src/mem/cache/blk.hh b/src/mem/cache/blk.hh
index 44691c1..c2edc1a 100644
--- a/src/mem/cache/blk.hh
+++ b/src/mem/cache/blk.hh
@@ -212,6 +212,7 @@
{
status = 0;
isTouched = false;
+ refCount = 0;
lockList.clear();
}
diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc
index 64438c1..513a2a5 100644
--- a/src/mem/cache/cache.cc
+++ b/src/mem/cache/cache.cc
@@ -1656,8 +1656,8 @@
writebacks[Request::wbMasterId]++;
- Request *req = new Request(tags->regenerateBlkAddr(blk->tag, blk->set),
- blkSize, 0, Request::wbMasterId);
+ Request *req = new Request(tags->regenerateBlkAddr(blk->tag, blk->set,
+ blk->way), blkSize, 0, Request::wbMasterId);
if (blk->isSecure())
req->setFlags(Request::SECURE);
@@ -1691,8 +1691,8 @@
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->tag, blk->set,
+ blk->way), blkSize, 0, Request::wbMasterId);
if (blk->isSecure()) {
req->setFlags(Request::SECURE);
}
@@ -1734,8 +1734,8 @@
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,
- Request::wbMasterId);
+ new Request(tags->regenerateBlkAddr(blk->tag, blk->set, blk->way),
+ blkSize, 0, Request::wbMasterId);
if (blk->isSecure())
req->setFlags(Request::SECURE);
@@ -1777,7 +1777,7 @@
if (blk.isDirty()) {
assert(blk.isValid());
- Request request(tags->regenerateBlkAddr(blk.tag, blk.set),
+ Request request(tags->regenerateBlkAddr(blk.tag, blk.set, blk.way),
blkSize, 0, Request::funcMasterId);
request.taskId(blk.task_id);
if (blk.isSecure()) {
@@ -1820,7 +1820,7 @@
return nullptr;
if (blk->isValid()) {
- Addr repl_addr = tags->regenerateBlkAddr(blk->tag, blk->set);
+ Addr repl_addr = tags->regenerateBlkAddr(blk->tag, blk->set,
blk->way);
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 9714d9a..df27c1e 100644
--- a/src/mem/cache/tags/base.hh
+++ b/src/mem/cache/tags/base.hh
@@ -244,7 +244,16 @@
virtual void insertBlock(PacketPtr pkt, CacheBlk *blk) = 0;
- virtual Addr regenerateBlkAddr(Addr tag, unsigned set) const = 0;
+ /**
+ * Regenerate the block address from the tag, set and way.
+ *
+ * @param tag The tag of the block.
+ * @param set The set of the block.
+ * @param way The set of the block.
+ * @return The block address.
+ */
+ virtual Addr regenerateBlkAddr(Addr tag, unsigned set, unsigned way)
+ 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 21a250e..0c99da1 100644
--- a/src/mem/cache/tags/base_set_assoc.hh
+++ b/src/mem/cache/tags/base_set_assoc.hh
@@ -239,8 +239,6 @@
uint32_t task_id = pkt->req->taskId();
if (!blk->isTouched) {
- tagsInUse++;
- blk->isTouched = true;
if (!warmedUp && tagsInUse.value() >= warmupBound) {
warmedUp = true;
warmupCycle = curTick();
@@ -260,6 +258,9 @@
blk->invalidate();
}
+ // Previous block, if existed, has been removed, and now we have
+ // to insert the new one and mark it as touched
+ tagsInUse++;
blk->isTouched = true;
// Set tag for new block. Caller is responsible for setting
status.
@@ -317,12 +318,15 @@
}
/**
- * Regenerate the block address from the tag.
+ * Regenerate the block address from the tag and set.
+ *
* @param tag The tag of the block.
* @param set The set of the block.
+ * @param way The set of the block.
* @return The block address.
*/
- Addr regenerateBlkAddr(Addr tag, unsigned set) const override
+ Addr regenerateBlkAddr(Addr tag, unsigned set, unsigned way) const
+ override
{
return ((tag << tagShift) | ((Addr)set << setShift));
}
diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh
index a266fb5..7e1ba8d 100644
--- a/src/mem/cache/tags/fa_lru.hh
+++ b/src/mem/cache/tags/fa_lru.hh
@@ -242,12 +242,15 @@
}
/**
- * Regenerate the block address from the tag and the set.
+ * Regenerate the block address from the tag and set.
+ *
* @param tag The tag of the block.
* @param set The set the block belongs to.
+ * @param way The way the block belongs to.
* @return the block address.
*/
- Addr regenerateBlkAddr(Addr tag, unsigned set) const override
+ Addr regenerateBlkAddr(Addr tag, unsigned set, unsigned way) const
+ override
{
return (tag);
}
diff --git a/src/mem/cache/tags/lru.cc b/src/mem/cache/tags/lru.cc
index 5fc48b9..0b71987 100644
--- a/src/mem/cache/tags/lru.cc
+++ b/src/mem/cache/tags/lru.cc
@@ -64,7 +64,7 @@
// 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->tag, blk->set, blk->way),
is_secure ? "s" : "ns");
}
@@ -88,7 +88,7 @@
if (blk && blk->isValid()) {
DPRINTF(CacheRepl, "set %x: selecting blk %x for replacement\n",
- set, regenerateBlkAddr(blk->tag, set));
+ set, regenerateBlkAddr(blk->tag, set, blk->way));
}
return blk;
diff --git a/src/mem/cache/tags/random_repl.cc
b/src/mem/cache/tags/random_repl.cc
index ab51f64..84caa29 100644
--- a/src/mem/cache/tags/random_repl.cc
+++ b/src/mem/cache/tags/random_repl.cc
@@ -74,7 +74,7 @@
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->tag, blk->set, blk->way));
}
return blk;
--
To view, visit https://gem5-review.googlesource.com/8782
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: I62c61ac9509eff2f37bad36862751956db7a6e40
Gerrit-Change-Number: 8782
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev