From b933420268aeb228cb50344d52aceaf27ef38d49 Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Sat, 23 Nov 2024 14:48:59 -0500 Subject: [PATCH 1/2] Get rid of PairValueIndex and LegacyDefaultCallback in examples --- .../simple_intersection/example_intersection.cpp | 11 +++++------ .../triangle_intersection.cpp | 15 ++++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/simple_intersection/example_intersection.cpp b/examples/simple_intersection/example_intersection.cpp index 1386b6020..579a5ab7f 100644 --- a/examples/simple_intersection/example_intersection.cpp +++ b/examples/simple_intersection/example_intersection.cpp @@ -50,13 +50,12 @@ int main(int argc, char *argv[]) ExecutionSpace space; - using Value = ArborX::PairValueIndex; - ArborX::BoundingVolumeHierarchy const tree( space, ArborX::Experimental::attach_indices(boxes)); // The query will resize values and offsets accordingly - Kokkos::View values("Example::values", 0); + Kokkos::View values( + "Example::values", 0); Kokkos::View offsets("Example::offsets", 0); tree.query(space, queries, values, offsets); @@ -73,9 +72,9 @@ int main(int argc, char *argv[]) std::copy(offsets_host.data(), offsets_host.data() + offsets.size(), std::ostream_iterator(std::cout, " ")); std::cout << "\nindices:"; - for (int i = 0; i < values_host.extent_int(0); ++i) - std::cout << " " << values_host(i).index; - std::cout << '\n'; + std::transform(values_host.data(), values_host.data() + values.size(), + std::ostream_iterator(std::cout, " "), + [](auto value) { return value.index; }); return 0; } diff --git a/examples/triangle_intersection/triangle_intersection.cpp b/examples/triangle_intersection/triangle_intersection.cpp index b54e345f9..f638160a4 100644 --- a/examples/triangle_intersection/triangle_intersection.cpp +++ b/examples/triangle_intersection/triangle_intersection.cpp @@ -88,15 +88,15 @@ int main(int argc, char *argv[]) space, ArborX::Experimental::attach_indices(triangles)); // The query will resize indices and offsets accordingly - Kokkos::View indices("Example::indices", 0); + Kokkos::View values( + "Example::values", 0); Kokkos::View offsets("Example::offsets", 0); - tree.query(space, queries, ArborX::Details::LegacyDefaultCallback{}, indices, - offsets); + tree.query(space, queries, values, offsets); auto offsets_host = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, offsets); - auto indices_host = - Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, indices); + auto values_host = + Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, values); // Expected output: // offsets: 0 1 2 3 4 @@ -105,8 +105,9 @@ int main(int argc, char *argv[]) std::copy(offsets_host.data(), offsets_host.data() + offsets.size(), std::ostream_iterator(std::cout, " ")); std::cout << "\nindices: "; - std::copy(indices_host.data(), indices_host.data() + indices.size(), - std::ostream_iterator(std::cout, " ")); + std::transform(values_host.data(), values_host.data() + values.size(), + std::ostream_iterator(std::cout, " "), + [](auto value) { return value.index; }); std::cout << "\n"; return 0; From f124970541cf05485f59853cd7469cc3fbe9c1ca Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Sat, 23 Nov 2024 14:49:27 -0500 Subject: [PATCH 2/2] Get rid of LegacyDefaultCallback --- src/spatial/detail/ArborX_Callbacks.hpp | 15 --------------- test/ArborXTest_LegacyTree.hpp | 8 ++++++-- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/spatial/detail/ArborX_Callbacks.hpp b/src/spatial/detail/ArborX_Callbacks.hpp index 625ec4dd0..d6f06221b 100644 --- a/src/spatial/detail/ArborX_Callbacks.hpp +++ b/src/spatial/detail/ArborX_Callbacks.hpp @@ -45,21 +45,6 @@ struct DefaultCallback } }; -struct LegacyDefaultCallback -{ - template - KOKKOS_FUNCTION void operator()(Query const &, - PairValueIndex const &value, - OutputFunctor const &output) const - { - // APIv1 callback has the signature operator()(Query, int) - // As we store PairValueIndex with potentially non int index (like - // unsigned), we explicitly cast it here. - output((int)value.index); - } -}; - // archetypal alias for a 'tag' type member in user callbacks template using CallbackTagArchetypeAlias = typename Callback::tag; diff --git a/test/ArborXTest_LegacyTree.hpp b/test/ArborXTest_LegacyTree.hpp index 31427e893..8d2486ce6 100644 --- a/test/ArborXTest_LegacyTree.hpp +++ b/test/ArborXTest_LegacyTree.hpp @@ -134,7 +134,9 @@ class LegacyTree : public Tree query(ExecutionSpace const &space, Predicates const &predicates, View &&view, Args &&...args) const { - Tree::query(space, predicates, ArborX::Details::LegacyDefaultCallback{}, + Tree::query(space, predicates, + LegacyCallbackWrapper{ + ArborX::Details::DefaultCallback{}}, std::forward(view), std::forward(args)...); } @@ -159,7 +161,9 @@ class LegacyTree : public Tree { Kokkos::View indices( "Testing::indices", 0); - Tree::query(space, predicates, ArborX::Details::LegacyDefaultCallback{}, + Tree::query(space, predicates, + LegacyCallbackWrapper{ + ArborX::Details::DefaultCallback{}}, indices, std::forward(offset), std::forward(args)...); callback(predicates, std::forward(offset), indices,