psyclone.psyir.transformations.omp_parallel_loop_trans#

Classes#

class psyclone.psyir.transformations.omp_parallel_loop_trans.OMPParallelLoopTrans(omp_directive='do', omp_schedule='auto')[source]#

Adds an OpenMP PARALLEL DO directive to a loop. For example:

>>> from psyclone.psyir.frontend.fortran import FortranReader
>>> from psyclone.psyir.backend.fortran import FortranWriter
>>> psyir = FortranReader().psyir_from_source("""
... program do_loop
...     real, dimension(10) :: A
...     integer i
...     do i = 1, 10
...       A(i) = i
...     end do
... end program do_loop
... """)
>>> from psyclone.psyir.nodes import Loop
>>> from psyclone.transformations import OMPParallelLoopTrans
>>> trans = OMPParallelLoopTrans()
>>> trans.apply(psyir.walk(Loop)[0])
>>> print(FortranWriter()(psyir))
program do_loop
  real, dimension(10) :: a
  integer :: i

  !$omp parallel do default(shared) private(i) schedule(auto)
  do i = 1, 10, 1
    a(i) = i
  enddo
  !$omp end parallel do

end program do_loop

Inheritance

Inheritance diagram of OMPParallelLoopTrans
apply(node, force_private=(), options=None, **kwargs)[source]#

Apply an OMPParallelLoop Transformation to the supplied node (which must be a Loop). In the generated code this corresponds to wrapping the Loop with directives:

!$OMP PARALLEL DO ...
do ...
  ...
end do
!$OMP END PARALLEL DO
Parameters:
  • node (psyclone.psyir.nodes.Loop) – the node (loop) to which to apply the transformation.

  • force_private (Iterable[str]) – specify a list of symbol names explicitly requested to be private.

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