Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Possible OpenMP SIMD compiler bug

John_D_12
Beginner
111 Views

We encountered a possible problem with OpenMP SIMD vectorization.

 

Here is the simplest piece of code which generates the error:
 

program test
implicit none
integer, parameter :: n=4
integer i,j,k,iv(2)
real(8) a(n*n)

a(:)=0.d0

do j=1,n
  k=(j-1)*n
!$OMP SIMD PRIVATE(iv)
  do i=1,n
    k=k+1
    a(k)=1
    iv(:)=1
  end do
end do

print *,a

end program

 

The program should fill the matrix a with ones. Instead the variable k is corrupted by the assignment iv(:)=1 even though iv is not used.

If iv has dimension 1 then the problem disappears. Removing the PRIVATE clause also fixes the problem.

 

(Do I understand correctly that any variable not declared as PRIVATE in a SIMD loop is automatically shared and updated atomically? In other words, does the OpenMP SIMD standard ensure that the variable k is incremented correctly?)

 

The problem occurs with Intel Fortran versions 17 and 18. GNU Fortran version 8.2.1 works fine.

 

0 Kudos
1 Reply
Juergen_R_R
Valued Contributor I
111 Views

I do see the same output (including many zeros) also with ifort 19, even without the -qopenmp flag. Also, nagfor shows the same problem.

Reply