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