Compile bug?

Here is a short Fortran 90 program that I think shows a compiler problem:

subroutine stats_data(bd)
implicit none
integer, parameter :: MAX_SOUND=100000
integer, parameter :: MAX_CHANNEL=15
integer :: i
integer :: isound=1
real, dimension(MAX_CHANNEL) :: bd
real, dimension(MAX_CHANNEL,MAX_SOUND) :: tovs_bt_dev=0.0

! Compiling with the next line takes 1000 times longer than
! compiling with the line after next instead!
integer :: ncount(MAX_SOUND)= (/(0,i=1,MAX_SOUND)/)
! integer :: ncount(MAX_SOUND)=0

end subroutine stats_data

Initializing the ncount array with the data statement style, compile time is 290 seconds; initializing with the othre style, compile time is 0.27 seconds. The compile command was:

pgf90 -c stats_data.o -g stats_data.f90

Compiler version is: pgf90 6.1-1 64-bit target on x86-64 Linux

Resulting object files are almost the same size, and are very large, scaling linearly with MAX_SOUND. The compile time with the slow method, however, is quadratic in MAX_SOUND.

I tested the same program with the SGI f90 compiler and the IBM xlf90 compiler, and they do not exhibit the compile time slowdown with the first method. The SGI compiler also produces an object file that is proportional in size to MAX_SOUND, while the IBM compiler does not.

So, is this definitely the compiler, or could it be some issue related to the (new) Linux cluster that this compiler is on, such as stack/heap space, etc?

Bill Campbell
Naval Research Laboratory
Monterey, CA

Hi Bill,

Thanks from the post. I’ve passed you example on to our compiler team and created a technical problem report (TPR#3743) since I’m hoping we can do something about the compile time. Unfortunately, we can’t do anything about the object size due to constraints in a Linux object file format.

What’s occurring is that for each element of the array, an assembly directive must used to perform the data initialization. This directives become part of the object file and account for the large size. In the case of initializing the array to zero using “ncount(MAX_SOUND)=0”, the compiler recognizes that this is a constant repeating value and does not need to perform the extra processing needed to initialize the array. Hopefully, our compiler team will be change the compiler to recognize this as well for the second case.

If the object size is a concern, you’ll need to change the code to initial large arrays at runtime. On my system, when I remove the data initialization from “tovs_bt_dev” and “ncount” and add set these values are runtime, the object went from 6002032Kb to 1584Kb. Note that in this example, ncount is not used and hence not included in the final object. The size reduction is only attributed to “tovs_bt_dev” being initialized at runtime.

  • Mat