base, mem-cache: Remove IP dependency from the CacheEntry
We don't store a pointer to the indexing policy anymore. Instead, we register a tag extractor callback when we construct the CacheEntry Change-Id: I06dc58e2f67e01f3f9bcd9f0c641505d3aec82ff Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
This commit is contained in:
23
src/base/cache/cache_entry.hh
vendored
23
src/base/cache/cache_entry.hh
vendored
@@ -61,12 +61,12 @@ class CacheEntry : public ReplaceableEntry
|
||||
public:
|
||||
using IndexingPolicy = BaseIndexingPolicy;
|
||||
using KeyType = Addr;
|
||||
using TagExtractor = std::function<Addr(Addr)>;
|
||||
|
||||
CacheEntry(BaseIndexingPolicy *ip) : indexingPolicy(ip) {}
|
||||
~CacheEntry() = default;
|
||||
CacheEntry(const CacheEntry &rhs)
|
||||
: indexingPolicy(rhs.indexingPolicy)
|
||||
CacheEntry(TagExtractor ext)
|
||||
: extractTag(ext), valid(false), tag(MaxAddr)
|
||||
{}
|
||||
~CacheEntry() = default;
|
||||
|
||||
/**
|
||||
* Checks if the entry is valid.
|
||||
@@ -138,24 +138,19 @@ class CacheEntry : public ReplaceableEntry
|
||||
valid = true;
|
||||
}
|
||||
|
||||
virtual Addr
|
||||
extractTag(Addr addr) const
|
||||
{
|
||||
return indexingPolicy->extractTag(addr);
|
||||
}
|
||||
|
||||
private:
|
||||
/** Callback used to extract the tag from the entry */
|
||||
TagExtractor extractTag;
|
||||
|
||||
/**
|
||||
* Valid bit. The contents of this entry are only valid if this bit is set.
|
||||
* @sa invalidate()
|
||||
* @sa insert()
|
||||
*/
|
||||
bool valid{false};
|
||||
|
||||
BaseIndexingPolicy *indexingPolicy{nullptr};
|
||||
bool valid;
|
||||
|
||||
/** The entry's tag. */
|
||||
Addr tag{MaxAddr};
|
||||
Addr tag;
|
||||
};
|
||||
|
||||
} // namespace gem5
|
||||
|
||||
2
src/mem/cache/compressors/frequent_values.cc
vendored
2
src/mem/cache/compressors/frequent_values.cc
vendored
@@ -53,7 +53,7 @@ FrequentValues::FrequentValues(const Params &p)
|
||||
VFT((name() + ".VFT").c_str(),
|
||||
p.vft_entries, p.vft_assoc, p.vft_replacement_policy,
|
||||
p.vft_indexing_policy,
|
||||
VFTEntry(counterBits, p.vft_indexing_policy)),
|
||||
VFTEntry(counterBits, genTagExtractor(p.vft_indexing_policy))),
|
||||
codeGenerationEvent([this]{ phase = COMPRESSING; }, name())
|
||||
{
|
||||
fatal_if((numVFTEntries - 1) > mask(chunkSizeBits),
|
||||
|
||||
4
src/mem/cache/compressors/frequent_values.hh
vendored
4
src/mem/cache/compressors/frequent_values.hh
vendored
@@ -129,8 +129,8 @@ class FrequentValues : public Base
|
||||
*/
|
||||
SatCounter32 counter;
|
||||
|
||||
VFTEntry(std::size_t num_bits, BaseIndexingPolicy *ip)
|
||||
: CacheEntry(ip), value(0), counter(num_bits)
|
||||
VFTEntry(std::size_t num_bits, TagExtractor ext)
|
||||
: CacheEntry(ext), value(0), counter(num_bits)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ DeltaCorrelatingPredictionTables::DeltaCorrelatingPredictionTables(
|
||||
table((name() + "DCPT").c_str(), p.table_entries,
|
||||
p.table_assoc, p.table_replacement_policy,
|
||||
p.table_indexing_policy,
|
||||
DCPTEntry(p.deltas_per_entry, p.table_indexing_policy))
|
||||
DCPTEntry(p.deltas_per_entry,
|
||||
genTagExtractor(p.table_indexing_policy)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ class DeltaCorrelatingPredictionTables : public SimObject
|
||||
* Constructor
|
||||
* @param num_deltas number of deltas stored in the entry
|
||||
*/
|
||||
DCPTEntry(unsigned int num_deltas, BaseIndexingPolicy *ip)
|
||||
: CacheEntry(ip), lastAddress(0), deltas(num_deltas)
|
||||
DCPTEntry(unsigned int num_deltas, TagExtractor ext)
|
||||
: CacheEntry(ext), lastAddress(0), deltas(num_deltas)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
14
src/mem/cache/tags/indexing_policies/base.hh
vendored
14
src/mem/cache/tags/indexing_policies/base.hh
vendored
@@ -213,6 +213,20 @@ class AddrTypes
|
||||
using BaseIndexingPolicy = IndexingPolicyTemplate<AddrTypes>;
|
||||
template class IndexingPolicyTemplate<AddrTypes>;
|
||||
|
||||
/**
|
||||
* This helper generates an a tag extractor function object
|
||||
* which will be typically used by Replaceable entries indexed
|
||||
* with the BaseIndexingPolicy.
|
||||
* It allows to "decouple" indexing from tagging. Those entries
|
||||
* would call the functor without directly holding a pointer
|
||||
* to the indexing policy which should reside in the cache.
|
||||
*/
|
||||
static constexpr auto
|
||||
genTagExtractor(BaseIndexingPolicy *ip)
|
||||
{
|
||||
return [ip] (Addr addr) { return ip->extractTag(addr); };
|
||||
}
|
||||
|
||||
} // namespace gem5
|
||||
|
||||
#endif //__MEM_CACHE_INDEXING_POLICIES_BASE_HH__
|
||||
|
||||
Reference in New Issue
Block a user