gem5  v22.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/cur_tick.hh"
36 
37 namespace gem5
38 {
39 
40 GEM5_DEPRECATED_NAMESPACE(ReplacementPolicy, replacement_policy);
41 namespace replacement_policy
42 {
43 
44 MRU::MRU(const Params &p)
45  : Base(p)
46 {
47 }
48 
49 void
50 MRU::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
51 {
52  // Reset last touch timestamp
53  std::static_pointer_cast<MRUReplData>(
54  replacement_data)->lastTouchTick = Tick(0);
55 }
56 
57 void
58 MRU::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
59 {
60  // Update last touch timestamp
61  std::static_pointer_cast<MRUReplData>(
62  replacement_data)->lastTouchTick = curTick();
63 }
64 
65 void
66 MRU::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
67 {
68  // Set last touch timestamp
69  std::static_pointer_cast<MRUReplData>(
70  replacement_data)->lastTouchTick = curTick();
71 }
72 
74 MRU::getVictim(const ReplacementCandidates& candidates) const
75 {
76  // There must be at least one replacement candidate
77  assert(candidates.size() > 0);
78 
79  // Visit all candidates to find victim
80  ReplaceableEntry* victim = candidates[0];
81  for (const auto& candidate : candidates) {
82  std::shared_ptr<MRUReplData> candidate_replacement_data =
83  std::static_pointer_cast<MRUReplData>(candidate->replacementData);
84 
85  // Stop searching entry if a cache line that doesn't warm up is found.
86  if (candidate_replacement_data->lastTouchTick == 0) {
87  victim = candidate;
88  break;
89  } else if (candidate_replacement_data->lastTouchTick >
90  std::static_pointer_cast<MRUReplData>(
91  victim->replacementData)->lastTouchTick) {
92  victim = candidate;
93  }
94  }
95 
96  return victim;
97 }
98 
99 std::shared_ptr<ReplacementData>
101 {
102  return std::shared_ptr<ReplacementData>(new MRUReplData());
103 }
104 
105 } // namespace replacement_policy
106 } // namespace gem5
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
std::shared_ptr< replacement_policy::ReplacementData > replacementData
Replacement data associated to this entry.
A common base class of cache replacement policy objects.
Definition: base.hh:56
BaseReplacementPolicyParams Params
Definition: base.hh:58
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using access timestamps.
Definition: mru_rp.cc:74
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
Definition: mru_rp.cc:50
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition: mru_rp.cc:100
MRU(const Params &p)
Definition: mru_rp.cc:44
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: mru_rp.cc:66
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: mru_rp.cc:58
STL vector class.
Definition: stl.hh:37
Copyright (c) 2018-2020 Inria All rights reserved.
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
uint64_t Tick
Tick count type.
Definition: types.hh:58
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
MRU-specific implementation of replacement data.
Definition: mru_rp.hh:56

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