gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
36namespace gem5
37{
38
39namespace replacement_policy
40{
41
43 : Base(p)
44{
45}
46
47void
48LFU::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
49{
50 // Reset reference count
51 std::static_pointer_cast<LFUReplData>(replacement_data)->refCount = 0;
52}
53
54void
55LFU::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
56{
57 // Update reference count
58 std::static_pointer_cast<LFUReplData>(replacement_data)->refCount++;
59}
60
61void
62LFU::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
63{
64 // Reset reference count
65 std::static_pointer_cast<LFUReplData>(replacement_data)->refCount = 1;
66}
67
69LFU::getVictim(const ReplacementCandidates& candidates) const
70{
71 // There must be at least one replacement candidate
72 assert(candidates.size() > 0);
73
74 // Visit all candidates to find victim
75 ReplaceableEntry* victim = candidates[0];
76 for (const auto& candidate : candidates) {
77 // Update victim entry if necessary
78 if (std::static_pointer_cast<LFUReplData>(
79 candidate->replacementData)->refCount <
80 std::static_pointer_cast<LFUReplData>(
81 victim->replacementData)->refCount) {
82 victim = candidate;
83 }
84 }
85
86 return victim;
87}
88
89std::shared_ptr<ReplacementData>
91{
92 return std::shared_ptr<ReplacementData>(new LFUReplData());
93}
94
95} // namespace replacement_policy
96} // 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:55
LFU(const Params &p)
Definition lfu_rp.cc:42
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition lfu_rp.cc:90
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:48
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition lfu_rp.cc:55
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using reference frequency.
Definition lfu_rp.cc:69
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition lfu_rp.cc:62
STL vector class.
Definition stl.hh:37
Copyright (c) 2018-2020 Inria All rights reserved.
Bitfield< 0 > p
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
LFU-specific implementation of replacement data.
Definition lfu_rp.hh:55

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0