gem5
v20.1.0.0
mem
cache
replacement_policies
lfu_rp.cc
Go to the documentation of this file.
1
29
#include "
mem/cache/replacement_policies/lfu_rp.hh
"
30
31
#include <cassert>
32
#include <memory>
33
34
#include "params/LFURP.hh"
35
36
LFURP::LFURP
(
const
Params
*
p
)
37
:
BaseReplacementPolicy
(
p
)
38
{
39
}
40
41
void
42
LFURP::invalidate
(
const
std::shared_ptr<ReplacementData>& replacement_data)
43
const
44
{
45
// Reset reference count
46
std::static_pointer_cast<LFUReplData>(replacement_data)->refCount = 0;
47
}
48
49
void
50
LFURP::touch
(
const
std::shared_ptr<ReplacementData>& replacement_data)
const
51
{
52
// Update reference count
53
std::static_pointer_cast<LFUReplData>(replacement_data)->refCount++;
54
}
55
56
void
57
LFURP::reset
(
const
std::shared_ptr<ReplacementData>& replacement_data)
const
58
{
59
// Reset reference count
60
std::static_pointer_cast<LFUReplData>(replacement_data)->refCount = 1;
61
}
62
63
ReplaceableEntry
*
64
LFURP::getVictim
(
const
ReplacementCandidates
& candidates)
const
65
{
66
// There must be at least one replacement candidate
67
assert(candidates.size() > 0);
68
69
// Visit all candidates to find victim
70
ReplaceableEntry
* victim = candidates[0];
71
for
(
const
auto
& candidate : candidates) {
72
// Update victim entry if necessary
73
if
(std::static_pointer_cast<LFUReplData>(
74
candidate->replacementData)->refCount <
75
std::static_pointer_cast<LFUReplData>(
76
victim->
replacementData
)->refCount) {
77
victim = candidate;
78
}
79
}
80
81
return
victim;
82
}
83
84
std::shared_ptr<ReplacementData>
85
LFURP::instantiateEntry
()
86
{
87
return
std::shared_ptr<ReplacementData>(
new
LFUReplData
());
88
}
89
90
LFURP
*
91
LFURPParams::create()
92
{
93
return
new
LFURP
(
this
);
94
}
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
LFURP::invalidate
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) const override
Invalidate replacement data to set it as the next probable victim.
Definition:
lfu_rp.cc:42
lfu_rp.hh
Copyright (c) 2018 Inria All rights reserved.
std::vector
STL vector class.
Definition:
stl.hh:37
LFURP::getVictim
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using reference frequency.
Definition:
lfu_rp.cc:64
LFURP::LFUReplData
LFU-specific implementation of replacement data.
Definition:
lfu_rp.hh:48
LFURP
Definition:
lfu_rp.hh:44
BaseReplacementPolicy
A common base class of cache replacement policy objects.
Definition:
base.hh:46
LFURP::instantiateEntry
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition:
lfu_rp.cc:85
LFURP::reset
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition:
lfu_rp.cc:57
ReplaceableEntry::replacementData
std::shared_ptr< ReplacementData > replacementData
Replacement data associated to this entry.
Definition:
replaceable_entry.hh:74
LFURP::LFURP
LFURP(const Params *p)
Construct and initiliaze this replacement policy.
Definition:
lfu_rp.cc:36
MipsISA::p
Bitfield< 0 > p
Definition:
pra_constants.hh:323
LFURP::touch
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition:
lfu_rp.cc:50
Generated on Wed Sep 30 2020 14:02:12 for gem5 by
doxygen
1.8.17