m_omptgt_kernels_fieldops Module

Field operation kernels for the OpenMP target backend, following cuda/kernels/fieldops.f90 and the sum/reorder kernels of cuda/kernels/reorder.f90.

Arrays are explicit-shape or assumed-size dummies named in OMP_DEVICE_ADDR (see m_omptgt_common). Pointwise kernels see a field as a flat array of n points, as the CUDA ones sweep the whole block. Kernels on the pencil layout index a DIR_X/Y/Z field as (SZ, n, groups) in the layout of m_ordering, which is not the one the CUDA kernels use: a DIR_X group index is b = y_block + (z - 1)*n_yb_pad, y-blocks fastest with n_yb_pad = ny_padded/SZ of them per z station.


Uses

  • module~~m_omptgt_kernels_fieldops~~UsesGraph module~m_omptgt_kernels_fieldops m_omptgt_kernels_fieldops module~m_common m_common module~m_omptgt_kernels_fieldops->module~m_common module~m_omptgt_common m_omptgt_common module~m_omptgt_kernels_fieldops->module~m_omptgt_common m_mpi m_mpi module~m_common->m_mpi module~m_logger m_logger module~m_common->module~m_logger module~m_omptgt_common->module~m_common iso_c_binding iso_c_binding module~m_omptgt_common->iso_c_binding module~m_omptgt_common->module~m_logger omp_lib omp_lib module~m_omptgt_common->omp_lib module~m_logger->m_mpi iso_fortran_env iso_fortran_env module~m_logger->iso_fortran_env

Used by

  • module~~m_omptgt_kernels_fieldops~~UsedByGraph module~m_omptgt_kernels_fieldops m_omptgt_kernels_fieldops module~m_omptgt_backend m_omptgt_backend module~m_omptgt_backend->module~m_omptgt_kernels_fieldops module~m_backend_setup m_backend_setup module~m_backend_setup->module~m_omptgt_backend program~x3d2_poisson_solver x3d2_poisson_solver program~x3d2_poisson_solver->module~m_backend_setup program~xcompact xcompact program~xcompact->module~m_backend_setup

Functions

public function scalar_product(x, y, n_f, n, n_i, n_groups_pad, n_j) result(s)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: x(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(in) :: y(SZ,n_f,n_groups_pad*n_i)
integer, intent(in) :: n_f
integer, intent(in) :: n
integer, intent(in) :: n_i
integer, intent(in) :: n_groups_pad
integer, intent(in) :: n_j

Return Value real(kind=dp)

public function scalar_product_cart(x, y, n_c, dims) result(s)

Scalar product of two DIR_C fields, whose storage is the padded Cartesian box n_c with the physical points in 1:dims.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: x(*)
real(kind=dp), intent(in) :: y(*)
integer, intent(in) :: n_c(3)
integer, intent(in) :: dims(3)

Return Value real(kind=dp)

public function vector_norm_squared(a, b, c, n_f, n, n_i, n_groups_pad, n_j) result(s)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: a(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(in) :: b(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(in) :: c(SZ,n_f,n_groups_pad*n_i)
integer, intent(in) :: n_f
integer, intent(in) :: n
integer, intent(in) :: n_i
integer, intent(in) :: n_groups_pad
integer, intent(in) :: n_j

Return Value real(kind=dp)

public function volume_integral(f, n_f, n, n_i, n_groups_pad, n_j) result(s)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: f(SZ,n_f,n_groups_pad*n_i)
integer, intent(in) :: n_f
integer, intent(in) :: n
integer, intent(in) :: n_i
integer, intent(in) :: n_groups_pad
integer, intent(in) :: n_j

Return Value real(kind=dp)


Subroutines

public subroutine copy(n, dst, src)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
real(kind=dp), intent(inout) :: dst(n)
real(kind=dp), intent(in) :: src(n)

public subroutine axpby(n, alpha, x, beta, y)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
real(kind=dp), intent(in) :: alpha
real(kind=dp), intent(in) :: x(n)
real(kind=dp), intent(in) :: beta
real(kind=dp), intent(inout) :: y(n)

public subroutine pwmul(y, x, n)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: y(n)
real(kind=dp), intent(in) :: x(n)
integer, intent(in) :: n

public subroutine field_scale(f, alpha, n)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: f(n)
real(kind=dp), intent(in) :: alpha
integer, intent(in) :: n

public subroutine field_shift(f, const, n)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: f(n)
real(kind=dp), intent(in) :: const
integer, intent(in) :: n

public subroutine vorticity_from_gradients(vort, dudy, dudz, dvdx, dvdz, dwdx, dwdy, n)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: vort(n)
real(kind=dp), intent(in) :: dudy(n)
real(kind=dp), intent(in) :: dudz(n)
real(kind=dp), intent(in) :: dvdx(n)
real(kind=dp), intent(in) :: dvdz(n)
real(kind=dp), intent(in) :: dwdx(n)
real(kind=dp), intent(in) :: dwdy(n)
integer, intent(in) :: n

public subroutine qcriterion_from_gradients(qcrit, dudx, dudy, dudz, dvdx, dvdy, dvdz, dwdx, dwdy, dwdz, n)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: qcrit(n)
real(kind=dp), intent(in) :: dudx(n)
real(kind=dp), intent(in) :: dudy(n)
real(kind=dp), intent(in) :: dudz(n)
real(kind=dp), intent(in) :: dvdx(n)
real(kind=dp), intent(in) :: dvdy(n)
real(kind=dp), intent(in) :: dvdz(n)
real(kind=dp), intent(in) :: dwdx(n)
real(kind=dp), intent(in) :: dwdy(n)
real(kind=dp), intent(in) :: dwdz(n)
integer, intent(in) :: n

public subroutine smagorinsky_from_gradients(nut, mixing_length_sq, dudx, dudy, dudz, dvdx, dvdy, dvdz, dwdx, dwdy, dwdz, n)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: nut(n)
real(kind=dp), intent(in) :: mixing_length_sq(n)
real(kind=dp), intent(in) :: dudx(n)
real(kind=dp), intent(in) :: dudy(n)
real(kind=dp), intent(in) :: dudz(n)
real(kind=dp), intent(in) :: dvdx(n)
real(kind=dp), intent(in) :: dvdy(n)
real(kind=dp), intent(in) :: dvdz(n)
real(kind=dp), intent(in) :: dwdx(n)
real(kind=dp), intent(in) :: dwdy(n)
real(kind=dp), intent(in) :: dwdz(n)
integer, intent(in) :: n

public subroutine sgs_stress_from_gradients(stress, nut, gradient_a, gradient_b, scale_a, scale_b, n)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: stress(n)
real(kind=dp), intent(in) :: nut(n)
real(kind=dp), intent(in) :: gradient_a(n)
real(kind=dp), intent(in) :: gradient_b(n)
real(kind=dp), intent(in) :: scale_a
real(kind=dp), intent(in) :: scale_b
integer, intent(in) :: n

public subroutine buffer_copy(u_send_s, u_send_e, u, n_u, n, n_groups)

Copies the first and last four points of every line into the start and end send buffers. n is the line length, n_u the padded extent.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: u_send_s(SZ,4,n_groups)
real(kind=dp), intent(inout) :: u_send_e(SZ,4,n_groups)
real(kind=dp), intent(in) :: u(SZ,n_u,n_groups)
integer, intent(in) :: n_u
integer, intent(in) :: n
integer, intent(in) :: n_groups

public subroutine labelled_sums(s, g, label, a, b, c, n_label, n_f, n, n_i, n_groups_pad, n_j)

s(1:3, l) += sums of ga, gb and g*c over the points labelled l, as cuda/kernels/fieldops.f90: each thread accumulates runs of equal labels along its pencil and flushes a run when the label changes, so the atomics scale with the label changes rather than the points. Atomics instead of reduction(+:s), which flang cannot do on the GPU for an array whose shape is only known at run time.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: s(3,n_label)
real(kind=dp), intent(in) :: g(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(in) :: label(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(in) :: a(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(in) :: b(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(in) :: c(SZ,n_f,n_groups_pad*n_i)
integer, intent(in) :: n_label
integer, intent(in) :: n_f
integer, intent(in) :: n
integer, intent(in) :: n_i
integer, intent(in) :: n_groups_pad
integer, intent(in) :: n_j

public subroutine labelled_axpy(coeffs, g, label, a, b, c, n_label, n_f, n, n_i, n_groups_pad, n_j)

a, b, c += coeffs(1:3, l)*g at the points labelled l.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: coeffs(3,n_label)
real(kind=dp), intent(in) :: g(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(in) :: label(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(inout) :: a(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(inout) :: b(SZ,n_f,n_groups_pad*n_i)
real(kind=dp), intent(inout) :: c(SZ,n_f,n_groups_pad*n_i)
integer, intent(in) :: n_label
integer, intent(in) :: n_f
integer, intent(in) :: n
integer, intent(in) :: n_i
integer, intent(in) :: n_groups_pad
integer, intent(in) :: n_j

public subroutine field_max_sum(max_f, sum_f, f, n_f, n, n_i, n_groups_pad, n_j)

Maximum and sum of |f|.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(out) :: max_f
real(kind=dp), intent(out) :: sum_f
real(kind=dp), intent(in) :: f(SZ,n_f,n_groups_pad*n_i)
integer, intent(in) :: n_f
integer, intent(in) :: n
integer, intent(in) :: n_i
integer, intent(in) :: n_groups_pad
integer, intent(in) :: n_j

public subroutine slice_max_sum(max_f, sum_f, f, n_f, i_slice, n_i, n_groups_pad, n_j)

Signed maximum and sum of the slice f(:, i_slice, :).

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(out) :: max_f
real(kind=dp), intent(out) :: sum_f
real(kind=dp), intent(in) :: f(SZ,n_f,n_groups_pad*n_i)
integer, intent(in) :: n_f
integer, intent(in) :: i_slice
integer, intent(in) :: n_i
integer, intent(in) :: n_groups_pad
integer, intent(in) :: n_j

public subroutine field_set_x_face(f, c_start, c_end, bc_start, bc_end, flow_rate_diff, n_f, nx, ny, nz, n_yb_pad)

Sets the x faces: a Dirichlet value c_start at the inlet (pencil index 1) and the convective outflow du/dt + Uc*du/dx = 0, Uc = c_end, at the outlet (pencil index nx). BC_NEUMANN (1) leaves a face untouched.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: f(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: c_start
real(kind=dp), intent(in) :: c_end
integer, intent(in) :: bc_start
integer, intent(in) :: bc_end
real(kind=dp), intent(in) :: flow_rate_diff
integer, intent(in) :: n_f
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
integer, intent(in) :: n_yb_pad

public subroutine field_set_x_face_from_field(f, f_start, c_end, bc_start, bc_end, flow_rate_diff, n_f, nx, ny, nz, n_yb_pad)

As field_set_x_face, with the inlet taken from the inlet plane of f_start rather than a constant.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: f(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: f_start(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: c_end
integer, intent(in) :: bc_start
integer, intent(in) :: bc_end
real(kind=dp), intent(in) :: flow_rate_diff
integer, intent(in) :: n_f
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
integer, intent(in) :: n_yb_pad

public subroutine field_add_x_face_from_field(f, g, set_start, set_end, n_f, nx, ny, nz, n_yb_pad)

f += g on the x faces flagged by set_start/set_end.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: f(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: g(SZ,n_f,n_yb_pad*nz)
logical, intent(in) :: set_start
logical, intent(in) :: set_end
integer, intent(in) :: n_f
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
integer, intent(in) :: n_yb_pad

public subroutine field_set_y_face(f, c_start, c_end, set_start, set_end, n_f, nx, ny, nz, n_yb_pad)

Sets the bottom (y = 1) and top (y = ny) faces where flagged, so the two y faces can differ (ABL: no-slip floor, free-slip lid).

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: f(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: c_start
real(kind=dp), intent(in) :: c_end
logical, intent(in) :: set_start
logical, intent(in) :: set_end
integer, intent(in) :: n_f
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
integer, intent(in) :: n_yb_pad

public subroutine field_set_y_face_from_field(f, f_start, n_f, nx, ny, nz, n_yb_pad)

Copies the bottom and top y planes of f_start onto those of f.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: f(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: f_start(SZ,n_f,n_yb_pad*nz)
integer, intent(in) :: n_f
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
integer, intent(in) :: n_yb_pad

public subroutine field_add_y_face_from_field(f, g, set_start, set_end, n_f, nx, ny, nz, n_yb_pad)

f += g on the y faces flagged by set_start/set_end.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: f(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: g(SZ,n_f,n_yb_pad*nz)
logical, intent(in) :: set_start
logical, intent(in) :: set_end
integer, intent(in) :: n_f
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
integer, intent(in) :: n_yb_pad

public subroutine field_set_y_plane(f, c, plane, n_f, nx, nz, n_yb_pad)

Sets the y plane plane to c.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: f(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: c
integer, intent(in) :: plane
integer, intent(in) :: n_f
integer, intent(in) :: nx
integer, intent(in) :: nz
integer, intent(in) :: n_yb_pad

public subroutine field_set_abl_wall_stress(stress, u, w, drag_coeff, sample_plane, stress_plane, n_f, nx, nz, n_yb_pad, component)

Drag law tau = drag_coeffu_c|u_h| from each column's own sampled velocity, written into one stress plane (component 1: x, 3: z).

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: stress(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: u(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: w(SZ,n_f,n_yb_pad*nz)
real(kind=dp), intent(in) :: drag_coeff
integer, intent(in) :: sample_plane
integer, intent(in) :: stress_plane
integer, intent(in) :: n_f
integer, intent(in) :: nx
integer, intent(in) :: nz
integer, intent(in) :: n_yb_pad
integer, intent(in) :: component

public subroutine field_plane_partial_sums(partial, f, n_f, nx, ny, nz, n_yb_pad)

First pass of field_plane_sums: partial(j, z) is the sum over x of y index j at z, summed in a fixed order.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: partial(ny,nz)
real(kind=dp), intent(in) :: f(SZ,n_f,n_yb_pad*nz)
integer, intent(in) :: n_f
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
integer, intent(in) :: n_yb_pad

public subroutine field_plane_sums_reduce(sums, partial, ny, nz)

Second pass of field_plane_sums: sums(j) is the sum over z of partial(j, z), in a fixed order.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: sums(ny)
real(kind=dp), intent(in) :: partial(ny,nz)
integer, intent(in) :: ny
integer, intent(in) :: nz

public subroutine reorder(u_o, u_i, dir_from, dir_to, cart_padded)

Reorders u_i in layout dir_from into u_o in layout dir_to.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: u_o(*)
real(kind=dp), intent(in) :: u_i(*)
integer, intent(in) :: dir_from
integer, intent(in) :: dir_to
integer, intent(in) :: cart_padded(3)

public subroutine sum_intox(u, u_d, dir_from, cart_padded)

u += u_d, where u is DIR_X and u_d the same field in layout dir_from.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: u(*)
real(kind=dp), intent(in) :: u_d(*)
integer, intent(in) :: dir_from
integer, intent(in) :: cart_padded(3)