pstl_config.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // -*- C++ -*-
  2. //===-- pstl_config.h -----------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _PSTL_CONFIG_H
  10. #define _PSTL_CONFIG_H
  11. // The version is XYYZ, where X is major, YY is minor, and Z is patch (i.e. X.YY.Z)
  12. #define _PSTL_VERSION 12000
  13. #define _PSTL_VERSION_MAJOR (_PSTL_VERSION / 1000)
  14. #define _PSTL_VERSION_MINOR ((_PSTL_VERSION % 1000) / 10)
  15. #define _PSTL_VERSION_PATCH (_PSTL_VERSION % 10)
  16. #if !defined(_PSTL_PAR_BACKEND_SERIAL) && !defined(_PSTL_PAR_BACKEND_TBB)
  17. # error "A parallel backend must be specified"
  18. #endif
  19. // Check the user-defined macro for warnings
  20. #if defined(PSTL_USAGE_WARNINGS)
  21. # undef _PSTL_USAGE_WARNINGS
  22. # define _PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS
  23. // Check the internal macro for warnings
  24. #elif !defined(_PSTL_USAGE_WARNINGS)
  25. # define _PSTL_USAGE_WARNINGS 0
  26. #endif
  27. // Portability "#pragma" definition
  28. #ifdef _MSC_VER
  29. # define _PSTL_PRAGMA(x) __pragma(x)
  30. #else
  31. # define _PSTL_PRAGMA(x) _Pragma(# x)
  32. #endif
  33. #define _PSTL_STRING_AUX(x) #x
  34. #define _PSTL_STRING(x) _PSTL_STRING_AUX(x)
  35. #define _PSTL_STRING_CONCAT(x, y) x #y
  36. #ifdef _PSTL_HIDE_FROM_ABI_PER_TU
  37. # define _PSTL_HIDE_FROM_ABI_PUSH \
  38. _Pragma("clang attribute push(__attribute__((internal_linkage)), apply_to=any(function,record))")
  39. # define _PSTL_HIDE_FROM_ABI_POP _Pragma("clang attribute pop")
  40. #else
  41. # define _PSTL_HIDE_FROM_ABI_PUSH /* nothing */
  42. # define _PSTL_HIDE_FROM_ABI_POP /* nothing */
  43. #endif
  44. // note that when ICC or Clang is in use, _PSTL_GCC_VERSION might not fully match
  45. // the actual GCC version on the system.
  46. #define _PSTL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  47. #if __clang__
  48. // according to clang documentation, version can be vendor specific
  49. # define _PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
  50. #endif
  51. // Enable SIMD for compilers that support OpenMP 4.0
  52. #if (_OPENMP >= 201307) || (__INTEL_COMPILER >= 1600) || (!defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900) || \
  53. defined(__clang__)
  54. # define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
  55. # define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
  56. # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
  57. #elif !defined(_MSC_VER) //#pragma simd
  58. # define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(simd)
  59. # define _PSTL_PRAGMA_DECLARE_SIMD
  60. # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(simd reduction(PRM))
  61. #else //no simd
  62. # define _PSTL_PRAGMA_SIMD
  63. # define _PSTL_PRAGMA_DECLARE_SIMD
  64. # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
  65. #endif //Enable SIMD
  66. #if (__INTEL_COMPILER)
  67. # define _PSTL_PRAGMA_FORCEINLINE _PSTL_PRAGMA(forceinline)
  68. #else
  69. # define _PSTL_PRAGMA_FORCEINLINE
  70. #endif
  71. #if (__INTEL_COMPILER >= 1900)
  72. # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
  73. # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
  74. # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
  75. #else
  76. # define _PSTL_PRAGMA_SIMD_SCAN(PRM)
  77. # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
  78. # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
  79. #endif
  80. // Should be defined to 1 for environments with a vendor implementation of C++17 execution policies
  81. #define _PSTL_CPP17_EXECUTION_POLICIES_PRESENT (_MSC_VER >= 1912)
  82. #define _PSTL_CPP14_2RANGE_MISMATCH_EQUAL_PRESENT \
  83. (_MSC_VER >= 1900 || __cplusplus >= 201300L || __cpp_lib_robust_nonmodifying_seq_ops == 201304)
  84. #define _PSTL_CPP14_MAKE_REVERSE_ITERATOR_PRESENT \
  85. (_MSC_VER >= 1900 || __cplusplus >= 201402L || __cpp_lib_make_reverse_iterator == 201402)
  86. #define _PSTL_CPP14_INTEGER_SEQUENCE_PRESENT (_MSC_VER >= 1900 || __cplusplus >= 201402L)
  87. #define _PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT \
  88. (!__INTEL_COMPILER || __INTEL_COMPILER >= 1700) && (_MSC_FULL_VER >= 190023918 || __cplusplus >= 201402L)
  89. #define _PSTL_EARLYEXIT_PRESENT (__INTEL_COMPILER >= 1800)
  90. #define _PSTL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800)
  91. #if (__INTEL_COMPILER >= 1900 || !defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900 || _OPENMP >= 201307)
  92. # define _PSTL_UDR_PRESENT 1
  93. #else
  94. # define _PSTL_UDR_PRESENT 0
  95. #endif
  96. #define _PSTL_UDS_PRESENT (__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626)
  97. #if _PSTL_EARLYEXIT_PRESENT
  98. # define _PSTL_PRAGMA_SIMD_EARLYEXIT _PSTL_PRAGMA(omp simd early_exit)
  99. #else
  100. # define _PSTL_PRAGMA_SIMD_EARLYEXIT
  101. #endif
  102. #if _PSTL_MONOTONIC_PRESENT
  103. # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) _PSTL_PRAGMA(omp ordered simd monotonic(PRM))
  104. # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) _PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
  105. #else
  106. # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
  107. # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
  108. #endif
  109. // Declaration of reduction functor, where
  110. // NAME - the name of the functor
  111. // OP - type of the callable object with the reduction operation
  112. // omp_in - refers to the local partial result
  113. // omp_out - refers to the final value of the combiner operator
  114. // omp_priv - refers to the private copy of the initial value
  115. // omp_orig - refers to the original variable to be reduced
  116. #define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
  117. _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
  118. #if (__INTEL_COMPILER >= 1600)
  119. # define _PSTL_PRAGMA_VECTOR_UNALIGNED _PSTL_PRAGMA(vector unaligned)
  120. #else
  121. # define _PSTL_PRAGMA_VECTOR_UNALIGNED
  122. #endif
  123. // Check the user-defined macro to use non-temporal stores
  124. #if defined(PSTL_USE_NONTEMPORAL_STORES) && (__INTEL_COMPILER >= 1600)
  125. # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED _PSTL_PRAGMA(vector nontemporal)
  126. #else
  127. # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
  128. #endif
  129. #if _MSC_VER || __INTEL_COMPILER //the preprocessors don't type a message location
  130. # define _PSTL_PRAGMA_LOCATION __FILE__ ":" _PSTL_STRING(__LINE__) ": [Parallel STL message]: "
  131. #else
  132. # define _PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
  133. #endif
  134. #define _PSTL_PRAGMA_MESSAGE_IMPL(x) _PSTL_PRAGMA(message(_PSTL_STRING_CONCAT(_PSTL_PRAGMA_LOCATION, x)))
  135. #if _PSTL_USAGE_WARNINGS
  136. # define _PSTL_PRAGMA_MESSAGE(x) _PSTL_PRAGMA_MESSAGE_IMPL(x)
  137. # define _PSTL_PRAGMA_MESSAGE_POLICIES(x) _PSTL_PRAGMA_MESSAGE_IMPL(x)
  138. #else
  139. # define _PSTL_PRAGMA_MESSAGE(x)
  140. # define _PSTL_PRAGMA_MESSAGE_POLICIES(x)
  141. #endif
  142. // broken macros
  143. #define _PSTL_CPP11_STD_ROTATE_BROKEN ((__GLIBCXX__ && __GLIBCXX__ < 20150716) || (_MSC_VER && _MSC_VER < 1800))
  144. #define _PSTL_ICC_18_OMP_SIMD_BROKEN (__INTEL_COMPILER == 1800)
  145. #endif /* _PSTL_CONFIG_H */