Skip to content

Latest commit

 

History

History
60 lines (39 loc) · 1.54 KB

ordered_directive.md

File metadata and controls

60 lines (39 loc) · 1.54 KB
layout title release_number author tutorial
tutorial_page
OpenMP Directives: Synchronization Constructs: ORDERED Directive
UCRL-MI-133316
Blaise Barney, Lawrence Livermore National Laboratory
OpenMP

Purpose:

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

Format:

Fortran

!$OMP DO ORDERED [clauses...]
   (loop region)

!$OMP ORDERED

   (block)

!$OMP END ORDERED

   (end of loop region)
!$OMP END DO

C/C++

#pragma omp for ordered [clauses...]
   (loop region)

#pragma omp ordered  newline

   structured_block

   (endo of loop region)

Restrictions:

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