32#include "debug/HWPrefetch.hh"
33#include "params/BOPPrefetcher.hh"
42 scoreMax(
p.score_max), roundMax(
p.round_max),
43 badScore(
p.bad_score), rrEntries(
p.rr_size),
44 tagMask((1 <<
p.tag_bits) - 1),
45 delayQueueEnabled(
p.delay_queue_enable),
46 delayQueueSize(
p.delay_queue_size),
47 delayTicks(cyclesToTicks(
p.delay_queue_cycles)),
49 issuePrefetchRequests(
false), bestOffset(1), phaseBestOffset(0),
50 bestScore(0), round(0), degree(
p.degree)
53 fatal(
"%s: number of RR entries is not power of 2\n",
name());
56 fatal(
"%s: cache line size is not power of 2\n",
name());
58 if (
p.negative_offsets_enable && (
p.offset_list_size % 2 != 0)) {
59 fatal(
"%s: negative offsets enabled with odd offset list size\n",
63 fatal(
"%s: prefetch degree must be strictly greater than zero\n",
67 rrLeft.resize(rrEntries);
68 rrRight.resize(rrEntries);
74 const int factors[] = { 2, 3, 5 };
78 while (
i <
p.offset_list_size)
82 for (
int n : factors) {
89 offsetsList.push_back(OffsetListEntry(offset_i, 0));
95 if (
p.negative_offsets_enable) {
96 offsetsList.push_back(OffsetListEntry(-offset_i, 0));
104 offsetsListIterator = offsetsList.begin();
155 Addr hash = line_addr ^ (line_addr >> (log_rr_entries << way));
156 hash &= ((1ULL << log_rr_entries) - 1);
228 Addr offset_tag = (*offsetsListIterator).first;
241 DPRINTF(HWPrefetch,
"Address %#lx found in the RR table\n",
243 (*offsetsListIterator).second++;
244 if ((*offsetsListIterator).second >
bestScore) {
245 bestScore = (*offsetsListIterator).second;
309 DPRINTF(HWPrefetch,
"Generated prefetch %#lx\n", prefetch_addr);
Information provided to probes on a cache event.
PacketPtr pkt
Packet that triggered the cache access.
bool isHWPrefetch() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
MemCmd cmd
The command field of the packet.
std::deque< DelayQueueEntry > delayQueue
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses, const CacheAccessor &cache) override
unsigned int round
Current round.
std::vector< Addr > rrLeft
unsigned int bestScore
Max score found so far.
unsigned int index(Addr addr, unsigned int way) const
Generate a hash for the specified address to index the RR table.
const unsigned int delayQueueSize
void insertIntoDelayQueue(Addr addr)
Insert the specified address into the delay queue.
BOP(const BOPPrefetcherParams &p)
const unsigned int rrEntries
Recent requests table parameteres.
const unsigned int tagMask
std::vector< OffsetListEntry >::iterator offsetsListIterator
Current test offset index.
const unsigned int badScore
const bool delayQueueEnabled
Delay queue parameters.
const unsigned int scoreMax
Learning phase parameters.
std::vector< Addr > rrRight
bool issuePrefetchRequests
Hardware prefetcher enabled.
Addr tag(Addr addr) const
Generate the tag for the specified address based on the tag bits and the block size.
void delayQueueEventWrapper()
Event to handle the delay queue processing.
void bestOffsetLearning(Addr)
Learning phase of the BOP.
const unsigned int roundMax
Addr phaseBestOffset
Current best offset found in the learning phase.
EventFunctionWrapper delayQueueEvent
void notifyFill(const CacheAccessProbeArg &arg) override
Update the RR right table after a prefetch fill.
unsigned int degree
The prefetch degree, i.e.
std::vector< OffsetListEntry > offsetsList
bool testRR(Addr) const
Test if @X-O is hitting in the RR table to update the offset score.
void insertIntoRR(Addr addr, Addr addr_tag, unsigned int way)
Insert the specified address into the RR table.
void resetScores()
Reset all the scores from the offset list.
Addr bestOffset
Current best offset to issue prefetches.
const unsigned int delayTicks
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Addr getAddr() const
Obtains the address value of this Prefetcher address.
unsigned lBlkSize
log_2(block size of the parent cache).
std::pair< Addr, int32_t > AddrPriority
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
static constexpr bool isPowerOf2(const T &n)
bool scheduled() const
Determine if the current event is scheduled.
void schedule(Event &event, Tick when)
#define fatal(...)
This implements a cprintf based fatal() function.
Copyright (c) 2024 Arm Limited All rights reserved.
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
Provides generic cache lookup functions.
In a first implementation of the BO prefetcher, both banks of the RR were written simultaneously when...
const std::string & name()