-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
Labels
Description
Version of flang : 22.0.0(63fe60f830ec00cb44fb7354291a74ddc1a7c513)/AArch64
In the attached program (test011.f90), FIRSTPRIVATE clause and LASTPRIVATE clause are specified within DO SIMD construct, and the same variable (a) is specified in both clauses.
When checking the variable's value, LASTPRIVATE clause appears to be active, but FIRSTPRIVATE clause seems inactive.
The values for main1 : a = and sub1 : a = are expected to output 10.
The result is correct in the following cases:
- Change
DO SIMD constructtoDO construct, or - Specify only
FIRSTPRIVATE clause(removeLASTPRIVATE clause)
This issue relates to the closed #155195.
The compilation error in the above issue #155195 has been fixed. However, since the current execution result is incorrect, I issue this new issue.
The following are the test program, Flang, Gfortran and ifx compilation/execution results.
test011.f90:
subroutine sub
integer a
a=10
!$omp do simd lastprivate(a) firstprivate(a)
do i=1,1
write(6,*) "sub1 : a = ", a
a=20
end do
!$omp end do simd
write(6,*) "sub2 : a = ", a
end subroutine sub
program main
integer a
a=10
!$omp do simd lastprivate(a) firstprivate(a)
do i=1,1
write(6,*) "main1 : a = ", a
a=20
end do
!$omp end do simd
write(6,*) "main2 : a = ", a
call sub
print *,'pass'
end program main$ export OMP_NUM_THREADS=2; flang -fopenmp test011.f90; ./a.out
main1 : a = 0
main2 : a = 20
sub1 : a = -45698304
sub2 : a = 20
pass
$
$ gfortran -fopenmp test011.f90
test011.f90:4:44:
4 | !$omp do simd lastprivate(a) firstprivate(a)
| ^
Error: firstprivate variable ‘a’ is private in outer context
test011.f90:4:44: Error: lastprivate variable ‘a’ is private in outer context
test011.f90:16:44:
16 | !$omp do simd lastprivate(a) firstprivate(a)
| ^
Error: firstprivate variable ‘a’ is private in outer context
test011.f90:16:44: Error: lastprivate variable ‘a’ is private in outer context
$
$ export OMP_NUM_THREADS=2; ifx -qopenmp test011.f90; ./a.out
main1 : a = 10
main2 : a = 20
sub1 : a = 10
sub2 : a = 20
$
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done