Summary of OpenMP pragma directives

The pragma directives summarized on this page give you control over how the compiler handles parallel processing in your program.

Directives apply only to the statement or statement block immediately following the directive.

OpenMP pragma directives
Description
#pragma omp atomic Identifies a specific memory location that must be updated atomically and not be exposed to multiple, simultaneous writing threads.
#pragma omp parallel Defines a parallel region to be run by multiple threads in parallel. With specific exceptions, all other OpenMP directives work within parallelized regions defined by this directive.
#pragma omp for Work-sharing construct identifying an iterative for-loop whose iterations should be run in parallel.
#pragma omp parallel for Shortcut combination of omp parallel and omp for pragma directives, used to define a parallel region containing a single for directive.
#pragma omp ordered Work-sharing construct identifying a structured block of code that must be executed in sequential order.
#pragma omp section, #pragma omp sections Work-sharing construct identifying a non-iterative section of code containing one or more subsections of code that should be run in parallel.
#pragma omp parallel sections Shortcut combination of omp parallel and omp sections pragma directives, used to define a parallel region containing a single sections directive.
#pragma omp single Work-sharing construct identifying a section of code that must be run by a single available thread.
#pragma omp master Synchronization construct identifying a section of code that must be run only by the master thread.
#pragma omp critical Synchronization construct identifying a statement block that must be executed by a single thread at a time.
#pragma omp barrier Synchronizes all the threads in a parallel region.
#pragma omp flush Synchronization construct identifying a point at which the compiler ensures that all threads in a parallel region have the same view of specified objects in memory.
#pragma omp threadprivate Defines the scope of selected file-scope data variables as being private to a thread, but file-scope visible within that thread.