2 use mpi_f08,
only : mpi_comm, mpi_datatype, mpi_initialized, mpi_init_thread, &
3 mpi_init, mpi_thread_single, mpi_thread_funneled, &
4 mpi_thread_serialized, mpi_thread_multiple, mpi_comm_rank, &
5 mpi_comm_split, mpi_comm_dup, mpi_barrier, mpi_comm_free, mpi_finalize, &
6 mpi_comm_world, mpi_double_precision, mpi_real, mpi_comm_size, &
17 bind(c, name=
'neko_comm_wrapper_init')
18 use,
intrinsic :: iso_c_binding, only : c_int
19 integer(c_int),
value :: fcomm
23 subroutine neko_comm_nvshmem_init() &
24 bind(c, name=
'neko_comm_nvshmem_init')
25 end subroutine neko_comm_nvshmem_init
27 subroutine neko_comm_nvshmem_finalize() &
28 bind(c, name=
'neko_comm_nvshmem_finalize')
29 end subroutine neko_comm_nvshmem_finalize
32#if defined(HAVE_NCCL) || defined(HAVE_RCCL)
33 subroutine neko_comm_nccl_init() &
34 bind(c, name=
'neko_comm_nccl_init')
35 end subroutine neko_comm_nccl_init
37 subroutine neko_comm_nccl_finalize() &
38 bind(c, name=
'neko_comm_nccl_finalize')
39 end subroutine neko_comm_nccl_finalize
50#ifdef HAVE_MPI_PARAM_DTYPE
65 logical,
public ::
nio
91 logical :: initialized
92 integer :: provided, nthrds
95 character(len=255) :: color_str
96 character(len=32) :: thread_str
97 integer :: thread_envvar_len
98 integer :: requested_thread_level
99 logical :: user_thread_level
101 integer :: shmem_ierr
102 integer :: shmem_requested
109 call mpi_initialized(initialized, ierr)
111 call get_environment_variable(
"NEKO_COMM_ID", color_str, envvar_len)
112 if (envvar_len .gt. 0)
then
113 read(color_str(1:envvar_len), *) color
125 call get_environment_variable(
"NEKO_MPI_THREAD_LEVEL", thread_str, &
127 user_thread_level = thread_envvar_len .gt. 0
128 if (user_thread_level)
then
129 select case (trim(adjustl(thread_str(1:thread_envvar_len))))
130 case (
"single",
"SINGLE")
131 requested_thread_level = mpi_thread_single
132 case (
"funneled",
"FUNNELED")
133 requested_thread_level = mpi_thread_funneled
134 case (
"serialized",
"SERIALIZED")
135 requested_thread_level = mpi_thread_serialized
136 case (
"multiple",
"MULTIPLE")
137 requested_thread_level = mpi_thread_multiple
139 call neko_error(
'Unknown NEKO_MPI_THREAD_LEVEL: '// &
140 trim(thread_str(1:thread_envvar_len)))
144 if (.not.initialized)
then
145 if (user_thread_level)
then
146 if (requested_thread_level .eq. mpi_thread_single)
then
148 provided = mpi_thread_single
150 call mpi_init_thread(requested_thread_level, provided, ierr)
151 if (provided .lt. requested_thread_level)
then
152 call neko_error(
'Requested MPI thread level not provided')
155 else if (nthrds .gt. 1)
then
156 call mpi_init_thread(mpi_thread_multiple, provided, ierr)
157 if (provided .lt. mpi_thread_multiple)
then
163 call neko_error(
'Invalid thread support provided by MPI')
164 else if (provided .lt. mpi_thread_funneled)
then
165 call neko_error(
'Invalid thread support provided by MPI')
172 call mpi_query_thread(provided, ierr)
177#ifndef HAVE_MPI_PARAM_DTYPE
185 call mpi_comm_rank(mpi_comm_world,
pe_rank, ierr)
194 if (envvar_len .gt. 0)
then
209 call neko_comm_nvshmem_init()
212#if defined(HAVE_NCCL) | defined(HAVE_RCCL)
214 call neko_comm_nccl_init()
219 if (user_thread_level)
then
220 select case (requested_thread_level)
221 case (mpi_thread_single)
223 case (mpi_thread_funneled)
225 case (mpi_thread_serialized)
227 case (mpi_thread_multiple)
236 else if (nthrds .gt. 1)
then
266 integer,
intent(in) :: provided
270 call neko_error(
'Invalid thread support provided by SHMEM')
284 call neko_comm_nccl_finalize()
288 call neko_comm_nvshmem_finalize()
295 call mpi_finalize(ierr)
subroutine, public comm_free
subroutine, public comm_init
logical, public nio
I/O node.
type(mpi_comm), public neko_global_comm
type(mpi_datatype), public mpi_real_precision
MPI type for working precision of REAL types.
integer, public global_pe_rank
Global MPI rank.
integer, public pe_size
MPI size of communicator.
integer, public pe_rank
MPI rank.
integer, public global_pe_size
Global MPI size of communicator.
type(mpi_comm), public neko_comm
MPI communicator.
integer, public neko_mpi_thread_provided
Thread support provided by the MPI library.
subroutine shmem_check_thread_level(provided)
Decide whether the thread level an OpenSHMEM library handed back is usable, given how Neko drives it.
type(mpi_datatype), public mpi_extra_precision
pure logical function, public is_mpmd()
Whether this is one of several simulations coupled in an MPMD run, that is, whether Neko's communicat...
integer, parameter neko_bcknd_device
Fortran bindings to SHMEM's C API.
@ shmem_thread_serialized