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)
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.