gem5 v24.0.0.0
Loading...
Searching...
No Matches
fifo_rp.cc
Go to the documentation of this file.
1
30
31#include <cassert>
32#include <memory>
33
34#include "params/FIFORP.hh"
35#include "sim/cur_tick.hh"
36
37namespace gem5
38{
39
40namespace replacement_policy
41{
42
44 : Base(p)
45{
46}
47
48void
49FIFO::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
50{
51 // Reset insertion tick
52 std::static_pointer_cast<FIFOReplData>(
53 replacement_data)->tickInserted = ++timeTicks;
54}
55
56void
57FIFO::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
58{
59 // A touch does not modify the insertion tick
60}
61
62void
63FIFO::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
64{
65 // Set insertion tick
66 std::static_pointer_cast<FIFOReplData>(
67 replacement_data)->tickInserted = ++timeTicks;
68}
69
71FIFO::getVictim(const ReplacementCandidates& candidates) const
72{
73 // There must be at least one replacement candidate
74 assert(candidates.size() > 0);
75
76 // Visit all candidates to find victim
77 ReplaceableEntry* victim = candidates[0];
78 for (const auto& candidate : candidates) {
79 // Update victim entry if necessary
80 if (std::static_pointer_cast<FIFOReplData>(
81 candidate->replacementData)->tickInserted <
82 std::static_pointer_cast<FIFOReplData>(
83 victim->replacementData)->tickInserted) {
84 victim = candidate;
85 }
86 }
87
88 return victim;
89}
90
91std::shared_ptr<ReplacementData>
93{
94 return std::shared_ptr<ReplacementData>(new FIFOReplData());
95}
96
97} // namespace replacement_policy
98} // 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 fifo_rp.cc:63
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition fifo_rp.cc:92
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using insertion timestamps.
Definition fifo_rp.cc:71
Tick timeTicks
A counter that tracks the number of ticks since being created to avoid a tie.
Definition fifo_rp.hh:69
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
Definition fifo_rp.cc:49
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition fifo_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
FIFO-specific implementation of replacement data.
Definition fifo_rp.hh:55

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