Majid Jalili has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/56265 )

Change subject: mem-cache: adding round-robin aribitration to multiprefetchers
......................................................................

mem-cache: adding round-robin aribitration to multiprefetchers

To find a candidate in cache base.cc, function getPacket
is called. In case of multi-prefetchers, we alyways start
from the first prefetcher. Given the default value for "latency"
is 1, there is always a candidate ready for prefech by prefetcher 0.
Hence, we need an arbitration mechansim to cycle through
all prefechers. To make this fair, we added a variable to save what
prefetcher first used to get a packet from, and in the next round,
 we start from the next prefetcher to give every prefetcher a chance
to be the first one in a round-robin fashion.

JIRA Ticket: https://gem5.atlassian.net/browse/GEM5-1169

Change-Id: I1c6a267b2bf71764559a080371c1d7f8be95ac71
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56265
Reviewed-by: Daniel Carvalho <oda...@yahoo.com.br>
Maintainer: Daniel Carvalho <oda...@yahoo.com.br>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/mem/cache/prefetch/multi.cc
M src/mem/cache/prefetch/multi.hh
2 files changed, 38 insertions(+), 5 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/mem/cache/prefetch/multi.cc b/src/mem/cache/prefetch/multi.cc
index 230db50..ddf0e30 100644
--- a/src/mem/cache/prefetch/multi.cc
+++ b/src/mem/cache/prefetch/multi.cc
@@ -48,7 +48,8 @@

 Multi::Multi(const MultiPrefetcherParams &p)
   : Base(p),
-    prefetchers(p.prefetchers.begin(), p.prefetchers.end())
+    prefetchers(p.prefetchers.begin(), p.prefetchers.end()),
+    lastChosenPf(0)
 {
 }

@@ -73,14 +74,18 @@
 PacketPtr
 Multi::getPacket()
 {
-    for (auto pf : prefetchers) {
-        if (pf->nextPrefetchReadyTime() <= curTick()) {
-            PacketPtr pkt = pf->getPacket();
+    lastChosenPf = (lastChosenPf + 1) % prefetchers.size();
+    uint8_t pf_turn = lastChosenPf;
+
+    for (int pf = 0 ;  pf < prefetchers.size(); pf++) {
+        if (prefetchers[pf_turn]->nextPrefetchReadyTime() <= curTick()) {
+            PacketPtr pkt = prefetchers[pf_turn]->getPacket();
panic_if(!pkt, "Prefetcher is ready but didn't return a packet.");
             prefetchStats.pfIssued++;
             issuedPrefetches++;
             return pkt;
         }
+        pf_turn = (pf_turn + 1) % prefetchers.size();
     }

     return nullptr;
diff --git a/src/mem/cache/prefetch/multi.hh b/src/mem/cache/prefetch/multi.hh
index 037d23e..ff17918 100644
--- a/src/mem/cache/prefetch/multi.hh
+++ b/src/mem/cache/prefetch/multi.hh
@@ -38,6 +38,8 @@
 #ifndef __MEM_CACHE_PREFETCH_MULTI_HH__
 #define __MEM_CACHE_PREFETCH_MULTI_HH__

+#include <vector>
+
 #include "mem/cache/prefetch/base.hh"

 namespace gem5
@@ -70,7 +72,8 @@

   protected:
     /** List of sub-prefetchers ordered by priority. */
-    std::list<Base*> prefetchers;
+    std::vector<Base*> prefetchers;
+    uint8_t lastChosenPf;
 };

 } // namespace prefetch

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/56265
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I1c6a267b2bf71764559a080371c1d7f8be95ac71
Gerrit-Change-Number: 56265
Gerrit-PatchSet: 5
Gerrit-Owner: Majid Jalili <majid0jal...@gmail.com>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Majid Jalili <majid0jal...@gmail.com>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to