-
Notifications
You must be signed in to change notification settings - Fork 46
ArborX::DistributedTree::DistributedTree
Daniel Arndt edited this page Aug 30, 2022
·
3 revisions
ArborX / Spatial indexes / ArborX::DistributedTree
template <typename ExecutionSpace, typename Primitives>
DistributedTree(MPI_Comm comm, ExecutionSpace const& space, Primitives const& primitives); // (1)- Constructs a bounding volume hierarchy from the given data source.
comm
: the MPI communicator.
space
: the execution space.
primitives
: geometrical objects one wishes to index.
-
MemorySpacemust be accessible fromExecutionSpace(i.e.,Kokkos::SpaceAccessibility<ExecutionSpace, MemorySpace>::accessiblemust betrue). - A specialization of
ArborX::AccessTraitsmust matchPrimitivesas the first template argument andArborX::PrimitivesTagas second argument. - The return type of
ArborX::AccessTraits<Primitives,ArborX::PrimitivesTag>::get()must decay either toArborX::PointorArborX::Box. ArborX provides specializations for Kokkos::View objects but a user may specialize it for their types.
O(N log N), where N is the number of primitives passed to the constructor (ArborX::AccessTraits<Primitives,ArborX::PrimitivesTag>::size(primitives)).
Memory allocation with Kokkos may throw.
The constructor must be called by all MPI ranks related to the given MPI communicator collectively.
#include <ArborX_DistributedTree.hpp>
#include <Kokkos_Core.hpp>
#include <iostream>
int main(int argc, char *argv[])
{
MPI_Init(&argc, &argv);
{
Kokkos::ScopeGuard guard(argc, argv);
MPI_Comm const comm = MPI_COMM_WORLD;
int comm_rank;
MPI_Comm_rank(comm, &comm_rank);
Kokkos::View<ArborX::Point *> cloud("point_cloud", 10);
Kokkos::parallel_for(10, KOKKOS_LAMBDA(int i) {
cloud[i] = {{(float)i + 10 * comm_rank, (float)i, (float)i}};
});
using memory_space = decltype(cloud)::memory_space; // where to store the tree
using execution_space = decltype(cloud)::execution_space; // where to execute code
ArborX::DistributedTree<memory_space> bvh{comm, execution_space{}, cloud};
if (comm_rank == 0)
{
auto const box = bvh.bounds();
auto min = box.minCorner();
auto max = box.maxCorner();
std::cout << min[0] << ',' << min[1] << ',' << min[2] << " - "
<< max[0] << ',' << max[1] << ',' << max[2] << '\n';
}
}
MPI_Finalize();
return 0;
}Output for 4 MPI processes
(0,0,0) - (39,9,9)
query
: search for all primitives that meet some predicates.
bounds
: returns the bounding volume that contains all leaves.