# loki.transformations.single_column.vector

Functions

`wrap_vector_section`(section, routine, ...[, ...]) | Wrap a section of nodes in a vector-level loop across the horizontal.
`wrap_vector_section_from_dimension`(section, ...) | Wrap a section of nodes in a vector-level loop across the horizontal.

Classes

`BaseRevectorTransformation`(horizontal) | A base/parent class for transformation to wrap thread-parallel IR sections within a horizontal loop.
`SCCDemoteTransformation`(horizontal[, ...]) | A set of utilities to determine which local arrays can be safely demoted in a `Subroutine` as part of a transformation pass.
`SCCDevectorTransformation`(horizontal[, ...]) | A set of utilities that can be used to strip vector loops from a `Subroutine` and determine the regions of the IR to be placed within thread-parallel loop directives.
`SCCRevectorTransformation` | alias of `SCCVecRevectorTransformation`

`SCCSeqRevectorTransformation`(horizontal)

A transformation to wrap thread-parallel IR sections within a horizontal loop in a way that the horizontal loop is hoisted/moved to the driver level while the horizontal/loop index is passed as an argument. This transformation relies on markers placed by `SCCDevectorTransformation`. :param horizontal: `Dimension` object describing the variable conventions used in code to define the horizontal data dimension and iteration space. :type horizontal: `Dimension`.

`SCCVecRevectorTransformation`(horizontal) | A transformation to wrap thread-parallel IR sections within a horizontal loop.

class SCCDevectorTransformation(horizontal, trim_vector_sections=False)

  Bases: `Transformation`

  A set of utilities that can be used to strip vector loops from a `Subroutine` and determine the regions of the IR to be placed within thread-parallel loop directives.

  Parameters:

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

    - trim_vector_sections (bool) – Flag to trigger trimming of extracted vector sections to remove nodes that are not assignments involving vector parallel arrays.

  classmethod kernel_remove_vector_loops(routine, horizontal)

    Remove all vector loops over the specified dimension.

    Parameters:

      - routine (`Subroutine`) – The subroutine in the vector loops should be removed.

      - horizontal (`Dimension`) – The dimension specifying the horizontal vector dimension

  classmethod extract_vector_sections(section, horizontal)

    Extract a contiguous sections of nodes that contains vector-level computations and are not interrupted by recursive subroutine calls or nested control-flow structures.

    Parameters:

      - section (tuple of `Node`) – A section of nodes from which to extract vector-level sub-sections

      - horizontal (`Dimension`) – The dimension specifying the horizontal vector dimension

  classmethod get_trimmed_sections(routine, horizontal, sections)

    Trim extracted vector sections to remove nodes that are not assignments involving vector parallel arrays.

  transform_subroutine(routine, **kwargs)

    Apply SCCDevector utilities to a `Subroutine`.

    Parameters:

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

      - role (string) – Role of the subroutine in the call tree; should be `"kernel"`

  process_kernel(routine)

    Applies the SCCDevector utilities to a “kernel”. This consists simply of stripping vector loops and determing which sections of the IR can be placed within thread-parallel loops.

    Parameters:

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

  process_driver(routine, targets=())

    Applies the SCCDevector utilities to a “driver”. This consists simply of stripping vector loops and determining which sections of the IR can be placed within thread-parallel loops.

    Parameters:

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

      - targets (list or string) – List of subroutines that are to be considered as part of the transformation call tree.

SCCRevectorTransformation

  alias of `SCCVecRevectorTransformation`

class SCCVecRevectorTransformation(horizontal)

  Bases: `BaseRevectorTransformation`

  A transformation to wrap thread-parallel IR sections within a horizontal loop. This transformation relies on markers placed by `SCCDevectorTransformation`.

  Parameters:

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

  transform_subroutine(routine, **kwargs)

    Wrap vector-parallel sections in vector `Loop` objects.

    This wraps all thread-parallel sections within “kernel” routines or within the parallel loops in “driver” routines.

    The markers placed by `SCCDevectorTransformation` are removed

    Parameters:

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

      - role (str) – Must be either `"kernel"` or `"driver"`

      - targets (tuple or str) – Tuple of target routine names for determining “driver” loops

class SCCSeqRevectorTransformation(horizontal)

  Bases: `BaseRevectorTransformation`

  A transformation to wrap thread-parallel IR sections within a horizontal loop in a way that the horizontal loop is hoisted/moved to the driver level while the horizontal/loop index is passed as an argument. This transformation relies on markers placed by `SCCDevectorTransformation`. :param horizontal: `Dimension` object describing the variable conventions used in code

  > to define the horizontal data dimension and iteration space.

  process_ignored_items = True
  remove_vector_sections(section)

    Remove all thread-parallel `Section` objects within a given code section :param routine: Subroutine to apply this transformation to. :type routine: `Subroutine` :param section: Code section in which to replace vector-parallel

    > `Section` objects.

  mark_vector_reductions(routine, section)

    Mark vector-reduction loops in marked vector-reduction regions. If a region explicitly marked with `!$loki vector-reduction(<reduction clause>)`/ `!$loki end vector-reduction` is encountered, we replace existing `!$loki loop vector` loop pragmas and add the reduction keyword and clause. These will be turned into OpenACC equivalents by `SCCAnnotate`.

  transform_subroutine(routine, **kwargs)

    Wrap vector-parallel sections in vector `Loop` objects. This wraps all thread-parallel sections within “kernel” routines or within the parallel loops in “driver” routines. The markers placed by `SCCDevectorTransformation` are removed :param routine: Subroutine to apply this transformation to. :type routine: `Subroutine` :param role: Must be either `"kernel"` or `"driver"` :type role: str :param targets: Tuple of target routine names for determining “driver” loops :type targets: tuple or str

class SCCDemoteTransformation(horizontal, demote_local_arrays=True)

  Bases: `Transformation`

  A set of utilities to determine which local arrays can be safely demoted in a `Subroutine` as part of a transformation pass.

  Unless the option demote_local_arrays is set to False, this transformation will demote local arrays that do not buffer values between vector loops. Specific arrays in individual routines can also be marked for preservation by assigning them to the preserve_arrays list in the `SchedulerConfig`.

  Parameters:

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

  classmethod get_locals_to_demote(routine, sections, horizontal)

    Create a list of local temporary arrays after checking that demotion is safe.

    Demotion is considered safe if the temporary is only used within one coherent vector-section (see `extract_vector_sections`).

    Local temporaries get demoted if they have: * Only one dimension, which is the `horizontal` * Have the `horizontal` as the innermost dimension, with all

    > other dimensions being declared constant parameters.

  transform_subroutine(routine, **kwargs)

    Apply SCCDemote utilities to a `Subroutine`.

    Parameters:

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

      - role (string) – Role of the subroutine in the call tree; should be `"kernel"`

  process_kernel(routine, demote_locals=True, preserve_arrays=None)

    Applies the SCCDemote utilities to a “kernel” and demotes all suitable local arrays.

    Parameters:

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

wrap_vector_section(section, routine, bounds, index, insert_pragma=True)

  Wrap a section of nodes in a vector-level loop across the horizontal.

  Parameters:

    - section (tuple of `Node`) – A section of nodes to be wrapped in a vector-level loop

    - routine (`Subroutine`) – The subroutine in the vector loops should be removed.

    - horizontal (`Dimension`) – The dimension specifying the horizontal vector dimension

    - insert_pragma (bool, optional) – Adds a `!$loki vector` pragma around the created loop