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 db95d0bd6..6440f0de9 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 @@ -75,43 +75,43 @@ template static void run_fp(int nprimitives, int nqueries, int nrepeats) { ExecutionSpace space{}; + Placeholder primitives{nprimitives}; Placeholder predicates{nqueries}; + using Point = ArborX::Point; for (int i = 0; i < nrepeats; i++) { [[maybe_unused]] unsigned int out_count; { Kokkos::Timer timer; - ArborX::BoundingVolumeHierarchy bvh{ - space, ArborX::Experimental::attach_indices(primitives)}; + ArborX::BoundingVolumeHierarchy bvh{space, primitives}; - Kokkos::View indices("Benchmark::indices_ref", 0); + Kokkos::View values("Benchmark::values_ref", 0); Kokkos::View offset("Benchmark::offset_ref", 0); - bvh.query(space, predicates, indices, offset); + bvh.query(space, predicates, values, offset); space.fence(); double time = timer.seconds(); if (i == 0) printf("Collisions: %.5f\n", - (float)(indices.extent(0)) / (nprimitives * nqueries)); + (float)(values.extent(0)) / (nprimitives * nqueries)); printf("Time BVH : %lf\n", time); - out_count = indices.extent(0); + out_count = values.extent(0); } { Kokkos::Timer timer; - ArborX::BruteForce brute{ - space, ArborX::Experimental::attach_indices(primitives)}; + ArborX::BruteForce brute{space, primitives}; - Kokkos::View indices("Benchmark::indices", 0); + Kokkos::View values("Benchmark::values", 0); Kokkos::View offset("Benchmark::offset", 0); - brute.query(space, predicates, indices, offset); + brute.query(space, predicates, values, offset); space.fence(); double time = timer.seconds(); printf("Time BF : %lf\n", time); - assert(out_count == indices.extent(0)); + assert(out_count == values.extent(0)); } } } diff --git a/benchmarks/bvh_driver/benchmark_registration.hpp b/benchmarks/bvh_driver/benchmark_registration.hpp index 264e7ae70..dab40acfa 100644 --- a/benchmarks/bvh_driver/benchmark_registration.hpp +++ b/benchmarks/bvh_driver/benchmark_registration.hpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -135,7 +136,10 @@ auto makeTree(ExecutionSpace const &space, Primitives const &primitives) if constexpr (is_boost_rtree_v) return TreeType(space, primitives); else - return TreeType(space, ArborX::Experimental::attach_indices(primitives)); + return TreeType(space, + ArborX::Experimental::Iota{ + primitives.size()}, + primitives); } template diff --git a/benchmarks/bvh_driver/bvh_driver.cpp b/benchmarks/bvh_driver/bvh_driver.cpp index 2fa521b69..1741ff764 100644 --- a/benchmarks/bvh_driver/bvh_driver.cpp +++ b/benchmarks/bvh_driver/bvh_driver.cpp @@ -51,9 +51,10 @@ struct BenchmarkRegistration template using BVHBenchmarkRegistration = BenchmarkRegistration< - ExecutionSpace, - ArborX::BoundingVolumeHierarchy>>>; + ExecutionSpace, ArborX::BoundingVolumeHierarchy< + typename ExecutionSpace::memory_space, int, + Kokkos::View *, + typename ExecutionSpace::memory_space>>>; void register_bvh_benchmarks(Spec const &spec) { diff --git a/benchmarks/dbscan/ArborX_DBSCANVerification.hpp b/benchmarks/dbscan/ArborX_DBSCANVerification.hpp index 78fa1eff9..8b4b8e956 100644 --- a/benchmarks/dbscan/ArborX_DBSCANVerification.hpp +++ b/benchmarks/dbscan/ArborX_DBSCANVerification.hpp @@ -13,6 +13,7 @@ #define ARBORX_DETAILSDBSCANVERIFICATION_HPP #include +#include #include #include @@ -299,7 +300,8 @@ bool verifyDBSCAN(ExecutionSpace exec_space, Primitives const &primitives, static_assert(GeometryTraits::is_point_v); ArborX::BoundingVolumeHierarchy bvh( - exec_space, ArborX::Experimental::attach_indices(points)); + exec_space, ArborX::Experimental::Iota{points.size()}, + points); auto const predicates = ArborX::Experimental::attach_indices( ArborX::Experimental::make_intersects(points, eps)); diff --git a/examples/brute_force/example_brute_force.cpp b/examples/brute_force/example_brute_force.cpp index 6bf5543d2..9847b38fe 100644 --- a/examples/brute_force/example_brute_force.cpp +++ b/examples/brute_force/example_brute_force.cpp @@ -23,13 +23,13 @@ struct Dummy using ExecutionSpace = Kokkos::DefaultExecutionSpace; using MemorySpace = ExecutionSpace::memory_space; -template <> -struct ArborX::AccessTraits +struct DummyIndexableGetter { + int count; + using memory_space = MemorySpace; - using size_type = typename MemorySpace::size_type; - static KOKKOS_FUNCTION size_type size(Dummy const &d) { return d.count; } - static KOKKOS_FUNCTION auto get(Dummy const &, size_type i) + KOKKOS_FUNCTION auto size() const { return count; } + KOKKOS_FUNCTION auto operator()(int i) const { return ArborX::Point{(float)i, (float)i, (float)i}; } @@ -69,13 +69,13 @@ int main(int argc, char *argv[]) int nprimitives = 5; int npredicates = 5; - Dummy primitives{nprimitives}; + ArborX::Experimental::Iota primitives{nprimitives}; + DummyIndexableGetter indexable_getter{nprimitives}; Dummy predicates{npredicates}; unsigned int out_count; { - ArborX::BoundingVolumeHierarchy bvh{ - space, ArborX::Experimental::attach_indices(primitives)}; + ArborX::BoundingVolumeHierarchy bvh{space, primitives, indexable_getter}; Kokkos::View indices("Example::indices_ref", 0); Kokkos::View offset("Example::offset_ref", 0); @@ -88,8 +88,7 @@ int main(int argc, char *argv[]) } { - ArborX::BruteForce brute{space, - ArborX::Experimental::attach_indices(primitives)}; + ArborX::BruteForce brute{space, primitives, indexable_getter}; Kokkos::View indices("Example::indices", 0); Kokkos::View offset("Example::offset", 0); diff --git a/examples/simple_intersection/example_intersection.cpp b/examples/simple_intersection/example_intersection.cpp index e0d03be79..d360871ab 100644 --- a/examples/simple_intersection/example_intersection.cpp +++ b/examples/simple_intersection/example_intersection.cpp @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) ExecutionSpace space; ArborX::BoundingVolumeHierarchy const tree( - space, ArborX::Experimental::attach_indices(boxes)); + space, ArborX::Experimental::Iota{boxes.size()}, boxes); // The query will resize indices and offsets accordingly Kokkos::View indices("Example::indices", 0); diff --git a/src/ArborX.hpp b/src/ArborX.hpp index 28335e2a7..e0d667bb5 100644 --- a/src/ArborX.hpp +++ b/src/ArborX.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/src/distributed/ArborX_DistributedTree.hpp b/src/distributed/ArborX_DistributedTree.hpp index 5d0431fee..d265363d9 100644 --- a/src/distributed/ArborX_DistributedTree.hpp +++ b/src/distributed/ArborX_DistributedTree.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -36,8 +37,9 @@ class DistributedTreeBase using MemorySpace = typename BottomTree::memory_space; using BoundingVolume = typename BottomTree::bounding_volume_type; using TopTree = - BoundingVolumeHierarchy, - Details::DefaultIndexableGetter, BoundingVolume>; + BoundingVolumeHierarchy, + BoundingVolume>; using bottom_tree_type = BottomTree; using top_tree_type = TopTree; @@ -228,7 +230,8 @@ DistributedTreeBase::DistributedTreeBase( #endif // Build top tree with attached ranks - _top_tree = TopTree{space, Experimental::attach_indices(volumes)}; + _top_tree = + TopTree{space, Experimental::Iota{volumes.size()}, volumes}; Kokkos::Profiling::popRegion(); Kokkos::Profiling::pushRegion("ArborX::DistributedTree::DistributedTree::" diff --git a/src/spatial/detail/ArborX_Iota.hpp b/src/spatial/detail/ArborX_Iota.hpp index d2a90aabe..b3bc77c47 100644 --- a/src/spatial/detail/ArborX_Iota.hpp +++ b/src/spatial/detail/ArborX_Iota.hpp @@ -18,7 +18,7 @@ #include -namespace ArborX +namespace ArborX::Experimental { template @@ -35,11 +35,13 @@ struct Iota : _n(n) {} }; +} // namespace ArborX::Experimental template -struct ArborX::AccessTraits, ArborX::PrimitivesTag> +struct ArborX::AccessTraits, + ArborX::PrimitivesTag> { - using Self = Iota; + using Self = ArborX::Experimental::Iota; using memory_space = typename Self::memory_space; static KOKKOS_FUNCTION size_t size(Self const &self) { return self._n; } @@ -49,6 +51,4 @@ struct ArborX::AccessTraits, ArborX::PrimitivesTag> } }; -} // namespace ArborX - #endif diff --git a/test/tstQueryTreeIntersectsKDOP.cpp b/test/tstQueryTreeIntersectsKDOP.cpp index f0b7cf193..216f249c6 100644 --- a/test/tstQueryTreeIntersectsKDOP.cpp +++ b/test/tstQueryTreeIntersectsKDOP.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -28,8 +29,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_kdop, DeviceType, ARBORX_DEVICE_TYPES) using MemorySpace = typename DeviceType::memory_space; using Point = ArborX::Point<3>; - using Tree = ArborX::BoundingVolumeHierarchy>; std::vector primitives = { {{0, 0, 0}}, // 0 @@ -46,12 +45,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_kdop, DeviceType, ARBORX_DEVICE_TYPES) {{0, 0, 2}}, // 11 {{0, 0, 3}}, // 12 }; - Tree const tree( + ArborX::BoundingVolumeHierarchy const tree( ExecutionSpace{}, - ArborX::Experimental::attach_indices(Kokkos::create_mirror_view_and_copy( + ArborX::Experimental::Iota{primitives.size()}, + Kokkos::create_mirror_view_and_copy( MemorySpace{}, Kokkos::View( - primitives.data(), primitives.size())))); + primitives.data(), primitives.size()))); // (0,0,0)->(1,2,3) box with (0,0,0)--(0,0,3) edge cut off ArborX::Experimental::KDOP<3, 18> x;