Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/10143
Change subject: mem-cache: Use block iteration in BaseSetAssoc
......................................................................
mem-cache: Use block iteration in BaseSetAssoc
Use block iteration instead of numSets and assoc in print(),
cleanupRefs() and computeStats().
This makes these functions rely solely on what they are used for:
printing and calculating stats of blocks. With the addition of
Sectors an extra indirection level is added, and thus these
functions would be skipping blocks.
Change-Id: I0006f82736cce02ba3e501ffafe9236f748daf32
---
M src/mem/cache/tags/base_set_assoc.cc
M src/mem/cache/tags/base_set_assoc.hh
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/src/mem/cache/tags/base_set_assoc.cc
b/src/mem/cache/tags/base_set_assoc.cc
index 1761109..734840b 100644
--- a/src/mem/cache/tags/base_set_assoc.cc
+++ b/src/mem/cache/tags/base_set_assoc.cc
@@ -119,14 +119,10 @@
std::string
BaseSetAssoc::print() const {
std::string cache_state;
- for (unsigned i = 0; i < numSets; ++i) {
- // link in the data blocks
- for (unsigned j = 0; j < assoc; ++j) {
- BlkType *blk = sets[i].blks[j];
- if (blk->isValid())
- cache_state += csprintf("\tset: %d block: %d %s\n", i, j,
- blk->print());
- }
+ for (const CacheBlk& blk : blks) {
+ if (blk.isValid())
+ cache_state += csprintf("\tset: %d way: %d %s\n", blk.set,
+ blk.way, blk.print());
}
if (cache_state.empty())
cache_state = "no valid tags\n";
@@ -136,9 +132,9 @@
void
BaseSetAssoc::cleanupRefs()
{
- for (unsigned i = 0; i < numSets*assoc; ++i) {
- if (blks[i].isValid()) {
- totalRefs += blks[i].refCount;
+ for (const CacheBlk& blk : blks) {
+ if (blk.isValid()) {
+ totalRefs += blk.refCount;
++sampledRefs;
}
}
@@ -154,12 +150,12 @@
}
}
- for (unsigned i = 0; i < numSets * assoc; ++i) {
- if (blks[i].isValid()) {
- assert(blks[i].task_id < ContextSwitchTaskId::NumTaskId);
- occupanciesTaskId[blks[i].task_id]++;
- assert(blks[i].tickInserted <= curTick());
- Tick age = curTick() - blks[i].tickInserted;
+ for (const CacheBlk& blk : blks) {
+ if (blk.isValid()) {
+ assert(blk.task_id < ContextSwitchTaskId::NumTaskId);
+ occupanciesTaskId[blk.task_id]++;
+ assert(blk.tickInserted <= curTick());
+ Tick age = curTick() - blk.tickInserted;
int age_index;
if (age / SimClock::Int::us < 10) { // <10us
@@ -173,7 +169,7 @@
} else
age_index = 4; // >10ms
- ageTaskId[blks[i].task_id][age_index]++;
+ ageTaskId[blk.task_id][age_index]++;
}
}
}
diff --git a/src/mem/cache/tags/base_set_assoc.hh
b/src/mem/cache/tags/base_set_assoc.hh
index bf1dff8..7a1d908 100644
--- a/src/mem/cache/tags/base_set_assoc.hh
+++ b/src/mem/cache/tags/base_set_assoc.hh
@@ -308,8 +308,8 @@
* \param visitor Visitor to call on each block.
*/
void forEachBlk(CacheBlkVisitor &visitor) override {
- for (unsigned i = 0; i < numSets * assoc; ++i) {
- if (!visitor(blks[i]))
+ for (CacheBlk& blk : blks) {
+ if (!visitor(blk))
return;
}
}
--
To view, visit https://gem5-review.googlesource.com/10143
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I0006f82736cce02ba3e501ffafe9236f748daf32
Gerrit-Change-Number: 10143
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev