An official website of the United States government

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.


Home

OpenMP Directives: C/C++ Directive Format

Format:

#pragma omp directive-name [clause, ...] newline
Required for all OpenMP C/C++ directives. A valid OpenMP directive must appear after the pragma and before any clauses. Optional. Clauses can be in any order, and repeated as necessary unless otherwise restricted. Required. Precedes the structured block which is enclosed by this directive.

Example:

#pragma omp parallel default(shared) private(beta,pi)

General Rules:

  • Case sensitive.

  • Directives follow conventions of the C/C++ standards for compiler directives.

  • Only one directive-name may be specified per directive.

  • Each directive applies to at most one succeeding statement, which must be a structured block.

  • Long directive lines can be “continued” on succeeding lines by escaping the newline character with a backslash (“") at the end of a directive line.

#pragma omp <directive>

    [ structured block of code ]