Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
28 Views

Possible OpenMP SIMD compiler bug

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
Highlighted
Valued Contributor I
28 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.

0 Kudos