Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/34956 )

Change subject: mem-cache: Encapsulate CacheBlk's task_id
......................................................................

mem-cache: Encapsulate CacheBlk's task_id

Encapsulate this variable to facilitate polymorphism.

- task_id was renamed to _taskId and was privatized.
- The task id should only be modified at 2 specific moments:
  insertion and invalidation of the block; thus, its setter
  is not public.

Change-Id: If9c49c22117ef5d7f25163ec94bf8b174f221e39
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/mem/cache/base.cc
M src/mem/cache/cache.cc
M src/mem/cache/cache_blk.cc
M src/mem/cache/cache_blk.hh
M src/mem/cache/tags/base.cc
5 files changed, 19 insertions(+), 11 deletions(-)



diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index c420714..3d3c9a9 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -1497,7 +1497,7 @@
     if (blk->isSecure())
         req->setFlags(Request::SECURE);

-    req->taskId(blk->task_id);
+    req->taskId(blk->getTaskId());

     PacketPtr pkt =
         new Packet(req, blk->isDirty() ?
@@ -1539,7 +1539,7 @@
     if (blk->isSecure()) {
         req->setFlags(Request::SECURE);
     }
-    req->taskId(blk->task_id);
+    req->taskId(blk->getTaskId());

     PacketPtr pkt = new Packet(req, MemCmd::WriteClean, blkSize, id);

@@ -1609,7 +1609,7 @@
         RequestPtr request = std::make_shared<Request>(
             regenerateBlkAddr(&blk), blkSize, 0, Request::funcRequestorId);

-        request->taskId(blk.task_id);
+        request->taskId(blk.getTaskId());
         if (blk.isSecure()) {
             request->setFlags(Request::SECURE);
         }
diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc
index b4f4238..ad18c28 100644
--- a/src/mem/cache/cache.cc
+++ b/src/mem/cache/cache.cc
@@ -917,7 +917,7 @@
     if (blk->isSecure())
         req->setFlags(Request::SECURE);

-    req->taskId(blk->task_id);
+    req->taskId(blk->getTaskId());

     PacketPtr pkt = new Packet(req, MemCmd::CleanEvict);
     pkt->allocate();
diff --git a/src/mem/cache/cache_blk.cc b/src/mem/cache/cache_blk.cc
index 0c44210..8bdf0a4 100644
--- a/src/mem/cache/cache_blk.cc
+++ b/src/mem/cache/cache_blk.cc
@@ -63,7 +63,7 @@
     srcRequestorId = src_requestor_ID;

     // Set task ID
-    task_id = task_ID;
+    setTaskId(task_ID);

     // Set insertion tick as current tick
     tickInserted = curTick();
diff --git a/src/mem/cache/cache_blk.hh b/src/mem/cache/cache_blk.hh
index 19a5e58..46f4679 100644
--- a/src/mem/cache/cache_blk.hh
+++ b/src/mem/cache/cache_blk.hh
@@ -88,10 +88,14 @@
     /** Data block tag value. */
     Addr _tag;

-  public:
     /** Task Id associated with this block */
-    uint32_t task_id;
+    uint32_t _taskId;

+  protected:
+    /** Set the task id value. */
+    inline void setTaskId(const uint32_t task_id) { _taskId = task_id; }
+
+  public:
     /**
* Contains a copy of the data in this block for easy access. This is used
      * for efficient execution when the data could be actually stored in
@@ -214,7 +218,7 @@
     virtual void invalidate()
     {
         setTag(MaxAddr);
-        task_id = ContextSwitchTaskId::Unknown;
+        setTaskId(ContextSwitchTaskId::Unknown);
         status = 0;
         whenReady = MaxTick;
         refCount = 0;
@@ -305,6 +309,9 @@
         whenReady = tick;
     }

+    /** Get the task id associated to this block. */
+    inline uint32_t getTaskId() const { return _taskId; }
+
     /**
      * 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 28b5fcb..b25231c 100644
--- a/src/mem/cache/tags/base.cc
+++ b/src/mem/cache/tags/base.cc
@@ -148,8 +148,9 @@
 BaseTags::computeStatsVisitor(CacheBlk &blk)
 {
     if (blk.isValid()) {
-        assert(blk.task_id < ContextSwitchTaskId::NumTaskId);
-        stats.occupanciesTaskId[blk.task_id]++;
+        const uint32_t task_id = blk.getTaskId();
+        assert(task_id < ContextSwitchTaskId::NumTaskId);
+        stats.occupanciesTaskId[task_id]++;
         assert(blk.tickInserted <= curTick());
         Tick age = curTick() - blk.tickInserted;

@@ -165,7 +166,7 @@
         } else
             age_index = 4; // >10ms

-        stats.ageTaskId[blk.task_id][age_index]++;
+        stats.ageTaskId[task_id][age_index]++;
     }
 }


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34956
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: If9c49c22117ef5d7f25163ec94bf8b174f221e39
Gerrit-Change-Number: 34956
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

Reply via email to