]> git.ipfire.org Git - thirdparty/gcc.git/blame - include/gomp-constants.h
gcc/
[thirdparty/gcc.git] / include / gomp-constants.h
CommitLineData
ca4c3545 1/* Communication between GCC and libgomp.
2
3 Copyright (C) 2014-2015 Free Software Foundation, Inc.
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)
9561765e 42#define GOMP_MAP_FLAG_SPECIAL_2 (1 << 4)
ca4c3545 43#define GOMP_MAP_FLAG_SPECIAL (GOMP_MAP_FLAG_SPECIAL_1 \
44 | GOMP_MAP_FLAG_SPECIAL_0)
45/* Flag to force a specific behavior (or else, trigger a run-time error). */
46#define GOMP_MAP_FLAG_FORCE (1 << 7)
47
48enum gomp_map_kind
49 {
50 /* If not already present, allocate. */
51 GOMP_MAP_ALLOC = 0,
52 /* ..., and copy to device. */
53 GOMP_MAP_TO = (GOMP_MAP_ALLOC | GOMP_MAP_FLAG_TO),
54 /* ..., and copy from device. */
55 GOMP_MAP_FROM = (GOMP_MAP_ALLOC | GOMP_MAP_FLAG_FROM),
56 /* ..., and copy to and from device. */
57 GOMP_MAP_TOFROM = (GOMP_MAP_TO | GOMP_MAP_FROM),
58 /* The following kind is an internal only map kind, used for pointer based
59 array sections. OMP_CLAUSE_SIZE for these is not the pointer size,
60 which is implicitly POINTER_SIZE_UNITS, but the bias. */
61 GOMP_MAP_POINTER = (GOMP_MAP_FLAG_SPECIAL_0 | 0),
62 /* Also internal, behaves like GOMP_MAP_TO, but additionally any
63 GOMP_MAP_POINTER records consecutive after it which have addresses
64 falling into that range will not be ignored if GOMP_MAP_TO_PSET wasn't
65 mapped already. */
66 GOMP_MAP_TO_PSET = (GOMP_MAP_FLAG_SPECIAL_0 | 1),
67 /* Must already be present. */
68 GOMP_MAP_FORCE_PRESENT = (GOMP_MAP_FLAG_SPECIAL_0 | 2),
69 /* Deallocate a mapping, without copying from device. */
70 GOMP_MAP_FORCE_DEALLOC = (GOMP_MAP_FLAG_SPECIAL_0 | 3),
71 /* Is a device pointer. OMP_CLAUSE_SIZE for these is unused; is implicitly
72 POINTER_SIZE_UNITS. */
73 GOMP_MAP_FORCE_DEVICEPTR = (GOMP_MAP_FLAG_SPECIAL_1 | 0),
43895be5 74 /* Do not map, copy bits for firstprivate instead. */
75 GOMP_MAP_FIRSTPRIVATE = (GOMP_MAP_FLAG_SPECIAL | 0),
76 /* Similarly, but store the value in the pointer rather than
77 pointed by the pointer. */
78 GOMP_MAP_FIRSTPRIVATE_INT = (GOMP_MAP_FLAG_SPECIAL | 1),
79 /* Pointer translate host address into device address and copy that
80 back to host. */
81 GOMP_MAP_USE_DEVICE_PTR = (GOMP_MAP_FLAG_SPECIAL | 2),
82 /* Allocate a zero length array section. Prefer next non-zero length
83 mapping over previous non-zero length mapping over zero length mapping
84 at the address. If not already mapped, do nothing (and pointer translate
85 to NULL). */
86 GOMP_MAP_ZERO_LEN_ARRAY_SECTION = (GOMP_MAP_FLAG_SPECIAL | 3),
ca4c3545 87 /* Allocate. */
88 GOMP_MAP_FORCE_ALLOC = (GOMP_MAP_FLAG_FORCE | GOMP_MAP_ALLOC),
89 /* ..., and copy to device. */
90 GOMP_MAP_FORCE_TO = (GOMP_MAP_FLAG_FORCE | GOMP_MAP_TO),
91 /* ..., and copy from device. */
92 GOMP_MAP_FORCE_FROM = (GOMP_MAP_FLAG_FORCE | GOMP_MAP_FROM),
93 /* ..., and copy to and from device. */
43895be5 94 GOMP_MAP_FORCE_TOFROM = (GOMP_MAP_FLAG_FORCE | GOMP_MAP_TOFROM),
95 /* If not already present, allocate. And unconditionally copy to
96 device. */
9561765e 97 GOMP_MAP_ALWAYS_TO = (GOMP_MAP_FLAG_SPECIAL_2 | GOMP_MAP_TO),
43895be5 98 /* If not already present, allocate. And unconditionally copy from
99 device. */
9561765e 100 GOMP_MAP_ALWAYS_FROM = (GOMP_MAP_FLAG_SPECIAL_2
101 | GOMP_MAP_FROM),
43895be5 102 /* If not already present, allocate. And unconditionally copy to and from
103 device. */
9561765e 104 GOMP_MAP_ALWAYS_TOFROM = (GOMP_MAP_FLAG_SPECIAL_2
105 | GOMP_MAP_TOFROM),
43895be5 106 /* Map a sparse struct; the address is the base of the structure, alignment
107 it's required alignment, and size is the number of adjacent entries
108 that belong to the struct. The adjacent entries should be sorted by
109 increasing address, so it is easy to determine lowest needed address
110 (address of the first adjacent entry) and highest needed address
111 (address of the last adjacent entry plus its size). */
9561765e 112 GOMP_MAP_STRUCT = (GOMP_MAP_FLAG_SPECIAL_2
43895be5 113 | GOMP_MAP_FLAG_SPECIAL | 0),
9561765e 114 /* On a location of a pointer/reference that is assumed to be already mapped
115 earlier, store the translated address of the preceeding mapping.
116 No refcount is bumped by this, and the store is done unconditionally. */
117 GOMP_MAP_ALWAYS_POINTER = (GOMP_MAP_FLAG_SPECIAL_2
118 | GOMP_MAP_FLAG_SPECIAL | 1),
43895be5 119 /* Forced deallocation of zero length array section. */
120 GOMP_MAP_DELETE_ZERO_LEN_ARRAY_SECTION
9561765e 121 = (GOMP_MAP_FLAG_SPECIAL_2
43895be5 122 | GOMP_MAP_FLAG_SPECIAL | 3),
9561765e 123 /* OpenMP 4.5 alias for forced deallocation. */
43895be5 124 GOMP_MAP_DELETE = GOMP_MAP_FORCE_DEALLOC,
125 /* Decrement usage count and deallocate if zero. */
9561765e 126 GOMP_MAP_RELEASE = (GOMP_MAP_FLAG_SPECIAL_2
43895be5 127 | GOMP_MAP_FORCE_DEALLOC),
128
129 /* Internal to GCC, not used in libgomp. */
130 /* Do not map, but pointer assign a pointer instead. */
9561765e 131 GOMP_MAP_FIRSTPRIVATE_POINTER = (GOMP_MAP_LAST | 1),
132 /* Do not map, but pointer assign a reference instead. */
133 GOMP_MAP_FIRSTPRIVATE_REFERENCE = (GOMP_MAP_LAST | 2)
ca4c3545 134 };
135
136#define GOMP_MAP_COPY_TO_P(X) \
137 (!((X) & GOMP_MAP_FLAG_SPECIAL) \
138 && ((X) & GOMP_MAP_FLAG_TO))
139
140#define GOMP_MAP_COPY_FROM_P(X) \
141 (!((X) & GOMP_MAP_FLAG_SPECIAL) \
142 && ((X) & GOMP_MAP_FLAG_FROM))
143
144#define GOMP_MAP_POINTER_P(X) \
145 ((X) == GOMP_MAP_POINTER)
146
43895be5 147#define GOMP_MAP_ALWAYS_TO_P(X) \
148 (((X) == GOMP_MAP_ALWAYS_TO) || ((X) == GOMP_MAP_ALWAYS_TOFROM))
149
150#define GOMP_MAP_ALWAYS_FROM_P(X) \
151 (((X) == GOMP_MAP_ALWAYS_FROM) || ((X) == GOMP_MAP_ALWAYS_TOFROM))
152
9561765e 153#define GOMP_MAP_ALWAYS_P(X) \
154 (GOMP_MAP_ALWAYS_TO_P (X) || ((X) == GOMP_MAP_ALWAYS_FROM))
155
ca4c3545 156
157/* Asynchronous behavior. Keep in sync with
158 libgomp/{openacc.h,openacc.f90,openacc_lib.h}:acc_async_t. */
159
160#define GOMP_ASYNC_NOVAL -1
161#define GOMP_ASYNC_SYNC -2
162
163
164/* Device codes. Keep in sync with
165 libgomp/{openacc.h,openacc.f90,openacc_lib.h}:acc_device_t as well as
f212338e 166 libgomp/libgomp-plugin.h. */
ca4c3545 167#define GOMP_DEVICE_NONE 0
168#define GOMP_DEVICE_DEFAULT 1
169#define GOMP_DEVICE_HOST 2
f212338e 170/* #define GOMP_DEVICE_HOST_NONSHM 3 removed. */
ca4c3545 171#define GOMP_DEVICE_NOT_HOST 4
172#define GOMP_DEVICE_NVIDIA_PTX 5
173#define GOMP_DEVICE_INTEL_MIC 6
174
175#define GOMP_DEVICE_ICV -1
176#define GOMP_DEVICE_HOST_FALLBACK -2
177
43895be5 178/* GOMP_task/GOMP_taskloop* flags argument. */
179#define GOMP_TASK_FLAG_UNTIED (1 << 0)
180#define GOMP_TASK_FLAG_FINAL (1 << 1)
181#define GOMP_TASK_FLAG_MERGEABLE (1 << 2)
182#define GOMP_TASK_FLAG_DEPEND (1 << 3)
183#define GOMP_TASK_FLAG_PRIORITY (1 << 4)
184#define GOMP_TASK_FLAG_UP (1 << 8)
185#define GOMP_TASK_FLAG_GRAINSIZE (1 << 9)
186#define GOMP_TASK_FLAG_IF (1 << 10)
187#define GOMP_TASK_FLAG_NOGROUP (1 << 11)
188
9561765e 189/* GOMP_target{_ext,update_ext,enter_exit_data} flags argument. */
43895be5 190#define GOMP_TARGET_FLAG_NOWAIT (1 << 0)
191#define GOMP_TARGET_FLAG_EXIT_DATA (1 << 1)
192/* Internal to libgomp. */
193#define GOMP_TARGET_FLAG_UPDATE (1U << 31)
194
d3d8e632 195/* Versions of libgomp and device-specific plugins. */
196#define GOMP_VERSION 0
e561d5e1 197#define GOMP_VERSION_NVIDIA_PTX 1
d3d8e632 198#define GOMP_VERSION_INTEL_MIC 0
199
200#define GOMP_VERSION_PACK(LIB, DEV) (((LIB) << 16) | (DEV))
201#define GOMP_VERSION_LIB(PACK) (((PACK) >> 16) & 0xffff)
202#define GOMP_VERSION_DEV(PACK) ((PACK) & 0xffff)
203
e561d5e1 204#define GOMP_DIM_GANG 0
205#define GOMP_DIM_WORKER 1
206#define GOMP_DIM_VECTOR 2
207#define GOMP_DIM_MAX 3
208#define GOMP_DIM_MASK(X) (1u << (X))
209
210/* Varadic launch arguments. End of list is marked by a zero. */
211#define GOMP_LAUNCH_DIM 1 /* Launch dimensions, op = mask */
212#define GOMP_LAUNCH_ASYNC 2 /* Async, op = cst val if not MAX */
213#define GOMP_LAUNCH_WAIT 3 /* Waits, op = num waits. */
214#define GOMP_LAUNCH_CODE_SHIFT 28
215#define GOMP_LAUNCH_DEVICE_SHIFT 16
216#define GOMP_LAUNCH_OP_SHIFT 0
217#define GOMP_LAUNCH_PACK(CODE,DEVICE,OP) \
218 (((CODE) << GOMP_LAUNCH_CODE_SHIFT) \
219 | ((DEVICE) << GOMP_LAUNCH_DEVICE_SHIFT) \
220 | ((OP) << GOMP_LAUNCH_OP_SHIFT))
221#define GOMP_LAUNCH_CODE(X) (((X) >> GOMP_LAUNCH_CODE_SHIFT) & 0xf)
222#define GOMP_LAUNCH_DEVICE(X) (((X) >> GOMP_LAUNCH_DEVICE_SHIFT) & 0xfff)
223#define GOMP_LAUNCH_OP(X) (((X) >> GOMP_LAUNCH_OP_SHIFT) & 0xffff)
224#define GOMP_LAUNCH_OP_MAX 0xffff
225
ca4c3545 226#endif