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

Generated on Mon Jul 10 2023 15:32:04 for gem5 by doxygen 1.9.7