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

Public Member Functions

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

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 OpenMP PARALLEL region by inserting directives. For
example:

>>> from psyclone.parse.algorithm import parse
>>> from psyclone.parse.utils import ParseError
>>> from psyclone.psyGen import PSyFactory
>>> from psyclone.errors import GenerationError
>>> api = "gocean1.0"
>>> ast, invokeInfo = parse(GOCEAN_SOURCE_FILE, api=api)
>>> psy = PSyFactory(api).create(invokeInfo)
>>>
>>> from psyclone.psyGen import TransInfo
>>> t = TransInfo()
>>> ltrans = t.get_trans_name('GOceanOMPLoopTrans')
>>> rtrans = t.get_trans_name('OMPParallelTrans')
>>>
>>> schedule = psy.invokes.get('invoke_0').schedule
>>> # Uncomment the following line to see a text view of the schedule
>>> # print(schedule.view())
>>>
>>> # Apply the OpenMP Loop transformation to *every* loop
>>> # in the schedule
>>> for child in schedule.children:
>>>     ltrans.apply(child)
>>>
>>> # Enclose all of these loops within a single OpenMP
>>> # PARALLEL region
>>> rtrans.apply(schedule.children)
>>> # Uncomment the following line to see a text view of the schedule
>>> # print(schedule.view())

Definition at line 1467 of file transformations.py.

Member Function Documentation

◆ name()

def psyclone.transformations.OMPParallelTrans.name (   self)
:returns: the name of this transformation as a string.
:rtype: str

Reimplemented from psyclone.psyGen.Transformation.

Definition at line 1514 of file transformations.py.

1514  def name(self):
1515  '''
1516  :returns: the name of this transformation as a string.
1517  :rtype: str
1518  '''
1519  return "OMPParallelTrans"
1520 
Here is the caller graph for this function:

◆ validate()

def psyclone.transformations.OMPParallelTrans.validate (   self,
  node_list,
  options = None 
)
Perform OpenMP-specific validation checks.

:param node_list: list of Nodes to put within parallel region.
:type node_list: 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.

:raises TransformationError: if the target Nodes are already within \
                             some OMP parallel region.

Reimplemented from psyclone.transformations.ParallelRegionTrans.

Definition at line 1521 of file transformations.py.

1521  def validate(self, node_list, options=None):
1522  '''
1523  Perform OpenMP-specific validation checks.
1524 
1525  :param node_list: list of Nodes to put within parallel region.
1526  :type node_list: list of :py:class:`psyclone.psyir.nodes.Node`
1527  :param options: a dictionary with options for transformations.
1528  :type options: Optional[Dict[str, Any]]
1529  :param bool options["node-type-check"]: this flag controls if the \
1530  type of the nodes enclosed in the region should be tested \
1531  to avoid using unsupported nodes inside a region.
1532 
1533  :raises TransformationError: if the target Nodes are already within \
1534  some OMP parallel region.
1535  '''
1536  if node_list[0].ancestor(OMPDirective):
1537  raise TransformationError("Error in OMPParallel transformation:" +
1538  " cannot create an OpenMP PARALLEL " +
1539  "region within another OpenMP region.")
1540 
1541  # Now call the general validation checks
1542  super().validate(node_list, options)
1543 
1544 
Here is the caller graph for this function:

Member Data Documentation

◆ excluded_node_types

tuple psyclone.transformations.OMPParallelTrans.excluded_node_types
static
Initial value:
= (CodeBlock, Return, ACCDirective,
psyGen.HaloExchange)

Definition at line 1502 of file transformations.py.


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