loki.transformations.single_column.vector

Functions

wrap_vector_section(section, routine, horizontal)

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

Classes

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(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.

class SCCRevectorTransformation(horizontal, remove_vector_section=False)

Bases: Transformation

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.

revector_section(routine, section)

Wrap all thread-parallel Section objects within a given code section in a horizontal loop and mark interior loops as !$loki loop seq.

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

  • section (tuple of Node) – 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.

mark_seq_loops(section)

Mark interior sequential loops in a thread-parallel section with !$loki loop seq for later annotation.

This utility requires loop-pragmas to be attached via pragmas_attached. It also updates loops in-place.

Parameters:

section (tuple of Node) – Code section in which to mark “seq loops”.

mark_driver_loop(routine, loop)

Add !$loki loop driver pragmas to outer block loops and add vector-length(size) clause for later annotations.

This method assumes that pragmas have been attached via pragmas_attached.

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 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, horizontal, 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