]>
Commit | Line | Data |
---|---|---|
41dbbb37 TS |
1 | /* Communication between GCC and libgomp. |
2 | ||
8d9254fc | 3 | Copyright (C) 2014-2020 Free Software Foundation, Inc. |
41dbbb37 TS |
4 | |
5 | Contributed by Mentor Embedded. | |
6 | ||
7 | This file is part of the GNU Offloading and Multi Processing Library | |
8 | (libgomp). | |
9 | ||
10 | Libgomp is free software; you can redistribute it and/or modify it | |
11 | under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 3, or (at your option) | |
13 | any later version. | |
14 | ||
15 | Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY | |
16 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
17 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
18 | more details. | |
19 | ||
20 | Under Section 7 of GPL version 3, you are granted additional | |
21 | permissions described in the GCC Runtime Library Exception, version | |
22 | 3.1, as published by the Free Software Foundation. | |
23 | ||
24 | You should have received a copy of the GNU General Public License and | |
25 | a copy of the GCC Runtime Library Exception along with this program; | |
26 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
27 | <http://www.gnu.org/licenses/>. */ | |
28 | ||
29 | #ifndef GOMP_CONSTANTS_H | |
30 | #define GOMP_CONSTANTS_H 1 | |
31 | ||
32 | /* Memory mapping types. */ | |
33 | ||
34 | /* One byte. */ | |
35 | #define GOMP_MAP_LAST (1 << 8) | |
36 | ||
37 | #define GOMP_MAP_FLAG_TO (1 << 0) | |
38 | #define GOMP_MAP_FLAG_FROM (1 << 1) | |
39 | /* Special map kinds, enumerated starting here. */ | |
40 | #define GOMP_MAP_FLAG_SPECIAL_0 (1 << 2) | |
41 | #define GOMP_MAP_FLAG_SPECIAL_1 (1 << 3) | |
e01d41e5 | 42 | #define GOMP_MAP_FLAG_SPECIAL_2 (1 << 4) |
8e7e71ff | 43 | #define GOMP_MAP_FLAG_SPECIAL_4 (1 << 6) |
41dbbb37 TS |
44 | #define GOMP_MAP_FLAG_SPECIAL (GOMP_MAP_FLAG_SPECIAL_1 \ |
45 | | GOMP_MAP_FLAG_SPECIAL_0) | |
8e7e71ff JB |
46 | #define GOMP_MAP_DEEP_COPY (GOMP_MAP_FLAG_SPECIAL_4 \ |
47 | | GOMP_MAP_FLAG_SPECIAL_2) | |
41dbbb37 TS |
48 | /* Flag to force a specific behavior (or else, trigger a run-time error). */ |
49 | #define GOMP_MAP_FLAG_FORCE (1 << 7) | |
50 | ||
51 | enum gomp_map_kind | |
52 | { | |
53 | /* If not already present, allocate. */ | |
54 | GOMP_MAP_ALLOC = 0, | |
55 | /* ..., and copy to device. */ | |
56 | GOMP_MAP_TO = (GOMP_MAP_ALLOC | GOMP_MAP_FLAG_TO), | |
57 | /* ..., and copy from device. */ | |
58 | GOMP_MAP_FROM = (GOMP_MAP_ALLOC | GOMP_MAP_FLAG_FROM), | |
59 | /* ..., and copy to and from device. */ | |
60 | GOMP_MAP_TOFROM = (GOMP_MAP_TO | GOMP_MAP_FROM), | |
61 | /* The following kind is an internal only map kind, used for pointer based | |
62 | array sections. OMP_CLAUSE_SIZE for these is not the pointer size, | |
63 | which is implicitly POINTER_SIZE_UNITS, but the bias. */ | |
64 | GOMP_MAP_POINTER = (GOMP_MAP_FLAG_SPECIAL_0 | 0), | |
65 | /* Also internal, behaves like GOMP_MAP_TO, but additionally any | |
66 | GOMP_MAP_POINTER records consecutive after it which have addresses | |
67 | falling into that range will not be ignored if GOMP_MAP_TO_PSET wasn't | |
68 | mapped already. */ | |
69 | GOMP_MAP_TO_PSET = (GOMP_MAP_FLAG_SPECIAL_0 | 1), | |
70 | /* Must already be present. */ | |
71 | GOMP_MAP_FORCE_PRESENT = (GOMP_MAP_FLAG_SPECIAL_0 | 2), | |
72 | /* Deallocate a mapping, without copying from device. */ | |
91106e84 | 73 | GOMP_MAP_DELETE = (GOMP_MAP_FLAG_SPECIAL_0 | 3), |
41dbbb37 TS |
74 | /* Is a device pointer. OMP_CLAUSE_SIZE for these is unused; is implicitly |
75 | POINTER_SIZE_UNITS. */ | |
76 | GOMP_MAP_FORCE_DEVICEPTR = (GOMP_MAP_FLAG_SPECIAL_1 | 0), | |
6e232ba4 JN |
77 | /* OpenACC device_resident. */ |
78 | GOMP_MAP_DEVICE_RESIDENT = (GOMP_MAP_FLAG_SPECIAL_1 | 1), | |
79 | /* OpenACC link. */ | |
80 | GOMP_MAP_LINK = (GOMP_MAP_FLAG_SPECIAL_1 | 2), | |
a6163563 | 81 | /* Use device data if present, fall back to host address otherwise. */ |
d5c23c6c | 82 | GOMP_MAP_IF_PRESENT = (GOMP_MAP_FLAG_SPECIAL_1 | 3), |
cbdce905 | 83 | /* Do not map, copy bits for firstprivate instead. */ |
d9a6bd32 JJ |
84 | GOMP_MAP_FIRSTPRIVATE = (GOMP_MAP_FLAG_SPECIAL | 0), |
85 | /* Similarly, but store the value in the pointer rather than | |
86 | pointed by the pointer. */ | |
87 | GOMP_MAP_FIRSTPRIVATE_INT = (GOMP_MAP_FLAG_SPECIAL | 1), | |
88 | /* Pointer translate host address into device address and copy that | |
89 | back to host. */ | |
90 | GOMP_MAP_USE_DEVICE_PTR = (GOMP_MAP_FLAG_SPECIAL | 2), | |
91 | /* Allocate a zero length array section. Prefer next non-zero length | |
92 | mapping over previous non-zero length mapping over zero length mapping | |
93 | at the address. If not already mapped, do nothing (and pointer translate | |
94 | to NULL). */ | |
95 | GOMP_MAP_ZERO_LEN_ARRAY_SECTION = (GOMP_MAP_FLAG_SPECIAL | 3), | |
41dbbb37 TS |
96 | /* Allocate. */ |
97 | GOMP_MAP_FORCE_ALLOC = (GOMP_MAP_FLAG_FORCE | GOMP_MAP_ALLOC), | |
98 | /* ..., and copy to device. */ | |
99 | GOMP_MAP_FORCE_TO = (GOMP_MAP_FLAG_FORCE | GOMP_MAP_TO), | |
100 | /* ..., and copy from device. */ | |
101 | GOMP_MAP_FORCE_FROM = (GOMP_MAP_FLAG_FORCE | GOMP_MAP_FROM), | |
102 | /* ..., and copy to and from device. */ | |
d9a6bd32 | 103 | GOMP_MAP_FORCE_TOFROM = (GOMP_MAP_FLAG_FORCE | GOMP_MAP_TOFROM), |
d5c23c6c TB |
104 | /* Like GOMP_MAP_USE_DEVICE_PTR above, translate a host to a device |
105 | address. If translation fails because the target is not mapped, | |
106 | continue using the host address. */ | |
107 | GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT = (GOMP_MAP_FLAG_SPECIAL_2 | 0), | |
d9a6bd32 JJ |
108 | /* If not already present, allocate. And unconditionally copy to |
109 | device. */ | |
e01d41e5 | 110 | GOMP_MAP_ALWAYS_TO = (GOMP_MAP_FLAG_SPECIAL_2 | GOMP_MAP_TO), |
d9a6bd32 JJ |
111 | /* If not already present, allocate. And unconditionally copy from |
112 | device. */ | |
e01d41e5 JJ |
113 | GOMP_MAP_ALWAYS_FROM = (GOMP_MAP_FLAG_SPECIAL_2 |
114 | | GOMP_MAP_FROM), | |
d9a6bd32 JJ |
115 | /* If not already present, allocate. And unconditionally copy to and from |
116 | device. */ | |
e01d41e5 JJ |
117 | GOMP_MAP_ALWAYS_TOFROM = (GOMP_MAP_FLAG_SPECIAL_2 |
118 | | GOMP_MAP_TOFROM), | |
d9a6bd32 JJ |
119 | /* Map a sparse struct; the address is the base of the structure, alignment |
120 | it's required alignment, and size is the number of adjacent entries | |
121 | that belong to the struct. The adjacent entries should be sorted by | |
122 | increasing address, so it is easy to determine lowest needed address | |
123 | (address of the first adjacent entry) and highest needed address | |
124 | (address of the last adjacent entry plus its size). */ | |
e01d41e5 | 125 | GOMP_MAP_STRUCT = (GOMP_MAP_FLAG_SPECIAL_2 |
d9a6bd32 | 126 | | GOMP_MAP_FLAG_SPECIAL | 0), |
e01d41e5 JJ |
127 | /* On a location of a pointer/reference that is assumed to be already mapped |
128 | earlier, store the translated address of the preceeding mapping. | |
129 | No refcount is bumped by this, and the store is done unconditionally. */ | |
130 | GOMP_MAP_ALWAYS_POINTER = (GOMP_MAP_FLAG_SPECIAL_2 | |
131 | | GOMP_MAP_FLAG_SPECIAL | 1), | |
d9a6bd32 JJ |
132 | /* Forced deallocation of zero length array section. */ |
133 | GOMP_MAP_DELETE_ZERO_LEN_ARRAY_SECTION | |
e01d41e5 | 134 | = (GOMP_MAP_FLAG_SPECIAL_2 |
d9a6bd32 | 135 | | GOMP_MAP_FLAG_SPECIAL | 3), |
d9a6bd32 | 136 | /* Decrement usage count and deallocate if zero. */ |
e01d41e5 | 137 | GOMP_MAP_RELEASE = (GOMP_MAP_FLAG_SPECIAL_2 |
91106e84 | 138 | | GOMP_MAP_DELETE), |
8e7e71ff JB |
139 | /* In OpenACC, attach a pointer to a mapped struct field. */ |
140 | GOMP_MAP_ATTACH = (GOMP_MAP_DEEP_COPY | 0), | |
141 | /* In OpenACC, detach a pointer to a mapped struct field. */ | |
142 | GOMP_MAP_DETACH = (GOMP_MAP_DEEP_COPY | 1), | |
143 | /* In OpenACC, detach a pointer to a mapped struct field. */ | |
144 | GOMP_MAP_FORCE_DETACH = (GOMP_MAP_DEEP_COPY | |
145 | | GOMP_MAP_FLAG_FORCE | 1), | |
d9a6bd32 JJ |
146 | |
147 | /* Internal to GCC, not used in libgomp. */ | |
148 | /* Do not map, but pointer assign a pointer instead. */ | |
e01d41e5 JJ |
149 | GOMP_MAP_FIRSTPRIVATE_POINTER = (GOMP_MAP_LAST | 1), |
150 | /* Do not map, but pointer assign a reference instead. */ | |
4fd872bc JB |
151 | GOMP_MAP_FIRSTPRIVATE_REFERENCE = (GOMP_MAP_LAST | 2), |
152 | /* An attach or detach operation. Rewritten to the appropriate type during | |
153 | gimplification, depending on directive (i.e. "enter data" or | |
154 | parallel/kernels region vs. "exit data"). */ | |
155 | GOMP_MAP_ATTACH_DETACH = (GOMP_MAP_LAST | 3) | |
41dbbb37 TS |
156 | }; |
157 | ||
158 | #define GOMP_MAP_COPY_TO_P(X) \ | |
159 | (!((X) & GOMP_MAP_FLAG_SPECIAL) \ | |
160 | && ((X) & GOMP_MAP_FLAG_TO)) | |
161 | ||
162 | #define GOMP_MAP_COPY_FROM_P(X) \ | |
163 | (!((X) & GOMP_MAP_FLAG_SPECIAL) \ | |
164 | && ((X) & GOMP_MAP_FLAG_FROM)) | |
165 | ||
166 | #define GOMP_MAP_POINTER_P(X) \ | |
167 | ((X) == GOMP_MAP_POINTER) | |
168 | ||
d9a6bd32 JJ |
169 | #define GOMP_MAP_ALWAYS_TO_P(X) \ |
170 | (((X) == GOMP_MAP_ALWAYS_TO) || ((X) == GOMP_MAP_ALWAYS_TOFROM)) | |
171 | ||
172 | #define GOMP_MAP_ALWAYS_FROM_P(X) \ | |
173 | (((X) == GOMP_MAP_ALWAYS_FROM) || ((X) == GOMP_MAP_ALWAYS_TOFROM)) | |
174 | ||
e01d41e5 JJ |
175 | #define GOMP_MAP_ALWAYS_P(X) \ |
176 | (GOMP_MAP_ALWAYS_TO_P (X) || ((X) == GOMP_MAP_ALWAYS_FROM)) | |
177 | ||
41dbbb37 TS |
178 | |
179 | /* Asynchronous behavior. Keep in sync with | |
180 | libgomp/{openacc.h,openacc.f90,openacc_lib.h}:acc_async_t. */ | |
181 | ||
182 | #define GOMP_ASYNC_NOVAL -1 | |
183 | #define GOMP_ASYNC_SYNC -2 | |
184 | ||
185 | ||
186 | /* Device codes. Keep in sync with | |
187 | libgomp/{openacc.h,openacc.f90,openacc_lib.h}:acc_device_t as well as | |
b97e78b7 | 188 | libgomp/libgomp-plugin.h. */ |
41dbbb37 TS |
189 | #define GOMP_DEVICE_NONE 0 |
190 | #define GOMP_DEVICE_DEFAULT 1 | |
191 | #define GOMP_DEVICE_HOST 2 | |
b97e78b7 | 192 | /* #define GOMP_DEVICE_HOST_NONSHM 3 removed. */ |
41dbbb37 TS |
193 | #define GOMP_DEVICE_NOT_HOST 4 |
194 | #define GOMP_DEVICE_NVIDIA_PTX 5 | |
195 | #define GOMP_DEVICE_INTEL_MIC 6 | |
b2b40051 | 196 | #define GOMP_DEVICE_HSA 7 |
fa499995 | 197 | #define GOMP_DEVICE_GCN 8 |
41dbbb37 TS |
198 | |
199 | #define GOMP_DEVICE_ICV -1 | |
200 | #define GOMP_DEVICE_HOST_FALLBACK -2 | |
201 | ||
d9a6bd32 JJ |
202 | /* GOMP_task/GOMP_taskloop* flags argument. */ |
203 | #define GOMP_TASK_FLAG_UNTIED (1 << 0) | |
204 | #define GOMP_TASK_FLAG_FINAL (1 << 1) | |
205 | #define GOMP_TASK_FLAG_MERGEABLE (1 << 2) | |
206 | #define GOMP_TASK_FLAG_DEPEND (1 << 3) | |
207 | #define GOMP_TASK_FLAG_PRIORITY (1 << 4) | |
208 | #define GOMP_TASK_FLAG_UP (1 << 8) | |
209 | #define GOMP_TASK_FLAG_GRAINSIZE (1 << 9) | |
210 | #define GOMP_TASK_FLAG_IF (1 << 10) | |
211 | #define GOMP_TASK_FLAG_NOGROUP (1 << 11) | |
28567c40 | 212 | #define GOMP_TASK_FLAG_REDUCTION (1 << 12) |
d9a6bd32 | 213 | |
e01d41e5 | 214 | /* GOMP_target{_ext,update_ext,enter_exit_data} flags argument. */ |
d9a6bd32 JJ |
215 | #define GOMP_TARGET_FLAG_NOWAIT (1 << 0) |
216 | #define GOMP_TARGET_FLAG_EXIT_DATA (1 << 1) | |
217 | /* Internal to libgomp. */ | |
218 | #define GOMP_TARGET_FLAG_UPDATE (1U << 31) | |
219 | ||
59d5960c TS |
220 | |
221 | /* OpenACC construct flags. */ | |
222 | ||
223 | /* Force host fallback execution. */ | |
224 | #define GOACC_FLAG_HOST_FALLBACK (1 << 0) | |
225 | ||
226 | /* For legacy reasons, in the ABI, the GOACC_FLAGs are encoded as an inverted | |
227 | bitmask. */ | |
228 | #define GOACC_FLAGS_MARSHAL_OP BIT_NOT_EXPR | |
229 | #define GOACC_FLAGS_UNMARSHAL(X) (~(X)) | |
230 | ||
231 | ||
06fca33d CLT |
232 | /* Versions of libgomp and device-specific plugins. GOMP_VERSION |
233 | should be incremented whenever an ABI-incompatible change is introduced | |
234 | to the plugin interface defined in libgomp/libgomp.h. */ | |
235 | #define GOMP_VERSION 1 | |
3e32ee19 | 236 | #define GOMP_VERSION_NVIDIA_PTX 1 |
2a21ff19 | 237 | #define GOMP_VERSION_INTEL_MIC 0 |
b2b40051 | 238 | #define GOMP_VERSION_HSA 0 |
fa499995 | 239 | #define GOMP_VERSION_GCN 1 |
2a21ff19 NS |
240 | |
241 | #define GOMP_VERSION_PACK(LIB, DEV) (((LIB) << 16) | (DEV)) | |
242 | #define GOMP_VERSION_LIB(PACK) (((PACK) >> 16) & 0xffff) | |
243 | #define GOMP_VERSION_DEV(PACK) ((PACK) & 0xffff) | |
244 | ||
3e32ee19 NS |
245 | #define GOMP_DIM_GANG 0 |
246 | #define GOMP_DIM_WORKER 1 | |
247 | #define GOMP_DIM_VECTOR 2 | |
248 | #define GOMP_DIM_MAX 3 | |
249 | #define GOMP_DIM_MASK(X) (1u << (X)) | |
250 | ||
251 | /* Varadic launch arguments. End of list is marked by a zero. */ | |
252 | #define GOMP_LAUNCH_DIM 1 /* Launch dimensions, op = mask */ | |
253 | #define GOMP_LAUNCH_ASYNC 2 /* Async, op = cst val if not MAX */ | |
254 | #define GOMP_LAUNCH_WAIT 3 /* Waits, op = num waits. */ | |
255 | #define GOMP_LAUNCH_CODE_SHIFT 28 | |
256 | #define GOMP_LAUNCH_DEVICE_SHIFT 16 | |
257 | #define GOMP_LAUNCH_OP_SHIFT 0 | |
258 | #define GOMP_LAUNCH_PACK(CODE,DEVICE,OP) \ | |
259 | (((CODE) << GOMP_LAUNCH_CODE_SHIFT) \ | |
260 | | ((DEVICE) << GOMP_LAUNCH_DEVICE_SHIFT) \ | |
261 | | ((OP) << GOMP_LAUNCH_OP_SHIFT)) | |
262 | #define GOMP_LAUNCH_CODE(X) (((X) >> GOMP_LAUNCH_CODE_SHIFT) & 0xf) | |
263 | #define GOMP_LAUNCH_DEVICE(X) (((X) >> GOMP_LAUNCH_DEVICE_SHIFT) & 0xfff) | |
264 | #define GOMP_LAUNCH_OP(X) (((X) >> GOMP_LAUNCH_OP_SHIFT) & 0xffff) | |
265 | #define GOMP_LAUNCH_OP_MAX 0xffff | |
266 | ||
b2b40051 MJ |
267 | /* Bitmask to apply in order to find out the intended device of a target |
268 | argument. */ | |
269 | #define GOMP_TARGET_ARG_DEVICE_MASK ((1 << 7) - 1) | |
270 | /* The target argument is significant for all devices. */ | |
271 | #define GOMP_TARGET_ARG_DEVICE_ALL 0 | |
272 | ||
273 | /* Flag set when the subsequent element in the device-specific argument | |
274 | values. */ | |
275 | #define GOMP_TARGET_ARG_SUBSEQUENT_PARAM (1 << 7) | |
276 | ||
277 | /* Bitmask to apply to a target argument to find out the value identifier. */ | |
278 | #define GOMP_TARGET_ARG_ID_MASK (((1 << 8) - 1) << 8) | |
279 | /* Target argument index of NUM_TEAMS. */ | |
280 | #define GOMP_TARGET_ARG_NUM_TEAMS (1 << 8) | |
281 | /* Target argument index of THREAD_LIMIT. */ | |
282 | #define GOMP_TARGET_ARG_THREAD_LIMIT (2 << 8) | |
283 | ||
284 | /* If the value is directly embeded in target argument, it should be a 16-bit | |
285 | at most and shifted by this many bits. */ | |
286 | #define GOMP_TARGET_ARG_VALUE_SHIFT 16 | |
287 | ||
28567c40 JJ |
288 | /* Dependence types in omp_depend_t objects. */ |
289 | #define GOMP_DEPEND_IN 1 | |
290 | #define GOMP_DEPEND_OUT 2 | |
291 | #define GOMP_DEPEND_INOUT 3 | |
292 | #define GOMP_DEPEND_MUTEXINOUTSET 4 | |
293 | ||
b2b40051 MJ |
294 | /* HSA specific data structures. */ |
295 | ||
296 | /* Identifiers of device-specific target arguments. */ | |
297 | #define GOMP_TARGET_ARG_HSA_KERNEL_ATTRIBUTES (1 << 8) | |
298 | ||
41dbbb37 | 299 | #endif |