Javier Bueno Hedo has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/18808
Change subject: mem-cache: Accuracy-based rate control for prefetchers
......................................................................
mem-cache: Accuracy-based rate control for prefetchers
Added a mechanism to control the number of prefetches generated
based in the effectiveness of the prefetches generated so far.
Change-Id: I33af82546f74a5b5ab372c28574b76dd9a1bd46a
---
M src/mem/cache/prefetch/Prefetcher.py
M src/mem/cache/prefetch/queued.cc
M src/mem/cache/prefetch/queued.hh
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/src/mem/cache/prefetch/Prefetcher.py
b/src/mem/cache/prefetch/Prefetcher.py
index a45f662..304419e 100644
--- a/src/mem/cache/prefetch/Prefetcher.py
+++ b/src/mem/cache/prefetch/Prefetcher.py
@@ -122,6 +122,8 @@
cache_snoop = Param.Bool(False, "Snoop cache to eliminate redundant
request")
tag_prefetch = Param.Bool(True, "Tag prefetch with PC of generating
access")
+ throttle_control_percentage = Param.Unsigned(0, "Percentage of
requests \
+ that can be throttled depending on the accuracy of the
prefetcher.")
class StridePrefetcher(QueuedPrefetcher):
type = 'StridePrefetcher'
diff --git a/src/mem/cache/prefetch/queued.cc
b/src/mem/cache/prefetch/queued.cc
index 12f4a36..c4dd0e1 100644
--- a/src/mem/cache/prefetch/queued.cc
+++ b/src/mem/cache/prefetch/queued.cc
@@ -96,8 +96,11 @@
p->max_prefetch_requests_with_pending_translation),
latency(p->latency), queueSquash(p->queue_squash),
queueFilter(p->queue_filter), cacheSnoop(p->cache_snoop),
- tagPrefetch(p->tag_prefetch)
+ tagPrefetch(p->tag_prefetch),
+ throttleControlPct(p->throttle_control_percentage)
{
+ fatal_if(throttleControlPct > 100,
+ "throttleControlPct must be a value between 0 and 100.");
}
QueuedPrefetcher::~QueuedPrefetcher()
@@ -132,7 +135,31 @@
std::vector<AddrPriority> addresses;
calculatePrefetch(pfi, addresses);
+ /**
+ * Throttle generated prefetches based in the accuracy of the
prefetcher.
+ * Accuracy is computed based in the ratio of useful prefetches with
+ * respect to the number of issued prefetches.
+ *
+ * The throttleControlPct controls how many of the generated addresses
will
+ * be controled by the throttle control algorithm:
+ * - If set to 100, all requests can potentially be throttle (one
request
+ * will always be allowed to be generated)
+ * - Setting it to 0 will disable the throttle control
+ * - If set to 60, 40% of requests will be generated, and the remaining
+ * 60% will be generated depending on the mentioned accuracy
+ */
+
+ size_t max_pfs = addresses.size();
+ if (addresses.size() > 0 && issuedPrefetches > 0) {
+ size_t throttle_pfs = (addresses.size() * throttleControlPct) /
100;
+ size_t min_pfs = (addresses.size() - throttle_pfs) == 0 ?
+ 1 : (addresses.size() - throttle_pfs);
+ max_pfs = min_pfs + (addresses.size() - min_pfs) *
+ usefulPrefetches / issuedPrefetches;
+ }
+
// Queue up generated prefetches
+ size_t num_pfs = 0;
for (AddrPriority& addr_prio : addresses) {
// Block align prefetch address
@@ -150,6 +177,10 @@
"inserting into prefetch queue.\n", new_pfi.getAddr());
// Create and insert the request
insert(pkt, new_pfi, addr_prio.second);
+ num_pfs += 1;
+ if (num_pfs == max_pfs) {
+ break;
+ }
} else {
DPRINTF(HWPrefetch, "Ignoring page crossing prefetch.\n");
}
diff --git a/src/mem/cache/prefetch/queued.hh
b/src/mem/cache/prefetch/queued.hh
index 1ffbc9a..5e56d2c 100644
--- a/src/mem/cache/prefetch/queued.hh
+++ b/src/mem/cache/prefetch/queued.hh
@@ -163,6 +163,9 @@
/** Tag prefetch with PC of generating access? */
const bool tagPrefetch;
+ /** Percentage of requests that can be throttled */
+ const unsigned int throttleControlPct;
+
// STATS
Stats::Scalar pfIdentified;
Stats::Scalar pfBufferHit;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18808
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I33af82546f74a5b5ab372c28574b76dd9a1bd46a
Gerrit-Change-Number: 18808
Gerrit-PatchSet: 1
Gerrit-Owner: Javier Bueno Hedo <javier.bu...@metempsy.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev