gem5
v20.1.0.0
mem
cache
replacement_policies
lru_rp.cc
Go to the documentation of this file.
1
29
#include "
mem/cache/replacement_policies/lru_rp.hh
"
30
31
#include <cassert>
32
#include <memory>
33
34
#include "params/LRURP.hh"
35
#include "
sim/core.hh
"
36
37
LRURP::LRURP
(
const
Params
*
p
)
38
:
BaseReplacementPolicy
(
p
)
39
{
40
}
41
42
void
43
LRURP::invalidate
(
const
std::shared_ptr<ReplacementData>& replacement_data)
44
const
45
{
46
// Reset last touch timestamp
47
std::static_pointer_cast<LRUReplData>(
48
replacement_data)->lastTouchTick =
Tick
(0);
49
}
50
51
void
52
LRURP::touch
(
const
std::shared_ptr<ReplacementData>& replacement_data)
const
53
{
54
// Update last touch timestamp
55
std::static_pointer_cast<LRUReplData>(
56
replacement_data)->lastTouchTick =
curTick
();
57
}
58
59
void
60
LRURP::reset
(
const
std::shared_ptr<ReplacementData>& replacement_data)
const
61
{
62
// Set last touch timestamp
63
std::static_pointer_cast<LRUReplData>(
64
replacement_data)->lastTouchTick =
curTick
();
65
}
66
67
ReplaceableEntry
*
68
LRURP::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<LRUReplData>(
78
candidate->replacementData)->lastTouchTick <
79
std::static_pointer_cast<LRUReplData>(
80
victim->
replacementData
)->lastTouchTick) {
81
victim = candidate;
82
}
83
}
84
85
return
victim;
86
}
87
88
std::shared_ptr<ReplacementData>
89
LRURP::instantiateEntry
()
90
{
91
return
std::shared_ptr<ReplacementData>(
new
LRUReplData
());
92
}
93
94
LRURP
*
95
LRURPParams::create()
96
{
97
return
new
LRURP
(
this
);
98
}
ReplaceableEntry
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
Definition:
replaceable_entry.hh:53
BaseReplacementPolicy::Params
BaseReplacementPolicyParams Params
Convenience typedef.
Definition:
base.hh:52
Tick
uint64_t Tick
Tick count type.
Definition:
types.hh:63
std::vector
STL vector class.
Definition:
stl.hh:37
LRURP::invalidate
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:43
LRURP::LRURP
LRURP(const Params *p)
Construct and initiliaze this replacement policy.
Definition:
lru_rp.cc:37
BaseReplacementPolicy
A common base class of cache replacement policy objects.
Definition:
base.hh:46
LRURP::LRUReplData
LRU-specific implementation of replacement data.
Definition:
lru_rp.hh:46
lru_rp.hh
Copyright (c) 2018 Inria All rights reserved.
LRURP::touch
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition:
lru_rp.cc:52
core.hh
LRURP
Definition:
lru_rp.hh:42
ReplaceableEntry::replacementData
std::shared_ptr< ReplacementData > replacementData
Replacement data associated to this entry.
Definition:
replaceable_entry.hh:74
MipsISA::p
Bitfield< 0 > p
Definition:
pra_constants.hh:323
LRURP::reset
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition:
lru_rp.cc:60
LRURP::instantiateEntry
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition:
lru_rp.cc:89
LRURP::getVictim
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using LRU timestamps.
Definition:
lru_rp.cc:68
curTick
Tick curTick()
The current simulated tick.
Definition:
core.hh:45
Generated on Wed Sep 30 2020 14:02:12 for gem5 by
doxygen
1.8.17