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

Module removes stack overflow error

ymahmoudi
Beginner
1,426 Views

Dear f 90 programmers
I run a simple code to solve 2-d heat equation using OPENMP
for array size more than (301*301) i got stack overflow error and the code has terminated. But as i defined variables in "MODULE" i got no error. Can anyone explain whay this is for??
Regards

0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,426 Views

Module variables are global and statically allocated. If you have local arrays, they will be allocated on the stack, which is good for threading but bad for stack usage. I'd suggest making these ALLOCATABLE arrays and allocating them to the proper size, or increase the stacksize of the application. Static arrays can introduce threading errors.
0 Kudos
TimP
Honored Contributor III
1,426 Views
You may have shifted some of your big arrays from local (default stack) allocation to global heap allocation. When you set /Qopenmp, implying /Qauto, if you don't set heap-arrays, the local arrays have to go on stack, as the compiler doesn't know whether they will be replicated for each thread. This use of MODULE may be a good strategy, to keep shared data off the stack.
0 Kudos
ymahmoudi
Beginner
1,426 Views

Module variables are global and statically allocated. If you have local arrays, they will be allocated on the stack, which is good for threading but bad for stack usage. I'd suggest making these ALLOCATABLE arrays and allocating them to the proper size, or increase the stacksize of the application. Static arrays can introduce threading errors.

Deat Steve
Thanks for reply. Actually i'm so engage with stack overflow error inexecuting my code regarding to what i gonna do in my Ph.d thesis. My main code containsdiffetent variables which defined in common block and most of them are shared between different subroutines. when i run the code in sequential mode i got no error but with OPENMP igot stack overflow and i have to decrease the grid size. may you please tell me what can i do to remove the stack error, in additioni cant define array in allocating mode bacausethe arrays shoulb be share between different program units.
0 Kudos
ymahmoudi
Beginner
1,426 Views
Quoting - tim18
You may have shifted some of your big arrays from local (default stack) allocation to global heap allocation. When you set /Qopenmp, implying /Qauto, if you don't set heap-arrays, the local arrays have to go on stack, as the compiler doesn't know whether they will be replicated for each thread. This use of MODULE may be a good strategy, to keep shared data off the stack.

Thanks for reply
May you please tell me, how can i use heap-array tocompile a program on intel windows?Inlinux adding this option to command line willdo this, but i don't know whatto doin windows.
0 Kudos
TimP
Honored Contributor III
1,426 Views
Quoting - ymahmoudi
May you please tell me, how can i use heap-array tocompile a program on intel windows?Inlinux adding this option to command line willdo this, but i don't know whatto doin windows.
I suppose (could be missing something) it's not one of the Properties options, so it would have to be added as additional command line option e.g. /heap-arrays:512
0 Kudos
Steven_L_Intel1
Employee
1,426 Views

The property is Fortran > Optiimization > Heap Arrays. Set it to 0.
0 Kudos
ymahmoudi
Beginner
1,426 Views

The property is Fortran > Optiimization > Heap Arrays. Set it to 0.
In command line i typed /heap_arrays, but i didn't work and i still get stack overflow, in addition in property>Optimization i can't find the option 'heap-array'? please help me with this
0 Kudos
Steven_L_Intel1
Employee
1,426 Views

Which compiler version are you using?
0 Kudos
Reply