33 #include "debug/HWPrefetch.hh" 35 #include "params/STeMSPrefetcher.hh" 39 spatialRegionSizeBits(
floorLog2(p->spatial_region_size)),
40 reconstructionEntries(p->reconstruction_entries),
41 activeGenerationTable(p->active_generation_table_assoc,
42 p->active_generation_table_entries,
43 p->active_generation_table_indexing_policy,
44 p->active_generation_table_replacement_policy,
46 spatialRegionSize / blkSize)),
47 patternSequenceTable(p->pattern_sequence_table_assoc,
48 p->pattern_sequence_table_entries,
49 p->pattern_sequence_table_indexing_policy,
50 p->pattern_sequence_table_replacement_policy,
52 spatialRegionSize / blkSize)),
53 rmob(p->region_miss_order_buffer_entries), rmobHead(0)
56 "The spatial region size must be a power of 2.");
67 if (agt_entry.isValid()) {
68 bool generation_ended =
false;
69 bool sr_is_secure = agt_entry.isSecure();
70 for (
auto &seq_entry : agt_entry.sequence) {
71 if (seq_entry.counter > 0) {
73 agt_entry.paddress + seq_entry.offset *
blkSize;
74 if (!
inCache(cache_addr, sr_is_secure) &&
76 generation_ended =
true;
81 if (generation_ended) {
86 if (pst_entry ==
nullptr) {
89 assert(pst_entry !=
nullptr);
97 pst_entry->
update(agt_entry);
99 activeGenerationTable.invalidate(&agt_entry);
113 rmob_entry.
delta = delta;
114 rmob_entry.
valid =
true;
122 DPRINTF(HWPrefetch,
"Ignoring request with no PC.\n");
140 if (agt_entry !=
nullptr) {
157 assert(agt_entry !=
nullptr);
165 if (agt_e.isValid() && agt_entry != &agt_e) {
166 agt_e.seqCounter += 1;
175 idx = (idx - 1) %
rmob.size())
177 if (
rmob[idx].srAddress == sr_addr) {
191 unsigned int idx = 0;
194 for (
int i = rmob_idx;
196 i = (
i + 1) %
rmob.size())
199 unsigned int next_i = (
i + 1) %
rmob.size();
200 idx +=
rmob[next_i].delta + 1;
204 for (
int i = rmob_idx;
206 i = (
i + 1) %
rmob.size())
211 if (pst_entry !=
nullptr) {
213 for (
auto &seq_entry : pst_entry->
sequence) {
214 if (seq_entry.counter > 1) {
219 unsigned ridx = idx + seq_entry.delta;
222 if (ridx < reconstructionEntries &&
223 reconstruction[ridx] ==
MaxAddr) {
224 reconstruction[ridx] = rec_addr;
225 }
else if ((ridx + 1) < reconstructionEntries &&
226 reconstruction[ridx + 1] ==
MaxAddr) {
227 reconstruction[ridx + 1] = rec_addr;
228 }
else if ((ridx + 2) < reconstructionEntries &&
229 reconstruction[ridx + 2] ==
MaxAddr) {
230 reconstruction[ridx + 2] = rec_addr;
231 }
else if ((ridx > 0) &&
232 ((ridx - 1) < reconstructionEntries) &&
233 reconstruction[ridx - 1] ==
MaxAddr) {
234 reconstruction[ridx - 1] = rec_addr;
235 }
else if ((ridx > 1) &&
236 ((ridx - 2) < reconstructionEntries) &&
237 reconstruction[ridx - 2] ==
MaxAddr) {
238 reconstruction[ridx - 2] = rec_addr;
243 unsigned int next_i = (
i + 1) %
rmob.size();
244 idx +=
rmob[next_i].delta + 1;
246 for (
Addr pf_addr : reconstruction) {
254 STeMSPrefetcherParams::create()
Data type of the Region Miss Order Buffer entry.
AssociativeSet< ActiveGenerationTableEntry > patternSequenceTable
Pattern Sequence Table (PST)
const unsigned int reconstructionEntries
Number of reconstruction entries.
void checkForActiveGenerationsEnd()
Checks if the active generations have ended.
void update(ActiveGenerationTableEntry const &e)
Update the entry data with an entry from a generation that just ended.
void addOffset(unsigned int offset)
Add a new access to the sequence.
bool inCache(Addr addr, bool is_secure) const
Determine if address is in cache.
bool isCacheMiss() const
Check if this event comes from a cache miss.
bool isSecure() const
Returns true if the address targets the secure memory space.
AssociativeSet< ActiveGenerationTableEntry > activeGenerationTable
Active Generation Table (AGT)
const size_t spatialRegionSizeBits
log_2 of the spatial region size
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
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
Addr paddress
Physical address of the spatial region.
Addr getPC() const
Returns the program counter that generated this request.
void reconstructSequence(unsigned int rmob_idx, std::vector< AddrPriority > &addresses)
Reconstructs a sequence of accesses and generates the prefetch addresses, adding them to the addresse...
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...
unsigned int delta
Delta within the global miss order sequence.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::vector< RegionMissOrderBufferEntry > rmob
Region Miss Order Buffer (RMOB)
Addr srAddress
Address of the spatial region.
unsigned int lastTriggerCounter
Counter to keep the count of accesses between trigger accesses.
Addr pc
PC that started this generation.
const size_t spatialRegionSize
Size of each spatial region.
int floorLog2(unsigned x)
STeMSPrefetcher(const STeMSPrefetcherParams *p)
Copyright (c) 2019 Metempsy Technology Consulting All rights reserved.
bool inMissQueue(Addr addr, bool is_secure) const
Determine if address is in cache miss queue.
Entry data type for the Active Generation Table (AGT) and the Pattern Sequence Table (PST) ...
Addr getPaddr() const
Gets the physical address of the request.
unsigned blkSize
The block size of the parent cache.
void addToRMOB(Addr sr_addr, Addr pst_addr, unsigned int delta)
Adds an entry to the RMOB.
unsigned int rmobHead
First free position (or older, if it is full) of the RMOB.
Addr pstAddress
Address used to index the PST table, generated using the PC and the offset within the spatial region...
std::vector< SequenceEntry > sequence
Sequence of accesses.
bool hasPC() const
Returns true if the associated program counter is valid.