diff options
author | Lisa Hsu <Lisa.Hsu@amd.com> | 2010-02-23 09:34:22 -0800 |
---|---|---|
committer | Lisa Hsu <Lisa.Hsu@amd.com> | 2010-02-23 09:34:22 -0800 |
commit | 1d3228481f3c5f9a4ad041cd21d57139f5f8f331 (patch) | |
tree | 7006a0d99e1f278df5ff88b70c4940230fe9e768 /src/mem/cache/tags/lru.cc | |
parent | be4cf50c5a6a5761f6474fb9f85a9c241101f3ce (diff) | |
download | gem5-1d3228481f3c5f9a4ad041cd21d57139f5f8f331.tar.xz |
cache: Make caches sharing aware and add occupancy stats.
On the config end, if a shared L2 is created for the system, it is
parameterized to have n sharers as defined by option.num_cpus. In addition to
making the cache sharing aware so that discriminating tag policies can make use
of context_ids to make decisions, I added an occupancy AverageStat and an occ %
stat to each cache so that you could know which contexts are occupying how much
cache on average, both in terms of blocks and percentage. Note that since
devices have context_id -1, having an array of occ stats that correspond to
each context_id will break here, so in FS mode I add an extra bucket for device
blocks. This bucket is explicitly not added in SE mode in order to not only
avoid ugliness in the stats.txt file, but to avoid broken stats (some formulas
break when a bucket is 0).
Diffstat (limited to 'src/mem/cache/tags/lru.cc')
-rw-r--r-- | src/mem/cache/tags/lru.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mem/cache/tags/lru.cc b/src/mem/cache/tags/lru.cc index 81d44b0c0..0da2a72e9 100644 --- a/src/mem/cache/tags/lru.cc +++ b/src/mem/cache/tags/lru.cc @@ -74,7 +74,8 @@ LRU::LRU(unsigned _numSets, unsigned _blkSize, unsigned _assoc, sets = new CacheSet[numSets]; blks = new BlkType[numSets * assoc]; // allocate data storage in one big chunk - dataBlks = new uint8_t[numSets*assoc*blkSize]; + numBlocks = numSets * assoc; + dataBlks = new uint8_t[numBlocks * blkSize]; unsigned blkIndex = 0; // index into blks array for (unsigned i = 0; i < numSets; ++i) { @@ -157,6 +158,12 @@ LRU::findVictim(Addr addr, PacketList &writebacks) ++sampledRefs; blk->refCount = 0; + // deal with evicted block + if (blk->contextSrc != -1) { + occupancies[blk->contextSrc % cache->numCpus()]--; + blk->contextSrc = -1; + } + DPRINTF(CacheRepl, "set %x: selecting blk %x for replacement\n", set, regenerateBlkAddr(blk->tag, set)); } @@ -178,6 +185,12 @@ LRU::insertBlock(Addr addr, BlkType *blk, int context_src) // Set tag for new block. Caller is responsible for setting status. blk->tag = extractTag(addr); + // deal with what we are bringing in + if (context_src != -1) { + occupancies[context_src % cache->numCpus()]++; + blk->contextSrc = context_src; + } + unsigned set = extractSet(addr); sets[set].moveToHead(blk); } @@ -190,6 +203,10 @@ LRU::invalidateBlk(BlkType *blk) blk->isTouched = false; blk->clearLoadLocks(); tagsInUse--; + if (blk->contextSrc != -1) { + occupancies[blk->contextSrc % cache->numCpus()]--; + blk->contextSrc = -1; + } } } |