From a3bf4aa6ec9caa68a558f7347d55991f7a254fa5 Mon Sep 17 00:00:00 2001 From: Rekai Gonzalez Alberquilla Date: Wed, 27 May 2015 13:50:01 +0100 Subject: [PATCH] mem: Add unused prefetch counter in caches Added stat to the cache to account for HardPF'ed blocks that are evicted before being referenced (over-prefetching). --- src/mem/cache/base.cc | 6 ++++++ src/mem/cache/base.hh | 3 +++ src/mem/cache/cache.cc | 3 +++ 3 files changed, 12 insertions(+) diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc index ecbd3526e..3ae52cebd 100644 --- a/src/mem/cache/base.cc +++ b/src/mem/cache/base.cc @@ -444,6 +444,12 @@ BaseCache::regStats() .desc("number of cache copies performed") ; + unusedPrefetches + .name(name() + ".unused_prefetches") + .desc("number of HardPF blocks evicted w/o reference") + .flags(nozero) + ; + writebacks .init(system->maxMasters()) .name(name() + ".writebacks") diff --git a/src/mem/cache/base.hh b/src/mem/cache/base.hh index cd21bce91..9275eb453 100644 --- a/src/mem/cache/base.hh +++ b/src/mem/cache/base.hh @@ -387,6 +387,9 @@ class BaseCache : public MemObject /** The number of cache copies performed. */ Stats::Scalar cacheCopies; + /** The number of times a HW-prefetched block is evicted w/o reference. */ + Stats::Scalar unusedPrefetches; + /** Number of blocks written back per thread. */ Stats::Vector writebacks; diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc index 267497aca..5d5760ff3 100644 --- a/src/mem/cache/cache.cc +++ b/src/mem/cache/cache.cc @@ -1709,6 +1709,9 @@ Cache::allocateBlock(Addr addr, bool is_secure, PacketList &writebacks) addr, is_secure ? "s" : "ns", blk->isDirty() ? "writeback" : "clean"); + if (blk->wasPrefetched()) { + unusedPrefetches++; + } // Will send up Writeback/CleanEvict snoops via isCachedAbove // when pushing this writeback list into the write buffer. if (blk->isDirty() || writebackClean) { -- 2.30.2