gem5 v24.0.0.0
Loading...
Searching...
No Matches
sbooe.cc
Go to the documentation of this file.
1
30
31#include "debug/HWPrefetch.hh"
32#include "params/SBOOEPrefetcher.hh"
33
34namespace gem5
35{
36
37namespace prefetch
38{
39
40SBOOE::SBOOE(const SBOOEPrefetcherParams &p)
41 : Queued(p),
42 sequentialPrefetchers(p.sequential_prefetchers),
43 scoreThreshold((p.sandbox_entries*p.score_threshold_pct)/100),
44 latencyBuffer(p.latency_buffer_size),
45 averageAccessLatency(0), latencyBufferSum(0),
46 bestSandbox(NULL),
47 accesses(0)
48{
49 // Initialize a sandbox for every sequential prefetcher between
50 // -1 and the number of sequential prefetchers defined
51 for (int i = 0; i < sequentialPrefetchers; i++) {
52 sandboxes.push_back(Sandbox(p.sandbox_entries, i-1));
53 }
54}
55
56void
58{
59 // Search for the address in the FIFO queue to update the score
60 for (const SandboxEntry &entry: entries) {
61 if (entry.valid && entry.line == addr) {
63 if (entry.expectedArrivalTick > curTick()) {
64 lateScore++;
65 }
66 }
67 }
68
69 // Insert new access in this sandbox
70 SandboxEntry entry;
71 entry.valid = true;
72 entry.line = addr + stride;
74 entries.push_back(entry);
75}
76
77bool
78SBOOE::access(Addr access_line)
79{
80 for (Sandbox &sb : sandboxes) {
81 sb.access(access_line, curTick() + averageAccessLatency);
82
83 if (bestSandbox == NULL || sb.score() > bestSandbox->score()) {
84 bestSandbox = &sb;
85 }
86 }
87
88 accesses++;
89
90 return (accesses >= sandboxes.size());
91}
92
93void
95{
96 const PacketPtr& pkt = arg.pkt;
97
98 // (1) Look for the address in the demands list
99 // (2) Calculate the elapsed cycles until it was filled (curTick)
100 // (3) Insert the latency into the latency buffer (FIFO)
101 // (4) Calculate the new average access latency
102
103 auto it = demandAddresses.find(pkt->getAddr());
104
105 if (it != demandAddresses.end()) {
106 Tick elapsed_ticks = curTick() - it->second;
107
108 if (latencyBuffer.full()) {
110 }
111 latencyBuffer.push_back(elapsed_ticks);
112 latencyBufferSum += elapsed_ticks;
113
115
116 demandAddresses.erase(it);
117 }
118}
119
120void
122 std::vector<AddrPriority> &addresses,
123 const CacheAccessor &cache)
124{
125 const Addr pfi_addr = pfi.getAddr();
126 const Addr pfi_line = pfi_addr >> lBlkSize;
127
128 auto it = demandAddresses.find(pfi_addr);
129
130 if (it == demandAddresses.end()) {
131 demandAddresses.insert(std::pair<Addr, Tick>(pfi_addr, curTick()));
132 }
133
134 const bool evaluationFinished = access(pfi_line);
135
136 if (evaluationFinished && bestSandbox->score() > scoreThreshold) {
137 Addr pref_line = pfi_line + bestSandbox->stride;
138 addresses.push_back(AddrPriority(pref_line << lBlkSize, 0));
139 }
140}
141
142} // namespace prefetch
143} // namespace gem5
Information provided to probes on a cache event.
PacketPtr pkt
Packet that triggered the cache access.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Addr getAddr() const
Definition packet.hh:807
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition base.hh:111
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition base.hh:138
unsigned lBlkSize
log_2(block size of the parent cache).
Definition base.hh:289
std::pair< Addr, int32_t > AddrPriority
Definition queued.hh:192
unsigned int sandboxScore
Accesses during the eval period that were present in the sandbox.
Definition sbooe.hh:108
const int stride
Sequential stride for this prefetcher.
Definition sbooe.hh:115
CircularQueue< SandboxEntry > entries
FIFO queue containing the sandbox entries.
Definition sbooe.hh:102
void access(Addr line, Tick tick)
Update score and insert the line address being accessed into the FIFO queue of the sandbox.
Definition sbooe.cc:57
unsigned int score() const
Calculate the useful score.
Definition sbooe.hh:136
unsigned int lateScore
Hits in the sandbox that wouldn't have been filled on time.
Definition sbooe.hh:111
bool access(Addr line)
Process an access to the specified line address and update the sandbox counters counters.
Definition sbooe.cc:78
const int sequentialPrefetchers
Prefetcher parameters.
Definition sbooe.hh:58
unsigned int accesses
Number of accesses notified to the prefetcher.
Definition sbooe.hh:145
std::vector< Sandbox > sandboxes
Definition sbooe.hh:139
CircularQueue< Tick > latencyBuffer
The latency buffer holds the elapsed ticks between the demand and the fill in the cache for the lates...
Definition sbooe.hh:76
std::unordered_map< Addr, Tick > demandAddresses
Holds the current demand addresses and tick.
Definition sbooe.hh:68
Tick latencyBufferSum
Holds the current sum of the latency buffer latency.
Definition sbooe.hh:82
SBOOE(const SBOOEPrefetcherParams &p)
Definition sbooe.cc:40
Tick averageAccessLatency
Holds the current average access latency.
Definition sbooe.hh:79
const Sandbox * bestSandbox
Current best sandbox.
Definition sbooe.hh:142
void notifyFill(const CacheAccessProbeArg &arg) override
Update the latency buffer after a prefetch fill.
Definition sbooe.cc:94
const unsigned int scoreThreshold
Threshold used to issue prefetchers.
Definition sbooe.hh:61
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses, const CacheAccessor &cache) override
Definition sbooe.cc:121
STL pair class.
Definition stl.hh:58
STL vector class.
Definition stl.hh:37
void push_back(typename std::vector< T >::value_type val)
Pushes an element at the end of the queue.
bool full() const
Is the queue full? A queue is full if the head is the 0^{th} element and the tail is the (size-1)^{th...
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 15, 12 > sb
Definition misc_types.hh:99
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
Provides generic cache lookup functions.
Tick expectedArrivalTick
Tick when the simulated prefetch is expected to be filled.
Definition sbooe.hh:89
Addr line
Cache line predicted by the candidate prefetcher.
Definition sbooe.hh:87
bool valid
To indicate if it was initialized.
Definition sbooe.hh:91

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0