From 96317d466ea26955ce26f658f162755b39d3352e Mon Sep 17 00:00:00 2001 From: Mitch Hayenga Date: Wed, 29 Jan 2014 23:21:26 -0600 Subject: [PATCH] mem: Add additional tolerance to stride prefetcher Forces the prefetcher to mispredict twice in a row before resetting the confidence of prefetching. This helps cases where a load PC strides by a constant factor, however it may operate on different arrays at times. Avoids the cost of retraining. Primarily helps with small iteration loops. Committed by: Nilay Vaish --- src/mem/cache/prefetch/stride.cc | 14 ++++++++++---- src/mem/cache/prefetch/stride.hh | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mem/cache/prefetch/stride.cc b/src/mem/cache/prefetch/stride.cc index c4cf2023a..d4a31f9da 100644 --- a/src/mem/cache/prefetch/stride.cc +++ b/src/mem/cache/prefetch/stride.cc @@ -98,12 +98,17 @@ StridePrefetcher::calculatePrefetch(PacketPtr &pkt, std::list &addresses, bool stride_match = (new_stride == (*iter)->stride); if (stride_match && new_stride != 0) { + (*iter)->tolerance = true; if ((*iter)->confidence < Max_Conf) (*iter)->confidence++; } else { - (*iter)->stride = new_stride; - if ((*iter)->confidence > Min_Conf) - (*iter)->confidence = 0; + if (!((*iter)->tolerance)) { + (*iter)->stride = new_stride; + if ((*iter)->confidence > Min_Conf) + (*iter)->confidence = 0; + } else { + (*iter)->tolerance = false; + } } DPRINTF(HWPrefetch, "hit: PC %x data_addr %x (%s) stride %d (%s), " @@ -118,7 +123,7 @@ StridePrefetcher::calculatePrefetch(PacketPtr &pkt, std::list &addresses, return; for (int d = 1; d <= degree; d++) { - Addr new_addr = data_addr + d * new_stride; + Addr new_addr = data_addr + d * (*iter)->stride; if (pageStop && !samePage(data_addr, new_addr)) { // Spanned the page, so now stop pfSpanPage += degree - d + 1; @@ -160,6 +165,7 @@ StridePrefetcher::calculatePrefetch(PacketPtr &pkt, std::list &addresses, new_entry->isSecure = is_secure; new_entry->stride = 0; new_entry->confidence = 0; + new_entry->tolerance = false; tab.push_back(new_entry); } } diff --git a/src/mem/cache/prefetch/stride.hh b/src/mem/cache/prefetch/stride.hh index 0e31984f9..a491eb687 100644 --- a/src/mem/cache/prefetch/stride.hh +++ b/src/mem/cache/prefetch/stride.hh @@ -72,6 +72,7 @@ class StridePrefetcher : public BasePrefetcher bool isSecure; int stride; int confidence; + bool tolerance; }; std::list table[Max_Contexts];