gem5  v22.1.0.0
sbooe.cc
Go to the documentation of this file.
1 
30 
31 #include "debug/HWPrefetch.hh"
32 #include "params/SBOOEPrefetcher.hh"
33 
34 namespace gem5
35 {
36 
38 namespace prefetch
39 {
40 
41 SBOOE::SBOOE(const SBOOEPrefetcherParams &p)
42  : Queued(p),
43  sequentialPrefetchers(p.sequential_prefetchers),
44  scoreThreshold((p.sandbox_entries*p.score_threshold_pct)/100),
45  latencyBuffer(p.latency_buffer_size),
46  averageAccessLatency(0), latencyBufferSum(0),
47  bestSandbox(NULL),
48  accesses(0)
49 {
50  // Initialize a sandbox for every sequential prefetcher between
51  // -1 and the number of sequential prefetchers defined
52  for (int i = 0; i < sequentialPrefetchers; i++) {
53  sandboxes.push_back(Sandbox(p.sandbox_entries, i-1));
54  }
55 }
56 
57 void
59 {
60  // Search for the address in the FIFO queue to update the score
61  for (const SandboxEntry &entry: entries) {
62  if (entry.valid && entry.line == addr) {
63  sandboxScore++;
64  if (entry.expectedArrivalTick > curTick()) {
65  lateScore++;
66  }
67  }
68  }
69 
70  // Insert new access in this sandbox
71  SandboxEntry entry;
72  entry.valid = true;
73  entry.line = addr + stride;
74  entry.expectedArrivalTick = tick;
75  entries.push_back(entry);
76 }
77 
78 bool
79 SBOOE::access(Addr access_line)
80 {
81  for (Sandbox &sb : sandboxes) {
82  sb.access(access_line, curTick() + averageAccessLatency);
83 
84  if (bestSandbox == NULL || sb.score() > bestSandbox->score()) {
85  bestSandbox = &sb;
86  }
87  }
88 
89  accesses++;
90 
91  return (accesses >= sandboxes.size());
92 }
93 
94 void
96 {
97  // (1) Look for the address in the demands list
98  // (2) Calculate the elapsed cycles until it was filled (curTick)
99  // (3) Insert the latency into the latency buffer (FIFO)
100  // (4) Calculate the new average access latency
101 
102  auto it = demandAddresses.find(pkt->getAddr());
103 
104  if (it != demandAddresses.end()) {
105  Tick elapsed_ticks = curTick() - it->second;
106 
107  if (latencyBuffer.full()) {
109  }
110  latencyBuffer.push_back(elapsed_ticks);
111  latencyBufferSum += elapsed_ticks;
112 
114 
115  demandAddresses.erase(it);
116  }
117 }
118 
119 void
121  std::vector<AddrPriority> &addresses)
122 {
123  const Addr pfi_addr = pfi.getAddr();
124  const Addr pfi_line = pfi_addr >> lBlkSize;
125 
126  auto it = demandAddresses.find(pfi_addr);
127 
128  if (it == demandAddresses.end()) {
129  demandAddresses.insert(std::pair<Addr, Tick>(pfi_addr, curTick()));
130  }
131 
132  const bool evaluationFinished = access(pfi_line);
133 
134  if (evaluationFinished && bestSandbox->score() > scoreThreshold) {
135  Addr pref_line = pfi_line + bestSandbox->stride;
136  addresses.push_back(AddrPriority(pref_line << lBlkSize, 0));
137  }
138 }
139 
140 } // namespace prefetch
141 } // namespace gem5
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Addr getAddr() const
Definition: packet.hh:805
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition: base.hh:98
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition: base.hh:125
unsigned lBlkSize
log_2(block size of the parent cache).
Definition: base.hh:273
std::pair< Addr, int32_t > AddrPriority
Definition: queued.hh:191
unsigned int sandboxScore
Accesses during the eval period that were present in the sandbox.
Definition: sbooe.hh:109
const int stride
Sequential stride for this prefetcher.
Definition: sbooe.hh:116
CircularQueue< SandboxEntry > entries
FIFO queue containing the sandbox entries.
Definition: sbooe.hh:103
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:58
unsigned int score() const
Calculate the useful score.
Definition: sbooe.hh:137
unsigned int lateScore
Hits in the sandbox that wouldn't have been filled on time.
Definition: sbooe.hh:112
bool access(Addr line)
Process an access to the specified line address and update the sandbox counters counters.
Definition: sbooe.cc:79
const int sequentialPrefetchers
Prefetcher parameters.
Definition: sbooe.hh:59
void notifyFill(const PacketPtr &pkt) override
Update the latency buffer after a prefetch fill.
Definition: sbooe.cc:95
unsigned int accesses
Number of accesses notified to the prefetcher.
Definition: sbooe.hh:146
std::vector< Sandbox > sandboxes
Definition: sbooe.hh:140
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:77
std::unordered_map< Addr, Tick > demandAddresses
Holds the current demand addresses and tick.
Definition: sbooe.hh:69
Tick latencyBufferSum
Holds the current sum of the latency buffer latency.
Definition: sbooe.hh:83
SBOOE(const SBOOEPrefetcherParams &p)
Definition: sbooe.cc:41
Tick averageAccessLatency
Holds the current average access latency.
Definition: sbooe.hh:80
const Sandbox * bestSandbox
Current best sandbox.
Definition: sbooe.hh:143
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
Definition: sbooe.cc:120
const unsigned int scoreThreshold
Threshold used to issue prefetchers.
Definition: sbooe.hh:62
STL pair class.
Definition: stl.hh:58
STL vector class.
Definition: stl.hh:37
size_t size() const
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< 39, 36 > sb
Definition: misc_types.hh:109
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Tick expectedArrivalTick
Tick when the simulated prefetch is expected to be filled.
Definition: sbooe.hh:90
Addr line
Cache line predicted by the candidate prefetcher.
Definition: sbooe.hh:88
bool valid
To indicate if it was initialized.
Definition: sbooe.hh:92

Generated on Wed Dec 21 2022 10:22:36 for gem5 by doxygen 1.9.1