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

5.4.5  lastprivate Clause

Name: lastprivate

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

Arguments

Name

Type

Properties

list

list of variable list item type

default

Modifiers

Name

Modifies

Type

Properties

lastprivate-modifier

list

Keyword: conditional

default

Directives

distribute, do, for, loop, sections, simd, taskloop

Semantics

The lastprivate clause provides a superset of the functionality provided by the private clause. A list item that appears in a lastprivate clause is subject to the private clause semantics described in Section 5.4.3. In addition, when a lastprivate clause without the conditional modifier appears on a directive and the list item is not an iteration variable of any associated loop, the value of each new list item from the sequentially last iteration of the associated loops, or the lexically last structured block sequence associated with a sections construct, is assigned to the original list item. When the conditional modifier appears on the clause or the list item is an iteration variable of one of the associated loops, if sequential execution of the loop nest would assign a value to the list item then the original list item is assigned the value that the list item would have after sequential execution of the loop nest.

For class types, the copy assignment operator is invoked. The order in which copy assignment operators for different variables of the same class type are invoked is unspecified.
For an array of elements of non-array type, each element is assigned to the corresponding element of the original array.
If the original list item does not have the POINTER attribute, its update occurs as if by intrinsic assignment unless it has a type bound procedure as a defined assignment.

If the original list item has the POINTER attribute, its update occurs as if by pointer assignment.

When the conditional modifier does not appear on the lastprivate clause, any list item that is not an iteration variable of the associated loops and that is not assigned a value by the sequentially last iteration of the loops, or by the lexically last structured block sequence associated with a sections construct, has an unspecified value after the construct. When the conditional modifier does not appear on the lastprivate clause, a list item that is the iteration variable of an associated loop and that would not be assigned a value during sequential execution of the loop nest has an unspecified value after the construct. Unassigned subcomponents also have unspecified values after the construct.

If the lastprivate clause is used on a construct to which neither the nowait nor the nogroup clauses are applied, the original list item becomes defined at the end of the construct. To avoid data races, concurrent reads or updates of the original list item must be synchronized with the update of the original list item that occurs as a result of the lastprivate clause.

Otherwise, if the lastprivate clause is used on a construct to which the nowait or the nogroup clauses are applied, accesses to the original list item may create a data race. To avoid this data race, if an assignment to the original list item occurs then synchronization must be inserted to ensure that the assignment completes and the original list item is flushed to memory.

If a list item that appears in a lastprivate clause with the conditional modifier is modified in the region by an assignment outside the construct or not to the list item then the value assigned to the original list item is unspecified.

Restrictions

Restrictions to the lastprivate clause are as follows:

Cross References