From f631ac2ee7f87e502587e9448a03568d87805425 Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Mon, 28 Aug 2023 23:38:17 -0400 Subject: [PATCH] Change BasicBVH constructor --- .../brute_force_vs_bvh_timpl.hpp | 5 +- .../dbscan/ArborX_DBSCANVerification.hpp | 7 ++- .../triangle_intersection.cpp | 13 +++-- src/ArborX_BruteForce.hpp | 4 +- src/ArborX_DBSCAN.hpp | 51 +++++++++++------ src/ArborX_LinearBVH.hpp | 57 +++++++++++-------- src/details/ArborX_AccessTraits.hpp | 29 ++++++++-- src/details/ArborX_DetailsLegacy.hpp | 37 +++++++++++- src/details/ArborX_IndexableGetter.hpp | 18 +++--- src/details/ArborX_MinimumSpanningTree.hpp | 8 +-- test/CMakeLists.txt | 22 +++++++ test/Search_UnitTestHelpers.hpp | 9 ++- test/tstCompileOnlyTypeRequirements.cpp | 4 +- test/tstDetailsMutualReachabilityDistance.cpp | 4 +- test/tstDetailsTreeConstruction.cpp | 3 +- test/tstKokkosToolsDistributedAnnotations.cpp | 1 + test/tstQueryTreeCallbacks.cpp | 36 ++++++++++-- test/tstQueryTreeComparisonWithBoost.cpp | 14 +++++ test/tstQueryTreeDegenerate.cpp | 54 +++++++++--------- test/tstQueryTreeManufacturedSolution.cpp | 6 ++ 20 files changed, 273 insertions(+), 109 deletions(-) diff --git a/benchmarks/brute_force_vs_bvh/brute_force_vs_bvh_timpl.hpp b/benchmarks/brute_force_vs_bvh/brute_force_vs_bvh_timpl.hpp index 51d66f1ea..b5e57cee3 100644 --- a/benchmarks/brute_force_vs_bvh/brute_force_vs_bvh_timpl.hpp +++ b/benchmarks/brute_force_vs_bvh/brute_force_vs_bvh_timpl.hpp @@ -83,6 +83,7 @@ static void run_fp(int nprimitives, int nqueries, int nrepeats) Placeholder primitives{nprimitives}; Placeholder predicates{nqueries}; + using Point = ArborX::ExperimentalHyperGeometry::Point; using Box = ArborX::ExperimentalHyperGeometry::Box; for (int i = 0; i < nrepeats; i++) @@ -91,8 +92,8 @@ static void run_fp(int nprimitives, int nqueries, int nrepeats) { Kokkos::Timer timer; ArborX::BasicBoundingVolumeHierarchy< - MemorySpace, ArborX::Details::PairIndexVolume> - bvh{space, primitives}; + MemorySpace, ArborX::Details::PairIndexVolume> + bvh{space, ArborX::Details::LegacyValues{primitives, Point{}}}; Kokkos::View indices("Benchmark::indices_ref", 0); Kokkos::View offset("Benchmark::offset_ref", 0); diff --git a/benchmarks/dbscan/ArborX_DBSCANVerification.hpp b/benchmarks/dbscan/ArborX_DBSCANVerification.hpp index 8b3879487..4f0d0b0fa 100644 --- a/benchmarks/dbscan/ArborX_DBSCANVerification.hpp +++ b/benchmarks/dbscan/ArborX_DBSCANVerification.hpp @@ -302,12 +302,13 @@ bool verifyDBSCAN(ExecutionSpace exec_space, Primitives const &primitives, ARBORX_ASSERT(eps > 0); ARBORX_ASSERT(core_min_size >= 2); - constexpr int dim = GeometryTraits::dimension_v< - typename Details::AccessTraitsHelper::type>; + using Point = typename Details::AccessTraitsHelper::type; + static_assert(GeometryTraits::is_point{}); + constexpr int dim = GeometryTraits::dimension_v; using Box = ExperimentalHyperGeometry::Box; ArborX::BasicBoundingVolumeHierarchy> - bvh(exec_space, primitives); + bvh(exec_space, ArborX::Details::LegacyValues{primitives, Box{}}); auto const predicates = Details::PrimitivesWithRadius{primitives, eps}; diff --git a/examples/triangle_intersection/triangle_intersection.cpp b/examples/triangle_intersection/triangle_intersection.cpp index 008f923f7..49280f177 100644 --- a/examples/triangle_intersection/triangle_intersection.cpp +++ b/examples/triangle_intersection/triangle_intersection.cpp @@ -36,6 +36,7 @@ constexpr float hx = Lx / (nx - 1); constexpr float hy = Ly / (ny - 1); using Point = ArborX::ExperimentalHyperGeometry::Point<2>; +using Box = ArborX::ExperimentalHyperGeometry::Box<2>; using Triangle = ArborX::ExperimentalHyperGeometry::Triangle<2>; #ifdef PRECOMPUTE_MAPPING @@ -206,9 +207,10 @@ struct ArborX::AccessTraits, ArborX::PrimitivesTag> { auto const &triangle = triangles(i); ArborX::ExperimentalHyperGeometry::Box<2> box{}; - box += triangle.a; - box += triangle.b; - box += triangle.c; + using ArborX::Details::expand; + expand(box, triangle.a); + expand(box, triangle.b); + expand(box, triangle.c); return box; } }; @@ -319,9 +321,8 @@ int main() // Create BVH tree ArborX::BasicBoundingVolumeHierarchy< - MemorySpace, ArborX::Details::PairIndexVolume< - ArborX::ExperimentalHyperGeometry::Box<2>>> const - tree(execution_space, triangles); + MemorySpace, ArborX::Details::PairIndexVolume> const + tree(execution_space, ArborX::Details::LegacyValues{triangles, Box{}}); // Create the points used for queries Points points(execution_space); diff --git a/src/ArborX_BruteForce.hpp b/src/ArborX_BruteForce.hpp index ab020ec1b..647a32e8d 100644 --- a/src/ArborX_BruteForce.hpp +++ b/src/ArborX_BruteForce.hpp @@ -91,7 +91,9 @@ BruteForce::BruteForce( { static_assert( KokkosExt::is_accessible_from::value); - Details::check_valid_access_traits(PrimitivesTag{}, primitives); + // FIXME for now, do not check the return type of get() + Details::check_valid_access_traits(PrimitivesTag{}, + primitives); using Access = AccessTraits; static_assert(KokkosExt::is_accessible_from::value, diff --git a/src/ArborX_DBSCAN.hpp b/src/ArborX_DBSCAN.hpp index b80944e88..4b10b7c53 100644 --- a/src/ArborX_DBSCAN.hpp +++ b/src/ArborX_DBSCAN.hpp @@ -60,15 +60,14 @@ struct WithinRadiusGetter { float _r; - template - KOKKOS_FUNCTION auto operator()(Box const &box) const + template + KOKKOS_FUNCTION auto operator()(Point const &point) const { - static_assert(GeometryTraits::is_box::value); + static_assert(GeometryTraits::is_point::value); - constexpr int dim = GeometryTraits::dimension_v; + constexpr int dim = GeometryTraits::dimension_v; auto const &hyper_point = - reinterpret_cast const &>( - box.minCorner()); + reinterpret_cast const &>(point); using ArborX::intersects; return intersects(ExperimentalHyperGeometry::Sphere{hyper_point, _r}); } @@ -98,6 +97,22 @@ struct MixedBoxPrimitives Permutation _permute; }; +template +struct PrimitivesIndexables +{ + Primitives _primitives; + + using Access = AccessTraits; + using memory_space = typename Access::memory_space; + + KOKKOS_FUNCTION decltype(auto) operator()(int i) const + { + return Access::get(_primitives, i); + } + + KOKKOS_FUNCTION auto size() const { return Access::size(_primitives); } +}; + } // namespace Details template @@ -266,8 +281,9 @@ dbscan(ExecutionSpace const &exec_space, Primitives const &primitives, using UnionFind = Details::UnionFind; #endif - constexpr int dim = GeometryTraits::dimension_v< - typename Details::AccessTraitsHelper::type>; + using Point = typename Details::AccessTraitsHelper::type; + static_assert(GeometryTraits::is_point{}); + constexpr int dim = GeometryTraits::dimension_v; using Box = ExperimentalHyperGeometry::Box; bool const is_special_case = (core_min_size == 2); @@ -290,8 +306,8 @@ dbscan(ExecutionSpace const &exec_space, Primitives const &primitives, // Build the tree Kokkos::Profiling::pushRegion("ArborX::DBSCAN::tree_construction"); ArborX::BasicBoundingVolumeHierarchy> - bvh(exec_space, primitives); + Details::PairIndexVolume> + bvh(exec_space, Details::LegacyValues{primitives, Point{}}); Kokkos::Profiling::popRegion(); Kokkos::Profiling::pushRegion("ArborX::DBSCAN::clusters"); @@ -352,7 +368,8 @@ dbscan(ExecutionSpace const &exec_space, Primitives const &primitives, Kokkos::Profiling::pushRegion("ArborX::DBSCAN::dense_cells"); Box bounds; Details::TreeConstruction::calculateBoundingBoxOfTheScene( - exec_space, Details::Indexables{primitives}, bounds); + exec_space, Details::PrimitivesIndexables{primitives}, + bounds); // The cell length is chosen to be eps/sqrt(dimension), so that any two // points within the same cell are within eps distance of each other. @@ -414,11 +431,13 @@ dbscan(ExecutionSpace const &exec_space, Primitives const &primitives, ArborX::BasicBoundingVolumeHierarchy> bvh(exec_space, - Details::MixedBoxPrimitives< - Primitives, decltype(dense_cell_offsets), - decltype(cell_indices), decltype(permute)>{ - primitives, grid, dense_cell_offsets, num_points_in_dense_cells, - sorted_cell_indices, permute}); + Details::LegacyValues{ + Details::MixedBoxPrimitives< + Primitives, decltype(dense_cell_offsets), + decltype(cell_indices), decltype(permute)>{ + primitives, grid, dense_cell_offsets, + num_points_in_dense_cells, sorted_cell_indices, permute}, + Box{}}); Kokkos::Profiling::popRegion(); diff --git a/src/ArborX_LinearBVH.hpp b/src/ArborX_LinearBVH.hpp index de148d632..6c43943cc 100644 --- a/src/ArborX_LinearBVH.hpp +++ b/src/ArborX_LinearBVH.hpp @@ -61,10 +61,11 @@ class BasicBoundingVolumeHierarchy BasicBoundingVolumeHierarchy() = default; // build an empty tree - template BasicBoundingVolumeHierarchy( - ExecutionSpace const &space, Primitives const &primitives, + ExecutionSpace const &space, Values const &values, + IndexableGetter const &indexable_getter = IndexableGetter(), SpaceFillingCurve const &curve = SpaceFillingCurve()); KOKKOS_FUNCTION @@ -131,6 +132,8 @@ class BoundingVolumeHierarchy public: using legacy_tree = void; + using bounding_volume_type = typename base_type::bounding_volume_type; + BoundingVolumeHierarchy() = default; // build an empty tree template void query(ExecutionSpace const &space, Predicates const &predicates, @@ -170,28 +178,31 @@ using BVH = BoundingVolumeHierarchy; template -template +template BasicBoundingVolumeHierarchy:: BasicBoundingVolumeHierarchy(ExecutionSpace const &space, - Primitives const &primitives, + Values const &user_values, + IndexableGetter const &indexable_getter, SpaceFillingCurve const &curve) - : _size(AccessTraits::size(primitives)) + : _size(AccessTraits::size(user_values)) , _leaf_nodes(Kokkos::view_alloc(space, Kokkos::WithoutInitializing, "ArborX::BVH::leaf_nodes"), _size) , _internal_nodes(Kokkos::view_alloc(space, Kokkos::WithoutInitializing, "ArborX::BVH::internal_nodes"), _size > 1 ? _size - 1 : 0) + , _indexable_getter(indexable_getter) { static_assert( KokkosExt::is_accessible_from::value); - Details::check_valid_access_traits(PrimitivesTag{}, primitives); - using Access = AccessTraits; + Details::check_valid_access_traits(PrimitivesTag{}, + user_values); + using Access = AccessTraits; static_assert(KokkosExt::is_accessible_from::value, - "Primitives must be accessible from the execution space"); + "Values must be accessible from the execution space"); + constexpr int DIM = GeometryTraits::dimension_v; Details::check_valid_space_filling_curve(curve); @@ -203,14 +214,18 @@ BasicBoundingVolumeHierarchy values{user_values}; + if (size() == 1) { Details::TreeConstruction::initializeSingleLeafTree( - space, Details::LegacyValues{primitives}, - _indexable_getter, _leaf_nodes, _bounds); + space, values, _indexable_getter, _leaf_nodes, _bounds); return; } + Details::Indexables indexables{user_values, + indexable_getter}; + Kokkos::Profiling::pushRegion( "ArborX::BVH::BVH::calculate_scene_bounding_box"); @@ -218,24 +233,21 @@ BasicBoundingVolumeHierarchy::type> bbox{}; - Details::TreeConstruction::calculateBoundingBoxOfTheScene( - space, Details::Indexables{primitives}, bbox); - + Details::TreeConstruction::calculateBoundingBoxOfTheScene(space, indexables, + bbox); Kokkos::Profiling::popRegion(); Kokkos::Profiling::pushRegion("ArborX::BVH::BVH::compute_linear_ordering"); // Map indexables from multidimensional domain to one-dimensional interval using LinearOrderingValueType = Kokkos::detected_t< Details::SpaceFillingCurveProjectionArchetypeExpression, - SpaceFillingCurve, decltype(bbox), - std::decay_t>; + SpaceFillingCurve, decltype(bbox), indexable_type>; Kokkos::View linear_ordering_indices( Kokkos::view_alloc(space, Kokkos::WithoutInitializing, "ArborX::BVH::BVH::linear_ordering"), size()); Details::TreeConstruction::projectOntoSpaceFillingCurve( - space, Details::Indexables{primitives}, curve, bbox, - linear_ordering_indices); + space, indexables, curve, bbox, linear_ordering_indices); Kokkos::Profiling::popRegion(); Kokkos::Profiling::pushRegion("ArborX::BVH::BVH::sort_linearized_order"); @@ -249,9 +261,8 @@ BasicBoundingVolumeHierarchy{primitives}, - _indexable_getter, permutation_indices, linear_ordering_indices, - _leaf_nodes, _internal_nodes, _bounds); + space, values, _indexable_getter, permutation_indices, + linear_ordering_indices, _leaf_nodes, _internal_nodes, _bounds); Kokkos::Profiling::popRegion(); } diff --git a/src/details/ArborX_AccessTraits.hpp b/src/details/ArborX_AccessTraits.hpp index 745b72a3c..f48fd5b1d 100644 --- a/src/details/ArborX_AccessTraits.hpp +++ b/src/details/ArborX_AccessTraits.hpp @@ -153,7 +153,7 @@ void check_valid_access_traits(PredicatesTag, Predicates const &) "Invalid tag for the predicates"); } -template +template void check_valid_access_traits(PrimitivesTag, Primitives const &) { using Access = AccessTraits; @@ -187,11 +187,32 @@ void check_valid_access_traits(PrimitivesTag, Primitives const &) "member function"); using T = std::decay_t>; - static_assert(GeometryTraits::is_point{} || GeometryTraits::is_box{}, - "AccessTraits::get() return type " - "must decay to a point or a box type"); + if constexpr (!ReturnAny) + { + static_assert(GeometryTraits::is_point{} || GeometryTraits::is_box{}, + "AccessTraits::get() return type " + "must decay to a point or a box type"); + } } +template +class AccessValues +{ +private: + using Access = AccessTraits; + +public: + Values _values; + + using memory_space = typename Access::memory_space; + + KOKKOS_FUNCTION + decltype(auto) operator()(int i) const { return Access::get(_values, i); } + + KOKKOS_FUNCTION + auto size() const { return Access::size(_values); } +}; + } // namespace Details namespace Traits diff --git a/src/details/ArborX_DetailsLegacy.hpp b/src/details/ArborX_DetailsLegacy.hpp index 370dedb1b..258d0ef05 100644 --- a/src/details/ArborX_DetailsLegacy.hpp +++ b/src/details/ArborX_DetailsLegacy.hpp @@ -15,7 +15,10 @@ #include #include -namespace ArborX::Details +namespace ArborX +{ + +namespace Details { template @@ -35,6 +38,10 @@ class LegacyValues : _primitives(primitives) {} + LegacyValues(Primitives const &primitives, BoundingVolume const &) + : _primitives(primitives) + {} + KOKKOS_FUNCTION decltype(auto) operator()(size_type i) const { @@ -55,6 +62,10 @@ class LegacyValues size_type size() const { return Access::size(_primitives); } }; +template +LegacyValues(Primitives const &, BoundingVolume const &) + -> LegacyValues; + template struct LegacyCallbackWrapper { @@ -68,6 +79,28 @@ struct LegacyCallbackWrapper } }; -} // namespace ArborX::Details +} // namespace Details + +template +struct AccessTraits, + PrimitivesTag> +{ + using Values = Details::LegacyValues; + + using memory_space = typename Values::memory_space; + using size_type = typename Values::size_type; + using value_type = typename Values::value_type; + + KOKKOS_FUNCTION static size_type size(Values const &values) + { + return values.size(); + } + KOKKOS_FUNCTION static decltype(auto) get(Values const &values, size_type i) + { + return values(i); + } +}; + +} // namespace ArborX #endif diff --git a/src/details/ArborX_IndexableGetter.hpp b/src/details/ArborX_IndexableGetter.hpp index 829b43046..db06f308c 100644 --- a/src/details/ArborX_IndexableGetter.hpp +++ b/src/details/ArborX_IndexableGetter.hpp @@ -24,9 +24,9 @@ struct DefaultIndexableGetter KOKKOS_DEFAULTED_FUNCTION DefaultIndexableGetter() = default; - template {} || - GeometryTraits::is_box{}>> + template {} || + GeometryTraits::is_box{}>> KOKKOS_FUNCTION auto const &operator()(Geometry const &geometry) const { return geometry; @@ -40,19 +40,21 @@ struct DefaultIndexableGetter } }; -template +template struct Indexables { - Primitives _primitives; - using Access = AccessTraits; + Values _values; + IndexableGetter _indexable_getter; + + using Access = AccessTraits; using memory_space = typename Access::memory_space; KOKKOS_FUNCTION decltype(auto) operator()(int i) const { - return Access::get(_primitives, i); + return _indexable_getter(Access::get(_values, i)); } - KOKKOS_FUNCTION auto size() const { return Access::size(_primitives); } + KOKKOS_FUNCTION auto size() const { return Access::size(_values); } }; } // namespace ArborX::Details diff --git a/src/details/ArborX_MinimumSpanningTree.hpp b/src/details/ArborX_MinimumSpanningTree.hpp index 24afcba81..894372a93 100644 --- a/src/details/ArborX_MinimumSpanningTree.hpp +++ b/src/details/ArborX_MinimumSpanningTree.hpp @@ -709,15 +709,13 @@ struct MinimumSpanningTree Kokkos::Profiling::pushRegion("ArborX::MST::MST"); using Access = AccessTraits; - constexpr int dim = GeometryTraits::dimension_v< - typename Details::AccessTraitsHelper::type>; - using Box = ExperimentalHyperGeometry::Box; + using Point = typename AccessTraitsHelper::type; auto const n = AccessTraits::size(primitives); Kokkos::Profiling::pushRegion("ArborX::MST::construction"); - BasicBoundingVolumeHierarchy> bvh( - space, primitives); + BasicBoundingVolumeHierarchy> bvh( + space, Details::LegacyValues{primitives, Point{}}); Kokkos::Profiling::popRegion(); if (k > 1) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 85dbc5dfa..b2000ef01 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -77,6 +77,8 @@ set(ARBORX_TEST_QUERY_TREE_SOURCES) foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BVH.cpp.tmp" "#include \n" + "#define ARBORX_APIV1\n" + "[[maybe_unused]] constexpr bool APIv1 = true;\n" "#define ARBORX_TEST_TREE_TYPES Tuple\n" "#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n" "#include \n" @@ -86,10 +88,27 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost) "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BVH.cpp" COPYONLY ) list(APPEND ARBORX_TEST_QUERY_TREE_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BVH.cpp") + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BasicBVH.cpp.tmp" + "#include \n" + "template using ArborX__BoundingVolumeHierarchy_Box = ArborX::BasicBoundingVolumeHierarchy, ArborX::Details::DefaultIndexableGetter, ArborX::Box>;\n" + "[[maybe_unused]] constexpr bool APIv1 = false;\n" + "#define ARBORX_TEST_TREE_TYPES Tuple\n" + "#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n" + "#include \n" + ) + configure_file( + "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BasicBVH.cpp.tmp" + "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BasicBVH.cpp" COPYONLY + ) + list(APPEND ARBORX_TEST_QUERY_TREE_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BasicBVH.cpp") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BF.cpp.tmp" "#include \n" "#include \n" "template using ArborX__BruteForce = ArborX::BruteForce;\n" + "#define ARBORX_APIV1\n" + "[[maybe_unused]] constexpr bool APIv1 = true;\n" "#define ARBORX_TEST_TREE_TYPES Tuple\n" "#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n" "#define ARBORX_TEST_DISABLE_NEAREST_QUERY\n" @@ -110,6 +129,7 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost) "using KDOP18 = ArborX::Experimental::KDOP<18>;\n" "using KDOP26 = ArborX::Experimental::KDOP<26>;\n" "template using ArborX__BoundingVolumeHierarchy_${_bounding_volume} = ArborX::BasicBoundingVolumeHierarchy, ArborX::Details::DefaultIndexableGetter, ${_bounding_volume}>;\n" + "[[maybe_unused]] constexpr bool APIv1 = false;\n" "#define ARBORX_TEST_TREE_TYPES Tuple\n" "#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n" "#define ARBORX_TEST_DISABLE_NEAREST_QUERY\n" @@ -123,6 +143,8 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost) list(APPEND ARBORX_TEST_QUERY_TREE_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BVH_${_bounding_volume}.cpp") endforeach() endforeach() + + list(APPEND ARBORX_TEST_QUERY_TREE_SOURCES tstQueryTreeRay.cpp tstQueryTreeTraversalPolicy.cpp diff --git a/test/Search_UnitTestHelpers.hpp b/test/Search_UnitTestHelpers.hpp index 12f5d3bd9..19575288b 100644 --- a/test/Search_UnitTestHelpers.hpp +++ b/test/Search_UnitTestHelpers.hpp @@ -25,6 +25,7 @@ #include #endif #include +#include #include #include @@ -162,7 +163,7 @@ auto query_with_distance(ExecutionSpace const &exec_space, Tree const &tree, BOOST_TEST(query_with_distance(exec_space, tree, queries) == (reference), \ boost::test_tools::per_element()); -template +template auto make(ExecutionSpace const &exec_space, std::vector const &b) { int const n = b.size(); @@ -172,7 +173,11 @@ auto make(ExecutionSpace const &exec_space, std::vector const &b) for (int i = 0; i < n; ++i) boxes_host(i) = b[i]; Kokkos::deep_copy(boxes, boxes_host); - return Tree(exec_space, boxes); + if constexpr (Legacy) + return Tree(exec_space, boxes); + else + return Tree(exec_space, ArborX::Details::LegacyValues{ + boxes, typename Tree::bounding_volume_type{}}); } #ifdef ARBORX_ENABLE_MPI diff --git a/test/tstCompileOnlyTypeRequirements.cpp b/test/tstCompileOnlyTypeRequirements.cpp index 52bd382fc..53348c495 100644 --- a/test/tstCompileOnlyTypeRequirements.cpp +++ b/test/tstCompileOnlyTypeRequirements.cpp @@ -34,6 +34,8 @@ struct FakePredicateGeometry {}; KOKKOS_FUNCTION ArborX::Point returnCentroid(FakePredicateGeometry) { return {}; } KOKKOS_FUNCTION bool intersects(FakePredicateGeometry, FakeBoundingVolume) { return true; } KOKKOS_FUNCTION float distance(FakePredicateGeometry, FakeBoundingVolume) { return 0.f; } +KOKKOS_FUNCTION bool intersects(FakePredicateGeometry, PrimitivePointOrBox) { return true; } +KOKKOS_FUNCTION float distance(FakePredicateGeometry, PrimitivePointOrBox) { return 0.f; } // clang-format on struct PoorManLambda @@ -61,7 +63,7 @@ void check_bounding_volume_and_predicate_geometry_type_requirements() using ExecutionSpace = Kokkos::DefaultExecutionSpace; using MemorySpace = ExecutionSpace::memory_space; using Tree = ArborX::BasicBoundingVolumeHierarchy< - MemorySpace, ArborX::Details::PairIndexVolume, + MemorySpace, Test::PrimitivePointOrBox, ArborX::Details::DefaultIndexableGetter, Test::FakeBoundingVolume>; Kokkos::View primitives( diff --git a/test/tstDetailsMutualReachabilityDistance.cpp b/test/tstDetailsMutualReachabilityDistance.cpp index 25ef1cbc8..dbc1a15ee 100644 --- a/test/tstDetailsMutualReachabilityDistance.cpp +++ b/test/tstDetailsMutualReachabilityDistance.cpp @@ -33,8 +33,8 @@ auto compute_core_distances(ExecutionSpace exec_space, ARBORX_ASSERT(points.extent_int(0) >= k); using MemorySpace = typename ExecutionSpace::memory_space; ArborX::BasicBoundingVolumeHierarchy< - MemorySpace, ArborX::Details::PairIndexVolume> - bvh{exec_space, points}; + MemorySpace, ArborX::Details::PairIndexVolume> + bvh{exec_space, ArborX::Details::LegacyValues{points, ArborX::Point{}}}; Kokkos::View distances( Kokkos::view_alloc(Kokkos::WithoutInitializing, "Test::core_distances"), bvh.size()); diff --git a/test/tstDetailsTreeConstruction.cpp b/test/tstDetailsTreeConstruction.cpp index 80c388d84..7cfcced27 100644 --- a/test/tstDetailsTreeConstruction.cpp +++ b/test/tstDetailsTreeConstruction.cpp @@ -158,8 +158,7 @@ void generateHierarchy(Primitives primitives, MortonCodes sorted_morton_codes, typename InternalNodes::value_type::bounding_volume_type; BoundingVolume bounds; ArborX::Details::TreeConstruction::generateHierarchy( - space, - ArborX::Details::LegacyValues{primitives}, + space, ArborX::Details::LegacyValues{primitives, BoundingVolume{}}, ArborX::Details::DefaultIndexableGetter{}, permutation_indices, sorted_morton_codes, leaf_nodes, internal_nodes, bounds); } diff --git a/test/tstKokkosToolsDistributedAnnotations.cpp b/test/tstKokkosToolsDistributedAnnotations.cpp index 351b163a1..047f9c540 100644 --- a/test/tstKokkosToolsDistributedAnnotations.cpp +++ b/test/tstKokkosToolsDistributedAnnotations.cpp @@ -38,6 +38,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( std::regex re("^(Testing::" "|ArborX::DistributedTree::" "|ArborX::BVH::" + "|Kokkos::SortImpl::BinSortFunctor::" "|ArborX::Sorting::" ").*"); BOOST_TEST(std::regex_match(label, re), diff --git a/test/tstQueryTreeCallbacks.cpp b/test/tstQueryTreeCallbacks.cpp index 6aad3feff..2a53f7c77 100644 --- a/test/tstQueryTreeCallbacks.cpp +++ b/test/tstQueryTreeCallbacks.cpp @@ -103,7 +103,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_spatial_predicate, TreeTypeTraits, auto values = initialize_values(points, /*delta*/ 0.f); std::vector offsets = {0, n}; +#ifdef ARBORX_APIV1 Tree const tree(ExecutionSpace{}, points); +#else + Tree const tree(ExecutionSpace{}, + ArborX::Details::LegacyValues{ + points, typename Tree::bounding_volume_type{}}); +#endif ARBORX_TEST_QUERY_TREE_CALLBACK(ExecutionSpace{}, tree, makeIntersectsBoxQueries({ @@ -140,7 +146,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_nearest_predicate, TreeTypeTraits, auto values = initialize_values(points, /*delta*/ 0.f); std::vector offsets = {0, n}; +#ifdef ARBORX_APIV1 Tree const tree(ExecutionSpace{}, points); +#else + Tree const tree(ExecutionSpace{}, + ArborX::Details::LegacyValues{ + points, typename Tree::bounding_volume_type{}}); +#endif ARBORX_TEST_QUERY_TREE_CALLBACK(ExecutionSpace{}, tree, makeNearestQueries({ @@ -186,12 +198,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_early_exit, TreeTypeTraits, using DeviceType = typename TreeTypeTraits::device_type; auto const tree = - make(ExecutionSpace{}, { - {{{0., 0., 0.}}, {{0., 0., 0.}}}, - {{{1., 1., 1.}}, {{1., 1., 1.}}}, - {{{2., 2., 2.}}, {{2., 2., 2.}}}, - {{{3., 3., 3.}}, {{3., 3., 3.}}}, - }); + make(ExecutionSpace{}, { + {{{0., 0., 0.}}, {{0., 0., 0.}}}, + {{{1., 1., 1.}}, {{1., 1., 1.}}}, + {{{2., 2., 2.}}, {{2., 2., 2.}}}, + {{{3., 3., 3.}}, {{3., 3., 3.}}}, + }); Kokkos::View counts("counts", 4); @@ -274,7 +286,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_with_attachment_spatial_predicate, auto values = initialize_values(points, delta); std::vector offsets = {0, n}; +#ifdef ARBORX_APIV1 Tree const tree(ExecutionSpace{}, points); +#else + Tree const tree(ExecutionSpace{}, + ArborX::Details::LegacyValues{ + points, typename Tree::bounding_volume_type{}}); +#endif ARBORX_TEST_QUERY_TREE_CALLBACK( ExecutionSpace{}, tree, @@ -313,7 +331,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_with_attachment_nearest_predicate, auto values = initialize_values(points, delta); std::vector offsets = {0, n}; +#ifdef ARBORX_APIV1 Tree const tree(ExecutionSpace{}, points); +#else + Tree const tree(ExecutionSpace{}, + ArborX::Details::LegacyValues{ + points, typename Tree::bounding_volume_type{}}); +#endif ARBORX_TEST_QUERY_TREE_CALLBACK( ExecutionSpace{}, tree, diff --git a/test/tstQueryTreeComparisonWithBoost.cpp b/test/tstQueryTreeComparisonWithBoost.cpp index 188da9e7c..9fcf9f5eb 100644 --- a/test/tstQueryTreeComparisonWithBoost.cpp +++ b/test/tstQueryTreeComparisonWithBoost.cpp @@ -98,8 +98,15 @@ void boost_rtree_nearest_predicate() auto nearest_queries_host = Kokkos::create_mirror_view(nearest_queries); Kokkos::deep_copy(nearest_queries_host, nearest_queries); +#ifdef ARBORX_APIV1 Tree tree(ExecutionSpace{}, Kokkos::create_mirror_view_and_copy(MemorySpace{}, cloud)); +#else + Tree tree(ExecutionSpace{}, + ArborX::Details::LegacyValues{ + Kokkos::create_mirror_view_and_copy(MemorySpace{}, cloud), + typename Tree::bounding_volume_type{}}); +#endif BoostExt::RTree rtree(ExecutionSpace{}, cloud); @@ -178,8 +185,15 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(boost_rtree_spatial_predicate, TreeTypeTraits, auto intersects_queries_host = Kokkos::create_mirror_view(intersects_queries); Kokkos::deep_copy(intersects_queries_host, intersects_queries); +#ifdef ARBORX_APIV1 Tree tree(ExecutionSpace{}, Kokkos::create_mirror_view_and_copy(MemorySpace{}, cloud)); +#else + Tree tree(ExecutionSpace{}, + ArborX::Details::LegacyValues{ + Kokkos::create_mirror_view_and_copy(MemorySpace{}, cloud), + typename Tree::bounding_volume_type{}}); +#endif BoostExt::RTree rtree(ExecutionSpace{}, cloud); diff --git a/test/tstQueryTreeDegenerate.cpp b/test/tstQueryTreeDegenerate.cpp index 416a1b137..103155ceb 100644 --- a/test/tstQueryTreeDegenerate.cpp +++ b/test/tstQueryTreeDegenerate.cpp @@ -34,8 +34,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(empty_tree_spatial_predicate, TreeTypeTraits, Tree value_initialized{}; for (auto const &tree : { default_initialized, value_initialized, - make(ExecutionSpace{}, - {}), // constructed with empty view of boxes + make(ExecutionSpace{}, + {}), // constructed with empty view of boxes }) { BOOST_TEST(tree.empty()); @@ -91,8 +91,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(empty_tree_nearest_predicate, TreeTypeTraits, // tree is empty, it has no leaves. for (auto const &tree : { Tree{}, // default constructed - make(ExecutionSpace{}, - {}), // constructed with empty view of boxes + make(ExecutionSpace{}, + {}), // constructed with empty view of boxes }) { BOOST_TEST(tree.empty()); @@ -130,9 +130,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(single_leaf_tree_spatial_predicate, // tree has a single leaf (unit box) auto const tree = - make(ExecutionSpace{}, { - {{{0., 0., 0.}}, {{1., 1., 1.}}}, - }); + make(ExecutionSpace{}, { + {{{0., 0., 0.}}, {{1., 1., 1.}}}, + }); BOOST_TEST(!tree.empty()); BOOST_TEST(tree.size() == 1); @@ -176,9 +176,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(single_leaf_tree_nearest_predicate, // tree has a single leaf (unit box) auto const tree = - make(ExecutionSpace{}, { - {{{0., 0., 0.}}, {{1., 1., 1.}}}, - }); + make(ExecutionSpace{}, { + {{{0., 0., 0.}}, {{1., 1., 1.}}}, + }); BOOST_TEST(!tree.empty()); BOOST_TEST(tree.size() == 1); @@ -213,10 +213,10 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(couple_leaves_tree_spatial_predicate, using DeviceType = typename TreeTypeTraits::device_type; auto const tree = - make(ExecutionSpace{}, { - {{{0., 0., 0.}}, {{0., 0., 0.}}}, - {{{1., 1., 1.}}, {{1., 1., 1.}}}, - }); + make(ExecutionSpace{}, { + {{{0., 0., 0.}}, {{0., 0., 0.}}}, + {{{1., 1., 1.}}, {{1., 1., 1.}}}, + }); BOOST_TEST(!tree.empty()); BOOST_TEST(tree.size() == 2); @@ -276,10 +276,10 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(couple_leaves_tree_nearest_predicate, using DeviceType = typename TreeTypeTraits::device_type; auto const tree = - make(ExecutionSpace{}, { - {{{0., 0., 0.}}, {{0., 0., 0.}}}, - {{{1., 1., 1.}}, {{1., 1., 1.}}}, - }); + make(ExecutionSpace{}, { + {{{0., 0., 0.}}, {{0., 0., 0.}}}, + {{{1., 1., 1.}}, {{1., 1., 1.}}}, + }); BOOST_TEST(!tree.empty()); BOOST_TEST(tree.size() == 2); @@ -315,12 +315,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(duplicated_leaves_spatial_predicate, // at construction had leaves with no parent which yielded a segfault later // when computing bounding boxes and walking the hierarchy toward the root. auto const tree = - make(ExecutionSpace{}, { - {{{0., 0., 0.}}, {{0., 0., 0.}}}, - {{{1., 1., 1.}}, {{1., 1., 1.}}}, - {{{1., 1., 1.}}, {{1., 1., 1.}}}, - {{{1., 1., 1.}}, {{1., 1., 1.}}}, - }); + make(ExecutionSpace{}, { + {{{0., 0., 0.}}, {{0., 0., 0.}}}, + {{{1., 1., 1.}}, {{1., 1., 1.}}}, + {{{1., 1., 1.}}, {{1., 1., 1.}}}, + {{{1., 1., 1.}}, {{1., 1., 1.}}}, + }); ARBORX_TEST_QUERY_TREE( ExecutionSpace{}, tree, @@ -356,7 +356,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(not_exceeding_stack_capacity_spatial_predicate, } ExecutionSpace space; auto const bvh = - make>(space, boxes); + make, true /*APIv1*/>( + space, boxes); Kokkos::View indices("indices", 0); Kokkos::View offset("offset", 0); @@ -390,7 +391,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(not_exceeding_stack_capacity_nearest_predicate, } ExecutionSpace space; auto const bvh = - make>(space, boxes); + make, true /*APIv1*/>( + space, boxes); Kokkos::View indices("indices", 0); Kokkos::View offset("offset", 0); diff --git a/test/tstQueryTreeManufacturedSolution.cpp b/test/tstQueryTreeManufacturedSolution.cpp index 6f2d563fc..abcaa779f 100644 --- a/test/tstQueryTreeManufacturedSolution.cpp +++ b/test/tstQueryTreeManufacturedSolution.cpp @@ -80,7 +80,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(structured_grid, TreeTypeTraits, } Kokkos::deep_copy(bounding_boxes, bounding_boxes_host); +#ifdef ARBORX_APIV1 Tree const tree(ExecutionSpace{}, bounding_boxes); +#else + Tree const tree(ExecutionSpace{}, + ArborX::Details::LegacyValues{ + bounding_boxes, typename Tree::bounding_volume_type{}}); +#endif std::vector offset_ref(n + 1); std::vector indices_ref;