From 62db2c46f460deb41d43930e4b6460e53f70376a Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Tue, 24 Apr 2018 11:20:38 +0200 Subject: 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 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- src/mem/cache/tags/base_set_assoc.hh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/mem/cache/tags/base_set_assoc.hh') 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& evict_blks) const + override { // Get possible locations for the victim block std::vector locations = getPossibleLocations(addr); @@ -215,6 +218,9 @@ class BaseSetAssoc : public BaseTags std::vector( 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 getPossibleLocations(Addr addr) + const std::vector getPossibleLocations(Addr addr) const { return sets[extractSet(addr)].blks; } -- cgit v1.2.3