summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags/base_set_assoc.hh
diff options
context:
space:
mode:
authorDaniel R. Carvalho <odanrc@yahoo.com.br>2018-04-24 11:20:38 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2018-06-08 09:33:39 +0000
commit62db2c46f460deb41d43930e4b6460e53f70376a (patch)
treeb00cde3c6f1c2f7f12d8c86b5db8aa68ea69259a /src/mem/cache/tags/base_set_assoc.hh
parent815b12fb4aa45bfe8b38f96f923c150880bf9200 (diff)
downloadgem5-62db2c46f460deb41d43930e4b6460e53f70376a.tar.xz
mem-cache: Return evictions along with victims
For both sector and compressed caches multiple blocks may need to be evicted in order to make room for a new block. For example, when replacing a sector, all the blocks in this sector must be evicted. A replacement, however, does not always need to evict multiple blocks, as it is in the case of an insertion of a block whose sector is already present in the cache (i.e., its corresponding entry in the sector had not been brought in yet, so it was invalid). This patch creates the cache framework for that to happen. Change-Id: I77bedf69637cf899fef4d9432eb6da8529ea398b Reviewed-on: https://gem5-review.googlesource.com/10142 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> 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.hh12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh
index 475566268..d19a00ed9 100644
--- a/src/mem/cache/tags/base_set_assoc.hh
+++ b/src/mem/cache/tags/base_set_assoc.hh
@@ -200,12 +200,15 @@ class BaseSetAssoc : public BaseTags
ReplaceableEntry* findBlockBySetAndWay(int set, int way) const override;
/**
- * Find replacement victim based on address.
+ * Find replacement victim based on address. The list of evicted blocks
+ * only contains the victim.
*
* @param addr Address to find a victim for.
+ * @param evict_blks Cache blocks to be evicted.
* @return Cache block to be replaced.
*/
- CacheBlk* findVictim(Addr addr) override
+ CacheBlk* findVictim(Addr addr, std::vector<CacheBlk*>& evict_blks) const
+ override
{
// Get possible locations for the victim block
std::vector<CacheBlk*> locations = getPossibleLocations(addr);
@@ -215,6 +218,9 @@ class BaseSetAssoc : public BaseTags
std::vector<ReplaceableEntry*>(
locations.begin(), locations.end())));
+ // There is only one eviction for this replacement
+ evict_blks.push_back(victim);
+
DPRINTF(CacheRepl, "set %x, way %x: selecting blk for replacement\n",
victim->set, victim->way);
@@ -230,7 +236,7 @@ class BaseSetAssoc : public BaseTags
* @param addr The addr to a find possible locations for.
* @return The possible locations.
*/
- const std::vector<CacheBlk*> getPossibleLocations(Addr addr)
+ const std::vector<CacheBlk*> getPossibleLocations(Addr addr) const
{
return sets[extractSet(addr)].blks;
}