gem5  v22.0.0.2
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
gem5::curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
gem5::replacement_policy::Base::Params
BaseReplacementPolicyParams Params
Definition: base.hh:58
cur_tick.hh
std::vector
STL vector class.
Definition: stl.hh:37
gem5::replacement_policy::MRU::getVictim
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using access timestamps.
Definition: mru_rp.cc:74
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::replacement_policy::MRU::MRUReplData
MRU-specific implementation of replacement data.
Definition: mru_rp.hh:55
mru_rp.hh
Copyright (c) 2018-2020 Inria All rights reserved.
gem5::replacement_policy::Base
A common base class of cache replacement policy objects.
Definition: base.hh:55
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::replacement_policy::MRU::MRU
MRU(const Params &p)
Definition: mru_rp.cc:44
gem5::replacement_policy::MRU::reset
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: mru_rp.cc:66
gem5::replacement_policy::MRU::invalidate
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
gem5::ReplaceableEntry
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
Definition: replaceable_entry.hh:63
gem5::replacement_policy::MRU::touch
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: mru_rp.cc:58
gem5::replacement_policy::MRU::instantiateEntry
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition: mru_rp.cc:100
gem5::ReplaceableEntry::replacementData
std::shared_ptr< replacement_policy::ReplacementData > replacementData
Replacement data associated to this entry.
Definition: replaceable_entry.hh:84
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37

Generated on Thu Jul 28 2022 13:32:34 for gem5 by doxygen 1.8.17