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 <odanrc@yahoo.com.br>
Maintainer: Daniel Carvalho <odanrc@yahoo.com.br>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Majid Jalili
2022-02-01 16:30:29 +00:00
parent c6df79628c
commit 714b9b2356
2 changed files with 13 additions and 5 deletions

View File

@@ -48,7 +48,8 @@ namespace prefetch
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 @@ Multi::nextPrefetchReadyTime() const
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;

View File

@@ -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 @@ class Multi : public Base
protected:
/** List of sub-prefetchers ordered by priority. */
std::list<Base*> prefetchers;
std::vector<Base*> prefetchers;
uint8_t lastChosenPf;
};
} // namespace prefetch