Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

Possible bug in OpenMP code with shared DO-loop indices

$
0
0

Let's start by saying that I regard this as a misdesign in OpenMP.  However, both gcc and Sun/Oracle disagree with Intel ifort.  NAG regards it as a user error.  However, my reading is that it is legal, and I quote the specification later.  No, I didn't write it, but it was written as a horrible example following a debate about what OpenMP actually permits.

Program ugh
  Use omp_lib
  Real x(200)
  Integer i
  i = 42
  !$OMP PARALLEL SHARED(i) NUM_THREADS(5)
    !$OMP SINGLE
      Do i=1,Size(x)
        x(i) = 0
      End Do
    !$OMP END SINGLE
    !$OMP CRITICAL
      Print *,omp_get_thread_num(),':',i
    !$OMP END CRITICAL
  !$OMP END PARALLEL
End Program

gfortran and Sun print 201, 5 times.  Intel prints 42, 5 times.

Let's use OpenMP 3.1, as I have it to hand.

2.9.1.1 page 85, lines 21-22 "Variables with predetermined data-sharing attributes may not be listed in data-sharing attribute clauses, except for the cases listed below."

2.9.1.1 page 86, lines 3-5 "Variables used as loop iteration variables in sequential loops in a parallel or task construct may be listed in data-sharing clauses on the construct itself, and on enclosed constructs, subject to other restrictions."

A.9 page 182 Example A.9.2f.

Comments (other than "Ugh"!) gratefully accepted!


Viewing all articles
Browse latest Browse all 2746

Trending Articles