Skip to content

Commit 498e171

Browse files
committed
feat(mpi): add non-blocking all-to-all
Prepare for exposure in "core" API. Signed-off-by: Gabriel Dos Santos <[email protected]>
1 parent 404167a commit 498e171

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/KokkosComm/mpi/alltoall.hpp

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

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

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

1618
namespace KokkosComm::mpi {
1719

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

0 commit comments

Comments
 (0)