-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Closed
Closed
Copy link
Labels
Description
Version of flang : 22.0.0(5892a2beec4eaf77922211a9aec70faa0ae287db)/AArch64
Specifying FIRSTPRIVATE clause in DO SIMD construct results in a compilation error (FIRSTPRIVATE cannot be used with SIMD).
According to OpenMP 6.0: 12.4 simd Construct and OpenMP 6.0: 13.6.2 do Construct,
FIRSTPRIVATEclause cannot be specified inSIMDconstruct.FIRSTPRIVATEclause can be specified inDOconstruct.
Also, according to OpenMP 6.0: 19.2 Clauses on Compound Constructs,
!$omp do simdisCompound Constructthat combinesDOconstruct (worksharing construct) andSIMDconstruct.DOconstruct isworksharing constructandFIRSTPRIVATEclause is applied.SIMDconstruct is not aworksharing construct, soFIRSTPRIVATEclause is not applied.
So it seems likely that FIRSTPRIVATE clause can be specified in DO SIMD construct, which is Compound Construct.
Thus, the Flang compilation error messages appear to violate the OpenMP specification.
Please point out any errors in my interpretation of OpenMP.
The following are the test program, Flang, Gfortran and ifx compilation/execution results.
test01.f90:
subroutine sub
integer a
a=10
!$omp do simd lastprivate(a) firstprivate(a)
do i=1,1
if (a/=10) print *,11
a=20
end do
!$omp end do simd
if (a/=20) print *,21
end subroutine sub
program main
integer a
a=10
!$omp do simd lastprivate(a) firstprivate(a)
do i=1,1
if (a/=10) print *,11
a=20
end do
!$omp end do simd
if (a/=20) print *,21
call sub
print *,'pass'
end program main$ flang -fopenmp test01.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FJ-Compiler-Test-Suite/34/test01.f90":4:7): FIRSTPRIVATE cannot be used with SIMD
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FJ-Compiler-Test-Suite/34/test01.f90":16:7): FIRSTPRIVATE cannot be used with SIMD
error: verification of lowering to FIR failed
$
$ gfortran -fopenmp test01.f90
test01.f90:4:44:
4 | !$omp do simd lastprivate(a) firstprivate(a)
| ^
Error: firstprivate variable ‘a’ is private in outer context
test01.f90:4:44: Error: lastprivate variable ‘a’ is private in outer context
test01.f90:16:44:
16 | !$omp do simd lastprivate(a) firstprivate(a)
| ^
Error: firstprivate variable ‘a’ is private in outer context
test01.f90:16:44: Error: lastprivate variable ‘a’ is private in outer context
$
$ export OMP_NUM_THREADS=2; ifx -qopenmp test01.f90; ./a.out
pass
$
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done