Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/9963
Change subject: mem-cache: Make tag a pointer
......................................................................
mem-cache: Make tag a pointer
Currently there is only one tag associated for each block and
vice-versa. However, in sector and compressed caches, that is
not the case, therefore each block must have a pointer to its
tag entry, which may be shared by multiple blocks.
Change-Id: I0b74b7db4424cc625debf3c229c9149fc2cadc88
---
M src/mem/cache/blk.hh
M src/mem/cache/tags/base_set_assoc.cc
M src/mem/cache/tags/fa_lru.cc
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/src/mem/cache/blk.hh b/src/mem/cache/blk.hh
index 66c07f5..0ebb69f 100644
--- a/src/mem/cache/blk.hh
+++ b/src/mem/cache/blk.hh
@@ -59,7 +59,7 @@
/**
* A Basic Cache block.
- * Contains the tag, status, and a pointer to data.
+ * Contains a pointer to its tag, its status, and a pointer to its data.
*/
class CacheBlk
{
@@ -95,8 +95,12 @@
*/
Addr _addr;
- /** Data block tag value. */
- Addr _tag;
+ /**
+ * Pointer to data block tag value.
+ * A block may share its tag with many other blocks when compressed or
+ * in sectored caches.
+ */
+ std::shared_ptr<Addr> _tag;
/** Task ID associated with this block */
uint32_t _taskID;
@@ -184,8 +188,7 @@
std::list<Lock> lockList;
public:
-
- CacheBlk()
+ CacheBlk() : _tag(nullptr)
{
// Simulation started, so block hasn't been touched yet
_isTouched = false;
@@ -234,7 +237,6 @@
virtual void invalidate()
{
_addr = MaxAddr;
- _tag = MaxAddr;
_status = 0;
_taskID = ContextSwitchTaskId::Unknown;
_srcMasterID = Request::invldMasterId;
@@ -323,13 +325,23 @@
}
/**
+ * Set tag pointer. A block may share its tag entry with multiple
blocks.
+ *
+ * @param tag Initialized tag pointer shared by this block.
+ */
+ void setTagPointer(const std::shared_ptr<Addr>& tag)
+ {
+ _tag = tag;
+ }
+
+ /**
* Get tag associated to this block.
*
* @return The tag value.
*/
Addr getTag() const
{
- return _tag;
+ return *_tag;
}
/**
@@ -386,7 +398,7 @@
* Set member variables when a block insertion occurs.
*
* @param addr Address value.
- * @param tag Block address tag.
+ * @param tag Block address tag value.
* @param src_master_ID The new src master ID.
* @param task_ID The new task ID.
*/
@@ -397,7 +409,7 @@
_isTouched = true;
_addr = addr;
- _tag = tag;
+ *_tag = tag;
_srcMasterID = src_master_ID;
_taskID = task_ID;
_refCount = 1;
diff --git a/src/mem/cache/tags/base_set_assoc.cc
b/src/mem/cache/tags/base_set_assoc.cc
index 397ad96..8ac7d97 100644
--- a/src/mem/cache/tags/base_set_assoc.cc
+++ b/src/mem/cache/tags/base_set_assoc.cc
@@ -88,6 +88,9 @@
// Locate next cache block
blk = &blks[blkIndex];
+ // Associate a tag to the block
+ blk->setTagPointer(std::shared_ptr<Addr>(new Addr()));
+
// Associate a data chunk to the block
blk->data = &dataBlks[blkSize*blkIndex];
diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc
index d6acbd8..ed3404f 100644
--- a/src/mem/cache/tags/fa_lru.cc
+++ b/src/mem/cache/tags/fa_lru.cc
@@ -101,6 +101,9 @@
blks[i].set = 0;
blks[i].way = i;
+ // Associate a tag to the block
+ blks[i].setTagPointer(std::shared_ptr<Addr>(new Addr()));
+
// Associate a data chunk to the block
blks[i].data = &dataBlks[blkSize*i];
}
--
To view, visit https://gem5-review.googlesource.com/9963
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: I0b74b7db4424cc625debf3c229c9149fc2cadc88
Gerrit-Change-Number: 9963
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