52#include "params/BasePrefetcher.hh"
62 : address(
addr),
pc(pkt->req->hasPC() ? pkt->req->getPC() : 0),
63 requestorId(pkt->req->requestorId()), validPC(pkt->req->hasPC()),
64 secure(pkt->
isSecure()), size(pkt->req->getSize()), write(pkt->isWrite()),
65 paddress(pkt->req->getPaddr()), cacheMiss(miss)
67 unsigned int req_size = pkt->
req->getSize();
71 data =
new uint8_t[req_size];
79 validPC(pfi.validPC), secure(pfi.secure), size(pfi.size),
80 write(pfi.write), paddress(pfi.paddress), cacheMiss(pfi.cacheMiss),
89 parent.notifyFill(arg);
91 parent.probeNotify(arg, miss);
99 parent.notifyEvict(info);
129 : statistics::
Group(parent),
130 ADD_STAT(demandMshrMisses, statistics::units::Count::get(),
131 "demands not covered by prefetchs"),
132 ADD_STAT(pfIssued, statistics::units::Count::get(),
133 "number of hwpf issued"),
134 ADD_STAT(pfUnused, statistics::units::Count::get(),
135 "number of HardPF blocks evicted w/o reference"),
136 ADD_STAT(pfUseful, statistics::units::Count::get(),
137 "number of useful prefetch"),
138 ADD_STAT(pfUsefulButMiss, statistics::units::Count::get(),
139 "number of hit on prefetch but cache block is not in an usable "
141 ADD_STAT(accuracy, statistics::units::Count::get(),
142 "accuracy of the prefetcher"),
143 ADD_STAT(coverage, statistics::units::Count::get(),
144 "coverage brought by this prefetcher"),
145 ADD_STAT(pfHitInCache, statistics::units::Count::get(),
146 "number of prefetches hitting in cache"),
147 ADD_STAT(pfHitInMSHR, statistics::units::Count::get(),
148 "number of prefetches hitting in a MSHR"),
149 ADD_STAT(pfHitInWB, statistics::units::Count::get(),
150 "number of prefetches hit in the Write Buffer"),
151 ADD_STAT(pfLate, statistics::units::Count::get(),
152 "number of late prefetches (hitting in cache, MSHR or WB)")
154 using namespace statistics;
170 bool fetch = pkt->
req->isInstFetch();
171 bool read = pkt->
isRead();
180 if (pkt->
req->isUncacheable())
return false;
181 if (fetch && !
onInst)
return false;
182 if (!fetch && !
onData)
return false;
183 if (!fetch && read && !
onRead)
return false;
184 if (!fetch && !read && !
onWrite)
return false;
185 if (!fetch && !read &&
inv)
return false;
240 if (pkt->
req->isCacheMaintenance())
return;
243 if (!pkt->
req->hasPaddr()) {
244 panic(
"Request must have a physical address");
247 bool has_been_prefetched =
250 if (has_been_prefetched) {
281 "Miss",
false,
true));
283 "Fill",
true,
false));
285 "Hit",
false,
false));
301 fatal_if(
mmu !=
nullptr,
"Only one MMU can be registered");
Information provided to probes on a cache event.
PacketPtr pkt
Packet that triggered the cache access.
CacheAccessor & cache
Accessor for the cache.
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
bool isSWPrefetch() const
virtual std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
bool isCleanEviction() const
Is this packet a clean eviction, including both actual clean evict packets, but also clean writebacks...
RequestPtr req
A pointer to the original request.
const T * getConstPtr() const
MemCmd cmd
The command field of the packet.
bool isInvalidate() const
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Abstract superclass for simulation objects.
void notify(const EvictionInfo &info) override
Class containing the information needed by the prefetch to train and generate new prefetch requests.
PrefetchInfo(PacketPtr pkt, Addr addr, bool miss)
Constructs a PrefetchInfo using a PacketPtr.
bool write
Whether this event comes from a write request.
uint8_t * data
Pointer to the associated request data.
void notify(const CacheAccessProbeArg &arg) override
Base(const BasePrefetcherParams &p)
const bool useVirtualAddresses
Use Virtual Addresses for prefetching.
const bool prefetchOnAccess
Prefetch on every access, not just misses.
const bool onRead
Consult prefetcher on reads?
unsigned blkSize
The block size of the parent cache.
uint64_t issuedPrefetches
Total prefetches issued.
const RequestorID requestorId
Request id for prefetches.
void addMMU(BaseMMU *mmu)
Add a BaseMMU object to be used whenever a translation is needed.
void regProbeListeners() override
Register probe points for this object.
Addr pageAddress(Addr a) const
Determine the address of the page in which a lays.
ProbeManager * probeManager
Pointer to the parent cache's probe manager.
const bool onInst
Consult prefetcher on instruction accesses?
uint64_t usefulPrefetches
Total prefetches that has been useful.
gem5::prefetch::Base::StatGroup prefetchStats
virtual void setParentInfo(System *sys, ProbeManager *pm, unsigned blk_size)
virtual void notify(const CacheAccessProbeArg &acc, const PrefetchInfo &pfi)=0
Notify prefetcher of cache access (may be any access or just misses, depending on cache parameters....
Addr pageIthBlockAddress(Addr page, uint32_t i) const
Build the address of the i-th block inside the page.
Addr pageOffset(Addr a) const
Determine the page-offset of a
std::vector< ProbeListener * > listeners
BaseMMU * mmu
Registered mmu for address translations.
const bool onData
Consult prefetcher on data accesses?
const bool prefetchOnPfHit
Prefetch on hit on prefetched lines.
System * system
Pointer to the parent system.
const bool onWrite
Consult prefetcher on reads?
unsigned lBlkSize
log_2(block size of the parent cache).
bool observeAccess(const PacketPtr &pkt, bool miss, bool prefetched) const
Determine if this access should be observed.
Addr blockIndex(Addr a) const
Determine the address of a at block granularity.
Addr blockAddress(Addr a) const
Determine the address of the block in which a lays.
void probeNotify(const CacheAccessProbeArg &acc, bool miss)
Process a notification event from the ProbeListener.
const bool onMiss
Only consult prefetcher on cache misses?
bool samePage(Addr a, Addr b) const
Determine if addresses are on the same page.
void addEventProbe(SimObject *obj, const char *name)
Add a SimObject and a probe name to listen events from.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
static constexpr T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
#define panic(...)
This implements a cprintf based panic() function.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
ProbeManager * getProbeManager()
Get the probe manager for this object.
Declares a basic cache interface BaseCache.
Miss and writeback queue declarations.
bool isSecure(ThreadContext *tc)
const FlagsType nozero
Don't print if this is zero.
const FlagsType total
Print the total.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Provides generic cache lookup functions.
virtual bool coalesce() const =0
Determine if cache is coalescing writes.
virtual bool hasBeenPrefetched(Addr addr, bool is_secure) const =0
Determine if address has been prefetched.
A data contents update is composed of the updated block's address, the old contents,...
std::vector< uint64_t > newData
The new data contents.
statistics::Formula accuracy
statistics::Scalar pfUsefulButMiss
The number of times there is a hit on prefetch but cache block is not in an usable state.
statistics::Scalar pfIssued
statistics::Scalar pfUseful
The number of times a HW-prefetch is useful.
statistics::Scalar pfHitInWB
The number of times a HW-prefetch hits in the Write Buffer (WB).
statistics::Scalar pfHitInMSHR
The number of times a HW-prefetch hits in a MSHR.
statistics::Formula pfLate
The number of times a HW-prefetch is late (hit in cache, MSHR, WB).
statistics::Scalar pfUnused
The number of times a HW-prefetched block is evicted w/o reference.
statistics::Scalar pfHitInCache
The number of times a HW-prefetch hits in cache.
statistics::Scalar demandMshrMisses
StatGroup(statistics::Group *parent)
statistics::Formula coverage