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
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".
Could you please share a bit more details on the problem, so that we would be able to reproduce it and understand the reason.
E.g. what is array size in your hanging example, which OS you are using? If possible, please provide the complete test case.
I tried to create an example from your pattern, and it works fine for me (I used n=128, compiler version 184.108.40.206 on Windows).