55a56,63
> fatal_if(prefetchConfidenceThreshold < 0,
> "The prefetch confidence threshold must be greater than 0\n");
> fatal_if(prefetchConfidenceThreshold > 1,
> "The prefetch confidence threshold must be less than 1\n");
> fatal_if(lookaheadConfidenceThreshold < 0,
> "The lookahead confidence threshold must be greater than 0\n");
> fatal_if(lookaheadConfidenceThreshold > 1,
> "The lookahead confidence threshold must be less than 1\n");
89c97,98
< SignaturePathPrefetcher::addPrefetch(Addr ppn, stride_t block,
---
> SignaturePathPrefetcher::addPrefetch(Addr ppn, stride_t last_block,
> stride_t delta, double path_confidence, signature_t signature,
92,101c101
< /**
< * block is relative to the provided ppn. Assuming a page size of 4kB and
< * a block size of 64B, the range of the stride of this prefetcher is
< * -63,63 (pageBytes/blkSize) as the last accessed block also ranges from
< * 0,63, the block value is expected to be between -63 and 126
< * Negative block means that we are accessing the lower contiguous page,
< * 64 or greater point to the next contiguous.
< */
< assert(block > -((stride_t)(pageBytes/blkSize)));
< assert(block < 2*((stride_t)(pageBytes/blkSize)));
---
> stride_t block = last_block + delta;
106,107c106,114
< pf_ppn = ppn - 1;
< pf_block = block + (pageBytes/blkSize);
---
> stride_t num_cross_pages = 1 + (-block) / (pageBytes/blkSize);
> if (num_cross_pages > ppn) {
> // target address smaller than page 0, ignore this request;
> return;
> }
> pf_ppn = ppn - num_cross_pages;
> pf_block = block + (pageBytes/blkSize) * num_cross_pages;
> handlePageCrossingLookahead(signature, last_block, delta,
> path_confidence);
109,110c116,124
< pf_ppn = ppn + 1;
< pf_block = block - (pageBytes/blkSize);
---
> stride_t num_cross_pages = block / (pageBytes/blkSize);
> if (MaxAddr/pageBytes < (ppn + num_cross_pages)) {
> // target address goes beyond MaxAddr, ignore this request;
> return;
> }
> pf_ppn = ppn + num_cross_pages;
> pf_block = block - (pageBytes/blkSize) * num_cross_pages;
> handlePageCrossingLookahead(signature, last_block, delta,
> path_confidence);
123a138,155
> SignaturePathPrefetcher::handleSignatureTableMiss(stride_t current_block,
> signature_t &new_signature, double &new_conf, stride_t &new_stride)
> {
> new_signature = current_block;
> new_conf = 1.0;
> new_stride = current_block;
> }
>
> void
> SignaturePathPrefetcher::increasePatternEntryCounter(
> PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry)
> {
> if (pstride_entry.counter < maxCounterValue) {
> pstride_entry.counter += 1;
> }
> }
>
> void
131,133c163
< if (ps_entry.counter < maxCounterValue) {
< ps_entry.counter += 1;
< }
---
> increasePatternEntryCounter(p_entry, ps_entry);
138c168,169
< stride_t block, bool &miss)
---
> stride_t block, bool &miss, stride_t &stride,
> double &initial_confidence)
143a175
> stride = block - signature_entry->lastBlock;
147a180,183
> // Sets signature_entry->signature, initial_confidence, and stride
> handleSignatureTableMiss(block, signature_entry->signature,
> initial_confidence, stride);
>
149,150d184
< signature_entry->signature = block;
< signature_entry->lastBlock = block;
152a187
> signature_entry->lastBlock = block;
172a208,232
> double
> SignaturePathPrefetcher::calculatePrefetchConfidence(PatternEntry const &sig,
> PatternStrideEntry const &entry) const
> {
> return ((double) entry.counter) / maxCounterValue;
> }
>
> double
> SignaturePathPrefetcher::calculateLookaheadConfidence(PatternEntry const &sig,
> PatternStrideEntry const &lookahead) const
> {
> double lookahead_confidence;
> if (lookahead.counter == maxCounterValue) {
> /**
> * maximum confidence is 0.95, guaranteeing that
> * current confidence will eventually fall beyond
> * the threshold
> */
> lookahead_confidence = 0.95;
> } else {
> lookahead_confidence = ((double) lookahead.counter / maxCounterValue);
> }
> return lookahead_confidence;
> }
>
181a242
> double initial_confidence = 1.0;
188c249,250
< current_block, miss);
---
> current_block, miss, stride, initial_confidence);
>
194d255
< stride = current_block - signature_entry.lastBlock;
203c264
< // Update the current SignatureEntry signature and lastBlock
---
> // Update the current SignatureEntry signature
206d266
< signature_entry.lastBlock = current_block;
209c269
< double current_confidence = 1.0;
---
> double current_confidence = initial_confidence;
212c272,274
< do {
---
> // Look for prefetch candidates while the current path confidence is
> // high enough
> while (current_confidence > lookaheadConfidenceThreshold) {
229c291
< (double) entry.counter / maxCounterValue;
---
> calculatePrefetchConfidence(*current_pattern_entry, entry);
234,235c296,298
< addPrefetch(ppn, current_stride + entry.stride,
< is_secure, addresses);
---
> addPrefetch(ppn, current_stride, entry.stride,
> current_confidence, current_signature,
> is_secure, addresses);
238a302
>
240,253c304,305
< // If a lookahead was selected, compute its confidence using
< // the counter of its entry and the accumulated confidence
< // if the confidence is high enough, generate a new signature
< double lookahead_confidence;
< if (lookahead->counter == maxCounterValue) {
< // maximum confidence is 0.95, guaranteeing that
< // current confidence will eventually fall beyond
< // the threshold
< lookahead_confidence = 0.95;
< } else {
< lookahead_confidence =
< ((double) lookahead->counter / maxCounterValue);
< }
< current_confidence *= lookahead_confidence;
---
> current_confidence *= calculateLookaheadConfidence(
> *current_pattern_entry, *lookahead);
260,261d311
< // If the accumulated confidence is high enough, keep repeating
< // this process with the updated signature
263d312
< while (current_confidence > lookaheadConfidenceThreshold);
264a314,320
> auxiliaryPrefetcher(ppn, current_block, is_secure, addresses);
> }
>
> void
> SignaturePathPrefetcher::auxiliaryPrefetcher(Addr ppn, stride_t current_block,
> bool is_secure, std::vector<AddrPriority> &addresses)
> {
267c323,324
< addPrefetch(ppn, current_block + 1, is_secure, addresses);
---
> addPrefetch(ppn, current_block, 1, 0.0 /* unused*/, 0 /* unused */,
> is_secure, addresses);