gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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/core.hh"
36 
37 namespace ReplacementPolicy {
38 
40  : Base(p)
41 {
42 }
43 
44 void
45 FIFO::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
46 const
47 {
48  // Reset insertion tick
49  std::static_pointer_cast<FIFOReplData>(
50  replacement_data)->tickInserted = Tick(0);
51 }
52 
53 void
54 FIFO::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
55 {
56  // A touch does not modify the insertion tick
57 }
58 
59 void
60 FIFO::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
61 {
62  // Set insertion tick
63  std::static_pointer_cast<FIFOReplData>(
64  replacement_data)->tickInserted = curTick();
65 }
66 
68 FIFO::getVictim(const ReplacementCandidates& candidates) const
69 {
70  // There must be at least one replacement candidate
71  assert(candidates.size() > 0);
72 
73  // Visit all candidates to find victim
74  ReplaceableEntry* victim = candidates[0];
75  for (const auto& candidate : candidates) {
76  // Update victim entry if necessary
77  if (std::static_pointer_cast<FIFOReplData>(
78  candidate->replacementData)->tickInserted <
79  std::static_pointer_cast<FIFOReplData>(
80  victim->replacementData)->tickInserted) {
81  victim = candidate;
82  }
83  }
84 
85  return victim;
86 }
87 
88 std::shared_ptr<ReplacementData>
90 {
91  return std::shared_ptr<ReplacementData>(new FIFOReplData());
92 }
93 
94 } // namespace ReplacementPolicy
ReplacementPolicy::FIFO::instantiateEntry
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition: fifo_rp.cc:89
ReplaceableEntry
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
Definition: replaceable_entry.hh:57
ReplacementPolicy::FIFO::FIFOReplData
FIFO-specific implementation of replacement data.
Definition: fifo_rp.hh:50
fifo_rp.hh
Copyright (c) 2018-2020 Inria All rights reserved.
ReplacementPolicy::FIFO::reset
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: fifo_rp.cc:60
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
std::vector
STL vector class.
Definition: stl.hh:37
ReplacementPolicy
Copyright (c) 2018-2020 Inria All rights reserved.
Definition: stride.hh:64
ReplacementPolicy::Base::Params
BaseReplacementPolicyParams Params
Definition: base.hh:51
ReplacementPolicy::Base
A common base class of cache replacement policy objects.
Definition: base.hh:48
ReplaceableEntry::replacementData
std::shared_ptr< ReplacementPolicy::ReplacementData > replacementData
Replacement data associated to this entry.
Definition: replaceable_entry.hh:78
core.hh
ReplacementPolicy::FIFO::touch
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: fifo_rp.cc:54
ReplacementPolicy::FIFO::FIFO
FIFO(const Params &p)
Definition: fifo_rp.cc:39
ReplacementPolicy::FIFO::getVictim
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using insertion timestamps.
Definition: fifo_rp.cc:68
ReplacementPolicy::FIFO::invalidate
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) const override
Invalidate replacement data to set it as the next probable victim.
Definition: fifo_rp.cc:45
curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:43
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323

Generated on Tue Jun 22 2021 15:28:29 for gem5 by doxygen 1.8.17