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

Public Member Functions

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

Public Attributes

 omp_nowait
 

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 SINGLE region by inserting directives. The most
likely use case for this transformation is to wrap around task-based
transformations. The parent region for this should usually also be
a OMPParallelTrans.

:param bool nowait: whether to apply a nowait clause to this \
                   transformation. The default value is False

For example:

>>> from psyclone.parse.algorithm import parse
>>> from psyclone.psyGen import PSyFactory
>>> api = "gocean1.0"
>>> ast, invokeInfo = parse(GOCEAN_SOURCE_FILE, api=api)
>>> psy = PSyFactory(api).create(invokeInfo)
>>>
>>> from psyclone.transformations import OMPParallelTrans, OMPSingleTrans
>>> singletrans = OMPSingleTrans()
>>> paralleltrans = OMPParallelTrans()
>>>
>>> schedule = psy.invokes.get('invoke_0').schedule
>>> # Uncomment the following line to see a text view of the schedule
>>> # print(schedule.view())
>>>
>>> # Enclose all of these loops within a single OpenMP
>>> # SINGLE region
>>> singletrans.apply(schedule.children)
>>> # Enclose all of these loops within a single OpenMP
>>> # PARALLEL region
>>> paralleltrans.apply(schedule.children)
>>> # Uncomment the following line to see a text view of the schedule
>>> # print(schedule.view())

Definition at line 1277 of file transformations.py.

Member Function Documentation

◆ apply()

def psyclone.transformations.OMPSingleTrans.apply (   self,
  node_list,
  options = None 
)
Apply the OMPSingleTrans transformation to the specified node in a
Schedule.

At code-generation time this node must be within (i.e. a child of)
an OpenMP PARALLEL region. Code generation happens when
:py:meth:`OMPLoopDirective.gen_code` is called, or when the PSyIR
tree is given to a backend.

If the keyword "nowait" is specified in the options, it will cause a
nowait clause to be added if it is set to True, otherwise no clause
will be added.

:param node_list: the supplied node or node list to which we will \
                  apply the OMPSingleTrans transformation
:type node_list: (a list of) :py:class:`psyclone.psyir.nodes.Node`
:param options: a list with options for transformations \
                and validation.
:type options: Optional[Dict[str, Any]]
:param bool options["nowait"]:
        indicating whether or not to use a nowait clause on this \
        single region.

Reimplemented from psyclone.transformations.ParallelRegionTrans.

Definition at line 1378 of file transformations.py.

1378  def apply(self, node_list, options=None):
1379  # pylint: disable=arguments-renamed
1380  '''Apply the OMPSingleTrans transformation to the specified node in a
1381  Schedule.
1382 
1383  At code-generation time this node must be within (i.e. a child of)
1384  an OpenMP PARALLEL region. Code generation happens when
1385  :py:meth:`OMPLoopDirective.gen_code` is called, or when the PSyIR
1386  tree is given to a backend.
1387 
1388  If the keyword "nowait" is specified in the options, it will cause a
1389  nowait clause to be added if it is set to True, otherwise no clause
1390  will be added.
1391 
1392  :param node_list: the supplied node or node list to which we will \
1393  apply the OMPSingleTrans transformation
1394  :type node_list: (a list of) :py:class:`psyclone.psyir.nodes.Node`
1395  :param options: a list with options for transformations \
1396  and validation.
1397  :type options: Optional[Dict[str, Any]]
1398  :param bool options["nowait"]:
1399  indicating whether or not to use a nowait clause on this \
1400  single region.
1401 
1402  '''
1403  if not options:
1404  options = {}
1405  if options.get("nowait") is not None:
1406  self.omp_nowait = options.get("nowait")
1407 
1408  super().apply(node_list, options)
1409 
1410 

References psyclone.transformations.OMPSingleTrans.omp_nowait.

◆ name()

def psyclone.transformations.OMPSingleTrans.name (   self)
:returns: the name of this transformation.
:rtype: str

Reimplemented from psyclone.psyGen.Transformation.

Definition at line 1337 of file transformations.py.

1337  def name(self):
1338  '''
1339  :returns: the name of this transformation.
1340  :rtype: str
1341  '''
1342  return "OMPSingleTrans"
1343 
Here is the caller graph for this function:

◆ omp_nowait() [1/2]

def psyclone.transformations.OMPSingleTrans.omp_nowait (   self)
 :returns: whether or not this Single region uses a nowait \
              clause to remove the end barrier.
    :rtype: bool

Definition at line 1329 of file transformations.py.

1329  def omp_nowait(self):
1330  ''' :returns: whether or not this Single region uses a nowait \
1331  clause to remove the end barrier.
1332  :rtype: bool
1333  '''
1334  return self._omp_nowait
1335 

References psyclone.transformations.OMPSingleTrans._omp_nowait.

Here is the caller graph for this function:

◆ omp_nowait() [2/2]

def psyclone.transformations.OMPSingleTrans.omp_nowait (   self,
  value 
)
 Sets the nowait property that will be specified by
    this transformation. Checks that the value supplied in
    :py:obj:`value` is a bool

    :param bool value: whether this Single clause should have a \
                       nowait applied.

    :raises TypeError: if the value parameter is not a bool.

Definition at line 1345 of file transformations.py.

1345  def omp_nowait(self, value):
1346  ''' Sets the nowait property that will be specified by
1347  this transformation. Checks that the value supplied in
1348  :py:obj:`value` is a bool
1349 
1350  :param bool value: whether this Single clause should have a \
1351  nowait applied.
1352 
1353  :raises TypeError: if the value parameter is not a bool.
1354 
1355  '''
1356  if not isinstance(value, bool):
1357  raise TypeError(f"Expected nowait to be a bool "
1358  f"but got a {type(value).__name__}")
1359  self._omp_nowait = value
1360 

References psyclone.transformations.OMPSingleTrans._omp_nowait, and psyclone.transformations.OMPSingleTrans.omp_nowait.

Here is the caller graph for this function:

Member Data Documentation

◆ excluded_node_types

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

Definition at line 1314 of file transformations.py.


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