Skip to content

Commit

Permalink
Initialize HIP before MPI for older Cray MPICH versions
Browse files Browse the repository at this point in the history
  • Loading branch information
msimberg committed Feb 1, 2024
1 parent 56b6b2a commit e2584d5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion include/dlaf/communication/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

#include <mpi.h>

#ifdef DLAF_WITH_HIP
#include <hip/hip_runtime.h>
#include <whip.hpp>
#endif

#include <pika/mutex.hpp>

#include <dlaf/communication/error.h>
Expand All @@ -25,7 +30,13 @@ namespace comm {

struct mpi_init {
/// Initialize MPI to MPI_THREAD_MULTIPLE
mpi_init(int argc, char** argv) noexcept {
mpi_init(int argc, char **argv) noexcept {
// On older Cray MPICH versions initializing HIP after MPI leads to HIP not seeing any devices. Hence
// we eagerly initialize HIP here before MPI.
#ifdef DLAF_WITH_HIP
whip::check_error(hipInit(0));
#endif

int required_threading = MPI_THREAD_MULTIPLE;
int provided_threading;
MPI_Init_thread(&argc, &argv, required_threading, &provided_threading);
Expand Down

0 comments on commit e2584d5

Please sign in to comment.