gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
37namespace gem5
38{
39
40namespace replacement_policy
41{
42
44 : Base(p)
45{
46}
47
48void
49MRU::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
50{
51 // Reset last touch timestamp
52 std::static_pointer_cast<MRUReplData>(
53 replacement_data)->lastTouchTick = Tick(0);
54}
55
56void
57MRU::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
58{
59 // Update last touch timestamp
60 std::static_pointer_cast<MRUReplData>(
61 replacement_data)->lastTouchTick = curTick();
62}
63
64void
65MRU::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
66{
67 // Set last touch timestamp
68 std::static_pointer_cast<MRUReplData>(
69 replacement_data)->lastTouchTick = curTick();
70}
71
73MRU::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 std::shared_ptr<MRUReplData> candidate_replacement_data =
82 std::static_pointer_cast<MRUReplData>(candidate->replacementData);
83
84 // Stop searching entry if a cache line that doesn't warm up is found.
85 if (candidate_replacement_data->lastTouchTick == 0) {
86 victim = candidate;
87 break;
88 } else if (candidate_replacement_data->lastTouchTick >
89 std::static_pointer_cast<MRUReplData>(
90 victim->replacementData)->lastTouchTick) {
91 victim = candidate;
92 }
93 }
94
95 return victim;
96}
97
98std::shared_ptr<ReplacementData>
100{
101 return std::shared_ptr<ReplacementData>(new MRUReplData());
102}
103
104} // namespace replacement_policy
105} // 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
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using access timestamps.
Definition mru_rp.cc:73
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:49
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition mru_rp.cc:99
MRU(const Params &p)
Definition mru_rp.cc:43
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition mru_rp.cc:65
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition mru_rp.cc:57
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
MRU-specific implementation of replacement data.
Definition mru_rp.hh:55

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