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

Stack Size

maria
Beginner
527 Views
Hi, I have IVF 2008 Version 9.0 complier.

Recently, I run into stack overflow problem. The problem went away with either increasing the stack sizeor using heap array compiler option. My question is that if we are going to distribute theexecutibles to end users, which option we should choose, increasing stack size or using heap array compiler option? We know that heap array option makes the program 5% slower for certain cases and no significant slow down for most our cases.
Any cons if we increase the stack size while making executibles? I mean what if someone's memory is much smaller than our specified stack size, will it cause problems? I am asking since the recommendation is to use heap array compiler option and I just want to know why.

Thanks, Maria

0 Kudos
6 Replies
Steven_L_Intel1
Employee
527 Views
It is unlikely that you would be setting the stack size high enough to pose a problem for your users, unless you "go crazy" with it, but there is the possibility that you don't set it high enough and a stack error will happen. This is why I generally recommend /heap-arrays.
0 Kudos
maria
Beginner
527 Views
Thanks Steve.

Just want to make sure that I understand your recommendation. You said that 'I generally
recommend /heap arrays'. Does this mean that in general /heap arrays is better when you
are not sure the size? If you 100% sure about temp array size, you may increase stack size only without losing the speed. Is this a true statement? One more question, canI do /heap arrays and increasing stack size at the
same time? What will happen if I do this? Sorry that I don't totally understand stack and help size, so I am asking all these entry level questions.

Maria
0 Kudos
Steven_L_Intel1
Employee
527 Views
If you don't absolutely know how much stack you're going to need, /heap-arrays is a win. This is especially true with 64-bit applications where the stack is limited to 1GB just as it is on 32-bits.

Yes, if you set the stack reserve size high enough for your program to run, you won't lose any performance.

As for doing both - you can, but with /heap-arrays enabled, the use of the stack will be much lower.

You may want to read Doctor Fortran - Don't Blow Your Stack!
0 Kudos
a_leonard
Beginner
527 Views
Steve,

I don't find the article in your link.
0 Kudos
Steven_L_Intel1
Employee
527 Views
Sorry - I should have linked to the specific post. Fixed.
0 Kudos
SergeyKostrov
Valued Contributor II
527 Views
Quoting maria
...I mean what if someone's memory is much smaller than our specified stack size, will it cause problems?...

Yes.An applicationwon't be able to allocate a requested memory block and it will exit or even crash at a startup.

Best regards,
Sergey
0 Kudos
Reply