LLVM 22.0.0git
OMPConstants.h
Go to the documentation of this file.
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
18#include "llvm/ADT/StringRef.h"
20
21namespace llvm {
22namespace omp {
24
25/// IDs for all Internal Control Variables (ICVs).
27#define ICV_DATA_ENV(Enum, ...) Enum,
28#include "llvm/Frontend/OpenMP/OMPKinds.def"
29};
30
31#define ICV_DATA_ENV(Enum, ...) \
32 constexpr auto Enum = omp::InternalControlVar::Enum;
33#include "llvm/Frontend/OpenMP/OMPKinds.def"
34
35enum class ICVInitValue {
36#define ICV_INIT_VALUE(Enum, Name) Enum,
37#include "llvm/Frontend/OpenMP/OMPKinds.def"
38};
39
40#define ICV_INIT_VALUE(Enum, Name) \
41 constexpr auto Enum = omp::ICVInitValue::Enum;
42#include "llvm/Frontend/OpenMP/OMPKinds.def"
43
44/// IDs for all omp runtime library (RTL) functions.
45enum class RuntimeFunction {
46#define OMP_RTL(Enum, ...) Enum,
47#include "llvm/Frontend/OpenMP/OMPKinds.def"
48};
49
50#define OMP_RTL(Enum, ...) constexpr auto Enum = omp::RuntimeFunction::Enum;
51#include "llvm/Frontend/OpenMP/OMPKinds.def"
52
53/// IDs for the different default kinds.
54enum class DefaultKind {
55#define OMP_DEFAULT_KIND(Enum, Str) Enum,
56#include "llvm/Frontend/OpenMP/OMPKinds.def"
57};
58
59#define OMP_DEFAULT_KIND(Enum, ...) \
60 constexpr auto Enum = omp::DefaultKind::Enum;
61#include "llvm/Frontend/OpenMP/OMPKinds.def"
62
63/// IDs for all omp runtime library ident_t flag encodings (see
64/// their defintion in openmp/runtime/src/kmp.h).
65enum class IdentFlag {
66#define OMP_IDENT_FLAG(Enum, Str, Value) Enum = Value,
67#include "llvm/Frontend/OpenMP/OMPKinds.def"
69};
70
71#define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum;
72#include "llvm/Frontend/OpenMP/OMPKinds.def"
73
74// Version of the kernel argument format used by the omp runtime.
75#define OMP_KERNEL_ARG_VERSION 3
76
77// Minimum version of the compiler that generates a kernel dynamic pointer.
78#define OMP_KERNEL_ARG_MIN_VERSION_WITH_DYN_PTR 3
79
80/// \note This needs to be kept in sync with kmp.h enum sched_type.
81/// Todo: Update kmp.h to include this file, and remove the enums in kmp.h
82enum class OMPScheduleType {
83 // For typed comparisons, not a valid schedule
84 None = 0,
85
86 // Schedule algorithms
99
100 // with chunk adjustment (e.g., simd)
104
105 // static schedules algorithims for distribute
108
109 // Modifier flags to be combined with schedule algorithms
111 ModifierOrdered = (1 << 6),
112 ModifierNomerge = (1 << 7),
113 ModifierMonotonic = (1 << 29),
115
116 // Masks combining multiple flags
120
121 // valid schedule type values, without monotonicity flags
136
141
149
152
176
189
190 LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue */ ModifierMask)
191};
192
193/// The fallback types for the dyn_groupprivate clause.
195 /// Abort the execution.
196 Abort = 0,
197 /// Return null pointer.
198 Null = 1,
199 /// Allocate from a implementation defined memory space.
201};
202
203// Default OpenMP mapper name suffix.
204inline constexpr const char *OmpDefaultMapperName = "_omp_default_mapper";
205
206/// Values for bit flags used to specify the mapping type for
207/// offloading.
209 /// No flags
211 /// Allocate memory on the device and move data from host to device.
213 /// Allocate memory on the device and move data from device to host.
215 /// Always perform the requested mapping action on the element, even
216 /// if it was already mapped before.
218 /// Delete the element from the device environment, ignoring the
219 /// current reference count associated with the element.
221 /// The element being mapped is a pointer-pointee pair; both the
222 /// pointer and the pointee should be mapped.
224 /// This flags signals that the base address of an entry should be
225 /// passed to the target kernel as an argument.
227 /// Signal that the runtime library has to return the device pointer
228 /// in the current position for the data being mapped. Used when we have the
229 /// use_device_ptr or use_device_addr clause.
231 /// This flag signals that the reference being passed is a pointer to
232 /// private data.
234 /// Pass the element to the device by value.
236 /// Implicit map
238 /// Close is a hint to the runtime to allocate memory close to
239 /// the target device.
241 /// 0x800 is reserved for compatibility with XLC.
242 /// Produce a runtime error if the data is not already allocated.
244 // Increment and decrement a separate reference counter so that the data
245 // cannot be unmapped within the associated region. Thus, this flag is
246 // intended to be used on 'target' and 'target data' directives because they
247 // are inherently structured. It is not intended to be used on 'target
248 // enter data' and 'target exit data' directives because they are inherently
249 // dynamic.
250 // This is an OpenMP extension for the sake of OpenACC support.
252 // Attach pointer and pointee, after processing all other maps.
253 // Applicable to map-entering directives. Does not change ref-count.
255 /// Signal that the runtime library should use args as an array of
256 /// descriptor_dim pointers and use args_size as dims. Used when we have
257 /// non-contiguous list items in target update directive
258 OMP_MAP_NON_CONTIG = 0x100000000000,
259 /// The 16 MSBs of the flags indicate whether the entry is member of some
260 /// struct/class.
261 OMP_MAP_MEMBER_OF = 0xffff000000000000,
263};
264
266 /// Device ID if the device was not defined, runtime should get it
267 /// from environment variables in the spec.
269};
270
271enum class AddressSpace : unsigned {
276 Local = 5,
277};
278
279/// \note This needs to be kept in sync with interop.h enum kmp_interop_type_t.:
281
282/// Atomic compare operations. Currently OpenMP only supports ==, >, and <.
283enum class OMPAtomicCompareOp : unsigned { EQ, MIN, MAX };
284
285/// Fields ids in kmp_depend_info record.
287
288/// Dependence kind for RTL.
297
298/// A type of worksharing loop construct
300 // Worksharing `for`-loop
302 // Worksharing `distrbute`-loop
304 // Worksharing `distrbute parallel for`-loop
306};
307
308} // end namespace omp
309
310} // end namespace llvm
311
312#include "OMPDeviceConstants.h"
313
314#endif // LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H
This file defines constans that will be used by both host and device compilation.
OpenMPOffloadMappingFlags
Values for bit flags used to specify the mapping type for offloading.
@ OMP_MAP_TO
Allocate memory on the device and move data from host to device.
@ OMP_MAP_NON_CONTIG
Signal that the runtime library should use args as an array of descriptor_dim pointers and use args_s...
@ OMP_MAP_LITERAL
Pass the element to the device by value.
@ OMP_MAP_RETURN_PARAM
Signal that the runtime library has to return the device pointer in the current position for the data...
@ OMP_MAP_PTR_AND_OBJ
The element being mapped is a pointer-pointee pair; both the pointer and the pointee should be mapped...
@ OMP_MAP_TARGET_PARAM
This flags signals that the base address of an entry should be passed to the target kernel as an argu...
@ OMP_MAP_PRESENT
0x800 is reserved for compatibility with XLC.
@ OMP_MAP_CLOSE
Close is a hint to the runtime to allocate memory close to the target device.
@ OMP_MAP_PRIVATE
This flag signals that the reference being passed is a pointer to private data.
@ OMP_MAP_MEMBER_OF
The 16 MSBs of the flags indicate whether the entry is member of some struct/class.
@ OMP_MAP_DELETE
Delete the element from the device environment, ignoring the current reference count associated with ...
@ OMP_MAP_ALWAYS
Always perform the requested mapping action on the element, even if it was already mapped before.
@ OMP_MAP_FROM
Allocate memory on the device and move data from device to host.
OpenMPOffloadingReservedDeviceIDs
@ OMP_DEVICEID_UNDEF
Device ID if the device was not defined, runtime should get it from environment variables in the spec...
IdentFlag
IDs for all omp runtime library ident_t flag encodings (see their defintion in openmp/runtime/src/kmp...
RTLDependInfoFields
Fields ids in kmp_depend_info record.
RTLDependenceKindTy
Dependence kind for RTL.
InternalControlVar
IDs for all Internal Control Variables (ICVs).
RuntimeFunction
IDs for all omp runtime library (RTL) functions.
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
OMPDynGroupprivateFallbackType
The fallback types for the dyn_groupprivate clause.
@ DefaultMem
Allocate from a implementation defined memory space.
WorksharingLoopType
A type of worksharing loop construct.
OMPAtomicCompareOp
Atomic compare operations. Currently OpenMP only supports ==, >, and <.
DefaultKind
IDs for the different default kinds.
constexpr const char * OmpDefaultMapperName
This is an optimization pass for GlobalISel generic memory operations.
@ LLVM_MARK_AS_BITMASK_ENUM
Definition ModRef.h:37