|
8 | 8 |
|
9 | 9 | #include <KokkosComm/concepts.hpp> |
10 | 10 | #include <KokkosComm/traits.hpp> |
| 11 | +#include "mpi_space.hpp" |
| 12 | +#include "req.hpp" |
11 | 13 |
|
12 | 14 | #include "impl/pack_traits.hpp" |
13 | 15 | #include "impl/types.hpp" |
14 | 16 | #include "impl/error_handling.hpp" |
15 | 17 |
|
16 | 18 | namespace KokkosComm::mpi { |
17 | 19 |
|
| 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 | + |
18 | 44 | template <KokkosExecutionSpace ExecSpace, KokkosView SendView, KokkosView RecvView> |
19 | 45 | void alltoall(const ExecSpace &space, const SendView &sv, const size_t sendCount, const RecvView &rv, |
20 | 46 | const size_t recvCount, MPI_Comm comm) { |
|
0 commit comments