Reference Guide
2.5.0
|
Public Member Functions | |
def | __init__ (self, omp_directive="do", omp_schedule="auto") |
def | __str__ (self) |
def | omp_directive (self) |
def | omp_directive (self, value) |
def | omp_schedule (self) |
def | omp_schedule (self, value) |
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) |
Public Attributes | |
omp_schedule | |
omp_directive | |
Additional Inherited Members | |
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 = () |
Adds an OpenMP directive to parallelise this loop. It can insert different directives such as "omp do/for", "omp parallel do/for", "omp teams distribute parallel do/for" or "omp loop" depending on the provided parameters. The OpenMP schedule to use can also be specified, but this will be ignored in case of the "omp loop" (as the 'schedule' clause is not valid for this specific directive). The configuration-defined 'reprod' parameter also specifies whether a manual reproducible reproduction is to be used. Note, reproducible in this case means obtaining the same results with the same number of OpenMP threads, not for different numbers of OpenMP threads. :param str omp_schedule: the OpenMP schedule to use. Defaults to 'auto'. :param str omp_directive: choose which OpenMP loop directive to use. \ Defaults to "omp do" For example: >>> from psyclone.psyir.frontend.fortran import FortranReader >>> from psyclone.psyir.backend.fortran import FortranWriter >>> from psyclone.psyir.nodes import Loop >>> from psyclone.transformations import OMPLoopTrans, OMPParallelTrans >>> >>> psyir = FortranReader().psyir_from_source(""" ... subroutine my_subroutine() ... integer, dimension(10, 10) :: A ... integer :: i ... integer :: j ... do i = 1, 10 ... do j = 1, 10 ... A(i, j) = 0 ... end do ... end do ... end subroutine ... """) >>> loop = psyir.walk(Loop)[0] >>> omplooptrans1 = OMPLoopTrans(omp_schedule="dynamic", ... omp_directive="paralleldo") >>> omplooptrans1.apply(loop) >>> print(FortranWriter()(psyir)) subroutine my_subroutine() integer, dimension(10,10) :: a integer :: i integer :: j <BLANKLINE> !$omp parallel do default(shared), private(i,j), schedule(dynamic) do i = 1, 10, 1 do j = 1, 10, 1 a(i,j) = 0 enddo enddo !$omp end parallel do <BLANKLINE> end subroutine my_subroutine <BLANKLINE>
Definition at line 55 of file omp_loop_trans.py.
def psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans.apply | ( | self, | |
node, | |||
options = None |
|||
) |
Apply the OMPLoopTrans transformation to the specified PSyIR Loop. :param node: the supplied node to which we will apply the \ OMPLoopTrans transformation :type node: :py:class:`psyclone.psyir.nodes.Node` :param options: a dictionary with options for transformations\ and validation. :type options: Optional[Dict[str, Any]] :param bool options["reprod"]: indicating whether reproducible reductions should be used. \ By default the value from the config file will be used.
Reimplemented from psyclone.psyir.transformations.parallel_loop_trans.ParallelLoopTrans.
Reimplemented in psyclone.transformations.Dynamo0p3OMPLoopTrans, psyclone.transformations.GOceanOMPParallelLoopTrans, and psyclone.transformations.OMPParallelLoopTrans.
Definition at line 227 of file omp_loop_trans.py.
References psyclone.psyir.nodes.omp_directives.OMPDoDirective._reprod, and psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans._reprod.
def psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans.omp_directive | ( | self | ) |
:returns: the type of OMP directive that this transformation will \ insert. :rtype: str
Definition at line 131 of file omp_loop_trans.py.
References psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans._omp_directive.
def psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans.omp_directive | ( | self, | |
value | |||
) |
:param str value: the type of OMP directive to add. :raises TypeError: if the provided value is not a valid str.
Definition at line 140 of file omp_loop_trans.py.
References psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans._omp_directive.
def psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans.omp_schedule | ( | self | ) |
:returns: the OpenMP schedule that will be specified by \ this transformation. :rtype: str
Definition at line 154 of file omp_loop_trans.py.
References psyclone.psyir.nodes.omp_directives.OMPDoDirective._omp_schedule, and psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans._omp_schedule.
def psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans.omp_schedule | ( | self, | |
value | |||
) |
:param str value: Sets the OpenMP schedule value that will be \ specified by this transformation, unless adding an OMP Loop \ directive (in which case it is not applicable). :raises TypeError: if the provided value is not a string. :raises ValueError: if the provided string is not a valid OpenMP \ schedule format.
Definition at line 164 of file omp_loop_trans.py.
References psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans._omp_directive, psyclone.psyir.nodes.omp_directives.OMPDoDirective._omp_schedule, psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans._omp_schedule, psyclone.psyir.nodes.omp_directives.OMPDoDirective._reprod, and psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans._reprod.