Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Problem with omp schedule(guided) if construct

AndrewC
New Contributor III
859 Views

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

}

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

 

0 Kudos
1 Reply
Andrey_C_Intel1
Employee
859 Views

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

Thanks,
Andrey

0 Kudos
Reply