Skip to content

Commit

Permalink
Add DistributedTree::getComm() private member function and use it
Browse files Browse the repository at this point in the history
  • Loading branch information
dalg24 committed Sep 14, 2020
1 parent 9281c93 commit 275981b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/ArborX_DistributedSearchTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class DistributedSearchTree
private:
template <typename DeviceType>
friend struct Details::DistributedSearchTreeImpl;
MPI_Comm getComm() const { return *_comm_ptr; }
std::shared_ptr<MPI_Comm> _comm_ptr;
BVH<MemorySpace> _top_tree; // replicated
BVH<MemorySpace> _bottom_tree; // local
Expand Down Expand Up @@ -130,9 +131,9 @@ DistributedSearchTree<MemorySpace, Enable>::DistributedSearchTree(
});

int comm_rank;
MPI_Comm_rank(*_comm_ptr, &comm_rank);
MPI_Comm_rank(getComm(), &comm_rank);
int comm_size;
MPI_Comm_size(*_comm_ptr, &comm_size);
MPI_Comm_size(getComm(), &comm_size);

Kokkos::View<Box *, MemorySpace> boxes(
Kokkos::ViewAllocateWithoutInitializing("rank_bounding_boxes"),
Expand All @@ -143,7 +144,7 @@ DistributedSearchTree<MemorySpace, Enable>::DistributedSearchTree(
boxes_host(comm_rank) = _bottom_tree.bounds();
MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
static_cast<void *>(boxes_host.data()), sizeof(Box), MPI_BYTE,
*_comm_ptr);
getComm());
Kokkos::deep_copy(space, boxes, boxes_host);

_top_tree = BVH<MemorySpace>{space, boxes};
Expand All @@ -155,7 +156,7 @@ DistributedSearchTree<MemorySpace, Enable>::DistributedSearchTree(
bottom_tree_sizes_host(comm_rank) = _bottom_tree.size();
MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
static_cast<void *>(bottom_tree_sizes_host.data()),
sizeof(size_type), MPI_BYTE, *_comm_ptr);
sizeof(size_type), MPI_BYTE, getComm());
Kokkos::deep_copy(space, _bottom_tree_sizes, bottom_tree_sizes_host);

_top_tree_size = accumulate(space, _bottom_tree_sizes, 0);
Expand Down
6 changes: 3 additions & 3 deletions src/details/ArborX_DetailsDistributedSearchTreeImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct DistributedSearchTreeImpl
IndicesAndRanks &values, Offset &offset)
{
int comm_rank;
MPI_Comm_rank(tree._comm, &comm_rank);
MPI_Comm_rank(tree.getComm(), &comm_rank);
queryDispatch(SpatialPredicateTag{}, tree, space, queries,
CallbackDefaultSpatialPredicateWithRank{comm_rank}, values,
offset);
Expand Down Expand Up @@ -379,7 +379,7 @@ DistributedSearchTreeImpl<DeviceType>::queryDispatchImpl(
Offset &offset, Ranks &ranks, Distances *distances_ptr)
{
auto const &bottom_tree = tree._bottom_tree;
auto comm = tree._comm;
auto comm = tree.getComm();

Distances distances("distances", 0);
if (distances_ptr)
Expand Down Expand Up @@ -452,7 +452,7 @@ DistributedSearchTreeImpl<DeviceType>::queryDispatch(
{
auto const &top_tree = tree._top_tree;
auto const &bottom_tree = tree._bottom_tree;
auto comm = tree._comm;
auto comm = tree.getComm();

Kokkos::View<int *, DeviceType> indices("indices", 0);
Kokkos::View<int *, DeviceType> ranks("ranks", 0);
Expand Down

0 comments on commit 275981b

Please sign in to comment.