From 1b946fee7a61409c82a6ba2ad2f48f688c5d0017 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Mon, 21 Sep 2020 17:51:04 +0200 Subject: [PATCH] mem-cache: Encapsulate CacheBlk's srcRequestorId Encapsulate this variable to facilitate polymorphism. - requestorId was renamed to _requestorId and was privatized. - The requestor ID should only be modified on insertion and invalidation; thus, its setter is not public. Change-Id: I5bab21a6c21e9d912fb5194bb44ff785d44999f4 Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34959 Reviewed-by: Jason Lowe-Power Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris Tested-by: kokoro --- src/mem/cache/cache_blk.cc | 2 +- src/mem/cache/cache_blk.hh | 14 ++++++++++---- src/mem/cache/tags/base.hh | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mem/cache/cache_blk.cc b/src/mem/cache/cache_blk.cc index 26ad4afcc..01b71c5b7 100644 --- a/src/mem/cache/cache_blk.cc +++ b/src/mem/cache/cache_blk.cc @@ -60,7 +60,7 @@ CacheBlk::insert(const Addr tag, const bool is_secure, setTag(tag); // Set source requestor ID - srcRequestorId = src_requestor_ID; + setSrcRequestorId(src_requestor_ID); // Set task ID setTaskId(task_ID); diff --git a/src/mem/cache/cache_blk.hh b/src/mem/cache/cache_blk.hh index 448b89593..0ad355c37 100644 --- a/src/mem/cache/cache_blk.hh +++ b/src/mem/cache/cache_blk.hh @@ -107,9 +107,6 @@ class CacheBlk : public ReplaceableEntry */ Tick whenReady; - /** holds the source requestor ID for this block. */ - int srcRequestorId; - protected: /** * Represents that the indicated thread context has a "lock" on @@ -203,7 +200,7 @@ class CacheBlk : public ReplaceableEntry status = 0; whenReady = MaxTick; setRefCount(0); - srcRequestorId = Request::invldRequestorId; + setSrcRequestorId(Request::invldRequestorId); lockList.clear(); } @@ -293,6 +290,9 @@ class CacheBlk : public ReplaceableEntry /** Get the task id associated to this block. */ uint32_t getTaskId() const { return _taskId; } + /** Get the requestor id associated to this block. */ + uint32_t getSrcRequestorId() const { return _srcRequestorId; } + /** Get the number of references to this block since insertion. */ unsigned getRefCount() const { return _refCount; } @@ -466,6 +466,9 @@ class CacheBlk : public ReplaceableEntry /** Set the task id value. */ void setTaskId(const uint32_t task_id) { _taskId = task_id; } + /** Set the source requestor id. */ + void setSrcRequestorId(const uint32_t id) { _srcRequestorId = id; } + /** Set the number of references to this block since insertion. */ void setRefCount(const unsigned count) { _refCount = count; } @@ -479,6 +482,9 @@ class CacheBlk : public ReplaceableEntry /** Task Id associated with this block */ uint32_t _taskId; + /** holds the source requestor ID for this block. */ + int _srcRequestorId; + /** Number of references to this block since it was brought in. */ unsigned _refCount; diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh index 700edcb92..35e984ac2 100644 --- a/src/mem/cache/tags/base.hh +++ b/src/mem/cache/tags/base.hh @@ -253,7 +253,7 @@ class BaseTags : public ClockedObject assert(blk); assert(blk->isValid()); - stats.occupancies[blk->srcRequestorId]--; + stats.occupancies[blk->getSrcRequestorId()]--; stats.totalRefs += blk->getRefCount(); stats.sampledRefs++; -- 2.30.2