gem5
v24.0.0.0
Loading...
Searching...
No Matches
mem
cache
replacement_policies
random_rp.cc
Go to the documentation of this file.
1
29
#include "
mem/cache/replacement_policies/random_rp.hh
"
30
31
#include <cassert>
32
#include <memory>
33
34
#include "
base/random.hh
"
35
#include "params/RandomRP.hh"
36
37
namespace
gem5
38
{
39
40
namespace
replacement_policy
41
{
42
43
Random::Random
(
const
Params
&
p
)
44
:
Base
(
p
)
45
{
46
}
47
48
void
49
Random::invalidate
(
const
std::shared_ptr<ReplacementData>& replacement_data)
50
{
51
// Unprioritize replacement data victimization
52
std::static_pointer_cast<RandomReplData>(
53
replacement_data)->valid =
false
;
54
}
55
56
void
57
Random::touch
(
const
std::shared_ptr<ReplacementData>& replacement_data)
const
58
{
59
}
60
61
void
62
Random::reset
(
const
std::shared_ptr<ReplacementData>& replacement_data)
const
63
{
64
// Unprioritize replacement data victimization
65
std::static_pointer_cast<RandomReplData>(
66
replacement_data)->valid =
true
;
67
}
68
69
ReplaceableEntry
*
70
Random::getVictim
(
const
ReplacementCandidates
& candidates)
const
71
{
72
// There must be at least one replacement candidate
73
assert(candidates.size() > 0);
74
75
// Choose one candidate at random
76
ReplaceableEntry
* victim = candidates[
random_mt
.
random
<
unsigned
>(0,
77
candidates.size() - 1)];
78
79
// Visit all candidates to search for an invalid entry. If one is found,
80
// its eviction is prioritized
81
for
(
const
auto
& candidate : candidates) {
82
if
(!std::static_pointer_cast<RandomReplData>(
83
candidate->replacementData)->valid) {
84
victim = candidate;
85
break
;
86
}
87
}
88
89
return
victim;
90
}
91
92
std::shared_ptr<ReplacementData>
93
Random::instantiateEntry
()
94
{
95
return
std::shared_ptr<ReplacementData>(
new
RandomReplData
());
96
}
97
98
}
// namespace replacement_policy
99
}
// namespace gem5
gem5::ReplaceableEntry
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
Definition
replaceable_entry.hh:63
gem5::replacement_policy::Base
A common base class of cache replacement policy objects.
Definition
base.hh:55
gem5::replacement_policy::Random::instantiateEntry
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
Definition
random_rp.cc:93
gem5::replacement_policy::Random::invalidate
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
Definition
random_rp.cc:49
gem5::replacement_policy::Random::touch
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Definition
random_rp.cc:57
gem5::replacement_policy::Random::reset
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
Definition
random_rp.cc:62
gem5::replacement_policy::Random::Params
RandomRPParams Params
Definition
random_rp.hh:67
gem5::replacement_policy::Random::getVictim
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim at random.
Definition
random_rp.cc:70
std::vector
STL vector class.
Definition
stl.hh:37
gem5::random_mt
Random random_mt
Definition
random.cc:99
gem5::Random::Random
Random()
Definition
random.cc:51
gem5::Random::random
std::enable_if_t< std::is_integral_v< T >, T > random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
Definition
random.hh:90
gem5::MipsISA::p
Bitfield< 0 > p
Definition
pra_constants.hh:326
gem5
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition
binary32.hh:36
random.hh
random_rp.hh
Copyright (c) 2018-2020 Inria All rights reserved.
gem5::replacement_policy::Random::RandomReplData
Random-specific implementation of replacement data.
Definition
random_rp.hh:53
Generated on Tue Jun 18 2024 16:24:05 for gem5 by
doxygen
1.11.0