Daniel Carvalho has submitted this change and it was merged. (
https://gem5-review.googlesource.com/9961 )
Change subject: mem-cache: Create an address aware TempCacheBlk
......................................................................
mem-cache: Create an address aware TempCacheBlk
tempBlock has its member variables manually set in order to allow
it to be used in the block address regeneration function. This is
not necessary, and ti can be simply given the address, so it does
not need to be aware of set and tag. This will simplify
implementation of sector and skewed caches.
Change-Id: Iaffb10c323509722cd5589fe1030b818d43336d6
Reviewed-on: https://gem5-review.googlesource.com/9961
Reviewed-by: Nikos Nikoleris <[email protected]>
Maintainer: Nikos Nikoleris <[email protected]>
---
M src/mem/cache/base.cc
M src/mem/cache/base.hh
M src/mem/cache/blk.cc
M src/mem/cache/blk.hh
M src/mem/cache/cache.cc
5 files changed, 90 insertions(+), 12 deletions(-)
Approvals:
Nikos Nikoleris: Looks good to me, approved; Looks good to me, approved
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index 604aab6..efdb3be 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -113,7 +113,7 @@
// forward snoops is overridden in init() once we can query
// whether the connected master is actually snooping or not
- tempBlock = new CacheBlk();
+ tempBlock = new TempCacheBlk();
tempBlock->data = new uint8_t[blkSize];
tags->setCache(this);
@@ -164,6 +164,16 @@
sendRetryReq();
}
+Addr
+BaseCache::regenerateBlkAddr(CacheBlk* blk)
+{
+ if (blk != tempBlock) {
+ return tags->regenerateBlkAddr(blk);
+ } else {
+ return tempBlock->getAddr();
+ }
+}
+
void
BaseCache::init()
{
@@ -1123,8 +1133,7 @@
// current request and then get rid of it
assert(!tempBlock->isValid());
blk = tempBlock;
- tempBlock->set = tags->extractSet(addr);
- tempBlock->tag = tags->extractTag(addr);
+ tempBlock->insert(addr, is_secure);
DPRINTF(Cache, "using temp block for %#llx (%s)\n", addr,
is_secure ? "s" : "ns");
} else {
@@ -1207,7 +1216,7 @@
return nullptr;
if (blk->isValid()) {
- Addr repl_addr = tags->regenerateBlkAddr(blk);
+ Addr repl_addr = regenerateBlkAddr(blk);
MSHR *repl_mshr = mshrQueue.findMatch(repl_addr, blk->isSecure());
if (repl_mshr) {
// must be an outstanding upgrade or clean request
@@ -1251,7 +1260,7 @@
writebacks[Request::wbMasterId]++;
- Request *req = new Request(tags->regenerateBlkAddr(blk), blkSize, 0,
+ Request *req = new Request(regenerateBlkAddr(blk), blkSize, 0,
Request::wbMasterId);
if (blk->isSecure())
req->setFlags(Request::SECURE);
@@ -1286,7 +1295,7 @@
PacketPtr
BaseCache::writecleanBlk(CacheBlk *blk, Request::Flags dest, PacketId id)
{
- Request *req = new Request(tags->regenerateBlkAddr(blk), blkSize, 0,
+ Request *req = new Request(regenerateBlkAddr(blk), blkSize, 0,
Request::wbMasterId);
if (blk->isSecure()) {
req->setFlags(Request::SECURE);
@@ -1346,7 +1355,7 @@
if (blk.isDirty()) {
assert(blk.isValid());
- Request request(tags->regenerateBlkAddr(&blk),
+ Request request(regenerateBlkAddr(&blk),
blkSize, 0, Request::funcMasterId);
request.taskId(blk.task_id);
if (blk.isSecure()) {
diff --git a/src/mem/cache/base.hh b/src/mem/cache/base.hh
index 04225c1..6600aeb 100644
--- a/src/mem/cache/base.hh
+++ b/src/mem/cache/base.hh
@@ -334,7 +334,7 @@
* is an outstanding request that accesses the victim block) or
* when we want to avoid allocation (e.g., exclusive caches)
*/
- CacheBlk *tempBlock;
+ TempCacheBlk *tempBlock;
/**
* Upstream caches need this packet until true is returned, so
@@ -390,6 +390,16 @@
}
/**
+ * Regenerate block address using tags.
+ * Block address regeneration depends on whether we're using a
temporary
+ * block or not.
+ *
+ * @param blk The block to regenerate address.
+ * @return The block's address.
+ */
+ Addr regenerateBlkAddr(CacheBlk* blk);
+
+ /**
* Does all the processing necessary to perform the provided request.
* @param pkt The memory request to perform.
* @param blk The cache block to be updated.
diff --git a/src/mem/cache/blk.cc b/src/mem/cache/blk.cc
index ad0c20a..45bd9bf 100644
--- a/src/mem/cache/blk.cc
+++ b/src/mem/cache/blk.cc
@@ -43,7 +43,7 @@
#include "base/cprintf.hh"
void
-CacheBlk::insert(const Addr tag, const State is_secure,
+CacheBlk::insert(const Addr tag, const bool is_secure,
const int src_master_ID, const uint32_t task_ID)
{
// Set block tag
diff --git a/src/mem/cache/blk.hh b/src/mem/cache/blk.hh
index c94c3ba..c4ec12f 100644
--- a/src/mem/cache/blk.hh
+++ b/src/mem/cache/blk.hh
@@ -166,7 +166,6 @@
std::list<Lock> lockList;
public:
-
CacheBlk()
{
invalidate();
@@ -261,7 +260,7 @@
* @param src_master_ID The source requestor ID.
* @param task_ID The new task ID.
*/
- void insert(const Addr tag, const State is_secure, const int
src_master_ID,
+ void insert(const Addr tag, const bool is_secure, const int
src_master_ID,
const uint32_t task_ID);
/**
@@ -394,6 +393,66 @@
};
/**
+ * Special instance of CacheBlk for use with tempBlk that deals with its
+ * block address regeneration.
+ * @sa Cache
+ */
+class TempCacheBlk final : public CacheBlk
+{
+ private:
+ /**
+ * Copy of the block's address, used to regenerate tempBlock's address.
+ */
+ Addr _addr;
+
+ public:
+ TempCacheBlk() : CacheBlk() {}
+ TempCacheBlk(const TempCacheBlk&) = delete;
+ TempCacheBlk& operator=(const TempCacheBlk&) = delete;
+ ~TempCacheBlk() {};
+
+ /**
+ * Invalidate the block and clear all state.
+ */
+ void invalidate() override {
+ CacheBlk::invalidate();
+
+ _addr = MaxAddr;
+ }
+
+ /**
+ * Set member variables when a block insertion occurs. A TempCacheBlk
does
+ * not have all the information required to regenerate the block's
address,
+ * so it is provided the address itself for easy regeneration.
+ *
+ * @param addr Block address.
+ * @param is_secure Whether the block is in secure space or not.
+ */
+ void insert(const Addr addr, const bool is_secure)
+ {
+ // Set block address
+ _addr = addr;
+
+ // Set secure state
+ if (is_secure) {
+ status = BlkSecure;
+ } else {
+ status = 0;
+ }
+ }
+
+ /**
+ * Get block's address.
+ *
+ * @return addr Address value.
+ */
+ Addr getAddr() const
+ {
+ return _addr;
+ }
+};
+
+/**
* Simple class to provide virtual print() method on cache blocks
* without allocating a vtable pointer for every single cache block.
* Just wrap the CacheBlk object in an instance of this before passing
diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc
index 9177ebe..34f3dc5 100644
--- a/src/mem/cache/cache.cc
+++ b/src/mem/cache/cache.cc
@@ -873,7 +873,7 @@
assert(blk && blk->isValid() && !blk->isDirty());
// Creating a zero sized write, a message to the snoop filter
Request *req =
- new Request(tags->regenerateBlkAddr(blk), blkSize, 0,
+ new Request(regenerateBlkAddr(blk), blkSize, 0,
Request::wbMasterId);
if (blk->isSecure())
req->setFlags(Request::SECURE);
--
To view, visit https://gem5-review.googlesource.com/9961
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: Iaffb10c323509722cd5589fe1030b818d43336d6
Gerrit-Change-Number: 9961
Gerrit-PatchSet: 6
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev