Skip to content

Commit b2749cc

Browse files
authored
Initialize HIP ASAP (#988)
1 parent 3de92ca commit b2749cc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Source/main.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,16 @@ main(int argc, char* argv[])
5656
}
5757
}
5858

59-
// Make sure to catch new failures.
59+
#ifdef AMREX_USE_HIP
60+
// Explicitly initialize the HIP runtime before MPI/AMReX to avoid lazy init
61+
// race conditions at scale.
62+
hipError_t herr = hipInit(0);
63+
if (herr != hipSuccess) {
64+
fprintf(stderr, "hipInit failed: %s\n", hipGetErrorString(herr));
65+
return 1;
66+
}
67+
#endif
68+
6069
amrex::Initialize(
6170
argc, argv, true, MPI_COMM_WORLD, override_default_parameters);
6271
// Defined and initialized when in gnumake, but not defined in cmake and

0 commit comments

Comments
 (0)