xtensor_config.hpp 4.0 KB

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