Skip to content

Commit

Permalink
Merge pull request #1181 from aprokop/indexable
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop authored Nov 10, 2024
2 parents 93f1af3 + 53442f6 commit bede66d
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 30 deletions.
3 changes: 1 addition & 2 deletions src/cluster/ArborX_DBSCAN.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ dbscan(ExecutionSpace const &exec_space, Primitives const &primitives,
Box bounds;
Details::TreeConstruction::calculateBoundingBoxOfTheScene(
exec_space,
Details::Indexables<Points, Details::DefaultIndexableGetter>{
points, Details::DefaultIndexableGetter{}},
Details::Indexables{points, Experimental::DefaultIndexableGetter{}},
bounds);

// The cell length is chosen to be eps/sqrt(dimension), so that any two
Expand Down
5 changes: 3 additions & 2 deletions src/distributed/ArborX_DistributedTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class DistributedTreeBase
using BoundingVolume = typename BottomTree::bounding_volume_type;
using TopTree =
BoundingVolumeHierarchy<MemorySpace, PairValueIndex<BoundingVolume, int>,
Details::DefaultIndexableGetter, BoundingVolume>;
Experimental::DefaultIndexableGetter,
BoundingVolume>;

using bottom_tree_type = BottomTree;
using top_tree_type = TopTree;
Expand Down Expand Up @@ -119,7 +120,7 @@ class DistributedTreeBase
// NOTE: query() must be called as collective over all processes in the
// communicator passed to the constructor
template <typename MemorySpace, typename Value,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename IndexableGetter = Experimental::DefaultIndexableGetter,
typename BoundingVolume = Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
Expand Down
6 changes: 2 additions & 4 deletions src/spatial/ArborX_BruteForce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace ArborX
{

template <typename MemorySpace, typename Value,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename IndexableGetter = Experimental::DefaultIndexableGetter,
typename BoundingVolume = Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
Expand Down Expand Up @@ -198,9 +198,7 @@ void BruteForce<MemorySpace, Value, IndexableGetter, BoundingVolume>::query(

Details::BruteForceImpl::query(
Tag{}, space, predicates, _values,
Details::Indexables<decltype(_values), IndexableGetter>{
_values, _indexable_getter},
callback);
Details::Indexables{_values, _indexable_getter}, callback);
}

} // namespace ArborX
Expand Down
7 changes: 3 additions & 4 deletions src/spatial/ArborX_LinearBVH.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct HappyTreeFriends;
} // namespace Details

template <typename MemorySpace, typename Value,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename IndexableGetter = Experimental::DefaultIndexableGetter,
typename BoundingVolume = Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
Expand Down Expand Up @@ -179,7 +179,7 @@ KOKKOS_FUNCTION
typename Details::AccessValues<Values, PrimitivesTag>::value_type>;

template <typename MemorySpace, typename Value,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename IndexableGetter = Experimental::DefaultIndexableGetter,
typename BoundingVolume = Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
Expand Down Expand Up @@ -238,8 +238,7 @@ BoundingVolumeHierarchy<MemorySpace, Value, IndexableGetter, BoundingVolume>::
return;
}

Details::Indexables<Values, IndexableGetter> indexables{values,
indexable_getter};
Details::Indexables indexables{values, indexable_getter};

Kokkos::Profiling::pushRegion(
"ArborX::BVH::BVH::calculate_scene_bounding_box");
Expand Down
24 changes: 22 additions & 2 deletions src/spatial/detail/ArborX_IndexableGetter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
#include <detail/ArborX_AccessTraits.hpp>
#include <detail/ArborX_PairValueIndex.hpp>

namespace ArborX::Details
namespace ArborX
{

namespace Experimental
{

struct DefaultIndexableGetter
Expand Down Expand Up @@ -52,6 +55,11 @@ struct DefaultIndexableGetter
}
};

} // namespace Experimental

namespace Details
{

template <typename Values, typename IndexableGetter>
struct Indexables
{
Expand All @@ -68,6 +76,18 @@ struct Indexables
KOKKOS_FUNCTION auto size() const { return _values.size(); }
};

} // namespace ArborX::Details
#ifdef KOKKOS_ENABLE_CXX17
template <typename Values, typename IndexableGetter>
#if KOKKOS_VERSION >= 40400
KOKKOS_DEDUCTION_GUIDE
#else
KOKKOS_FUNCTION
#endif
Indexables(Values, IndexableGetter) -> Indexables<Values, IndexableGetter>;
#endif

} // namespace Details

} // namespace ArborX

#endif
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost)
"using ArborX_Legacy_BVH_Box =\n"
" LegacyTree<ArborX::BoundingVolumeHierarchy<\n"
" MemorySpace, ArborX::PairValueIndex<ArborX::Box<3, float>>,\n"
" ArborX::Details::DefaultIndexableGetter, ArborX::Box<3, float>>>;\n"
" ArborX::Experimental::DefaultIndexableGetter, ArborX::Box<3, float>>>;\n"
"#define ARBORX_TEST_TREE_TYPES Tuple<ArborX_Legacy_BVH_Box>\n"
"#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n"
"#include <tstQueryTree${_test}.cpp>\n"
Expand All @@ -106,7 +106,7 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost)
"using ArborX_Legacy_BruteForce_Box =\n"
" LegacyTree<ArborX::BruteForce<\n"
" MemorySpace, ArborX::PairValueIndex<ArborX::Box<3, float>>,\n"
" ArborX::Details::DefaultIndexableGetter, ArborX::Box<3, float>>>;\n"
" ArborX::Experimental::DefaultIndexableGetter, ArborX::Box<3, float>>>;\n"
"#define ARBORX_TEST_TREE_TYPES Tuple<ArborX_Legacy_BruteForce_Box>\n"
"#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n"
"#define ARBORX_TEST_DISABLE_CALLBACK_EARLY_EXIT\n"
Expand All @@ -130,7 +130,7 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost)
"using ArborX_Legacy_BVH_${_bounding_volume} =\n"
" LegacyTree<ArborX::BoundingVolumeHierarchy<\n"
" MemorySpace, ArborX::PairValueIndex<${_bounding_volume}>,\n"
" ArborX::Details::DefaultIndexableGetter, ${_bounding_volume}>>;\n"
" ArborX::Experimental::DefaultIndexableGetter, ${_bounding_volume}>>;\n"
"#define ARBORX_TEST_TREE_TYPES Tuple<ArborX_Legacy_BVH_${_bounding_volume}>\n"
"#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n"
"#define ARBORX_TEST_DISABLE_NEAREST_QUERY\n"
Expand Down
7 changes: 3 additions & 4 deletions test/tstCompileOnlyTypeRequirements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ void check_bounding_volume_and_predicate_geometry_type_requirements()
{
using ExecutionSpace = Kokkos::DefaultExecutionSpace;
using MemorySpace = ExecutionSpace::memory_space;
using Tree =
ArborX::BoundingVolumeHierarchy<MemorySpace, Test::PrimitivePointOrBox,
ArborX::Details::DefaultIndexableGetter,
Test::FakeBoundingVolume>;
using Tree = ArborX::BoundingVolumeHierarchy<
MemorySpace, Test::PrimitivePointOrBox,
ArborX::Experimental::DefaultIndexableGetter, Test::FakeBoundingVolume>;

Kokkos::View<Test::PrimitivePointOrBox *, MemorySpace> primitives(
"primitives", 0);
Expand Down
7 changes: 3 additions & 4 deletions test/tstDetailsTreeConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(assign_morton_codes, DeviceType,
scene_host, {{{0.0, 0.0, 0.0}}, {{(float)N, (float)N, (float)N}}}));

LegacyValues<decltype(boxes), ArborX::Box<3>> values{boxes};
ArborX::Details::Indexables<decltype(values),
ArborX::Details::DefaultIndexableGetter>
indexables{values, ArborX::Details::DefaultIndexableGetter{}};
ArborX::Details::Indexables indexables{
values, ArborX::Experimental::DefaultIndexableGetter{}};

// Test for a bug where missing move ref operator() in DefaultIndexableGetter
// results in a default initialized indexable used in scene box calucation.
Expand Down Expand Up @@ -172,7 +171,7 @@ void generateHierarchy(Primitives primitives, MortonCodes sorted_morton_codes,
BoundingVolume bounds;
ArborX::Details::TreeConstruction::generateHierarchy(
space, LegacyValues<Primitives, BoundingVolume>{primitives},
ArborX::Details::DefaultIndexableGetter{}, permutation_indices,
ArborX::Experimental::DefaultIndexableGetter{}, permutation_indices,
sorted_morton_codes, leaf_nodes, internal_nodes, bounds);
}

Expand Down
8 changes: 3 additions & 5 deletions test/tstIndexableGetter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(indexables, DeviceType, ARBORX_DEVICE_TYPES)

ArborX::Box scene_bounding_box{{-1.f, -1.f, -1.f}, {1.f, 1.f, 1.f}};

using IndexableGetter = ArborX::Details::DefaultIndexableGetter;
using IndexableGetter = ArborX::Experimental::DefaultIndexableGetter;
IndexableGetter indexable_getter;

{
Expand All @@ -110,8 +110,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(indexables, DeviceType, ARBORX_DEVICE_TYPES)
ArborX::PrimitivesTag>;
Primitives primitives(points_cloud);

ArborX::Details::Indexables<Primitives, IndexableGetter> indexables{
primitives, indexable_getter};
ArborX::Details::Indexables indexables{primitives, indexable_getter};

ArborX::Box<3> box;
calculateBoundingBoxOfTheScene(ExecutionSpace{}, indexables, box);
Expand All @@ -126,8 +125,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(indexables, DeviceType, ARBORX_DEVICE_TYPES)
ArborX::PrimitivesTag>;
Primitives primitives(points_cloud);

ArborX::Details::Indexables<Primitives, IndexableGetter> indexables{
primitives, indexable_getter};
ArborX::Details::Indexables indexables{primitives, indexable_getter};

ArborX::Box<3> box;
calculateBoundingBoxOfTheScene(ExecutionSpace{}, indexables, box);
Expand Down

0 comments on commit bede66d

Please sign in to comment.