2

Consider the following OpenMP for loop:

#pragma omp parallel for schedule(dynamic)
for (int i = 0; i < n; ++i)
{
    //do something with i
}

Is it guaranteed that each OpenMP thread sees its i values in ascending order?

AbuBakr
  • 968
  • 2
  • 11
  • 22

2 Answers2

4

The order in which threads run is not guaranteed; the order in which a thread processes its own chunk is guaranteed.

cnicutar
  • 178,505
  • 25
  • 365
  • 392
4

If your question is if each thread will get a chunk of the iteration and if within that chunk the value of i is sequential, then the answer is yes. Is that your question?

Gangadhar
  • 1,893
  • 9
  • 9