1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 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 10 #ifndef _PSTL_CONFIG_H 11 #define _PSTL_CONFIG_H 12 13 #include <__pstl_config_site> 14 15 // The version is XYYZ, where X is major, YY is minor, and Z is patch (i.e. X.YY.Z) 16 #define _PSTL_VERSION 13000 17 #define _PSTL_VERSION_MAJOR (_PSTL_VERSION / 1000) 18 #define _PSTL_VERSION_MINOR ((_PSTL_VERSION % 1000) / 10) 19 #define _PSTL_VERSION_PATCH (_PSTL_VERSION % 10) 20 21 #if !defined(_PSTL_PAR_BACKEND_SERIAL) && !defined(_PSTL_PAR_BACKEND_TBB) 22 # error "A parallel backend must be specified" 23 #endif 24 25 // Check the user-defined macro for warnings 26 #if defined(PSTL_USAGE_WARNINGS) 27 # define _PSTL_USAGE_WARNINGS 28 #endif 29 30 #if !defined(_PSTL_ASSERT) 31 # include <cassert> 32 # define _PSTL_ASSERT(pred) (assert((pred))) 33 #endif 34 35 // Portability "#pragma" definition 36 #ifdef _MSC_VER 37 # define _PSTL_PRAGMA(x) __pragma(x) 38 #else 39 # define _PSTL_PRAGMA(x) _Pragma(# x) 40 #endif 41 42 #define _PSTL_STRING_AUX(x) #x 43 #define _PSTL_STRING(x) _PSTL_STRING_AUX(x) 44 #define _PSTL_STRING_CONCAT(x, y) x #y 45 46 #ifdef _PSTL_HIDE_FROM_ABI_PER_TU 47 # define _PSTL_HIDE_FROM_ABI_PUSH \ 48 _Pragma("clang attribute push(__attribute__((internal_linkage)), apply_to=any(function,record))") 49 # define _PSTL_HIDE_FROM_ABI_POP _Pragma("clang attribute pop") 50 #else 51 # define _PSTL_HIDE_FROM_ABI_PUSH /* nothing */ 52 # define _PSTL_HIDE_FROM_ABI_POP /* nothing */ 53 #endif 54 55 // note that when ICC or Clang is in use, _PSTL_GCC_VERSION might not fully match 56 // the actual GCC version on the system. 57 #define _PSTL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 58 59 #if defined(__clang__) 60 // according to clang documentation, version can be vendor specific 61 # define _PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) 62 #endif 63 64 // Enable SIMD for compilers that support OpenMP 4.0 65 #if (defined(_OPENMP) && _OPENMP >= 201307) || \ 66 (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1600) || \ 67 (!defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900) || \ 68 defined(__clang__) 69 # define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd) 70 # define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd) 71 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM)) 72 #elif !defined(_MSC_VER) //#pragma simd 73 # define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(simd) 74 # define _PSTL_PRAGMA_DECLARE_SIMD 75 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(simd reduction(PRM)) 76 #else //no simd 77 # define _PSTL_PRAGMA_SIMD 78 # define _PSTL_PRAGMA_DECLARE_SIMD 79 # define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) 80 #endif //Enable SIMD 81 82 #if defined(__INTEL_COMPILER) 83 # define _PSTL_PRAGMA_FORCEINLINE _PSTL_PRAGMA(forceinline) 84 #else 85 # define _PSTL_PRAGMA_FORCEINLINE 86 #endif 87 88 #if defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1900 89 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM)) 90 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM)) 91 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM)) 92 #else 93 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) 94 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) 95 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) 96 #endif 97 98 // Should be defined to 1 for environments with a vendor implementation of C++17 execution policies 99 #define _PSTL_CPP17_EXECUTION_POLICIES_PRESENT (_MSC_VER >= 1912) 100 101 #if (defined(_MSC_VER) && _MSC_VER >= 1900) || \ 102 __cplusplus >= 201300L || \ 103 __cpp_lib_robust_nonmodifying_seq_ops == 201304 104 # define _PSTL_CPP14_2RANGE_MISMATCH_EQUAL_PRESENT 105 #endif 106 #if (defined(_MSC_VER) && _MSC_VER >= 1900) || \ 107 __cplusplus >= 201402L || \ 108 __cpp_lib_make_reverse_iterator == 201402 109 # define _PSTL_CPP14_MAKE_REVERSE_ITERATOR_PRESENT 110 #endif 111 #if (defined(_MSC_VER) && _MSC_VER >= 1900) || __cplusplus >= 201402L 112 # define _PSTL_CPP14_INTEGER_SEQUENCE_PRESENT 113 #endif 114 #if (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1700) || \ 115 (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023918) || \ 116 __cplusplus >= 201402L 117 # define _PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT 118 #endif 119 120 #if defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1800 121 # define _PSTL_EARLYEXIT_PRESENT 122 # define _PSTL_MONOTONIC_PRESENT 123 #endif 124 125 #if (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1900) || \ 126 (!defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900) || \ 127 (defined(_OPENMP) && _OPENMP >= 201307) 128 # define _PSTL_UDR_PRESENT 129 #endif 130 131 #if defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626 132 # define _PSTL_UDS_PRESENT 133 #endif 134 135 #if defined(_PSTL_EARLYEXIT_PRESENT) 136 # define _PSTL_PRAGMA_SIMD_EARLYEXIT _PSTL_PRAGMA(omp simd early_exit) 137 #else 138 # define _PSTL_PRAGMA_SIMD_EARLYEXIT 139 #endif 140 141 #if defined(_PSTL_MONOTONIC_PRESENT) 142 # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) _PSTL_PRAGMA(omp ordered simd monotonic(PRM)) 143 # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) _PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2)) 144 #else 145 # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) 146 # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) 147 #endif 148 149 // Declaration of reduction functor, where 150 // NAME - the name of the functor 151 // OP - type of the callable object with the reduction operation 152 // omp_in - refers to the local partial result 153 // omp_out - refers to the final value of the combiner operator 154 // omp_priv - refers to the private copy of the initial value 155 // omp_orig - refers to the original variable to be reduced 156 #define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \ 157 _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig)) 158 159 #if defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1600 160 # define _PSTL_PRAGMA_VECTOR_UNALIGNED _PSTL_PRAGMA(vector unaligned) 161 #else 162 # define _PSTL_PRAGMA_VECTOR_UNALIGNED 163 #endif 164 165 // Check the user-defined macro to use non-temporal stores 166 #if defined(PSTL_USE_NONTEMPORAL_STORES) && (__INTEL_COMPILER >= 1600) 167 # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED _PSTL_PRAGMA(vector nontemporal) 168 #else 169 # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED 170 #endif 171 172 #if defined(_MSC_VER) || defined(__INTEL_COMPILER) // the preprocessors don't type a message location 173 # define _PSTL_PRAGMA_LOCATION __FILE__ ":" _PSTL_STRING(__LINE__) ": [Parallel STL message]: " 174 #else 175 # define _PSTL_PRAGMA_LOCATION " [Parallel STL message]: " 176 #endif 177 178 #define _PSTL_PRAGMA_MESSAGE_IMPL(x) _PSTL_PRAGMA(message(_PSTL_STRING_CONCAT(_PSTL_PRAGMA_LOCATION, x))) 179 180 #if defined(_PSTL_USAGE_WARNINGS) 181 # define _PSTL_PRAGMA_MESSAGE(x) _PSTL_PRAGMA_MESSAGE_IMPL(x) 182 # define _PSTL_PRAGMA_MESSAGE_POLICIES(x) _PSTL_PRAGMA_MESSAGE_IMPL(x) 183 #else 184 # define _PSTL_PRAGMA_MESSAGE(x) 185 # define _PSTL_PRAGMA_MESSAGE_POLICIES(x) 186 #endif 187 188 // broken macros 189 #if (defined(__GLIBCXX__) && __GLIBCXX__ < 20150716) || \ 190 (defined(_MSC_VER) && _MSC_VER < 1800) 191 # define _PSTL_CPP11_STD_ROTATE_BROKEN 192 #endif 193 194 #if defined(__INTEL_COMPILER) && __INTEL_COMPILER == 1800 195 # define _PSTL_ICC_18_OMP_SIMD_BROKEN 196 #endif 197 198 #endif /* _PSTL_CONFIG_H */ 199