31#include "debug/HWPrefetch.hh"
33#include "params/STeMSPrefetcher.hh"
42 :
Queued(
p), spatialRegionSize(
p.spatial_region_size),
43 spatialRegionSizeBits(
floorLog2(
p.spatial_region_size)),
44 reconstructionEntries(
p.reconstruction_entries),
45 activeGenerationTable((
name() +
".ActiveGenerationTable").c_str(),
46 p.active_generation_table_entries,
47 p.active_generation_table_assoc,
48 p.active_generation_table_replacement_policy,
49 p.active_generation_table_indexing_policy,
51 spatialRegionSize / blkSize)),
52 patternSequenceTable((
name() +
".PatternSequenceTable").c_str(),
53 p.pattern_sequence_table_entries,
54 p.pattern_sequence_table_assoc,
55 p.pattern_sequence_table_replacement_policy,
56 p.pattern_sequence_table_indexing_policy,
58 spatialRegionSize / blkSize)),
59 rmob(
p.region_miss_order_buffer_entries),
60 addDuplicateEntriesToRMOB(
p.add_duplicate_entries_to_rmob),
64 "The spatial region size must be a power of 2.");
76 if (agt_entry.isValid()) {
77 bool generation_ended =
false;
78 bool sr_is_secure = agt_entry.isSecure();
80 for (
auto &seq_entry : agt_entry.sequence) {
81 if (seq_entry.counter > 0) {
83 agt_entry.paddress + seq_entry.offset *
blkSize;
84 if (!cache.
inCache(cache_addr, sr_is_secure) &&
86 generation_ended =
true;
93 if (generation_ended) {
96 if (pst_entry ==
nullptr) {
99 assert(pst_entry !=
nullptr);
106 pst_entry->update(agt_entry);
120 rmob_entry.
delta = delta;
123 for (
const auto& entry :
rmob) {
124 if (entry.srAddress == sr_addr &&
125 entry.pstAddress == pst_addr &&
126 entry.delta == delta) {
132 rmob.push_back(rmob_entry);
141 DPRINTF(HWPrefetch,
"Ignoring request with no PC.\n");
159 if (agt_entry !=
nullptr) {
176 assert(agt_entry !=
nullptr);
184 if (agt_e.isValid() && agt_entry != &agt_e) {
185 agt_e.seqCounter += 1;
192 auto it =
rmob.end();
193 while (it !=
rmob.begin()) {
195 if (it->srAddress == sr_addr) {
210 unsigned int idx = 0;
217 idx += (it+1)->delta + 1;
225 if (pst_entry !=
nullptr) {
227 for (
auto &seq_entry : pst_entry->sequence) {
228 if (seq_entry.counter > 1) {
233 unsigned ridx = idx + seq_entry.delta;
237 reconstruction[ridx] ==
MaxAddr) {
238 reconstruction[ridx] = rec_addr;
240 reconstruction[ridx + 1] ==
MaxAddr) {
241 reconstruction[ridx + 1] = rec_addr;
243 reconstruction[ridx + 2] ==
MaxAddr) {
244 reconstruction[ridx + 2] = rec_addr;
245 }
else if ((ridx > 0) &&
247 reconstruction[ridx - 1] ==
MaxAddr) {
248 reconstruction[ridx - 1] = rec_addr;
249 }
else if ((ridx > 1) &&
251 reconstruction[ridx - 2] ==
MaxAddr) {
252 reconstruction[ridx - 2] = rec_addr;
257 idx += (it+1)->delta + 1;
260 for (
Addr pf_addr : reconstruction) {
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 getPaddr() const
Gets the physical address of the request.
bool isCacheMiss() const
Check if this event comes from a cache miss.
Addr getAddr() const
Obtains the address value of this Prefetcher address.
bool hasPC() const
Returns true if the associated program counter is valid.
unsigned blkSize
The block size of the parent cache.
std::pair< Addr, int32_t > AddrPriority
unsigned int lastTriggerCounter
Counter to keep the count of accesses between trigger accesses.
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses, const CacheAccessor &cache) override
void addToRMOB(Addr sr_addr, Addr pst_addr, unsigned int delta)
Adds an entry to the RMOB.
AssociativeSet< ActiveGenerationTableEntry > activeGenerationTable
Active Generation Table (AGT)
AssociativeCache< ActiveGenerationTableEntry > patternSequenceTable
Pattern Sequence Table (PST)
void checkForActiveGenerationsEnd(const CacheAccessor &cache)
Checks if the active generations have ended.
CircularQueue< RegionMissOrderBufferEntry > rmob
Region Miss Order Buffer (RMOB)
bool addDuplicateEntriesToRMOB
Add duplicate entries to RMOB
const size_t spatialRegionSizeBits
log_2 of the spatial region size
STeMS(const STeMSPrefetcherParams &p)
const unsigned int reconstructionEntries
Number of reconstruction entries.
void reconstructSequence(CircularQueue< RegionMissOrderBufferEntry >::iterator rmob_it, std::vector< AddrPriority > &addresses)
Reconstructs a sequence of accesses and generates the prefetch addresses, adding them to the addresse...
const size_t spatialRegionSize
Size of each spatial region.
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
static constexpr bool isPowerOf2(const T &n)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
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.
Provides generic cache lookup functions.
virtual bool inCache(Addr addr, bool is_secure) const =0
Determine if address is in cache.
virtual bool inMissQueue(Addr addr, bool is_secure) const =0
Determine if address is in cache miss queue.
Iterator to the circular queue.
Entry data type for the Active Generation Table (AGT) and the Pattern Sequence Table (PST)
Addr pc
PC that started this generation.
Addr paddress
Physical address of the spatial region.
void addOffset(unsigned int offset)
Add a new access to the sequence.
Data type of the Region Miss Order Buffer entry.
Addr srAddress
Address of the spatial region.
Addr pstAddress
Address used to index the PST table, generated using the PC and the offset within the spatial region.
unsigned int delta
Delta within the global miss order sequence.
const std::string & name()