52#include "params/BasePrefetcher.hh"
67 unsigned int req_size = pkt->
req->getSize();
71 data = new uint8_t[req_size];
72 Addr offset = pkt->req->getPaddr() - pkt->getAddr();
73 std::memcpy(data, &(pkt->getConstPtr<uint8_t>()[offset]), req_size);
131 "demands not covered by prefetchs"),
133 "number of hwpf issued"),
135 "number of HardPF blocks evicted w/o reference"),
137 "number of useful prefetch"),
139 "number of hit on prefetch but cache block is not in an usable "
142 "accuracy of the prefetcher"),
144 "coverage brought by this prefetcher"),
146 "number of prefetches hitting in cache"),
148 "number of prefetches hitting in a MSHR"),
150 "number of prefetches hit in the Write Buffer"),
152 "number of late prefetches (hitting in cache, MSHR or WB)")
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 *
this,
"Miss",
false,
true));
283 *
this,
"Fill",
true,
false));
285 *
this,
"Hit",
false,
false));
287 *
this,
"Data Update"));
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.
ClockedObject(const ClockedObjectParams &p)
bool isSWPrefetch() const
virtual std::string name() const
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.
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...
ProbeListenerPtr< Listener > connect(Args &&...args)
void notify(const EvictionInfo &info) override
Class containing the information needed by the prefetch to train and generate new prefetch requests.
bool validPC
Validity bit for the PC of this address.
PrefetchInfo(PacketPtr pkt, Addr addr, bool miss)
Constructs a PrefetchInfo using a PacketPtr.
Addr getPC() const
Returns the program counter that generated this request.
bool isSecure() const
Returns true if the address targets the secure memory space.
unsigned int getSize() const
Gets the size of the request triggering this event.
Addr getPaddr() const
Gets the physical address of the request.
bool write
Whether this event comes from a write request.
bool isWrite() const
Checks if the request that caused this prefetch event was a write request.
RequestorID requestorId
The requestor ID that generated this address.
Addr address
The address used to train and generate prefetches.
bool cacheMiss
Whether this event comes from a cache miss.
Addr paddress
Physical address, needed because address can be virtual.
bool hasPC() const
Returns true if the associated program counter is valid.
Addr pc
The program counter that generated this address.
unsigned int size
Size in bytes of the request triggering this event.
uint8_t * data
Pointer to the associated request data.
bool secure
Whether this address targets the secure memory space.
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.
void addEventProbe(SimObject *obj, const char *name)
Add a SimObject and a probe name to listen events from.
std::vector< ProbeListenerPtr<> > listeners
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....
CacheDataUpdateProbeArg EvictionInfo
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.
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.
#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...
SimObject(const Params &p)
ProbeManager * getProbeManager()
Get the probe manager for this object.
Declares a basic cache interface BaseCache.
Miss and writeback queue declarations.
const FlagsType nozero
Don't print if this is zero.
const FlagsType total
Print the total.
Copyright (c) 2024 Arm Limited 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.
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