gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
sbooe.cc
Go to the documentation of this file.
1 
32 
33 #include "debug/HWPrefetch.hh"
34 #include "params/SBOOEPrefetcher.hh"
35 
36 SBOOEPrefetcher::SBOOEPrefetcher(const SBOOEPrefetcherParams *p)
37  : QueuedPrefetcher(p),
38  latencyBufferSize(p->latency_buffer_size),
39  sequentialPrefetchers(p->sequential_prefetchers),
40  scoreThreshold((p->sandbox_entries*p->score_threshold_pct)/100),
41  averageAccessLatency(0), latencyBufferSum(0),
42  bestSandbox(NULL),
43  accesses(0)
44 {
45  if (!(p->score_threshold_pct >= 0 && p->score_threshold_pct <= 100)) {
46  fatal("%s: the score threshold should be between 0 and 100\n", name());
47  }
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 
56 void
58 {
59  entries[index].valid = true;
60  entries[index].line = addr + stride;
61  entries[index].expectedArrivalTick = tick;
62 
63  index++;
64 
65  if (index == entries.size()) {
66  index = 0;
67  }
68 }
69 
70 bool
72 {
73  for (Sandbox &sb : sandboxes) {
74  // Search for the address in the FIFO queue
75  for (const SandboxEntry &entry: sb.entries) {
76  if (entry.valid && entry.line == access_line) {
77  sb.sandboxScore++;
78  if (entry.expectedArrivalTick > curTick()) {
79  sb.lateScore++;
80  }
81  }
82  }
83 
84  sb.insert(access_line, curTick() + averageAccessLatency);
85 
86  if (bestSandbox == NULL || sb.score() > bestSandbox->score()) {
87  bestSandbox = &sb;
88  }
89  }
90 
91  accesses++;
92 
93  return (accesses >= sandboxes.size());
94 }
95 
96 void
98 {
99  // (1) Look for the address in the demands list
100  // (2) Calculate the elapsed cycles until it was filled (curTick)
101  // (3) Insert the latency into the latency buffer (FIFO)
102  // (4) Calculate the new average access latency
103 
104  auto it = demandAddresses.find(pkt->getAddr());
105 
106  if (it != demandAddresses.end()) {
107  Tick elapsed_ticks = curTick() - it->second;
108 
109  latencyBuffer.push_back(elapsed_ticks);
110  latencyBufferSum += elapsed_ticks;
111 
112  if (latencyBuffer.size() > latencyBufferSize) {
113  latencyBufferSum -= latencyBuffer.front();
114  latencyBuffer.pop_front();
115  }
116 
118 
119  demandAddresses.erase(it);
120  }
121 }
122 
123 void
125  std::vector<AddrPriority> &addresses)
126 {
127  const Addr pfi_addr = pfi.getAddr();
128  const Addr pfi_line = pfi_addr >> lBlkSize;
129 
130  auto it = demandAddresses.find(pfi_addr);
131 
132  if (it == demandAddresses.end()) {
133  demandAddresses.insert(std::pair<Addr, Tick>(pfi_addr, curTick()));
134  }
135 
136  const bool evaluationFinished = access(pfi_line);
137 
138  if (evaluationFinished && bestSandbox->score() > scoreThreshold) {
139  Addr pref_line = pfi_line + bestSandbox->stride;
140  addresses.push_back(AddrPriority(pref_line << lBlkSize, 0));
141  }
142 }
143 
145 SBOOEPrefetcherParams::create()
146 {
147  return new SBOOEPrefetcher(this);
148 }
Tick expectedArrivalTick
Tick when the simulated prefetch is expected to be filled.
Definition: sbooe.hh:85
Bitfield< 30, 0 > index
std::unordered_map< Addr, Tick > demandAddresses
Holds the current demand addresses and tick.
Definition: sbooe.hh:65
void insert(Addr line, Tick tick)
Insert the line address being accessed to the cache into the FIFO queue of the sandbox.
Definition: sbooe.cc:57
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:175
Bitfield< 7 > i
STL pair class.
Definition: stl.hh:61
bool access(Addr line)
Process an access to the specified line address and update the sandbox counters counters.
Definition: sbooe.cc:71
Bitfield< 21, 20 > stride
void notifyFill(const PacketPtr &pkt) override
Update the latency buffer after a prefetch fill.
Definition: sbooe.cc:97
ip6_addr_t addr
Definition: inet.hh:335
Addr line
Cache line predicted by the candidate prefetcher.
Definition: sbooe.hh:83
Sandbox * bestSandbox
Current best sandbox.
Definition: sbooe.hh:135
unsigned lBlkSize
log_2(block size of the parent cache).
Definition: base.hh:267
STL vector class.
Definition: stl.hh:40
const int stride
Sequential stride for this prefetcher.
Definition: sbooe.hh:107
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition: base.hh:119
Tick curTick()
The current simulated tick.
Definition: core.hh:47
Class containing the information needed by the prefetch to train and generate new prefetch requests...
Definition: base.hh:92
std::pair< Addr, int32_t > AddrPriority
Definition: queued.hh:178
std::vector< Sandbox > sandboxes
Definition: sbooe.hh:132
Tick latencyBufferSum
Holds the current sum of the latency buffer latency.
Definition: sbooe.hh:79
uint64_t Tick
Tick count type.
Definition: types.hh:63
Addr getAddr() const
Definition: packet.hh:726
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
virtual const std::string name() const
Definition: sim_object.hh:120
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
Definition: sbooe.cc:124
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
bool valid
To indicate if it was initialized.
Definition: sbooe.hh:87
unsigned int score() const
Calculate the useful score.
Definition: sbooe.hh:127
std::deque< Tick > latencyBuffer
The latency buffer holds the elapsed ticks between the demand and the fill in the cache for the lates...
Definition: sbooe.hh:73
Tick averageAccessLatency
Holds the current average access latency.
Definition: sbooe.hh:76
SBOOEPrefetcher(const SBOOEPrefetcherParams *p)
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
Definition: sbooe.cc:36
unsigned int accesses
Number of accesses notified to the prefetcher.
Definition: sbooe.hh:138
const unsigned int scoreThreshold
Threshold used to issue prefetchers.
Definition: sbooe.hh:58
const int sequentialPrefetchers
Definition: sbooe.hh:55
Bitfield< 0 > p
Bitfield< 39, 36 > sb
const int latencyBufferSize
Prefetcher parameters.
Definition: sbooe.hh:54

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13