|
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/types.hpp" |
13 | 15 | #include "impl/error_handling.hpp" |
14 | 16 |
|
15 | 17 | namespace KokkosComm::mpi { |
16 | 18 |
|
| 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 | + |
17 | 43 | template <KokkosView SendView, KokkosView RecvView> |
18 | 44 | void allgather(const SendView &sv, const RecvView &rv, MPI_Comm comm) { |
19 | 45 | Kokkos::Tools::pushRegion("KokkosComm::Mpi::allgather"); |
|
0 commit comments