Skip to content

Commit 05ea6d7

Browse files
authored
Merge pull request #69 from cwpearson/mpi/allgather-inplace
MPI: in-place allgather for contiguous views
2 parents 26eba36 + 7b6615f commit 05ea6d7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/impl/KokkosComm_allgather.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ void allgather(const SendView &sv, const RecvView &rv, MPI_Comm comm) {
5050
Kokkos::Tools::popRegion();
5151
}
5252

53+
// in-place allgather
54+
template <KokkosView RecvView>
55+
void allgather(const RecvView &rv, MPI_Comm comm) {
56+
Kokkos::Tools::pushRegion("KokkosComm::Impl::allgather");
57+
58+
using RT = KokkosComm::Traits<RecvView>;
59+
using RecvScalar = typename RecvView::value_type;
60+
61+
static_assert(RT::rank() <= 1, "allgather for RecvView::rank > 1 not supported");
62+
63+
if (!RT::is_contiguous(rv)) {
64+
throw std::runtime_error("low-level allgather requires contiguous recv view");
65+
}
66+
MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, RT::data_handle(rv), RT::span(rv), mpi_type_v<RecvScalar>, comm);
67+
68+
Kokkos::Tools::popRegion();
69+
}
70+
5371
template <KokkosExecutionSpace ExecSpace, KokkosView SendView, KokkosView RecvView>
5472
void allgather(const ExecSpace &space, const SendView &sv, const RecvView &rv, MPI_Comm comm) {
5573
Kokkos::Tools::pushRegion("KokkosComm::Impl::allgather");

0 commit comments

Comments
 (0)