gem5  v19.0.0.0
delta_correlating_prediction_tables.cc
Go to the documentation of this file.
1 
32 
33 #include "debug/HWPrefetch.hh"
35 #include "params/DCPTPrefetcher.hh"
36 #include "params/DeltaCorrelatingPredictionTables.hh"
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  for (auto &delta : deltas) {
52  delta = 0;
53  }
54  lastAddress = 0;
55  deltaPointer = 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[deltaPointer] = delta;
78  deltaPointer = (deltaPointer + 1) % deltas.size();
79  lastAddress = address;
80  }
81 }
82 
83 void
85  std::vector<QueuedPrefetcher::AddrPriority> &pfs, unsigned int mask) const
86 {
87  // most recent index
88  unsigned int last = (deltaPointer - 1) % deltas.size();
89  // second most recent index
90  unsigned int last_prev = (deltaPointer - 2) % deltas.size();
91  int delta_0 = deltas[last_prev];
92  int delta_1 = deltas[last];
93 
94  // a delta 0 means that it overflowed, we can not match it
95  if (delta_0 == 0 || delta_1 == 0) {
96  return;
97  }
98 
99  // Try to find the two most recent deltas in a previous position on the
100  // delta circular array, if found, start issuing prefetches using the
101  // remaining deltas (adding each delta to the last Addr to generate the
102  // prefetched address.
103 
104  // oldest index
105  int idx_0 = deltaPointer + 1;
106  // second oldest index
107  int idx_1 = deltaPointer + 2;
108  for (int i = 0; i < deltas.size() - 2; i += 1) {
109  int this_delta_0 = deltas[(idx_0 + i) % deltas.size()];
110  int this_delta_1 = deltas[(idx_1 + i) % deltas.size()];
111  if ((this_delta_0 >> mask) == (delta_0 >> mask) &&
112  (this_delta_1 >> mask) == (delta_1 >> mask)) {
113  Addr addr = lastAddress;
114  // Pattern found, issue prefetches with the remaining deltas after
115  // this pair
116  i += 2; // skip the matching pair
117  do {
118  int pf_delta = deltas[(idx_0 + i) % deltas.size()];
119  addr += pf_delta;
120  pfs.push_back(QueuedPrefetcher::AddrPriority(addr, 0));
121  i += 1;
122  } while (i < deltas.size() - 2);
123  }
124  }
125 }
126 
127 void
129  const BasePrefetcher::PrefetchInfo &pfi,
131 {
132  if (!pfi.hasPC()) {
133  DPRINTF(HWPrefetch, "Ignoring request with no PC.\n");
134  return;
135  }
136  Addr address = pfi.getAddr();
137  Addr pc = pfi.getPC();
138  // Look up table entry, is_secure is unused in findEntry because we
139  // index using the pc
140  DCPTEntry *entry = table.findEntry(pc, false /* unused */);
141  if (entry != nullptr) {
142  entry->addAddress(address, deltaBits);
143  //Delta correlating
144  entry->getCandidates(addresses, deltaMaskBits);
145  } else {
146  entry = table.findVictim(pc);
147 
148  table.insertEntry(pc, false /* unused */, entry);
149 
150  entry->lastAddress = address;
151  }
152 }
153 
155 DeltaCorrelatingPredictionTablesParams::create()
156 {
157  return new DeltaCorrelatingPredictionTables(this);
158 }
159 
160 DCPTPrefetcher::DCPTPrefetcher(const DCPTPrefetcherParams *p)
161  : QueuedPrefetcher(p), dcpt(*p->dcpt)
162 {
163 }
164 
165 void
167  std::vector<AddrPriority> &addresses)
168 {
169  dcpt.calculatePrefetch(pfi, addresses);
170 }
171 
173 DCPTPrefetcherParams::create()
174 {
175  return new DCPTPrefetcher(this);
176 }
#define DPRINTF(x,...)
Definition: trace.hh:229
Bitfield< 7 > i
STL pair class.
Definition: stl.hh:61
ip6_addr_t addr
Definition: inet.hh:335
void calculatePrefetch(const BasePrefetcher::PrefetchInfo &pfi, std::vector< QueuedPrefetcher::AddrPriority > &addresses)
Computes the prefetch candidates given a prefetch event.
void getCandidates(std::vector< QueuedPrefetcher::AddrPriority > &pfs, unsigned int mask_bits) const
Attempt to generate prefetch candidates using the two most recent deltas.
STL vector class.
Definition: stl.hh:40
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition: base.hh:119
Bitfield< 4 > pc
Class containing the information needed by the prefetch to train and generate new prefetch requests...
Definition: base.hh:92
Delta Correlating Prediction Tables Prefetcher References: Multi-level hardware prefetching using low...
const unsigned int deltaBits
Number of bits of each delta.
Addr getPC() const
Returns the program counter that generated this request.
Definition: base.hh:137
The prefetcher object using the DCPT.
DeltaCorrelatingPredictionTables(DeltaCorrelatingPredictionTablesParams *p)
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
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.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
DCPTPrefetcher(const DCPTPrefetcherParams *p)
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
DeltaCorrelatingPredictionTables & dcpt
DCPT object.
Bitfield< 3, 0 > mask
Definition: types.hh:64
virtual void invalidate()
Invalidates the entry.
Bitfield< 0 > p
Abstract superclass for simulation objects.
Definition: sim_object.hh:96
AssociativeSet< DCPTEntry > table
The main table.
const unsigned int deltaMaskBits
Number of lower bits to ignore from the deltas.
bool hasPC() const
Returns true if the associated program counter is valid.
Definition: base.hh:147

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