Skip to content

Commit

Permalink
Move AttachIndices to Experimental and add attach_indices
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Dec 23, 2023
1 parent bf94eb5 commit 2f317e6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions benchmarks/brute_force_vs_bvh/brute_force_vs_bvh_timpl.hpp
Expand Up @@ -91,7 +91,7 @@ static void run_fp(int nprimitives, int nqueries, int nrepeats)
Kokkos::Timer timer;
ArborX::BoundingVolumeHierarchy<MemorySpace,
ArborX::PairValueIndex<Point>>
bvh{space, ArborX::AttachIndices<decltype(primitives)>{primitives}};
bvh{space, ArborX::Experimental::attach_indices(primitives)};

Kokkos::View<int *, ExecutionSpace> indices("Benchmark::indices_ref", 0);
Kokkos::View<int *, ExecutionSpace> offset("Benchmark::offset_ref", 0);
Expand All @@ -110,7 +110,7 @@ static void run_fp(int nprimitives, int nqueries, int nrepeats)
{
Kokkos::Timer timer;
ArborX::BruteForce<MemorySpace, ArborX::PairValueIndex<Point>> brute{
space, ArborX::AttachIndices<decltype(primitives)>{primitives}};
space, ArborX::Experimental::attach_indices(primitives)};

Kokkos::View<int *, ExecutionSpace> indices("Benchmark::indices", 0);
Kokkos::View<int *, ExecutionSpace> offset("Benchmark::offset", 0);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/dbscan/ArborX_DBSCANVerification.hpp
Expand Up @@ -312,7 +312,7 @@ bool verifyDBSCAN(ExecutionSpace exec_space, Primitives const &primitives,
static_assert(GeometryTraits::is_point<Point>{});

ArborX::BoundingVolumeHierarchy<MemorySpace, ArborX::PairValueIndex<Point>>
bvh(exec_space, ArborX::AttachIndices<Points>{points});
bvh(exec_space, ArborX::Experimental::attach_indices(points));

auto const predicates = Details::PrimitivesWithRadius<Points>{points, eps};

Expand Down
3 changes: 1 addition & 2 deletions examples/triangle_intersection/triangle_intersection.cpp
Expand Up @@ -323,8 +323,7 @@ int main()
// Create BVH tree
ArborX::BoundingVolumeHierarchy<MemorySpace,
ArborX::PairValueIndex<Box>> const
tree(execution_space,
ArborX::AttachIndices<decltype(triangles)>{triangles});
tree(execution_space, ArborX::Experimental::attach_indices(triangles));

// Create the points used for queries
Points<MemorySpace> points(execution_space);
Expand Down
5 changes: 2 additions & 3 deletions src/ArborX_DBSCAN.hpp
Expand Up @@ -279,7 +279,7 @@ dbscan(ExecutionSpace const &exec_space, Primitives const &primitives,
// Build the tree
Kokkos::Profiling::pushRegion("ArborX::DBSCAN::tree_construction");
BoundingVolumeHierarchy<MemorySpace, PairValueIndex<Point>> bvh(
exec_space, AttachIndices<Points>{points});
exec_space, Experimental::attach_indices(points));
Kokkos::Profiling::popRegion();

// Initialize labels after the hierarchy construction to lower memory high
Expand Down Expand Up @@ -421,8 +421,7 @@ dbscan(ExecutionSpace const &exec_space, Primitives const &primitives,
permute};

BoundingVolumeHierarchy<MemorySpace, PairValueIndex<Box>> bvh(
exec_space,
AttachIndices<decltype(mixed_primitives)>{mixed_primitives});
exec_space, Experimental::attach_indices(mixed_primitives));

Kokkos::Profiling::popRegion();

Expand Down
2 changes: 1 addition & 1 deletion src/details/ArborX_MinimumSpanningTree.hpp
Expand Up @@ -58,7 +58,7 @@ struct MinimumSpanningTree

Kokkos::Profiling::pushRegion("ArborX::MST::construction");
BoundingVolumeHierarchy<MemorySpace, PairValueIndex<Point>> bvh(
space, AttachIndices<Points>{points});
space, Experimental::attach_indices(points));
Kokkos::Profiling::popRegion();

if (k > 1)
Expand Down
15 changes: 12 additions & 3 deletions src/details/ArborX_PairValueIndex.hpp
Expand Up @@ -31,7 +31,9 @@ struct PairValueIndex
Index index;
};

template <typename Values, typename Index = unsigned>
namespace Experimental
{
template <typename Values, typename Index>
class AttachIndices
{
private:
Expand All @@ -54,13 +56,20 @@ class AttachIndices
auto size() const { return _data.size(); }
};

template <typename Values, typename Index = unsigned>
auto attach_indices(Values const &values)
{
return AttachIndices<Values, Index>{values};
}
} // namespace Experimental

} // namespace ArborX

template <typename Values, typename Index>
struct ArborX::AccessTraits<ArborX::AttachIndices<Values, Index>,
struct ArborX::AccessTraits<ArborX::Experimental::AttachIndices<Values, Index>,
ArborX::PrimitivesTag>
{
using Self = ArborX::AttachIndices<Values, Index>;
using Self = ArborX::Experimental::AttachIndices<Values, Index>;

using memory_space = typename Self::memory_space;

Expand Down
2 changes: 1 addition & 1 deletion src/interpolation/ArborX_InterpMovingLeastSquares.hpp
Expand Up @@ -130,7 +130,7 @@ class MovingLeastSquares

// Organize the source points as a tree
BoundingVolumeHierarchy<MemorySpace, ArborX::PairValueIndex<src_point>>
source_tree(space, ArborX::AttachIndices<SourcePoints>{source_points});
source_tree(space, ArborX::Experimental::attach_indices(source_points));

// Create the predicates
Details::MLSTargetPointsPredicateWrapper<TargetPoints> predicates{
Expand Down
2 changes: 1 addition & 1 deletion test/tstDetailsMutualReachabilityDistance.cpp
Expand Up @@ -34,7 +34,7 @@ auto compute_core_distances(ExecutionSpace exec_space,
using MemorySpace = typename ExecutionSpace::memory_space;
ArborX::BoundingVolumeHierarchy<MemorySpace,
ArborX::PairValueIndex<ArborX::Point>>
bvh{exec_space, ArborX::AttachIndices<decltype(points)>{points}};
bvh{exec_space, ArborX::Experimental::attach_indices(points)};
Kokkos::View<float *, MemorySpace> distances(
Kokkos::view_alloc(Kokkos::WithoutInitializing, "Test::core_distances"),
bvh.size());
Expand Down

0 comments on commit 2f317e6

Please sign in to comment.