Problem with omp schedule(guided) if construct

Problem with omp schedule(guided) if construct

My intention for the following omp construct is that more than one thread  will be used only if (n>64)

size_t n=array.size();
#pragma omp parallel for schedule(guided) if(n>64)
for(size_t i=0;i<n;i++){

// 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".


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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 on Windows).


Leave a Comment

Please sign in to add a comment. Not a member? Join today