gem5 v24.1.0.1
Loading...
Searching...
No Matches
signature_path_v2.cc
Go to the documentation of this file.
1
42
43#include <cassert>
44
45#include "debug/HWPrefetch.hh"
46#include "params/SignaturePathPrefetcherV2.hh"
47
48namespace gem5
49{
50
51namespace prefetch
52{
53
54SignaturePathV2::SignaturePathV2(const SignaturePathPrefetcherV2Params &p)
56 globalHistoryRegister((name() + ".GlobalHistoryRegister").c_str(),
57 p.global_history_register_entries,
58 p.global_history_register_entries,
59 p.global_history_register_replacement_policy,
60 p.global_history_register_indexing_policy,
62 genTagExtractor(p.global_history_register_indexing_policy)))
63{
64}
65
66void
68 signature_t &new_signature, double &new_conf, stride_t &new_stride)
69{
70 bool found = false;
71
72 // This should return all entries of the GHR, since it is a fully
73 // associative table
74 for (auto &gh_entry : globalHistoryRegister) {
75 if (gh_entry.lastBlock + gh_entry.delta == current_block) {
76 new_signature = gh_entry.signature;
77 new_conf = gh_entry.confidence;
78 new_stride = gh_entry.delta;
79 found = true;
80 globalHistoryRegister.accessEntry(&gh_entry);
81 break;
82 }
83 }
84 if (!found) {
85 new_signature = current_block;
86 new_conf = 1.0;
87 new_stride = current_block;
88 }
89}
90
91double
93 PatternEntry const &sig, PatternStrideEntry const &lookahead) const
94{
95 if (sig.counter == 0) return 0.0;
96 return (((double) usefulPrefetches) / issuedPrefetches) *
97 (((double) lookahead.counter) / sig.counter);
98}
99
100double
102 PatternStrideEntry const &entry) const
103{
104 if (sig.counter == 0) return 0.0;
105 return ((double) entry.counter) / sig.counter;
106}
107
108void
110 PatternEntry &pattern_entry, PatternStrideEntry &pstride_entry)
111{
112 if (pattern_entry.counter.isSaturated()) {
113 pattern_entry.counter >>= 1;
114 for (auto &entry : pattern_entry.strideEntries) {
115 entry.counter >>= 1;
116 }
117 }
118 if (pstride_entry.counter.isSaturated()) {
119 pattern_entry.counter >>= 1;
120 for (auto &entry : pattern_entry.strideEntries) {
121 entry.counter >>= 1;
122 }
123 }
124 pattern_entry.counter++;
125 pstride_entry.counter++;
126}
127
128void
130 stride_t last_offset, stride_t delta, double path_confidence)
131{
132 // Always use the replacement policy to assign new entries, as all
133 // of them are unique, there are never "hits" in the GHR
134 const GlobalHistoryEntry::KeyType key{0, false};
135 GlobalHistoryEntry *gh_entry = globalHistoryRegister.findVictim(key);
136 assert(gh_entry != nullptr);
137 // Any address value works, as it is never used
138 globalHistoryRegister.insertEntry(key, gh_entry);
139
140 gh_entry->signature = signature;
141 gh_entry->lastBlock = last_offset;
142 gh_entry->delta = delta;
143 gh_entry->confidence = path_confidence;
144}
145
146} // namespace prefetch
147} // namespace gem5
uint64_t issuedPrefetches
Total prefetches issued.
Definition base.hh:372
uint64_t usefulPrefetches
Total prefetches that has been useful.
Definition base.hh:374
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.
AssociativeCache< GlobalHistoryEntry > globalHistoryRegister
Global History Register.
uint16_t signature_t
Signature type.
bool isSaturated() const
Whether the counter has achieved its maximum value or not.
Bitfield< 0 > p
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
static constexpr auto genTagExtractor(BTBIndexingPolicy *ip)
This helper generates a tag extractor function object which will be typically used by Replaceable ent...
Definition btb_entry.hh:281
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
const std::string & name()
Definition trace.cc:48

Generated on Mon Jan 13 2025 04:28:38 for gem5 by doxygen 1.9.8