diff options
author | Daniel R. Carvalho <odanrc@yahoo.com.br> | 2018-03-09 15:04:20 +0100 |
---|---|---|
committer | Daniel Carvalho <odanrc@yahoo.com.br> | 2018-10-10 18:17:42 +0000 |
commit | d204e56b2b9b8ad561fc258ebdc50ae8365159e1 (patch) | |
tree | 52783a7a32db7d055cb85e5454e6512c22cb2b1c /src/mem/cache/tags/sector_tags.cc | |
parent | 99a6c94e58b6375c0d524530cab2a27b6ea0f2bc (diff) | |
download | gem5-d204e56b2b9b8ad561fc258ebdc50ae8365159e1.tar.xz |
mem-cache: Use possible locations to find block
Use possible locations to find block to make it placement policy
independent.
Change-Id: I4c9d9e1e1ff91ce12e85ca1970f927d8f4f5a93b
Reviewed-on: https://gem5-review.googlesource.com/c/8884
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/mem/cache/tags/sector_tags.cc')
-rw-r--r-- | src/mem/cache/tags/sector_tags.cc | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/mem/cache/tags/sector_tags.cc b/src/mem/cache/tags/sector_tags.cc index 988fda540..ef3fec2b9 100644 --- a/src/mem/cache/tags/sector_tags.cc +++ b/src/mem/cache/tags/sector_tags.cc @@ -194,10 +194,14 @@ SectorTags::accessBlock(Addr addr, bool is_secure, Cycles &lat) return blk; } -const std::vector<SectorBlk*> -SectorTags::getPossibleLocations(Addr addr) const +std::vector<ReplaceableEntry*> +SectorTags::getPossibleLocations(const Addr addr) const { - return sets[extractSet(addr)]; + std::vector<ReplaceableEntry*> locations; + for (const auto& blk : sets[extractSet(addr)]) { + locations.push_back(static_cast<ReplaceableEntry*>(blk)); + } + return locations; } void @@ -238,11 +242,12 @@ SectorTags::findBlock(Addr addr, bool is_secure) const const Addr offset = extractSectorOffset(addr); // Find all possible sector locations for the given address - const std::vector<SectorBlk*> locations = getPossibleLocations(addr); + const std::vector<ReplaceableEntry*> locations = + getPossibleLocations(addr); // Search for block for (const auto& sector : locations) { - auto blk = sector->blks[offset]; + auto blk = static_cast<SectorBlk*>(sector)->blks[offset]; if (blk->getTag() == tag && blk->isValid() && blk->isSecure() == is_secure) { return blk; @@ -264,16 +269,17 @@ SectorTags::findVictim(Addr addr, const bool is_secure, std::vector<CacheBlk*>& evict_blks) const { // Get all possible locations of this sector - const std::vector<SectorBlk*> sector_locations = + const std::vector<ReplaceableEntry*> sector_locations = getPossibleLocations(addr); // Check if the sector this address belongs to has been allocated Addr tag = extractTag(addr); SectorBlk* victim_sector = nullptr; - for (const auto& sector : sector_locations){ - if ((tag == sector->getTag()) && sector->isValid() && - (is_secure == sector->isSecure())){ - victim_sector = sector; + for (const auto& sector : sector_locations) { + SectorBlk* sector_blk = static_cast<SectorBlk*>(sector); + if ((tag == sector_blk->getTag()) && sector_blk->isValid() && + (is_secure == sector_blk->isSecure())){ + victim_sector = sector_blk; break; } } @@ -282,8 +288,7 @@ SectorTags::findVictim(Addr addr, const bool is_secure, if (victim_sector == nullptr){ // Choose replacement victim from replacement candidates victim_sector = static_cast<SectorBlk*>(replacementPolicy->getVictim( - std::vector<ReplaceableEntry*>( - sector_locations.begin(), sector_locations.end()))); + sector_locations)); } // Get the location of the victim block within the sector |