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(
p.active_generation_table_assoc,
46 p.active_generation_table_entries,
47 p.active_generation_table_indexing_policy,
48 p.active_generation_table_replacement_policy,
50 spatialRegionSize / blkSize)),
51 patternSequenceTable(
p.pattern_sequence_table_assoc,
52 p.pattern_sequence_table_entries,
53 p.pattern_sequence_table_indexing_policy,
54 p.pattern_sequence_table_replacement_policy,
56 spatialRegionSize / blkSize)),
57 rmob(
p.region_miss_order_buffer_entries),
58 addDuplicateEntriesToRMOB(
p.add_duplicate_entries_to_rmob),
62 "The spatial region size must be a power of 2.");
74 if (agt_entry.isValid()) {
75 bool generation_ended =
false;
76 bool sr_is_secure = agt_entry.isSecure();
78 for (
auto &seq_entry : agt_entry.sequence) {
79 if (seq_entry.counter > 0) {
81 agt_entry.paddress + seq_entry.offset *
blkSize;
82 if (!
inCache(cache_addr, sr_is_secure) &&
84 generation_ended =
true;
91 if (generation_ended) {
96 if (pst_entry ==
nullptr) {
99 assert(pst_entry !=
nullptr);
107 pst_entry->
update(agt_entry);
121 rmob_entry.
delta = delta;
124 for (
const auto& entry :
rmob) {
125 if (entry.srAddress == sr_addr &&
126 entry.pstAddress == pst_addr &&
127 entry.delta == delta) {
133 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;
226 if (pst_entry !=
nullptr) {
228 for (
auto &seq_entry : pst_entry->
sequence) {
229 if (seq_entry.counter > 1) {
234 unsigned ridx = idx + seq_entry.delta;
238 reconstruction[ridx] ==
MaxAddr) {
239 reconstruction[ridx] = rec_addr;
241 reconstruction[ridx + 1] ==
MaxAddr) {
242 reconstruction[ridx + 1] = rec_addr;
244 reconstruction[ridx + 2] ==
MaxAddr) {
245 reconstruction[ridx + 2] = rec_addr;
246 }
else if ((ridx > 0) &&
248 reconstruction[ridx - 1] ==
MaxAddr) {
249 reconstruction[ridx - 1] = rec_addr;
250 }
else if ((ridx > 1) &&
252 reconstruction[ridx - 2] ==
MaxAddr) {
253 reconstruction[ridx - 2] = rec_addr;
258 idx += (it+1)->delta + 1;
261 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.
bool inCache(Addr addr, bool is_secure) const
Determine if address is in cache.
bool inMissQueue(Addr addr, bool is_secure) const
Determine if address is in cache miss queue.
std::pair< Addr, int32_t > AddrPriority
unsigned int lastTriggerCounter
Counter to keep the count of accesses between trigger accesses.
void addToRMOB(Addr sr_addr, Addr pst_addr, unsigned int delta)
Adds an entry to the RMOB.
AssociativeSet< ActiveGenerationTableEntry > activeGenerationTable
Active Generation Table (AGT)
void checkForActiveGenerationsEnd()
Checks if the active generations have ended.
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
AssociativeSet< ActiveGenerationTableEntry > patternSequenceTable
Pattern Sequence Table (PST)
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...
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Iterator to the circular queue.
Entry data type for the Active Generation Table (AGT) and the Pattern Sequence Table (PST)
std::vector< SequenceEntry > sequence
Sequence of accesses.
Addr pc
PC that started this generation.
Addr paddress
Physical address of the spatial region.
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.
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.