summaryrefslogtreecommitdiff
path: root/src/mem/cache/prefetch/signature_path.cc
diff options
context:
space:
mode:
authorDaniel <odanrc@yahoo.com.br>2019-04-11 08:37:56 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2019-05-14 07:55:06 +0000
commitc1bd27907d9404ba0803495d8eb5c9ad8513f09f (patch)
treea8447ce260a1a810a53c00eeeea6c42af06f9596 /src/mem/cache/prefetch/signature_path.cc
parent50a533f10134e7bc377dfdb9209b0334fd01cd24 (diff)
downloadgem5-c1bd27907d9404ba0803495d8eb5c9ad8513f09f.tar.xz
mem-cache: Use SatCounter for prefetchers
Many prefetchers re-implement saturating counters with ints. Make them use SatCounters instead. Added missing operators and constructors to SatCounter for that to be possible and their respective tests. Change-Id: I36f10c89c27c9b3d1bf461e9ea546920f6ebb888 Signed-off-by: Daniel <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17995 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Javier Bueno Hedo <javier.bueno@metempsy.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/mem/cache/prefetch/signature_path.cc')
-rw-r--r--src/mem/cache/prefetch/signature_path.cc32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/mem/cache/prefetch/signature_path.cc b/src/mem/cache/prefetch/signature_path.cc
index 857354e65..febc47132 100644
--- a/src/mem/cache/prefetch/signature_path.cc
+++ b/src/mem/cache/prefetch/signature_path.cc
@@ -31,6 +31,7 @@
#include "mem/cache/prefetch/signature_path.hh"
#include <cassert>
+#include <climits>
#include "debug/HWPrefetch.hh"
#include "mem/cache/prefetch/associative_set_impl.hh"
@@ -42,7 +43,6 @@ SignaturePathPrefetcher::SignaturePathPrefetcher(
stridesPerPatternEntry(p->strides_per_pattern_entry),
signatureShift(p->signature_shift),
signatureBits(p->signature_bits),
- maxCounterValue(p->max_counter_value),
prefetchConfidenceThreshold(p->prefetch_confidence_threshold),
lookaheadConfidenceThreshold(p->lookahead_confidence_threshold),
signatureTable(p->signature_table_assoc, p->signature_table_entries,
@@ -51,7 +51,7 @@ SignaturePathPrefetcher::SignaturePathPrefetcher(
patternTable(p->pattern_table_assoc, p->pattern_table_entries,
p->pattern_table_indexing_policy,
p->pattern_table_replacement_policy,
- PatternEntry(stridesPerPatternEntry))
+ PatternEntry(stridesPerPatternEntry, p->num_counter_bits))
{
fatal_if(prefetchConfidenceThreshold < 0,
"The prefetch confidence threshold must be greater than 0\n");
@@ -64,8 +64,7 @@ SignaturePathPrefetcher::SignaturePathPrefetcher(
}
SignaturePathPrefetcher::PatternStrideEntry &
-SignaturePathPrefetcher::PatternEntry::getStrideEntry(stride_t stride,
- uint8_t max_counter_value)
+SignaturePathPrefetcher::PatternEntry::getStrideEntry(stride_t stride)
{
PatternStrideEntry *pstride_entry = findStride(stride);
if (pstride_entry == nullptr) {
@@ -76,18 +75,16 @@ SignaturePathPrefetcher::PatternEntry::getStrideEntry(stride_t stride,
// If all counters have the max value, this will be the pick
PatternStrideEntry *victim_pstride_entry = &(strideEntries[0]);
- uint8_t current_counter = max_counter_value;
+ unsigned long current_counter = ULONG_MAX;
for (auto &entry : strideEntries) {
if (entry.counter < current_counter) {
victim_pstride_entry = &entry;
current_counter = entry.counter;
}
- if (entry.counter > 0) {
- entry.counter -= 1;
- }
+ entry.counter--;
}
pstride_entry = victim_pstride_entry;
- pstride_entry->counter = 0;
+ pstride_entry->counter.reset();
pstride_entry->stride = stride;
}
return *pstride_entry;
@@ -147,9 +144,7 @@ void
SignaturePathPrefetcher::increasePatternEntryCounter(
PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry)
{
- if (pstride_entry.counter < maxCounterValue) {
- pstride_entry.counter += 1;
- }
+ pstride_entry.counter++;
}
void
@@ -158,8 +153,7 @@ SignaturePathPrefetcher::updatePatternTable(Addr signature, stride_t stride)
assert(stride != 0);
// The pattern table is indexed by signatures
PatternEntry &p_entry = getPatternEntry(signature);
- PatternStrideEntry &ps_entry = p_entry.getStrideEntry(stride,
- maxCounterValue);
+ PatternStrideEntry &ps_entry = p_entry.getStrideEntry(stride);
increasePatternEntryCounter(p_entry, ps_entry);
}
@@ -209,23 +203,21 @@ double
SignaturePathPrefetcher::calculatePrefetchConfidence(PatternEntry const &sig,
PatternStrideEntry const &entry) const
{
- return ((double) entry.counter) / maxCounterValue;
+ return entry.counter.calcSaturation();
}
double
SignaturePathPrefetcher::calculateLookaheadConfidence(PatternEntry const &sig,
PatternStrideEntry const &lookahead) const
{
- double lookahead_confidence;
- if (lookahead.counter == maxCounterValue) {
+ double lookahead_confidence = lookahead.counter.calcSaturation();
+ if (lookahead_confidence > 0.95) {
/**
* 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;
}
@@ -280,7 +272,7 @@ SignaturePathPrefetcher::calculatePrefetch(const PrefetchInfo &pfi,
patternTable.findEntry(current_signature, false);
PatternStrideEntry const *lookahead = nullptr;
if (current_pattern_entry != nullptr) {
- uint8_t max_counter = 0;
+ unsigned long max_counter = 0;
for (auto const &entry : current_pattern_entry->strideEntries) {
//select the entry with the maximum counter value as lookahead
if (max_counter < entry.counter) {