43 #include "params/TreePLRURP.hh" 54 return std::floor((index-1)/2);
95 const uint64_t
index, std::shared_ptr<PLRUTree> tree)
96 : index(index), tree(tree)
105 "Number of leaves must be non-zero and a power of 2");
110 const std::shared_ptr<ReplacementData>& replacement_data)
const 113 std::shared_ptr<TreePLRUReplData> treePLRU_replacement_data =
115 PLRUTree* tree = treePLRU_replacement_data->tree.get();
119 uint64_t tree_index = treePLRU_replacement_data->index;
130 tree->at(tree_index) = right;
131 }
while (tree_index != 0);
139 std::shared_ptr<TreePLRUReplData> treePLRU_replacement_data =
141 PLRUTree* tree = treePLRU_replacement_data->tree.get();
145 uint64_t tree_index = treePLRU_replacement_data->index;
156 tree->at(tree_index) = !right;
157 }
while (tree_index != 0);
165 touch(replacement_data);
172 assert(candidates.size() > 0);
176 candidates[0]->replacementData)->tree.get();
179 uint64_t tree_index = 0;
182 while (tree_index < tree->size()) {
184 if (tree->at(tree_index)) {
193 return candidates[tree_index - (
numLeaves - 1)];
196 std::shared_ptr<ReplacementData>
212 return std::shared_ptr<ReplacementData>(treePLRUReplData);
216 TreePLRURPParams::create()
BaseReplacementPolicyParams Params
Convenience typedef.
static uint64_t parentIndex(const uint64_t index)
Get the index of the parent of the given indexed subtree.
uint64_t count
Count of the number of sharers of a replacement data.
TreePLRUReplData(const uint64_t index, std::shared_ptr< PLRUTree > tree)
Default constructor.
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.
PLRUTree * treeInstance
Holds the latest temporary tree instance created by instantiateEntry().
A common base class of cache replacement policy objects.
void invalidate(const std::shared_ptr< ReplacementData > &replacement_data) const override
Invalidate replacement data to set it as the next probable victim.
static uint64_t rightSubtreeIndex(const uint64_t index)
Get index of the subtree on the right of the given indexed tree.
bool isPowerOf2(const T &n)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
TreePLRURP(const Params *p)
Construct and initiliaze this replacement policy.
Copyright (c) 2018 Inria All rights reserved.
void touch(const std::shared_ptr< ReplacementData > &replacement_data) const override
Touch an entry to update its replacement data.
Tree-PLRU-specific implementation of replacement data.
std::vector< bool > PLRUTree
Instead of implementing the tree itself with pointers, it is implemented as an array of bits...
static uint64_t leftSubtreeIndex(const uint64_t index)
Get index of the subtree on the left of the given indexed tree.
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
ReplaceableEntry * getVictim(const ReplacementCandidates &candidates) const override
Find replacement victim using TreePLRU bits.
std::shared_ptr< ReplacementData > instantiateEntry() override
Instantiate a replacement data entry.
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...