Behavior of stack with unlimited size in openMP
I'm curious how openmp deals with (or doesn't as the case looks to be) with an unlimited stacksize:
[alm475@compute-0-139 ~]$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
max nice (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 278528
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 4096
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
max rt priority (-r) 0
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) 278528
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
[alm475@compute-0-139 ~]$ big_stack_openmp
Segmentation Fault
[alm475@compute-0-139 ~]开发者_Go百科$ ulimit -s 30960
[alm475@compute-0-139 ~]$ big_stack_openmp
The final command runs clean and produces the correct result. It requires a ~12MB stack to run.
What is the behavior of the stack allocations in a parallel environment when there is not a declared stack size?
There are two stack sizes you have to consider when working with OpenMP. There is the stack of the initial (or master) thread, which is controlled by ulimit. Then there is the stack of each of the "slave" threads which is controlled by the OpenMP environment variable OMP_STACKSIZE. This second stack has a default determined by each implementation. Most have a different size default depending on whether you are running in 32-bit or 64-bit mode.
精彩评论