I need to check continuously through a callback provided by a closed source module a terminating condition. The thread then enters a parallel section. I don't know if this callback is safe to call from other threads other the one that received it, so if I want to use it from within the parallel section, I should have only the main, "originating" thread call it. I can do that, but I need the assumption that the main thread always enters it, or the callback won't be called. Does that hold?
Asked
Active
Viewed 864 times
1
-
2I believe you can write your code to do as you wish. I haven't a clue whether or not you have written your code to do as you wish. How could I without sight of your code ? – High Performance Mark Sep 15 '14 at 14:30
2 Answers
1
From the OpenMP 4.5 Complete Specifications
When any thread encounters a parallel construct, the thread creates a team of itself and zero or more additional threads and becomes the master of the new team.
So yes the main thread enters the oMP section.
Note that the term section may not be appropriate here, as if you have several #pragma omp section
, you won't know which thread will execute which one.

user276648
- 6,018
- 6
- 60
- 86
0
What you describe fits
#pragma omp master
See What is the benefit of '#pragma omp master' as opposed to '#pragma omp single'? for more details