aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-11-17 21:51:48 -0800
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-11-17 21:51:48 -0800
commit553f50b246e549cd82d6f098373b11be9554bd49 (patch)
tree7c866ddd35fbdc82992f76fbf1873f1cb6544577
parent72a45d32e99f24411c822fe1edd8b33735dd8e0c (diff)
Added a way to detect errors generated by the opencl device from the host
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h12
-rw-r--r--unsupported/test/cxx11_tensor_device_sycl.cpp12
2 files changed, 15 insertions, 9 deletions
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 <iostream>
+
#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
diff --git a/unsupported/test/cxx11_tensor_device_sycl.cpp b/unsupported/test/cxx11_tensor_device_sycl.cpp
index f92e38ed5..8289959eb 100644
--- a/unsupported/test/cxx11_tensor_device_sycl.cpp
+++ b/unsupported/test/cxx11_tensor_device_sycl.cpp
@@ -42,17 +42,13 @@ void test_device_memory(const Eigen::SyclDevice &sycl_device) {
void test_device_exceptions(const Eigen::SyclDevice &sycl_device) {
- bool threw_exception = false;
+ VERIFY(sycl_device.ok());
array<int, 1> tensorDims = {{100}};
int* gpu_data = static_cast<int*>(sycl_device.allocate(100*sizeof(int)));
TensorMap<Tensor<int, 1>> in(gpu_data, tensorDims);
TensorMap<Tensor<int, 1>> out(gpu_data, tensorDims);
- try {
- out.device(sycl_device) = in / in.constant(0);
- } catch(...) {
- threw_exception = true;
- }
- VERIFY(threw_exception);
+ out.device(sycl_device) = in / in.constant(0);
+ VERIFY(!sycl_device.ok());
sycl_device.deallocate(gpu_data);
}
@@ -62,5 +58,5 @@ void test_cxx11_tensor_device_sycl() {
Eigen::SyclDevice sycl_device(s);
CALL_SUBTEST(test_device_memory(sycl_device));
// This deadlocks
- // CALL_SUBTEST(test_device_exceptions(sycl_device));
+ //CALL_SUBTEST(test_device_exceptions(sycl_device));
}