HOME
| OPENMP API Specification: Version 5.0 November 2018

2.19.6  Data Copying Clauses

This section describes the copyin clause (allowed on the parallel construct and combined parallel worksharing constructs) and the copyprivate clause (allowed on the single construct).

These clauses support the copying of data values from private or threadprivate variables on one implicit task or thread to the corresponding variables on other implicit tasks or threads in the team.

The clauses accept a comma-separated list of list items (see Section 2.1 on page 104). All list items appearing in a clause must be visible, according to the scoping rules of the base language. Clauses may be repeated as needed, but a list item that specifies a given variable may not appear in more than one clause on the same directive.

SVG-Viewer needed.

An associate name preserves the association with the selector established at the ASSOCIATE statement. A list item that appears in a data copying clause may be a selector of an ASSOCIATE construct. If the construct association is established prior to a parallel region, the association between the associate name and the original list item will be retained in the region.

SVG-Viewer needed.

2.19.6.1 copyin Clause

SummaryThe copyin clause provides a mechanism to copy the value of a threadprivate variable of the master thread to the threadprivate variable of each other member of the team that is executing the parallel region.

Syntax

The syntax of the copyin clause is as follows:  

 
copyin(list)  

Description

SVG-Viewer needed.

The copy is done after the team is formed and prior to the start of execution of the associated structured block. For variables of non-array type, the copy occurs by copy assignment. For an array of elements of non-array type, each element is copied as if by assignment from an element of the array of the master thread to the corresponding element of the array of the other thread.

SVG-Viewer needed.

SVG-Viewer needed.

For class types, the copy assignment operator is invoked. The order in which copy assignment operators for different variables of class type are called is unspecified.

SVG-Viewer needed.

SVG-Viewer needed.

The copy is done, as if by assignment, after the team is formed and prior to the start of execution of the associated structured block.

On entry to any parallel region, each thread’s copy of a variable that is affected by a copyin clause for the parallel region will acquire the type parameters, allocation, association, and definition status of the copy of the master thread, according to the following rules:

SVG-Viewer needed.

RestrictionsThe restrictions to the copyin clause are as follows:

SVG-Viewer needed.

SVG-Viewer needed.

SVG-Viewer needed.

SVG-Viewer needed.

Cross References

2.19.6.2 copyprivate Clause

SummaryThe copyprivate clause provides a mechanism to use a private variable to broadcast a value from the data environment of one implicit task to the data environments of the other implicit tasks that belong to the parallel region. To avoid data races, concurrent reads or updates of the list item must be synchronized with the update of the list item that occurs as a result of the copyprivate clause.

Syntax

The syntax of the copyprivate clause is as follows:  

 
copyprivate(list)  

DescriptionThe effect of the copyprivate clause on the specified list items occurs after the execution of the structured block associated with the single construct (see Section 2.8.2 on page 256), and before any of the threads in the team have left the barrier at the end of the construct.

SVG-Viewer needed.

In all other implicit tasks that belong to the parallel region, each specified list item becomes defined with the value of the corresponding list item in the implicit task associated with the thread that executed the structured block. For variables of non-array type, the definition occurs by copy assignment. For an array of elements of non-array type, each element is copied by copy assignment from an element of the array in the data environment of the implicit task that is associated with the thread that executed the structured block to the corresponding element of the array in the data environment of the other implicit tasks

SVG-Viewer needed.

SVG-Viewer needed.

For class types, a copy assignment operator is invoked. The order in which copy assignment operators for different variables of class type are called is unspecified.

SVG-Viewer needed.

SVG-Viewer needed.

If a list item does not have the POINTER attribute, then in all other implicit tasks that belong to the parallel region, the list item becomes defined as if by intrinsic assignment with the value of the corresponding list item in the implicit task that is associated with the thread that executed the structured block. If the list item has a type bound procedure as a defined assignment, the assignment is performed by the defined assignment.

If the list item has the POINTER attribute, then, in all other implicit tasks that belong to the parallel region, the list item receives, as if by pointer assignment, the same association status of the corresponding list item in the implicit task that is associated with the thread that executed the structured block.

The order in which any final subroutines for different variables of a finalizable type are called is unspecified.

SVG-Viewer needed.

SVG-Viewer needed.

Note – The copyprivate clause is an alternative to using a shared variable for the value when providing such a shared variable would be difficult (for example, in a recursion requiring a different variable at each level).

SVG-Viewer needed.

RestrictionsThe restrictions to the copyprivate clause are as follows:

Cross References