gem5  v20.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 Prefetcher {
35 
36 SBOOE::SBOOE(const SBOOEPrefetcherParams *p)
37  : Queued(p),
38  sequentialPrefetchers(p->sequential_prefetchers),
39  scoreThreshold((p->sandbox_entries*p->score_threshold_pct)/100),
40  latencyBuffer(p->latency_buffer_size),
41  averageAccessLatency(0), latencyBufferSum(0),
42  bestSandbox(NULL),
43  accesses(0)
44 {
45  // Initialize a sandbox for every sequential prefetcher between
46  // -1 and the number of sequential prefetchers defined
47  for (int i = 0; i < sequentialPrefetchers; i++) {
48  sandboxes.push_back(Sandbox(p->sandbox_entries, i-1));
49  }
50 }
51 
52 void
54 {
55  // Search for the address in the FIFO queue to update the score
56  for (const SandboxEntry &entry: entries) {
57  if (entry.valid && entry.line == addr) {
58  sandboxScore++;
59  if (entry.expectedArrivalTick > curTick()) {
60  lateScore++;
61  }
62  }
63  }
64 
65  // Insert new access in this sandbox
66  SandboxEntry entry;
67  entry.valid = true;
68  entry.line = addr + stride;
69  entry.expectedArrivalTick = tick;
70  entries.push_back(entry);
71 }
72 
73 bool
74 SBOOE::access(Addr access_line)
75 {
76  for (Sandbox &sb : sandboxes) {
77  sb.access(access_line, curTick() + averageAccessLatency);
78 
79  if (bestSandbox == NULL || sb.score() > bestSandbox->score()) {
80  bestSandbox = &sb;
81  }
82  }
83 
84  accesses++;
85 
86  return (accesses >= sandboxes.size());
87 }
88 
89 void
91 {
92  // (1) Look for the address in the demands list
93  // (2) Calculate the elapsed cycles until it was filled (curTick)
94  // (3) Insert the latency into the latency buffer (FIFO)
95  // (4) Calculate the new average access latency
96 
97  auto it = demandAddresses.find(pkt->getAddr());
98 
99  if (it != demandAddresses.end()) {
100  Tick elapsed_ticks = curTick() - it->second;
101 
102  if (latencyBuffer.full()) {
104  }
105  latencyBuffer.push_back(elapsed_ticks);
106  latencyBufferSum += elapsed_ticks;
107 
109 
110  demandAddresses.erase(it);
111  }
112 }
113 
114 void
116  std::vector<AddrPriority> &addresses)
117 {
118  const Addr pfi_addr = pfi.getAddr();
119  const Addr pfi_line = pfi_addr >> lBlkSize;
120 
121  auto it = demandAddresses.find(pfi_addr);
122 
123  if (it == demandAddresses.end()) {
124  demandAddresses.insert(std::pair<Addr, Tick>(pfi_addr, curTick()));
125  }
126 
127  const bool evaluationFinished = access(pfi_line);
128 
129  if (evaluationFinished && bestSandbox->score() > scoreThreshold) {
130  Addr pref_line = pfi_line + bestSandbox->stride;
131  addresses.push_back(AddrPriority(pref_line << lBlkSize, 0));
132  }
133 }
134 
135 } // namespace Prefetcher
136 
138 SBOOEPrefetcherParams::create()
139 {
140  return new Prefetcher::SBOOE(this);
141 }
Prefetcher::SBOOE::SBOOE
SBOOE(const SBOOEPrefetcherParams *p)
Definition: sbooe.cc:36
Prefetcher::Queued::AddrPriority
std::pair< Addr, int32_t > AddrPriority
Definition: queued.hh:182
ArmISA::sb
Bitfield< 39, 36 > sb
Definition: miscregs_types.hh:105
Prefetcher::SBOOE::accesses
unsigned int accesses
Number of accesses notified to the prefetcher.
Definition: sbooe.hh:140
sbooe.hh
Packet::getAddr
Addr getAddr() const
Definition: packet.hh:754
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
Prefetcher::SBOOE::Sandbox::entries
CircularQueue< SandboxEntry > entries
FIFO queue containing the sandbox entries.
Definition: sbooe.hh:97
Prefetcher::SBOOE::Sandbox::stride
const int stride
Sequential stride for this prefetcher.
Definition: sbooe.hh:110
Clocked::tick
Tick tick
Definition: clocked_object.hh:65
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
Prefetcher::SBOOE::bestSandbox
const Sandbox * bestSandbox
Current best sandbox.
Definition: sbooe.hh:137
std::vector
STL vector class.
Definition: stl.hh:37
Prefetcher::SBOOE::scoreThreshold
const unsigned int scoreThreshold
Threshold used to issue prefetchers.
Definition: sbooe.hh:57
Prefetcher::SBOOE::Sandbox::lateScore
unsigned int lateScore
Hits in the sandbox that wouldn't have been filled on time.
Definition: sbooe.hh:106
Prefetcher::SBOOE::Sandbox
Definition: sbooe.hh:93
Prefetcher::SBOOE::averageAccessLatency
Tick averageAccessLatency
Holds the current average access latency.
Definition: sbooe.hh:75
CircularQueue::full
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...
Definition: circular_queue.hh:744
Prefetcher::SBOOE::notifyFill
void notifyFill(const PacketPtr &pkt) override
Update the latency buffer after a prefetch fill.
Definition: sbooe.cc:90
Prefetcher::SBOOE::sandboxes
std::vector< Sandbox > sandboxes
Definition: sbooe.hh:134
Prefetcher::SBOOE
Definition: sbooe.hh:49
CircularQueue::front
reference front()
Definition: circular_queue.hh:608
Prefetcher::Base::lBlkSize
unsigned lBlkSize
log_2(block size of the parent cache).
Definition: base.hh:265
CircularQueue::size
uint32_t size() const
Definition: circular_queue.hh:633
Prefetcher::SBOOE::sequentialPrefetchers
const int sequentialPrefetchers
Prefetcher parameters.
Definition: sbooe.hh:54
Prefetcher
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
Definition: base.hh:78
Prefetcher::SBOOE::SandboxEntry::expectedArrivalTick
Tick expectedArrivalTick
Tick when the simulated prefetch is expected to be filled.
Definition: sbooe.hh:84
std::pair
STL pair class.
Definition: stl.hh:58
Prefetcher::SBOOE::SandboxEntry
Definition: sbooe.hh:80
CircularQueue::push_back
void push_back(typename Base::value_type val)
Pushes an element at the end of the queue.
Definition: circular_queue.hh:692
Prefetcher::SBOOE::Sandbox::access
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:53
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Prefetcher::Queued
Definition: queued.hh:54
Prefetcher::SBOOE::Sandbox::score
unsigned int score() const
Calculate the useful score.
Definition: sbooe.hh:131
Prefetcher::SBOOE::demandAddresses
std::unordered_map< Addr, Tick > demandAddresses
Holds the current demand addresses and tick.
Definition: sbooe.hh:64
Prefetcher::SBOOE::access
bool access(Addr line)
Process an access to the specified line address and update the sandbox counters counters.
Definition: sbooe.cc:74
Prefetcher::SBOOE::latencyBufferSum
Tick latencyBufferSum
Holds the current sum of the latency buffer latency.
Definition: sbooe.hh:78
Prefetcher::SBOOE::calculatePrefetch
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
Definition: sbooe.cc:115
Prefetcher::SBOOE::SandboxEntry::valid
bool valid
To indicate if it was initialized.
Definition: sbooe.hh:86
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Prefetcher::SBOOE::SandboxEntry::line
Addr line
Cache line predicted by the candidate prefetcher.
Definition: sbooe.hh:82
addr
ip6_addr_t addr
Definition: inet.hh:423
Prefetcher::Base::PrefetchInfo
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition: base.hh:90
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Prefetcher::SBOOE::latencyBuffer
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:72
Prefetcher::Base::PrefetchInfo::getAddr
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition: base.hh:117
Prefetcher::SBOOE::Sandbox::sandboxScore
unsigned int sandboxScore
Accesses during the eval period that were present in the sandbox.
Definition: sbooe.hh:103
curTick
Tick curTick()
The current simulated tick.
Definition: core.hh:45

Generated on Wed Sep 30 2020 14:02:12 for gem5 by doxygen 1.8.17