# loki.transformations.single_column.vertical

Classes

`SCCFuseVerticalLoops`([vertical, apply_to]) | A transformation to fuse vertical loops and demote temporaries in the vertical dimension if possible.

class SCCFuseVerticalLoops(vertical=None, apply_to=None)

  Bases: `Transformation`

  A transformation to fuse vertical loops and demote temporaries in the vertical dimension if possible.

  Note

  This transfomation currently relies on pragmas being inserted in the input source files. Relevant pragmas are !$loki loop-interchange to expose the vertical loops (in case vertical loops are nested) and !$loki loop-fusion possibly grouped via group(<group name>). Further, if there are loops that initialize multilevel arrays (jk +/- 1) it is possible to mark those loops as !$loki loop-fusion group(<group-name>-init). This allows to split the relevant node and moves the initialization of those arrays to the top of the group.

  Parameters:

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

    - apply_to (list of str, optional) – list of routines to apply this transformation to, if not provided or None apply to all routines (default: None)

  transform_subroutine(routine, **kwargs)

    Fuse vertical loops and demote temporaries in the vertical dimension if possible.

    Parameters:

      routine (`Subroutine`) – The subroutine in the vertical loops should be fused and temporaries be demoted.

  process_kernel(routine)

    Current logic (simplified):

    1. loop interchange to expose vertical loops

    2. fuse vertical loops (possibly into multiple groups)

    3. find local arrays to be demoted and apply heuristics to check whether this is safe

    4. demote those arrays which are safe to be demoted

  check_safe_to_demote(routine, demote_candidates)

    Check whether variables that are candidates to be demoted in the vertical dimension are really safe to be demoted.

    Current heuristic: If the candidate is used in more than one vertical loop, assume it is NOT safe to demote!

  find_relevant_local_arrays(routine)

    Find local arrays/temporaries that do have the vertical dimension.

  find_local_arrays_to_be_ignored(routine)

    Identify variables to be ignore regarding demotion for whatever reason.

    Reasons are:

    - explicitly marked to be ignored via pragmas within the input source file, e.g., ‘loki k-caching ignore(var1, var2, …)’

  identify_multilevel_arrays(local_arrays)

    Identify local arrays/temporaries that have an access in the vertical dimension that is different to ‘<vertical.index>’, e.g., ‘<vertical.index> +/- 1’

  correct_init_of_multilevel_arrays(routine, multilevel_local_arrays)

    Possibly handle initialization of those multilevel local arrays via splitting relevant loops or rather creating a new node with the relevant nodes moved to the newly created loop.

    Note

    This relies on pragmas being inserted in the input source code!