diff options
author | Nikos Nikoleris <nikos.nikoleris@arm.com> | 2018-05-30 11:54:57 +0100 |
---|---|---|
committer | Nikos Nikoleris <nikos.nikoleris@arm.com> | 2018-05-31 17:45:23 +0000 |
commit | 51f83a3cffa9f068afb3ca35327420c72713900a (patch) | |
tree | 017ea6bb77e05424c2f0a4050dbfade4dbd0c74a /src/mem/cache/tags/base_set_assoc.cc | |
parent | 56865ad1154c7c3fde2ae6b7329d0c888390f781 (diff) | |
download | gem5-51f83a3cffa9f068afb3ca35327420c72713900a.tar.xz |
mem-cache: Replace block visitor with std::function
This change modifies forEachBlk tags function to accept std::function
as parameter. It also adds an anyBlk tags function that given a
condition, it iterates through the blocks and returns whether the
condition is met.
Finally, it uses forEachBlk to implement the print, computeStats and
cleanupRefs functions that also work for the FALRU class.
Change-Id: I2f75f4baa1fdd5a1d343a63ecace3eb9458fbf03
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/10621
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src/mem/cache/tags/base_set_assoc.cc')
-rw-r--r-- | src/mem/cache/tags/base_set_assoc.cc | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/mem/cache/tags/base_set_assoc.cc b/src/mem/cache/tags/base_set_assoc.cc index d3420b440..9cd93dbea 100644 --- a/src/mem/cache/tags/base_set_assoc.cc +++ b/src/mem/cache/tags/base_set_assoc.cc @@ -47,11 +47,9 @@ #include "mem/cache/tags/base_set_assoc.hh" -#include <cassert> #include <string> #include "base/intmath.hh" -#include "mem/request.hh" BaseSetAssoc::BaseSetAssoc(const Params *p) :BaseTags(p), assoc(p->assoc), allocAssoc(p->assoc), @@ -134,64 +132,6 @@ BaseSetAssoc::findBlockBySetAndWay(int set, int way) const return sets[set].blks[way]; } -std::string -BaseSetAssoc::print() const { - std::string cache_state; - 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"; - return cache_state; -} - -void -BaseSetAssoc::cleanupRefs() -{ - for (const CacheBlk& blk : blks) { - if (blk.isValid()) { - totalRefs += blk.refCount; - ++sampledRefs; - } - } -} - -void -BaseSetAssoc::computeStats() -{ - for (unsigned i = 0; i < ContextSwitchTaskId::NumTaskId; ++i) { - occupanciesTaskId[i] = 0; - for (unsigned j = 0; j < 5; ++j) { - ageTaskId[i][j] = 0; - } - } - - 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 - age_index = 0; - } else if (age / SimClock::Int::us < 100) { // <100us - age_index = 1; - } else if (age / SimClock::Int::ms < 1) { // <1ms - age_index = 2; - } else if (age / SimClock::Int::ms < 10) { // <10ms - age_index = 3; - } else - age_index = 4; // >10ms - - ageTaskId[blk.task_id][age_index]++; - } - } -} - BaseSetAssoc * BaseSetAssocParams::create() { |