gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
37namespace gem5
38{
39
40namespace replacement_policy
41{
42
44 : Base(p)
45{
46}
47
48void
49LRU::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
50{
51 // Reset last touch timestamp
52 std::static_pointer_cast<LRUReplData>(
53 replacement_data)->lastTouchTick = Tick(0);
54}
55
56void
57LRU::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
58{
59 // Update last touch timestamp
60 std::static_pointer_cast<LRUReplData>(
61 replacement_data)->lastTouchTick = curTick();
62}
63
64void
65LRU::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
66{
67 // Set last touch timestamp
68 std::static_pointer_cast<LRUReplData>(
69 replacement_data)->lastTouchTick = curTick();
70}
71
73LRU::getVictim(const ReplacementCandidates& candidates) const
74{
75 // There must be at least one replacement candidate
76 assert(candidates.size() > 0);
77
78 // Visit all candidates to find victim
79 ReplaceableEntry* victim = candidates[0];
80 for (const auto& candidate : candidates) {
81 // Update victim entry if necessary
82 if (std::static_pointer_cast<LRUReplData>(
83 candidate->replacementData)->lastTouchTick <
84 std::static_pointer_cast<LRUReplData>(
85 victim->replacementData)->lastTouchTick) {
86 victim = candidate;
87 }
88 }
89
90 return victim;
91}
92
93std::shared_ptr<ReplacementData>
95{
96 return std::shared_ptr<ReplacementData>(new LRUReplData());
97}
98
99} // namespace replacement_policy
100} // 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
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition lru_rp.cc:65
LRU(const Params &p)
Definition lru_rp.cc:43
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition lru_rp.cc:57
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:49
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using LRU timestamps.
Definition lru_rp.cc:73
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition lru_rp.cc:94
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
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
uint64_t Tick
Tick count type.
Definition types.hh:58
LRU-specific implementation of replacement data.
Definition lru_rp.hh:53

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