Setting stack size in Cilk++

Setting stack size in Cilk++

Hello.

Intel's OpenMP implementation allows the KMP_STACKSIZE environment variable to specify stack size for a thread, and OMP_STACKSIZE is the gcc equivalent. Is there a similar facility in Cilk++? I know threads/workers are really "behind the scenes" given the task parallel interface of Cilk++, but I have found the KMP_STACKSIZE useful for task parallel (i.e. OpenMP 3.0) as well as thread parallel programs. In either case, tasks are mapped to threads/workers and need memory, and some times a lot of memory.

In particular, I have a Cilk++ program that runs using 16 threads on a particular machine. It fails with worker stack overflow if fewer threads are used:

Stack overflow on Cilk++ worker 0xd15c540, h=0xd15cb00 t=0xd15eb08. Aborting program.

I have written implementations in OpenMP 3.0 and in Cilk 5 that do not overflow the stack, even without the stack size increase. I have the OS stack size limit set to unlimited, though the machine node actually has 32M of RAM.

Thanks,
Stephen Olivier
UNC Chapel Hill

2 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

Hi Stephen.

The error message that you are getting is misleading (I apologize for this, we'll fix it): the message refers to the overflow of the spawn stack, as opposed to the system stack.

Cilk++ does not use a stack in the traditional sense; instead, all activation records are heap-allocated. In this sense, there is no stack size---you can use as much ``stack'' memory as you want.

However, every spawn operation pushes one item onto a separate ``spawn stack'', which is really a doubly-ended queue. This queue overflows when you have more than 1024 nested spawns, and currently there is no user-visible API for changing it. (This was on our TODO list of things to change.)

Are you sure you need that many nested spawns? Can you tell me what application needs it? If you really need this we'll think of a workaround.

发表评论

登录添加评论。还不是成员?立即加入