diff --git a/src/common/m_mpi_common.fpp b/src/common/m_mpi_common.fpp index 7a549f6bb6..386333d43c 100644 --- a/src/common/m_mpi_common.fpp +++ b/src/common/m_mpi_common.fpp @@ -138,6 +138,11 @@ contains proc_rank = 0 #endif + ! First device operation, on the default device: with NVHPC OpenMP offload a rank's first one must come before + ! omp_set_default_device moves it to another GPU, or its later allocations fail with CUDA_ERROR_INVALID_CONTEXT. The + ! bound device gets its own copy in s_initialize_mpi_domain. + $:GPU_UPDATE(device='[num_procs, proc_rank]') + end subroutine s_mpi_initialize !> Set up MPI I/O data views and variable pointers for parallel file output. diff --git a/src/simulation/m_start_up.fpp b/src/simulation/m_start_up.fpp index 6e21a22684..40e9799992 100644 --- a/src/simulation/m_start_up.fpp +++ b/src/simulation/m_start_up.fpp @@ -1104,7 +1104,7 @@ contains #endif #endif - ! After the device is bound: s_mpi_initialize ran earlier, so its update went to the default device + ! After the device is bound: the update in s_mpi_initialize went to the default device $:GPU_UPDATE(device='[num_procs, proc_rank]') if (proc_rank == 0) then