39 use mpi_f08,
only : mpi_test, mpi_status_ignore, mpi_status, &
40 mpi_request, mpi_isend, mpi_irecv
42 use,
intrinsic :: iso_c_binding
51 type(mpi_status) :: status
53 type(mpi_request) :: request
58 real(kind=
rp),
allocatable ::
data(:)
81 class(
gs_mpi_t),
intent(inout) :: this
84 integer,
pointer :: sp(:), rp(:)
87 call this%init_order(send_pe, recv_pe)
89 allocate(this%send_buf(send_pe%size()))
92 do i = 1, send_pe%size()
93 allocate(this%send_buf(i)%data(this%send_dof(sp(i))%size()))
96 allocate(this%recv_buf(recv_pe%size()))
99 do i = 1, recv_pe%size()
100 allocate(this%recv_buf(i)%data(this%recv_dof(rp(i))%size()))
107 class(
gs_mpi_t),
intent(inout) :: this
110 if (
allocated(this%send_buf))
then
111 do i = 1,
size(this%send_buf)
112 if (
allocated(this%send_buf(i)%data))
then
113 deallocate(this%send_buf(i)%data)
116 deallocate(this%send_buf)
119 if (
allocated(this%recv_buf))
then
120 do i = 1,
size(this%recv_buf)
121 if (
allocated(this%recv_buf(i)%data))
then
122 deallocate(this%recv_buf(i)%data)
125 deallocate(this%recv_buf)
128 call this%free_order()
129 call this%free_dofs()
135 class(
gs_mpi_t),
intent(inout) :: this
136 integer,
intent(in) :: n
137 real(kind=
rp),
dimension(n),
intent(inout) :: u
138 type(c_ptr),
intent(inout) :: deps
139 type(c_ptr),
intent(inout) :: strm
140 integer :: i, j, ierr, dst, thrdid
141 integer ,
pointer :: sp(:)
146 do i = 1,
size(this%send_pe)
147 dst = this%send_pe(i)
150 sp => this%send_dof(dst)%array()
151 do concurrent(j = 1:this%send_dof(dst)%size())
152 this%send_buf(i)%data(j) = u(sp(j))
157 associate(send_data => this%send_buf(i)%data)
158 call mpi_isend(send_data,
size(send_data), &
160 neko_comm, this%send_buf(i)%request, ierr)
162 this%send_buf(i)%flag = .false.
168 class(
gs_mpi_t),
intent(inout) :: this
169 integer :: i, ierr, thrdid
174 do i = 1,
size(this%recv_pe)
180 associate(recv_data => this%recv_buf(i)%data)
181 call mpi_irecv(recv_data,
size(recv_data), &
182 mpi_real_precision, this%recv_pe(i), thrdid, &
183 neko_comm, this%recv_buf(i)%request, ierr)
185 this%recv_buf(i)%flag = .false.
192 class(
gs_mpi_t),
intent(inout) :: this
193 integer,
intent(in) :: n
194 real(kind=rp),
dimension(n),
intent(inout) :: u
195 type(c_ptr),
intent(inout) :: strm
196 integer :: i, j, src, ierr
198 integer ,
pointer :: sp(:)
201 nreqs =
size(this%recv_pe)
203 do while (nreqs .gt. 0)
204 do i = 1,
size(this%recv_pe)
205 if (.not. this%recv_buf(i)%flag)
then
207 call mpi_test(this%recv_buf(i)%request, this%recv_buf(i)%flag, &
208 this%recv_buf(i)%status, ierr)
210 if (this%recv_buf(i)%flag)
then
214 src = this%recv_pe(i)
215 sp => this%recv_dof(src)%array()
220 do concurrent(j = 1:this%recv_dof(src)%size())
221 u(sp(j)) = u(sp(j)) + this%recv_buf(i)%data(j)
225 do concurrent(j = 1:this%recv_dof(src)%size())
226 u(sp(j)) = u(sp(j)) * this%recv_buf(i)%data(j)
230 do concurrent(j = 1:this%recv_dof(src)%size())
231 u(sp(j)) = min(u(sp(j)), this%recv_buf(i)%data(j))
235 do concurrent(j = 1:this%recv_dof(src)%size())
236 u(sp(j)) =
max(u(sp(j)), this%recv_buf(i)%data(j))
239 call neko_error(
"Unknown operation in gs_nbwait_mpi")
247 nreqs =
size(this%send_pe)
248 do while (nreqs .gt. 0)
249 do i = 1,
size(this%send_pe)
250 if (.not. this%send_buf(i)%flag)
then
251 call mpi_test(this%send_buf(i)%request, this%send_buf(i)%flag, &
252 mpi_status_ignore, ierr)
253 if (this%send_buf(i)%flag) nreqs = nreqs - 1
type(mpi_datatype), public mpi_real_precision
MPI type for working precision of REAL types.
type(mpi_comm), public neko_comm
MPI communicator.
Defines a gather-scatter communication method.
integer, parameter, public gs_comm_mpigpu
integer, parameter, public gs_comm_mpi
Defines MPI gather-scatter communication.
subroutine gs_nbwait_mpi(this, u, n, op, strm)
Wait for non-blocking operations.
subroutine gs_nbrecv_mpi(this)
Post non-blocking receive operations.
subroutine gs_mpi_init(this, send_pe, recv_pe)
Initialise MPI based communication method See gs_comm.f90 for details.
subroutine gs_mpi_free(this)
Deallocate MPI based communication method.
subroutine gs_nbsend_mpi(this, u, n, deps, strm)
Post non-blocking send operations.
Defines Gather-scatter operations.
integer, parameter, public gs_op_add
integer, parameter, public gs_op_max
integer, parameter, public gs_op_min
integer, parameter, public gs_op_mul
integer, parameter, public rp
Global precision used in computations.
Implements a dynamic stack ADT.
Gather-scatter communication method.
MPI buffer for non-blocking operations.
Gather-scatter communication using MPI.