Skip to content

adam_fnl_field_kernels ​

ADAM, field class FNL kernels (FNL backend of field_object).

Source: src/lib/fnl/adam_fnl_field_kernels.F90

Dependencies

Contents ​

Subroutines ​

pack_blocks_transposed_dev ​

Pack blocks 1:blocks_number of the device field a_gpu(b, i, j, k, v), ghost cells included, into buf_gpu in the host layout (v, i, j, k, b) (issue #75): buf_gpu is then one contiguous copy of the host slab a(:, :, :, :, 1:blocks_number), so a host round trip moves the blocks in use, not the block capacity nb (the leading device index is the block, so the blocks in use are a strided section of a_gpu).

fortran
subroutine pack_blocks_transposed_dev(blocks_number, ni, nj, nk, ngc, nv, a_gpu, buf_gpu)

Arguments

NameTypeIntentAttributesDescription
blocks_numberinteger(kind=I4P)inBlocks to pack.
niinteger(kind=I4P)inBlock dimensions, ghost cells number.
njinteger(kind=I4P)inBlock dimensions, ghost cells number.
nkinteger(kind=I4P)inBlock dimensions, ghost cells number.
ngcinteger(kind=I4P)inBlock dimensions, ghost cells number.
nvinteger(kind=I4P)inVariables number.
a_gpureal(kind=R8P)inField (b, i, j, k, v).
buf_gpureal(kind=R8P)inoutPacked blocks (v, i, j, k, b).

Call graph

unpack_blocks_transposed_dev ​

Unpack buf_gpu, blocks 1:blocks_number in the host layout (v, i, j, k, b), into the device field a_gpu(b, i, j, k, v), ghost cells included: the inverse of pack_blocks_transposed_dev (issue #75); the blocks beyond blocks_number are untouched.

fortran
subroutine unpack_blocks_transposed_dev(blocks_number, ni, nj, nk, ngc, nv, buf_gpu, a_gpu)

Arguments

NameTypeIntentAttributesDescription
blocks_numberinteger(kind=I4P)inBlocks to unpack.
niinteger(kind=I4P)inBlock dimensions, ghost cells number.
njinteger(kind=I4P)inBlock dimensions, ghost cells number.
nkinteger(kind=I4P)inBlock dimensions, ghost cells number.
ngcinteger(kind=I4P)inBlock dimensions, ghost cells number.
nvinteger(kind=I4P)inVariables number.
buf_gpureal(kind=R8P)inPacked blocks (v, i, j, k, b).
a_gpureal(kind=R8P)inoutField (b, i, j, k, v).

Call graph

pack_seam_rows_dev ​

Pack the ghost values of the seam send rows [rank, b, i, j, k, kind, meta] row_start..row_start+row_count-1 from q_gpu into buf_gpu, nv values per row in row order (issues #40, #52), the device twin of adam_seam_exchange%pack_seam_rows: kind 1 copies the cell, kind 4 interpolates the fine ghost around the coarse anchor cell (interp_seam_ghost_gpu_dev, the intra-realm flag-4 fill; injection copies the anchor), kind 8 is the mean of the 2x2x2 fine cells from the base cell (the intra-realm flag-8 order). The kinds are the values of adam_seam_exchange SEAM_ROW_*.

fortran
subroutine pack_seam_rows_dev(row_start, row_count, nv, ngc, regime, rows_gpu, q_gpu, buf_gpu)

Arguments

NameTypeIntentAttributesDescription
row_startinteger(kind=I4P)inFirst row.
row_countinteger(kind=I4P)inNumber of rows.
nvinteger(kind=I4P)inVariables number.
ngcinteger(kind=I4P)inGhost cells number.
regimeinteger(kind=I4P)inCoarse->fine fill regime (maps%seam_ghost_fill).
rows_gpuinteger(kind=I4P)inRows [rank, b, i, j, k, kind, meta].
q_gpureal(kind=R8P)inField (b, i, j, k, v).
buf_gpureal(kind=R8P)inoutPacked values.

Call graph

unpack_seam_rows_dev ​

Scatter buf_gpu (nv values per row in row order) into the cells of the cross-rank seam rows [rank, b, i, j, k] row_start..row_start+row_count-1 of q_gpu (issue #40).

fortran
subroutine unpack_seam_rows_dev(row_start, row_count, nv, ngc, rows_gpu, buf_gpu, q_gpu)

Arguments

NameTypeIntentAttributesDescription
row_startinteger(kind=I4P)inFirst row.
row_countinteger(kind=I4P)inNumber of rows.
nvinteger(kind=I4P)inVariables number.
ngcinteger(kind=I4P)inGhost cells number.
rows_gpuinteger(kind=I4P)inRows [rank, b, i, j, k].
buf_gpureal(kind=R8P)inPacked values.
q_gpureal(kind=R8P)inoutField (b, i, j, k, v).

Call graph

compute_q_gradient_dev ​

Compute gradient of q(ivar).

fortran
subroutine compute_q_gradient_dev(b, ni, nj, nk, ngc, dx, dy, dz, q_gpu, ivar, gradient)

Arguments

NameTypeIntentAttributesDescription
binteger(kind=I4P)inBlock index.
niinteger(kind=I4P)inGrid cells number in I direction.
njinteger(kind=I4P)inGrid cells number in J direction.
nkinteger(kind=I4P)inGrid cells number in K direction.
ngcinteger(kind=I4P)inGhost cells number.
dxreal(kind=R8P)inX space step.
dyreal(kind=R8P)inY space step.
dzreal(kind=R8P)inZ space step.
q_gpureal(kind=R8P)inField component to which apply gradient.
ivarinteger(kind=I4P)inGhost cells number.
gradientreal(kind=R8P)outMaximum gradient of q.

Call graph

compute_normL2_residuals_dev ​

Compute L2 norm of residuals.

fortran
subroutine compute_normL2_residuals_dev(ni, nj, nk, ngc, nv, blocks_number, dq_gpu, norm)

Arguments

NameTypeIntentAttributesDescription
niinteger(kind=I4P)inGrid cells number in I direction.
njinteger(kind=I4P)inGrid cells number in J direction.
nkinteger(kind=I4P)inGrid cells number in K direction.
ngcinteger(kind=I4P)inGhost grid number.
nvinteger(kind=I4P)inNumber of states variables.
blocks_numberinteger(kind=I4P)inNumber of blocks.
dq_gpureal(kind=R8P)inResiduals.
normreal(kind=R8P)inoutResiduals norm.

Call graph

populate_send_buffer_ghost_gpu_dev ​

Polulate send buffer ghost GPU.

A fine->coarse row averages the ri*rj*rk fine cells of its coarse ghost: 2 per refined axis, 1 on an axis the tree never refines (quadtree z, issue #46).

fortran
subroutine populate_send_buffer_ghost_gpu_dev(ngc, seam_ghost_fill, seam_restriction, ri, rj, rk, comm_map_send_ghost_cell_gpu, send_buffer_ghost_gpu, q_gpu)

Arguments

NameTypeIntentAttributesDescription
ngcinteger(kind=I4P)inGhost cells number.
seam_ghost_fillinteger(kind=I4P)inSeam ghost-fill regime (flag-4 rows).
seam_restrictioninteger(kind=I4P)inSeam restriction regime (flag-8 rows).
riinteger(kind=I4P)inPer-axis refinement factor.
rjinteger(kind=I4P)inPer-axis refinement factor.
rkinteger(kind=I4P)inPer-axis refinement factor.
comm_map_send_ghost_cell_gpuinteger(kind=I8P)inpointerComm map, cell information.
send_buffer_ghost_gpureal(kind=R8P)inoutpointerSend buffer of ghost cells.
q_gpureal(kind=R8P)inoutField component to be updated.

Call graph

receive_recv_buffer_ghost_gpu_dev ​

Receive recv buffer ghost GPU.

fortran
subroutine receive_recv_buffer_ghost_gpu_dev(ngc, comm_map_recv_ghost_cell_gpu, recv_buffer_ghost_gpu, q_gpu)

Arguments

NameTypeIntentAttributesDescription
ngcinteger(kind=I4P)inGhost cells number.
comm_map_recv_ghost_cell_gpuinteger(kind=I8P)inpointerComm map, cell information.
recv_buffer_ghost_gpureal(kind=R8P)inoutpointerReceive buffer of ghost cells.
q_gpureal(kind=R8P)inoutField component to be updated.

Call graph

update_ghost_local_gpu_dev ​

Update (local) ghost cells.

A fine->coarse row averages the ri*rj*rk fine cells of its coarse ghost: 2 per refined axis, 1 on an axis the tree never refines (quadtree z, issue #46).

fortran
subroutine update_ghost_local_gpu_dev(ngc, seam_ghost_fill, seam_restriction, ri, rj, rk, l_map_ghost_cell_gpu, q_gpu)

Arguments

NameTypeIntentAttributesDescription
ngcinteger(kind=I4P)inGhost cells number.
seam_ghost_fillinteger(kind=I4P)inSeam ghost-fill regime (flag-4 rows).
seam_restrictioninteger(kind=I4P)inSeam restriction regime (flag-8 rows).
riinteger(kind=I4P)inPer-axis refinement factor.
rjinteger(kind=I4P)inPer-axis refinement factor.
rkinteger(kind=I4P)inPer-axis refinement factor.
l_map_ghost_cell_gpuinteger(kind=I8P)inpointerLocal map of ghost cells.
q_gpureal(kind=R8P)inoutField component to be updated.

Call graph

reduce_ghost_local_gpu_dev ​

Fold (local) ghost cells back onto the cells they mirror, the transpose of update_ghost_local_gpu_dev. Device twin of field_object%reduce_ghost_local: same-level rows only (bad_rows returns the number of 2:1 rows, in which case nothing is touched). A donor cell may receive from several ghosts (edges, corners): atomic updates, and the ghost refill runs in a second kernel, after every fold is complete.

fortran
subroutine reduce_ghost_local_gpu_dev(ngc, v_first, v_last, l_map_ghost_cell_gpu, q_gpu, bad_rows)

Arguments

NameTypeIntentAttributesDescription
ngcinteger(kind=I4P)inGhost cells number.
v_firstinteger(kind=I4P)inFirst variable to reduce.
v_lastinteger(kind=I4P)inLast variable to reduce.
l_map_ghost_cell_gpuinteger(kind=I8P)inpointerLocal map of ghost cells.
q_gpureal(kind=R8P)inoutField component to be reduced.
bad_rowsinteger(kind=I4P)outNumber of 2:1 (non same-level) rows.

Call graph

pack_reduce_ghost_mpi_gpu_dev ​

Pack the received ghost cells of variables v_first:v_last into their receive-buffer slots (transpose of receive_recv_buffer_ghost_gpu_dev); every other slot is zeroed, so superseded (deduplicated) slots carry nothing back.

fortran
subroutine pack_reduce_ghost_mpi_gpu_dev(ngc, v_first, v_last, comm_map_recv_ghost_cell_gpu, recv_buffer_ghost_gpu, q_gpu)

Arguments

NameTypeIntentAttributesDescription
ngcinteger(kind=I4P)inGhost cells number.
v_firstinteger(kind=I4P)inFirst variable to reduce.
v_lastinteger(kind=I4P)inLast variable to reduce.
comm_map_recv_ghost_cell_gpuinteger(kind=I8P)inpointerComm map, cell information.
recv_buffer_ghost_gpureal(kind=R8P)inoutpointerReceive buffer of ghost cells.
q_gpureal(kind=R8P)inField component to be reduced.

Call graph

fold_reduce_ghost_mpi_gpu_dev ​

Add the slots sent back by the other ranks to their donor cells (transpose of populate_send_buffer_ghost_gpu_dev), variables v_first:v_last, same-level rows only (bad_rows returns the number of 2:1 rows, in which case nothing is touched). A donor may own several slots (edges, corners): atomic updates.

fortran
subroutine fold_reduce_ghost_mpi_gpu_dev(ngc, v_first, v_last, comm_map_send_ghost_cell_gpu, send_buffer_ghost_gpu, q_gpu, bad_rows)

Arguments

NameTypeIntentAttributesDescription
ngcinteger(kind=I4P)inGhost cells number.
v_firstinteger(kind=I4P)inFirst variable to reduce.
v_lastinteger(kind=I4P)inLast variable to reduce.
comm_map_send_ghost_cell_gpuinteger(kind=I8P)inpointerComm map, cell information.
send_buffer_ghost_gpureal(kind=R8P)inpointerSend buffer of ghost cells.
q_gpureal(kind=R8P)inoutField component to be reduced.
bad_rowsinteger(kind=I4P)outNumber of 2:1 (non same-level) rows.

Call graph

Functions ​

interp_seam_ghost_gpu_dev ​

Device twin of field_object%interp_seam_ghost (issue #22 F3): evaluate the coarse->fine seam ghost interpolant for one (variable, fine ghost) pair on the FNL layout q_gpu(b,i,j,k,v), calling the single-source evaluators of adam_seam_interpolation_library (device-pinned by test_seam_interpolation_fnl, #22 F2).

Race discipline (CLAUDE-gpu, #22 F1-bis/F2): the footprint gather buffers are CONSTANT-BOUND locals of this acc routine seq — per-thread stack storage, the WENO device-kernels precedent — never private() clauses of a contained kernel nor array-section actuals (both are nvfortran race shapes). The anchor and the shift-clamped positions in meta guarantee the footprint reads REAL donor cells only (G3), so the gather never sees ghost cells written concurrently by other map rows.

Attributes: pure

Returns: real(kind=R8P)

fortran
function interp_seam_ghost_gpu_dev(regime, meta, ngc, q_gpu, v, b_send, i_send, j_send, k_send) result(value_)

Arguments

NameTypeIntentAttributesDescription
regimeinteger(kind=I4P)inActive fill regime (SEAM_FILL_*).
metainteger(kind=I4P)inPacked interpolation metadata (see seam_meta_pack).
ngcinteger(kind=I4P)inGhost cells number (bounds of q_gpu).
q_gpureal(kind=R8P)inField variables, FNL layout (b,i,j,k,v).
vinteger(kind=I4P)inVariable index.
b_sendinteger(kind=I4P)inDonor block index.
i_sendinteger(kind=I4P)inAnchor donor cell, i.
j_sendinteger(kind=I4P)inAnchor donor cell, j.
k_sendinteger(kind=I4P)inAnchor donor cell, k.

Call graph

restrict_seam_high_order_gpu_dev ​

Device twin of field_object%restrict_seam_high_order (issue #68 C2, C3): the 6-point Lagrange or the WENO restriction of one (variable, coarse ghost) pair on the FNL layout q_gpu(b,i,j,k,v), in the same order as the host (x innermost, then y, then z). The footprint is shifted inside the donor block by the codes of meta, so it reads REAL donor cells only and never a ghost cell another map row writes concurrently (the #22 race discipline). The Lagrange sums use scalar locals only; the WENO gathers one x line at a time (6 values) and calls seam_restriction_weno6_1d line by line, the arithmetic of the host's seam_restriction_weno6.

Attributes: pure

Returns: real(kind=R8P)

fortran
function restrict_seam_high_order_gpu_dev(meta, ngc, q_gpu, v, b_send, i_send, j_send, k_send) result(value_)

Arguments

NameTypeIntentAttributesDescription
metainteger(kind=I4P)inPacked restriction codes and regime (seam_restriction_meta_pack).
ngcinteger(kind=I4P)inGhost cells number (bounds of q_gpu).
q_gpureal(kind=R8P)inField variables, FNL layout (b,i,j,k,v).
vinteger(kind=I4P)inVariable index.
b_sendinteger(kind=I4P)inDonor block index.
i_sendinteger(kind=I4P)inFirst fine cell of the restricted pair, i.
j_sendinteger(kind=I4P)inFirst fine cell of the restricted pair, j.
k_sendinteger(kind=I4P)inFirst fine cell of the restricted pair, k.

Call graph