diff options
author | Erik Hallnor <ehallnor@umich.edu> | 2004-09-30 01:46:48 -0400 |
---|---|---|
committer | Erik Hallnor <ehallnor@umich.edu> | 2004-09-30 01:46:48 -0400 |
commit | f2ac7b645f9c352bfb2697e2893beef62af0d08a (patch) | |
tree | 08b57dc74964f01c308def466c3fd1aab77b82a7 /cpu/trace/opt_cpu.hh | |
parent | 34742515f53fa807faa1809ef3cc7d319b9a244e (diff) | |
download | gem5-f2ac7b645f9c352bfb2697e2893beef62af0d08a.tar.xz |
Updates to make traces work correctly in all circumstances. Add opt set associative simulation.
cpu/trace/opt_cpu.cc:
cpu/trace/opt_cpu.hh:
Add the ability to simulate less than fully-associative opt caches.
cpu/trace/reader/itx_reader.cc:
Add writeback to the command list.
--HG--
extra : convert_revision : a9c9c4be3358f4083d7e85772620441a3ad809db
Diffstat (limited to 'cpu/trace/opt_cpu.hh')
-rw-r--r-- | cpu/trace/opt_cpu.hh | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/cpu/trace/opt_cpu.hh b/cpu/trace/opt_cpu.hh index e366c2068..847147b3c 100644 --- a/cpu/trace/opt_cpu.hh +++ b/cpu/trace/opt_cpu.hh @@ -90,8 +90,8 @@ class OptCPU : public BaseCPU Addr addr; }; - /** Reference Information. */ - std::vector<RefInfo> refInfo; + /** Reference Information, per set. */ + std::vector<std::vector<RefInfo> > refInfo; /** Lookup table to track blocks in the cache heap */ L1Table lookupTable; @@ -125,63 +125,65 @@ class OptCPU : public BaseCPU */ void initTable(Addr addr, RefIndex index); - void heapSwap(int a, int b) { + void heapSwap(int set, int a, int b) { RefIndex tmp = cacheHeap[a]; cacheHeap[a] = cacheHeap[b]; cacheHeap[b] = tmp; - setValue(refInfo[cacheHeap[a]].addr, a); - setValue(refInfo[cacheHeap[b]].addr, b); + setValue(refInfo[set][cacheHeap[a]].addr, a); + setValue(refInfo[set][cacheHeap[b]].addr, b); } int heapLeft(int index) { return index + index + 1; } int heapRight(int index) { return index + index + 2; } int heapParent(int index) { return (index - 1) >> 1; } - RefIndex heapRank(int index) { - return refInfo[cacheHeap[index]].nextRefTime; + RefIndex heapRank(int set, int index) { + return refInfo[set][cacheHeap[index]].nextRefTime; } - void heapify(int start){ + void heapify(int set, int start){ int left = heapLeft(start); int right = heapRight(start); int max = start; - if (left < numBlks && heapRank(left) > heapRank(start)) { + if (left < assoc && heapRank(set, left) > heapRank(set, start)) { max = left; } - if (right < numBlks && heapRank(right) > heapRank(max)) { + if (right < assoc && heapRank(set, right) > heapRank(set, max)) { max = right; } if (max != start) { - heapSwap(start, max); - heapify(max); + heapSwap(set, start, max); + heapify(set, max); } } - void verifyHeap(int start) { + void verifyHeap(int set, int start) { int left = heapLeft(start); int right = heapRight(start); - if (left < numBlks) { - assert(heapRank(start) >= heapRank(left)); - verifyHeap(left); + if (left < assoc) { + assert(heapRank(set, start) >= heapRank(set, left)); + verifyHeap(set, left); } - if (right < numBlks) { - assert(heapRank(start) >= heapRank(right)); - verifyHeap(right); + if (right < assoc) { + assert(heapRank(set, start) >= heapRank(set, right)); + verifyHeap(set, right); } } - void processRankIncrease(int start) { + void processRankIncrease(int set, int start) { int parent = heapParent(start); - while (start > 0 && heapRank(parent) < heapRank(start)) { - heapSwap(parent, start); + while (start > 0 && heapRank(set,parent) < heapRank(set,start)) { + heapSwap(set, parent, start); start = parent; parent = heapParent(start); } } + void processSet(int set); + static const RefIndex InfiniteRef = 0x7fffffff; /** Memory reference trace. */ @@ -193,6 +195,10 @@ class OptCPU : public BaseCPU /** The number of blocks in the cache. */ const int numBlks; + const int assoc; + const int numSets; + const int setMask; + int misses; int hits; @@ -203,8 +209,9 @@ class OptCPU : public BaseCPU */ OptCPU(const std::string &name, MemTraceReader *_trace, - int log_block_size, - int cache_size); + int block_size, + int cache_size, + int assoc); /** * Perform the optimal replacement simulation. |