psyclone.psyir.transformations.loop_fuse_trans
This module provides the generic loop fusion class, which is the base class for all API-specific loop fusion transformations.
Classes
LoopFuseTrans
: Provides a generic loop-fuse transformation to two Nodes in the
- class psyclone.psyir.transformations.loop_fuse_trans.LoopFuseTrans
Provides a generic loop-fuse transformation to two Nodes in the PSyIR of a Schedule after performing validity checks for the supplied Nodes. Examples are given in the descriptions of any children classes.
If loops have different named loop variables, when possible the loop variable of the second loop will be renamed to be the same as the first loop. This has the side effect that the second loop’s variable will no longer have its value modified, with the expectation that that value isn’t used anymore.
Note that the validation of this transformation still has several shortcomings, especially for domain API loops. Use at your own risk.
Inheritance
- apply(node1, node2, options=None)
Fuses two loops represented by psyclone.psyir.nodes.Node objects after performing validity checks.
If the two loops don’t have the same loop variable, the second loop’s variable (and references to it inside the loop) will be changed to be references to the first loop’s variable before merging. This has the side effect that the second loop’s variable will no longer have its value modified, with the expectation that that value isn’t used after.
- Parameters:
node1 (
psyclone.psyir.nodes.Node
) – the first Node that is being checked.node2 (
psyclone.psyir.nodes.Node
) – the second Node that is being checked.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- validate(node1, node2, options=None)
Performs various checks to ensure that it is valid to apply the LoopFuseTrans transformation to the supplied Nodes.
- Parameters:
node1 (
psyclone.psyir.nodes.Node
) – the first Node that is being checked.node2 (
psyclone.psyir.nodes.Node
) – the second Node that is being checked.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
options["force"] (bool) – whether to force fusion of the target loop (i.e. ignore any dependence analysis). This only skips a limited number of the checks, and does not fully force merging.
- Raises:
TransformationError – if one or both of the Nodes is/are not a
psyclone.psyir.nodes.Loop
.TransformationError – if one or both Nodes are not fully-formed.
TransformationError – if the Nodes do not have the same parent.
TransformationError – if the Nodes are not next to each other in the tree.
TransformationError – if the two Loops do not have the same iteration space.
TransformationError – if the two Loops don’t share the same iteration variable, but make use of the other loop’s variable in their body.
TransformationError – if there are dependencies between the loops that prevent the loop fusion.