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
16 bind(c, name=
'neko_comm_wrapper_init')
17 use,
intrinsic :: iso_c_binding, only : c_int
18 integer(c_int),
value :: fcomm
22 subroutine neko_comm_nvshmem_init() &
23 bind(c, name=
'neko_comm_nvshmem_init')
24 end subroutine neko_comm_nvshmem_init
26 subroutine neko_comm_nvshmem_finalize() &
27 bind(c, name=
'neko_comm_nvshmem_finalize')
28 end subroutine neko_comm_nvshmem_finalize
31#if defined(HAVE_NCCL) || defined(HAVE_RCCL)
32 subroutine neko_comm_nccl_init() &
33 bind(c, name=
'neko_comm_nccl_init')
34 end subroutine neko_comm_nccl_init
36 subroutine neko_comm_nccl_finalize() &
37 bind(c, name=
'neko_comm_nccl_finalize')
38 end subroutine neko_comm_nccl_finalize
49#ifdef HAVE_MPI_PARAM_DTYPE
64 logical,
public ::
nio
80 logical :: initialized
81 integer :: provided, nthrds
84 character(len=255) :: color_str
85 character(len=32) :: thread_str
86 integer :: thread_envvar_len
87 integer :: requested_thread_level
88 logical :: user_thread_level
91 integer :: shmem_requested
98 call mpi_initialized(initialized, ierr)
100 call get_environment_variable(
"NEKO_COMM_ID", color_str, envvar_len)
101 if (envvar_len .gt. 0)
then
102 read(color_str(1:envvar_len), *) color
114 call get_environment_variable(
"NEKO_MPI_THREAD_LEVEL", thread_str, &
116 user_thread_level = thread_envvar_len .gt. 0
117 if (user_thread_level)
then
118 select case (trim(adjustl(thread_str(1:thread_envvar_len))))
119 case (
"single",
"SINGLE")
120 requested_thread_level = mpi_thread_single
121 case (
"funneled",
"FUNNELED")
122 requested_thread_level = mpi_thread_funneled
123 case (
"serialized",
"SERIALIZED")
124 requested_thread_level = mpi_thread_serialized
125 case (
"multiple",
"MULTIPLE")
126 requested_thread_level = mpi_thread_multiple
128 call neko_error(
'Unknown NEKO_MPI_THREAD_LEVEL: '// &
129 trim(thread_str(1:thread_envvar_len)))
133 if (.not.initialized)
then
134 if (user_thread_level)
then
135 if (requested_thread_level .eq. mpi_thread_single)
then
137 provided = mpi_thread_single
139 call mpi_init_thread(requested_thread_level, provided, ierr)
140 if (provided .lt. requested_thread_level)
then
141 call neko_error(
'Requested MPI thread level not provided')
144 else if (nthrds .gt. 1)
then
145 call mpi_init_thread(mpi_thread_multiple, provided, ierr)
146 if (provided .lt. mpi_thread_multiple)
then
152 call neko_error(
'Invalid thread support provided by MPI')
153 else if (provided .lt. mpi_thread_funneled)
then
154 call neko_error(
'Invalid thread support provided by MPI')
164#ifndef HAVE_MPI_PARAM_DTYPE
172 call mpi_comm_rank(mpi_comm_world,
pe_rank, ierr)
181 if (envvar_len .gt. 0)
then
196 call neko_comm_nvshmem_init()
199#if defined(HAVE_NCCL) | defined(HAVE_RCCL)
201 call neko_comm_nccl_init()
206 if (user_thread_level)
then
207 select case (requested_thread_level)
208 case (mpi_thread_single)
210 case (mpi_thread_funneled)
212 case (mpi_thread_serialized)
214 case (mpi_thread_multiple)
221 if (provided .lt. shmem_requested)
then
222 call neko_error(
'Requested SHMEM thread level not provided')
225 else if (nthrds .gt. 1)
then
229 call neko_error(
'Invalid thread support provided by SHMEM')
233 call neko_error(
'Invalid thread support provided by SHMEM')
253 call neko_comm_nccl_finalize()
257 call neko_comm_nvshmem_finalize()
264 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.
type(mpi_datatype), public mpi_extra_precision
integer, parameter neko_bcknd_device
Fortran bindings to SHMEM's C API.
@ shmem_thread_serialized