gem5  v20.0.0.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 
38 {
39 }
40 
41 void
42 FIFORP::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
43 const
44 {
45  // Reset insertion tick
46  std::static_pointer_cast<FIFOReplData>(
47  replacement_data)->tickInserted = Tick(0);
48 }
49 
50 void
51 FIFORP::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
52 {
53  // A touch does not modify the insertion tick
54 }
55 
56 void
57 FIFORP::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
58 {
59  // Set insertion tick
60  std::static_pointer_cast<FIFOReplData>(
61  replacement_data)->tickInserted = curTick();
62 }
63 
65 FIFORP::getVictim(const ReplacementCandidates& candidates) const
66 {
67  // There must be at least one replacement candidate
68  assert(candidates.size() > 0);
69 
70  // Visit all candidates to find victim
71  ReplaceableEntry* victim = candidates[0];
72  for (const auto& candidate : candidates) {
73  // Update victim entry if necessary
74  if (std::static_pointer_cast<FIFOReplData>(
75  candidate->replacementData)->tickInserted <
76  std::static_pointer_cast<FIFOReplData>(
77  victim->replacementData)->tickInserted) {
78  victim = candidate;
79  }
80  }
81 
82  return victim;
83 }
84 
85 std::shared_ptr<ReplacementData>
87 {
88  return std::shared_ptr<ReplacementData>(new FIFOReplData());
89 }
90 
91 FIFORP*
92 FIFORPParams::create()
93 {
94  return new FIFORP(this);
95 }
BaseReplacementPolicyParams Params
Convenience typedef.
Definition: base.hh:52
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:42
A common base class of cache replacement policy objects.
Definition: base.hh:46
STL vector class.
Definition: stl.hh:37
Tick curTick()
The current simulated tick.
Definition: core.hh:44
FIFORP(const Params *p)
Construct and initiliaze this replacement policy.
Definition: fifo_rp.cc:36
uint64_t Tick
Tick count type.
Definition: types.hh:61
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: fifo_rp.cc:51
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using insertion timestamps.
Definition: fifo_rp.cc:65
FIFO-specific implementation of replacement data.
Definition: fifo_rp.hh:48
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
Copyright (c) 2018 Inria All rights reserved.
Bitfield< 0 > p
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: fifo_rp.cc:57
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition: fifo_rp.cc:86

Generated on Thu May 28 2020 16:21:34 for gem5 by doxygen 1.8.13