gem5  v20.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 Prefetcher {
38 
39 SignaturePathV2::SignaturePathV2(const SignaturePathPrefetcherV2Params *p)
40  : SignaturePath(p),
41  globalHistoryRegister(p->global_history_register_entries,
42  p->global_history_register_entries,
43  p->global_history_register_indexing_policy,
44  p->global_history_register_replacement_policy,
46 {
47 }
48 
49 void
51  signature_t &new_signature, double &new_conf, stride_t &new_stride)
52 {
53  bool found = false;
54 
55  // This should return all entries of the GHR, since it is a fully
56  // associative table
57  std::vector<GlobalHistoryEntry *> all_ghr_entries =
58  globalHistoryRegister.getPossibleEntries(0 /* any value works */);
59 
60  for (auto gh_entry : all_ghr_entries) {
61  if (gh_entry->lastBlock + gh_entry->delta == current_block) {
62  new_signature = gh_entry->signature;
63  new_conf = gh_entry->confidence;
64  new_stride = gh_entry->delta;
65  found = true;
66  globalHistoryRegister.accessEntry(gh_entry);
67  break;
68  }
69  }
70  if (!found) {
71  new_signature = current_block;
72  new_conf = 1.0;
73  new_stride = current_block;
74  }
75 }
76 
77 double
79  PatternEntry const &sig, PatternStrideEntry const &lookahead) const
80 {
81  if (sig.counter == 0) return 0.0;
82  return (((double) usefulPrefetches) / issuedPrefetches) *
83  (((double) lookahead.counter) / sig.counter);
84 }
85 
86 double
88  PatternStrideEntry const &entry) const
89 {
90  if (sig.counter == 0) return 0.0;
91  return ((double) entry.counter) / sig.counter;
92 }
93 
94 void
96  PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry)
97 {
98  if (pattern_entry.counter.isSaturated()) {
99  pattern_entry.counter >>= 1;
100  for (auto &entry : pattern_entry.strideEntries) {
101  entry.counter >>= 1;
102  }
103  }
104  if (pstride_entry.counter.isSaturated()) {
105  pattern_entry.counter >>= 1;
106  for (auto &entry : pattern_entry.strideEntries) {
107  entry.counter >>= 1;
108  }
109  }
110  pattern_entry.counter++;
111  pstride_entry.counter++;
112 }
113 
114 void
116  stride_t last_offset, stride_t delta, double path_confidence)
117 {
118  // Always use the replacement policy to assign new entries, as all
119  // of them are unique, there are never "hits" in the GHR
120  GlobalHistoryEntry *gh_entry = globalHistoryRegister.findVictim(0);
121  assert(gh_entry != nullptr);
122  // Any address value works, as it is never used
123  globalHistoryRegister.insertEntry(0, false, gh_entry);
124 
125  gh_entry->signature = signature;
126  gh_entry->lastBlock = last_offset;
127  gh_entry->delta = delta;
128  gh_entry->confidence = path_confidence;
129 }
130 
131 } // namespace Prefetcher
132 
134 SignaturePathPrefetcherV2Params::create()
135 {
136  return new Prefetcher::SignaturePathV2(this);
137 }
Prefetcher::SignaturePathV2::GlobalHistoryEntry::signature
signature_t signature
Definition: signature_path_v2.hh:57
associative_set_impl.hh
Prefetcher::SignaturePath::PatternStrideEntry
A stride entry with its counter.
Definition: signature_path.hh:85
Prefetcher::SignaturePathV2::GlobalHistoryEntry::lastBlock
stride_t lastBlock
Definition: signature_path_v2.hh:59
std::vector
STL vector class.
Definition: stl.hh:37
signature_path_v2.hh
Prefetcher::Base::usefulPrefetches
uint64_t usefulPrefetches
Total prefetches that has been useful.
Definition: base.hh:329
Prefetcher::SignaturePathV2::GlobalHistoryEntry::delta
stride_t delta
Definition: signature_path_v2.hh:60
Prefetcher::SignaturePathV2::GlobalHistoryEntry
Global History Register entry datatype.
Definition: signature_path_v2.hh:55
Prefetcher::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:87
Prefetcher::SignaturePath::stride_t
int16_t stride_t
Stride type.
Definition: signature_path.hh:58
Prefetcher::SignaturePath::PatternEntry
Pattern entry data type, a set of stride and counter entries.
Definition: signature_path.hh:95
SatCounter::isSaturated
bool isSaturated() const
Whether the counter has achieved its maximum value or not.
Definition: sat_counter.hh:306
Prefetcher::SignaturePath::PatternStrideEntry::counter
SatCounter counter
Saturating counter.
Definition: signature_path.hh:90
Prefetcher::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:115
Prefetcher
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
Definition: base.hh:78
Prefetcher::SignaturePath::PatternEntry::strideEntries
std::vector< PatternStrideEntry > strideEntries
group of stides
Definition: signature_path.hh:98
Prefetcher::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:50
Prefetcher::SignaturePathV2
Definition: signature_path_v2.hh:52
SatCounter::counter
uint8_t counter
Definition: sat_counter.hh:325
Prefetcher::Base::issuedPrefetches
uint64_t issuedPrefetches
Total prefetches issued.
Definition: base.hh:327
Prefetcher::SignaturePath
Definition: signature_path.hh:52
Prefetcher::SignaturePath::signature_t
uint16_t signature_t
Signature type.
Definition: signature_path.hh:56
Prefetcher::SignaturePathV2::GlobalHistoryEntry::confidence
double confidence
Definition: signature_path_v2.hh:58
Prefetcher::SignaturePathV2::globalHistoryRegister
AssociativeSet< GlobalHistoryEntry > globalHistoryRegister
Global History Register.
Definition: signature_path_v2.hh:65
Prefetcher::SignaturePath::PatternEntry::counter
SatCounter counter
use counter, used by SPPv2
Definition: signature_path.hh:100
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Prefetcher::SignaturePathV2::increasePatternEntryCounter
void increasePatternEntryCounter(PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry) override
Increases the counter of a given PatternEntry/PatternStrideEntry.
Definition: signature_path_v2.cc:95
Prefetcher::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:78
Prefetcher::SignaturePathV2::SignaturePathV2
SignaturePathV2(const SignaturePathPrefetcherV2Params *p)
Definition: signature_path_v2.cc:39

Generated on Wed Sep 30 2020 14:02:12 for gem5 by doxygen 1.8.17