diff options
author | David Guillen-Fandos <david.guillen@arm.com> | 2015-07-30 03:41:42 -0400 |
---|---|---|
committer | David Guillen-Fandos <david.guillen@arm.com> | 2015-07-30 03:41:42 -0400 |
commit | 0c89c15b23d4db50eb08f8ebf2a40b569f41dd29 (patch) | |
tree | 9f5e2bcf48d88e940b9fea6b2fa9f37d05ea2741 /src/mem/cache/tags/random_repl.cc | |
parent | 5a18e181ffb8fbef5f4aca8fb9a63ee6a7c9e0d6 (diff) | |
download | gem5-0c89c15b23d4db50eb08f8ebf2a40b569f41dd29.tar.xz |
mem: Make caches way aware
This patch makes cache sets aware of the way number. This enables
some nice features such as the ablity to restrict way allocation. The
implemented mechanism allows to set a maximum way number to be
allocated 'k' which must fulfill 0 < k <= N (where N is the number of
ways). In the future more sophisticated mechasims can be implemented.
Diffstat (limited to 'src/mem/cache/tags/random_repl.cc')
-rw-r--r-- | src/mem/cache/tags/random_repl.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mem/cache/tags/random_repl.cc b/src/mem/cache/tags/random_repl.cc index e7422a335..9f1ef800a 100644 --- a/src/mem/cache/tags/random_repl.cc +++ b/src/mem/cache/tags/random_repl.cc @@ -54,14 +54,22 @@ CacheBlk* RandomRepl::findVictim(Addr addr) { CacheBlk *blk = BaseSetAssoc::findVictim(addr); + unsigned set = extractSet(addr); // if all blocks are valid, pick a replacement at random - if (blk->isValid()) { + if (blk && blk->isValid()) { // find a random index within the bounds of the set int idx = random_mt.random<int>(0, assoc - 1); + blk = sets[set].blks[idx]; + // Enforce allocation limit + while (blk->way >= allocAssoc) { + idx = (idx + 1) % assoc; + blk = sets[set].blks[idx]; + } + assert(idx < assoc); assert(idx >= 0); - blk = sets[extractSet(addr)].blks[idx]; + assert(blk->way < allocAssoc); DPRINTF(CacheRepl, "set %x: selecting blk %x for replacement\n", blk->set, regenerateBlkAddr(blk->tag, blk->set)); |