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 <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34958 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
2c21052fa6
commit
b6209eb911
2
src/mem/cache/cache_blk.cc
vendored
2
src/mem/cache/cache_blk.cc
vendored
@@ -66,7 +66,7 @@ CacheBlk::insert(const Addr tag, const bool is_secure,
|
||||
setTaskId(task_ID);
|
||||
|
||||
// Set insertion tick as current tick
|
||||
tickInserted = curTick();
|
||||
setTickInserted();
|
||||
|
||||
// Insertion counts as a reference to the block
|
||||
increaseRefCount();
|
||||
|
||||
32
src/mem/cache/cache_blk.hh
vendored
32
src/mem/cache/cache_blk.hh
vendored
@@ -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
|
||||
@@ -109,12 +110,6 @@ class CacheBlk : public ReplaceableEntry
|
||||
/** 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
|
||||
@@ -158,7 +153,7 @@ class CacheBlk : public ReplaceableEntry
|
||||
std::list<Lock> lockList;
|
||||
|
||||
public:
|
||||
CacheBlk() : data(nullptr), tickInserted(0)
|
||||
CacheBlk() : data(nullptr), _tickInserted(0)
|
||||
{
|
||||
invalidate();
|
||||
}
|
||||
@@ -291,7 +286,7 @@ class CacheBlk : public ReplaceableEntry
|
||||
*/
|
||||
void setWhenReady(const Tick tick)
|
||||
{
|
||||
assert(tick >= tickInserted);
|
||||
assert(tick >= _tickInserted);
|
||||
whenReady = tick;
|
||||
}
|
||||
|
||||
@@ -304,6 +299,18 @@ class CacheBlk : public ReplaceableEntry
|
||||
/** Get the number of references to this block since insertion. */
|
||||
void increaseRefCount() { _refCount++; }
|
||||
|
||||
/**
|
||||
* Get the block's age, that is, the number of ticks since its insertion.
|
||||
*
|
||||
* @return The block's age.
|
||||
*/
|
||||
Tick
|
||||
getAge() const
|
||||
{
|
||||
assert(_tickInserted <= curTick());
|
||||
return curTick() - _tickInserted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given information corresponds to this block's.
|
||||
*
|
||||
@@ -462,6 +469,9 @@ class CacheBlk : public ReplaceableEntry
|
||||
/** Set the number of references to this block since insertion. */
|
||||
void setRefCount(const unsigned count) { _refCount = count; }
|
||||
|
||||
/** Set the current tick as this block's insertion tick. */
|
||||
void setTickInserted() { _tickInserted = curTick(); }
|
||||
|
||||
private:
|
||||
/** Data block tag value. */
|
||||
Addr _tag;
|
||||
@@ -471,6 +481,12 @@ class CacheBlk : public ReplaceableEntry
|
||||
|
||||
/** 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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
3
src/mem/cache/tags/base.cc
vendored
3
src/mem/cache/tags/base.cc
vendored
@@ -151,8 +151,7 @@ BaseTags::computeStatsVisitor(CacheBlk &blk)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user