I want to know if there is any way we can change the stack size per cilk thread that will be spawned.
Intel Cilk Plus doesn't work that way.
"cilk_spawn" is a terrible keyword. Except we never found a better one. The cilk_spawn keyword tells the runtime that the continuation (the code after the spawned function) may be stolen by another worker and run in parallel with the spawned function. It gives permission for parallelism. It does not command it. The Cilk runtime does not create a thread in response to the cilk_spawn keyword.
When the runtime steals a continuation, it needs a stack to run it on. So it creates a stack, transfersonto the new stack,and starts executing the continuation. When the two strands sync, you continue executing on the leftmost stack; the one that you entered the function on.
You can set the size of the stacks that the Cilk runtime will create, both when threads are created and when the runtime creates these extra stacks. But a stack may move between threads. You don't have control on a per-thread basis.
What you said pretty much answers my question but not I was looking for. I want to know that where does cilk plus runtime takes this stacksize information when it initializes address space for the first time and if we change that configration before starting the program we can have all threads with greater stack size. If I am not clear please tell I will try to explain in more details
At the beginning of "main" in your program (before using any Cilk keywords), try executing the folllowing call, and see if it addresses your problem.
__cilkrts_set_param("stack size", "2000000");
That should set the default size of all of the stacks that Cilk creates to approximately 2 MB. Note that the Cilk runtime creates more than P stacks on amachine with P worker threadsbecause of the way the scheduler works, so use with caution.
On Linux, the default stack size isto 1MB.
On Windows, the default is taken from the value set by the /STACK linker option for the executable (the .exe file). If not specified, the Windows linker defaults to 1MB.
As Jim noted, you can override these defaultsusing __cilkrts_set_param().