36 #include "debug/HWPrefetch.hh" 38 #include "params/SignaturePathPrefetcher.hh" 41 const SignaturePathPrefetcherParams *
p)
43 stridesPerPatternEntry(p->strides_per_pattern_entry),
44 signatureShift(p->signature_shift),
45 signatureBits(p->signature_bits),
46 prefetchConfidenceThreshold(p->prefetch_confidence_threshold),
47 lookaheadConfidenceThreshold(p->lookahead_confidence_threshold),
48 signatureTable(p->signature_table_assoc, p->signature_table_entries,
49 p->signature_table_indexing_policy,
50 p->signature_table_replacement_policy),
51 patternTable(p->pattern_table_assoc, p->pattern_table_entries,
52 p->pattern_table_indexing_policy,
53 p->pattern_table_replacement_policy,
54 PatternEntry(stridesPerPatternEntry, p->num_counter_bits))
57 "The prefetch confidence threshold must be greater than 0\n");
59 "The prefetch confidence threshold must be less than 1\n");
61 "The lookahead confidence threshold must be greater than 0\n");
63 "The lookahead confidence threshold must be less than 1\n");
70 if (pstride_entry ==
nullptr) {
78 unsigned long current_counter = ULONG_MAX;
79 for (
auto &entry : strideEntries) {
80 if (entry.counter < current_counter) {
81 victim_pstride_entry = &entry;
82 current_counter = entry.
counter;
86 pstride_entry = victim_pstride_entry;
90 return *pstride_entry;
104 if (num_cross_pages > ppn) {
108 pf_ppn = ppn - num_cross_pages;
118 pf_ppn = ppn + num_cross_pages;
130 DPRINTF(HWPrefetch,
"Queuing prefetch to %#x.\n", new_addr);
138 new_signature = current_block;
140 new_stride = current_block;
163 double &initial_confidence)
166 if (signature_entry !=
nullptr) {
169 stride = block - signature_entry->
lastBlock;
172 assert(signature_entry !=
nullptr);
176 initial_confidence, stride);
182 return *signature_entry;
189 if (pattern_entry !=
nullptr) {
195 assert(pattern_entry !=
nullptr);
197 patternTable.insertEntry(signature,
false, pattern_entry);
199 return *pattern_entry;
214 if (lookahead_confidence > 0.95) {
220 lookahead_confidence = 0.95;
222 return lookahead_confidence;
234 double initial_confidence = 1.0;
241 current_block, miss, stride, initial_confidence);
261 double current_confidence = initial_confidence;
274 if (current_pattern_entry !=
nullptr) {
275 unsigned long max_counter = 0;
276 for (
auto const &entry : current_pattern_entry->
strideEntries) {
278 if (max_counter < entry.counter) {
282 double prefetch_confidence =
286 assert(entry.stride != 0);
289 current_confidence, current_signature,
290 is_secure, addresses);
295 if (lookahead !=
nullptr) {
297 *current_pattern_entry, *lookahead);
300 current_stride += lookahead->
stride;
302 current_confidence = 0.0;
313 if (addresses.empty()) {
316 is_secure, addresses);
321 SignaturePathPrefetcherParams::create()
Signature entry data type.
AssociativeSet< PatternEntry > patternTable
Pattern table.
virtual void increasePatternEntryCounter(PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry)
Increases the counter of a given PatternEntry/PatternStrideEntry.
stride_t stride
stride in a page in blkSize increments
A stride entry with its counter.
Bitfield< 21, 20 > stride
const double prefetchConfidenceThreshold
Minimum confidence to issue a prefetch.
double calcSaturation() const
Calculate saturation percentile of the current counter's value with regard to its maximum possible va...
SignaturePathPrefetcher(const SignaturePathPrefetcherParams *p)
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
void addPrefetch(Addr ppn, stride_t last_block, stride_t delta, double path_confidence, signature_t signature, bool is_secure, std::vector< AddrPriority > &addresses)
Generates an address to be prefetched.
virtual double calculateLookaheadConfidence(PatternEntry const &sig, PatternStrideEntry const &lookahead) const
Computes the lookahead path confidence of the provided pattern entry.
bool isSecure() const
Returns true if the address targets the secure memory space.
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
signature_t signature
Path signature.
virtual void handleSignatureTableMiss(stride_t current_block, signature_t &new_signature, double &new_conf, stride_t &new_stride)
Whenever a new SignatureEntry is allocated, it computes the new signature to be used with the new ent...
Addr getAddr() const
Obtains the address value of this Prefetcher address.
std::vector< PatternStrideEntry > strideEntries
group of stides
Class containing the information needed by the prefetch to train and generate new prefetch requests...
std::pair< Addr, int32_t > AddrPriority
virtual void handlePageCrossingLookahead(signature_t signature, stride_t last_offset, stride_t delta, double path_confidence)
Handles the situation when the lookahead process has crossed the boundaries of the current page...
SignatureEntry & getSignatureEntry(Addr ppn, bool is_secure, stride_t block, bool &miss, stride_t &stride, double &initial_confidence)
Obtains the SignatureEntry of the given page, if the page is not found, it allocates a new one...
const double lookaheadConfidenceThreshold
Minimum confidence to keep navigating lookahead entries.
int16_t stride_t
Stride type.
void updatePatternTable(Addr signature, stride_t stride)
Updates the pattern table with the provided signature and stride.
void reset()
Reset the counter to its initial value.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
PatternEntry & getPatternEntry(Addr signature)
Obtains the PatternEntry of the given signature, if the signature is not found, it allocates a new on...
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual void auxiliaryPrefetcher(Addr ppn, stride_t current_block, bool is_secure, std::vector< AddrPriority > &addresses)
Auxiliar prefetch mechanism used at the end of calculatePrefetch.
PatternStrideEntry & getStrideEntry(stride_t stride)
Gets the entry with the provided stride, if there is no entry with the associated stride...
AssociativeSet< SignatureEntry > signatureTable
Signature table.
signature_t updateSignature(signature_t sig, stride_t str) const
Generates a new signature from an existing one and a new stride.
SatCounter counter
Saturating counter.
unsigned blkSize
The block size of the parent cache.
virtual double calculatePrefetchConfidence(PatternEntry const &sig, PatternStrideEntry const &entry) const
Computes the prefetch confidence of the provided pattern entry.
uint16_t signature_t
Signature type.
stride_t lastBlock
Last accessed block within a page.
Pattern entry data type, a set of stride and counter entries.