HOME
| OPENMP API Specification: Version 5.1 November 2020

1.4.5  Flush Synchronization and Happens Before

OpenMP supports thread synchronization with the use of release flushes and acquire flushes. For any such synchronization, a release flush is the source of the synchronization and an acquire flush is the sink of the synchronization, such that the release flush synchronizes with the acquire flush.

A release flush has one or more associated release sequences that define the set of modifications that may be used to establish a synchronization. A release sequence starts with an atomic operation that follows the release flush and modifies a shared variable and additionally includes any read-modify-write atomic operations that read a value taken from some modification in the release sequence. The following rules determine the atomic operation that starts an associated release sequence.

An acquire flush is associated with one or more prior atomic operations that read a shared variable and that may be used to establish a synchronization. The following rules determine the associated atomic operation that may establish a synchronization.

A release flush synchronizes with an acquire flush if the following conditions are satisfied:

An operation X simply happens before an operation Y if any of the following conditions are satisfied:

1.
X and Y are performed by the same thread, and X precedes Y in the thread’s program order;
2.
X synchronizes with Y according to the flush synchronization conditions explained above or according to the base language’s definition of synchronizes with, if such a definition exists; or
3.
Another operation, Z, exists such that X simply happens before Z and Z simply happens before Y.

An operation X happens before an operation Y if any of the following conditions are satisfied:

1.
X happens before Y according to the base language’s definition of happens before, if such a definition exists; or
2.
X simply happens before Y.

A variable with an initial value is treated as if the value is stored to the variable by an operation that happens before all operations that access or modify the variable in the program.