psyclone.domain.lfric.transformations.lfric_redundant_computation_trans#
This module provides the LFRic redundant-computation transformation.
Classes#
LFRicRedundantComputationTrans: This transformation allows the user to modify a loop’s bounds so
- class psyclone.domain.lfric.transformations.lfric_redundant_computation_trans.LFRicRedundantComputationTrans[source]#
This transformation allows the user to modify a loop’s bounds so that redundant computation will be performed. Redundant computation can result in halo exchanges being modified, new halo exchanges being added or existing halo exchanges being removed.
This transformation should be performed before any parallelisation transformations (e.g. for OpenMP) to the loop in question and will raise an exception if this is not the case.
This transformation can not be applied to a loop containing a reduction and will again raise an exception if this is the case.
This transformation can only be used to add redundant computation to a loop, not to remove it.
This transformation allows a loop that is already performing redundant computation to be modified, but only if the depth is increased.
Inheritance

- apply(node, options=None, depth=None, **kwargs)[source]#
Apply the redundant computation transformation to the loop
node. This transformation can be applied to loops iterating over ‘cells or ‘dofs’. ifdepthis set to a value then the value will be the depth of the field’s halo over which redundant computation will be performed. Ifdepthis not set to a value then redundant computation will be performed to the full depth of the field’s halo.- Parameters:
node (
Loop) – the loop to transform.options (
Optional[dict[str,Any]]) – a dictionary with options for transformations.depth (
Union[int,DataNode,None]) – the depth to which to perform redundant computation. Default is None in which case the full halo depth is used.node_type_check (bool) – If the type of nodes enclosed in the loop should be tested to avoid including unsupported nodes in the transformation.
verbose (bool) – whether to log the reason the validation failed, at the moment with a comment in the provided PSyIR node.
- validate(node, options=None, **kwargs)[source]#
Perform various checks to ensure that it is valid to apply the RedundantComputation transformation to the supplied node
- Parameters:
node (
Loop) – the supplied node on which we are performing validity checks.options (dict[str, Any] | None) – a dictionary with options for transformations.
depth (int | psyclone.psyir.nodes.datanode.DataNode | None) – the depth to which to perform redundant computation. Default is None in which case the full halo depth is used.
node_type_check (bool) – If the type of nodes enclosed in the loop should be tested to avoid including unsupported nodes in the transformation.
verbose (bool) – whether to log the reason the validation failed, at the moment with a comment in the provided PSyIR node.
- Raises:
TransformationError – if the parent of the loop is a
psyclone.psyir.nodes.Directive.TransformationError – if the parent of the loop is not a
psyclone.psyir.nodes.Loopor apsyclone.psyGen.LFRicInvokeSchedule.TransformationError – if the parent of the loop is
psyclone.psyir.nodes.Loopbut the original loop does not iterate over ‘cells_in_colour’.TransformationError – if the parent of the loop is a
psyclone.psyir.nodes.Loopbut the parent does not iterate over ‘colours’.TransformationError – if the parent of the loop is a
psyclone.psyir.nodes.Loopbut the parent’s parent is not apsyclone.psyGen.LFRicInvokeSchedule.TransformationError – if this transformation is applied when distributed memory is not switched on.
TransformationError – if the loop does not iterate over cells, dofs or colour.
TransformationError – if the loop contains a kernel that operates on halo cells or only on owned cells/dofs.
TransformationError – if the transformation is setting the loop to the maximum halo depth but the loop already computes to the maximum halo depth.
TransformationError – if the transformation is setting the loop to the maximum halo depth but the loop contains a stencil access (as this would result in the field being accessed beyond the halo depth).
TypeError – if the supplied depth value is of the wrong type.
TransformationError – if the supplied depth value is less than 1.
TransformationError – if the supplied depth value is not greater than 1 when a continuous loop is modified as this is the minimum valid value.
TransformationError – if the supplied depth value is not greater than the existing depth value, as we should not need to undo existing transformations.
TransformationError – if a depth value has been supplied but the loop has already been set to the maximum halo depth.