Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7242 Discussions

Stack overflow and /Qopenmp: is the stack size smaller when /Qopenmp used?

Tony_Garratt
Beginner
843 Views
I have a Fortran program that has some hardwired arrays via PARAMETER statements. Hence the memory goes on the stack. There is not THAT much memory going on the stack. If I compile without /Qopenmp I have no problems. If I compile with /Qopenmp I get a stack overflow. Why would /Qopenmp make such a difference?
0 Kudos
2 Replies
Tony_Garratt
Beginner
843 Views
I should add that I am linking with MKL and this is windows 64bit with version 11.1 of the compiler.
0 Kudos
Tony_Garratt
Beginner
843 Views

I think I have answered my own question by readingthe following... using openmp is pushing hardwired arrays on to the stack...

http://docs.sun.com/source/819-0501/5_compiling.html

5.5 Stacks and Stack Sizes

The executing program maintains a main memory stack for the initial thread executing the program, as well as distinct stacks for each slave thread. Stacks are temporary memory address spaces used to hold arguments and automatic variables during invocation of a subprogram or function reference.

In general, the default main stack size is 8 megabytes. Compiling Fortran programs with the f95 -stackvar option forces the allocation of local variables and arrays on the stack as if they were automatic variables. Use of -stackvar with OpenMP programs is implied with explicitly parallelized programs because it improves the optimizer's ability to parallelize calls in loops. (See the Fortran User's Guide for a discussion of the -stackvar flag.) However, this may lead to stack overflow if not enough memory is allocated for the stack.

0 Kudos
Reply