gem5  v20.1.0.0
delta_correlating_prediction_tables.cc
Go to the documentation of this file.
1 
30 
31 #include "debug/HWPrefetch.hh"
33 #include "params/DCPTPrefetcher.hh"
34 #include "params/DeltaCorrelatingPredictionTables.hh"
35 
36 namespace Prefetcher {
37 
39  DeltaCorrelatingPredictionTablesParams *p) : SimObject(p),
40  deltaBits(p->delta_bits), deltaMaskBits(p->delta_mask_bits),
41  table(p->table_assoc, p->table_entries, p->table_indexing_policy,
42  p->table_replacement_policy, DCPTEntry(p->deltas_per_entry))
43 {
44 }
45 
46 void
48 {
50 
51  deltas.flush();
52  while (!deltas.full()) {
53  deltas.push_back(0);
54  }
55  lastAddress = 0;
56 }
57 
58 void
60  unsigned int delta_bits)
61 {
62  if ((address - lastAddress) != 0) {
63  Addr delta = address - lastAddress;
64  // Account for the sign bit
65  Addr max_positive_delta = (1 << (delta_bits-1)) - 1;
66  if (address > lastAddress) {
67  // check positive delta overflow
68  if (delta > max_positive_delta) {
69  delta = 0;
70  }
71  } else {
72  // check negative delta overflow
73  if (lastAddress - address > (max_positive_delta + 1)) {
74  delta = 0;
75  }
76  }
77  deltas.push_back(delta);
78  lastAddress = address;
79  }
80 }
81 
82 void
84  std::vector<Queued::AddrPriority> &pfs, unsigned int mask) const
85 {
86  assert(deltas.full());
87 
88  // Get the two most recent deltas
89  const int delta_penultimate = *(deltas.end() - 2);
90  const int delta_last = *(deltas.end() - 1);
91 
92  // a delta 0 means that it overflowed, we can not match it
93  if (delta_last == 0 || delta_penultimate == 0) {
94  return;
95  }
96 
97  // Try to find the two most recent deltas in a previous position on the
98  // delta circular array, if found, start issuing prefetches using the
99  // remaining deltas (adding each delta to the last Addr to generate the
100  // prefetched address.
101  auto it = deltas.begin();
102  for (; it != (deltas.end() - 2); ++it) {
103  const int prev_delta_penultimate = *it;
104  const int prev_delta_last = *(it + 1);
105  if ((prev_delta_penultimate >> mask) == (delta_penultimate >> mask) &&
106  (prev_delta_last >> mask) == (delta_last >> mask)) {
107  // Pattern found. Skip the matching pair and issue prefetches with
108  // the remaining deltas
109  it += 2;
110  Addr addr = lastAddress;
111  while (it != deltas.end()) {
112  const int pf_delta = *(it++);
113  addr += pf_delta;
114  pfs.push_back(Queued::AddrPriority(addr, 0));
115  }
116  break;
117  }
118  }
119 }
120 
121 void
123  const Base::PrefetchInfo &pfi,
125 {
126  if (!pfi.hasPC()) {
127  DPRINTF(HWPrefetch, "Ignoring request with no PC.\n");
128  return;
129  }
130  Addr address = pfi.getAddr();
131  Addr pc = pfi.getPC();
132  // Look up table entry, is_secure is unused in findEntry because we
133  // index using the pc
134  DCPTEntry *entry = table.findEntry(pc, false /* unused */);
135  if (entry != nullptr) {
136  entry->addAddress(address, deltaBits);
137  //Delta correlating
138  entry->getCandidates(addresses, deltaMaskBits);
139  } else {
140  entry = table.findVictim(pc);
141 
142  table.insertEntry(pc, false /* unused */, entry);
143 
144  entry->lastAddress = address;
145  }
146 }
147 
148 DCPT::DCPT(const DCPTPrefetcherParams *p)
149  : Queued(p), dcpt(*p->dcpt)
150 {
151 }
152 
153 void
155  std::vector<AddrPriority> &addresses)
156 {
157  dcpt.calculatePrefetch(pfi, addresses);
158 }
159 
160 } // namespace Prefetcher
161 
163 DeltaCorrelatingPredictionTablesParams::create()
164 {
166 }
167 
169 DCPTPrefetcherParams::create()
170 {
171  return new Prefetcher::DCPT(this);
172 }
associative_set_impl.hh
Prefetcher::DCPT::calculatePrefetch
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
Definition: delta_correlating_prediction_tables.cc:154
Prefetcher::DeltaCorrelatingPredictionTables::DCPTEntry::getCandidates
void getCandidates(std::vector< Queued::AddrPriority > &pfs, unsigned int mask_bits) const
Attempt to generate prefetch candidates using the two most recent deltas.
Definition: delta_correlating_prediction_tables.cc:83
Prefetcher::DeltaCorrelatingPredictionTables
Delta Correlating Prediction Tables Prefetcher References: Multi-level hardware prefetching using low...
Definition: delta_correlating_prediction_tables.hh:56
Prefetcher::Base::PrefetchInfo::getPC
Addr getPC() const
Returns the program counter that generated this request.
Definition: base.hh:135
Prefetcher::DCPT::DCPT
DCPT(const DCPTPrefetcherParams *p)
Definition: delta_correlating_prediction_tables.cc:148
Prefetcher::DCPT::dcpt
DeltaCorrelatingPredictionTables & dcpt
DCPT object.
Definition: delta_correlating_prediction_tables.hh:123
Prefetcher::DeltaCorrelatingPredictionTables::deltaBits
const unsigned int deltaBits
Number of bits of each delta.
Definition: delta_correlating_prediction_tables.hh:59
std::vector
STL vector class.
Definition: stl.hh:37
Prefetcher::DeltaCorrelatingPredictionTables::DCPTEntry::addAddress
void addAddress(Addr address, unsigned int delta_num_bits)
Adds an address to the entry, if the entry already existed, a delta will be generated.
Definition: delta_correlating_prediction_tables.cc:59
CircularQueue::flush
void flush()
Remove all the elements in the queue.
Definition: circular_queue.hh:536
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::DeltaCorrelatingPredictionTables::deltaMaskBits
const unsigned int deltaMaskBits
Number of lower bits to ignore from the deltas.
Definition: delta_correlating_prediction_tables.hh:61
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
Prefetcher::DeltaCorrelatingPredictionTables::table
AssociativeSet< DCPTEntry > table
The main table.
Definition: delta_correlating_prediction_tables.hh:102
Prefetcher
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
Definition: base.hh:78
Prefetcher::DCPT
The prefetcher object using the DCPT.
Definition: delta_correlating_prediction_tables.hh:120
Prefetcher::DeltaCorrelatingPredictionTables::DCPTEntry::invalidate
void invalidate() override
Invalidates the entry.
Definition: delta_correlating_prediction_tables.cc:47
std::pair
STL pair class.
Definition: stl.hh:58
Prefetcher::DeltaCorrelatingPredictionTables::DCPTEntry::deltas
CircularQueue< Addr > deltas
Stored deltas.
Definition: delta_correlating_prediction_tables.hh:69
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::DeltaCorrelatingPredictionTables::DeltaCorrelatingPredictionTables
DeltaCorrelatingPredictionTables(DeltaCorrelatingPredictionTablesParams *p)
Definition: delta_correlating_prediction_tables.cc:38
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::DeltaCorrelatingPredictionTables::DCPTEntry::lastAddress
Addr lastAddress
Last accessed address.
Definition: delta_correlating_prediction_tables.hh:67
Prefetcher::DeltaCorrelatingPredictionTables::DCPTEntry
DCPT Table entry datatype.
Definition: delta_correlating_prediction_tables.hh:64
delta_correlating_prediction_tables.hh
Prefetcher::DeltaCorrelatingPredictionTables::calculatePrefetch
void calculatePrefetch(const Base::PrefetchInfo &pfi, std::vector< Queued::AddrPriority > &addresses)
Computes the prefetch candidates given a prefetch event.
Definition: delta_correlating_prediction_tables.cc:122
TaggedEntry::invalidate
virtual void invalidate()
Invalidates the entry.
Definition: associative_set.hh:69
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::Base::PrefetchInfo::getAddr
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition: base.hh:117
Prefetcher::Base::PrefetchInfo::hasPC
bool hasPC() const
Returns true if the associated program counter is valid.
Definition: base.hh:145
ArmISA::mask
Bitfield< 28, 24 > mask
Definition: miscregs_types.hh:711
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

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