Reference Guide  2.5.0
psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans Class Reference
Inheritance diagram for psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans:
Collaboration diagram for psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans:

Public Member Functions

def name (self)
 
def validate (self, node, options=None)
 
def apply (self, node, options=None)
 

Detailed Description

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']
<BLANKLINE>

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

Definition at line 47 of file create_nemo_invoke_schedule_trans.py.

Member Function Documentation

◆ apply()

def psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans.apply (   self,
  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.

:param node: the routine node to be transformed.
:type node: :py:class:`psyclone.psyir.nodes.Routine`
:param options: a dictionary with options for \
    transformations. No options are used in this \
    transformation. This is an optional argument that defaults \
    to None.
:type options: Optional[Dict[str, Any]]

Definition at line 122 of file create_nemo_invoke_schedule_trans.py.

122  def apply(self, node, options=None):
123  '''
124  Takes a generic PSyIR Routine and replaces it with a
125  NemoInvokeSchedule (in-place). Note that this may mean replacing
126  the top-level node itself and therefore this routine returns the
127  root of the modified tree.
128 
129  :param node: the routine node to be transformed.
130  :type node: :py:class:`psyclone.psyir.nodes.Routine`
131  :param options: a dictionary with options for \
132  transformations. No options are used in this \
133  transformation. This is an optional argument that defaults \
134  to None.
135  :type options: Optional[Dict[str, Any]]
136 
137  '''
138  self.validate(node, options=options)
139 
140  # If it's a function we need to provide the return_symbol_name to the
141  # create method
142  return_symbol_name = None
143  if node.return_symbol:
144  return_symbol_name = node.return_symbol.name
145 
146  new_node = NemoInvokeSchedule.create(
147  node.name, node.symbol_table.detach(), node.pop_all_children(),
148  is_program=node.is_program,
149  return_symbol_name=return_symbol_name)
150 
151  # We need to replace the top node in the (possibly sub-) PSyIR
152  # tree that we've been passed.
153  if node.parent:
154  node.replace_with(new_node)
155 
156 
157 # For AutoAPI documentation generation

References psyclone.domain.lfric.kernel.lfric_kernel_metadata.LFRicKernelMetadata.validate(), psyclone.transformations.MoveTrans.validate(), psyclone.transformations.Dynamo0p3AsyncHaloExchangeTrans.validate(), psyclone.domain.common.transformations.alg_invoke_2_psy_call_trans.AlgInvoke2PSyCallTrans.validate(), psyclone.domain.common.transformations.alg_trans.AlgTrans.validate(), psyclone.domain.common.transformations.kernel_module_inline_trans.KernelModuleInlineTrans.validate(), psyclone.domain.common.transformations.raise_psyir_2_alg_trans.RaisePSyIR2AlgTrans.validate(), psyclone.domain.gocean.transformations.gocean_const_loop_bounds_trans.GOConstLoopBoundsTrans.validate(), psyclone.domain.gocean.transformations.gocean_move_iteration_boundaries_inside_kernel_trans.GOMoveIterationBoundariesInsideKernelTrans.validate(), psyclone.domain.gocean.transformations.gocean_opencl_trans.GOOpenCLTrans.validate(), psyclone.domain.gocean.transformations.raise_psyir_2_gocean_kern_trans.RaisePSyIR2GOceanKernTrans.validate(), psyclone.domain.lfric.transformations.lfric_alg_invoke_2_psy_call_trans.LFRicAlgInvoke2PSyCallTrans.validate(), psyclone.domain.lfric.transformations.raise_psyir_2_lfric_kern_trans.RaisePSyIR2LFRicKernTrans.validate(), psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans.validate(), psyclone.domain.nemo.transformations.create_nemo_psy_trans.CreateNemoPSyTrans.validate(), psyclone.domain.nemo.transformations.nemo_allarrayrange2loop_trans.NemoAllArrayRange2LoopTrans.validate(), psyclone.domain.nemo.transformations.nemo_arrayrange2loop_trans.NemoArrayRange2LoopTrans.validate(), psyclone.domain.nemo.transformations.nemo_outerarrayrange2loop_trans.NemoOuterArrayRange2LoopTrans.validate(), psyclone.psyad.transformations.assignment_trans.AssignmentTrans.validate(), psyclone.psyGen.Transformation.validate(), psyclone.psyir.transformations.acc_update_trans.ACCUpdateTrans.validate(), psyclone.psyir.transformations.allarrayaccess2loop_trans.AllArrayAccess2LoopTrans.validate(), psyclone.psyir.transformations.arrayaccess2loop_trans.ArrayAccess2LoopTrans.validate(), psyclone.psyir.transformations.arrayrange2loop_trans.ArrayRange2LoopTrans.validate(), psyclone.psyir.transformations.chunk_loop_trans.ChunkLoopTrans.validate(), psyclone.psyir.transformations.fold_conditional_return_expressions_trans.FoldConditionalReturnExpressionsTrans.validate(), psyclone.psyir.transformations.hoist_local_arrays_trans.HoistLocalArraysTrans.validate(), psyclone.psyir.transformations.hoist_loop_bound_expr_trans.HoistLoopBoundExprTrans.validate(), psyclone.psyir.transformations.hoist_trans.HoistTrans.validate(), psyclone.psyir.transformations.inline_trans.InlineTrans.validate(), psyclone.psyir.transformations.intrinsics.array_reduction_base_trans.ArrayReductionBaseTrans.validate(), psyclone.psyir.transformations.intrinsics.dotproduct2code_trans.DotProduct2CodeTrans.validate(), psyclone.psyir.transformations.intrinsics.intrinsic2code_trans.Intrinsic2CodeTrans.validate(), psyclone.psyir.transformations.intrinsics.matmul2code_trans.Matmul2CodeTrans.validate(), psyclone.psyir.transformations.loop_swap_trans.LoopSwapTrans.validate(), psyclone.psyir.transformations.loop_tiling_2d_trans.LoopTiling2DTrans.validate(), psyclone.psyir.transformations.loop_trans.LoopTrans.validate(), psyclone.psyir.transformations.omp_task_trans.OMPTaskTrans.validate(), psyclone.psyir.transformations.omp_taskwait_trans.OMPTaskwaitTrans.validate(), psyclone.psyir.transformations.parallel_loop_trans.ParallelLoopTrans.validate(), psyclone.psyir.transformations.reference2arrayrange_trans.Reference2ArrayRangeTrans.validate(), psyclone.psyir.transformations.replace_induction_variables_trans.ReplaceInductionVariablesTrans.validate(), psyclone.transformations.OMPDeclareTargetTrans.validate(), psyclone.transformations.DynamoOMPParallelLoopTrans.validate(), psyclone.transformations.Dynamo0p3OMPLoopTrans.validate(), psyclone.transformations.GOceanOMPLoopTrans.validate(), psyclone.transformations.Dynamo0p3RedundantComputationTrans.validate(), psyclone.transformations.Dynamo0p3KernelConstTrans.validate(), psyclone.transformations.ACCRoutineTrans.validate(), psyclone.transformations.KernelImportsToArguments.validate(), psyclone.domain.gocean.transformations.gocean_loop_fuse_trans.GOceanLoopFuseTrans.validate(), psyclone.domain.lfric.transformations.lfric_loop_fuse_trans.LFRicLoopFuseTrans.validate(), psyclone.psyir.transformations.loop_fuse_trans.LoopFuseTrans.validate(), psyclone.domain.gocean.transformations.gocean_extract_trans.GOceanExtractTrans.validate(), psyclone.domain.lfric.transformations.lfric_extract_trans.LFRicExtractTrans.validate(), psyclone.psyir.transformations.extract_trans.ExtractTrans.validate(), psyclone.psyir.transformations.nan_test_trans.NanTestTrans.validate(), psyclone.psyir.transformations.read_only_verify_trans.ReadOnlyVerifyTrans.validate(), psyclone.transformations.ParallelRegionTrans.validate(), psyclone.transformations.OMPParallelTrans.validate(), psyclone.transformations.ACCParallelTrans.validate(), psyclone.transformations.ACCKernelsTrans.validate(), psyclone.transformations.ACCDataTrans.validate(), psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.validate(), psyclone.psyir.transformations.region_trans.RegionTrans.validate(), and psyclone.transformations.ACCEnterDataTrans.validate().

Here is the call graph for this function:

◆ name()

def psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans.name (   self)
:returns: the name of the transformation.
:rtype: str

TODO #1214 remove this method.

Definition at line 89 of file create_nemo_invoke_schedule_trans.py.

89  def name(self):
90  '''
91  :returns: the name of the transformation.
92  :rtype: str
93 
94  TODO #1214 remove this method.
95 
96  '''
97  return type(self).__name__
98 
Here is the caller graph for this function:

◆ validate()

def psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans.validate (   self,
  node,
  options = None 
)
Check that the supplied node is a valid target for this transformation.

:param node: the target of the transformation.
:type node: :py:class:`psyclone.psyir.nodes.Node`
:param options: a dictionary with options for \
    transformations. No options are used in this \
    transformation. This is an optional argument that defaults \
    to None.
:type options: Optional[Dict[str, Any]]

:raises TransformationError: if the supplied node is not a Routine.

Definition at line 99 of file create_nemo_invoke_schedule_trans.py.

99  def validate(self, node, options=None):
100  '''
101  Check that the supplied node is a valid target for this transformation.
102 
103  :param node: the target of the transformation.
104  :type node: :py:class:`psyclone.psyir.nodes.Node`
105  :param options: a dictionary with options for \
106  transformations. No options are used in this \
107  transformation. This is an optional argument that defaults \
108  to None.
109  :type options: Optional[Dict[str, Any]]
110 
111  :raises TransformationError: if the supplied node is not a Routine.
112 
113  '''
114  super(CreateNemoInvokeScheduleTrans, self).validate(node,
115  options=options)
116 
117  if not isinstance(node, Routine):
118  raise TransformationError(
119  f"Error in NemoInvokeTrans transformation. The supplied node "
120  f"should be a PSyIR Routine but found '{type(node).__name__}'")
121 
Here is the caller graph for this function:

The documentation for this class was generated from the following file: