loki.transformations.single_column.claw

Transformations to extract single-column Fortran code adhering to the Single Column Abstraction (SCA), as defined by CLAW (Clement et al., 2018)

Classes

CLAWTransformation(**kwargs)

Transformation to extract SCA Fortran and apply the necessary CLAW annotations.

ExtractSCATransformation(horizontal)

Transformation to convert vectorized Fortran kernels into SCA format by removing horizontal vector loops.

class ExtractSCATransformation(horizontal)

Bases: Transformation

Transformation to convert vectorized Fortran kernels into SCA format by removing horizontal vector loops.

This will remove all “vector loops” as determined by the horizontal Dimension object from “kernel” subroutines, and adjust variable and argument declarations accordingly. In “driver” subroutines, the call signature will be adjusted accordingly, and a single hoisted loop across the horizontal dimension inserted around the first-level kernel invocation.

Note, this requires preprocessing with the DerivedTypeArgumentsTransformation, if “array-of-struct”-type derived type arguments are present.

Parameters:

horizontal (Dimension) – Dimension object describing the variable conventions used in existing code to define the horizontal data dimension and iteration space.

transform_subroutine(routine, **kwargs)

Apply transformation to convert a Subroutine to SCA code format.

Parameters:
  • routine (Subroutine) – Subroutine to apply this transformation to.

  • role (string) – Role of the subroutine in the call tree; either "driver" or "kernel"

remove_dimension(routine)

Remove all loops and variable indices of the stored horizontal dimension from the given routine.

Parameters:

routine (Subroutine) – Subroutine to apply this transformation to.

hoist_dimension_from_call(caller, wrap=True)

Remove all indices and variables of the horzontal dimension from caller (driver) and callee (kernel) routines, and insert the necessary loop over the target dimension into the driver.

Note: In order for this routine to see the horizontal dimension in the argument declarations of the kernel, it must be applied before they are stripped from the kernel itself.

Parameters:
  • routine (Subroutine) – Subroutine to apply this transformation to.

  • wrap (bool) – Flag to trigger the creation of a loop to wrap the kernel call in.

class CLAWTransformation(**kwargs)

Bases: ExtractSCATransformation

Transformation to extract SCA Fortran and apply the necessary CLAW annotations.

This transformation builds on the SCA extraction of the ExtractSCATransformation by inserting additional CLAW SCA directives into the “kernel” and “driver” routines.

The following CLAW directives are inserted by the transformation: * !$claw sca forward markers in the “driver” routine * !$claw sca and claw model-config regions in the first-level “kernel” routine * !$claw sca routine in any “kernel” routines beyond first-level

Note, this requires preprocessing with the DerivedTypeArgumentsTransformation, if “array-of-struct”-type derived type arguments are present.

Parameters:

claw_data_offload (bool) – Flag triggering the addition of create and update` clauses to the ``!$claw sca forward directive, causing CLAW to tightly wrap the kernel invocation in OpenACC offload directives.

transform_subroutine(routine, **kwargs)

Apply transformation to convert a Subroutine to SCA code format.

Parameters:
  • routine (Subroutine) – Subroutine to apply this transformation to.

  • role (string) – Role of the subroutine in the call tree; either "driver" or "kernel"