gem5  v20.1.0.0
mru_rp.cc
Go to the documentation of this file.
1 
30 
31 #include <cassert>
32 #include <memory>
33 
34 #include "params/MRURP.hh"
35 #include "sim/core.hh"
36 
39 {
40 }
41 
42 void
43 MRURP::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
44 const
45 {
46  // Reset last touch timestamp
47  std::static_pointer_cast<MRUReplData>(
48  replacement_data)->lastTouchTick = Tick(0);
49 }
50 
51 void
52 MRURP::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
53 {
54  // Update last touch timestamp
55  std::static_pointer_cast<MRUReplData>(
56  replacement_data)->lastTouchTick = curTick();
57 }
58 
59 void
60 MRURP::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
61 {
62  // Set last touch timestamp
63  std::static_pointer_cast<MRUReplData>(
64  replacement_data)->lastTouchTick = curTick();
65 }
66 
68 MRURP::getVictim(const ReplacementCandidates& candidates) const
69 {
70  // There must be at least one replacement candidate
71  assert(candidates.size() > 0);
72 
73  // Visit all candidates to find victim
74  ReplaceableEntry* victim = candidates[0];
75  for (const auto& candidate : candidates) {
76  std::shared_ptr<MRUReplData> candidate_replacement_data =
77  std::static_pointer_cast<MRUReplData>(candidate->replacementData);
78 
79  // Stop searching entry if a cache line that doesn't warm up is found.
80  if (candidate_replacement_data->lastTouchTick == 0) {
81  victim = candidate;
82  break;
83  } else if (candidate_replacement_data->lastTouchTick >
84  std::static_pointer_cast<MRUReplData>(
85  victim->replacementData)->lastTouchTick) {
86  victim = candidate;
87  }
88  }
89 
90  return victim;
91 }
92 
93 std::shared_ptr<ReplacementData>
95 {
96  return std::shared_ptr<ReplacementData>(new MRUReplData());
97 }
98 
99 MRURP*
100 MRURPParams::create()
101 {
102  return new MRURP(this);
103 }
ReplaceableEntry
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
Definition: replaceable_entry.hh:53
BaseReplacementPolicy::Params
BaseReplacementPolicyParams Params
Convenience typedef.
Definition: base.hh:52
MRURP
Definition: mru_rp.hh:44
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
std::vector
STL vector class.
Definition: stl.hh:37
MRURP::invalidate
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) const override
Invalidate replacement data to set it as the next probable victim.
Definition: mru_rp.cc:43
BaseReplacementPolicy
A common base class of cache replacement policy objects.
Definition: base.hh:46
MRURP::instantiateEntry
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition: mru_rp.cc:94
mru_rp.hh
Copyright (c) 2018 Inria All rights reserved.
core.hh
MRURP::getVictim
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using access timestamps.
Definition: mru_rp.cc:68
MRURP::MRUReplData
MRU-specific implementation of replacement data.
Definition: mru_rp.hh:48
MRURP::touch
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: mru_rp.cc:52
ReplaceableEntry::replacementData
std::shared_ptr< ReplacementData > replacementData
Replacement data associated to this entry.
Definition: replaceable_entry.hh:74
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
MRURP::reset
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: mru_rp.cc:60
MRURP::MRURP
MRURP(const Params *p)
Construct and initiliaze this replacement policy.
Definition: mru_rp.cc:37
curTick
Tick curTick()
The current simulated tick.
Definition: core.hh:45

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