Skip to content

Commit 4c56040

Browse files
authored
feat(mpi): add non-blocking all-gather (#192)
Prepare for exposure in "core" API. Signed-off-by: Gabriel Dos Santos <[email protected]>
1 parent 498e171 commit 4c56040

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/KokkosComm/mpi/allgather.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,38 @@
88

99
#include <KokkosComm/concepts.hpp>
1010
#include <KokkosComm/traits.hpp>
11+
#include "mpi_space.hpp"
12+
#include "req.hpp"
1113

1214
#include "impl/types.hpp"
1315
#include "impl/error_handling.hpp"
1416

1517
namespace KokkosComm::mpi {
1618

19+
template <KokkosExecutionSpace ExecSpace, KokkosView SView, KokkosView RView>
20+
auto iallgather(const ExecSpace &space, const SView sv, RView rv, MPI_Comm comm) -> Req<Mpi> {
21+
using ST = typename SView::non_const_value_type;
22+
using RT = typename RView::non_const_value_type;
23+
static_assert(std::is_same_v<ST, RT>, "KokkosComm::mpi::iallgather: View value types must be identical");
24+
Kokkos::Tools::pushRegion("KokkosComm::mpi::iallgather");
25+
26+
fail_if(!is_contiguous(sv) || !is_contiguous(rv),
27+
"KokkosComm::mpi::iallgather: unimplemented for non-contiguous views");
28+
29+
// Sync: Work in space may have been used to produce view data.
30+
space.fence("fence before non-blocking all-gather");
31+
32+
Req<Mpi> req;
33+
// All ranks send/recv same count
34+
MPI_Iallgather(data_handle(sv), span(sv), Impl::mpi_type_v<ST>, data_handle(rv), span(sv), Impl::mpi_type_v<RT>, comm,
35+
&req.mpi_request());
36+
req.extend_view_lifetime(sv);
37+
req.extend_view_lifetime(rv);
38+
39+
Kokkos::Tools::popRegion();
40+
return req;
41+
}
42+
1743
template <KokkosView SendView, KokkosView RecvView>
1844
void allgather(const SendView &sv, const RecvView &rv, MPI_Comm comm) {
1945
Kokkos::Tools::pushRegion("KokkosComm::Mpi::allgather");

0 commit comments

Comments
 (0)