Huang Jiasen has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/54163 )
Change subject: mem-cache: Added Prefetch stats that is useful and span
pages simultaneously
......................................................................
mem-cache: Added Prefetch stats that is useful and span pages simultaneously
Change-Id: I2570ee47f064ac999f2dcc813c9e39174a2ad8af
---
M src/mem/cache/prefetch/base.cc
M src/mem/cache/prefetch/base.hh
M src/mem/cache/prefetch/multi.hh
M src/mem/cache/prefetch/queued.cc
M src/mem/cache/prefetch/queued.hh
5 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/src/mem/cache/prefetch/base.cc b/src/mem/cache/prefetch/base.cc
index cb4c1e8..68e6052 100644
--- a/src/mem/cache/prefetch/base.cc
+++ b/src/mem/cache/prefetch/base.cc
@@ -48,6 +48,8 @@
#include <cassert>
#include "base/intmath.hh"
+#include "cpu/base.hh"
+#include "debug/HWPrefetch.hh"
#include "mem/cache/base.hh"
#include "params/BasePrefetcher.hh"
#include "sim/system.hh"
@@ -251,9 +253,12 @@
panic("Request must have a physical address");
}
+ bool pf_useful = false;
+
if (hasBeenPrefetched(pkt->getAddr(), pkt->isSecure())) {
usefulPrefetches += 1;
prefetchStats.pfUseful++;
+ pf_useful = true;
if (miss)
// This case happens when a demand hits on a prefetched line
// that's not in the requested coherency state.
@@ -265,9 +270,17 @@
if (useVirtualAddresses && pkt->req->hasVaddr()) {
PrefetchInfo pfi(pkt, pkt->req->getVaddr(), miss);
notify(pkt, pfi);
+ pfi.setUseFul(pf_useful);
+ if (pfi.isUseFul() && pfi.isSpanPage()) {
+ prefetchStats.pfUsefulSpanPage++;
+ }
} else if (!useVirtualAddresses) {
PrefetchInfo pfi(pkt, pkt->req->getPaddr(), miss);
notify(pkt, pfi);
+ pfi.setUseFul(pf_useful);
+ if (pfi.isUseFul() && pfi.isSpanPage()) {
+ prefetchStats.pfUsefulSpanPage++;
+ }
}
}
}
diff --git a/src/mem/cache/prefetch/base.hh b/src/mem/cache/prefetch/base.hh
index f2a8207..ca316fd 100644
--- a/src/mem/cache/prefetch/base.hh
+++ b/src/mem/cache/prefetch/base.hh
@@ -64,6 +64,7 @@
class BaseCache;
struct BasePrefetcherParams;
+class Queued;
GEM5_DEPRECATED_NAMESPACE(Prefetcher, prefetch);
namespace prefetch
@@ -116,9 +117,40 @@
bool cacheMiss;
/** Pointer to the associated request data */
uint8_t *data;
+ /** Whether this prefetch is useful */
+ bool useful;
+ /** Whether this prefetch span pages */
+ bool spanPage;
+
+ protected:
+ friend class Base;
+ friend class Queued;
+ void setUseFul(const bool& pf_useful) {
+ useful = pf_useful;
+ }
+ void setSpanPage() {
+ spanPage = true;
+ }
public:
/**
+ * Returns true if this prefetch is useful
+ * @return true if this prefetch is useful
+ */
+ bool isUseFul() const
+ {
+ return useful;
+ }
+ /**
+ * Returns true if this prefetch spans pages
+ * @return true if this prefetch spans pages
+ */
+ bool isSpanPage() const
+ {
+ return spanPage;
+ }
+
+ /**
* Obtains the address value of this Prefetcher address.
* @return the addres value.
*/
@@ -338,6 +370,8 @@
statistics::Scalar pfUnused;
/** The number of times a HW-prefetch is useful. */
statistics::Scalar pfUseful;
+ /** The number of times a HW-prefetch is useful and spanPage. */
+ Stats::Scalar pfUsefulSpanPage;
/** The number of times there is a hit on prefetch but cache block
* is not in an usable state */
statistics::Scalar pfUsefulButMiss;
@@ -377,7 +411,7 @@
* Notify prefetcher of cache access (may be any access or just
* misses, depending on cache parameters.)
*/
- virtual void notify(const PacketPtr &pkt, const PrefetchInfo &pfi) = 0;
+ virtual void notify(const PacketPtr &pkt, PrefetchInfo &pfi) = 0;
/** Notify prefetcher of cache fill */
virtual void notifyFill(const PacketPtr &pkt)
diff --git a/src/mem/cache/prefetch/multi.hh
b/src/mem/cache/prefetch/multi.hh
index 037d23e..b187aef 100644
--- a/src/mem/cache/prefetch/multi.hh
+++ b/src/mem/cache/prefetch/multi.hh
@@ -64,7 +64,7 @@
* Ignore notifications since each sub-prefetcher already gets a
* notification through their probes-based interface.
*/
- void notify(const PacketPtr &pkt, const PrefetchInfo &pfi) override {};
+ void notify(const PacketPtr &pkt, PrefetchInfo &pfi) override {};
void notifyFill(const PacketPtr &pkt) override {};
/** @} */
diff --git a/src/mem/cache/prefetch/queued.cc
b/src/mem/cache/prefetch/queued.cc
index 597c88a..6d75cc5 100644
--- a/src/mem/cache/prefetch/queued.cc
+++ b/src/mem/cache/prefetch/queued.cc
@@ -170,7 +170,7 @@
}
void
-Queued::notify(const PacketPtr &pkt, const PrefetchInfo &pfi)
+Queued::notify(const PacketPtr &pkt, PrefetchInfo &pfi)
{
Addr blk_addr = blockAddress(pfi.getAddr());
bool is_secure = pfi.isSecure();
@@ -210,6 +210,7 @@
if (!samePage(addr_prio.first, pfi.getAddr())) {
statsQueued.pfSpanPage += 1;
+ pfi.setSpanPage();
}
bool can_cross_page = (tlb != nullptr);
diff --git a/src/mem/cache/prefetch/queued.hh
b/src/mem/cache/prefetch/queued.hh
index 1062630..9405469 100644
--- a/src/mem/cache/prefetch/queued.hh
+++ b/src/mem/cache/prefetch/queued.hh
@@ -192,7 +192,7 @@
Queued(const QueuedPrefetcherParams &p);
virtual ~Queued();
- void notify(const PacketPtr &pkt, const PrefetchInfo &pfi) override;
+ void notify(const PacketPtr &pkt, PrefetchInfo &pfi) override;
void insert(const PacketPtr &pkt, PrefetchInfo &new_pfi, int32_t
priority);
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/54163
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: I2570ee47f064ac999f2dcc813c9e39174a2ad8af
Gerrit-Change-Number: 54163
Gerrit-PatchSet: 1
Gerrit-Owner: Huang Jiasen <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s