mem-cache: accuracy and coverage stat for prefetchers

Add an accuracy and coverage stat for the prefetchers.
Accuracy is defined as the ratio of the number of prefetch
request that have been counted as useful over the number
of prefetch request issued.
Accuracy tells whether the prefetcher is producing useful
requests or not.
Coverage is defined as the ratio of of the number of prefetch
request that have been counted as useful over the number of
demand misses if there was no prefetch, which is counted as
the number of useful prefetch request plus the remaining
demand misses. Due to the way stats are defined in the cache,
I have to add a stat to count the number of remaining demand
misses directly in the prefetcher stat. Demand is defined
as being one of this request type: ReadReq, WriteReq,
WriteLineReq, ReadExReq, ReadCleanReq, ReadSharedReq.
Coverage tells what part of misses are covered by the prefetcher.

Change-Id: I3bb8838f87b42665fdd782889f6ba56ca2a802fc
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47603
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:
Nathanael Premillieu
2021-06-30 15:04:04 +02:00
parent c66f32f24e
commit 352ae672e2
4 changed files with 36 additions and 3 deletions

View File

@@ -308,6 +308,8 @@ BaseCache::handleTimingReqMiss(PacketPtr pkt, MSHR *mshr, CacheBlk *blk,
// no MSHR
assert(pkt->req->requestorId() < system->maxRequestors());
stats.cmdStats(pkt).mshrMisses[pkt->req->requestorId()]++;
if (prefetcher && pkt->isDemand())
prefetcher->incrDemandMhsrMisses();
if (pkt->isEviction() || pkt->cmd == MemCmd::WriteClean) {
// We use forward_time here because there is an

View File

@@ -119,6 +119,8 @@ Base::setCache(BaseCache *_cache)
Base::StatGroup::StatGroup(statistics::Group *parent)
: statistics::Group(parent),
ADD_STAT(demandMshrMisses, statistics::units::Count::get(),
"demands not covered by prefetchs"),
ADD_STAT(pfIssued, statistics::units::Count::get(),
"number of hwpf issued"),
ADD_STAT(pfUnused, statistics::units::Count::get(),
@@ -127,11 +129,22 @@ Base::StatGroup::StatGroup(statistics::Group *parent)
"number of useful prefetch"),
ADD_STAT(pfUsefulButMiss, statistics::units::Count::get(),
"number of hit on prefetch but cache block is not in an usable "
"state")
"state"),
ADD_STAT(accuracy, statistics::units::Count::get(),
"accuracy of the prefetcher"),
ADD_STAT(coverage, statistics::units::Count::get(),
"coverage brought by this prefetcher")
{
pfUnused.flags(statistics::nozero);
}
using namespace statistics;
pfUnused.flags(nozero);
accuracy.flags(total);
accuracy = pfUseful / pfIssued;
coverage.flags(total);
coverage = pfUseful / (pfUseful + demandMshrMisses);
}
bool
Base::observeAccess(const PacketPtr &pkt, bool miss) const

View File

@@ -328,6 +328,7 @@ class Base : public ClockedObject
struct StatGroup : public statistics::Group
{
StatGroup(statistics::Group *parent);
statistics::Scalar demandMshrMisses;
statistics::Scalar pfIssued;
/** The number of times a HW-prefetched block is evicted w/o
* reference. */
@@ -337,6 +338,8 @@ class Base : public ClockedObject
/** The number of times there is a hit on prefetch but cache block
* is not in an usable state */
statistics::Scalar pfUsefulButMiss;
statistics::Formula accuracy;
statistics::Formula coverage;
} prefetchStats;
/** Total prefetches issued */
@@ -373,6 +376,12 @@ class Base : public ClockedObject
prefetchStats.pfUnused++;
}
void
incrDemandMhsrMisses()
{
prefetchStats.demandMshrMisses++;
}
/**
* Register probe points for this object.
*/

View File

@@ -247,6 +247,14 @@ class MemCmd
bool isPrint() const { return testCmdAttrib(IsPrint); }
bool isFlush() const { return testCmdAttrib(IsFlush); }
bool
isDemand() const
{
return (cmd == ReadReq || cmd == WriteReq ||
cmd == WriteLineReq || cmd == ReadExReq ||
cmd == ReadCleanReq || cmd == ReadSharedReq);
}
Command
responseCommand() const
{
@@ -573,6 +581,7 @@ class Packet : public Printable
bool isRead() const { return cmd.isRead(); }
bool isWrite() const { return cmd.isWrite(); }
bool isDemand() const { return cmd.isDemand(); }
bool isUpgrade() const { return cmd.isUpgrade(); }
bool isRequest() const { return cmd.isRequest(); }
bool isResponse() const { return cmd.isResponse(); }