When lastprivate clause is specified in a loop or section, the value of the lastprivate variable from either the sequentially last iteration of the associated loop, or the lexically last section directive is assigned to the variable’s original object. The lastprivate clause provides a superset of the functionality provided by the private clause. Variables specified in the list have private clause semantics described earlier.

copyprivate

copyprivate(list)

The copyprivate clause can be used to broadcast values acquired by a single thread directly to all instances of the private variables in the other threads.

NOTE: The copyprivate clause can only appear on the single directive.

if

if(scalar-expression)

The associated block of code will be executed in parallel if the scalar-expressionevaluates to a non-zero value. Otherwise no parallelization happens and it is executed sequentially.

Example:

#pragma omp parallel private(x) if (a>b) reduction(+:p)

{

// code to be parallelized only when a is greater than b

}

default

default(sharednone)

Specifying default(shared) clause is equivalent to explicitly listing each currently visible variable in a shared clause unless it is threadprivate or const-qualified. A variable referenced in the scope of default(none) should be explicitly qualified by a private or shared clause.

shared

shared(list)

The shared clause causes the variables that appear in the list to be shared among all threads in a team. All threads within a team access the same storage area for the shared variables.

copyin

copyin(list)

The copyin clause copies the value of master thread’s copy of a threadprivate variable to all other threads at the beginning of the parallel region. This clause can only be used with the parallel directive.

reduction

reduction(op:list)

The reduction clause performs a reduction on the scalar variables that appear in the list, with the operator op.

nowait

nowait

The nowait clause removes the implicit barrier synchronization at the end of a for or sections construct.

OpenMP Clauses 115