Skip to content

Commit

Permalink
Fix a bug in the hierarchy construction when using 63 bits for Morton…
Browse files Browse the repository at this point in the history
… codes
  • Loading branch information
aprokop committed Feb 21, 2022
1 parent e9cc9f1 commit 2b69f24
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/details/ArborX_DetailsTreeConstruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,15 @@ class GenerateHierarchy
// Morton comparison. Thus, we add INT_MIN to it.
// We also avoid if/else statement by doing a "x + !x*<blah>" trick.
auto x = _sorted_morton_codes(i) ^ _sorted_morton_codes(i + 1);
return x + (!x) * (LLONG_MIN + (i ^ (i + 1)));
if (x != 0)
{
// When using 63 bits for Morton codes, the LLONG_MAX is actually a valid
// code. As we want the return statement above to return a value always
// greater than anything here, we downshift by 1.
return x - 1;
}

return LLONG_MIN + (i ^ (i + 1));
}

KOKKOS_FUNCTION Node *getNodePtr(int i) const
Expand Down

0 comments on commit 2b69f24

Please sign in to comment.