55#include "debug/HWPrefetch.hh"
58#include "params/StridePrefetcher.hh"
88 pcTableInfo(
p.table_assoc,
p.table_entries,
p.table_indexing_policy,
89 p.table_replacement_policy)
108 std::string table_name =
name() +
".PCTable" + std::to_string(context);
110 auto ins_result =
pcTables.emplace(std::piecewise_construct,
111 std::forward_as_tuple(context),
112 std::forward_as_tuple(table_name.c_str(),
119 DPRINTF(HWPrefetch,
"Adding context %i with stride entries\n", context);
122 return &(ins_result.first->second);
131 DPRINTF(HWPrefetch,
"Ignoring request with no PC.\n");
147 if (entry !=
nullptr) {
151 int new_stride = pf_addr - entry->
lastAddr;
152 bool stride_match = (new_stride == entry->
stride);
155 if (stride_match && new_stride != 0) {
161 entry->
stride = new_stride;
165 DPRINTF(HWPrefetch,
"Hit: PC %x pkt_addr %x (%s) stride %d (%s), "
166 "conf %d\n",
pc, pf_addr, is_secure ?
"s" :
"ns",
167 new_stride, stride_match ?
"match" :
"change",
178 int prefetch_stride = new_stride;
179 if (abs(new_stride) <
blkSize) {
186 new_addr += prefetch_stride;
191 DPRINTF(HWPrefetch,
"Miss: PC %x pkt_addr %x (%s)\n",
pc, pf_addr,
192 is_secure ?
"s" :
"ns");
197 entry->lastAddr = pf_addr;
205 const Addr hash1 =
pc >> 1;
207 return (hash1 ^ hash2) &
setMask;
virtual Entry * findVictim(const Addr addr)
Find a victim to be replaced.
virtual void accessEntry(Entry *entry)
Update the replacement information for an entry.
Associative container based on the previosuly defined Entry type Each element is indexed by a key of ...
void insertEntry(Addr addr, bool is_secure, Entry *entry)
Indicate that an entry has just been inserted.
Entry * findEntry(Addr addr, bool is_secure) const
Find an entry within the set.
const unsigned setMask
Mask out all bits that aren't part of the set index.
const int tagShift
The amount to shift the address to get the tag.
virtual std::string name() const
A tagged entry is an entry containing a tag.
void invalidate() override
Invalidate the block.
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.
std::pair< Addr, int32_t > AddrPriority
Addr extractTag(const Addr addr) const override
Generate the tag from the given address.
uint32_t extractSet(const Addr addr) const override
Apply a hash function to calculate address set.
const SatCounter8 initConfidence
Initial confidence counter value for the pc tables.
const double threshConf
Confidence threshold for prefetch generation.
PCTable * allocateNewContext(int context)
Create a PC table for the given context.
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses, const CacheAccessor &cache) override
const int distance
How far ahead of the demand stream to start prefetching.
Stride(const StridePrefetcherParams &p)
std::unordered_map< int, PCTable > pcTables
const bool useRequestorId
const struct gem5::prefetch::Stride::PCTableInfo pcTableInfo
PCTable * findTable(int context)
Try to find a table of entries for the given context.
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 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Describes a strided prefetcher.
Provides generic cache lookup functions.
replacement_policy::Base *const replacementPolicy
BaseIndexingPolicy *const indexingPolicy
StrideEntry(const SatCounter8 &init_confidence)
void invalidate() override
Invalidate the block.