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// Default OpenMP mapper name suffix.
194inline constexpr const char *OmpDefaultMapperName = ".omp.default.mapper";
195
196/// Values for bit flags used to specify the mapping type for
197/// offloading.
199 /// No flags
201 /// Allocate memory on the device and move data from host to device.
203 /// Allocate memory on the device and move data from device to host.
205 /// Always perform the requested mapping action on the element, even
206 /// if it was already mapped before.
208 /// Delete the element from the device environment, ignoring the
209 /// current reference count associated with the element.
211 /// The element being mapped is a pointer-pointee pair; both the
212 /// pointer and the pointee should be mapped.
214 /// This flags signals that the base address of an entry should be
215 /// passed to the target kernel as an argument.
217 /// Signal that the runtime library has to return the device pointer
218 /// in the current position for the data being mapped. Used when we have the
219 /// use_device_ptr or use_device_addr clause.
221 /// This flag signals that the reference being passed is a pointer to
222 /// private data.
224 /// Pass the element to the device by value.
226 /// Implicit map
228 /// Close is a hint to the runtime to allocate memory close to
229 /// the target device.
231 /// 0x800 is reserved for compatibility with XLC.
232 /// Produce a runtime error if the data is not already allocated.
234 // Increment and decrement a separate reference counter so that the data
235 // cannot be unmapped within the associated region. Thus, this flag is
236 // intended to be used on 'target' and 'target data' directives because they
237 // are inherently structured. It is not intended to be used on 'target
238 // enter data' and 'target exit data' directives because they are inherently
239 // dynamic.
240 // This is an OpenMP extension for the sake of OpenACC support.
242 /// Signal that the runtime library should use args as an array of
243 /// descriptor_dim pointers and use args_size as dims. Used when we have
244 /// non-contiguous list items in target update directive
245 OMP_MAP_NON_CONTIG = 0x100000000000,
246 /// The 16 MSBs of the flags indicate whether the entry is member of some
247 /// struct/class.
248 OMP_MAP_MEMBER_OF = 0xffff000000000000,
250};
251
253 /// Device ID if the device was not defined, runtime should get it
254 /// from environment variables in the spec.
256};
257
258enum class AddressSpace : unsigned {
263 Local = 5,
264};
265
266/// \note This needs to be kept in sync with interop.h enum kmp_interop_type_t.:
268
269/// Atomic compare operations. Currently OpenMP only supports ==, >, and <.
270enum class OMPAtomicCompareOp : unsigned { EQ, MIN, MAX };
271
272/// Fields ids in kmp_depend_info record.
274
275/// Dependence kind for RTL.
284
285/// A type of worksharing loop construct
287 // Worksharing `for`-loop
289 // Worksharing `distrbute`-loop
291 // Worksharing `distrbute parallel for`-loop
293};
294
295} // end namespace omp
296
297} // end namespace llvm
298
299#include "OMPDeviceConstants.h"
300
301#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()
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