[Openmp-dev] OpenMP ordered clause for nested loops

Cownie, James H via Openmp-dev openmp-dev at lists.llvm.org
Mon Mar 4 01:47:38 PST 2019


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<https://stackoverflow.com/> where there are many more people who can answer. (Remember to tag the question with the OpenMP tag…)

-- Jim

Jim Cownie <james.h.cownie at intel.com>
IAGS/CPDP/TCAR (Technical Computing, Analyzers, and Runtimes)
Tel: +44 117 9071438

From: Openmp-dev [mailto:openmp-dev-bounces at lists.llvm.org] On Behalf Of Himanshu Shukla via Openmp-dev
Sent: Monday, March 4, 2019 7:31 AM
To: openmp-dev at lists.llvm.org
Subject: Re: [Openmp-dev] OpenMP ordered clause for nested loops

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<mailto: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 .
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20190304/f4410b00/attachment-0001.html>


More information about the Openmp-dev mailing list