gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lru_rp.cc
Go to the documentation of this file.
1 
32 
33 #include <cassert>
34 #include <memory>
35 
36 #include "params/LRURP.hh"
37 
40 {
41 }
42 
43 void
44 LRURP::invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
45 const
46 {
47  // Reset last touch timestamp
48  std::static_pointer_cast<LRUReplData>(
49  replacement_data)->lastTouchTick = Tick(0);
50 }
51 
52 void
53 LRURP::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
54 {
55  // Update last touch timestamp
56  std::static_pointer_cast<LRUReplData>(
57  replacement_data)->lastTouchTick = curTick();
58 }
59 
60 void
61 LRURP::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
62 {
63  // Set last touch timestamp
64  std::static_pointer_cast<LRUReplData>(
65  replacement_data)->lastTouchTick = curTick();
66 }
67 
69 LRURP::getVictim(const ReplacementCandidates& candidates) const
70 {
71  // There must be at least one replacement candidate
72  assert(candidates.size() > 0);
73 
74  // Visit all candidates to find victim
75  ReplaceableEntry* victim = candidates[0];
76  for (const auto& candidate : candidates) {
77  // Update victim entry if necessary
78  if (std::static_pointer_cast<LRUReplData>(
79  candidate->replacementData)->lastTouchTick <
80  std::static_pointer_cast<LRUReplData>(
81  victim->replacementData)->lastTouchTick) {
82  victim = candidate;
83  }
84  }
85 
86  return victim;
87 }
88 
89 std::shared_ptr<ReplacementData>
91 {
92  return std::shared_ptr<ReplacementData>(new LRUReplData());
93 }
94 
95 LRURP*
96 LRURPParams::create()
97 {
98  return new LRURP(this);
99 }
BaseReplacementPolicyParams Params
Convenience typedef.
Definition: base.hh:54
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) const override
Invalidate replacement data to set it as the next probable victim.
Definition: lru_rp.cc:44
LRURP(const Params *p)
Construct and initiliaze this replacement policy.
Definition: lru_rp.cc:38
A common base class of cache replacement policy objects.
Definition: base.hh:48
STL vector class.
Definition: stl.hh:40
LRU-specific implementation of replacement data.
Definition: lru_rp.hh:48
Tick curTick()
The current simulated tick.
Definition: core.hh:47
uint64_t Tick
Tick count type.
Definition: types.hh:63
Definition: lru_rp.hh:44
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition: lru_rp.cc:61
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using LRU timestamps.
Definition: lru_rp.cc:69
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition: lru_rp.cc:90
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.
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition: lru_rp.cc:53
Bitfield< 0 > p

Generated on Fri Feb 28 2020 16:27:02 for gem5 by doxygen 1.8.13