gem5  v21.1.0.2
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 gem5
37 {
38 
40 namespace prefetch
41 {
42 
44  const DeltaCorrelatingPredictionTablesParams &p) : SimObject(p),
45  deltaBits(p.delta_bits), deltaMaskBits(p.delta_mask_bits),
46  table(p.table_assoc, p.table_entries, p.table_indexing_policy,
47  p.table_replacement_policy, DCPTEntry(p.deltas_per_entry))
48 {
49 }
50 
51 void
53 {
55 
56  deltas.flush();
57  while (!deltas.full()) {
58  deltas.push_back(0);
59  }
60  lastAddress = 0;
61 }
62 
63 void
65  unsigned int delta_bits)
66 {
67  if ((address - lastAddress) != 0) {
68  Addr delta = address - lastAddress;
69  // Account for the sign bit
70  Addr max_positive_delta = (1 << (delta_bits-1)) - 1;
71  if (address > lastAddress) {
72  // check positive delta overflow
73  if (delta > max_positive_delta) {
74  delta = 0;
75  }
76  } else {
77  // check negative delta overflow
78  if (lastAddress - address > (max_positive_delta + 1)) {
79  delta = 0;
80  }
81  }
82  deltas.push_back(delta);
83  lastAddress = address;
84  }
85 }
86 
87 void
89  std::vector<Queued::AddrPriority> &pfs, unsigned int mask) const
90 {
91  assert(deltas.full());
92 
93  // Get the two most recent deltas
94  const int delta_penultimate = *(deltas.end() - 2);
95  const int delta_last = *(deltas.end() - 1);
96 
97  // a delta 0 means that it overflowed, we can not match it
98  if (delta_last == 0 || delta_penultimate == 0) {
99  return;
100  }
101 
102  // Try to find the two most recent deltas in a previous position on the
103  // delta circular array, if found, start issuing prefetches using the
104  // remaining deltas (adding each delta to the last Addr to generate the
105  // prefetched address.
106  auto it = deltas.begin();
107  for (; it != (deltas.end() - 2); ++it) {
108  const int prev_delta_penultimate = *it;
109  const int prev_delta_last = *(it + 1);
110  if ((prev_delta_penultimate >> mask) == (delta_penultimate >> mask) &&
111  (prev_delta_last >> mask) == (delta_last >> mask)) {
112  // Pattern found. Skip the matching pair and issue prefetches with
113  // the remaining deltas
114  it += 2;
115  Addr addr = lastAddress;
116  while (it != deltas.end()) {
117  const int pf_delta = *(it++);
118  addr += pf_delta;
119  pfs.push_back(Queued::AddrPriority(addr, 0));
120  }
121  break;
122  }
123  }
124 }
125 
126 void
128  const Base::PrefetchInfo &pfi,
130 {
131  if (!pfi.hasPC()) {
132  DPRINTF(HWPrefetch, "Ignoring request with no PC.\n");
133  return;
134  }
135  Addr address = pfi.getAddr();
136  Addr pc = pfi.getPC();
137  // Look up table entry, is_secure is unused in findEntry because we
138  // index using the pc
139  DCPTEntry *entry = table.findEntry(pc, false /* unused */);
140  if (entry != nullptr) {
141  entry->addAddress(address, deltaBits);
142  //Delta correlating
143  entry->getCandidates(addresses, deltaMaskBits);
144  } else {
145  entry = table.findVictim(pc);
146 
147  table.insertEntry(pc, false /* unused */, entry);
148 
149  entry->lastAddress = address;
150  }
151 }
152 
153 DCPT::DCPT(const DCPTPrefetcherParams &p)
154  : Queued(p), dcpt(*p.dcpt)
155 {
156 }
157 
158 void
160  std::vector<AddrPriority> &addresses)
161 {
162  dcpt.calculatePrefetch(pfi, addresses);
163 }
164 
165 } // namespace prefetch
166 } // namespace gem5
gem5::prefetch::Base::PrefetchInfo::getAddr
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition: base.hh:125
associative_set_impl.hh
gem5::prefetch::DeltaCorrelatingPredictionTables::table
AssociativeSet< DCPTEntry > table
The main table.
Definition: delta_correlating_prediction_tables.hh:107
gem5::prefetch::DeltaCorrelatingPredictionTables::deltaMaskBits
const unsigned int deltaMaskBits
Number of lower bits to ignore from the deltas.
Definition: delta_correlating_prediction_tables.hh:66
gem5::prefetch::DeltaCorrelatingPredictionTables::DCPTEntry::invalidate
void invalidate() override
Invalidate the block.
Definition: delta_correlating_prediction_tables.cc:52
std::vector
STL vector class.
Definition: stl.hh:37
gem5::CircularQueue::push_back
void push_back(typename std::vector< T >::value_type val)
Pushes an element at the end of the queue.
Definition: circular_queue.hh:502
gem5::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:558
gem5::prefetch::DCPT::DCPT
DCPT(const DCPTPrefetcherParams &p)
Definition: delta_correlating_prediction_tables.cc:153
gem5::prefetch::DeltaCorrelatingPredictionTables::DCPTEntry
DCPT Table entry datatype.
Definition: delta_correlating_prediction_tables.hh:69
gem5::prefetch::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:127
gem5::mask
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
gem5::prefetch::DeltaCorrelatingPredictionTables::deltaBits
const unsigned int deltaBits
Number of bits of each delta.
Definition: delta_correlating_prediction_tables.hh:64
gem5::prefetch::Base::PrefetchInfo::getPC
Addr getPC() const
Returns the program counter that generated this request.
Definition: base.hh:143
gem5::CircularQueue::flush
void flush()
Remove all the elements in the queue.
Definition: circular_queue.hh:423
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::TaggedEntry::invalidate
virtual void invalidate()
Invalidate the block.
Definition: tagged_entry.hh:103
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::prefetch::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:64
std::pair
STL pair class.
Definition: stl.hh:58
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::prefetch::DeltaCorrelatingPredictionTables::DeltaCorrelatingPredictionTables
DeltaCorrelatingPredictionTables(const DeltaCorrelatingPredictionTablesParams &p)
Definition: delta_correlating_prediction_tables.cc:43
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::prefetch::Queued
Definition: queued.hh:60
delta_correlating_prediction_tables.hh
gem5::prefetch::DeltaCorrelatingPredictionTables::DCPTEntry::deltas
CircularQueue< Addr > deltas
Stored deltas.
Definition: delta_correlating_prediction_tables.hh:74
gem5::prefetch::DCPT::dcpt
DeltaCorrelatingPredictionTables & dcpt
DCPT object.
Definition: delta_correlating_prediction_tables.hh:128
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::prefetch::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:88
gem5::context_switch_task_id::Prefetcher
@ Prefetcher
Definition: request.hh:83
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::prefetch::DeltaCorrelatingPredictionTables::DCPTEntry::lastAddress
Addr lastAddress
Last accessed address.
Definition: delta_correlating_prediction_tables.hh:72
gem5::prefetch::Base::PrefetchInfo
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition: base.hh:97
gem5::prefetch::DCPT::calculatePrefetch
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
Definition: delta_correlating_prediction_tables.cc:159
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::prefetch::Base::PrefetchInfo::hasPC
bool hasPC() const
Returns true if the associated program counter is valid.
Definition: base.hh:153

Generated on Tue Sep 21 2021 12:25:29 for gem5 by doxygen 1.8.17