My intention for the following omp construct is that more than one thread will be used only if (n>64)
#pragma omp parallel for schedule(guided) if(n>64)
// do stuff with array[i]
On a 6 core machine, I found that my code was "hanging" reproducibly.
When I debugged the code (debug mode, no optimization on.) I found that
- one of threads was still processing.
- the other threads had completed, it seemed.
- Looking at the variables in the "problem thread" showed that i>n ( out of bounds!), although i was not increasing. That , from my understanding, should not be possible.
- I think there is a bug in the implementation of this contstruct ( Intel Compiler 13.1) in that it is allowing the for index to be "out of bounds"
- If I remove the "schedule(guided) if(n>64)" all issues go away
- I have checked the code with Intel Inspector XE for other threading issues, it came away "clean".