Reference Guide  2.5.0
psyclone.domain.nemo.transformations.create_nemo_psy_trans.CreateNemoPSyTrans Class Reference
Inheritance diagram for psyclone.domain.nemo.transformations.create_nemo_psy_trans.CreateNemoPSyTrans:
Collaboration diagram for psyclone.domain.nemo.transformations.create_nemo_psy_trans.CreateNemoPSyTrans:

Public Member Functions

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

Detailed Description

Transform generic (language-level) PSyIR representation into a PSyclone
version with specialised, NEMO-specific nodes. For example:

>>> from psyclone.psyir.frontend.fortran import FortranReader
>>> from psyclone.psyir.nodes import Loop
>>> from psyclone.domain.nemo.transformations import CreateNemoPSyTrans
>>> code = '''
... subroutine sub()
...   integer :: ji, tmp(10)
...   do ji=1, 10
...     tmp(ji) = 2*ji
...   end do
... end subroutine sub'''
>>> psyir = FortranReader().psyir_from_source(code)
>>> loop = psyir.walk(Loop)[0]
>>> trans = CreateNemoPSyTrans()
>>> trans.apply(psyir)
>>> print(psyir.view(colour=False, indent="   "))
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', Scalar<INTEGER, UNDEFINED>]
                  Reference[name:'ji']
<BLANKLINE>

The result of this transformation is that the root `Routine` has
been converted into a `NemoInvokeSchedule`.

Definition at line 49 of file create_nemo_psy_trans.py.

Member Function Documentation

◆ apply()

def psyclone.domain.nemo.transformations.create_nemo_psy_trans.CreateNemoPSyTrans.apply (   self,
  psyir,
  options = None 
)
Takes generic PSyIR and replaces recognised structures with
NEMO-specific PSyIR (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 psyir: the root node of the PSyIR tree to process.
:type psyir: :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]]

Definition at line 122 of file create_nemo_psy_trans.py.

122  def apply(self, psyir, options=None):
123  '''
124  Takes generic PSyIR and replaces recognised structures with
125  NEMO-specific PSyIR (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 psyir: the root node of the PSyIR tree to process.
130  :type psyir: :py:class:`psyclone.psyir.nodes.Node`
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(psyir, options=options)
139 
140  invoke_trans = CreateNemoInvokeScheduleTrans()
141 
142  # Transform any Routines into NemoInvokeSchedules.
143  for routine in psyir.walk(Routine):
144  invoke_trans.apply(routine)
145 
146 
147 # 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_psy_trans.CreateNemoPSyTrans.name (   self)
:returns: the name of the transformation.
:rtype: str

TODO #1214 remove this method.

Definition at line 89 of file create_nemo_psy_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_psy_trans.CreateNemoPSyTrans.validate (   self,
  node,
  options = None 
)
Check that the supplied node is a valid target for this transformation.

:param node: the root of the PSyIR tree to be transformed.
: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 PSyIR node.

Definition at line 99 of file create_nemo_psy_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 root of the PSyIR tree to be transformed.
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 PSyIR node.
112 
113  '''
114  if not isinstance(node, Node):
115  raise TransformationError(
116  f"Error in CreateNemoPSyTrans transformation. The supplied "
117  f"node should be a PSyIR Node but found "
118  f"'{type(node).__name__}'")
119 
120  super(CreateNemoPSyTrans, self).validate(node, options=options)
121 
Here is the caller graph for this function:

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