[Openmp-dev] OpenMP ordered clause for nested loops

Himanshu Shukla via Openmp-dev openmp-dev at lists.llvm.org
Sun Mar 3 23:30:39 PST 2019


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());*

*    }}*


On Mon, Mar 4, 2019 at 12:49 PM Himanshu Shukla <cs15btech11042 at iith.ac.in>
wrote:

> 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 .
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20190304/69995ff4/attachment.html>


More information about the Openmp-dev mailing list