After an OpenMP sentinel, the parallel directive name can be followed by one or more clauses to modify the parallel construct. The available clauses for the OpenMP parallel construct are:

if

The if clause, if present, helps to determine whether the parallel construct will be used. There are two situations where the parallel construct would not be used: if the scalar expression in this clause evaluates to false or if the parallel construct appears while another parallel construct is active and the OpenMP nesting flag is off. Note that the standard specifies that nesting is off by default.

private

The private clause is followed by a list of variables that will be instantiated separately for each thread in the parallel region. The type of each private variable is determined by its type in the enclosing context, but its value is undefined at the beginning of the parallel region. Likewise, the value in the enclosing context of each variable that was declared private in a parallel region is undefined when the parallel region ends. Certain global variables cannot be listed as private because their status can't be changed to undefined.

firstprivate

The firstprivate clause contains a list of variables that, like the private variables, are instantiated separately for each thread in the parallel region. The one difference is that instead of being undefined at the beginning of the parallel region, the value of each variable is initialized to the value it had when the parallel region was entered.

default

The default clause sets the sharing status of any variables whose sharing status is not explicitly determined. The private option is available only in Fortran. The none option requires that every variable referenced in the parallel region have a sharing attribute.

shared

The shared clause can be used to list variables that are shared among all threads. This isn't usually necessary because most variables are shared by default.

copyin

The copyin clause causes the listed variables to be copied from the primary thread to all other threads in the team immediately after the threads have been created and before they do any other work. The variables in the list must also be threadprivate because if they were shared, copying would be meaningless.

reduction

The reduction clause lists variables upon which a reduction operation will be done at the end of the parallel region. The clause also specifies the operator for the reduction. A private copy of each reduction variable is created for each thread and is initialized as described in the table below. The private copies of the variables are updated as the threads execute and then the private copies from all threads are combined at the end of the parallel region. Any variable defined outside the parallel region that is involved in a reduction operation is undefined while the reduction calculation is in progress. The reduction operations are:

Reduction operations.
Op name C op Initial value (C) F op Initial value (F)
Add + 0 + 0
Multiply*1*1
Subtract-0-0
Max max least representable
item of type
MAX least representable
item of type
Min min largest representable
item of type
MAX largest representable
item of type
Logical AND && 1 .AND. .TRUE.
Logical OR || 0 .OR. .FALSE.
Logical Equivalent .EQV. .TRUE.
Logical Not Equivalent .NEQV. .FALSE.
Bitwise AND & ~0 IAND all bits on
Bitwise OR | 0 IOR 0
Bitwise XOR ^ 0 IEOR 0
num_threads

The num_threads expression, if present, overrides any other specification of the number of threads to start for this parallel region.

 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement