psyclone.psyir.transformations.acc_loop_trans#

Classes#

  • ACCLoopTrans: Adds an OpenACC loop directive to a loop. This directive must be within

class psyclone.psyir.transformations.acc_loop_trans.ACCLoopTrans[source]#

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
>>> from psyclone.psyir.transformations import ACCLoopTrans
>>> from psyclone.transformations import ACCParallelTrans
>>> api = "gocean"
>>> ast, invokeInfo = parse(GOCEAN_SOURCE_FILE, api=api)
>>> psy = PSyFactory(api).create(invokeInfo)
>>>
>>> ltrans = ACCLoopTrans()
>>> rtrans = 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)
>>>

Inheritance

Inheritance diagram of ACCLoopTrans
apply(node, options=None)[source]#

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.:

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

At code-generation time (when lowering is called), this node must be within (i.e. a child of) a PARALLEL region.

Parameters:
  • node (psyclone.psyir.nodes.Loop) – the supplied node to which we will apply the Loop transformation.

  • options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.

  • options["collapse"] (int) – number of nested loops to collapse.

  • options["independent"] (bool) – whether to add the “independent” clause to the directive (not strictly necessary within PARALLEL regions).

  • options["sequential"] (bool) – whether to add the “seq” clause to the directive.

  • options["gang"] (bool) – whether to add the “gang” clause to the directive.

  • options["vector"] (bool) – whether to add the “vector” clause to the directive.