transformations.single_column_coalesced
Classes
|
A set of utilities to insert offload directives. |
|
A basic set of utilities used in the SCC transformation. |
|
A transformation to promote all local arrays with column dimensions to arguments. |
- class SCCBaseTransformation(horizontal, directive=None)
Bases:
Transformation
A basic set of utilities used in the SCC transformation. These utilities can either be used as a transformation in their own right, or the contained class methods can be called directly.
- Parameters:
- classmethod check_routine_pragmas(routine, directive)
Check if routine is marked as sequential or has already been processed.
- Parameters:
routine (
Subroutine
) – Subroutine to perform checks on.directive (string or None) – Directives flavour to use for parallelism annotations; either
'openacc'
orNone
.
- classmethod check_horizontal_var(routine, horizontal)
Check for horizontal loop bounds in a
Subroutine
.- Parameters:
routine (
Subroutine
) – Subroutine to perform checks on.horizontal (
Dimension
) –Dimension
object describing the variable conventions used in code to define the horizontal data dimension and iteration space.
- classmethod get_integer_variable(routine, name)
Find a local variable in the routine, or create an integer-typed one.
- Parameters:
routine (
Subroutine
) – The subroutine in which to find the variablename (string) – Name of the variable to find the in the routine.
- classmethod resolve_masked_stmts(routine, loop_variable)
Resolve
MaskedStatement
(WHERE statement) objects to an explicit combination ofLoop
andConditional
combination.- Parameters:
routine (
Subroutine
) – The subroutine in which to resolve masked statementsloop_variable (
Scalar
) – The induction variable for the created loops.
- classmethod resolve_vector_dimension(routine, loop_variable, bounds)
Resolve vector notation for a given dimension only. The dimension is defined by a loop variable and the bounds of the given range.
TODO: Consolidate this with the internal loki.transform.transform_array_indexing.resolve_vector_notation.
- Parameters:
routine (
Subroutine
) – The subroutine in which to resolve vector notation usage.loop_variable (
Scalar
) – The induction variable for the created loops.bounds (tuple of
Scalar
) – Tuple defining the iteration space of the inserted loops.
- transform_subroutine(routine, **kwargs)
Apply SCCBase 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 SCCBase utilities to a “kernel”. This consists simply of resolving associations, masked statements and vector notation.
- Parameters:
routine (
Subroutine
) – Subroutine to apply this transformation to.
- process_driver(routine)
Applies the SCCBase utilities to a “driver”. This consists simply of resolving associations.
- Parameters:
routine (
Subroutine
) – Subroutine to apply this transformation to.
- class SCCAnnotateTransformation(horizontal, vertical, directive, block_dim, hoist_column_arrays=False)
Bases:
Transformation
A set of utilities to insert offload directives. This includes both
Loop
andSubroutine
level annotations.- Parameters:
horizontal (
Dimension
) –Dimension
object describing the variable conventions used in code to define the horizontal data dimension and iteration space.vertical (
Dimension
) –Dimension
object describing the variable conventions used in code to define the vertical dimension, as needed to decide array privatization.block_dim (
Dimension
) – OptionalDimension
object to define the blocking dimension to use for hoisted column arrays if hoisting is enabled.directive (string or None) – Directives flavour to use for parallelism annotations; either
'openacc'
orNone
.hoist_column_arrays (bool) – Flag to trigger the more aggressive “column array hoisting” optimization.
- classmethod kernel_annotate_vector_loops_openacc(routine, horizontal, vertical)
Insert
!$acc loop vector
annotations around horizontal vector loops, including the necessary private variable declarations.- Parameters:
routine (
Subroutine
) – The subroutine in the vector loops should be removed.horizontal (
Dimension
) – The dimension object specifying the horizontal vector dimensionvertical (
Dimension
) – The dimension object specifying the vertical loop dimension
- classmethod kernel_annotate_sequential_loops_openacc(routine, horizontal)
Insert
!$acc loop seq
annotations around all loops that are not horizontal vector loops.- Parameters:
routine (
Subroutine
) – The subroutine in which to annotate sequential loopshorizontal (
Dimension
) – The dimension object specifying the horizontal vector dimension
- classmethod kernel_annotate_subroutine_present_openacc(routine)
Insert
!$acc data present
annotations around the body of a subroutine.- Parameters:
routine (
Subroutine
) – The subroutine to which annotations will be added
- classmethod insert_annotations(routine, horizontal, vertical, hoist_column_arrays)
- transform_subroutine(routine, **kwargs)
Apply SCCAnnotate 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 SCCAnnotate utilities to a “kernel”. This consists of inserting the relevant
'openacc'
annotations at theLoop
andSubroutine
level.- Parameters:
routine (
Subroutine
) – Subroutine to apply this transformation to.
- process_driver(routine, targets=None, item=None)
Apply the relevant
'openacc'
annotations to the driver loop.- 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.
item (
Item
) – Scheduler work item corresponding to routine.
- classmethod device_alloc_column_locals(routine, column_locals)
Add explicit OpenACC statements for creating device variables for hoisted column locals.
- Parameters:
routine (
Subroutine
) – Subroutine to apply this transformation to.column_locals (list) – List of column locals to be hoisted to driver layer
- classmethod annotate_driver(directive, driver_loop, kernel_loop, block_dim, column_locals)
Annotate driver block loop with
'openacc'
pragmas, and add offload directives for hoisted column locals.- Parameters:
directive (string or None) – Directives flavour to use for parallelism annotations; either
'openacc'
orNone
.driver_loop (
Loop
) – DriverLoop
to wrap in'opencc'
pragmas.kernel_loop (
Loop
) – VectorLoop
to wrap in'opencc'
pragmas if hoisting is enabled.block_dim (
Dimension
) – OptionalDimension
object to define the blocking dimension to use for hoisted column arrays if hoisting is enabled.column_locals (list) – List of column locals to be hoisted to driver layer
- class SCCHoistTransformation(horizontal, vertical, block_dim)
Bases:
Transformation
A transformation to promote all local arrays with column dimensions to arguments.
- Parameters:
horizontal (
Dimension
) –Dimension
object describing the variable conventions used in code to define the horizontal data dimension and iteration space.vertical (
Dimension
) –Dimension
object describing the variable conventions used in code to define the vertical dimension, as needed to decide array privatization.block_dim (
Dimension
) – OptionalDimension
object to define the blocking dimension to use for hoisted column arrays if hoisting is enabled.
- classmethod get_column_locals(routine, vertical)
List of array variables that include a vertical dimension and thus need to be stored in shared memory.
- Parameters:
routine (
Subroutine
) – The subroutine in the vector loops should be removed.vertical (
Dimension
) – The dimension object specifying the vertical dimension
- classmethod add_loop_index_to_args(v_index, routine)
Add loop index to routine arguments.
- Parameters:
routine (
Subroutine
) – The subroutine to modify.v_index (
Scalar
) – The induction variable for the promoted horizontal loops.
- classmethod hoist_temporary_column_arrays(routine, call, horizontal, vertical, block_dim, item=None)
Hoist temporary column arrays to the driver level.
Note that this employs an interprocedural analysis pass (forward), and thus needs to be executed for the calling driver routine before any of the kernels are processed.
- Parameters:
routine (
Subroutine
) – Subroutine to apply this transformation to.call (
CallStatement
) – Call to subroutine from which we hoist the column arrays.horizontal (
Dimension
) – The dimension object specifying the horizontal vector dimensionvertical (
Dimension
) – The dimension object specifying the vertical loop dimensionblock_dim (
Dimension
) –Dimension
object to define the blocking dimension to use for hoisted column arrays if hoisting is enabled.item (
Item
) – Scheduler work item corresponding to routine.
- transform_subroutine(routine, **kwargs)
Apply SCCHoist 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 SCCHoist utilities to a “kernel” and promote all local arrays with column dimension to arguments.
- Parameters:
routine (
Subroutine
) – Subroutine to apply this transformation to.
- process_driver(routine, targets=None, item=None)
Hoist temporary column arrays.
Note that the driver needs to be processed before any kernels are transformed. This is due to the use of an interprocedural analysis forward pass needed to collect the list of “column arrays”.
- 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.
item (
Item
) – Scheduler work item corresponding to routine.