Reference Guide  2.5.0
psyclone.transformations.ParallelRegionTrans Class Reference
Inheritance diagram for psyclone.transformations.ParallelRegionTrans:
Collaboration diagram for psyclone.transformations.ParallelRegionTrans:

Public Member Functions

def __init__ (self)
 
def __str__ (self)
 
def validate (self, node_list, options=None)
 
def apply (self, target_nodes, options=None)
 
- Public Member Functions inherited from psyclone.psyir.transformations.region_trans.RegionTrans
def get_node_list (self, nodes)
 
- Public Member Functions inherited from psyclone.psyGen.Transformation
def name (self)
 

Static Public Attributes

tuple excluded_node_types = (CodeBlock, Return, psyGen.HaloExchange)
 
- Static Public Attributes inherited from psyclone.psyir.transformations.region_trans.RegionTrans
tuple excluded_node_types = ()
 

Detailed Description

Base class for transformations that create a parallel region.

Definition at line 1181 of file transformations.py.

Member Function Documentation

◆ apply()

def psyclone.transformations.ParallelRegionTrans.apply (   self,
  target_nodes,
  options = None 
)
Apply this transformation to a subset of the nodes within a
schedule - i.e. enclose the specified Loops in the
schedule within a single parallel region.

:param target_nodes: a single Node or a list of Nodes.
:type target_nodes: (list of) :py:class:`psyclone.psyir.nodes.Node`
:param options: a dictionary with options for transformations.
:type options: Optional[Dict[str, Any]]
:param bool options["node-type-check"]: this flag controls if the \
        type of the nodes enclosed in the region should be tested \
        to avoid using unsupported nodes inside a region.

Reimplemented from psyclone.psyGen.Transformation.

Reimplemented in psyclone.transformations.ACCParallelTrans, and psyclone.transformations.OMPSingleTrans.

Definition at line 1234 of file transformations.py.

1234  def apply(self, target_nodes, options=None):
1235  # pylint: disable=arguments-renamed
1236  '''
1237  Apply this transformation to a subset of the nodes within a
1238  schedule - i.e. enclose the specified Loops in the
1239  schedule within a single parallel region.
1240 
1241  :param target_nodes: a single Node or a list of Nodes.
1242  :type target_nodes: (list of) :py:class:`psyclone.psyir.nodes.Node`
1243  :param options: a dictionary with options for transformations.
1244  :type options: Optional[Dict[str, Any]]
1245  :param bool options["node-type-check"]: this flag controls if the \
1246  type of the nodes enclosed in the region should be tested \
1247  to avoid using unsupported nodes inside a region.
1248 
1249  '''
1250 
1251  # Check whether we've been passed a list of nodes or just a
1252  # single node. If the latter then we create ourselves a
1253  # list containing just that node.
1254  node_list = self.get_node_list(target_nodes)
1255  self.validate(node_list, options)
1256 
1257  # Keep a reference to the parent of the nodes that are to be
1258  # enclosed within a parallel region. Also keep the index of
1259  # the first child to be enclosed as that will become the
1260  # position of the new !$omp parallel directive.
1261  node_parent = node_list[0].parent
1262  node_position = node_list[0].position
1263 
1264  # Create the parallel directive as a child of the
1265  # parent of the nodes being enclosed and with those nodes
1266  # as its children.
1267  # pylint: disable=not-callable
1268  directive = self._directive_factory(
1269  children=[node.detach() for node in node_list])
1270 
1271  # Add the region directive as a child of the parent
1272  # of the nodes being enclosed and at the original location
1273  # of the first of these nodes
1274  node_parent.addchild(directive, index=node_position)
1275 
1276 

References psyclone.transformations.ParallelRegionTrans._directive_factory, psyclone.transformations.OMPSingleTrans._directive_factory, psyclone.transformations.OMPMasterTrans._directive_factory, psyclone.transformations.OMPParallelTrans._directive_factory, psyclone.psyir.transformations.region_trans.RegionTrans.get_node_list(), 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:

◆ validate()

def psyclone.transformations.ParallelRegionTrans.validate (   self,
  node_list,
  options = None 
)
Check that the supplied list of Nodes are eligible to be
put inside a parallel region.

:param list node_list: list of nodes to put into a parallel region
:param options: a dictionary with options for transformations.\
:type options: Optional[Dict[str, Any]]
:param bool options["node-type-check"]: this flag controls whether \
    or not the type of the nodes enclosed in the region should be \
    tested to avoid using unsupported nodes inside a region.

:raises TransformationError: if the supplied node is an \
    InvokeSchedule rather than being within an InvokeSchedule.
:raises TransformationError: if the supplied nodes are not all \
    children of the same parent (siblings).

Reimplemented from psyclone.psyir.transformations.region_trans.RegionTrans.

Reimplemented in psyclone.transformations.ACCParallelTrans, and psyclone.transformations.OMPParallelTrans.

Definition at line 1200 of file transformations.py.

1200  def validate(self, node_list, options=None):
1201  # pylint: disable=arguments-renamed
1202  '''
1203  Check that the supplied list of Nodes are eligible to be
1204  put inside a parallel region.
1205 
1206  :param list node_list: list of nodes to put into a parallel region
1207  :param options: a dictionary with options for transformations.\
1208  :type options: Optional[Dict[str, Any]]
1209  :param bool options["node-type-check"]: this flag controls whether \
1210  or not the type of the nodes enclosed in the region should be \
1211  tested to avoid using unsupported nodes inside a region.
1212 
1213  :raises TransformationError: if the supplied node is an \
1214  InvokeSchedule rather than being within an InvokeSchedule.
1215  :raises TransformationError: if the supplied nodes are not all \
1216  children of the same parent (siblings).
1217 
1218  '''
1219  if isinstance(node_list[0], InvokeSchedule):
1220  raise TransformationError(
1221  f"A {self.name} transformation cannot be applied to an "
1222  f"InvokeSchedule but only to one or more nodes from within an "
1223  f"InvokeSchedule.")
1224 
1225  node_parent = node_list[0].parent
1226 
1227  for child in node_list:
1228  if child.parent is not node_parent:
1229  raise TransformationError(
1230  f"Error in {self.name} transformation: supplied nodes are "
1231  f"not children of the same parent.")
1232  super().validate(node_list, options)
1233 
Here is the caller graph for this function:

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