-
Notifications
You must be signed in to change notification settings - Fork 45
ArborX::DistributedTree::DistributedTree
Andrey Prokopenko edited this page Apr 15, 2025
·
3 revisions
ArborX / Spatial indexes / ArborX::DistributedTree
DistributedTree() noexcept; // (1)
template <typename ExecutionSpace, typename Values>
DistributedTree(MPI_Comm comm, ExecutionSpace const& space, Values const& values); // (2)
template <typename ExecutionSpace, typename Values>
DistributedTree(MPI_Comm comm, ExecutionSpace const& space, Values const& values, IndexableGetter const& indexable_getter); // (3)- Default constructor. Constructs an empty tree.
- Constructs a bounding volume hierarchy from a given data source.
- Constructs a bounding volume hierarchy from a given data source and a function tranforming a value into indexable.
comm : the MPI communicator.
space: execution space
values: values stored in the container
indexable_getter: a function object to transform a value into an indexable
-
MemorySpacemust be accessible fromExecutionSpace(i.e.,Kokkos::SpaceAccessibility<ExecutionSpace, MemorySpace>::accessiblemust betrue). - A specialization of
ArborX::AccessTraitsmust matchValuesas the template argument. - The return type of
ArborX::AccessTraits<Values>::get()must decay toValue. ArborX provides specializations for Kokkos views but a user may specialize it for their types. -
IndexableGettermust provide anoperator()taking in a type that decays toValueand returning an indexable (geometric object).
O(N log N), where N is the number of primitives passed to the constructor (ArborX::AccessTraits<Values>::size(values)).
Memory allocation with Kokkos may throw.
The constructor must be called by all MPI ranks related in the provided MPI communicator.
#include <ArborX_DistributedTree.hpp>
#include <Kokkos_Core.hpp>
#include <iostream>
int main(int argc, char *argv[])
{
MPI_Init(&argc, &argv);
Kokkos::initialize(argc, argv);
MPI_Comm const comm = MPI_COMM_WORLD;
int comm_rank;
MPI_Comm_rank(comm, &comm_rank);
Kokkos::View<ArborX::Point<3> *> 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 dist_tree{comm, execution_space{}, cloud};
if (comm_rank == 0)
{
auto const box = dist_tree.bounds();
auto min = box.minCorner();
auto max = box.maxCorner();
std::cout << min[0] << ',' << min[1] << ',' << min[2] << " - "
<< max[0] << ',' << max[1] << ',' << max[2] << '\n';
}
Kokkos::finalize();
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.