33#include "debug/HWPrefetch.hh"
35#include "params/PIFPrefetcher.hh"
45 precSize(
p.prec_spatial_region_bits),
46 succSize(
p.succ_spatial_region_bits),
47 maxCompactorEntries(
p.compactor_entries),
48 historyBuffer(
p.history_buffer_size),
49 index((
name() +
".PIFIndex").c_str(),
p.index_entries,
p.index_assoc,
50 p.index_replacement_policy,
51 p.index_indexing_policy),
52 streamAddressBuffer(
p.stream_address_buffer_entries),
58 unsigned int prec_size,
unsigned int succ_size)
61 prec.resize(prec_size,
false);
62 succ.resize(succ_size,
false);
67 unsigned int log_blk_size)
const
69 const Addr target_blk = target >> log_blk_size;
72 return target_blk > trigger_blk ?
73 target_blk - trigger_blk : trigger_blk - target_blk;
78 unsigned int log_blk_size,
bool update)
80 Addr blk_distance = distanceFromTrigger(
pc, log_blk_size);
83 (
succ.size() > blk_distance) : (prec.size() > blk_distance);
86 succ[blk_distance] =
true;
88 prec[blk_distance] =
true;
96 unsigned int log_blk_size)
const
98 Addr blk_distance = distanceFromTrigger(target, log_blk_size);
101 hit = blk_distance <
succ.size() &&
succ[blk_distance];
103 hit = blk_distance < prec.size() && prec[blk_distance];
120 for (
int i = prec.size()-1;
i >= 0;
i--) {
123 const Addr prec_addr = (trigger_blk - (
i+1)) << log_blk_size;
127 for (
int i = 0;
i <
succ.size();
i++) {
130 const Addr succ_addr = (trigger_blk + (
i+1)) << log_blk_size;
152 bool is_in_temporal_compactor =
false;
158 if (it->inSameSpatialRegion(
pc,
lBlkSize,
false)) {
161 is_in_temporal_compactor =
true;
175 if (!is_in_temporal_compactor) {
181 if (idx_entry !=
nullptr) {
182 index.accessEntry(idx_entry);
185 assert(idx_entry !=
nullptr);
188 idx_entry->historyIt =
214 sabEntry->getPredictedAddresses(
lBlkSize, addresses);
224 if (idx_entry !=
nullptr) {
225 index.accessEntry(idx_entry);
233 entry->getPredictedAddresses(
lBlkSize, addresses);
240 parent.notifyRetiredInst(
pc);
iterator getIterator(size_t idx)
Return an iterator to an index in the queue.
void update() const
Align cycle and tick to the next clock edge if not already done.
virtual std::string name() const
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Abstract superclass for simulation objects.
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Addr getPC() const
Returns the program counter that generated this request.
bool hasPC() const
Returns true if the associated program counter is valid.
unsigned lBlkSize
log_2(block size of the parent cache).
Probe Listener to handle probe events from the CPU.
void notify(const Addr &pc) override
const unsigned int maxCompactorEntries
Number of entries used for the temporal compactor.
std::vector< PrefetchListenerPC * > listenersPC
Array of probe listeners.
const unsigned int precSize
Number of preceding and subsequent spatial addresses to compact.
void addEventProbeRetiredInsts(SimObject *obj, const char *name)
Add a SimObject and a probe name to monitor the retired instructions.
CircularQueue< HistoryBuffer::iterator > streamAddressBuffer
A Stream Address Buffer (SAB) tracks a window of consecutive spatial regions.
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses, const CacheAccessor &cache)
AssociativeCache< IndexEntry > index
The index table is a small cache-like structure that facilitates fast search of the history buffer.
void notifyRetiredInst(const Addr pc)
Updates the prefetcher structures upon an instruction retired.
const unsigned int succSize
CompactorEntry spatialCompactor
std::deque< CompactorEntry > temporalCompactor
PIF(const PIFPrefetcherParams &p)
HistoryBuffer historyBuffer
std::pair< Addr, int32_t > AddrPriority
void push_back(typename std::vector< T >::value_type val)
Pushes an element at the end of the queue.
ProbeManager * getProbeManager()
Get the probe manager for this object.
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.
The compactor tracks retired instructions addresses, leveraging the spatial and temporal locality amo...
bool hasAddress(Addr target, unsigned int log_blk_size) const
Checks if the provided address is contained in this spatial region and if its corresponding bit vecto...
bool inSameSpatialRegion(Addr addr, unsigned int log_blk_size, bool update)
Checks if a given address is in the same defined spatial region as the compactor entry.
void getPredictedAddresses(unsigned int log_blk_size, std::vector< AddrPriority > &addresses) const
Fills the provided vector with the predicted addresses using the recorded bit vectors of the entry.
Addr distanceFromTrigger(Addr addr, unsigned int log_blk_size) const
Computes the distance, in cache blocks, from an address to the trigger of the entry.
HistoryBuffer::iterator historyIt
const std::string & name()