Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 1 | //===- OMPConstants.h - OpenMP related constants and helpers ------ C++ -*-===// |
2 | // |
||
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
||
4 | // See https://llvm.org/LICENSE.txt for license information. |
||
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
||
6 | // |
||
7 | //===----------------------------------------------------------------------===// |
||
8 | /// \file |
||
9 | /// |
||
10 | /// This file defines constans and helpers used when dealing with OpenMP. |
||
11 | /// |
||
12 | //===----------------------------------------------------------------------===// |
||
13 | |||
14 | #ifndef LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H |
||
15 | #define LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H |
||
16 | |||
17 | #include "llvm/ADT/BitmaskEnum.h" |
||
18 | |||
19 | #include "llvm/ADT/StringRef.h" |
||
20 | #include "llvm/Frontend/OpenMP/OMP.h.inc" |
||
21 | |||
22 | namespace llvm { |
||
23 | namespace omp { |
||
24 | LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); |
||
25 | |||
26 | /// IDs for all Internal Control Variables (ICVs). |
||
27 | enum class InternalControlVar { |
||
28 | #define ICV_DATA_ENV(Enum, ...) Enum, |
||
29 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
30 | }; |
||
31 | |||
32 | #define ICV_DATA_ENV(Enum, ...) \ |
||
33 | constexpr auto Enum = omp::InternalControlVar::Enum; |
||
34 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
35 | |||
36 | enum class ICVInitValue { |
||
37 | #define ICV_INIT_VALUE(Enum, Name) Enum, |
||
38 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
39 | }; |
||
40 | |||
41 | #define ICV_INIT_VALUE(Enum, Name) \ |
||
42 | constexpr auto Enum = omp::ICVInitValue::Enum; |
||
43 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
44 | |||
45 | /// IDs for all omp runtime library (RTL) functions. |
||
46 | enum class RuntimeFunction { |
||
47 | #define OMP_RTL(Enum, ...) Enum, |
||
48 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
49 | }; |
||
50 | |||
51 | #define OMP_RTL(Enum, ...) constexpr auto Enum = omp::RuntimeFunction::Enum; |
||
52 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
53 | |||
54 | /// IDs for the different default kinds. |
||
55 | enum class DefaultKind { |
||
56 | #define OMP_DEFAULT_KIND(Enum, Str) Enum, |
||
57 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
58 | }; |
||
59 | |||
60 | #define OMP_DEFAULT_KIND(Enum, ...) \ |
||
61 | constexpr auto Enum = omp::DefaultKind::Enum; |
||
62 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
63 | |||
64 | /// IDs for all omp runtime library ident_t flag encodings (see |
||
65 | /// their defintion in openmp/runtime/src/kmp.h). |
||
66 | enum class IdentFlag { |
||
67 | #define OMP_IDENT_FLAG(Enum, Str, Value) Enum = Value, |
||
68 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
69 | LLVM_MARK_AS_BITMASK_ENUM(0x7FFFFFFF) |
||
70 | }; |
||
71 | |||
72 | #define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum; |
||
73 | #include "llvm/Frontend/OpenMP/OMPKinds.def" |
||
74 | |||
75 | /// \note This needs to be kept in sync with kmp.h enum sched_type. |
||
76 | /// Todo: Update kmp.h to include this file, and remove the enums in kmp.h |
||
77 | enum class OMPScheduleType { |
||
78 | // For typed comparisons, not a valid schedule |
||
79 | None = 0, |
||
80 | |||
81 | // Schedule algorithms |
||
82 | BaseStaticChunked = 1, |
||
83 | BaseStatic = 2, |
||
84 | BaseDynamicChunked = 3, |
||
85 | BaseGuidedChunked = 4, |
||
86 | BaseRuntime = 5, |
||
87 | BaseAuto = 6, |
||
88 | BaseTrapezoidal = 7, |
||
89 | BaseGreedy = 8, |
||
90 | BaseBalanced = 9, |
||
91 | BaseGuidedIterativeChunked = 10, |
||
92 | BaseGuidedAnalyticalChunked = 11, |
||
93 | BaseSteal = 12, |
||
94 | |||
95 | // with chunk adjustment (e.g., simd) |
||
96 | BaseStaticBalancedChunked = 13, |
||
97 | BaseGuidedSimd = 14, |
||
98 | BaseRuntimeSimd = 15, |
||
99 | |||
100 | // static schedules algorithims for distribute |
||
101 | BaseDistributeChunked = 27, |
||
102 | BaseDistribute = 28, |
||
103 | |||
104 | // Modifier flags to be combined with schedule algorithms |
||
105 | ModifierUnordered = (1 << 5), |
||
106 | ModifierOrdered = (1 << 6), |
||
107 | ModifierNomerge = (1 << 7), |
||
108 | ModifierMonotonic = (1 << 29), |
||
109 | ModifierNonmonotonic = (1 << 30), |
||
110 | |||
111 | // Masks combining multiple flags |
||
112 | OrderingMask = ModifierUnordered | ModifierOrdered | ModifierNomerge, |
||
113 | MonotonicityMask = ModifierMonotonic | ModifierNonmonotonic, |
||
114 | ModifierMask = OrderingMask | MonotonicityMask, |
||
115 | |||
116 | // valid schedule type values, without monotonicity flags |
||
117 | UnorderedStaticChunked = BaseStaticChunked | ModifierUnordered, // 33 |
||
118 | UnorderedStatic = BaseStatic | ModifierUnordered, // 34 |
||
119 | UnorderedDynamicChunked = BaseDynamicChunked | ModifierUnordered, // 35 |
||
120 | UnorderedGuidedChunked = BaseGuidedChunked | ModifierUnordered, // 36 |
||
121 | UnorderedRuntime = BaseRuntime | ModifierUnordered, // 37 |
||
122 | UnorderedAuto = BaseAuto | ModifierUnordered, // 38 |
||
123 | UnorderedTrapezoidal = BaseTrapezoidal | ModifierUnordered, // 39 |
||
124 | UnorderedGreedy = BaseGreedy | ModifierUnordered, // 40 |
||
125 | UnorderedBalanced = BaseBalanced | ModifierUnordered, // 41 |
||
126 | UnorderedGuidedIterativeChunked = |
||
127 | BaseGuidedIterativeChunked | ModifierUnordered, // 42 |
||
128 | UnorderedGuidedAnalyticalChunked = |
||
129 | BaseGuidedAnalyticalChunked | ModifierUnordered, // 43 |
||
130 | UnorderedSteal = BaseSteal | ModifierUnordered, // 44 |
||
131 | |||
132 | UnorderedStaticBalancedChunked = |
||
133 | BaseStaticBalancedChunked | ModifierUnordered, // 45 |
||
134 | UnorderedGuidedSimd = BaseGuidedSimd | ModifierUnordered, // 46 |
||
135 | UnorderedRuntimeSimd = BaseRuntimeSimd | ModifierUnordered, // 47 |
||
136 | |||
137 | OrderedStaticChunked = BaseStaticChunked | ModifierOrdered, // 65 |
||
138 | OrderedStatic = BaseStatic | ModifierOrdered, // 66 |
||
139 | OrderedDynamicChunked = BaseDynamicChunked | ModifierOrdered, // 67 |
||
140 | OrderedGuidedChunked = BaseGuidedChunked | ModifierOrdered, // 68 |
||
141 | OrderedRuntime = BaseRuntime | ModifierOrdered, // 69 |
||
142 | OrderedAuto = BaseAuto | ModifierOrdered, // 70 |
||
143 | OrderdTrapezoidal = BaseTrapezoidal | ModifierOrdered, // 71 |
||
144 | |||
145 | OrderedDistributeChunked = BaseDistributeChunked | ModifierOrdered, // 91 |
||
146 | OrderedDistribute = BaseDistribute | ModifierOrdered, // 92 |
||
147 | |||
148 | NomergeUnorderedStaticChunked = |
||
149 | BaseStaticChunked | ModifierUnordered | ModifierNomerge, // 161 |
||
150 | NomergeUnorderedStatic = |
||
151 | BaseStatic | ModifierUnordered | ModifierNomerge, // 162 |
||
152 | NomergeUnorderedDynamicChunked = |
||
153 | BaseDynamicChunked | ModifierUnordered | ModifierNomerge, // 163 |
||
154 | NomergeUnorderedGuidedChunked = |
||
155 | BaseGuidedChunked | ModifierUnordered | ModifierNomerge, // 164 |
||
156 | NomergeUnorderedRuntime = |
||
157 | BaseRuntime | ModifierUnordered | ModifierNomerge, // 165 |
||
158 | NomergeUnorderedAuto = BaseAuto | ModifierUnordered | ModifierNomerge, // 166 |
||
159 | NomergeUnorderedTrapezoidal = |
||
160 | BaseTrapezoidal | ModifierUnordered | ModifierNomerge, // 167 |
||
161 | NomergeUnorderedGreedy = |
||
162 | BaseGreedy | ModifierUnordered | ModifierNomerge, // 168 |
||
163 | NomergeUnorderedBalanced = |
||
164 | BaseBalanced | ModifierUnordered | ModifierNomerge, // 169 |
||
165 | NomergeUnorderedGuidedIterativeChunked = |
||
166 | BaseGuidedIterativeChunked | ModifierUnordered | ModifierNomerge, // 170 |
||
167 | NomergeUnorderedGuidedAnalyticalChunked = |
||
168 | BaseGuidedAnalyticalChunked | ModifierUnordered | ModifierNomerge, // 171 |
||
169 | NomergeUnorderedSteal = |
||
170 | BaseSteal | ModifierUnordered | ModifierNomerge, // 172 |
||
171 | |||
172 | NomergeOrderedStaticChunked = |
||
173 | BaseStaticChunked | ModifierOrdered | ModifierNomerge, // 193 |
||
174 | NomergeOrderedStatic = BaseStatic | ModifierOrdered | ModifierNomerge, // 194 |
||
175 | NomergeOrderedDynamicChunked = |
||
176 | BaseDynamicChunked | ModifierOrdered | ModifierNomerge, // 195 |
||
177 | NomergeOrderedGuidedChunked = |
||
178 | BaseGuidedChunked | ModifierOrdered | ModifierNomerge, // 196 |
||
179 | NomergeOrderedRuntime = |
||
180 | BaseRuntime | ModifierOrdered | ModifierNomerge, // 197 |
||
181 | NomergeOrderedAuto = BaseAuto | ModifierOrdered | ModifierNomerge, // 198 |
||
182 | NomergeOrderedTrapezoidal = |
||
183 | BaseTrapezoidal | ModifierOrdered | ModifierNomerge, // 199 |
||
184 | |||
185 | LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue */ ModifierMask) |
||
186 | }; |
||
187 | |||
188 | /// Values for bit flags used to specify the mapping type for |
||
189 | /// offloading. |
||
190 | enum class OpenMPOffloadMappingFlags : uint64_t { |
||
191 | /// No flags |
||
192 | OMP_MAP_NONE = 0x0, |
||
193 | /// Allocate memory on the device and move data from host to device. |
||
194 | OMP_MAP_TO = 0x01, |
||
195 | /// Allocate memory on the device and move data from device to host. |
||
196 | OMP_MAP_FROM = 0x02, |
||
197 | /// Always perform the requested mapping action on the element, even |
||
198 | /// if it was already mapped before. |
||
199 | OMP_MAP_ALWAYS = 0x04, |
||
200 | /// Delete the element from the device environment, ignoring the |
||
201 | /// current reference count associated with the element. |
||
202 | OMP_MAP_DELETE = 0x08, |
||
203 | /// The element being mapped is a pointer-pointee pair; both the |
||
204 | /// pointer and the pointee should be mapped. |
||
205 | OMP_MAP_PTR_AND_OBJ = 0x10, |
||
206 | /// This flags signals that the base address of an entry should be |
||
207 | /// passed to the target kernel as an argument. |
||
208 | OMP_MAP_TARGET_PARAM = 0x20, |
||
209 | /// Signal that the runtime library has to return the device pointer |
||
210 | /// in the current position for the data being mapped. Used when we have the |
||
211 | /// use_device_ptr or use_device_addr clause. |
||
212 | OMP_MAP_RETURN_PARAM = 0x40, |
||
213 | /// This flag signals that the reference being passed is a pointer to |
||
214 | /// private data. |
||
215 | OMP_MAP_PRIVATE = 0x80, |
||
216 | /// Pass the element to the device by value. |
||
217 | OMP_MAP_LITERAL = 0x100, |
||
218 | /// Implicit map |
||
219 | OMP_MAP_IMPLICIT = 0x200, |
||
220 | /// Close is a hint to the runtime to allocate memory close to |
||
221 | /// the target device. |
||
222 | OMP_MAP_CLOSE = 0x400, |
||
223 | /// 0x800 is reserved for compatibility with XLC. |
||
224 | /// Produce a runtime error if the data is not already allocated. |
||
225 | OMP_MAP_PRESENT = 0x1000, |
||
226 | // Increment and decrement a separate reference counter so that the data |
||
227 | // cannot be unmapped within the associated region. Thus, this flag is |
||
228 | // intended to be used on 'target' and 'target data' directives because they |
||
229 | // are inherently structured. It is not intended to be used on 'target |
||
230 | // enter data' and 'target exit data' directives because they are inherently |
||
231 | // dynamic. |
||
232 | // This is an OpenMP extension for the sake of OpenACC support. |
||
233 | OMP_MAP_OMPX_HOLD = 0x2000, |
||
234 | /// Signal that the runtime library should use args as an array of |
||
235 | /// descriptor_dim pointers and use args_size as dims. Used when we have |
||
236 | /// non-contiguous list items in target update directive |
||
237 | OMP_MAP_NON_CONTIG = 0x100000000000, |
||
238 | /// The 16 MSBs of the flags indicate whether the entry is member of some |
||
239 | /// struct/class. |
||
240 | OMP_MAP_MEMBER_OF = 0xffff000000000000, |
||
241 | LLVM_MARK_AS_BITMASK_ENUM(/* LargestFlag = */ OMP_MAP_MEMBER_OF) |
||
242 | }; |
||
243 | |||
244 | enum class AddressSpace : unsigned { |
||
245 | Generic = 0, |
||
246 | Global = 1, |
||
247 | Shared = 3, |
||
248 | Constant = 4, |
||
249 | Local = 5, |
||
250 | }; |
||
251 | |||
252 | /// \note This needs to be kept in sync with interop.h enum kmp_interop_type_t.: |
||
253 | enum class OMPInteropType { Unknown, Target, TargetSync }; |
||
254 | |||
255 | /// Atomic compare operations. Currently OpenMP only supports ==, >, and <. |
||
256 | enum class OMPAtomicCompareOp : unsigned { EQ, MIN, MAX }; |
||
257 | |||
258 | /// Fields ids in kmp_depend_info record. |
||
259 | enum class RTLDependInfoFields { BaseAddr, Len, Flags }; |
||
260 | |||
261 | /// Dependence kind for RTL. |
||
262 | enum class RTLDependenceKindTy { |
||
263 | DepUnknown = 0x0, |
||
264 | DepIn = 0x01, |
||
265 | DepInOut = 0x3, |
||
266 | DepMutexInOutSet = 0x4, |
||
267 | DepInOutSet = 0x8, |
||
268 | DepOmpAllMem = 0x80, |
||
269 | }; |
||
270 | |||
271 | } // end namespace omp |
||
272 | |||
273 | } // end namespace llvm |
||
274 | |||
275 | #include "OMPDeviceConstants.h" |
||
276 | |||
277 | #endif // LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H |