summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags/base_set_assoc.hh
diff options
context:
space:
mode:
authorDaniel R. Carvalho <odanrc@yahoo.com.br>2018-03-27 11:53:33 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2018-05-03 14:25:29 +0000
commitc149983d931054d8cf88d2977a1f03a0b8b3b543 (patch)
tree1651101f29d8b06098394ffb078bf2716348664a /src/mem/cache/tags/base_set_assoc.hh
parentddb80527e37e505e74b04755da502934ce8f0645 (diff)
downloadgem5-c149983d931054d8cf88d2977a1f03a0b8b3b543.tar.xz
mem-cache: ReplacementPolicy specific replacement data
Replacement data is specific for each replacement policy, and thus should be instantiated differently by each policy. Touch() and reset() do not need to be aware of CacheBlk, as they only update its ReplacementData. Invalidate() makes replacement policies independent of cache blocks, by removing the awareness of the valid state. An inheritable base ReplaceableEntry class was created to allow usage of replacement policies with any table-like structure. Change-Id: I998917d800fa48504ed95abffa2f1b7bfd68522b Reviewed-on: https://gem5-review.googlesource.com/9421 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src/mem/cache/tags/base_set_assoc.hh')
-rw-r--r--src/mem/cache/tags/base_set_assoc.hh31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh
index 024fda157..5a3e832c1 100644
--- a/src/mem/cache/tags/base_set_assoc.hh
+++ b/src/mem/cache/tags/base_set_assoc.hh
@@ -50,11 +50,12 @@
#include <cassert>
#include <cstring>
-#include <memory>
#include <vector>
+#include "debug/CacheRepl.hh"
#include "mem/cache/base.hh"
#include "mem/cache/blk.hh"
+#include "mem/cache/replacement_policies/base.hh"
#include "mem/cache/tags/base.hh"
#include "mem/cache/tags/cacheset.hh"
#include "mem/packet.hh"
@@ -105,7 +106,6 @@ class BaseSetAssoc : public BaseTags
BaseReplacementPolicy *replacementPolicy;
public:
-
/** Convenience typedef. */
typedef BaseSetAssocParams Params;
@@ -120,6 +120,14 @@ class BaseSetAssoc : public BaseTags
virtual ~BaseSetAssoc() {};
/**
+ * This function updates the tags when a block is invalidated but does
+ * not invalidate the block itself. It also updates the replacement data.
+ *
+ * @param blk The block to invalidate.
+ */
+ void invalidate(CacheBlk *blk) override;
+
+ /**
* Find the cache block given set and way
* @param set The set of the block.
* @param way The way of the block.
@@ -165,8 +173,11 @@ class BaseSetAssoc : public BaseTags
accessLatency;
}
+ // Update number of references to accessed block
+ blk->refCount++;
+
// Update replacement data of accessed block
- replacementPolicy->touch(blk);
+ replacementPolicy->touch(blk->replacementData);
} else {
// If a cache miss
lat = lookupLatency;
@@ -193,8 +204,18 @@ class BaseSetAssoc : public BaseTags
*/
CacheBlk* findVictim(Addr addr) override
{
+ // Get possible locations for the victim block
+ std::vector<CacheBlk*> locations = getPossibleLocations(addr);
+
// Choose replacement victim from replacement candidates
- return replacementPolicy->getVictim(getPossibleLocations(addr));
+ CacheBlk* victim = static_cast<CacheBlk*>(replacementPolicy->getVictim(
+ std::vector<ReplaceableEntry*>(
+ locations.begin(), locations.end())));
+
+ DPRINTF(CacheRepl, "set %x, way %x: selecting blk for replacement\n",
+ victim->set, victim->way);
+
+ return victim;
}
/**
@@ -223,7 +244,7 @@ class BaseSetAssoc : public BaseTags
BaseTags::insertBlock(pkt, blk);
// Update replacement policy
- replacementPolicy->reset(blk);
+ replacementPolicy->reset(blk->replacementData);
}
/**