OpenMP ordered clause for nested loops

Hi ,

I am trying to write an OpenMP code. When I execute this code, from the output it is clear that only outer dimension is parallelized.

#pragma omp parallel for schedule(static) ordered(1)
for (int j = 1; j < N; j++)
{
for (int i = 1; i < N; i++)
{
printf(“Iteration j=%d,i=%d, Thread %d\n”, j, i, omp_get_thread_num());

}

}

But when I execute the following code both the dimensions are parallelized. Why ? As per my understanding , the #pragma omp parallel for directive should only parallelize the outermost dimension and the inner dimension should run sequentially. Why is ordered clause parameter affecting it ?

#pragma omp parallel for schedule(static) ordered(1)
for (int j = 1; j < N; j++)
{
for (int i = 1; i < N; i++)
{
printf(“Iteration j=%d,i=%d, Thread %d\n”, j, i, omp_get_thread_num());

}

}

Please advise .

Apologies for a small mistake above. The second code has 2 as parameter instead of 1.

#pragma omp parallel for schedule(static) ordered(2)
for (int j = 1; j < N; j++)
{
for (int i = 1; i < N; i++)
{
printf(“Iteration j=%d,i=%d, Thread %d\n”, j, i, omp_get_thread_num());

}
}

I’m afraid you are not asking in the right place. This list is for discussion of the development of the LLVM OpenMP runtime (which is effectively part of the compiler).

It’s not a place for general discussion of OpenMP code itself.

I suggest you take your questions to StackOverflow where there are many more people who can answer. (Remember to tag the question with the OpenMP tag…)

– Jim

Jim Cownie james.h.cownie@intel.com
IAGS/CPDP/TCAR (Technical Computing, Analyzers, and Runtimes)

Tel: +44 117 9071438