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
81 logical :: initialized
82 integer :: provided, nthrds
85 character(len=255) :: color_str
86 character(len=32) :: thread_str
87 integer :: thread_envvar_len
88 integer :: requested_thread_level
89 logical :: user_thread_level
92 integer :: shmem_requested
99 call mpi_initialized(initialized, ierr)
101 call get_environment_variable(
"NEKO_COMM_ID", color_str, envvar_len)
102 if (envvar_len .gt. 0)
then
103 read(color_str(1:envvar_len), *) color
115 call get_environment_variable(
"NEKO_MPI_THREAD_LEVEL", thread_str, &
117 user_thread_level = thread_envvar_len .gt. 0
118 if (user_thread_level)
then
119 select case (trim(adjustl(thread_str(1:thread_envvar_len))))
120 case (
"single",
"SINGLE")
121 requested_thread_level = mpi_thread_single
122 case (
"funneled",
"FUNNELED")
123 requested_thread_level = mpi_thread_funneled
124 case (
"serialized",
"SERIALIZED")
125 requested_thread_level = mpi_thread_serialized
126 case (
"multiple",
"MULTIPLE")
127 requested_thread_level = mpi_thread_multiple
129 call neko_error(
'Unknown NEKO_MPI_THREAD_LEVEL: '// &
130 trim(thread_str(1:thread_envvar_len)))
134 if (.not.initialized)
then
135 if (user_thread_level)
then
136 if (requested_thread_level .eq. mpi_thread_single)
then
138 provided = mpi_thread_single
140 call mpi_init_thread(requested_thread_level, provided, ierr)
141 if (provided .lt. requested_thread_level)
then
142 call neko_error(
'Requested MPI thread level not provided')
145 else if (nthrds .gt. 1)
then
146 call mpi_init_thread(mpi_thread_multiple, provided, ierr)
147 if (provided .lt. mpi_thread_multiple)
then
153 call neko_error(
'Invalid thread support provided by MPI')
154 else if (provided .lt. mpi_thread_funneled)
then
155 call neko_error(
'Invalid thread support provided by MPI')
162 call mpi_query_thread(provided, ierr)
167#ifndef HAVE_MPI_PARAM_DTYPE
175 call mpi_comm_rank(mpi_comm_world,
pe_rank, ierr)
184 if (envvar_len .gt. 0)
then
199 call neko_comm_nvshmem_init()
202#if defined(HAVE_NCCL) | defined(HAVE_RCCL)
204 call neko_comm_nccl_init()
209 if (user_thread_level)
then
210 select case (requested_thread_level)
211 case (mpi_thread_single)
213 case (mpi_thread_funneled)
215 case (mpi_thread_serialized)
217 case (mpi_thread_multiple)
224 if (provided .lt. shmem_requested)
then
225 call neko_error(
'Requested SHMEM thread level not provided')
228 else if (nthrds .gt. 1)
then
232 call neko_error(
'Invalid thread support provided by SHMEM')
236 call neko_error(
'Invalid thread support provided by SHMEM')
256 call neko_comm_nccl_finalize()
260 call neko_comm_nvshmem_finalize()
267 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