diff --git a/src/ArborX_DistributedSearchTree.hpp b/src/ArborX_DistributedSearchTree.hpp index 436b70f5d6..e93516c0ec 100644 --- a/src/ArborX_DistributedSearchTree.hpp +++ b/src/ArborX_DistributedSearchTree.hpp @@ -101,6 +101,7 @@ class DistributedSearchTree private: template friend struct Details::DistributedSearchTreeImpl; + MPI_Comm getComm() const { return *_comm_ptr; } std::shared_ptr _comm_ptr; BVH _top_tree; // replicated BVH _bottom_tree; // local @@ -132,9 +133,9 @@ DistributedSearchTree::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 boxes( Kokkos::ViewAllocateWithoutInitializing("rank_bounding_boxes"), @@ -145,7 +146,7 @@ DistributedSearchTree::DistributedSearchTree( boxes_host(comm_rank) = _bottom_tree.bounds(); MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, static_cast(boxes_host.data()), sizeof(Box), MPI_BYTE, - *_comm_ptr); + getComm()); Kokkos::deep_copy(space, boxes, boxes_host); _top_tree = BVH{space, boxes}; @@ -157,7 +158,7 @@ DistributedSearchTree::DistributedSearchTree( bottom_tree_sizes_host(comm_rank) = _bottom_tree.size(); MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, static_cast(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); diff --git a/src/details/ArborX_DetailsDistributedSearchTreeImpl.hpp b/src/details/ArborX_DetailsDistributedSearchTreeImpl.hpp index 8147c1d07b..13d5932ac3 100644 --- a/src/details/ArborX_DetailsDistributedSearchTreeImpl.hpp +++ b/src/details/ArborX_DetailsDistributedSearchTreeImpl.hpp @@ -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); @@ -379,7 +379,7 @@ DistributedSearchTreeImpl::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) @@ -452,7 +452,7 @@ DistributedSearchTreeImpl::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 indices("indices", 0); Kokkos::View ranks("ranks", 0);