Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:55

0001 //===- OMPConstants.h - OpenMP related constants and helpers ------ C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 /// \file
0009 ///
0010 /// This file defines constans and helpers used when dealing with OpenMP.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H
0015 #define LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H
0016 
0017 #include "llvm/ADT/BitmaskEnum.h"
0018 #include "llvm/ADT/StringRef.h"
0019 #include "llvm/Frontend/OpenMP/OMP.h"
0020 
0021 namespace llvm {
0022 namespace omp {
0023 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
0024 
0025 /// IDs for all Internal Control Variables (ICVs).
0026 enum class InternalControlVar {
0027 #define ICV_DATA_ENV(Enum, ...) Enum,
0028 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0029 };
0030 
0031 #define ICV_DATA_ENV(Enum, ...)                                                \
0032   constexpr auto Enum = omp::InternalControlVar::Enum;
0033 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0034 
0035 enum class ICVInitValue {
0036 #define ICV_INIT_VALUE(Enum, Name) Enum,
0037 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0038 };
0039 
0040 #define ICV_INIT_VALUE(Enum, Name)                                             \
0041   constexpr auto Enum = omp::ICVInitValue::Enum;
0042 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0043 
0044 /// IDs for all omp runtime library (RTL) functions.
0045 enum class RuntimeFunction {
0046 #define OMP_RTL(Enum, ...) Enum,
0047 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0048 };
0049 
0050 #define OMP_RTL(Enum, ...) constexpr auto Enum = omp::RuntimeFunction::Enum;
0051 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0052 
0053 /// IDs for the different default kinds.
0054 enum class DefaultKind {
0055 #define OMP_DEFAULT_KIND(Enum, Str) Enum,
0056 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0057 };
0058 
0059 #define OMP_DEFAULT_KIND(Enum, ...)                                            \
0060   constexpr auto Enum = omp::DefaultKind::Enum;
0061 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0062 
0063 /// IDs for all omp runtime library ident_t flag encodings (see
0064 /// their defintion in openmp/runtime/src/kmp.h).
0065 enum class IdentFlag {
0066 #define OMP_IDENT_FLAG(Enum, Str, Value) Enum = Value,
0067 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0068   LLVM_MARK_AS_BITMASK_ENUM(0x7FFFFFFF)
0069 };
0070 
0071 #define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum;
0072 #include "llvm/Frontend/OpenMP/OMPKinds.def"
0073 
0074 // Version of the kernel argument format used by the omp runtime.
0075 #define OMP_KERNEL_ARG_VERSION 3
0076 
0077 // Minimum version of the compiler that generates a kernel dynamic pointer.
0078 #define OMP_KERNEL_ARG_MIN_VERSION_WITH_DYN_PTR 3
0079 
0080 /// \note This needs to be kept in sync with kmp.h enum sched_type.
0081 /// Todo: Update kmp.h to include this file, and remove the enums in kmp.h
0082 enum class OMPScheduleType {
0083   // For typed comparisons, not a valid schedule
0084   None = 0,
0085 
0086   // Schedule algorithms
0087   BaseStaticChunked = 1,
0088   BaseStatic = 2,
0089   BaseDynamicChunked = 3,
0090   BaseGuidedChunked = 4,
0091   BaseRuntime = 5,
0092   BaseAuto = 6,
0093   BaseTrapezoidal = 7,
0094   BaseGreedy = 8,
0095   BaseBalanced = 9,
0096   BaseGuidedIterativeChunked = 10,
0097   BaseGuidedAnalyticalChunked = 11,
0098   BaseSteal = 12,
0099 
0100   // with chunk adjustment (e.g., simd)
0101   BaseStaticBalancedChunked = 13,
0102   BaseGuidedSimd = 14,
0103   BaseRuntimeSimd = 15,
0104 
0105   // static schedules algorithims for distribute
0106   BaseDistributeChunked = 27,
0107   BaseDistribute = 28,
0108 
0109   // Modifier flags to be combined with schedule algorithms
0110   ModifierUnordered = (1 << 5),
0111   ModifierOrdered = (1 << 6),
0112   ModifierNomerge = (1 << 7),
0113   ModifierMonotonic = (1 << 29),
0114   ModifierNonmonotonic = (1 << 30),
0115 
0116   // Masks combining multiple flags
0117   OrderingMask = ModifierUnordered | ModifierOrdered | ModifierNomerge,
0118   MonotonicityMask = ModifierMonotonic | ModifierNonmonotonic,
0119   ModifierMask = OrderingMask | MonotonicityMask,
0120 
0121   // valid schedule type values, without monotonicity flags
0122   UnorderedStaticChunked = BaseStaticChunked | ModifierUnordered,        //  33
0123   UnorderedStatic = BaseStatic | ModifierUnordered,                      //  34
0124   UnorderedDynamicChunked = BaseDynamicChunked | ModifierUnordered,      //  35
0125   UnorderedGuidedChunked = BaseGuidedChunked | ModifierUnordered,        //  36
0126   UnorderedRuntime = BaseRuntime | ModifierUnordered,                    //  37
0127   UnorderedAuto = BaseAuto | ModifierUnordered,                          //  38
0128   UnorderedTrapezoidal = BaseTrapezoidal | ModifierUnordered,            //  39
0129   UnorderedGreedy = BaseGreedy | ModifierUnordered,                      //  40
0130   UnorderedBalanced = BaseBalanced | ModifierUnordered,                  //  41
0131   UnorderedGuidedIterativeChunked =
0132       BaseGuidedIterativeChunked | ModifierUnordered,                    //  42
0133   UnorderedGuidedAnalyticalChunked =
0134       BaseGuidedAnalyticalChunked | ModifierUnordered,                   //  43
0135   UnorderedSteal = BaseSteal | ModifierUnordered,                        //  44
0136 
0137   UnorderedStaticBalancedChunked =
0138       BaseStaticBalancedChunked | ModifierUnordered,                     //  45
0139   UnorderedGuidedSimd = BaseGuidedSimd | ModifierUnordered,              //  46
0140   UnorderedRuntimeSimd = BaseRuntimeSimd | ModifierUnordered,            //  47
0141 
0142   OrderedStaticChunked = BaseStaticChunked | ModifierOrdered,            //  65
0143   OrderedStatic = BaseStatic | ModifierOrdered,                          //  66
0144   OrderedDynamicChunked = BaseDynamicChunked | ModifierOrdered,          //  67
0145   OrderedGuidedChunked = BaseGuidedChunked | ModifierOrdered,            //  68
0146   OrderedRuntime = BaseRuntime | ModifierOrdered,                        //  69
0147   OrderedAuto = BaseAuto | ModifierOrdered,                              //  70
0148   OrderdTrapezoidal = BaseTrapezoidal | ModifierOrdered,                 //  71
0149 
0150   OrderedDistributeChunked = BaseDistributeChunked | ModifierOrdered,    //  91
0151   OrderedDistribute = BaseDistribute | ModifierOrdered,                  //  92
0152 
0153   NomergeUnorderedStaticChunked =
0154       BaseStaticChunked | ModifierUnordered | ModifierNomerge,           // 161
0155   NomergeUnorderedStatic =
0156       BaseStatic | ModifierUnordered | ModifierNomerge,                  // 162
0157   NomergeUnorderedDynamicChunked =
0158       BaseDynamicChunked | ModifierUnordered | ModifierNomerge,          // 163
0159   NomergeUnorderedGuidedChunked =
0160       BaseGuidedChunked | ModifierUnordered | ModifierNomerge,           // 164
0161   NomergeUnorderedRuntime =
0162       BaseRuntime | ModifierUnordered | ModifierNomerge,                 // 165
0163   NomergeUnorderedAuto = BaseAuto | ModifierUnordered | ModifierNomerge, // 166
0164   NomergeUnorderedTrapezoidal =
0165       BaseTrapezoidal | ModifierUnordered | ModifierNomerge,             // 167
0166   NomergeUnorderedGreedy =
0167       BaseGreedy | ModifierUnordered | ModifierNomerge,                  // 168
0168   NomergeUnorderedBalanced =
0169       BaseBalanced | ModifierUnordered | ModifierNomerge,                // 169
0170   NomergeUnorderedGuidedIterativeChunked =
0171       BaseGuidedIterativeChunked | ModifierUnordered | ModifierNomerge,  // 170
0172   NomergeUnorderedGuidedAnalyticalChunked =
0173       BaseGuidedAnalyticalChunked | ModifierUnordered | ModifierNomerge, // 171
0174   NomergeUnorderedSteal =
0175       BaseSteal | ModifierUnordered | ModifierNomerge,                   // 172
0176 
0177   NomergeOrderedStaticChunked =
0178       BaseStaticChunked | ModifierOrdered | ModifierNomerge,             // 193
0179   NomergeOrderedStatic = BaseStatic | ModifierOrdered | ModifierNomerge, // 194
0180   NomergeOrderedDynamicChunked =
0181       BaseDynamicChunked | ModifierOrdered | ModifierNomerge,            // 195
0182   NomergeOrderedGuidedChunked =
0183       BaseGuidedChunked | ModifierOrdered | ModifierNomerge,             // 196
0184   NomergeOrderedRuntime =
0185       BaseRuntime | ModifierOrdered | ModifierNomerge,                   // 197
0186   NomergeOrderedAuto = BaseAuto | ModifierOrdered | ModifierNomerge,     // 198
0187   NomergeOrderedTrapezoidal =
0188       BaseTrapezoidal | ModifierOrdered | ModifierNomerge,               // 199
0189 
0190   LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue */ ModifierMask)
0191 };
0192 
0193 /// Values for bit flags used to specify the mapping type for
0194 /// offloading.
0195 enum class OpenMPOffloadMappingFlags : uint64_t {
0196   /// No flags
0197   OMP_MAP_NONE = 0x0,
0198   /// Allocate memory on the device and move data from host to device.
0199   OMP_MAP_TO = 0x01,
0200   /// Allocate memory on the device and move data from device to host.
0201   OMP_MAP_FROM = 0x02,
0202   /// Always perform the requested mapping action on the element, even
0203   /// if it was already mapped before.
0204   OMP_MAP_ALWAYS = 0x04,
0205   /// Delete the element from the device environment, ignoring the
0206   /// current reference count associated with the element.
0207   OMP_MAP_DELETE = 0x08,
0208   /// The element being mapped is a pointer-pointee pair; both the
0209   /// pointer and the pointee should be mapped.
0210   OMP_MAP_PTR_AND_OBJ = 0x10,
0211   /// This flags signals that the base address of an entry should be
0212   /// passed to the target kernel as an argument.
0213   OMP_MAP_TARGET_PARAM = 0x20,
0214   /// Signal that the runtime library has to return the device pointer
0215   /// in the current position for the data being mapped. Used when we have the
0216   /// use_device_ptr or use_device_addr clause.
0217   OMP_MAP_RETURN_PARAM = 0x40,
0218   /// This flag signals that the reference being passed is a pointer to
0219   /// private data.
0220   OMP_MAP_PRIVATE = 0x80,
0221   /// Pass the element to the device by value.
0222   OMP_MAP_LITERAL = 0x100,
0223   /// Implicit map
0224   OMP_MAP_IMPLICIT = 0x200,
0225   /// Close is a hint to the runtime to allocate memory close to
0226   /// the target device.
0227   OMP_MAP_CLOSE = 0x400,
0228   /// 0x800 is reserved for compatibility with XLC.
0229   /// Produce a runtime error if the data is not already allocated.
0230   OMP_MAP_PRESENT = 0x1000,
0231   // Increment and decrement a separate reference counter so that the data
0232   // cannot be unmapped within the associated region.  Thus, this flag is
0233   // intended to be used on 'target' and 'target data' directives because they
0234   // are inherently structured.  It is not intended to be used on 'target
0235   // enter data' and 'target exit data' directives because they are inherently
0236   // dynamic.
0237   // This is an OpenMP extension for the sake of OpenACC support.
0238   OMP_MAP_OMPX_HOLD = 0x2000,
0239   /// Signal that the runtime library should use args as an array of
0240   /// descriptor_dim pointers and use args_size as dims. Used when we have
0241   /// non-contiguous list items in target update directive
0242   OMP_MAP_NON_CONTIG = 0x100000000000,
0243   /// The 16 MSBs of the flags indicate whether the entry is member of some
0244   /// struct/class.
0245   OMP_MAP_MEMBER_OF = 0xffff000000000000,
0246   LLVM_MARK_AS_BITMASK_ENUM(/* LargestFlag = */ OMP_MAP_MEMBER_OF)
0247 };
0248 
0249 enum OpenMPOffloadingReservedDeviceIDs {
0250   /// Device ID if the device was not defined, runtime should get it
0251   /// from environment variables in the spec.
0252   OMP_DEVICEID_UNDEF = -1
0253 };
0254 
0255 enum class AddressSpace : unsigned {
0256   Generic = 0,
0257   Global = 1,
0258   Shared = 3,
0259   Constant = 4,
0260   Local = 5,
0261 };
0262 
0263 /// \note This needs to be kept in sync with interop.h enum kmp_interop_type_t.:
0264 enum class OMPInteropType { Unknown, Target, TargetSync };
0265 
0266 /// Atomic compare operations. Currently OpenMP only supports ==, >, and <.
0267 enum class OMPAtomicCompareOp : unsigned { EQ, MIN, MAX };
0268 
0269 /// Fields ids in kmp_depend_info record.
0270 enum class RTLDependInfoFields { BaseAddr, Len, Flags };
0271 
0272 /// Dependence kind for RTL.
0273 enum class RTLDependenceKindTy {
0274   DepUnknown = 0x0,
0275   DepIn = 0x01,
0276   DepInOut = 0x3,
0277   DepMutexInOutSet = 0x4,
0278   DepInOutSet = 0x8,
0279   DepOmpAllMem = 0x80,
0280 };
0281 
0282 /// A type of worksharing loop construct
0283 enum class WorksharingLoopType {
0284   // Worksharing `for`-loop
0285   ForStaticLoop,
0286   // Worksharing `distrbute`-loop
0287   DistributeStaticLoop,
0288   // Worksharing `distrbute parallel for`-loop
0289   DistributeForStaticLoop
0290 };
0291 
0292 } // end namespace omp
0293 
0294 } // end namespace llvm
0295 
0296 #include "OMPDeviceConstants.h"
0297 
0298 #endif // LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H