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