We've been adding lots of OpenMP SIMD instructions to our electronic structure code (http://elk.sourceforge.net/) and successfully sped it up.
But we've also encountered a few potential compiler bugs along the the way. The first was reported here: https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux...
I think there may be another. Here is the simplest code which still has the problem:
program test use modbug implicit none integer i complex(8) z1 complex(8), allocatable :: x(:),y(:) complex(8) zf external zf n=10 allocate(r(n)) allocate(x(n),y(n)) r(:)=1 x(:)=1 y(:)=1 z1=zf(x,y) print *,z1 end program complex(8) function zf(x,y) use modbug implicit none complex(8), intent(in) :: x(n) complex(8), intent(in) :: y(n) ! local variables integer i zf=0.d0 !$OMP SIMD do i=1,n zf=zf+r(i)*conjg(x(i))*y(i) end do return end function
A module in a separate file is also needed:
module modbug integer n real(8), allocatable :: r(:) end module
The code is compiled with
ifort -O3 -ip -axCORE-AVX2,AVX,SSE4.2 -qopenmp modbug.f90 test.f90
on our Intel Xeon E5-2680 cluster with Intel Fortran 18.0.0.
The correct output should be 10.0, but with the SIMD directive the code returns 5.0 instead.
If the module file is included in the same file as the code then the compiler reports:
test.f90(35): warning #15552: loop was not vectorized with "simd"
and the code works fine.