Eigen-Contrib  5.0.1
 
Loading...
Searching...
No Matches
TensorMacros.h
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_TENSOR_TENSOR_META_MACROS_H
12#define EIGEN_TENSOR_TENSOR_META_MACROS_H
13
28
29#define EIGEN_SFINAE_ENABLE_IF(__condition__) std::enable_if_t<(__condition__), int> = 0
30
31// Define a macro to use a reference on the host but a value on the device
32#if defined(SYCL_DEVICE_ONLY)
33#define EIGEN_DEVICE_REF
34#else
35#define EIGEN_DEVICE_REF &
36#endif
37
38// Define a macro for catching SYCL exceptions if exceptions are enabled
39#define EIGEN_SYCL_TRY_CATCH(X) \
40 do { \
41 EIGEN_TRY { X; } \
42 EIGEN_CATCH(const cl::sycl::exception& e) { \
43 EIGEN_THROW_X(std::runtime_error("SYCL exception at " + std::string(__FILE__) + ":" + std::to_string(__LINE__) + \
44 "\n" + e.what())); \
45 } \
46 } while (false)
47
48// Define a macro if local memory flags are unset or one of them is set
49// Setting both flags is the same as unsetting them
50#if (!defined(EIGEN_SYCL_LOCAL_MEM) && !defined(EIGEN_SYCL_NO_LOCAL_MEM)) || \
51 (defined(EIGEN_SYCL_LOCAL_MEM) && defined(EIGEN_SYCL_NO_LOCAL_MEM))
52#define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_ON 1
53#define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_OFF 1
54#elif defined(EIGEN_SYCL_LOCAL_MEM) && !defined(EIGEN_SYCL_NO_LOCAL_MEM)
55#define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_ON 1
56#elif !defined(EIGEN_SYCL_LOCAL_MEM) && defined(EIGEN_SYCL_NO_LOCAL_MEM)
57#define EIGEN_SYCL_LOCAL_MEM_UNSET_OR_OFF 1
58#endif
59
60#endif