psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans

Module providing a transformation from a generic PSyIR routine into a NEMO InvokeSchedule.

Classes

class psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans

Transform a generic PSyIR Routine into a NEMO InvokeSchedule. For example:

>>> from psyclone.psyir.frontend.fortran import FortranReader
>>> from psyclone.psyir.nodes import Loop
>>> from psyclone.domain.nemo.transformations import     CreateNemoInvokeScheduleTrans
>>> code = '''
... subroutine sub()
...   integer :: ji
...   real :: tmp(10)
...   do ji=1, 10
...     tmp(ji) = 2.0*ji
...   end do
... end subroutine sub'''
>>> psyir = FortranReader().psyir_from_source(code)
>>> loop = psyir.walk(Loop)[0]
>>> trans = CreateNemoInvokeScheduleTrans()
>>> trans.apply(psyir.children[0])
>>> print(psyir.view(colour=False))
FileContainer[]
    NemoInvokeSchedule[invoke='sub']
        0: Loop[variable='ji']
            Literal[value:'1', Scalar<INTEGER, UNDEFINED>]
            Literal[value:'10', Scalar<INTEGER, UNDEFINED>]
            Literal[value:'1', Scalar<INTEGER, UNDEFINED>]
            Schedule[]
                0: Assignment[]
                    ArrayReference[name:'tmp']
                        Reference[name:'ji']
                    BinaryOperation[operator:'MUL']
                        Literal[value:'2.0', Scalar<REAL, UNDEFINED>]
                        Reference[name:'ji']

The root node of this example has been transformed from a Routine into a NemoInvokeSchedule.

Inheritance

Inheritance diagram of CreateNemoInvokeScheduleTrans
apply(node, options=None)

Takes a generic PSyIR Routine and replaces it with a NemoInvokeSchedule (in-place). Note that this may mean replacing the top-level node itself and therefore this routine returns the root of the modified tree.

Parameters:
  • node (psyclone.psyir.nodes.Routine) – the routine node to be transformed.

  • options (Optional[Dict[str, Any]]) – a dictionary with options for transformations. No options are used in this transformation. This is an optional argument that defaults to None.

property name
Returns:

the name of the transformation.

Return type:

str

TODO #1214 remove this method.

validate(node, options=None)

Check that the supplied node is a valid target for this transformation.

Parameters:
  • node (psyclone.psyir.nodes.Node) – the target of the transformation.

  • options (Optional[Dict[str, Any]]) – a dictionary with options for transformations. No options are used in this transformation. This is an optional argument that defaults to None.

Raises:

TransformationError – if the supplied node is not a Routine.