1 /*************************************************************************** 2 * Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht * 3 * Copyright (c) QuantStack * 4 * * 5 * Distributed under the terms of the BSD 3-Clause License. * 6 * * 7 * The full license is in the file LICENSE, distributed with this software. * 8 ****************************************************************************/ 9 10 #ifndef XTENSOR_CONFIG_HPP 11 #define XTENSOR_CONFIG_HPP 12 13 #define XTENSOR_VERSION_MAJOR 0 14 #define XTENSOR_VERSION_MINOR 24 15 #define XTENSOR_VERSION_PATCH 0 16 17 18 // Define if the library is going to be using exceptions. 19 #if (!defined(__cpp_exceptions) && !defined(__EXCEPTIONS) && !defined(_CPPUNWIND)) 20 #undef XTENSOR_DISABLE_EXCEPTIONS 21 #define XTENSOR_DISABLE_EXCEPTIONS 22 #endif 23 24 // Exception support. 25 #if defined(XTENSOR_DISABLE_EXCEPTIONS) 26 #include <iostream> 27 #define XTENSOR_THROW(_, msg) \ 28 { \ 29 std::cerr << msg << std::endl; \ 30 std::abort(); \ 31 } 32 #else 33 #define XTENSOR_THROW(exception, msg) throw exception(msg) 34 #endif 35 36 // Workaround for some missing constexpr functionality in MSVC 2015 and MSVC 2017 x86 37 #if defined(_MSC_VER) 38 #define XTENSOR_CONSTEXPR_ENHANCED const 39 // The following must not be defined to const, otherwise 40 // it prevents generation of copy operators of classes 41 // containing XTENSOR_CONSTEXPR_ENHANCED_STATIC members 42 #define XTENSOR_CONSTEXPR_ENHANCED_STATIC 43 #define XTENSOR_CONSTEXPR_RETURN inline 44 #else 45 #define XTENSOR_CONSTEXPR_ENHANCED constexpr 46 #define XTENSOR_CONSTEXPR_RETURN constexpr 47 #define XTENSOR_CONSTEXPR_ENHANCED_STATIC constexpr static 48 #define XTENSOR_HAS_CONSTEXPR_ENHANCED 49 #endif 50 51 #ifndef XTENSOR_DEFAULT_DATA_CONTAINER 52 #define XTENSOR_DEFAULT_DATA_CONTAINER(T, A) uvector<T, A> 53 #endif 54 55 #ifndef XTENSOR_DEFAULT_SHAPE_CONTAINER 56 #define XTENSOR_DEFAULT_SHAPE_CONTAINER(T, EA, SA) \ 57 xt::svector<typename XTENSOR_DEFAULT_DATA_CONTAINER(T, EA)::size_type, 4, SA, true> 58 #endif 59 60 #ifdef XTENSOR_USE_XSIMD 61 #include <xsimd/xsimd.hpp> 62 #define XSIMD_DEFAULT_ALIGNMENT xsimd::default_arch::alignment() 63 #endif 64 65 66 #ifndef XTENSOR_DEFAULT_ALLOCATOR 67 #ifdef XTENSOR_ALLOC_TRACKING 68 #ifndef XTENSOR_ALLOC_TRACKING_POLICY 69 #define XTENSOR_ALLOC_TRACKING_POLICY xt::alloc_tracking::policy::print 70 #endif 71 #ifdef XTENSOR_USE_XSIMD 72 #include <xsimd/xsimd.hpp> 73 #define XTENSOR_DEFAULT_ALLOCATOR(T) \ 74 xt::tracking_allocator<T, xsimd::aligned_allocator<T, XSIMD_DEFAULT_ALIGNMENT>, XTENSOR_ALLOC_TRACKING_POLICY> 75 #else 76 #define XTENSOR_DEFAULT_ALLOCATOR(T) \ 77 xt::tracking_allocator<T, std::allocator<T>, XTENSOR_ALLOC_TRACKING_POLICY> 78 #endif 79 #else 80 #ifdef XTENSOR_USE_XSIMD 81 82 #define XTENSOR_DEFAULT_ALLOCATOR(T) \ 83 xsimd::aligned_allocator<T, XSIMD_DEFAULT_ALIGNMENT> 84 #else 85 #define XTENSOR_DEFAULT_ALLOCATOR(T) \ 86 std::allocator<T> 87 #endif 88 #endif 89 #endif 90 91 #ifndef XTENSOR_DEFAULT_ALIGNMENT 92 #ifdef XTENSOR_USE_XSIMD 93 #define XTENSOR_DEFAULT_ALIGNMENT XSIMD_DEFAULT_ALIGNMENT 94 #else 95 #define XTENSOR_DEFAULT_ALIGNMENT 0 96 #endif 97 #endif 98 99 #ifndef XTENSOR_DEFAULT_LAYOUT 100 #define XTENSOR_DEFAULT_LAYOUT ::xt::layout_type::row_major 101 #endif 102 103 #ifndef XTENSOR_DEFAULT_TRAVERSAL 104 #define XTENSOR_DEFAULT_TRAVERSAL ::xt::layout_type::row_major 105 #endif 106 107 #ifndef XTENSOR_OPENMP_TRESHOLD 108 #define XTENSOR_OPENMP_TRESHOLD 0 109 #endif 110 111 #ifndef XTENSOR_SELECT_ALIGN 112 #define XTENSOR_SELECT_ALIGN(T) (XTENSOR_DEFAULT_ALIGNMENT != 0 ? XTENSOR_DEFAULT_ALIGNMENT : alignof(T)) 113 #endif 114 115 #ifndef XTENSOR_FIXED_ALIGN 116 #define XTENSOR_FIXED_ALIGN XTENSOR_SELECT_ALIGN(void*) 117 #endif 118 119 #ifdef IN_DOXYGEN 120 namespace xtl 121 { 122 template <class... T> 123 struct conjunction 124 { 125 constexpr bool value = true; 126 }; 127 128 template <class... C> 129 using check_concept = std::enable_if_t<conjunction<C...>::value, int>; 130 131 #define XTL_REQUIRES(...) xtl::check_concept<__VA_ARGS__> = 0 132 } 133 #endif 134 135 #endif 136