55#include "debug/HWPrefetch.hh"
57#include "params/StridePrefetcher.hh"
89 pcTableInfo(
p.table_assoc,
p.table_entries,
p.table_indexing_policy,
90 p.table_replacement_policy),
101 return *(it->second);
110 std::string table_name =
name() +
".PCTable" + std::to_string(context);
121 DPRINTF(HWPrefetch,
"Adding context %i with stride entries\n", context);
133 DPRINTF(HWPrefetch,
"Ignoring request with no PC.\n");
151 if (entry !=
nullptr) {
155 int new_stride = pf_addr - entry->
lastAddr;
161 bool stride_match = (new_stride == entry->
stride);
170 entry->
stride = new_stride;
174 DPRINTF(HWPrefetch,
"Hit: PC %x pkt_addr %x (%s) stride %d (%s), "
175 "conf %d\n",
pc, pf_addr, is_secure ?
"s" :
"ns",
176 new_stride, stride_match ?
"match" :
"change",
187 int prefetch_stride = entry->
stride;
188 if (abs(prefetch_stride) <
blkSize) {
195 new_addr += prefetch_stride;
200 DPRINTF(HWPrefetch,
"Miss: PC %x pkt_addr %x (%s)\n",
pc, pf_addr,
201 is_secure ?
"s" :
"ns");
206 entry->lastAddr = pf_addr;
214 const Addr pc = key.address;
215 const Addr hash1 =
pc >> 1;
217 return (hash1 ^ hash2) &
setMask;
virtual Entry * findVictim(const KeyType &key)
Find a victim to be replaced.
virtual Entry * findEntry(const KeyType &key) const
Find an entry within the set.
virtual void insertEntry(const KeyType &key, Entry *entry)
Indicate that an entry has just been inserted.
virtual Entry * accessEntry(const KeyType &key)
Do an access to the entry if it exists.
const int tagShift
The amount to shift the address to get the tag.
typename Types::KeyType KeyType
const unsigned setMask
Mask out all bits that aren't part of the set index.
virtual std::string name() const
A tagged entry is an entry containing a tag.
void registerTagExtractor(TagExtractor ext)
virtual void invalidate()
Invalidate the block.
std::function< Addr(Addr)> TagExtractor
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Addr getPC() const
Returns the program counter that generated this request.
bool isSecure() const
Returns true if the address targets the secure memory space.
Addr getAddr() const
Obtains the address value of this Prefetcher address.
bool hasPC() const
Returns true if the associated program counter is valid.
RequestorID getRequestorId() const
Gets the requestor ID that generated this address.
unsigned blkSize
The block size of the parent cache.
Addr blockAddress(Addr a) const
Determine the address of the block in which a lays.
std::pair< Addr, int32_t > AddrPriority
Addr extractTag(const Addr addr) const override
Generate the tag from the given address.
uint32_t extractSet(const KeyType &key) const override
const SatCounter8 initConfidence
Initial confidence counter value for the pc tables.
const double threshConf
Confidence threshold for prefetch generation.
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses, const CacheAccessor &cache) override
const bool useCachelineAddr
If this parameter is set to true, then the prefetcher will operate at the granularity of cache line.
PCTable & allocateNewContext(int context)
Create a PC table for the given context.
PCTable & findTable(int context)
Try to find a table of entries for the given context.
std::unordered_map< int, std::unique_ptr< PCTable > > pcTables
AssociativeCache< StrideEntry > PCTable
const int distance
How far ahead of the demand stream to start prefetching.
Stride(const StridePrefetcherParams &p)
const bool useRequestorId
const struct gem5::prefetch::Stride::PCTableInfo pcTableInfo
double calcSaturation() const
Calculate saturation percentile of the current counter's value with regard to its maximum possible va...
Bitfield< 21, 20 > stride
Copyright (c) 2024 Arm Limited All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
static constexpr auto genTagExtractor(BTBIndexingPolicy *ip)
This helper generates a tag extractor function object which will be typically used by Replaceable ent...
Describes a strided prefetcher.
Provides generic cache lookup functions.
TaggedIndexingPolicy *const indexingPolicy
replacement_policy::Base *const replacementPolicy
StrideEntry(const SatCounter8 &init_confidence, TagExtractor ext)
void invalidate() override
Invalidate the block.