Fork me on GitHub

OpenMP Directives: Synchronization Constructs: ATOMIC Directive

Purpose:

The ATOMIC directive specifies that a specific memory location must be updated atomically, rather than letting multiple threads attempt to write to it. In essence, this directive provides a mini-CRITICAL section.

Format:

Fortran

!$OMP ATOMIC

   statement_expression

C/C++

#pragma omp atomic  newline

   statement_expression

Restrictions:

The directive applies only to a single, immediately following statement.

An atomic statement must follow a specific syntax. See the most recent OpenMP specs for this.