mem-cache: De-virtualize forEachBlk() in tags
Avoid code duplication by using the anyBlk function with a lambda that always returns false, which forces all blocks to be visited. Change-Id: I25527602535c719f46699677a7f70f3e31157f26 Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70998 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
685a5cd017
commit
77ac6eacd9
9
src/mem/cache/tags/base.cc
vendored
9
src/mem/cache/tags/base.cc
vendored
@@ -215,6 +215,15 @@ BaseTags::print()
|
||||
return str;
|
||||
}
|
||||
|
||||
void
|
||||
BaseTags::forEachBlk(std::function<void(CacheBlk &)> visitor)
|
||||
{
|
||||
anyBlk([visitor](CacheBlk &blk) {
|
||||
visitor(blk);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
BaseTags::BaseTagStats::BaseTagStats(BaseTags &_tags)
|
||||
: statistics::Group(&_tags),
|
||||
tags(_tags),
|
||||
|
||||
2
src/mem/cache/tags/base.hh
vendored
2
src/mem/cache/tags/base.hh
vendored
@@ -336,7 +336,7 @@ class BaseTags : public ClockedObject
|
||||
*
|
||||
* @param visitor Visitor to call on each block.
|
||||
*/
|
||||
virtual void forEachBlk(std::function<void(CacheBlk &)> visitor) = 0;
|
||||
void forEachBlk(std::function<void(CacheBlk &)> visitor);
|
||||
|
||||
/**
|
||||
* Find if any of the blocks satisfies a condition
|
||||
|
||||
6
src/mem/cache/tags/base_set_assoc.hh
vendored
6
src/mem/cache/tags/base_set_assoc.hh
vendored
@@ -233,12 +233,6 @@ class BaseSetAssoc : public BaseTags
|
||||
return indexingPolicy->regenerateAddr(blk->getTag(), blk);
|
||||
}
|
||||
|
||||
void forEachBlk(std::function<void(CacheBlk &)> visitor) override {
|
||||
for (CacheBlk& blk : blks) {
|
||||
visitor(blk);
|
||||
}
|
||||
}
|
||||
|
||||
bool anyBlk(std::function<bool(CacheBlk &)> visitor) override {
|
||||
for (CacheBlk& blk : blks) {
|
||||
if (visitor(blk)) {
|
||||
|
||||
8
src/mem/cache/tags/compressed_tags.cc
vendored
8
src/mem/cache/tags/compressed_tags.cc
vendored
@@ -163,14 +163,6 @@ CompressedTags::findVictim(Addr addr, const bool is_secure,
|
||||
return victim;
|
||||
}
|
||||
|
||||
void
|
||||
CompressedTags::forEachBlk(std::function<void(CacheBlk &)> visitor)
|
||||
{
|
||||
for (CompressionBlk& blk : blks) {
|
||||
visitor(blk);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CompressedTags::anyBlk(std::function<bool(CacheBlk &)> visitor)
|
||||
{
|
||||
|
||||
10
src/mem/cache/tags/compressed_tags.hh
vendored
10
src/mem/cache/tags/compressed_tags.hh
vendored
@@ -108,16 +108,6 @@ class CompressedTags : public SectorTags
|
||||
const std::size_t compressed_size,
|
||||
std::vector<CacheBlk*>& evict_blks) override;
|
||||
|
||||
/**
|
||||
* Visit each sub-block in the tags and apply a visitor.
|
||||
*
|
||||
* The visitor should be a std::function that takes a cache block.
|
||||
* reference as its parameter.
|
||||
*
|
||||
* @param visitor Visitor to call on each block.
|
||||
*/
|
||||
void forEachBlk(std::function<void(CacheBlk &)> visitor) override;
|
||||
|
||||
/**
|
||||
* Find if any of the sub-blocks satisfies a condition.
|
||||
*
|
||||
|
||||
6
src/mem/cache/tags/fa_lru.hh
vendored
6
src/mem/cache/tags/fa_lru.hh
vendored
@@ -253,12 +253,6 @@ class FALRU : public BaseTags
|
||||
return blk->getTag();
|
||||
}
|
||||
|
||||
void forEachBlk(std::function<void(CacheBlk &)> visitor) override {
|
||||
for (int i = 0; i < numBlocks; i++) {
|
||||
visitor(blks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
bool anyBlk(std::function<bool(CacheBlk &)> visitor) override {
|
||||
for (int i = 0; i < numBlocks; i++) {
|
||||
if (visitor(blks[i])) {
|
||||
|
||||
8
src/mem/cache/tags/sector_tags.cc
vendored
8
src/mem/cache/tags/sector_tags.cc
vendored
@@ -359,14 +359,6 @@ SectorTags::SectorTagsStats::regStats()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SectorTags::forEachBlk(std::function<void(CacheBlk &)> visitor)
|
||||
{
|
||||
for (SectorSubBlk& blk : blks) {
|
||||
visitor(blk);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
SectorTags::anyBlk(std::function<bool(CacheBlk &)> visitor)
|
||||
{
|
||||
|
||||
10
src/mem/cache/tags/sector_tags.hh
vendored
10
src/mem/cache/tags/sector_tags.hh
vendored
@@ -193,16 +193,6 @@ class SectorTags : public BaseTags
|
||||
*/
|
||||
Addr regenerateBlkAddr(const CacheBlk* blk) const override;
|
||||
|
||||
/**
|
||||
* Visit each sub-block in the tags and apply a visitor.
|
||||
*
|
||||
* The visitor should be a std::function that takes a cache block.
|
||||
* reference as its parameter.
|
||||
*
|
||||
* @param visitor Visitor to call on each block.
|
||||
*/
|
||||
void forEachBlk(std::function<void(CacheBlk &)> visitor) override;
|
||||
|
||||
/**
|
||||
* Find if any of the sub-blocks satisfies a condition.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user