41#include "params/TreePLRURP.hh"
46namespace replacement_policy
58 return std::floor((
index-1)/2);
99 const uint64_t
index, std::shared_ptr<PLRUTree> tree)
108 "numLeaves should never be 0");
115 std::shared_ptr<TreePLRUReplData> treePLRU_replacement_data =
116 std::static_pointer_cast<TreePLRUReplData>(replacement_data);
117 PLRUTree* tree = treePLRU_replacement_data->tree.get();
121 uint64_t tree_index = treePLRU_replacement_data->index;
132 tree->at(tree_index) = right;
133 }
while (tree_index != 0);
141 std::shared_ptr<TreePLRUReplData> treePLRU_replacement_data =
142 std::static_pointer_cast<TreePLRUReplData>(replacement_data);
143 PLRUTree* tree = treePLRU_replacement_data->tree.get();
147 uint64_t tree_index = treePLRU_replacement_data->index;
158 tree->at(tree_index) = !right;
159 }
while (tree_index != 0);
167 touch(replacement_data);
174 assert(candidates.size() > 0);
177 const PLRUTree* tree = std::static_pointer_cast<TreePLRUReplData>(
178 candidates[0]->replacementData)->tree.get();
181 uint64_t tree_index = 0;
184 while (tree_index < tree->size()) {
186 if (tree->at(tree_index)) {
195 return candidates.at(tree_index - (
numLeaves - 1));
198std::shared_ptr<ReplacementData>
214 return std::shared_ptr<ReplacementData>(treePLRUReplData);
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
A common base class of cache replacement policy objects.
void reset(const std::shared_ptr< ReplacementData > &replacement_data) const override
Reset replacement data.
const uint64_t numLeaves
Number of leaves that share a single replacement data.
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using TreePLRU bits.
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) override
Invalidate replacement data to set it as the next probable victim.
uint64_t count
Count of the number of sharers of a replacement data.
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
std::vector< bool > PLRUTree
Instead of implementing the tree itself with pointers, it is implemented as an array of bits.
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
PLRUTree * treeInstance
Holds the latest temporary tree instance created by instantiateEntry().
TreePLRU(const Params &p)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
static uint64_t parentIndex(const uint64_t index)
Get the index of the parent of the given indexed subtree.
static bool isRightSubtree(const uint64_t index)
Find out if the subtree at index corresponds to the right or left subtree of its parent tree.
static uint64_t leftSubtreeIndex(const uint64_t index)
Get index of the subtree on the left of the given indexed tree.
static uint64_t rightSubtreeIndex(const uint64_t index)
Get index of the subtree on the right of the given indexed tree.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tree-PLRU-specific implementation of replacement data.
TreePLRUReplData(const uint64_t index, std::shared_ptr< PLRUTree > tree)
Default constructor.
Copyright (c) 2018-2020 Inria All rights reserved.