A very simple question. I have a Fortran routine containing OpenMP pragmas and compiling and running well using pgf90. When I add -mp flag, it crashes in a segfault. SInce I’m not completely familiar with pgf90 what would be the best strategy to address this issue ? Thank you for your answer.
It’s most likely a stack overflow. Try increasing your stack limit, or set the OpenMP environment variable “OMP_STACKSIZE” to a large value such as “128M”.
When I add -mp flag, it crashes in a segfault.
It’s most likely a stack overflow.
Yes, in my experience having a stack size that is too small causes a segmentation fault.
Along these same lines, it would be nice if some of the error messages were more specific and helpful. If in fact the stack size is too small, is it possible to have the code and exit with a message something like “stack size too small”? Segmentation faults can also occur if a variable of the wrong type is passed into a subroutine and the like. In that case, it would be nice to have a much more specific type of error message instead of just “segmentation fault”.
Add the diagnostic flag “-Mchkstk” to have the compiler check if there is sufficient stack.
Dear Mat and Jerry,
This is also what I suspected. Do pgfortran set a stack limit as some other compilers do ? Besides, using
pgfortran -mp -Mchkstk file.f90 -o file.out
Error: in routine file there is a
stack overflow: thread 0, max 1793KB, used 553KB, request 2400256B
I’m still wondering how a unique thread can request such a large amount of memory although it seems not in the serial case. Any thoughts ?
Thank you for your help
In order to ensure each thread has a private copy, a routine’s local variables that when built without OpenMP support would have been allocated on the heap (such as automatics or sub-arrays passed as arguments) are now allocated on the stack. This increases the amount of stack memory used.
Note that this is common across all compilers which implement OpenMP.