OpenMP* Stacksize Common Error

ID 662868
Updated 8/24/2018
Version Latest
Public

author-image

By

A common error when beginning to program with OpenMP is running out of stack size. Sometimes you will get your application work on a single thread but as soon as you start threading you get an error. It will often show up as a SIGSEGV error like the one below.

Many users will try to fix this issue by increasing the stack size via ulimit (macOS* and Linux*), or -F compiler flag (Windows*). However, these only address the thread that spawned the task not for any of the threads.

The solution to this problem is to increase the stack size of the threads. We recommend doing this the OMP_STACKSIZE environment variable. The default size is 2m or 4m for IA-32 and Intel® 64 systems. You are able to set it by the byte or you can use shortcuts for instance 1g would set the stack size to 1 gigabyte.

A word of caution you should be realistic in your stack size as each thread will take that much space if you specify 20 threads and 2g stack size but have only 32 gigabytes available the application will not run.

You can find out more about the Intel compilers here for FORTRAN and C/C++