Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/34957 )
Change subject: mem-cache: Encapsulate CacheBlk's refCount
......................................................................
mem-cache: Encapsulate CacheBlk's refCount
Encapsulate this variable to facilitate polymorphism.
- refCount was renamed to _refCount and was privatized.
- The reference count should only be reset at invalidation;
thus, its setter is not public.
- An additional function was created to increment the number
of references by 1.
Change-Id: Ibc8799a8dcb7c53c651de3eb1c9b86118a297b9d
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/mem/cache/cache_blk.cc
M src/mem/cache/cache_blk.hh
M src/mem/cache/tags/base.cc
M src/mem/cache/tags/base.hh
M src/mem/cache/tags/base_set_assoc.hh
M src/mem/cache/tags/sector_tags.cc
6 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/mem/cache/cache_blk.cc b/src/mem/cache/cache_blk.cc
index 8bdf0a4..f580dbb 100644
--- a/src/mem/cache/cache_blk.cc
+++ b/src/mem/cache/cache_blk.cc
@@ -69,7 +69,7 @@
tickInserted = curTick();
// Insertion counts as a reference to the block
- refCount = 1;
+ increaseRefCount();
// Set secure state
if (is_secure) {
diff --git a/src/mem/cache/cache_blk.hh b/src/mem/cache/cache_blk.hh
index 46f4679..851354d 100644
--- a/src/mem/cache/cache_blk.hh
+++ b/src/mem/cache/cache_blk.hh
@@ -91,10 +91,16 @@
/** Task Id associated with this block */
uint32_t _taskId;
+ /** Number of references to this block since it was brought in. */
+ unsigned _refCount;
+
protected:
/** Set the task id value. */
inline void setTaskId(const uint32_t task_id) { _taskId = task_id; }
+ /** Set the number of references to this block since insertion. */
+ inline void setRefCount(const unsigned count) { _refCount = count; }
+
public:
/**
* Contains a copy of the data in this block for easy access. This is
used
@@ -117,9 +123,6 @@
*/
Tick whenReady;
- /** Number of references to this block since it was brought in. */
- unsigned refCount;
-
/** holds the source requestor ID for this block. */
int srcRequestorId;
@@ -221,7 +224,7 @@
setTaskId(ContextSwitchTaskId::Unknown);
status = 0;
whenReady = MaxTick;
- refCount = 0;
+ setRefCount(0);
srcRequestorId = Request::invldRequestorId;
lockList.clear();
}
@@ -312,6 +315,12 @@
/** Get the task id associated to this block. */
inline uint32_t getTaskId() const { return _taskId; }
+ /** Get the number of references to this block since insertion. */
+ inline unsigned getRefCount() const { return _refCount; }
+
+ /** Get the number of references to this block since insertion. */
+ inline void increaseRefCount() { _refCount++; }
+
/**
* Checks if the given information corresponds to this block's.
*
diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc
index b25231c..9db4210 100644
--- a/src/mem/cache/tags/base.cc
+++ b/src/mem/cache/tags/base.cc
@@ -133,7 +133,7 @@
BaseTags::cleanupRefsVisitor(CacheBlk &blk)
{
if (blk.isValid()) {
- stats.totalRefs += blk.refCount;
+ stats.totalRefs += blk.getRefCount();
++stats.sampledRefs;
}
}
diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh
index 5e0af20..700edcb 100644
--- a/src/mem/cache/tags/base.hh
+++ b/src/mem/cache/tags/base.hh
@@ -254,7 +254,7 @@
assert(blk->isValid());
stats.occupancies[blk->srcRequestorId]--;
- stats.totalRefs += blk->refCount;
+ stats.totalRefs += blk->getRefCount();
stats.sampledRefs++;
blk->invalidate();
diff --git a/src/mem/cache/tags/base_set_assoc.hh
b/src/mem/cache/tags/base_set_assoc.hh
index d273f1e..211bc1f 100644
--- a/src/mem/cache/tags/base_set_assoc.hh
+++ b/src/mem/cache/tags/base_set_assoc.hh
@@ -141,7 +141,7 @@
// If a cache hit
if (blk != nullptr) {
// Update number of references to accessed block
- blk->refCount++;
+ blk->increaseRefCount();
// Update replacement data of accessed block
replacementPolicy->touch(blk->replacementData);
diff --git a/src/mem/cache/tags/sector_tags.cc
b/src/mem/cache/tags/sector_tags.cc
index 8a01740..bf0185e 100644
--- a/src/mem/cache/tags/sector_tags.cc
+++ b/src/mem/cache/tags/sector_tags.cc
@@ -151,7 +151,7 @@
// If a cache hit
if (blk != nullptr) {
// Update number of references to accessed block
- blk->refCount++;
+ blk->increaseRefCount();
// Get block's sector
SectorSubBlk* sub_blk = static_cast<SectorSubBlk*>(blk);
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34957
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ibc8799a8dcb7c53c651de3eb1c9b86118a297b9d
Gerrit-Change-Number: 34957
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s