psyclone.domain.lfric.transformations.lfric_alg_invoke_2_psy_call_trans
Transform a PSyclone LFRic algorithm-layer-specific invoke call into a call to the corresponding PSy-layer routine.
Classes
LFRicAlgInvoke2PSyCallTrans
: Transforms an LFRicAlgorithmInvokeCall into a standard Call to a generated
- class psyclone.domain.lfric.transformations.lfric_alg_invoke_2_psy_call_trans.LFRicAlgInvoke2PSyCallTrans
Transforms an LFRicAlgorithmInvokeCall into a standard Call to a generated PSy-layer routine.
This transformation would normally be written as a lowering method on a LFRicAlgorithmInvokeCall. 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 LFRicAlgorithmInvokeCall node. That node is replaced by a Call to the corresponding PSy-layer routine with appropriate arguments. The symbols representing any LFRic Builtins that are now no longer referred to are removed.
- Parameters:
node (
psyclone.domain.lfric.algorithm.LFRicAlgorithmInvokeCall
) – a PSyIR algorithm invoke call node.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
options["kernels"] (List[
psyclone.psyir.nodes.Container
]) – this option provides a list of LFRic kernels for this LFRic Algorithm Invoke call.
- get_arguments(node, options=None, check_args=False)
By default this method creates the LFRic processed (lowered) argument list from the argument lists of the kernel functors within the invoke call and the kernel metadata.
If the check_args flag is set to True this method does not create an argument list, but instead checks that the number of arguments expected by the kernel metadata and the number of arguments supplied in the algorithm layer match.
Check args does not create the argument list because a) it is faster to not create the list and b) a mismatch in the number of expected and actual arguments can cause an index error.
- Parameters:
node (
psyclone.domain.lfric.algorithm.psyir. LFRicAlgorithmInvokeCall
) – an LFRic algorithm invoke call.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
options["kernels"] (List[
psyclone.psyir.nodes.Container
]) – this option provides a list of LFRic kernels for this LFRic Algorithm Invoke call.check_args (bool) – if True, checks the number of kernel functor arguments matches the number expected by the kernel metadata. Defaults to False.
- Returns:
the processed (lowered) argument list.
- Return type:
- Raises:
GenerationError – if the number of arguments in the invoke does not match the expected number of arguments specified by the metadata.
- validate(node, options=None)
Validate the node argument.
- Parameters:
node (
psyclone.domain.lfric.algorithm.LFRicAlgorithmInvokeCall
) – a PSyIR node capturing an LFRicinvoke call.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
options["kernels"] (List[
psyclone.psyir.nodes.Container
]) – this option provides a list of LFRic kernels for this LFRic Algorithm Invoke call.
- Raises:
TransformationError – if the supplied call argument is not a PSyIR AlgorithmInvokeCall node.
TransformationError – if the ‘kernels’ option is not provided.