- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I experience a Segmentation fault in my code, which takes place at a long
WHERE (M1 .le. 0.0d0)
ELSEWHERE (M2 .le. 0.0d0)
ELSEWHERE
...
ENDWHERE
construct, when the matrices M1 etc are very large (of the order of 1000x1000). The Segmentation fault disappears (and the code works fine) if
- I use smaller matrices, or
- I substitute the whole structure with a corresponding double cycle over the matrix dimension, and a cascade of IF...ELSEIF...ENDIF.
What could be the reason of this Segmentation fault? Is there some "hidden" stack limit set by the compiler when unrolling the WHERE loop? I compile with parallelization on, and the stack size in the OS (CentOS 6.2 64 bits) is unlimited.
Any help is really appreciated---I don't like using the cumbersome cycle+if method, instead of the more elegant WHERE.
Regards
I experience a Segmentation fault in my code, which takes place at a long
WHERE (M1 .le. 0.0d0)
ELSEWHERE (M2 .le. 0.0d0)
ELSEWHERE
...
ENDWHERE
construct, when the matrices M1 etc are very large (of the order of 1000x1000). The Segmentation fault disappears (and the code works fine) if
- I use smaller matrices, or
- I substitute the whole structure with a corresponding double cycle over the matrix dimension, and a cascade of IF...ELSEIF...ENDIF.
What could be the reason of this Segmentation fault? Is there some "hidden" stack limit set by the compiler when unrolling the WHERE loop? I compile with parallelization on, and the stack size in the OS (CentOS 6.2 64 bits) is unlimited.
Any help is really appreciated---I don't like using the cumbersome cycle+if method, instead of the more elegant WHERE.
Regards
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you're parallelizing, then you have the thread stack limit. You can try setting the environment variable KMP_STACKSIZE to a larger value, or build with -heap-arrays. The compiler is constructing the mask on the stack.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you're parallelizing, then you have the thread stack limit. You can try setting the environment variable KMP_STACKSIZE to a larger value, or build with -heap-arrays. The compiler is constructing the mask on the stack.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know whether you mean -parallel, since if you used OpenMP you would require an explicit specification of which subscript is to be parallelized.
If there is just one assignment in each section, it often seems more efficient to break into multiple WHERE assignments:
WHERE (M1 <= 0.0)...
WHERE (M2 <= 0.0 .and. M1 > 0.0)...
WHERE (M2 > 0.0 .and. M1 > 0.0)....
As Steve said, the stack limit per thread could be increased by setting KMP_STACKSIZE (default 4MB for 64-bit mode).
If there is just one assignment in each section, it often seems more efficient to break into multiple WHERE assignments:
WHERE (M1 <= 0.0)...
WHERE (M2 <= 0.0 .and. M1 > 0.0)...
WHERE (M2 > 0.0 .and. M1 > 0.0)....
As Steve said, the stack limit per thread could be increased by setting KMP_STACKSIZE (default 4MB for 64-bit mode).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your prompt help, -heap-array solves the problem!
As a matter of fact, I also had an overflow in the SPREAD construct for the same reason.
Best regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I meant -parallel. I used the ELSEWHERE command because I have half a dozen conditions, and I wanted to be sure that the assignments were mutually exclusive, but I'll keep your suggestion in mind for the future.
Thank you for your help!

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page