31#include "debug/HWPrefetch.hh"
32#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)
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 rrLeft.resize(rrEntries);
64 rrRight.resize(rrEntries);
68 const int factors[] = { 2, 3, 5 };
72 while (
i <
p.offset_list_size)
76 for (
int n : factors) {
83 offsetsList.push_back(OffsetListEntry(offset_i, 0));
87 if (
p.negative_offsets_enable) {
88 offsetsList.push_back(OffsetListEntry(-offset_i, 0));
96 offsetsListIterator = offsetsList.begin();
190 Addr offset_addr = (*offsetsListIterator).first;
191 Addr lookup_addr =
x - offset_addr;
194 if (
testRR(lookup_addr)) {
195 DPRINTF(HWPrefetch,
"Address %#lx found in the RR table\n",
x);
196 (*offsetsListIterator).second++;
197 if ((*offsetsListIterator).second >
bestScore) {
198 bestScore = (*offsetsListIterator).second;
251 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.
const unsigned int delayQueueSize
void insertIntoDelayQueue(Addr addr)
Insert the specified address into the delay queue.
BOP(const BOPPrefetcherParams &p)
unsigned int hash(Addr addr, unsigned int way) const
Generate a hash for the specified address to index the RR table.
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
void insertIntoRR(Addr addr, unsigned int way)
Insert the specified address into the RR table.
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.
std::vector< OffsetListEntry > offsetsList
bool testRR(Addr) const
Test if @X-O is hitting in the RR table to update the offset score.
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 blkSize
The block size of the parent cache.
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 - Pranith Kumar Copyright (c) 2020 Inria 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()