Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow different volumes for leaf and internal nodes #897

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/details/ArborX_DetailsHalfTraversal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ struct HalfTraversal
{
bool const is_leaf = HappyTreeFriends::isLeaf(_bvh, node);

if (predicate((is_leaf ? HappyTreeFriends::getIndexable(_bvh, node)
: HappyTreeFriends::getInternalBoundingVolume(
_bvh, node))))
if (is_leaf ? predicate(HappyTreeFriends::getIndexable(_bvh, node))
: predicate(HappyTreeFriends::getInternalBoundingVolume(
_bvh, node)))
{
if (is_leaf)
{
Expand Down
3 changes: 0 additions & 3 deletions src/details/ArborX_DetailsHappyTreeFriends.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ struct HappyTreeFriends
#endif
getIndexable(BVH const &bvh, int i)
{
static_assert(
std::is_same_v<decltype(bvh._internal_nodes(0).bounding_volume),
decltype(bvh._leaf_nodes(0).value.bounding_volume)>);
return bvh._indexable_getter(getValue(bvh, i));
}

Expand Down
18 changes: 10 additions & 8 deletions src/details/ArborX_DetailsTreeConstruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,11 @@ class GenerateHierarchy
// thread.
// NOTE we need acquire semantics at the device scope
Kokkos::load_fence();
expand(bounding_volume,
right_child_is_leaf
? _indexable_getter(_leaf_nodes(right_child).value)
: _internal_nodes(right_child).bounding_volume);
if (right_child_is_leaf)
expand(bounding_volume,
_indexable_getter(_leaf_nodes(right_child).value));
else
expand(bounding_volume, _internal_nodes(right_child).bounding_volume);
}
else
{
Expand All @@ -273,10 +274,11 @@ class GenerateHierarchy
delta_left = delta(range_left - 1);

Kokkos::load_fence();
expand(bounding_volume,
left_child_is_leaf
? _indexable_getter(_leaf_nodes(left_child).value)
: _internal_nodes(left_child).bounding_volume);
if (left_child_is_leaf)
expand(bounding_volume,
_indexable_getter(_leaf_nodes(left_child).value));
else
expand(bounding_volume, _internal_nodes(left_child).bounding_volume);

if (!left_child_is_leaf)
left_child = internalIndex(left_child);
Expand Down
22 changes: 11 additions & 11 deletions src/details/ArborX_DetailsTreeTraversal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ struct TreeTraversal<BVH, Predicates, Callback, SpatialPredicateTag>
{
bool const is_leaf = HappyTreeFriends::isLeaf(_bvh, node);

if (predicate((is_leaf ? HappyTreeFriends::getIndexable(_bvh, node)
: HappyTreeFriends::getInternalBoundingVolume(
_bvh, node))))
if (is_leaf ? predicate(HappyTreeFriends::getIndexable(_bvh, node))
: predicate(HappyTreeFriends::getInternalBoundingVolume(
_bvh, node)))
{
if (is_leaf)
{
Expand Down Expand Up @@ -260,10 +260,10 @@ struct TreeTraversal<BVH, Predicates, Callback, NearestPredicateTag>

auto &bvh = _bvh;
auto const distance = [&predicate, &bvh](int j) {
return predicate.distance(
HappyTreeFriends::isLeaf(bvh, j)
? HappyTreeFriends::getIndexable(bvh, j)
: HappyTreeFriends::getInternalBoundingVolume(bvh, j));
return HappyTreeFriends::isLeaf(bvh, j)
? predicate.distance(HappyTreeFriends::getIndexable(bvh, j))
: predicate.distance(
HappyTreeFriends::getInternalBoundingVolume(bvh, j));
};

constexpr int SENTINEL = -1;
Expand Down Expand Up @@ -469,10 +469,10 @@ struct TreeTraversal<BVH, Predicates, Callback,

auto &bvh = _bvh;
auto const distance = [&predicate, &bvh](int j) {
return predicate.distance(
HappyTreeFriends::isLeaf(bvh, j)
? HappyTreeFriends::getIndexable(bvh, j)
: HappyTreeFriends::getInternalBoundingVolume(bvh, j));
return HappyTreeFriends::isLeaf(bvh, j)
? predicate.distance(HappyTreeFriends::getIndexable(bvh, j))
: predicate.distance(
HappyTreeFriends::getInternalBoundingVolume(bvh, j));
};

int node = HappyTreeFriends::getRoot(_bvh);
Expand Down
11 changes: 6 additions & 5 deletions src/details/ArborX_MinimumSpanningTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ struct FindComponentNearestNeighbors
HappyTreeFriends::getIndexable(_bvh, i),
&bvh = _bvh](int j) {
using Details::distance;
auto &&bounding_volume_j =
(HappyTreeFriends::isLeaf(bvh, j)
? HappyTreeFriends::getIndexable(bvh, j)
: HappyTreeFriends::getInternalBoundingVolume(bvh, j));
return distance(bounding_volume_i, bounding_volume_j);
return HappyTreeFriends::isLeaf(bvh, j)
? distance(bounding_volume_i,
HappyTreeFriends::getIndexable(bvh, j))
: distance(
bounding_volume_i,
HappyTreeFriends::getInternalBoundingVolume(bvh, j));
};

auto const component = _labels(i);
Expand Down