gem5  v22.1.0.0
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 
37 namespace gem5
38 {
39 
40 GEM5_DEPRECATED_NAMESPACE(ReplacementPolicy, replacement_policy);
41 namespace replacement_policy
42 {
43 
45  : Base(p)
46 {
47 }
48 
49 void
50 FIFO::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
51 {
52  // Reset insertion tick
53  std::static_pointer_cast<FIFOReplData>(
54  replacement_data)->tickInserted = Tick(0);
55 }
56 
57 void
58 FIFO::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
59 {
60  // A touch does not modify the insertion tick
61 }
62 
63 void
64 FIFO::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
65 {
66  // Set insertion tick
67  std::static_pointer_cast<FIFOReplData>(
68  replacement_data)->tickInserted = curTick();
69 }
70 
72 FIFO::getVictim(const ReplacementCandidates& candidates) const
73 {
74  // There must be at least one replacement candidate
75  assert(candidates.size() > 0);
76 
77  // Visit all candidates to find victim
78  ReplaceableEntry* victim = candidates[0];
79  for (const auto& candidate : candidates) {
80  // Update victim entry if necessary
81  if (std::static_pointer_cast<FIFOReplData>(
82  candidate->replacementData)->tickInserted <
83  std::static_pointer_cast<FIFOReplData>(
84  victim->replacementData)->tickInserted) {
85  victim = candidate;
86  }
87  }
88 
89  return victim;
90 }
91 
92 std::shared_ptr<ReplacementData>
94 {
95  return std::shared_ptr<ReplacementData>(new FIFOReplData());
96 }
97 
98 } // namespace replacement_policy
99 } // 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:56
BaseReplacementPolicyParams Params
Definition: base.hh:58
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: fifo_rp.cc:64
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition: fifo_rp.cc:93
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using insertion timestamps.
Definition: fifo_rp.cc:72
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:50
FIFO(const Params &p)
Definition: fifo_rp.cc:44
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: fifo_rp.cc:58
STL vector class.
Definition: stl.hh:37
Copyright (c) 2018-2020 Inria All rights reserved.
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
uint64_t Tick
Tick count type.
Definition: types.hh:58
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
FIFO-specific implementation of replacement data.
Definition: fifo_rp.hh:56

Generated on Wed Dec 21 2022 10:22:36 for gem5 by doxygen 1.9.1