31 #include "debug/HWPrefetch.hh"
33 #include "params/STeMSPrefetcher.hh"
43 :
Queued(
p), spatialRegionSize(
p.spatial_region_size),
44 spatialRegionSizeBits(
floorLog2(
p.spatial_region_size)),
45 reconstructionEntries(
p.reconstruction_entries),
46 activeGenerationTable(
p.active_generation_table_assoc,
47 p.active_generation_table_entries,
48 p.active_generation_table_indexing_policy,
49 p.active_generation_table_replacement_policy,
51 spatialRegionSize / blkSize)),
52 patternSequenceTable(
p.pattern_sequence_table_assoc,
53 p.pattern_sequence_table_entries,
54 p.pattern_sequence_table_indexing_policy,
55 p.pattern_sequence_table_replacement_policy,
57 spatialRegionSize / blkSize)),
58 rmob(
p.region_miss_order_buffer_entries),
59 addDuplicateEntriesToRMOB(
p.add_duplicate_entries_to_rmob),
63 "The spatial region size must be a power of 2.");
75 if (agt_entry.isValid()) {
76 bool generation_ended =
false;
77 bool sr_is_secure = agt_entry.isSecure();
79 for (
auto &seq_entry : agt_entry.sequence) {
80 if (seq_entry.counter > 0) {
82 agt_entry.paddress + seq_entry.offset *
blkSize;
83 if (!
inCache(cache_addr, sr_is_secure) &&
85 generation_ended =
true;
92 if (generation_ended) {
97 if (pst_entry ==
nullptr) {
100 assert(pst_entry !=
nullptr);
108 pst_entry->
update(agt_entry);
122 rmob_entry.
delta = delta;
125 for (
const auto& entry :
rmob) {
126 if (entry.srAddress == sr_addr &&
127 entry.pstAddress == pst_addr &&
128 entry.delta == delta) {
134 rmob.push_back(rmob_entry);
142 DPRINTF(HWPrefetch,
"Ignoring request with no PC.\n");
160 if (agt_entry !=
nullptr) {
177 assert(agt_entry !=
nullptr);
185 if (agt_e.isValid() && agt_entry != &agt_e) {
186 agt_e.seqCounter += 1;
193 auto it =
rmob.end();
194 while (it !=
rmob.begin()) {
196 if (it->srAddress == sr_addr) {
211 unsigned int idx = 0;
218 idx += (it+1)->delta + 1;
227 if (pst_entry !=
nullptr) {
229 for (
auto &seq_entry : pst_entry->
sequence) {
230 if (seq_entry.counter > 1) {
235 unsigned ridx = idx + seq_entry.delta;
239 reconstruction[ridx] ==
MaxAddr) {
240 reconstruction[ridx] = rec_addr;
242 reconstruction[ridx + 1] ==
MaxAddr) {
243 reconstruction[ridx + 1] = rec_addr;
245 reconstruction[ridx + 2] ==
MaxAddr) {
246 reconstruction[ridx + 2] = rec_addr;
247 }
else if ((ridx > 0) &&
249 reconstruction[ridx - 1] ==
MaxAddr) {
250 reconstruction[ridx - 1] = rec_addr;
251 }
else if ((ridx > 1) &&
253 reconstruction[ridx - 2] ==
MaxAddr) {
254 reconstruction[ridx - 2] = rec_addr;
259 idx += (it+1)->delta + 1;
262 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.
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
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.