HOME
| OPENMP API Specification: "Version 5.2 -- GIT rev 95b2e3a44"

5.4.4  firstprivate Clause

Name: firstprivate

Properties: data-environment attribute, data-sharing attribute, privatization

Arguments

Name

Type

Properties

list

list of variable list item type

default

Directives

distribute

,

do

,

for

,

parallel

,

scope

,

sections

,

single

,

target

,

task

,

taskloop

,

teams

Semantics

The firstprivate clause provides a superset of the functionality provided by the private clause. A list item that appears in a firstprivate clause is subject to the private clause semantics described in Section 5.4.3, except as noted. In addition, the new list item is initialized from the original list item that exists before the construct. The initialization of the new list item is done once for each task that references the list item in any statement in the construct. The initialization is done prior to the execution of the construct.

For a firstprivate clause on a construct that is not a work-distribution construct, the initial value of the new list item is the value of the original list item that exists immediately prior to the construct in the task region where the construct is encountered unless otherwise specified. For a firstprivate clause on a work-distribution construct, the initial value of the new list item for each implicit task of the threads that execute the construct is the value of the original list item that exists in the implicit task immediately prior to the point in time that the construct is encountered unless otherwise specified.

To avoid data races, concurrent updates of the original list item must be synchronized with the read of the original list item that occurs as a result of the firstprivate clause.

For variables of non-array type, the initialization occurs by copy assignment. For an array of elements of non-array type, each element is initialized as if by assignment from an element of the original array to the corresponding element of the new array.
For each variable of class type:

If copy constructors are called, the order in which copy constructors for different variables of class type are called is unspecified.

If the original list item does not have the POINTER attribute, initialization of the new list items occurs as if by intrinsic assignment unless the original list item has a compatible type-bound defined assignment, in which case initialization of the new list items occurs as if by the defined assignment. If the original list item that does not have the POINTER attribute has the allocation status of unallocated, the new list items will have the same status.

If the original list item has the POINTER attribute, the new list items receive the same association status as the original list item, as if by pointer assignment.

The list items that appear in a firstprivate clause may include named constants.

Restrictions

Restrictions to the firstprivate clause are as follows:

Cross References