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

Optimizer bug

mecej4
Honored Contributor III
838 Views
The following reproducer is a simplified version of the one recently posted by "bflynt" "Pointer Optimization Bug ?" . I can confirm that this is an optimizer bug, and has nothing to do with MPI, which might be what one may conclude from his post.

If the three units are combined into a single source file, the bug goes away, so I keep the pieces separate.

The type definition module, typ.f90:

[fortran]module typedef

type schedule

integer :: nproc_send
integer :: nproc_recv
integer :: nbuff_send
integer :: nbuff_recv

integer , pointer :: iproc_send(:)
integer , pointer :: iproc_recv(:)
integer , pointer :: ipntr_recv(:)

end type schedule

end module typedef
[/fortran]
The subroutine where the optimizer bug manifests itself, build.f90:

[fortran]module build
contains
subroutine build_sub(sch)

use typedef
implicit none
type(schedule) :: sch

sch%nproc_recv = 1
allocate(sch%ipntr_recv(2))
sch%ipntr_recv(sch%nproc_recv+1) = 0

sch%nproc_send = 0
sch%nproc_recv = 0
sch%nbuff_send = 0
sch%nbuff_recv = 0
write(6,*) 'In sub build, sch%nproc_recv : ',sch%nproc_recv
return
end subroutine build_sub
end module build
[/fortran]
and a short main program, prg.f90:

[fortran]program test1

use typedef
use build
implicit none
type(schedule) :: gpt

call build_sub(gpt)
write(*,*)'In main prog, gpt%nproc_recv : ',gpt%nproc_recv

stop
end program test1
[/fortran]
Compiling on Linux or Windows using the 11.1.070 or 12.0.2, 12.0.3 compilers with no optimization and running gives the correct output:

[bash]ifort -Od typ.f90 build.f90 prg.f90 -Fetyp

s:\LANG\test1.ifort\mini>typ
In sub build, sch%nproc_recv : 0
In main prog, gpt%nproc_recv : 0[/bash]
Turning optimization on, with the compiler versions listed above, shows the bug:

[bash]ifort -Ot typ.f90 build.f90 prg.f90 -Fetyp

s:\LANG\test1.ifort\mini>typ
In sub build, sch%nproc_recv : 1
In main prog, gpt%nproc_recv : 0
[/bash]
Commenting out the WRITE statement in build.f90 makes the bug go away, which is characteristic of optimizer bugs. As I wrote earlier, if the three files are combined into one file the bug goes away:

[bash]$ cat typ.f90 build.f90 prg.f90 > all.f90
$ ifort -O2 all.f90
$ ./a.out
In sub build, sch%nproc_recv : 0
In main prog, gpt%nproc_recv : 0
[/bash]

0 Kudos
4 Replies
Ron_Green
Moderator
838 Views
Thank you for the compact reproducer. I appreciate it.

Bug ID is DPD200168665. This bug showed up in the 11.0 compiler first. 10.1 compilers are fine.

ron
0 Kudos
Ron_Green
Moderator
838 Views
I do have a workaround: add this option:

-nolib-inline

at O1, O2 or O3 and it will avoid the bug.

ron
0 Kudos
mecej4
Honored Contributor III
838 Views
Excellent! Thank you, Ron.
0 Kudos
Ron_Green
Moderator
838 Views
This bug is fixed in the Composer XE 2011 Update 7 compiler, aka 12.1.1.256

ron
0 Kudos
Reply