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
50 type(mpi_status) :: status
52 type(mpi_request) :: request
57 real(kind=
rp),
allocatable ::
data(:)
80 class(
gs_mpi_t),
intent(inout) :: this
83 integer,
pointer :: sp(:), rp(:)
86 call this%init_order(send_pe, recv_pe)
88 allocate(this%send_buf(send_pe%size()))
91 do i = 1, send_pe%size()
92 allocate(this%send_buf(i)%data(this%send_dof(sp(i))%size()))
95 allocate(this%recv_buf(recv_pe%size()))
98 do i = 1, recv_pe%size()
99 allocate(this%recv_buf(i)%data(this%recv_dof(rp(i))%size()))
106 class(
gs_mpi_t),
intent(inout) :: this
109 if (
allocated(this%send_buf))
then
110 do i = 1,
size(this%send_buf)
111 if (
allocated(this%send_buf(i)%data))
then
112 deallocate(this%send_buf(i)%data)
115 deallocate(this%send_buf)
118 if (
allocated(this%recv_buf))
then
119 do i = 1,
size(this%recv_buf)
120 if (
allocated(this%recv_buf(i)%data))
then
121 deallocate(this%recv_buf(i)%data)
124 deallocate(this%recv_buf)
127 call this%free_order()
128 call this%free_dofs()
134 class(
gs_mpi_t),
intent(inout) :: this
135 integer,
intent(in) :: n
136 real(kind=
rp),
dimension(n),
intent(inout) :: u
137 type(c_ptr),
intent(inout) :: deps
138 type(c_ptr),
intent(inout) :: strm
139 integer :: i, j, ierr, dst, thrdid
140 integer ,
pointer :: sp(:)
145 do i = 1,
size(this%send_pe)
146 dst = this%send_pe(i)
149 sp => this%send_dof(dst)%array()
150 do concurrent(j = 1:this%send_dof(dst)%size())
151 this%send_buf(i)%data(j) = u(sp(j))
156 associate(send_data => this%send_buf(i)%data)
157 call mpi_isend(send_data,
size(send_data), &
159 neko_comm, this%send_buf(i)%request, ierr)
161 this%send_buf(i)%flag = .false.
167 class(
gs_mpi_t),
intent(inout) :: this
168 integer :: i, ierr, thrdid
173 do i = 1,
size(this%recv_pe)
179 associate(recv_data => this%recv_buf(i)%data)
180 call mpi_irecv(recv_data,
size(recv_data), &
181 mpi_real_precision, this%recv_pe(i), thrdid, &
182 neko_comm, this%recv_buf(i)%request, ierr)
184 this%recv_buf(i)%flag = .false.
191 class(
gs_mpi_t),
intent(inout) :: this
192 integer,
intent(in) :: n
193 real(kind=rp),
dimension(n),
intent(inout) :: u
194 type(c_ptr),
intent(inout) :: strm
195 integer :: i, j, src, ierr
197 integer ,
pointer :: sp(:)
200 nreqs =
size(this%recv_pe)
202 do while (nreqs .gt. 0)
203 do i = 1,
size(this%recv_pe)
204 if (.not. this%recv_buf(i)%flag)
then
206 call mpi_test(this%recv_buf(i)%request, this%recv_buf(i)%flag, &
207 this%recv_buf(i)%status, ierr)
209 if (this%recv_buf(i)%flag)
then
213 src = this%recv_pe(i)
214 sp => this%recv_dof(src)%array()
219 do concurrent(j = 1:this%send_dof(src)%size())
221 u(sp(j)) = u(sp(j)) + this%recv_buf(i)%data(j)
225 do concurrent(j = 1:this%send_dof(src)%size())
226 u(sp(j)) = u(sp(j)) * this%recv_buf(i)%data(j)
230 do concurrent(j = 1:this%send_dof(src)%size())
231 u(sp(j)) = min(u(sp(j)), this%recv_buf(i)%data(j))
235 do concurrent(j = 1:this%send_dof(src)%size())
236 u(sp(j)) =
max(u(sp(j)), this%recv_buf(i)%data(j))
245 nreqs =
size(this%send_pe)
246 do while (nreqs .gt. 0)
247 do i = 1,
size(this%send_pe)
248 if (.not. this%send_buf(i)%flag)
then
249 call mpi_test(this%send_buf(i)%request, this%send_buf(i)%flag, &
250 mpi_status_ignore, ierr)
251 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.