https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113840

            Bug ID: 113840
           Summary: [OpenACC] !$acc loop seq – bogus rejection of
                    Fortran's EXIT/CYCLE + C/C++ break/continue
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: openacc, rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: tschwinge at gcc dot gnu.org
  Target Milestone: ---

OpenACC seems to permit EXIT and CYCLE in "!$ACC LOOP" if there is the SEQ
clause.

The following quote is from OpenACC 3.2 but it can be also found in 2.5 a bit
less explicit and between the lines also for 1.0 and 2.0:

"2.9 Loop Construct" → "Restrictions"

"A loop associated with a loop construct that does not have a seq clause must
be written to
meet all of the following conditions:1931
– The loop variable must be of integer, C/C++ pointer, or C++ random-access
iterator type.
– The loop variable must monotonically increase or decrease in the direction of
its termination condition.
– The loop trip count must be computable in constant time when entering the
loop construct."

Currently, it fails with:

test.f90:4:6:

    4 |   EXIT
      |      1
Error: EXIT statement at (1) terminating !$ACC LOOP loop

or

test.c:5:7: error: break statement used with OpenMP for loop
    5 |       break;
      |       ^~~~~

 * * *

Testcases:
----------------------------
!$acc parallel
!$acc loop seq
do i=1, 5
  EXIT
end do
!$acc end parallel
end
----------------------------

----------------------------
void f() {
 #pragma acc parallel
  #pragma acc loop seq
    for (int i=1; i < 5; i++)
      break;
}
----------------------------

 * * *

It seems as if the loop conditions are also relaxed, which needs to be handled
/ supported. (Not folding to OMP_FOR internally – or still? If not: at least
PRIVATE needs to be handled and the SEQ be honored.)

 * * *

Real-world testcase:

https://gitlab.dkrz.de/icon/icon-model/-/blob/release-2024.01-public/src/diagnostics/mo_tropopause.f90?ref_type=heads#L200-L213

Reply via email to