gem5  v21.2.1.1
lfu_rp.cc
Go to the documentation of this file.
1 
30 
31 #include <cassert>
32 #include <memory>
33 
34 #include "params/LFURP.hh"
35 
36 namespace gem5
37 {
38 
39 GEM5_DEPRECATED_NAMESPACE(ReplacementPolicy, replacement_policy);
40 namespace replacement_policy
41 {
42 
43 LFU::LFU(const Params &p)
44  : Base(p)
45 {
46 }
47 
48 void
49 LFU::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
50 {
51  // Reset reference count
52  std::static_pointer_cast<LFUReplData>(replacement_data)->refCount = 0;
53 }
54 
55 void
56 LFU::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
57 {
58  // Update reference count
59  std::static_pointer_cast<LFUReplData>(replacement_data)->refCount++;
60 }
61 
62 void
63 LFU::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
64 {
65  // Reset reference count
66  std::static_pointer_cast<LFUReplData>(replacement_data)->refCount = 1;
67 }
68 
70 LFU::getVictim(const ReplacementCandidates& candidates) const
71 {
72  // There must be at least one replacement candidate
73  assert(candidates.size() > 0);
74 
75  // Visit all candidates to find victim
76  ReplaceableEntry* victim = candidates[0];
77  for (const auto& candidate : candidates) {
78  // Update victim entry if necessary
79  if (std::static_pointer_cast<LFUReplData>(
80  candidate->replacementData)->refCount <
81  std::static_pointer_cast<LFUReplData>(
82  victim->replacementData)->refCount) {
83  victim = candidate;
84  }
85  }
86 
87  return victim;
88 }
89 
90 std::shared_ptr<ReplacementData>
92 {
93  return std::shared_ptr<ReplacementData>(new LFUReplData());
94 }
95 
96 } // namespace replacement_policy
97 } // namespace gem5
gem5::replacement_policy::Base::Params
BaseReplacementPolicyParams Params
Definition: base.hh:58
gem5::replacement_policy::LFU::invalidate
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
Definition: lfu_rp.cc:49
lfu_rp.hh
Copyright (c) 2018-2020 Inria All rights reserved.
gem5::replacement_policy::LFU::instantiateEntry
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition: lfu_rp.cc:91
std::vector
STL vector class.
Definition: stl.hh:37
gem5::replacement_policy::LFU::reset
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: lfu_rp.cc:63
gem5::replacement_policy::LFU::LFU
LFU(const Params &p)
Definition: lfu_rp.cc:43
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::replacement_policy::LFU::getVictim
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using reference frequency.
Definition: lfu_rp.cc:70
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::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::LFU::LFUReplData
LFU-specific implementation of replacement data.
Definition: lfu_rp.hh:55
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: tlb.cc:60
gem5::replacement_policy::LFU::touch
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: lfu_rp.cc:56

Generated on Wed May 4 2022 12:13:59 for gem5 by doxygen 1.8.17