psyclone.domain.common.transformations
Submodules
Classes
AlgInvoke2PSyCallTrans
: Base class to transform (lower) an AlgorithmInvokeCall into aAlgTrans
: Transform a generic PSyIR representation of the Algorithm layer toKernelModuleInlineTrans
: Module-inlines (bring the subroutine to the same compiler-unit) theRaisePSyIR2AlgTrans
: Transform a generic PSyIR representation of an Algorithm-layer
- class psyclone.domain.common.transformations.AlgInvoke2PSyCallTrans
Base class to transform (lower) an AlgorithmInvokeCall into a standard Call to a generated PSy-layer routine. Requires the abstract get_arguments method to be implemented as the logic to create arguments can differ between APIs.
This transformation would normally be written as a lowering method on an AlgorithmInvokeCall. However, we don’t always want to lower the code as we want the flexibility to also be able to output algorithm-layer code containing invoke’s. We therefore need to selectively apply the lowering, which is naturally written as a transformation.
Inheritance
- apply(node, options=None)
Apply the transformation to the supplied AlgorithmInvokeCall. The supplied node will be replaced with a Call node with appropriate arguments. If there are no more invoke calls in the scope of the symbol table containing the ‘invoke’ symbol then that symbol is removed.
- Parameters:
node (
psyclone.domain.common.psyir.AlgorithmInvokeCall
) – a PSyIR algorithm invoke call node.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- abstract get_arguments(node, options=None)
- Parameters:
node (
psyclone.domain.common.psyir.AlgorithmInvokeCall
) – a PSyIR algorithm invoke call node.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- static remove_imported_symbols(node)
Removes any imported kernel functor symbols from the supplied AlgorithmInvokeCall if they are not used in another AlgorithmInvokeCall. Also removes the associated container symbol if there are now no symbols imported from it.
- Parameters:
node (
psyclone.domain.common.algorithm.AlgorithmInvokeCall
) – an AlgorithmInvokeCall node.
- validate(node, options=None)
Validate the node argument.
- Parameters:
node (
psyclone.domain.common.algorithm.AlgorithmInvokeCall
) – a PSyIR node capturing an invoke call.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- Raises:
TransformationError – if the supplied call argument is not a PSyIR AlgorithmInvokeCall node.
InternalError – if no corresponding ‘invoke’ symbol is present.
- class psyclone.domain.common.transformations.AlgTrans
Transform a generic PSyIR representation of the Algorithm layer to a PSyclone version with specialised domain-specific nodes.
Inheritance
- apply(psyir, options=None)
Apply transformation to the supplied PSyIR node.
- Parameters:
node (
psyclone.psyir.node.Routine
orpsyclone.psyir.node.Container
) – a PSyIR node that is the root of a PSyIR tree.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- validate(node, options=None)
Validate the supplied PSyIR tree.
- Parameters:
node (
psyclone.psyir.node.Routine
orpsyclone.psyir.node.Container
) – a PSyIR node that is the root of a PSyIR tree.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- Raises:
TransformationError – if the supplied node argument is not a Routine or a Container.
TransformationError – if the supplied node argument has a parent.
- class psyclone.domain.common.transformations.KernelModuleInlineTrans
Module-inlines (bring the subroutine to the same compiler-unit) the subroutine pointed by this Kernel. For example:
from psyclone.domain.common.transformations import \ KernelModuleInlineTrans inline_trans = KernelModuleInlineTrans() inline_trans.apply(schedule.walk(CodedKern)[0]) print(schedule.parent.view())
Warning
Not all kernel subroutines can be module-inlined. This transformation will reject attempts to in-line kernels that access global data in the original module.
Inheritance
- apply(node, options=None)
Bring the kernel subroutine into this Container.
- Parameters:
node (
psyclone.psyGen.CodedKern
) – the kernel to module-inline.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- validate(node, options=None)
Checks that the supplied node is a Kernel and that it is possible to inline its PSyIR.
- Parameters:
kern (
psyclone.psyGen.CodedKern
) – the kernel which is the target of the transformation.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- Raises:
TransformationError – if the target node is not a sub-class of psyGen.CodedKern.
TransformationError – if the subroutine containing the implementation of the kernel cannot be retrieved with ‘get_kernel_schedule’.
TransformationError – if the name of the routine that implements the kernel is not the same as the kernel name. This will happen if the kernel is polymorphic (uses a Fortran INTERFACE) and will be resolved by #1824.
TransformationError – if the kernel cannot be safely inlined.
- class psyclone.domain.common.transformations.RaisePSyIR2AlgTrans
Transform a generic PSyIR representation of an Algorithm-layer invoke call to a PSyclone version with specialised domain-specific nodes.
Inheritance
- apply(call, index, options=None)
Apply the transformation to the supplied node.
- Parameters:
call (
psyclone.psyir.nodes.Call
) – a PSyIR call node capturing an invoke call in generic PSyIR.index (int) – the position of this invoke call relative to other invokes in the algorithm layer.
options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- validate(node, options=None)
Validate the node argument.
- Parameters:
node (
psyclone.psyir.nodes.Call
) – a PSyIR call node capturing an invoke call in generic PSyIR.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
- Raises:
TransformationError – if the supplied call argument is not a PSyIR Call node.
TransformationError – if the supplied call argument does not have the expected name which would identify it as an invoke call.
TransformationError – if there is more than one named argument.
TransformationError – if the named argument does not conform to the name=str format.
TransformationError – if the name of the invoke is invalid.
TransformationError – if the invoke arguments are not a PSyIR ArrayReference or CodeBlock.