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

Public Member Functions

def __init__ (self, default_present=True)
 
def __str__ (self)
 
def validate (self, node_list, options=None)
 
def apply (self, target_nodes, options=None)
 
- Public Member Functions inherited from psyclone.transformations.ParallelRegionTrans
def __init__ (self)
 
- 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
 
- Static Public Attributes inherited from psyclone.transformations.ParallelRegionTrans
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

Create an OpenACC parallel region by inserting an 'acc parallel'
directive.

>>> from psyclone.psyGen import TransInfo
>>> from psyclone.psyir.frontend.fortran import FortranReader
>>> from psyclone.psyir.backend.fortran import FortranWriter
>>> from psyclone.psyir.nodes import Loop
>>> psyir = FortranReader().psyir_from_source("""
... program do_loop
...     real, dimension(10) :: A
...     integer i
...     do i = 1, 10
...       A(i) = i
...     end do
... end program do_loop
... """)
>>> ptrans = TransInfo().get_trans_name('ACCParallelTrans')
>>>
>>> # Enclose the loop within a OpenACC PARALLEL region
>>> ptrans.apply(psyir.walk(Loop))
>>> print(FortranWriter()(psyir))
program do_loop
  real, dimension(10) :: a
  integer :: i
<BLANKLINE>
  !$acc parallel default(present)
  do i = 1, 10, 1
    a(i) = i
  enddo
  !$acc end parallel
<BLANKLINE>
end program do_loop
<BLANKLINE>

Definition at line 1545 of file transformations.py.

Member Function Documentation

◆ apply()

def psyclone.transformations.ACCParallelTrans.apply (   self,
  target_nodes,
  options = None 
)
Encapsulate given nodes with the ACCParallelDirective.

:param target_nodes: a single Node or a list of Nodes.
:type target_nodes: :py:class:`psyclone.psyir.nodes.Node` |
    List[: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.
:param bool options["default_present"]: this flag controls if the
    inserted directive should include the default_present clause.

Reimplemented from psyclone.transformations.ParallelRegionTrans.

Definition at line 1622 of file transformations.py.

1622  def apply(self, target_nodes, options=None):
1623  '''
1624  Encapsulate given nodes with the ACCParallelDirective.
1625 
1626  :param target_nodes: a single Node or a list of Nodes.
1627  :type target_nodes: :py:class:`psyclone.psyir.nodes.Node` |
1628  List[:py:class:`psyclone.psyir.nodes.Node`]
1629  :param options: a dictionary with options for transformations.
1630  :type options: Optional[Dict[str, Any]]
1631  :param bool options["node-type-check"]: this flag controls if the
1632  type of the nodes enclosed in the region should be tested to
1633  avoid using unsupported nodes inside a region.
1634  :param bool options["default_present"]: this flag controls if the
1635  inserted directive should include the default_present clause.
1636 
1637  '''
1638  if not options:
1639  options = {}
1640  # Check whether we've been passed a list of nodes or just a
1641  # single node. If the latter then we create ourselves a
1642  # list containing just that node.
1643  node_list = self.get_node_list(target_nodes)
1644  self.validate(node_list, options)
1645 
1646  # Keep a reference to the parent of the nodes that are to be
1647  # enclosed within a parallel region. Also keep the index of
1648  # the first child to be enclosed as that will become the
1649  # position of the new !$omp parallel directive.
1650  node_parent = node_list[0].parent
1651  node_position = node_list[0].position
1652 
1653  # Create the parallel directive
1654  directive = ACCParallelDirective(
1655  children=[node.detach() for node in node_list])
1656  directive.default_present = options.get("default_present",
1657  self._default_present)
1658 
1659  # Add the region directive as a child of the parent
1660  # of the nodes being enclosed and at the original location
1661  # of the first of these nodes
1662  node_parent.addchild(directive, index=node_position)
1663 
1664 

References psyclone.psyir.nodes.acc_directives.ACCParallelDirective._default_present, psyclone.psyir.nodes.acc_directives.ACCKernelsDirective._default_present, psyclone.transformations.ACCParallelTrans._default_present, 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.ACCParallelTrans.validate (   self,
  node_list,
  options = None 
)
Validate this transformation.

:param node_list: a single Node or a list of Nodes.
:type node_list: :py:class:`psyclone.psyir.nodes.Node` |
    List[: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.
:param bool options["default_present"]: this flag controls if the
    inserted directive should include the default_present clause.

Reimplemented from psyclone.transformations.ParallelRegionTrans.

Definition at line 1598 of file transformations.py.

1598  def validate(self, node_list, options=None):
1599  '''
1600  Validate this transformation.
1601 
1602  :param node_list: a single Node or a list of Nodes.
1603  :type node_list: :py:class:`psyclone.psyir.nodes.Node` |
1604  List[:py:class:`psyclone.psyir.nodes.Node`]
1605  :param options: a dictionary with options for transformations.
1606  :type options: Optional[Dict[str, Any]]
1607  :param bool options["node-type-check"]: this flag controls if the
1608  type of the nodes enclosed in the region should be tested to
1609  avoid using unsupported nodes inside a region.
1610  :param bool options["default_present"]: this flag controls if the
1611  inserted directive should include the default_present clause.
1612 
1613  '''
1614  super().validate(node_list, options)
1615  if options is not None and "default_present" in options:
1616  if not isinstance(options["default_present"], bool):
1617  raise TransformationError(
1618  f"The provided 'default_present' option must be a "
1619  f"boolean, but found '{options['default_present']}'."
1620  )
1621 
Here is the caller graph for this function:

Member Data Documentation

◆ excluded_node_types

tuple psyclone.transformations.ACCParallelTrans.excluded_node_types
static
Initial value:
= (CodeBlock, Return, PSyDataNode,
ACCDataDirective, ACCEnterDataDirective,
psyGen.HaloExchange)

Definition at line 1582 of file transformations.py.


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