Why is the != operator not allowed with OpenMP?

前端 未结 5 1933
清歌不尽
清歌不尽 2020-12-01 01:05

I was trying to compiled the following code:

#pragma omp parallel shared (j)
{
   #pragma omp for schedule(dynamic)
   for(i = 0; i != j; i++)
   {
    // do         


        
5条回答
  •  余生分开走
    2020-12-01 01:53

    The answer is simple. OpenMP does not allow premature termination of a team of threads. With == or !=, OpenMP has no way of determining when the loop stops. 1. One or more threads could hit the termination condition, which might not be unique. 2. OpenMP has no way to shut down the other threads that might never detect the condition.

提交回复
热议问题