gem5  v22.1.0.0
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 
36 namespace gem5
37 {
38 
39 namespace replacement_policy
40 {
41 
43  : BRRIPReplData(num_bits), signature(0), outcome(false)
44 {
45 }
46 
49 {
50  return signature;
51 }
52 
53 void
55 {
56  signature = new_signature;
57  outcome = false;
58 }
59 
60 void
62 {
63  outcome = true;
64 }
65 
66 bool
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 
78 void
79 SHiP::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 
93 void
94 SHiP::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 
109 void
110 SHiP::touch(const std::shared_ptr<ReplacementData>& replacement_data)
111  const
112 {
113  panic("Cant train SHiP's predictor without access information.");
114 }
115 
116 void
117 SHiP::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 
137 void
138 SHiP::reset(const std::shared_ptr<ReplacementData>& replacement_data)
139  const
140 {
141  panic("Cant train SHiP's predictor without access information.");
142 }
143 
144 std::shared_ptr<ReplacementData>
146 {
147  return std::shared_ptr<ReplacementData>(new SHiPReplData(numRRPVBits));
148 }
149 
150 SHiPMem::SHiPMem(const SHiPMemRPParams &p) : SHiP(p) {}
151 
154 {
155  return static_cast<SignatureType>(pkt->getAddr() % SHCT.size());
156 }
157 
158 SHiPPC::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:294
Addr getAddr() const
Definition: packet.hh:805
RequestPtr req
A pointer to the original request.
Definition: packet.hh:376
const unsigned numRRPVBits
Number of RRPV bits.
Definition: brrip_rp.hh:100
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:53
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: brrip_rp.cc:63
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: brrip_rp.cc:79
BaseReplacementPolicyParams Params
Definition: base.hh:58
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:180
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:65
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.
SHiP(const Params &p)
Definition: ship_rp.cc:72
const double insertionThreshold
Saturation percentage at which an entry starts being inserted as intermediate re-reference.
Definition: ship_rp.hh:101
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:108
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:178
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Copyright (c) 2019, 2020 Inria All rights reserved.
BRRIP-specific implementation of replacement data.
Definition: brrip_rp.hh:72

Generated on Wed Dec 21 2022 10:22:36 for gem5 by doxygen 1.9.1