Can someone tell me how to set OpenMP stack size to unlimited?
Like this link: Why Segmentation fault is happening in this openmp code?
I also have a project written by Fortran (customer‘s complex code), if I set OMP_STACKSIZE
, the project is running normally. If I unset it, the project fails.
But, different input data have different OMP_STACKSIZE
, so I must try it for each inputdata, (because I must save memory).
Can I set the OpenMP stack like pthread (ulimit -s unlimited
)? Or have some way to set omp stack size dynamically?
I'm using RHEL 6.1, and the Intel compiler.
Thanks a lot!
There is big difference between how the stacks of the main thread and of the worker threads are implemented.
The "unlimited" stack of the main thread starts at the highest virtual address available in user mode and grows downwards until it meets the program break (the end of the data segment) or hits another memory allocation (either named or anonymous mapping) at which point the program crashes.
Any additional stacks have to be placed somewhere in memory between the program break and the bottom of the main stack. They cannot have an arbitrary extendible length since their initial placements (i.e. the distance between their beginnings) determines their maximum sizes (and vice versa - the specified maximum sizes determine their initial placement). This is the reason why the Linux implementation of pthread_create(3) (used by virtually all OpenMP runtimes in order to create new threads) states:
In other words, the answer is no - you cannot specify unlimited stack size for threads other than the main one.