Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28507 Discussions

do concurrent: Bug in code or in compiler?



I've started to substitute "forall" statements with "do concurrent" loops and found an unexpected behavior when compiling with -Ox, x>1 and openMP and autoparallelization, i.e.

 ifort test.f90 -O2  -parallel -qopenmp

for the Intel compiler in versions 18.0.1 and 18.0.3. I seems like that the "do concurrent" loop is not executed at all. Is my code invalid or does the compiler makes a mistake when doing the optimization?

program test
  implicit none
  real, dimension(4) :: c
  c = [1.0,2.0,5.0,3.3]
  write(6,*) math_qToR(c)
  write(6,*) math_qToR2(c)


function math_qToR(q)
 implicit none
 real, dimension(4), intent(in) :: q
 real, dimension(3,3) :: math_qToR
 integer :: i, j

 forall (i = 1:3, j = 1:3)
   math_qToR(i,j) = q(i+1) * q(j+1)
 end forall

end function math_qToR

function math_qToR2(q)
 implicit none
 real, dimension(4), intent(in) :: q
 real, dimension(3,3) :: math_qToR2
 integer :: i, j
 do concurrent (i = 1:3, j = 1:3)
   !write(6,*) i,j ! cures the behavior
   math_qToR2(i,j) = q(i+1) * q(j+1)

end function math_qToR2

end program


0 Kudos
0 Replies