77 use mpi_f08,
only : mpi_sendrecv, mpi_status, mpi_integer, mpi_integer8, &
100 integer,
intent(in) :: dest
101 integer(i8),
intent(in) :: body(:)
107 w = int(
size(body),
i8)
122 integer(i8),
allocatable,
intent(inout) :: buf(:)
123 integer,
intent(inout) :: n
124 integer(i8),
allocatable :: keep(:), snd(:), rcv(:), extra(:)
125 integer :: nkeep, nsnd, nrcv, nextra
126 integer :: lo, hi, m, half, mid, r, partner
136 do while (hi - lo > 1)
144 call cr_partition(buf, n, mid, lower, keep, nkeep, snd, nsnd)
152 if (r .lt. half)
then
155 partner = mpi_proc_null
161 call cr_exchange(snd, nsnd, partner, rcv, nrcv, partner)
162 call cr_concat(buf, n, keep, nkeep, rcv, nrcv)
166 if (iand(m, 1) .eq. 1)
then
167 if ((.not. lower) .and. ((
pe_rank - mid) .eq. half))
then
168 call cr_exchange(snd, nsnd, lo, extra, nextra, mpi_proc_null)
170 call cr_exchange(snd, 0, mpi_proc_null, extra, nextra, hi - 1)
184 if (
allocated(keep))
deallocate(keep)
185 if (
allocated(snd))
deallocate(snd)
186 if (
allocated(rcv))
deallocate(rcv)
187 if (
allocated(extra))
deallocate(extra)
193 integer(i8),
allocatable,
intent(in) :: buf(:)
194 integer,
intent(in) :: n
195 integer :: p, dest, rlen
200 rlen = int(buf(p + 1))
201 if (dest .lt. 0 .or. dest .ge.
pe_size)
then
202 call neko_error(
'crystal_router: record destination out of range')
212 integer(i8),
allocatable,
intent(in) :: buf(:)
213 integer,
intent(in) :: n, mid
214 logical,
intent(in) :: lower
215 integer(i8),
allocatable,
intent(out) :: keep(:), snd(:)
216 integer,
intent(out) :: nkeep, nsnd
217 integer :: p, dest, rlen, reclen
220 allocate(keep(
max(n, 1)))
221 allocate(snd(
max(n, 1)))
228 rlen = int(buf(p + 1))
230 in_lower = dest .lt. mid
231 if (in_lower .eqv. lower)
then
232 keep(nkeep + 1:nkeep + reclen) = buf(p:p + reclen - 1)
233 nkeep = nkeep + reclen
235 snd(nsnd + 1:nsnd + reclen) = buf(p:p + reclen - 1)
245 integer(i8),
intent(in) :: sbuf(:)
246 integer,
intent(in) :: sn, dst, src
247 integer(i8),
allocatable,
intent(out) :: rbuf(:)
248 integer,
intent(out) :: rn
249 type(mpi_status) :: status
253 call mpi_sendrecv(sn, 1, mpi_integer, dst,
cr_tag, &
256 allocate(rbuf(
max(rn, 1)))
257 call mpi_sendrecv(sbuf, sn, mpi_integer8, dst,
cr_tag, &
263 integer(i8),
allocatable,
intent(inout) :: buf(:)
264 integer,
intent(out) :: n
265 integer(i8),
allocatable,
intent(in) :: a(:), b(:)
266 integer,
intent(in) :: na, nb
268 if (
allocated(buf))
deallocate(buf)
269 allocate(buf(
max(na + nb, 1)))
270 if (na .gt. 0) buf(1:na) = a(1:na)
271 if (nb .gt. 0) buf(na + 1:na + nb) = b(1:nb)
277 integer(i8),
allocatable,
intent(inout) :: buf(:)
278 integer,
intent(inout) :: n
279 integer(i8),
allocatable,
intent(in) :: e(:)
280 integer,
intent(in) :: ne
281 integer(i8),
allocatable :: tmp(:)
283 if (ne .le. 0)
return
284 allocate(tmp(n + ne))
285 if (n .gt. 0) tmp(1:n) = buf(1:n)
286 tmp(n + 1:n + ne) = e(1:ne)
287 call move_alloc(tmp, buf)
integer, public pe_size
MPI size of communicator.
integer, public pe_rank
MPI rank.
type(mpi_comm), public neko_comm
MPI communicator.
Crystal router: scalable all-to-some personalized exchange.
subroutine, public crystal_router_transfer(buf, n)
Route packed records to their destination ranks.
subroutine cr_append(buf, n, e, ne)
Append e(1:ne) to buf(1:n) in place.
subroutine cr_concat(buf, n, a, na, b, nb)
Rebuild buf as the concatenation a(1:na) ++ b(1:nb).
subroutine cr_check_dest(buf, n)
Abort if any record destination falls outside .
integer, parameter cr_tag
Message tag used for all crystal-router exchanges. Stages are fully synchronised (blocking MPI_Sendre...
subroutine cr_partition(buf, n, mid, lower, keep, nkeep, snd, nsnd)
Partition buf into records kept locally and records to be sent. A record is kept when the side of its...
subroutine, public crystal_router_pack(out, dest, body)
Append one record to a packed crystal-router buffer.
subroutine cr_exchange(sbuf, sn, dst, rbuf, rn, src)
Size-negotiated bidirectional exchange with a partner. Either dst or src may be MPI_PROC_NULL to make...
integer, parameter, public i8
Implements a dynamic stack ADT.