psyclone.psyir.transformations.omp_parallel_trans#
This module provides the OMPParallelTrans transformation.
Classes#
OMPParallelTrans: Create an OpenMP PARALLEL region by inserting directives. For
- class psyclone.psyir.transformations.omp_parallel_trans.OMPParallelTrans[source]#
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 = "gocean" >>> 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())
Inheritance

- apply(nodes, options=None, **kwargs)[source]#
Surrounds the provided node list with an OpenMP Parallel region.
- Parameters:
nodes (
list[Node]) – list of Nodes to put within parallel region.node_type_check (bool) – whether or not the type of the nodes enclosed in the region should be tested to avoid using unsupported nodes inside a region.
- property name: str#
- Returns:
the name of this transformation as a string.
- validate(nodes, options=None, **kwargs)[source]#
Perform OpenMP-specific validation checks.
- Parameters:
nodes (
list[Node]) – list of Nodes to put within parallel region.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
node_type_check (bool) – whether or not 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.