OMPConstants.h 11 KB

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