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

            Bug ID: 109013
           Summary: [OpenMP] Diagnose if multiple 'omp ordered' appear in
                    a loop body
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: diagnostic, openmp
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

The following code is accepted – while clang errors with:

test.c:18:5: error: exactly one 'ordered' directive must appear in the loop
body of an enclosing directive

Cf. "Additional restrictions to the block-associated ordered construct are as
follows:"
...
"During execution of the logical iteration of a loop-associated construct, a
thread must not execute more than one block-associated ordered region that
binds to the corresponding region of the loop-associated construct."



int a[10];

void foo(int n)
{
#if 0
  #pragma omp for ordered schedule(static)
  #pragma omp unroll partial(2)
  for(int i = 1; i < n; i++) {
    #pragma omp ordered
       a[i] += a[i-1];
  }
  // ->
#endif
  #pragma omp for ordered schedule(static)
  for(int i = 1; i < n; i += 2) {
    #pragma omp ordered
       a[i] += a[i-1];
    #pragma omp ordered
       a[i+1] += a[i];
  }
}

Reply via email to