Skip to content

selah_kernels_box ​

SELAH, L1: the box kernels, the stage operations over the box of a rank-5 field.

Every kernel is a pointwise update of the cells of the box (selah_box): never a ghost cell, never a pool slot past the active blocks. One source serves the host (plain loops, OpenMP with -fopenmp), OpenACC and OpenMP offload, by the backend macros of FUNDAL (fundal.H) in the directive style of ADAM's FNL kernels; in a device build every array argument, the coefficients included, must be device resident.

Mask. With mask present, a cell is active where mask(..., mask_comp) < 0 (ADAM's immersed-boundary distance, negative in the fluid; mask_comp defaults to the last component, ADAM's all-solids summary). The mask has the field's shape with its own number of components. Inactive cells are left untouched, except the step residual dq, which is 0 there, and the stage state with masked_q (stage_state_box), which is q there.

Summation order. The sums over registers form a private sum and store once, as ADAM's FNL kernels do, so the results are bitwise those of ADAM's device path (src/tests: the parity test).

Aliasing. The output arrays must not alias the inputs (Fortran's rule on dummy arguments).

One procedure per variant. The loop of a kernel is an include file (selah_kernel_<name>.INC), compiled once per variant: masked or not, once per layout, with the step residual or not, with the stage-state fill, with a = 0. Each variant is a private procedure of its own, made from the wrapper selah_kernel_<name>_proc.INC under the name given by the macro SELAH_PROC (the block of private procedures at the end of the module), and the public routines only dispatch to them. The reason is a defect of AMD's flang (AFAR 23.2.1 and 24.4.0): it pairs the host launch of an OpenMP target region with the device kernel of ANOTHER region when several regions of one procedure come from the same line of an included file, so that on an AMD GPU a call ran the kernel of an arbitrary variant: the time integrator did not advance the state (ADAM issue #155). The same included line in different procedures is not affected. Do not include one kernel file more than once in a procedure.

Source: src/lib/selah_kernels_box.F90

Dependencies

Contents ​

Subroutines ​

copy_box ​

y = x over the box.

fortran
subroutine copy_box(bx, x, y, mask, mask_comp)

Arguments

NameTypeIntentAttributesDescription
bxtype(box)inBox.
xreal(kind=R_P)inSource.
yreal(kind=R_P)inoutDestination.
maskreal(kind=R_P)inoptionalActive where mask(..., mask_comp) < 0.
mask_compinteger(kind=I4P)inoptionalMask component (default: the last).

Call graph

axpy_box ​

y = y + alpha x over the box (a partition update of a splitting scheme, a forward-Euler step).

fortran
subroutine axpy_box(bx, alpha, x, y, mask, mask_comp)

Arguments

NameTypeIntentAttributesDescription
bxtype(box)inBox.
alphareal(kind=R_P)inCoefficient.
xreal(kind=R_P)inIncrement.
yreal(kind=R_P)inoutUpdated field.
maskreal(kind=R_P)inoptionalActive where mask(..., mask_comp) < 0.
mask_compinteger(kind=I4P)inoptionalMask component (default: the last).

Call graph

lincomb_box ​

y = alpha x + beta y over the box.

fortran
subroutine lincomb_box(bx, alpha, x, beta, y, mask, mask_comp)

Arguments

NameTypeIntentAttributesDescription
bxtype(box)inBox.
alphareal(kind=R_P)inCoefficient of x.
xreal(kind=R_P)inFirst field.
betareal(kind=R_P)inCoefficient of y.
yreal(kind=R_P)inoutSecond field, overwritten.
maskreal(kind=R_P)inoptionalActive where mask(..., mask_comp) < 0.
mask_compinteger(kind=I4P)inoptionalMask component (default: the last).

Call graph

stage_state_box ​

u = q + sum_{k=1..n} dt coef(k) regs(k) over the box: the state of a stage of a Butcher form, from the solution and the residuals of the previous stages (coef = row s of A, n = s - 1). n = 0 gives u = q, through the copy kernel: the summing loop with nothing to sum ran at 0.57 of the copy's speed on the A30 (M5, job 1368098). With masked_q, the inactive cells of u take q (the stepper's mask policy) in the same pass, instead of being left untouched.

fortran
subroutine stage_state_box(bx, n, dt, coef, q, regs, u, mask, mask_comp, masked_q)

Arguments

NameTypeIntentAttributesDescription
bxtype(box)inBox.
ninteger(kind=I4P)inRegisters summed.
dtreal(kind=R_P)inTime step.
coefreal(kind=R_P)inCoefficients [n or more].
qreal(kind=R_P)inSolution.
regsreal(kind=R_P)inResidual registers [..., n or more].
ureal(kind=R_P)inoutStage state.
maskreal(kind=R_P)inoptionalActive where mask(..., mask_comp) < 0.
mask_compinteger(kind=I4P)inoptionalMask component (default: the last).
masked_qlogicalinoptionalThe inactive cells of u take q (default .false.).

Call graph

step_update_box ​

q = q + dt sum_{k=1..n} coef(k) regs(k) over the box: the end of a step of a Butcher form (coef = b, n = s), fused with the step residual dq = sum_k coef(k) regs(k) when dq is present (0 where the mask is inactive).

fortran
subroutine step_update_box(bx, n, dt, coef, regs, q, dq, mask, mask_comp)

Arguments

NameTypeIntentAttributesDescription
bxtype(box)inBox.
ninteger(kind=I4P)inRegisters summed.
dtreal(kind=R_P)inTime step.
coefreal(kind=R_P)inWeights [n or more].
regsreal(kind=R_P)inResidual registers [..., n or more].
qreal(kind=R_P)inoutSolution, advanced.
dqreal(kind=R_P)inoutoptionalStep residual.
maskreal(kind=R_P)inoptionalActive where mask(..., mask_comp) < 0.
mask_compinteger(kind=I4P)inoptionalMask component (default: the last).

Call graph

shu_osher_2r_stage_box ​

q = a q0 + b q + dt c r over the box: a stage of a two-register Shu–Osher form (q0 = u^n, r = F(q)).

fortran
subroutine shu_osher_2r_stage_box(bx, dt, a, b, c, q0, r, q, mask, mask_comp)

Arguments

NameTypeIntentAttributesDescription
bxtype(box)inBox.
dtreal(kind=R_P)inTime step.
areal(kind=R_P)inStage coefficients.
breal(kind=R_P)inStage coefficients.
creal(kind=R_P)inStage coefficients.
q0real(kind=R_P)inSolution at the start of the step.
rreal(kind=R_P)inResidual of the current stage.
qreal(kind=R_P)inoutCurrent stage, advanced.
maskreal(kind=R_P)inoptionalActive where mask(..., mask_comp) < 0.
mask_compinteger(kind=I4P)inoptionalMask component (default: the last).

Call graph

williamson_2n_stage_box ​

dqr = a dqr + dt r; q = q + b dqr over the box: a stage of a Williamson 2N form (r = F(q)). With a = 0 dqr is not read (dqr = dt r): the first stage needs no prior content of the register.

fortran
subroutine williamson_2n_stage_box(bx, dt, a, b, r, dqr, q, mask, mask_comp)

Arguments

NameTypeIntentAttributesDescription
bxtype(box)inBox.
dtreal(kind=R_P)inTime step.
areal(kind=R_P)inStage coefficients A_i, B_i.
breal(kind=R_P)inStage coefficients A_i, B_i.
rreal(kind=R_P)inResidual of the current stage.
dqrreal(kind=R_P)inoutThe Delta Q register.
qreal(kind=R_P)inoutCurrent stage, advanced.
maskreal(kind=R_P)inoptionalActive where mask(..., mask_comp) < 0.
mask_compinteger(kind=I4P)inoptionalMask component (default: the last).

Call graph

stage_current_box ​

y = (h - sum_{r=1..n-1} coef(r) regs(r)) / coef(n) over the box: the stage current that makes the weighted sum of the stage currents equal a given one (coef = row n+1 of A, or b at the last stage; selah_stepper stage_current). One variant, so one loop: it needs no procedure of its own.

fortran
subroutine stage_current_box(bx, n, coef, h, regs, y)

Arguments

NameTypeIntentAttributesDescription
bxtype(box)inBox.
ninteger(kind=I4P)inStage (coef(n) /= 0).
coefreal(kind=R_P)inCoefficients [n or more].
hreal(kind=R_P)inThe weighted sum wanted.
regsreal(kind=R_P)inThe previous stage currents [..., n-1 or more].
yreal(kind=R_P)inoutStage current n.

GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT, at your choice