Skip to content

Commit d5739ef

Browse files
authored
add multi gpu support (#2)
* add multi gpu support * address review comments, add helpful comment for the acc/mp runbtime call
1 parent 3e3da6e commit d5739ef

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mpp/include/mpp_comm_mpi.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3232
!> @brief Initialize the @ref mpp_mod module. Must be called before any usage.
3333
subroutine mpp_init( flags, localcomm, test_level, alt_input_nml_path )
34+
!$use omp_lib
3435
integer, optional, intent(in) :: flags !< Flags for debug output, can be MPP_VERBOSE or MPP_DEBUG
3536
integer, optional, intent(in) :: localcomm !< Id of MPI communicator used to initialize
3637
integer, optional, intent(in) :: test_level !< Used to exit initialization at certain stages
@@ -54,6 +55,14 @@
5455
call MPI_COMM_RANK( mpp_comm_private, pe, error )
5556
call MPI_COMM_SIZE( mpp_comm_private, npes, error )
5657

58+
! set default device to enable multi GPU parallelism
59+
! calls to both OpenACC and OpenMP runtimes are needed
60+
! because we use both do-concurrent and openmp
61+
! if you remove either, the code will run multiple
62+
! ranks on a _single_ GPU. Be careful out there!
63+
!$call omp_set_default_device(pe)
64+
!$acc set device_num(pe)
65+
5766
module_is_initialized = .TRUE.
5867
if (present(test_level)) then
5968
t_level = test_level

0 commit comments

Comments
 (0)