gem5  v22.1.0.0
signature_path_v2.cc
Go to the documentation of this file.
1 
30 
31 #include <cassert>
32 
33 #include "debug/HWPrefetch.hh"
35 #include "params/SignaturePathPrefetcherV2.hh"
36 
37 namespace gem5
38 {
39 
41 namespace prefetch
42 {
43 
44 SignaturePathV2::SignaturePathV2(const SignaturePathPrefetcherV2Params &p)
45  : SignaturePath(p),
46  globalHistoryRegister(p.global_history_register_entries,
47  p.global_history_register_entries,
48  p.global_history_register_indexing_policy,
49  p.global_history_register_replacement_policy,
51 {
52 }
53 
54 void
56  signature_t &new_signature, double &new_conf, stride_t &new_stride)
57 {
58  bool found = false;
59 
60  // This should return all entries of the GHR, since it is a fully
61  // associative table
62  std::vector<GlobalHistoryEntry *> all_ghr_entries =
63  globalHistoryRegister.getPossibleEntries(0 /* any value works */);
64 
65  for (auto gh_entry : all_ghr_entries) {
66  if (gh_entry->lastBlock + gh_entry->delta == current_block) {
67  new_signature = gh_entry->signature;
68  new_conf = gh_entry->confidence;
69  new_stride = gh_entry->delta;
70  found = true;
71  globalHistoryRegister.accessEntry(gh_entry);
72  break;
73  }
74  }
75  if (!found) {
76  new_signature = current_block;
77  new_conf = 1.0;
78  new_stride = current_block;
79  }
80 }
81 
82 double
84  PatternEntry const &sig, PatternStrideEntry const &lookahead) const
85 {
86  if (sig.counter == 0) return 0.0;
87  return (((double) usefulPrefetches) / issuedPrefetches) *
88  (((double) lookahead.counter) / sig.counter);
89 }
90 
91 double
93  PatternStrideEntry const &entry) const
94 {
95  if (sig.counter == 0) return 0.0;
96  return ((double) entry.counter) / sig.counter;
97 }
98 
99 void
101  PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry)
102 {
103  if (pattern_entry.counter.isSaturated()) {
104  pattern_entry.counter >>= 1;
105  for (auto &entry : pattern_entry.strideEntries) {
106  entry.counter >>= 1;
107  }
108  }
109  if (pstride_entry.counter.isSaturated()) {
110  pattern_entry.counter >>= 1;
111  for (auto &entry : pattern_entry.strideEntries) {
112  entry.counter >>= 1;
113  }
114  }
115  pattern_entry.counter++;
116  pstride_entry.counter++;
117 }
118 
119 void
121  stride_t last_offset, stride_t delta, double path_confidence)
122 {
123  // Always use the replacement policy to assign new entries, as all
124  // of them are unique, there are never "hits" in the GHR
125  GlobalHistoryEntry *gh_entry = globalHistoryRegister.findVictim(0);
126  assert(gh_entry != nullptr);
127  // Any address value works, as it is never used
128  globalHistoryRegister.insertEntry(0, false, gh_entry);
129 
130  gh_entry->signature = signature;
131  gh_entry->lastBlock = last_offset;
132  gh_entry->delta = delta;
133  gh_entry->confidence = path_confidence;
134 }
135 
136 } // namespace prefetch
137 } // namespace gem5
uint64_t issuedPrefetches
Total prefetches issued.
Definition: base.hh:363
uint64_t usefulPrefetches
Total prefetches that has been useful.
Definition: base.hh:365
double calculateLookaheadConfidence(PatternEntry const &sig, PatternStrideEntry const &lookahead) const override
Computes the lookahead path confidence of the provided pattern entry.
virtual void handlePageCrossingLookahead(signature_t signature, stride_t last_offset, stride_t delta, double path_confidence) override
Handles the situation when the lookahead process has crossed the boundaries of the current page.
void increasePatternEntryCounter(PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry) override
Increases the counter of a given PatternEntry/PatternStrideEntry.
SignaturePathV2(const SignaturePathPrefetcherV2Params &p)
void handleSignatureTableMiss(stride_t current_block, signature_t &new_signature, double &new_conf, stride_t &new_stride) override
Whenever a new SignatureEntry is allocated, it computes the new signature to be used with the new ent...
double calculatePrefetchConfidence(PatternEntry const &sig, PatternStrideEntry const &lookahead) const override
Computes the prefetch confidence of the provided pattern entry.
AssociativeSet< GlobalHistoryEntry > globalHistoryRegister
Global History Register.
int16_t stride_t
Stride type.
uint16_t signature_t
Signature type.
STL vector class.
Definition: stl.hh:37
bool isSaturated() const
Whether the counter has achieved its maximum value or not.
Definition: sat_counter.hh:312
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Global History Register entry datatype.
Pattern entry data type, a set of stride and counter entries.
std::vector< PatternStrideEntry > strideEntries
group of stides
SatCounter8 counter
use counter, used by SPPv2

Generated on Wed Dec 21 2022 10:22:36 for gem5 by doxygen 1.9.1