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

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