layout | title | release_number | author | tutorial |
---|---|---|---|---|
tutorial_page |
OpenMP Directives: Synchronization Constructs: ORDERED Directive |
UCRL-MI-133316 |
Blaise Barney, Lawrence Livermore National Laboratory |
OpenMP |
-
The ORDERED directive specifies that iterations of the enclosed loop will be executed in the same order as if they were executed on a serial processor.
-
Threads will need to wait before executing their chunk of iterations if previous iterations haven't completed yet.
-
Used within a DO / for loop with an ORDERED clause.
-
The ORDERED directive provides a way to "fine tune" where ordering is to be applied within a loop. Otherwise, it is not required.
!$OMP DO ORDERED [clauses...] (loop region) !$OMP ORDERED (block) !$OMP END ORDERED (end of loop region) !$OMP END DO
#pragma omp for ordered [clauses...] (loop region) #pragma omp ordered newline structured_block (endo of loop region)
-
An ORDERED directive can only appear in the dynamic extent of the following directives:
- DO or PARALLEL DO (Fortran)
- for or parallel for (C/C++)
-
Only one thread is allowed in an ordered section at any time.
-
It is illegal to branch into or out of an ORDERED block.
-
An iteration of a loop must not execute the same ORDERED directive more than once, and it must not execute more than one ORDERED directive.
-
A loop which contains an ORDERED directive, must be a loop with an ORDERED clause.