psyclone.domain.gocean.transformations.raise_psyir_2_gocean_kern_trans
Raise generic PSyIR representing a kernel-layer routine to PSyclone kernel-layer-specific PSyIR which uses specialised classes.
Functions
find_symbol()
: Utility method to find the symbol associated with the supplied
- psyclone.domain.gocean.transformations.raise_psyir_2_gocean_kern_trans.find_symbol(node, name)
Utility method to find the symbol associated with the supplied name. The supplied node and all of its siblings are searched and the symbol and its scoping node are returned if the symbol is found.
- Parameters:
node – the starting node for the search.
name (str) – the name of the symbol being searched.
- Type:
- Returns:
a tuple containing the symbol with the same name as the supplied name and the scoping node for that symbol.
- Return type:
Optional[(
psyclone.psyir.symbols.datasymbol, :py:class:`psyclone.psyir.nodes.node
)]
Classes
RaisePSyIR2GOceanKernTrans
: Raise a generic PSyIR representation of a kernel-layer routine
- class psyclone.domain.gocean.transformations.raise_psyir_2_gocean_kern_trans.RaisePSyIR2GOceanKernTrans(metadata_name)
Raise a generic PSyIR representation of a kernel-layer routine to a PSyclone version with specialised domain-specific nodes and symbols. This is currently limited to the specialisation of kernel metadata.
>>> from psyclone.domain.gocean.transformations import RaisePSyIR2GOceanKernTrans >>> from psyclone.psyir.frontend.fortran import FortranReader >>> CODE = (""" ... MODULE example ... TYPE, EXTENDS(kernel_type) :: compute_cu ... TYPE(go_arg), DIMENSION(4) :: meta_args = (/ & ... go_arg(GO_WRITE, GO_CU, GO_POINTWISE), & ... go_arg(GO_READ, GO_CT, GO_STENCIL(000, 011, 000)), & ... go_arg(GO_READ, GO_GRID_AREA_T), & ... go_arg(GO_READ, GO_R_SCALAR, GO_POINTWISE)/) ... INTEGER :: ITERATES_OVER = GO_ALL_PTS ... INTEGER :: index_offset = GO_OFFSET_SW ... CONTAINS ... PROCEDURE, NOPASS :: code => compute_cu_code ... END TYPE compute_cu ... contains ... subroutine compute_cu_code() ... end subroutine ... end module""") >>> fortran_reader = FortranReader() >>> kernel_container = fortran_reader.psyir_from_source(CODE) >>> trans = RaisePSyIR2GOceanKernTrans("compute_cu") >>> trans.apply(kernel_container)
- Parameters:
metadata_name (str) – the name of the symbol containing the required kernel metadata in language-level PSyIR.
- Raises:
TransformationError – if the supplied metadata_name is invalid.
Inheritance
- apply(node, options=None)
Raise the supplied language-level GOcean kernel PSyIR to GOcean-specific kernel PSyIR. Specialises the kernel container to a GOcean-specific subclass, populates this subclass with the kernel metadata extracted from the metadata symbol as specified in metadata_name and removes the symbol from the symbol table.
- Parameters:
node (
psyclone.psyir.node.Container
) – a kernel represented in generic PSyIR.options (Optional[Dict[str: str]]) – a dictionary with options for transformations.
- validate(node, options=None)
Validate the supplied PSyIR tree.
- Parameters:
node (
psyclone.psyir.node.Container
) – a PSyIR node that is the root of a PSyIR tree.options (Optional[Dict[str: str]]) – a dictionary with options for transformations.
- Raises:
TransformationError – if the metadata name has not been set or does not exist in the code.
TransformationError – if the supplied node is not a Container.
TransformationError – if the supplied node argument has a parent.
TransformationError – if the kernel metadata cannot be parsed.
TransformationError – if the Container does not contain the routine which implements the kernel.