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

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