-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
While working on PR #3213 I found the following example where ParallelLoopTrans incorrectly parallelises a loop:
module main_mod
implicit none
type :: Box
integer :: arr(10)
end type
contains
subroutine main()
type(Box) :: b
integer :: i
do i = 1, size(b%arr)
b%arr(i) = i
call modify(b)
end do
end subroutine
pure subroutine modify(b)
type(Box), intent(inout) :: b
b%arr(1) = 0
end subroutine
end moduleHere is a small script to demonstrate the issue:
from psyclone.psyir.transformations import OMPLoopTrans, TransformationError
from psyclone.psyir.nodes import Loop, Routine
def trans(psyir):
for loop in psyir.walk(Loop):
OMPLoopTrans(omp_directive="paralleldo").apply(loop)Note that DependencyTools actually reports a SCALAR_WRITTEN_ONCE dependency but ParallelLoopTrans explicitly ignores it (for reasons I don't understand). Still, as DependencyTools explores scalar conflicts and array conflicts independently, it never considers the write to b and the write to b%arr(i) to be conflicting, which feels wrong.
@hiker may be interested in this.
Metadata
Metadata
Assignees
Labels
No labels