kokkos / kokkos-comm

Experimental MPI Wrapper for Kokkos
https://kokkos.org/kokkos-comm/
Other
14 stars 9 forks source link

Provide a KokkosCommInitialize #82

Open cedricchevalier19 opened 3 months ago

cedricchevalier19 commented 3 months ago

It must enforce a correct calling order for MPI_Init and Kokkos::initialize.

It should also handle special Kokkos arguments:

Another pretty annoying thing that we have to do is to avoid passing --help to non-zero ranks, as otherwise Kokkos would print help on all ranks. We do it like this:

// Strip "--help" and "--kokkos-help" from the flags passed to Kokkos if we
// are not on MPI rank 0 to prevent Kokkos from printing the help message
// multiply.
if (comm_rank != 0)
{
auto *help_it = std::find_if(argv, argv + argc, [](std::string const &x) {
return x == "--help" || x == "--kokkos-help";
});
if (help_it != argv + argc)
{
std::swap(*help_it, *(argv + argc - 1));
--argc;
}
}
Kokkos::initialize(argc, argv);

Originally posted by @aprokop in https://github.com/kokkos/kokkos-comm/issues/53#issuecomment-2105364199

dssgabriel commented 3 months ago

Tracking issue for #68?

Note that with the MPI Sessions model, we do not require users to call MPI_Init before our own initialization.

cedricchevalier19 commented 3 months ago

68 is more than that: here, it is a simple function that does not necessarily use sessions.