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 
28 #define EIGEN_SFINAE_ENABLE_IF(__condition__) std::enable_if_t<(__condition__), int> = 0
29 
30 // Define a macro to use a reference on the host but a value on the device
31 #if defined(SYCL_DEVICE_ONLY)
32 #define EIGEN_DEVICE_REF
33 #else
34 #define EIGEN_DEVICE_REF &
35 #endif
36 
37 // Define a macro for catching SYCL exceptions if exceptions are enabled
38 #define EIGEN_SYCL_TRY_CATCH(X) \
39  do { \
40  EIGEN_TRY { X; } \
41  EIGEN_CATCH(const cl::sycl::exception& e) { \
42  EIGEN_THROW_X(std::runtime_error("SYCL exception at " + std::string(__FILE__) + ":" + std::to_string(__LINE__) + \
43  "\n" + e.what())); \
44  } \
45  } while (false)
46 
47 // Define a macro if local memory flags are unset or one of them is set
48 // Setting both flags is the same as unsetting them
49 #if (!defined(EIGEN_SYCL_LOCAL_MEM) && !defined(EIGEN_SYCL_NO_LOCAL_MEM)) || \
50  (defined(EIGEN_SYCL_LOCAL_MEM) && defined(EIGEN_SYCL_NO_LOCAL_MEM))
51 #define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_ON 1
52 #define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_OFF 1
53 #elif defined(EIGEN_SYCL_LOCAL_MEM) && !defined(EIGEN_SYCL_NO_LOCAL_MEM)
54 #define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_ON 1
55 #elif !defined(EIGEN_SYCL_LOCAL_MEM) && defined(EIGEN_SYCL_NO_LOCAL_MEM)
56 #define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_OFF 1
57 #endif
58 
59 #if EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
60 #define EIGEN_TENSOR_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
61  using Base::operator=; \
62  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { \
63  Base::operator=(other); \
64  return *this; \
65  } \
66  template <typename OtherDerived> \
67  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const OtherDerived& other) { \
68  Base::operator=(other); \
69  return *this; \
70  }
71 #else
72 #define EIGEN_TENSOR_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
73 #endif
74 
81 #define EIGEN_TENSOR_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
82  EIGEN_TENSOR_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
83  EIGEN_DEFAULT_COPY_CONSTRUCTOR(Derived)
84 
85 #endif