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

Public Member Functions

def __init__ (self)
 
def __str__ (self)
 
def apply (self, node, options=None)
 
- Public Member Functions inherited from psyclone.psyir.transformations.parallel_loop_trans.ParallelLoopTrans
def validate (self, node, options=None)
 
- Public Member Functions inherited from psyclone.psyir.transformations.loop_trans.LoopTrans
def name (self)
 

Static Public Attributes

tuple excluded_node_types = (PSyDataNode,)
 
- Static Public Attributes inherited from psyclone.psyir.transformations.parallel_loop_trans.ParallelLoopTrans
tuple excluded_node_types = (nodes.Return, psyGen.HaloExchange, nodes.CodeBlock)
 
- Static Public Attributes inherited from psyclone.psyir.transformations.loop_trans.LoopTrans
tuple excluded_node_types = ()
 

Detailed Description

Adds an OpenACC loop directive to a loop. This directive must be within
the scope of some OpenACC Parallel region (at code-generation time).

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('ACCLoopTrans')
>>> rtrans = t.get_trans_name('ACCParallelTrans')
>>>
>>> schedule = psy.invokes.get('invoke_0').schedule
>>> # Uncomment the following line to see a text view of the schedule
>>> # print(schedule.view())
>>>
>>> # Apply the OpenACC Loop transformation to *every* loop in the schedule
>>> for child in schedule.children[:]:
...     ltrans.apply(child)
>>>
>>> # Enclose all of these loops within a single OpenACC parallel region
>>> rtrans.apply(schedule)
>>>

Definition at line 567 of file transformations.py.

Member Function Documentation

◆ apply()

def psyclone.transformations.ACCLoopTrans.apply (   self,
  node,
  options = None 
)
Apply the ACCLoop transformation to the specified node. This node
must be a Loop since this transformation corresponds to
inserting a directive immediately before a loop, e.g.:

.. code-block:: fortran

  !$ACC LOOP
  do ...
     ...
  end do

At code-generation time (when
:py:meth:`psyclone.psyir.nodes.ACCLoopDirective.gen_code` is called),
this node must be within (i.e. a child of) a PARALLEL region.

:param node: the supplied node to which we will apply the
             Loop transformation.
:type node: :py:class:`psyclone.psyir.nodes.Loop`
:param options: a dictionary with options for transformations.
:type options: Optional[Dict[str, Any]]
:param int options["collapse"]: number of nested loops to collapse.
:param bool options["independent"]: whether to add the "independent"
        clause to the directive (not strictly necessary within
        PARALLEL regions).
:param bool options["sequential"]: whether to add the "seq" clause to
        the directive.
:param bool options["gang"]: whether to add the "gang" clause to the
        directive.
:param bool options["vector"]: whether to add the "vector" clause to
        the directive.

Reimplemented from psyclone.psyir.transformations.parallel_loop_trans.ParallelLoopTrans.

Definition at line 634 of file transformations.py.

634  def apply(self, node, options=None):
635  '''
636  Apply the ACCLoop transformation to the specified node. This node
637  must be a Loop since this transformation corresponds to
638  inserting a directive immediately before a loop, e.g.:
639 
640  .. code-block:: fortran
641 
642  !$ACC LOOP
643  do ...
644  ...
645  end do
646 
647  At code-generation time (when
648  :py:meth:`psyclone.psyir.nodes.ACCLoopDirective.gen_code` is called),
649  this node must be within (i.e. a child of) a PARALLEL region.
650 
651  :param node: the supplied node to which we will apply the
652  Loop transformation.
653  :type node: :py:class:`psyclone.psyir.nodes.Loop`
654  :param options: a dictionary with options for transformations.
655  :type options: Optional[Dict[str, Any]]
656  :param int options["collapse"]: number of nested loops to collapse.
657  :param bool options["independent"]: whether to add the "independent"
658  clause to the directive (not strictly necessary within
659  PARALLEL regions).
660  :param bool options["sequential"]: whether to add the "seq" clause to
661  the directive.
662  :param bool options["gang"]: whether to add the "gang" clause to the
663  directive.
664  :param bool options["vector"]: whether to add the "vector" clause to
665  the directive.
666 
667  '''
668  # Store sub-class specific options. These are used when
669  # creating the directive (in the _directive() method).
670  if not options:
671  options = {}
672  self._independent = options.get("independent", True)
673  self._sequential = options.get("sequential", False)
674  self._gang = options.get("gang", False)
675  self._vector = options.get("vector", False)
676 
677  # Call the apply() method of the base class
678  super().apply(node, options)
679 
680 

References psyclone.psyir.nodes.acc_directives.ACCLoopDirective._gang, psyclone.transformations.ACCLoopTrans._gang, psyclone.psyir.nodes.acc_directives.ACCLoopDirective._independent, psyclone.transformations.ACCLoopTrans._independent, psyclone.psyir.nodes.acc_directives.ACCLoopDirective._sequential, psyclone.transformations.ACCLoopTrans._sequential, psyclone.psyir.nodes.acc_directives.ACCLoopDirective._vector, and psyclone.transformations.ACCLoopTrans._vector.


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