gem5  v21.2.1.1
lru_rp.cc
Go to the documentation of this file.
1 
30 
31 #include <cassert>
32 #include <memory>
33 
34 #include "params/LRURP.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 LRU::LRU(const Params &p)
45  : Base(p)
46 {
47 }
48 
49 void
50 LRU::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
51 {
52  // Reset last touch timestamp
53  std::static_pointer_cast<LRUReplData>(
54  replacement_data)->lastTouchTick = Tick(0);
55 }
56 
57 void
58 LRU::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
59 {
60  // Update last touch timestamp
61  std::static_pointer_cast<LRUReplData>(
62  replacement_data)->lastTouchTick = curTick();
63 }
64 
65 void
66 LRU::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
67 {
68  // Set last touch timestamp
69  std::static_pointer_cast<LRUReplData>(
70  replacement_data)->lastTouchTick = curTick();
71 }
72 
74 LRU::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  // Update victim entry if necessary
83  if (std::static_pointer_cast<LRUReplData>(
84  candidate->replacementData)->lastTouchTick <
85  std::static_pointer_cast<LRUReplData>(
86  victim->replacementData)->lastTouchTick) {
87  victim = candidate;
88  }
89  }
90 
91  return victim;
92 }
93 
94 std::shared_ptr<ReplacementData>
96 {
97  return std::shared_ptr<ReplacementData>(new LRUReplData());
98 }
99 
100 } // namespace replacement_policy
101 } // namespace gem5
gem5::curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
gem5::replacement_policy::LRU::instantiateEntry
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition: lru_rp.cc:95
gem5::replacement_policy::LRU::LRU
LRU(const Params &p)
Definition: lru_rp.cc:44
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::LRU::LRUReplData
LRU-specific implementation of replacement data.
Definition: lru_rp.hh:53
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
lru_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::LRU::touch
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: lru_rp.cc:58
gem5::replacement_policy::LRU::reset
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: lru_rp.cc:66
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::LRU::getVictim
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using LRU timestamps.
Definition: lru_rp.cc:74
gem5::ReplaceableEntry::replacementData
std::shared_ptr< replacement_policy::ReplacementData > replacementData
Replacement data associated to this entry.
Definition: replaceable_entry.hh:84
gem5::replacement_policy::LRU::invalidate
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
Definition: lru_rp.cc:50
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60

Generated on Wed May 4 2022 12:14:00 for gem5 by doxygen 1.8.17