Compiler Bug ?

Compiler Bug ?


Have compiled the following program once as debug version (OK) and once as a Release Version (faulty) and get different results for the two dot products computed. Should give the same results.

Compiling with Intel(R) Visual Fortran Compiler XE [Intel(R) 64]...

ifort /nologo /Os /module:"x64\Release\\" /object:"x64\Release\\" /Fd"x64\Release\vc100.pdb" /libs:static /threads /c /Qvc10 /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\\bin\amd64" "D:\Work\test_speed\problem_destilled.f90"
Link /OUT:"x64\Release\test_speed.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"D:\Work\test_speed\test_speed\x64\Release\test_speed.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /SUBSYSTEM:CONSOLE /IMPLIB:"D:\Work\test_speed\test_speed\x64\Release\test_speed.lib" "x64\Release\problem_destilled.obj"
Link: executing 'link'

Embedding manifest...
mt.exe /nologo /outputresource:"D:\Work\test_speed\test_speed\x64\Release\test_speed.exe;#1" /manifest "D:\Work\test_speed\test_speed\x64\Release\test_speed.exe.intermediate.manifest"


program problem_destilled

  implicit none

  integer, parameter :: MAX_NUMBER_STORAGE = 100000000
  integer, parameter :: MAX_BLOCK_SIZE = 8*1024*1024
  integer, parameter :: BLOCK_SIZE_I = MAX_BLOCK_SIZE/4
  integer, parameter :: BLOCK_SIZE_R = MAX_BLOCK_SIZE/4
  integer, parameter :: NUM_REP = 100

  integer :: idxRep, idxBlock, idx, index
  integer :: numBlocks, remainder

  real, allocatable, dimension(:) :: vec1, vec2
  real :: dot1(NUM_REP), dot2(NUM_REP)

  real :: time, duration1, duration2, duration3

  allocate( vec1(MAX_NUMBER_STORAGE) )
  allocate( vec2(MAX_NUMBER_STORAGE) )

  vec1 = 0.0
  vec2 = 0.0

  do idxRep = 1, NUM_REP

     vec1(idxRep) = 1.0
     vec2(idxRep) = 1.0

     dot1(idxRep) = 0.0

     do idx = 1, MAX_NUMBER_STORAGE
        dot1(idxRep) = dot1(idxRep) + vec1(idx)*vec2(idx)
     end do

  end do

  vec1(1:NUM_REP) = 0.0
  vec2(1:NUM_REP) = 0.0

  do idxRep = 1, NUM_REP

     vec1(idxRep) = 1.0
     vec2(idxRep) = 1.0

     dot2(idxRep) = 0.0

     remainder = mod( MAX_NUMBER_STORAGE, BLOCK_SIZE_R )

!     print*, BLOCK_SIZE_R, numBlocks, remainder
     do idxBlock = 0, numBlocks-1
        do idx = 1, BLOCK_SIZE_R
           index = idxBlock*BLOCK_SIZE_R + idx
           dot2(idxRep) = dot2(idxRep) + vec1(index)*vec2(index)
        end do
     end do

     do idx = 1, remainder
        index = numBlocks*BLOCK_SIZE_R + idx
        dot2(idxRep) = dot2(idxRep) + vec1(index)*vec2(index)
     end do

  end do

  do idxRep = 1, NUM_REP

     print*, idxRep, dot1(idxRep), dot2(idxRep)

  end do

  deallocate( vec1 )
  deallocate( vec2 )

end program problem_destilled

The content of dot1 and dot2 should be:

1.0 2.0 3.0 ... 100.0 but in this case dot2 is zero in all its components.


Can this be reproduced/explained?








Download problem-destilled.f901.64 KB
4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

We'll investigate this, test with latest compilers, etc. and report back shortly.


I believe the bug is with the /Os option. Try this
Project -> Properties -> Fortran -> Optimization property page
on this Optimization Properties, set "Favor Size or Speed" to "Favor Fast Code"

For me, that worked around the bug. There is a bug with /Os and your code. I'll write it up.


No, it looks like anything at O2 or Os is affected. Bug ID is DPD200179556.

It is related to loop distribution optimization.


Leave a Comment

Please sign in to add a comment. Not a member? Join today