From e1250ce16f5097793837230c9b63e925a7c43762 Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Mon, 11 Nov 2024 10:35:05 -0500 Subject: [PATCH] Simplify Iota struct usage --- .../bvh_driver/benchmark_registration.hpp | 21 ++++++------------- examples/brute_force/example_brute_force.cpp | 18 ++++------------ test/tstQueryTreeIntersectsKDOP.cpp | 20 +++++------------- 3 files changed, 15 insertions(+), 44 deletions(-) diff --git a/benchmarks/bvh_driver/benchmark_registration.hpp b/benchmarks/bvh_driver/benchmark_registration.hpp index 179f831fd..f22991d83 100644 --- a/benchmarks/bvh_driver/benchmark_registration.hpp +++ b/benchmarks/bvh_driver/benchmark_registration.hpp @@ -32,19 +32,12 @@ struct is_boost_rtree> : std::true_type template inline constexpr bool is_boost_rtree_v = is_boost_rtree::value; -template +template struct Iota { + static_assert(Kokkos::is_memory_space_v); using memory_space = MemorySpace; - using index_type = Index; - - size_t _n; - - template >> - Iota(T n) - : _n(n) - {} + int _n; }; template @@ -54,10 +47,7 @@ struct ArborX::AccessTraits, ArborX::PrimitivesTag> using memory_space = typename Self::memory_space; static KOKKOS_FUNCTION size_t size(Self const &self) { return self._n; } - static KOKKOS_FUNCTION auto get(Self const &, size_t i) - { - return (typename Self::index_type)i; - } + static KOKKOS_FUNCTION auto get(Self const &, int i) { return i; } }; struct Spec @@ -164,7 +154,8 @@ auto makeTree(ExecutionSpace const &space, Primitives const &primitives) return TreeType(space, primitives); else return TreeType(space, - Iota{primitives.size()}, + Iota{ + static_cast(primitives.size())}, primitives); } diff --git a/examples/brute_force/example_brute_force.cpp b/examples/brute_force/example_brute_force.cpp index 46cfb65a3..22445f79a 100644 --- a/examples/brute_force/example_brute_force.cpp +++ b/examples/brute_force/example_brute_force.cpp @@ -23,19 +23,12 @@ struct Dummy using ExecutionSpace = Kokkos::DefaultExecutionSpace; using MemorySpace = ExecutionSpace::memory_space; -template +template struct Iota { + static_assert(Kokkos::is_memory_space_v); using memory_space = MemorySpace; - using index_type = Index; - - size_t _n; - - template >> - Iota(T n) - : _n(n) - {} + int _n; }; template @@ -45,10 +38,7 @@ struct ArborX::AccessTraits, ArborX::PrimitivesTag> using memory_space = typename Self::memory_space; static KOKKOS_FUNCTION size_t size(Self const &self) { return self._n; } - static KOKKOS_FUNCTION auto get(Self const &, size_t i) - { - return (typename Self::index_type)i; - } + static KOKKOS_FUNCTION auto get(Self const &, int i) { return i; } }; struct DummyIndexableGetter diff --git a/test/tstQueryTreeIntersectsKDOP.cpp b/test/tstQueryTreeIntersectsKDOP.cpp index a62c885e9..21dac3737 100644 --- a/test/tstQueryTreeIntersectsKDOP.cpp +++ b/test/tstQueryTreeIntersectsKDOP.cpp @@ -18,19 +18,12 @@ #include -template +template struct Iota { + static_assert(Kokkos::is_memory_space_v); using memory_space = MemorySpace; - using index_type = Index; - - size_t _n; - - template >> - Iota(T n) - : _n(n) - {} + int _n; }; template @@ -40,10 +33,7 @@ struct ArborX::AccessTraits, ArborX::PrimitivesTag> using memory_space = typename Self::memory_space; static KOKKOS_FUNCTION size_t size(Self const &self) { return self._n; } - static KOKKOS_FUNCTION auto get(Self const &, size_t i) - { - return (typename Self::index_type)i; - } + static KOKKOS_FUNCTION auto get(Self const &, int i) { return i; } }; #include @@ -73,7 +63,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(intersects_kdop, DeviceType, ARBORX_DEVICE_TYPES) {{0, 0, 3}}, // 12 }; ArborX::BoundingVolumeHierarchy const tree( - ExecutionSpace{}, Iota{primitives.size()}, + ExecutionSpace{}, Iota{static_cast(primitives.size())}, Kokkos::create_mirror_view_and_copy( MemorySpace{}, Kokkos::View(