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 10 #ifndef _PSTL_CONFIG_H 11 #define _PSTL_CONFIG_H 12 13 // The version is XYYZ, where X is major, YY is minor, and Z is patch (i.e. X.YY.Z) 14 #define _PSTL_VERSION 9000 15 #define _PSTL_VERSION_MAJOR (_PSTL_VERSION / 1000) 16 #define _PSTL_VERSION_MINOR ((_PSTL_VERSION % 1000) / 10) 17 #define _PSTL_VERSION_PATCH (_PSTL_VERSION % 10) 18 19 #if !defined(_PSTL_PAR_BACKEND_SERIAL) && !defined(_PSTL_PAR_BACKEND_TBB) 20 # error "The parallel backend is neither serial nor TBB" 21 #endif 22 23 // Check the user-defined macro for warnings 24 #if defined(PSTL_USAGE_WARNINGS) 25 # undef _PSTL_USAGE_WARNINGS 26 # define _PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS 27 // Check the internal macro for warnings 28 #elif !defined(_PSTL_USAGE_WARNINGS) 29 # define _PSTL_USAGE_WARNINGS 0 30 #endif 31 32 // Portability "#pragma" definition 33 #ifdef _MSC_VER 34 # define _PSTL_PRAGMA(x) __pragma(x) 35 #else 36 # define _PSTL_PRAGMA(x) _Pragma(# x) 37 #endif 38 39 #define _PSTL_STRING_AUX(x) #x 40 #define _PSTL_STRING(x) _PSTL_STRING_AUX(x) 41 #define _PSTL_STRING_CONCAT(x, y) x #y 42 43 // note that when ICC or Clang is in use, _PSTL_GCC_VERSION might not fully match 44 // the actual GCC version on the system. 45 #define _PSTL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 46 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 52 // Enable SIMD for compilers that support OpenMP 4.0 53 #if (_OPENMP >= 201307) || (__INTEL_COMPILER >= 1600) || (!defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900) 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 67 #if (__INTEL_COMPILER) 68 # define _PSTL_PRAGMA_FORCEINLINE _PSTL_PRAGMA(forceinline) 69 #else 70 # define _PSTL_PRAGMA_FORCEINLINE 71 #endif 72 73 #if (__INTEL_COMPILER >= 1900) || (_PSTL_GCC_VERSION >= 100000) 74 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM)) 75 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM)) 76 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM)) 77 #else 78 # define _PSTL_PRAGMA_SIMD_SCAN(PRM) 79 # define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) 80 # define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) 81 #endif 82 83 // Should be defined to 1 for environments with a vendor implementation of C++17 execution policies 84 #define _PSTL_CPP17_EXECUTION_POLICIES_PRESENT (_MSC_VER >= 1912) 85 86 #define _PSTL_CPP14_2RANGE_MISMATCH_EQUAL_PRESENT \ 87 (_MSC_VER >= 1900 || __cplusplus >= 201300L || __cpp_lib_robust_nonmodifying_seq_ops == 201304) 88 #define _PSTL_CPP14_MAKE_REVERSE_ITERATOR_PRESENT \ 89 (_MSC_VER >= 1900 || __cplusplus >= 201402L || __cpp_lib_make_reverse_iterator == 201402) 90 #define _PSTL_CPP14_INTEGER_SEQUENCE_PRESENT (_MSC_VER >= 1900 || __cplusplus >= 201402L) 91 #define _PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT \ 92 (!__INTEL_COMPILER || __INTEL_COMPILER >= 1700) && (_MSC_FULL_VER >= 190023918 || __cplusplus >= 201402L) 93 94 #define _PSTL_EARLYEXIT_PRESENT (__INTEL_COMPILER >= 1800) 95 #define _PSTL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800) 96 97 #if (__INTEL_COMPILER >= 1900 || !defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900 || _OPENMP >= 201307) 98 # define _PSTL_UDR_PRESENT 1 99 #else 100 # define _PSTL_UDR_PRESENT 0 101 #endif 102 103 #if ((__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626) || _PSTL_GCC_VERSION >= 100000) 104 # define _PSTL_UDS_PRESENT 1 105 #else 106 # define _PSTL_UDS_PRESENT 0 107 #endif 108 109 #if _PSTL_EARLYEXIT_PRESENT 110 # define _PSTL_PRAGMA_SIMD_EARLYEXIT _PSTL_PRAGMA(omp simd early_exit) 111 #else 112 # define _PSTL_PRAGMA_SIMD_EARLYEXIT 113 #endif 114 115 #if _PSTL_MONOTONIC_PRESENT 116 # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) _PSTL_PRAGMA(omp ordered simd monotonic(PRM)) 117 # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) _PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2)) 118 #else 119 # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) 120 # define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) 121 #endif 122 123 // Declaration of reduction functor, where 124 // NAME - the name of the functor 125 // OP - type of the callable object with the reduction operation 126 // omp_in - refers to the local partial result 127 // omp_out - refers to the final value of the combiner operator 128 // omp_priv - refers to the private copy of the initial value 129 // omp_orig - refers to the original variable to be reduced 130 #define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \ 131 _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig)) 132 133 #if (__INTEL_COMPILER >= 1600) 134 # define _PSTL_PRAGMA_VECTOR_UNALIGNED _PSTL_PRAGMA(vector unaligned) 135 #else 136 # define _PSTL_PRAGMA_VECTOR_UNALIGNED 137 #endif 138 139 // Check the user-defined macro to use non-temporal stores 140 #if defined(PSTL_USE_NONTEMPORAL_STORES) && (__INTEL_COMPILER >= 1600) 141 # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED _PSTL_PRAGMA(vector nontemporal) 142 #else 143 # define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED 144 #endif 145 146 #if _MSC_VER || __INTEL_COMPILER //the preprocessors don't type a message location 147 # define _PSTL_PRAGMA_LOCATION __FILE__ ":" _PSTL_STRING(__LINE__) ": [Parallel STL message]: " 148 #else 149 # define _PSTL_PRAGMA_LOCATION " [Parallel STL message]: " 150 #endif 151 152 #define _PSTL_PRAGMA_MESSAGE_IMPL(x) _PSTL_PRAGMA(message(_PSTL_STRING_CONCAT(_PSTL_PRAGMA_LOCATION, x))) 153 154 #if _PSTL_USAGE_WARNINGS 155 # define _PSTL_PRAGMA_MESSAGE(x) _PSTL_PRAGMA_MESSAGE_IMPL(x) 156 # define _PSTL_PRAGMA_MESSAGE_POLICIES(x) _PSTL_PRAGMA_MESSAGE_IMPL(x) 157 #else 158 # define _PSTL_PRAGMA_MESSAGE(x) 159 # define _PSTL_PRAGMA_MESSAGE_POLICIES(x) 160 #endif 161 162 // broken macros 163 #define _PSTL_CPP11_STD_ROTATE_BROKEN ((__GLIBCXX__ && __GLIBCXX__ < 20150716) || (_MSC_VER && _MSC_VER < 1800)) 164 165 #define _PSTL_ICC_18_OMP_SIMD_BROKEN (__INTEL_COMPILER == 1800) 166 167 #endif /* _PSTL_CONFIG_H */ 168