gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
40 namespace prefetch
41 {
42 
43 SignaturePathV2::SignaturePathV2(const SignaturePathPrefetcherV2Params &p)
44  : SignaturePath(p),
45  globalHistoryRegister(p.global_history_register_entries,
46  p.global_history_register_entries,
47  p.global_history_register_indexing_policy,
48  p.global_history_register_replacement_policy,
50 {
51 }
52 
53 void
55  signature_t &new_signature, double &new_conf, stride_t &new_stride)
56 {
57  bool found = false;
58 
59  // This should return all entries of the GHR, since it is a fully
60  // associative table
61  std::vector<GlobalHistoryEntry *> all_ghr_entries =
62  globalHistoryRegister.getPossibleEntries(0 /* any value works */);
63 
64  for (auto gh_entry : all_ghr_entries) {
65  if (gh_entry->lastBlock + gh_entry->delta == current_block) {
66  new_signature = gh_entry->signature;
67  new_conf = gh_entry->confidence;
68  new_stride = gh_entry->delta;
69  found = true;
70  globalHistoryRegister.accessEntry(gh_entry);
71  break;
72  }
73  }
74  if (!found) {
75  new_signature = current_block;
76  new_conf = 1.0;
77  new_stride = current_block;
78  }
79 }
80 
81 double
83  PatternEntry const &sig, PatternStrideEntry const &lookahead) const
84 {
85  if (sig.counter == 0) return 0.0;
86  return (((double) usefulPrefetches) / issuedPrefetches) *
87  (((double) lookahead.counter) / sig.counter);
88 }
89 
90 double
92  PatternStrideEntry const &entry) const
93 {
94  if (sig.counter == 0) return 0.0;
95  return ((double) entry.counter) / sig.counter;
96 }
97 
98 void
100  PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry)
101 {
102  if (pattern_entry.counter.isSaturated()) {
103  pattern_entry.counter >>= 1;
104  for (auto &entry : pattern_entry.strideEntries) {
105  entry.counter >>= 1;
106  }
107  }
108  if (pstride_entry.counter.isSaturated()) {
109  pattern_entry.counter >>= 1;
110  for (auto &entry : pattern_entry.strideEntries) {
111  entry.counter >>= 1;
112  }
113  }
114  pattern_entry.counter++;
115  pstride_entry.counter++;
116 }
117 
118 void
120  stride_t last_offset, stride_t delta, double path_confidence)
121 {
122  // Always use the replacement policy to assign new entries, as all
123  // of them are unique, there are never "hits" in the GHR
124  GlobalHistoryEntry *gh_entry = globalHistoryRegister.findVictim(0);
125  assert(gh_entry != nullptr);
126  // Any address value works, as it is never used
127  globalHistoryRegister.insertEntry(0, false, gh_entry);
128 
129  gh_entry->signature = signature;
130  gh_entry->lastBlock = last_offset;
131  gh_entry->delta = delta;
132  gh_entry->confidence = path_confidence;
133 }
134 
135 } // namespace prefetch
136 } // namespace gem5
associative_set_impl.hh
gem5::prefetch::SignaturePath
Definition: signature_path.hh:56
gem5::prefetch::SignaturePathV2::GlobalHistoryEntry::delta
stride_t delta
Definition: signature_path_v2.hh:64
gem5::prefetch::SignaturePathV2::SignaturePathV2
SignaturePathV2(const SignaturePathPrefetcherV2Params &p)
Definition: signature_path_v2.cc:43
gem5::GenericSatCounter::isSaturated
bool isSaturated() const
Whether the counter has achieved its maximum value or not.
Definition: sat_counter.hh:312
std::vector
STL vector class.
Definition: stl.hh:37
signature_path_v2.hh
gem5::prefetch::SignaturePathV2::GlobalHistoryEntry
Global History Register entry datatype.
Definition: signature_path_v2.hh:59
gem5::GenericSatCounter::counter
T counter
Definition: sat_counter.hh:331
gem5::prefetch::SignaturePathV2::handleSignatureTableMiss
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...
Definition: signature_path_v2.cc:54
gem5::prefetch::SignaturePathV2::increasePatternEntryCounter
void increasePatternEntryCounter(PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry) override
Increases the counter of a given PatternEntry/PatternStrideEntry.
Definition: signature_path_v2.cc:99
gem5::prefetch::SignaturePath::signature_t
uint16_t signature_t
Signature type.
Definition: signature_path.hh:60
gem5::prefetch::SignaturePathV2::GlobalHistoryEntry::lastBlock
stride_t lastBlock
Definition: signature_path_v2.hh:63
gem5::prefetch::SignaturePath::PatternEntry::counter
SatCounter8 counter
use counter, used by SPPv2
Definition: signature_path.hh:104
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::prefetch::SignaturePathV2::GlobalHistoryEntry::confidence
double confidence
Definition: signature_path_v2.hh:62
gem5::prefetch::SignaturePathV2::calculatePrefetchConfidence
double calculatePrefetchConfidence(PatternEntry const &sig, PatternStrideEntry const &lookahead) const override
Computes the prefetch confidence of the provided pattern entry.
Definition: signature_path_v2.cc:91
gem5::prefetch::Base::usefulPrefetches
uint64_t usefulPrefetches
Total prefetches that has been useful.
Definition: base.hh:364
gem5::prefetch::SignaturePathV2::globalHistoryRegister
AssociativeSet< GlobalHistoryEntry > globalHistoryRegister
Global History Register.
Definition: signature_path_v2.hh:69
gem5::prefetch::SignaturePath::stride_t
int16_t stride_t
Stride type.
Definition: signature_path.hh:62
gem5::prefetch::SignaturePath::PatternStrideEntry
A stride entry with its counter.
Definition: signature_path.hh:89
gem5::prefetch::SignaturePathV2::calculateLookaheadConfidence
double calculateLookaheadConfidence(PatternEntry const &sig, PatternStrideEntry const &lookahead) const override
Computes the lookahead path confidence of the provided pattern entry.
Definition: signature_path_v2.cc:82
gem5::prefetch::Base::issuedPrefetches
uint64_t issuedPrefetches
Total prefetches issued.
Definition: base.hh:362
gem5::prefetch::SignaturePath::PatternEntry
Pattern entry data type, a set of stride and counter entries.
Definition: signature_path.hh:99
gem5::prefetch::SignaturePathV2::GlobalHistoryEntry::signature
signature_t signature
Definition: signature_path_v2.hh:61
gem5::prefetch::SignaturePath::PatternEntry::strideEntries
std::vector< PatternStrideEntry > strideEntries
group of stides
Definition: signature_path.hh:102
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::prefetch::SignaturePathV2::handlePageCrossingLookahead
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.
Definition: signature_path_v2.cc:119
gem5::prefetch::SignaturePath::PatternStrideEntry::counter
SatCounter8 counter
Saturating counter.
Definition: signature_path.hh:94

Generated on Sun Jul 30 2023 01:56:57 for gem5 by doxygen 1.8.17