Page 1 of 1

ifort stack problem

Posted: Wed Apr 21, 2010 12:20 pm
by mancini
Hi to all,

I was compiling and running ABINIT with different compiler and on
many platforms and everything worked fine.
Now I tried to compile ABINIT on my laptop with both IFORT AND GFORTRAN but
I found that when I increase the size of the system (in recursion method it corresponds to the size of the ngfft grid)
the IFORT compiled version gives a segmentation fault where GFORTRAN gives the good result
(but GFORTRAN is much more slow: I compiled with the "aggressive" compilation option for which IFORT is very fast).

As it was impossible for me to detect where was the error (gdb, compilation options) so I goggled a little bit
and I found that this error is explained by the behavior of these two compilers with respect to allocating automatic arrays.
IFORT allocates automatic arrays on the stack by default while GFORTRAN allocates them on the heap.

As in my subroutines I have a lots of automatic arrays I tried to increase my stack memory by "ulimit" and I compiled
IFORT with the extra-flags:
FCFLAGS_EXTRA="-heap-arrays 1024"
CFLAGS_EXTRA="-heap-arrays 1024"

Finally the IFORT compiled version works fine.

Now I ask me if I have to replace automatic arrays (more faster) with allocatable array.
Do you have a better idea to resolve this problem?

bye
Marco

Re: ifort stack problem

Posted: Wed Apr 21, 2010 4:44 pm
by pouillon
I don't know if there is a better solution. It depends essentially on your priorities (speed, reliability, portability, ...).

Please note that the concepts of heap and stack are architecture-dependent. Some computers may even not have one of the two.

If speed is critical, it is usually better to use the stack. If not, allocatable arrays will likely have a more reliable and portable behavior.

Re: ifort stack problem

Posted: Wed Apr 21, 2010 5:17 pm
by mancini
Thanks for you reply Yann,
As recursion is thought to run on big machine or workstation
(where I suppose a bigger stack memory than in my laptop),
as you implicitly suggest, I will not touch my arrays.
thanks a lot
Marco