Directive and clause it applies to
The omp simd directive should have lastprivate behavior by default.
Specification details
The 5.2 spec says under 5.1.1
The loop iteration variables in the associated loops of a simd construct with multiple associated loops are lastprivate.
...
The loop iteration variables in any associated loop of a loop-associates construct is otherwise private.
The OpenMP 6.0 spec says under 7.1.1
The loop-iteration variable in any affected loop of a loop or simd construct is lastprivate.
Pseudocode
The test could be an example similar to this one:
program foo
implicit none
integer(kind=4) :: i, j, me1, me2
me1 = 1
me2 = 1
i = me1
j = 42 !...dummy flag to test IV after loop exit
!$omp simd
do j=i+1, me2
me1 = me1+1
enddo
print *, 'me1 ', me1
print *, 'IV j should be 2, is: ', j
end program foo
Ideally the test should cover loops with both positive and non-positive trip count.
Any other comments
Related discussions:
Directive and clause it applies to
The
omp simddirective should havelastprivatebehavior by default.Specification details
The 5.2 spec says under 5.1.1
The OpenMP 6.0 spec says under 7.1.1
Pseudocode
The test could be an example similar to this one:
Ideally the test should cover loops with both positive and non-positive trip count.
Any other comments
Related discussions:
simdconstruct incorrectly treated asprivateinstead oflastprivatellvm/llvm-project#170784