59 #include "debug/HWPrefetch.hh" 61 #include "params/StridePrefetcher.hh" 109 auto insertion_result =
pcTables.insert(std::make_pair(context,
112 DPRINTF(HWPrefetch,
"Adding context %i with stride entries\n", context);
115 return &(insertion_result.first->second);
121 replacementPolicy(replacementPolicy)
123 for (
int set = 0;
set < sets;
set++) {
125 for (
int way = 0; way < assoc; way++) {
127 entries[
set][way].setPosition(
set, way);
130 entries[
set][way].replacementData =
145 DPRINTF(HWPrefetch,
"Ignoring request with no PC.\n");
161 if (entry !=
nullptr) {
163 int new_stride = pf_addr - entry->
lastAddr;
164 bool stride_match = (new_stride == entry->
stride);
167 if (stride_match && new_stride != 0) {
175 entry->
stride = new_stride;
178 DPRINTF(HWPrefetch,
"Hit: PC %x pkt_addr %x (%s) stride %d (%s), " 179 "conf %d\n", pc, pf_addr, is_secure ?
"s" :
"ns",
180 new_stride, stride_match ?
"match" :
"change",
192 int prefetch_stride = new_stride;
193 if (abs(new_stride) <
blkSize) {
197 Addr new_addr = pf_addr +
d * prefetch_stride;
202 DPRINTF(HWPrefetch,
"Miss: PC %x pkt_addr %x (%s)\n", pc, pf_addr,
203 is_secure ?
"s" :
"ns");
223 Addr hash1 = pc >> 1;
236 for (
auto& entry :
entries[
set]) {
237 possible_entries.push_back(&entry);
244 DPRINTF(HWPrefetch,
"Victimizing lookup table[%d][%d].\n",
254 for (
auto& entry :
entries[
set]) {
256 if ((entry.instAddr == pc) && (entry.isSecure == is_secure)) {
257 DPRINTF(HWPrefetch,
"Lookup hit table[%d][%d].\n", entry.getSet(),
267 StridePrefetcherParams::create()
PCTable * allocateNewContext(int context)
Create a PC table for the given context.
void invalidate()
Invalidate the entry.
Addr pcHash(Addr pc) const
PC hashing function to index sets in the table.
StridePrefetcher(const StridePrefetcherParams *p)
virtual void touch(const std::shared_ptr< ReplacementData > &replacement_data) const =0
Update replacement data.
bool isSecure() const
Returns true if the address targets the secure memory space.
virtual ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const =0
Find replacement victim among candidates.
BaseReplacementPolicy * replacementPolicy
Replacement policy used in the PC tables.
A common base class of cache replacement policy objects.
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
Describes a strided prefetcher.
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Class containing the information needed by the prefetch to train and generate new prefetch requests...
std::pair< Addr, int32_t > AddrPriority
std::shared_ptr< ReplacementData > replacementData
Replacement data associated to this entry.
Addr getPC() const
Returns the program counter that generated this request.
std::vector< std::vector< StrideEntry > > entries
bool isPowerOf2(const T &n)
StrideEntry * findEntry(Addr pc, bool is_secure)
Search for an entry in the pc table.
~PCTable()
Default destructor.
PCTable(int assoc, int sets, const std::string name, BaseReplacementPolicy *replacementPolicy)
Default constructor.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual const std::string name() const
virtual std::shared_ptr< ReplacementData > instantiateEntry()=0
Instantiate a replacement data entry.
PCTable * findTable(int context)
Try to find a table of entries for the given context.
StrideEntry()
Default constructor.
virtual void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) const =0
Invalidate replacement data to set it as the next probable victim.
virtual void reset(const std::shared_ptr< ReplacementData > &replacement_data) const =0
Reset replacement data.
int floorLog2(unsigned x)
uint32_t getWay() const
Get way number.
StrideEntry * findVictim(Addr pc)
Find a replacement victim to make room for given PC.
std::unordered_map< int, PCTable > pcTables
uint32_t getSet() const
Get set number.
unsigned blkSize
The block size of the parent cache.
BaseReplacementPolicy * replacementPolicy
Replacement policy used by StridePrefetcher.
MasterID getMasterId() const
Gets the requestor ID that generated this address.
bool hasPC() const
Returns true if the associated program counter is valid.