gem5 v24.0.0.0
Loading...
Searching...
No Matches
ship_rp.cc
Go to the documentation of this file.
1
30
31#include "base/logging.hh"
32#include "params/SHiPMemRP.hh"
33#include "params/SHiPPCRP.hh"
34#include "params/SHiPRP.hh"
35
36namespace gem5
37{
38
39namespace replacement_policy
40{
41
43 : BRRIPReplData(num_bits), signature(0), outcome(false)
44{
45}
46
49{
50 return signature;
51}
52
53void
55{
56 signature = new_signature;
57 outcome = false;
58}
59
60void
62{
63 outcome = true;
64}
65
66bool
68{
69 return outcome;
70}
71
73 : BRRIP(p), insertionThreshold(p.insertion_threshold / 100.0),
74 SHCT(p.shct_size, SatCounter8(numRRPVBits))
75{
76}
77
78void
79SHiP::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
80{
81 std::shared_ptr<SHiPReplData> casted_replacement_data =
82 std::static_pointer_cast<SHiPReplData>(replacement_data);
83
84 // The predictor is detrained when an entry that has not been re-
85 // referenced since insertion is invalidated
86 if (casted_replacement_data->wasReReferenced()) {
87 SHCT[casted_replacement_data->getSignature()]--;
88 }
89
90 BRRIP::invalidate(replacement_data);
91}
92
93void
94SHiP::touch(const std::shared_ptr<ReplacementData>& replacement_data,
95 const PacketPtr pkt)
96{
97 std::shared_ptr<SHiPReplData> casted_replacement_data =
98 std::static_pointer_cast<SHiPReplData>(replacement_data);
99
100 // When a hit happens the SHCT entry indexed by the signature is
101 // incremented
102 SHCT[getSignature(pkt)]++;
103 casted_replacement_data->setReReferenced();
104
105 // This was a hit; update replacement data accordingly
106 BRRIP::touch(replacement_data);
107}
108
109void
110SHiP::touch(const std::shared_ptr<ReplacementData>& replacement_data)
111 const
112{
113 panic("Cant train SHiP's predictor without access information.");
114}
115
116void
117SHiP::reset(const std::shared_ptr<ReplacementData>& replacement_data,
118 const PacketPtr pkt)
119{
120 std::shared_ptr<SHiPReplData> casted_replacement_data =
121 std::static_pointer_cast<SHiPReplData>(replacement_data);
122
123 // Get signature
124 const SignatureType signature = getSignature(pkt);
125
126 // Store signature
127 casted_replacement_data->setSignature(signature);
128
129 // If SHCT for signature is set, predict intermediate re-reference.
130 // Predict distant re-reference otherwise
131 BRRIP::reset(replacement_data);
132 if (SHCT[signature].calcSaturation() >= insertionThreshold) {
133 casted_replacement_data->rrpv--;
134 }
135}
136
137void
138SHiP::reset(const std::shared_ptr<ReplacementData>& replacement_data)
139 const
140{
141 panic("Cant train SHiP's predictor without access information.");
142}
143
144std::shared_ptr<ReplacementData>
146{
147 return std::shared_ptr<ReplacementData>(new SHiPReplData(numRRPVBits));
148}
149
150SHiPMem::SHiPMem(const SHiPMemRPParams &p) : SHiP(p) {}
151
154{
155 return static_cast<SignatureType>(pkt->getAddr() % SHCT.size());
156}
157
158SHiPPC::SHiPPC(const SHiPPCRPParams &p) : SHiP(p) {}
159
162{
163 SignatureType signature;
164
165 if (pkt->req->hasPC()) {
166 signature = static_cast<SignatureType>(pkt->req->getPC());
167 } else {
168 signature = NO_PC_SIGNATURE;
169 }
170
171 return signature % SHCT.size();
172}
173
174} // namespace replacement_policy
175} // namespace gem5
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Addr getAddr() const
Definition packet.hh:807
RequestPtr req
A pointer to the original request.
Definition packet.hh:377
const unsigned numRRPVBits
Number of RRPV bits.
Definition brrip_rp.hh:99
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
Definition brrip_rp.cc:52
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition brrip_rp.cc:62
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition brrip_rp.cc:78
SHiPMem(const SHiPMemRPParams &p)
Definition ship_rp.cc:150
SignatureType getSignature(const PacketPtr pkt) const override
Extract signature from packet.
Definition ship_rp.cc:153
SHiPPC(const SHiPPCRPParams &p)
Definition ship_rp.cc:158
const SignatureType NO_PC_SIGNATURE
Signature to be used when no PC is provided in an access.
Definition ship_rp.hh:179
SignatureType getSignature(const PacketPtr pkt) const override
Extract signature from packet.
Definition ship_rp.cc:161
SHiP-specific implementation of replacement data.
Definition ship_rp.hh:64
SignatureType getSignature() const
Get entry's signature.
Definition ship_rp.cc:48
bool wasReReferenced() const
Get whether entry has been re-referenced since insertion.
Definition ship_rp.cc:67
void setSignature(SignatureType signature)
Set this entry's signature and reset outcome.
Definition ship_rp.cc:54
void setReReferenced()
Set that this entry has been re-referenced.
Definition ship_rp.cc:61
virtual SignatureType getSignature(const PacketPtr pkt) const =0
Extract signature from packet.
const double insertionThreshold
Saturation percentage at which an entry starts being inserted as intermediate re-reference.
Definition ship_rp.hh:100
void touch(const std::shared_ptr< ReplacementData > &replacement_data, const PacketPtr pkt) override
Touch an entry to update its replacement data.
Definition ship_rp.cc:94
void reset(const std::shared_ptr< ReplacementData > &replacement_data, const PacketPtr pkt) override
Reset replacement data.
Definition ship_rp.cc:117
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
Definition ship_rp.cc:79
std::vector< SatCounter8 > SHCT
Signature History Counter Table; learns the re-reference behavior of a signature.
Definition ship_rp.hh:107
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition ship_rp.cc:145
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 0 > p
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Copyright (c) 2019, 2020 Inria All rights reserved.
BRRIP-specific implementation of replacement data.
Definition brrip_rp.hh:71

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0