openMP 中无限大小堆栈的行为
我很好奇 openmp 如何处理(或不按照实际情况)无限的堆栈大小:
[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 ~]$ ulimit -s 30960
[alm475@compute-0-139 ~]$ big_stack_openmp
最终的命令运行干净并产生正确的结果。它需要约 12MB 的堆栈才能运行。
当没有声明堆栈大小时,并行环境中堆栈分配的行为是什么?
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 ~]$ 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 OpenMP 时必须考虑两种堆栈大小。有初始(或主)线程的堆栈,它由 ulimit 控制。然后是每个“从”线程的堆栈,该堆栈由 OpenMP 环境变量 OMP_STACKSIZE 控制。第二个堆栈有一个由每个实现确定的默认值。大多数都有不同的默认大小,具体取决于您是在 32 位模式还是 64 位模式下运行。
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.