You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 9000
  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 "The parallel backend is neither serial nor TBB"
  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. // note that when ICC or Clang is in use, _PSTL_GCC_VERSION might not fully match
  37. // the actual GCC version on the system.
  38. #define _PSTL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  39. #if __clang__
  40. // according to clang documentation, version can be vendor specific
  41. # define _PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
  42. #endif
  43. // Enable SIMD for compilers that support OpenMP 4.0
  44. #if (_OPENMP >= 201307) || (__INTEL_COMPILER >= 1600) || (!defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900)
  45. # define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
  46. # define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
  47. # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
  48. #elif !defined(_MSC_VER) //#pragma simd
  49. # define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(simd)
  50. # define _PSTL_PRAGMA_DECLARE_SIMD
  51. # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(simd reduction(PRM))
  52. #else //no simd
  53. # define _PSTL_PRAGMA_SIMD
  54. # define _PSTL_PRAGMA_DECLARE_SIMD
  55. # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
  56. #endif //Enable SIMD
  57. #if (__INTEL_COMPILER)
  58. # define _PSTL_PRAGMA_FORCEINLINE _PSTL_PRAGMA(forceinline)
  59. #else
  60. # define _PSTL_PRAGMA_FORCEINLINE
  61. #endif
  62. #if (__INTEL_COMPILER >= 1900) || (_PSTL_GCC_VERSION >= 100000)
  63. # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
  64. # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
  65. # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
  66. #else
  67. # define _PSTL_PRAGMA_SIMD_SCAN(PRM)
  68. # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
  69. # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
  70. #endif
  71. // Should be defined to 1 for environments with a vendor implementation of C++17 execution policies
  72. #define _PSTL_CPP17_EXECUTION_POLICIES_PRESENT (_MSC_VER >= 1912)
  73. #define _PSTL_CPP14_2RANGE_MISMATCH_EQUAL_PRESENT \
  74. (_MSC_VER >= 1900 || __cplusplus >= 201300L || __cpp_lib_robust_nonmodifying_seq_ops == 201304)
  75. #define _PSTL_CPP14_MAKE_REVERSE_ITERATOR_PRESENT \
  76. (_MSC_VER >= 1900 || __cplusplus >= 201402L || __cpp_lib_make_reverse_iterator == 201402)
  77. #define _PSTL_CPP14_INTEGER_SEQUENCE_PRESENT (_MSC_VER >= 1900 || __cplusplus >= 201402L)
  78. #define _PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT \
  79. (!__INTEL_COMPILER || __INTEL_COMPILER >= 1700) && (_MSC_FULL_VER >= 190023918 || __cplusplus >= 201402L)
  80. #define _PSTL_EARLYEXIT_PRESENT (__INTEL_COMPILER >= 1800)
  81. #define _PSTL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800)
  82. #if (__INTEL_COMPILER >= 1900 || !defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900 || _OPENMP >= 201307)
  83. # define _PSTL_UDR_PRESENT 1
  84. #else
  85. # define _PSTL_UDR_PRESENT 0
  86. #endif
  87. #if ((__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626) || _PSTL_GCC_VERSION >= 100000)
  88. # define _PSTL_UDS_PRESENT 1
  89. #else
  90. # define _PSTL_UDS_PRESENT 0
  91. #endif
  92. #if _PSTL_EARLYEXIT_PRESENT
  93. # define _PSTL_PRAGMA_SIMD_EARLYEXIT _PSTL_PRAGMA(omp simd early_exit)
  94. #else
  95. # define _PSTL_PRAGMA_SIMD_EARLYEXIT
  96. #endif
  97. #if _PSTL_MONOTONIC_PRESENT
  98. # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) _PSTL_PRAGMA(omp ordered simd monotonic(PRM))
  99. # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) _PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
  100. #else
  101. # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
  102. # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
  103. #endif
  104. // Declaration of reduction functor, where
  105. // NAME - the name of the functor
  106. // OP - type of the callable object with the reduction operation
  107. // omp_in - refers to the local partial result
  108. // omp_out - refers to the final value of the combiner operator
  109. // omp_priv - refers to the private copy of the initial value
  110. // omp_orig - refers to the original variable to be reduced
  111. #define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
  112. _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
  113. #if (__INTEL_COMPILER >= 1600)
  114. # define _PSTL_PRAGMA_VECTOR_UNALIGNED _PSTL_PRAGMA(vector unaligned)
  115. #else
  116. # define _PSTL_PRAGMA_VECTOR_UNALIGNED
  117. #endif
  118. // Check the user-defined macro to use non-temporal stores
  119. #if defined(PSTL_USE_NONTEMPORAL_STORES) && (__INTEL_COMPILER >= 1600)
  120. # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED _PSTL_PRAGMA(vector nontemporal)
  121. #else
  122. # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
  123. #endif
  124. #if _MSC_VER || __INTEL_COMPILER //the preprocessors don't type a message location
  125. # define _PSTL_PRAGMA_LOCATION __FILE__ ":" _PSTL_STRING(__LINE__) ": [Parallel STL message]: "
  126. #else
  127. # define _PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
  128. #endif
  129. #define _PSTL_PRAGMA_MESSAGE_IMPL(x) _PSTL_PRAGMA(message(_PSTL_STRING_CONCAT(_PSTL_PRAGMA_LOCATION, x)))
  130. #if _PSTL_USAGE_WARNINGS
  131. # define _PSTL_PRAGMA_MESSAGE(x) _PSTL_PRAGMA_MESSAGE_IMPL(x)
  132. # define _PSTL_PRAGMA_MESSAGE_POLICIES(x) _PSTL_PRAGMA_MESSAGE_IMPL(x)
  133. #else
  134. # define _PSTL_PRAGMA_MESSAGE(x)
  135. # define _PSTL_PRAGMA_MESSAGE_POLICIES(x)
  136. #endif
  137. // broken macros
  138. #define _PSTL_CPP11_STD_ROTATE_BROKEN ((__GLIBCXX__ && __GLIBCXX__ < 20150716) || (_MSC_VER && _MSC_VER < 1800))
  139. #define _PSTL_ICC_18_OMP_SIMD_BROKEN (__INTEL_COMPILER == 1800)
  140. #endif /* _PSTL_CONFIG_H */