Community
cancel
Showing results for 
Search instead for 
Did you mean: 
44 Views

OpenMP incorrectly parallelizes C++ member function

Hi, my codebase is far too complex to post here; and I do not have time to reduce it to a simple case that reproduces this. However I just wanted to tell you guys about an issue I have recently had with Intel C++ 11.1 (both 069 and 072 builds).

I have a member function with an OpenMP parallel region inside it. If an exception is thrown in this function (but not from inside the parallel region) I get a segfault. The segfault happens during the unwinding of the stack as the exception is thrown; from the looks of it due to memory corruption.

Again, the exception is not thrown from inside the parallel region. When looking at the debugger output, I can see that the function's mangled name has been postfixed by __par_loopXXXX or something similar; so it would appear that Intel C++ compiler incorrectly believes that this whole function has been parallelized? (or is being called from some other parallel region? or maybe I am misinterpreting what that postfix means..)

In any case, turning off -openmp option in the command-line compile fixes the issue (as the compiler won't try to make any parallel regions) but that doesn't work since I need to use OpenMP.

So my workaround at the moment is to have the function call ANOTHER function, and this new function has the OpenMP parallel region code, while the original function is free to throw exceptions.

I should add that this problem does not occur with gcc.

/marcus
0 Kudos
1 Reply
TimP
Black Belt
44 Views

Intel OpenMP normally creates a function for the parallelized loop, which will be named according to the parent function and __par_loop. The serial part of the parent function will remain there. If this somehow is an "issue," I suppose your way of dealing with it is fine. I agree, gcc doesn't generate a new function for the parallel version of a loop, and that it may be desirable to keep your exception handling separate from the OpenMP parallel region. Evidently, libiomp can deal with either arrangement.
Reply