43 #include "debug/StackDist.hh"
47 verifyStack(verify_stack)
57 tree.push_back(tree_level);
66 tree.push_back(tree_level);
75 for (
auto& layer :
tree) {
76 for (
auto& index_node : layer) {
78 delete index_node.second;
98 uint64_t sum_from_below, uint64_t
level,
99 uint64_t stack_dist,
bool discard_node)
105 uint64_t node_sum_l = node->
sumLeft;
106 uint64_t node_sum_r = node->
sumRight;
122 "Error in sum left of level %ul, node index %ull, "
123 "Sum = %ull \n",
level, node_n_index, node_sum_l);
126 "Error in sum right of level %ul, node index %ull, "
127 "Sum = %ull \n",
level, node_n_index, node_sum_r);
135 node_sum_l = sum_from_below;
136 stack_dist += node_sum_r;
139 node_sum_r = sum_from_below;
143 if (discard_node && !sum_from_below) {
145 node_discard_left =
true;
147 node_discard_right =
true;
159 if (node_discard_left && node_discard_right &&
160 discard_node && node_parent_ptr && !sum_from_below) {
167 discard_node =
false;
172 if (node_parent_ptr) {
173 stack_dist =
updateSum(node_parent_ptr, node_left,
174 node_sum_l + node_sum_r,
175 level, stack_dist, discard_node);
189 uint64_t stack_dist = 0;
202 level, stack_dist,
true);
212 uint64_t stack_dist, uint64_t
level)
const
280 tree.push_back(treeLevel);
325 if ((
index % (1 <<
i)) == 0) {
361 auto ai =
aiMap.lower_bound(r_address);
375 if (ai !=
aiMap.end() && !(
aiMap.key_comp()(r_address, ai->first))) {
379 uint64_t r_index = ai->second;
385 aiMap.erase(r_address);
392 newLeafNode =
tree[0][r_index];
396 tree[0].erase(r_index);
409 if (
index % 2 == 0) {
419 newLeafNode =
new Node();
440 panic_if(verify_stack_dist != stack_dist,
441 "Expected stack-distance for address \
442 %#lx is %#lx but found %#lx",
443 r_address, verify_stack_dist, stack_dist);
452 return (std::make_pair(stack_dist, _mark));
464 auto ai =
aiMap.lower_bound(r_address);
467 uint64_t stack_dist = 0;
473 if (ai !=
aiMap.end() && !(
aiMap.key_comp()(r_address, ai->first))) {
477 uint64_t r_index = ai->second;
480 _mark =
tree[0][r_index]->isMarked;
482 tree[0][r_index]->isMarked = mark;
498 panic_if(verify_stack_dist != stack_dist,
499 "Expected stack-distance for address \
500 %#lx is %#lx but found %#lx",
501 r_address, verify_stack_dist, stack_dist);
506 return std::make_pair(stack_dist, _mark);
517 next_up = next_up->
parent;
518 panic_if(!next_up,
"Sanity check failed for node %ull \n",
535 uint64_t stack_dist = 0;
538 for (;
a !=
stack.rend(); ++
a) {
539 if (*
a == r_address) {
556 stack.push_back(r_address);
568 DPRINTF(StackDist,
"Printing last %d entries in tree\n",
n);
571 for (
auto it =
tree[0].rbegin(); (
count <
n) && (it !=
tree[0].rend());
577 for (
auto ai =
aiMap.rbegin(); ai !=
aiMap.rend(); ++ai) {
578 if (ai->second == r_index) {
579 DPRINTF(StackDist,
"Tree leaves, Rightmost-[%d] = %#lx\n",
589 DPRINTF(StackDist,
"Printing Last %d entries in VerifStack \n",
n);
593 DPRINTF(StackDist,
"Verif Stack, Top-[%d] = %#lx\n",
count, *
a);