diff --git a/Source/main.cpp b/Source/main.cpp index e8a6573ab..a328c3698 100644 --- a/Source/main.cpp +++ b/Source/main.cpp @@ -56,7 +56,16 @@ main(int argc, char* argv[]) } } - // Make sure to catch new failures. +#ifdef AMREX_USE_HIP + // Explicitly initialize the HIP runtime before MPI/AMReX to avoid lazy init + // race conditions at scale. + hipError_t herr = hipInit(0); + if (herr != hipSuccess) { + fprintf(stderr, "hipInit failed: %s\n", hipGetErrorString(herr)); + return 1; + } +#endif + amrex::Initialize( argc, argv, true, MPI_COMM_WORLD, override_default_parameters); // Defined and initialized when in gnumake, but not defined in cmake and