Skip to content

[flang][OpenMP] NOWAIT on target parallel do rejected before OpenMP 6.0 #241780

Open

Description

@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:

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, 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). OpenMP 4.5 section 2.11.6 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 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: "If the nowait clause is present, execution of the target task may be deferred."). OpenMP 5.2 section 17.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, and OpenMP 5.0 section 2.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 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.

Activity

  1. self-assigned this
    on Nov 12, 2026
  2. added and removed
    flangFlang issues not falling into any other category
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions