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

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

mem-cache: Encapsulate CacheBlk's tickInserted

Encapsulate this variable to facilitate polymorphism.

- tickInserted was renamed to _tickInserted and was privatized.
- The insertion tick should always be set to the current tick,
  and only on insertion; thus, its setter is not public and
  does not take arguments.
- An additional function was created to get the age since of
  the block relative to its insertion tick.
- There is no current need for a getter.

Change-Id: I81d4009abec5e9633e10f1e851e3a524553c98a4
Signed-off-by: Daniel R. Carvalho <oda...@yahoo.com.br>
---
M src/mem/cache/cache_blk.cc
M src/mem/cache/cache_blk.hh
M src/mem/cache/tags/base.cc
3 files changed, 26 insertions(+), 11 deletions(-)



diff --git a/src/mem/cache/cache_blk.cc b/src/mem/cache/cache_blk.cc
index f580dbb..c99c05c 100644
--- a/src/mem/cache/cache_blk.cc
+++ b/src/mem/cache/cache_blk.cc
@@ -66,7 +66,7 @@
     setTaskId(task_ID);

     // Set insertion tick as current tick
-    tickInserted = curTick();
+    setTickInserted();

     // Insertion counts as a reference to the block
     increaseRefCount();
diff --git a/src/mem/cache/cache_blk.hh b/src/mem/cache/cache_blk.hh
index 851354d..38f66cd 100644
--- a/src/mem/cache/cache_blk.hh
+++ b/src/mem/cache/cache_blk.hh
@@ -57,6 +57,7 @@
 #include "mem/cache/replacement_policies/base.hh"
 #include "mem/packet.hh"
 #include "mem/request.hh"
+#include "sim/core.hh"

 /**
  * Cache block status bit assignments
@@ -94,6 +95,12 @@
     /** Number of references to this block since it was brought in. */
     unsigned _refCount;

+    /**
+     * Tick on which the block was inserted in the cache. Its value is only
+     * meaningful if the block is valid.
+     */
+    Tick _tickInserted;
+
   protected:
     /** Set the task id value. */
     inline void setTaskId(const uint32_t task_id) { _taskId = task_id; }
@@ -101,6 +108,9 @@
     /** Set the number of references to this block since insertion. */
     inline void setRefCount(const unsigned count) { _refCount = count; }

+    /** Set the current tick as this block's insertion tick. */
+    inline void setTickInserted() { _tickInserted = curTick(); }
+
   public:
     /**
* Contains a copy of the data in this block for easy access. This is used
@@ -126,12 +136,6 @@
     /** holds the source requestor ID for this block. */
     int srcRequestorId;

-    /**
-     * Tick on which the block was inserted in the cache. Its value is only
-     * meaningful if the block is valid.
-     */
-    Tick tickInserted;
-
   protected:
     /**
      * Represents that the indicated thread context has a "lock" on
@@ -175,7 +179,7 @@
     std::list<Lock> lockList;

   public:
-    CacheBlk() : data(nullptr), tickInserted(0)
+    CacheBlk() : _tickInserted(0), data(nullptr)
     {
         invalidate();
     }
@@ -308,7 +312,7 @@
      */
     void setWhenReady(const Tick tick)
     {
-        assert(tick >= tickInserted);
+        assert(tick >= _tickInserted);
         whenReady = tick;
     }

@@ -322,6 +326,18 @@
     inline void increaseRefCount() { _refCount++; }

     /**
+ * Get the block's age, that is, the number of ticks since its insertion.
+     *
+     * @return The block's age.
+     */
+    inline Tick
+    getAge() const
+    {
+        assert(_tickInserted <= curTick());
+        return curTick() - _tickInserted;
+    }
+
+    /**
      * Checks if the given information corresponds to this block's.
      *
      * @param tag The tag value to compare to.
diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc
index 9db4210..bcba0b9 100644
--- a/src/mem/cache/tags/base.cc
+++ b/src/mem/cache/tags/base.cc
@@ -151,8 +151,7 @@
         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;
+        Tick age = blk.getAge();

         int age_index;
         if (age / SimClock::Int::us < 10) { // <10us

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34958
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: I81d4009abec5e9633e10f1e851e3a524553c98a4
Gerrit-Change-Number: 34958
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to