From 553f50b246e549cd82d6f098373b11be9554bd49 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 17 Nov 2016 21:51:48 -0800 Subject: Added a way to detect errors generated by the opencl device from the host --- unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h index 67cf66e5f..fe8452d79 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h @@ -12,13 +12,16 @@ // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #if defined(EIGEN_USE_SYCL) && !defined(EIGEN_CXX11_TENSOR_TENSOR_DEVICE_SYCL_H) #define EIGEN_CXX11_TENSOR_TENSOR_DEVICE_SYCL_H namespace Eigen { struct SyclDevice { /// class members: - + bool exception_caught_ = false; + /// sycl queue mutable cl::sycl::queue m_queue; @@ -34,6 +37,7 @@ struct SyclDevice { for (const auto& e : l) { try { if (e) { + exception_caught_ = true; std::rethrow_exception(e); } } catch (const cl::sycl::exception& e) { @@ -231,6 +235,12 @@ struct SyclDevice { EIGEN_STRONG_INLINE void synchronize() const { m_queue.wait_and_throw(); } + + // This function checks if the runtime recorded an error for the + // underlying stream device. + EIGEN_STRONG_INLINE bool ok() const { + return !exception_caught_; + } }; } // end namespace Eigen -- cgit v1.2.3