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