TensorMacros.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2015 Benoit Steiner <benoit.steiner.goog@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_META_MACROS_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_META_MACROS_H
12 
13 
29 #define EIGEN_SFINAE_ENABLE_IF( __condition__ ) \
30  std::enable_if_t< ( __condition__ ) , int > = 0
31 
32 // Define a macro to use a reference on the host but a value on the device
33 #if defined(SYCL_DEVICE_ONLY)
34  #define EIGEN_DEVICE_REF
35 #else
36  #define EIGEN_DEVICE_REF &
37 #endif
38 
39 // Define a macro for catching SYCL exceptions if exceptions are enabled
40 #define EIGEN_SYCL_TRY_CATCH(X) \
41  do { \
42  EIGEN_TRY {X;} \
43  EIGEN_CATCH(const cl::sycl::exception& e) { \
44  EIGEN_THROW_X(std::runtime_error("SYCL exception at " + \
45  std::string(__FILE__) + ":" + \
46  std::to_string(__LINE__) + "\n" + \
47  e.what())); \
48  } \
49  } while (false)
50 
51 // Define a macro if local memory flags are unset or one of them is set
52 // Setting both flags is the same as unsetting them
53 #if (!defined(EIGEN_SYCL_LOCAL_MEM) && !defined(EIGEN_SYCL_NO_LOCAL_MEM)) || \
54  (defined(EIGEN_SYCL_LOCAL_MEM) && defined(EIGEN_SYCL_NO_LOCAL_MEM))
55  #define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_ON 1
56  #define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_OFF 1
57 #elif defined(EIGEN_SYCL_LOCAL_MEM) && !defined(EIGEN_SYCL_NO_LOCAL_MEM)
58  #define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_ON 1
59 #elif !defined(EIGEN_SYCL_LOCAL_MEM) && defined(EIGEN_SYCL_NO_LOCAL_MEM)
60  #define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_OFF 1
61 #endif
62 
63 #if EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
64  #define EIGEN_TENSOR_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
65  using Base::operator =; \
66  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { Base::operator=(other); return *this; } \
67  template <typename OtherDerived> \
68  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const OtherDerived& other) { Base::operator=(other); return *this; }
69 #else
70  #define EIGEN_TENSOR_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
71  EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
72 #endif
73 
80 #define EIGEN_TENSOR_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
81  EIGEN_TENSOR_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
82  EIGEN_DEFAULT_COPY_CONSTRUCTOR(Derived)
83 
84 #endif