xtensor
Loading...
Searching...
No Matches
xtensor_config.hpp
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 25
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) xsimd::aligned_allocator<T, XTENSOR_DEFAULT_ALIGNMENT>
83#else
84#define XTENSOR_DEFAULT_ALLOCATOR(T) std::allocator<T>
85#endif
86#endif
87#endif
88
89#ifndef XTENSOR_DEFAULT_ALIGNMENT
90#ifdef XTENSOR_USE_XSIMD
91#define XTENSOR_DEFAULT_ALIGNMENT XSIMD_DEFAULT_ALIGNMENT
92#else
93#define XTENSOR_DEFAULT_ALIGNMENT 0
94#endif
95#endif
96
97#ifndef XTENSOR_DEFAULT_LAYOUT
98#define XTENSOR_DEFAULT_LAYOUT ::xt::layout_type::row_major
99#endif
100
101#ifndef XTENSOR_DEFAULT_TRAVERSAL
102#define XTENSOR_DEFAULT_TRAVERSAL ::xt::layout_type::row_major
103#endif
104
105#ifndef XTENSOR_OPENMP_TRESHOLD
106#define XTENSOR_OPENMP_TRESHOLD 0
107#endif
108
109#ifndef XTENSOR_TBB_THRESHOLD
110#define XTENSOR_TBB_THRESHOLD 0
111#endif
112
113#ifndef XTENSOR_SELECT_ALIGN
114#define XTENSOR_SELECT_ALIGN(T) (XTENSOR_DEFAULT_ALIGNMENT != 0 ? XTENSOR_DEFAULT_ALIGNMENT : alignof(T))
115#endif
116
117#ifndef XTENSOR_FIXED_ALIGN
118#define XTENSOR_FIXED_ALIGN XTENSOR_SELECT_ALIGN(void*)
119#endif
120
121#ifdef IN_DOXYGEN
122namespace xtl
123{
124 template <class... T>
126 {
127 constexpr bool value = true;
128 };
129
130 template <class... C>
131 using check_concept = std::enable_if_t<conjunction<C...>::value, int>;
132
133#define XTL_REQUIRES(...) xtl::check_concept<__VA_ARGS__> = 0
134}
135#endif
136
137#endif