diff options
Diffstat (limited to 'src/mem/cache/prefetch/queued.cc')
-rw-r--r-- | src/mem/cache/prefetch/queued.cc | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/mem/cache/prefetch/queued.cc b/src/mem/cache/prefetch/queued.cc index 12f4a3601..94df66621 100644 --- a/src/mem/cache/prefetch/queued.cc +++ b/src/mem/cache/prefetch/queued.cc @@ -96,7 +96,8 @@ QueuedPrefetcher::QueuedPrefetcher(const QueuedPrefetcherParams *p) 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) { } @@ -108,6 +109,36 @@ QueuedPrefetcher::~QueuedPrefetcher() } } +size_t +QueuedPrefetcher::getMaxPermittedPrefetches(size_t total) const +{ + /** + * 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 candidate addresses + * generated by the prefetcher will be finally turned into prefetch + * requests + * - If set to 100, all candidates can be discarded (one request + * will always be allowed to be generated) + * - Setting it to 0 will disable the throttle control, so requests are + * created for all candidates + * - If set to 60, 40% of candidates will generate a request, and the + * remaining 60% will be generated depending on the current accuracy + */ + + size_t max_pfs = total; + if (total > 0 && issuedPrefetches > 0) { + size_t throttle_pfs = (total * throttleControlPct) / 100; + size_t min_pfs = (total - throttle_pfs) == 0 ? + 1 : (total - throttle_pfs); + max_pfs = min_pfs + (total - min_pfs) * + usefulPrefetches / issuedPrefetches; + } + return max_pfs; +} + void QueuedPrefetcher::notify(const PacketPtr &pkt, const PrefetchInfo &pfi) { @@ -132,7 +163,11 @@ QueuedPrefetcher::notify(const PacketPtr &pkt, const PrefetchInfo &pfi) std::vector<AddrPriority> addresses; calculatePrefetch(pfi, addresses); + // Get the maximu number of prefetches that we are allowed to generate + size_t max_pfs = getMaxPermittedPrefetches(addresses.size()); + // Queue up generated prefetches + size_t num_pfs = 0; for (AddrPriority& addr_prio : addresses) { // Block align prefetch address @@ -150,6 +185,10 @@ QueuedPrefetcher::notify(const PacketPtr &pkt, const PrefetchInfo &pfi) "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"); } |