|
1 | 1 | \cchapter{Data Environment}{data_environment} |
2 | 2 | \label{chap:data_environment} |
3 | 3 | The OpenMP \plc{data environment} contains data attributes of variables and |
4 | | -objects. Many constructs (such as \code{parallel}, \code{simd}, \code{task}) |
| 4 | +objects. Many constructs (such as \kcode{parallel}, \kcode{simd}, \kcode{task}) |
5 | 5 | accept clauses to control \plc{data-sharing} attributes |
6 | 6 | of referenced variables in the construct, where \plc{data-sharing} applies to |
7 | 7 | whether the attribute of the variable is \plc{shared}, |
8 | 8 | is \plc{private} storage, or has special operational characteristics |
9 | | -(as found in the \code{firstprivate}, \code{lastprivate}, \code{linear}, or \code{reduction} clause). |
| 9 | +(as found in the \kcode{firstprivate}, \kcode{lastprivate}, \kcode{linear}, or \kcode{reduction} clause). |
10 | 10 |
|
11 | 11 | The data environment for a device (distinguished as a \plc{device data environment}) |
12 | 12 | is controlled on the host by \plc{data-mapping} attributes, which determine the |
|
21 | 21 |
|
22 | 22 | Certain variables and objects have predetermined attributes. |
23 | 23 | A commonly found case is the loop iteration variable in associated loops |
24 | | -of a \code{for} or \code{do} construct. It has a private data-sharing attribute. |
| 24 | +of a \kcode{for} or \kcode{do} construct. It has a private data-sharing attribute. |
25 | 25 | Variables with predetermined data-sharing attributes cannot be listed in a data-sharing clause; but there are some |
26 | 26 | exceptions (mainly concerning loop iteration variables). |
27 | 27 |
|
28 | 28 | Variables with explicitly determined data-sharing attributes are those that are |
29 | 29 | referenced in a given construct and are listed in a data-sharing attribute |
30 | 30 | clause on the construct. Some of the common data-sharing clauses are: |
31 | | -\code{shared}, \code{private}, \code{firstprivate}, \code{lastprivate}, |
32 | | -\code{linear}, and \code{reduction}. % Are these all of them? |
| 31 | +\kcode{shared}, \kcode{private}, \kcode{firstprivate}, \kcode{lastprivate}, |
| 32 | +\kcode{linear}, and \kcode{reduction}. % Are these all of them? |
33 | 33 |
|
34 | 34 | Variables with implicitly determined data-sharing attributes are those |
35 | 35 | that are referenced in a given construct, do not have predetermined |
36 | 36 | data-sharing attributes, and are not listed in a data-sharing |
37 | 37 | attribute clause of an enclosing construct. |
38 | 38 | For a complete list of variables and objects with predetermined and |
39 | 39 | implicitly determined attributes, please refer to the |
40 | | -\plc{Data-sharing Attribute Rules for Variables Referenced in a Construct} |
| 40 | +\docref{Data-sharing Attribute Rules for Variables Referenced in a Construct} |
41 | 41 | subsection of the OpenMP Specifications document. |
42 | 42 |
|
43 | 43 | \bigskip |
44 | 44 | DATA-MAPPING ATTRIBUTES |
45 | 45 |
|
46 | | -The \code{map} clause on a device construct explicitly specifies how the list items in |
| 46 | +The \kcode{map} clause on a device construct explicitly specifies how the list items in |
47 | 47 | the clause are mapped from the encountering task's data environment (on the host) |
48 | 48 | to the corresponding item in the device data environment (on the device). |
49 | 49 | The common \plc{list items} are arrays, array sections, scalars, pointers, and |
50 | 50 | structure elements (members). |
51 | 51 |
|
52 | 52 | Procedures and global variables have predetermined data mapping if they appear |
53 | | -within the list or block of a \code{declare}~\code{target} directive. Also, a C/C++ pointer |
| 53 | +within the list or block of a \kcode{declare target} directive. Also, a C/C++ pointer |
54 | 54 | is mapped as a zero-length array section, as is a C++ variable that is a reference to a pointer. |
55 | 55 | % Waiting for response from Eric on this. |
56 | 56 |
|
57 | | -Without explicit mapping, non-scalar and non-pointer variables within the scope of the \code{target} |
58 | | -construct are implicitly mapped with a \plc{map-type} of \code{tofrom}. |
59 | | -Without explicit mapping, scalar variables within the scope of the \code{target} |
| 57 | +Without explicit mapping, non-scalar and non-pointer variables within the scope of the \kcode{target} |
| 58 | +construct are implicitly mapped with a \plc{map-type} of \kcode{tofrom}. |
| 59 | +Without explicit mapping, scalar variables within the scope of the \kcode{target} |
60 | 60 | construct are not mapped, but have an implicit firstprivate data-sharing |
61 | 61 | attribute. (That is, the value of the original variable is given to a private |
62 | 62 | variable of the same name on the device.) This behavior can be changed with |
63 | | -the \code{defaultmap} clause. |
| 63 | +the \kcode{defaultmap} clause. |
64 | 64 |
|
65 | | -The \code{map} clause can appear on \code{target}, \code{target data} and |
66 | | -\code{target enter/exit data} constructs. The operations of creation and |
| 65 | +The \kcode{map} clause can appear on \kcode{target}, \kcode{target data} and |
| 66 | +\kcode{target enter/exit data} constructs. The operations of creation and |
67 | 67 | removal of device storage as well as assignment of the original list item |
68 | 68 | values to the corresponding list items may be complicated when the list |
69 | 69 | item appears on multiple constructs or when the host and device storage |
70 | 70 | is shared. In these cases the item's reference count, the number of times |
71 | | -it has been referenced (+1 on entry and -1 on exited) in nested (structured) |
| 71 | +it has been referenced (increment by 1 on entry and decrement by 1 on exit) in nested (structured) |
72 | 72 | map regions and/or accumulative (unstructured) mappings, determines the operation. |
73 | | -Details of the \code{map} clause and reference count operation are specified |
74 | | -in the \plc{map Clause} subsection of the OpenMP Specifications document. |
| 73 | +Details of the \kcode{map} clause and reference count operation are specified |
| 74 | +in the \docref{\kcode{map} Clause} subsection of the OpenMP Specifications document. |
75 | 75 |
|
76 | 76 |
|
77 | 77 | %===== Examples Sections ===== |
|
81 | 81 | \input{data_environment/fort_loopvar} |
82 | 82 | \input{data_environment/fort_sp_common} |
83 | 83 | \input{data_environment/fort_sa_private} |
| 84 | +\input{data_environment/fort_shared_var} |
84 | 85 | \input{data_environment/carrays_fpriv} |
85 | 86 | \input{data_environment/lastprivate} |
86 | 87 | \input{data_environment/reduction} |
|
0 commit comments