OpenMP* Directives and Clauses Summary

This topic provides a summary of the OpenMP directives and clauses. For detailed descriptions, see the OpenMP Fortran version 2.0 specifications.

OpenMP Directives

Directive

Description

PARALLEL
END PARALLEL

Defines a parallel region.

DO
END DO

Identifies an iterative worksharing construct in which the iterations of the associated loop should be executed in parallel.

SECTIONS
END SECTIONS

Identifies a non-iterative worksharing construct that specifies a set of structured blocks that are to be divided among threads in a team.

SECTION

Indicates that the associated structured block should be executed in parallel as part of the enclosing sections construct.

SINGLE
END SINGLE

Identifies a construct that specifies that the associated structured block is executed by only one thread in the team.

PARALLEL DO
END PARALLEL DO

A shortcut for a PARALLEL region that contains a single DO directive.

Note

The OpenMP PARALLEL DO or DO directive must be immediately followed by a DO statement (DO-stmt as defined by R818 of the ANSI Fortran standard). If you place another statement or an OpenMP directive between the PARALLEL DO or DO directive and the DO statement, the compiler issues a syntax error.

PARALLEL SECTIONS
END PARALLEL SECTIONS

Provides a shortcut form for specifying a parallel region containing a single SECTIONS construct.

MASTER
END MASTER

Identifies a construct that specifies a structured block that is executed by only the master thread of the team.

CRITICAL[lock]
END CRITICAL[
lock]

Identifies a construct that restricts execution of the associated structured block to a single thread at a time. Each thread waits at the beginning of the critical construct until no other thread is executing a critical construct with the same lock argument.

BARRIER

Synchronizes all the threads in a team. Each thread waits until all of the other threads in that team have reached this point.

ATOMIC

Ensures that a specific memory location is updated atomically, rather than exposing it to the possibility of multiple, simultaneously writing threads.

FLUSH [(list)]

Specifies a "cross-thread" sequence point at which the implementation is required to ensure that all the threads in a team have a consistent view of certain objects in memory. The optional list argument consists of a comma-separated list of variables to be flushed.

ORDERED
END ORDERED

The structured block following an ORDERED directive is executed in the order in which iterations would be executed in a sequential loop.

THREADPRIVATE (list)

Makes the named COMMON blocks or variables private to a thread. The list argument consists of a comma-separated list of COMMON blocks or variables.

OpenMP Clauses

Clause

Description

PRIVATE (list)

Declares variables in list to be PRIVATE to each thread in a team.

FIRSTPRIVATE (list)

Same as PRIVATE, but the copy of each variable in the list is initialized using the value of the original variable existing before the construct.

LASTPRIVATE (list)

Same as PRIVATE, but the original variables in list are updated using the values assigned to the corresponding PRIVATE variables in the last iteration in the DO construct loop or the last SECTION construct.

COPYPRIVATE (list)

Uses private variables in list to broadcast values, or pointers to shared objects, from one member of a team to the other members at the end of a single construct.

NOWAIT

Specifies that threads need not wait at the end of worksharing constructs until they have completed execution. The threads may proceed past the end of the worksharing constructs as soon as there is no more work available for them to execute.

SHARED (list)

Shares variables in list among all the threads in a team.

DEFAULT (mode)

Determines the default data-scope attributes of variables not explicitly specified by another clause. Possible values for mode are PRIVATE, SHARED, or NONE.

REDUCTION ({operator|intrinsic}:list)

Performs a reduction on variables that appear in list with the operator operator or the intrinsic procedure name intrinsic; operator is one of the following: +, *, .AND., .OR., .EQV., .NEQV.; intrinsic refers to one of the following: MAX, MIN, IAND, IOR, or IEOR.

ORDERED
END ORDERED

Used in conjunction with a DO or SECTIONS construct to impose a serial order on the execution of a section of code. If ORDERED constructs are contained in the dynamic extent of the DO construct, the ordered clause must be present on the DO directive.

IF (scalar_logical_expression)

The enclosed parallel region is executed in parallel only if the scalar_logical_expression evaluates to .TRUE., otherwise the parallel region is serialized.

NUM_THREADS (scalar_integer_expression)

Requests the number of threads specified by scalar_integer_expression for the parallel region.

SCHEDULE (type[,chunk])

Specifies how iterations of the DO construct are divided among the threads of the team. Possible values for the type argument are STATIC, DYNAMIC, GUIDED, and RUNTIME. The optional chunk argument must be a positive scalar integer expression.

COPYIN (list)

Specifies that the master thread's data values be copied to the THREADPRIVATE's copies of the common blocks or variables specified in list at the beginning of the parallel region.

Directives and Clauses Cross-reference

See Data Scope Attribute Clauses Overview.

Directive

Use these Clauses

PARALLEL
END PARALLEL

  • COPYIN

  • DEFAULT

  • PRIVATE

  • FIRSTPRIVATE

  • REDUCTION

  • SHARED

DO
END DO

  • PRIVATE

  • FIRSTPRIVATE

  • LASTPRIVATE

  • REDUCTION

  • SCHEDULE

SECTIONS
END SECTIONS

  • PRIVATE

  • FIRSTPRIVATE

  • LASTPRIVATE

  • REDUCTION

SECTION

  • PRIVATE

  • FIRSTPRIVATE

  • LASTPRIVATE

  • REDUCTION

SINGLE
END SINGLE

  • PRIVATE

  • FIRSTPRIVATE

PARALLEL DO
END PARALLEL DO

  • COPYIN

  • DEFAULT

  • PRIVATE

  • FIRSTPRIVATE

  • LASTPRIVATE

  • REDUCTION

  • SHARED

  • SCHEDULE

PARALLEL SECTIONS
END PARALLEL SECTIONS

  • COPYIN

  • DEFAULT

  • PRIVATE

  • FIRSTPRIVATE

  • LASTPRIVATE

  • REDUCTION

  • SHARED

All others

None