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.hh | |
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.hh')
-rw-r--r-- | src/mem/cache/tags/base_set_assoc.hh | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh index bf227c067..33b2d39c4 100644 --- a/src/mem/cache/tags/base_set_assoc.hh +++ b/src/mem/cache/tags/base_set_assoc.hh @@ -48,6 +48,7 @@ #ifndef __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__ #define __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__ +#include <functional> #include <string> #include <vector> @@ -298,38 +299,19 @@ class BaseSetAssoc : public BaseTags return ((blk->tag << tagShift) | ((Addr)blk->set << setShift)); } - /** - * Called at end of simulation to complete average block reference stats. - */ - void cleanupRefs() override; - - /** - * Print all tags used - */ - std::string print() const override; - - /** - * Called prior to dumping stats to compute task occupancy - */ - void computeStats() override; + void forEachBlk(std::function<void(CacheBlk &)> visitor) override { + for (CacheBlk& blk : blks) { + visitor(blk); + } + } - /** - * Visit each block in the tag store and apply a visitor to the - * block. - * - * The visitor should be a function (or object that behaves like a - * function) that takes a cache block reference as its parameter - * and returns a bool. A visitor can request the traversal to be - * stopped by returning false, returning true causes it to be - * called for the next block in the tag store. - * - * \param visitor Visitor to call on each block. - */ - void forEachBlk(CacheBlkVisitor &visitor) override { + bool anyBlk(std::function<bool(CacheBlk &)> visitor) override { for (CacheBlk& blk : blks) { - if (!visitor(blk)) - return; + if (visitor(blk)) { + return true; + } } + return false; } }; |