| Issue |
241780
|
| Summary |
[flang][OpenMP] NOWAIT on target parallel do rejected before OpenMP 6.0
|
| Labels |
flang
|
| Assignees |
|
| Reporter |
Saieiei
|
Since #229527, Flang rejects NOWAIT on the begin directive of target compound directives that contain PARALLEL DO or PARALLEL LOOP, at every OpenMP version before 6.0, the default one included:
```fortran
subroutine f(a, n)
integer :: n, i
real :: a(n)
!$omp target teams distribute parallel do nowait
do i = 1, n
a(i) = a(i) + 1.0
end do
end subroutine
```
```
$ flang -fopenmp -fsyntax-only t.f90
error: Semantic errors in t.f90
t.f90:4:9: error: This compound directive does not allow NOWAIT clause
!$omp target teams distribute parallel do nowait
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
t.f90:4:45: The clause is specified here
!$omp target teams distribute parallel do nowait
^^^^^^
```
`-fopenmp-version=52` gives the same error, and so do target parallel do, target parallel do simd, target parallel loop and target teams distribute parallel do simd. Flang accepted all five before #229527. gfortran 15.2, ifx 2023.0.0 and nvfortran 22.5 accept all five, Clang accepts `target parallel for nowait` in C, and the OpenMP Examples use the form above in [async_target.3.f90](https://github.com/OpenMP/Examples/blob/c9c948358f345ec9597879b86345f1085ec7fba5/devices/sources/async_target.3.f90), which is marked for 5.1 and expected to compile.
The #229527 review read OpenMP 4.5 as carrying the parallel do restriction over to target parallel do ([comment](https://github.com/llvm/llvm-project/pull/229527#discussion_r4377195286)). [OpenMP 4.5 section 2.11.6](https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf#page=140) gives target parallel do "any of the clauses accepted by the target or parallel do directives, except for copyin, with identical meanings and restrictions", and [OpenMP 4.5 section 2.11.1](https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf#page=133) says "nowait may not be specified on an end parallel do directive". That restriction names the end parallel do directive, which target parallel do does not have, and NOWAIT is a clause of target itself ([OpenMP 5.0 section 2.12.5](https://www.openmp.org/spec-html/5.0/openmpsu60.html#x86-2820002.12.5): "If the nowait clause is present, execution of the target task may be deferred."). [OpenMP 5.2 section 17.2](https://www.openmp.org/spec-html/5.2/openmpse102.html#x259-27200017.2) also says "The effect of the nowait clause is as if it is applied to the outermost leaf construct that permits it", as does [OpenMP 5.1 section 2.17](https://www.openmp.org/spec-html/5.1/openmpse25.html#x129-1390002.17), and [OpenMP 5.0 section 2.14](https://www.openmp.org/spec-html/5.0/openmpse22.html#x116-4340002.14) says the same of the outermost constituent construct.
Should these five directives accept NOWAIT on the begin directive before 6.0? If so, I have a small fix in CheckCompoundDirective. Before 6.0, TARGET is the only leaf in front of PARALLEL in these directives that permits NOWAIT, so the fix looks for a TARGET leaf. It keeps NOWAIT on the end directive rejected before 5.2 ([OpenMP 5.1 section 2.16.19](https://www.openmp.org/spec-html/5.1/openmpsu91.html#x121-1310002.16.19) says so for target parallel loop, and the other end directives take no clauses before 5.2) and leaves the other compound directives as they are.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs