Open MP - clauses
The table below summarizes which clauses are accepted by which OpenMP directives.
Clause | Description |
---|---|
copyin |
Allows threads to access the master thread’s value, for a threadprivate variable. |
copyprivate |
Specifies that one or more variables should be shared among all threads. |
default |
Specifies the behavior of unscoped variables in a parallel region. |
firstprivate |
Specifies that each thread should have its own instance of a variable, and that the variable should be initialized with the value of the variable, because it exists before the parallel construct. |
if |
Specifies whether a loop should be executed in parallel or in serial. |
lastprivate |
Specifies that the enclosing context’s version of the variable is set equal to the private version of whichever thread executes the final iteration (for-loop construct) or last section (#pragma sections). |
nowait |
Overrides the barrier implicit in a directive. |
num_threads |
Sets the number of threads in a thread team. |
ordered |
Required on a parallel for-loop statement if an ordered directive is to be used in the loop. |
private |
Specifies that each thread should have its own instance of a variable. |
reduction |
Specifies that one or more variables that are private to each thread are the subject of a reduction operation at the end of the parallel region. |
schedule |
Applies to the for directive. |
shared |
Specifies that one or more variables should be shared among all threads. |
Some examples next:
Get hands-on with 1400+ tech skills courses.