Skip to content

Commit 785c85a

Browse files
authored
feat(mpi): add non-blocking broadcast (#190)
* fix!: make "core" `broadcast` in-place only This is to match MPI's C API, and enable binding the MPI backend to the "core" API of KokkosComm. This change also forces the NCCL backend to only expose the in-place version of its broadcast (which was the only one we tested anyway). * feat(mpi): add non-blocking broadcast Prepare for exposure in "core" API. Signed-off-by: Gabriel Dos Santos <[email protected]> --------- Signed-off-by: Gabriel Dos Santos <[email protected]>
1 parent 4c56040 commit 785c85a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/KokkosComm/mpi/broadcast.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,31 @@
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"
15+
#include "impl/error_handling.hpp"
1316

1417
namespace KokkosComm::mpi {
1518

19+
template <KokkosExecutionSpace ExecSpace, KokkosView View>
20+
auto ibroadcast(const ExecSpace& space, View& v, int root, MPI_Comm comm) -> Req<Mpi> {
21+
using T = typename View::non_const_value_type;
22+
Kokkos::Tools::pushRegion("KokkosComm::mpi::ibroadcast");
23+
fail_if(!is_contiguous(v), "KokkosComm::mpi::ibroadcast: unimplemented for non-contiguous views");
24+
25+
// Sync: Work in space may have been used to produce view data.
26+
space.fence("fence before non-blocking broadcast");
27+
28+
Req<Mpi> req;
29+
MPI_Ibcast(data_handle(v), span(v), Impl::mpi_type_v<T>, root, comm, &req.mpi_request());
30+
req.extend_view_lifetime(v);
31+
32+
Kokkos::Tools::popRegion();
33+
return req;
34+
}
35+
1636
template <KokkosView View>
1737
void broadcast(View const& v, int root, MPI_Comm comm) {
1838
Kokkos::Tools::pushRegion("KokkosComm::mpi::broadcast");

0 commit comments

Comments
 (0)