I am running my code with Visual Studio Pro 2015 + parallel studio 2016 on Windows (machine : 16 GB , 64 bits). I get a problem of Stack overflow when using OpenMP associated to a call to the HDF4 function sfrdata (giving in return a large array). I got exactly the same problem on Unix and I was able to solve it thanks to the following post :
But I still don't understand how to do the same on windows ! where can I increase the STACKSIZE to avoid this problem with OpenMP. I should maybe note that the problem occurs only with the above mentioned HDF4 function, otherwise OpenMP works very well both on Windows and Unix.
Any help ? Thanks !
You should set KMP_STACKSIZE or OMP_STACKSIZE environment variables or call a kmp_set_stacksize_s(size_tsize) routine to set a stacksize of for your openMP threads.
Just like mentioned in the link you’ve provided.
In addition to this you should ask Windows to reserve a memory for stack.
You can do this by passing the stacksize to linker
icl /Qopenmp /F0x10000 test.cpp
icl test.cpp /Qopenmp /link /STACK:"1000000"
Omp_stacksize or kmp_stacksize is the solution if that was what you used on Linux. If you need to increase overall program stack size as you would do with a linux shell command, this has to be built in the .exe by /link /stack setting or a compiler option which passes that setting, or it could be reset by editbin.
Default omp stack size for 64 bit is 4m so if you required an increase it might be to 9m (the most I ever needed). As Dmitry mentioned , that might require increasing overall stack, which can't be done while app is running.