From 939d8e28dfdf32adcd08057e281516be88a4287e Mon Sep 17 00:00:00 2001 From: Ivana Mitrovic Date: Fri, 26 Apr 2024 20:22:20 -0700 Subject: [PATCH] mem-cache: Fix TreePLRU num leaves error (#1075) This PR fixes the error noted here #1073. Change-Id: I5d31c259ac5ee93f46f28b20eda4f58460ba8523 --- src/mem/cache/replacement_policies/tree_plru_rp.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mem/cache/replacement_policies/tree_plru_rp.cc b/src/mem/cache/replacement_policies/tree_plru_rp.cc index ffd039c9e1..2766916534 100644 --- a/src/mem/cache/replacement_policies/tree_plru_rp.cc +++ b/src/mem/cache/replacement_policies/tree_plru_rp.cc @@ -104,7 +104,8 @@ TreePLRU::TreePLRUReplData::TreePLRUReplData( TreePLRU::TreePLRU(const Params &p) : Base(p), numLeaves(p.num_leaves), count(0), treeInstance(nullptr) { - fatal_if(numLeaves < 2, "Number of leaves must be two or greater"); + fatal_if(numLeaves < 1, + "numLeaves should never be 0"); } void @@ -191,7 +192,7 @@ TreePLRU::getVictim(const ReplacementCandidates& candidates) const // The tree index is currently at the leaf of the victim displaced by the // number of non-leaf nodes - return candidates[tree_index - (numLeaves - 1)]; + return candidates.at(tree_index - (numLeaves - 1)); } std::shared_ptr