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...]
!$OMP END ORDERED
(end of loop region)
!$OMP END DO
#pragma omp for ordered [clauses...]
#pragma omp ordered newline
(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.
Lawrence Livermore National Laboratory
7000 East Avenue • Livermore, CA 94550 | LLNL-WEB-458451
Operated by the Lawrence Livermore National Security, LLC for the
Department of Energy's National Nuclear Security Administration
Learn about the Department of Energy's Vulnerability Disclosure Program