From 4349fc640ee107ad1833a9f44f312e9becdfc7ed Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 17 Nov 2016 20:27:54 -0800 Subject: [PATCH] Created a test to check that the sycl runtime can successfully report errors (like ivision by 0). Small cleanup --- .../Eigen/CXX11/src/Tensor/TensorDeviceSycl.h | 3 +- unsupported/test/cxx11_tensor_device_sycl.cpp | 36 +++++++++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h index 7f0f16de3..19686177e 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h @@ -158,10 +158,9 @@ struct SyclDevice { }); }); m_queue.throw_asynchronous(); - } else{ + } else { eigen_assert("no source or destination device memory found."); } - //::memcpy(dst, src, n); } /// The memcpyHostToDevice is used to copy the device only pointer to a host pointer. Using the device diff --git a/unsupported/test/cxx11_tensor_device_sycl.cpp b/unsupported/test/cxx11_tensor_device_sycl.cpp index 584fa8026..f92e38ed5 100644 --- a/unsupported/test/cxx11_tensor_device_sycl.cpp +++ b/unsupported/test/cxx11_tensor_device_sycl.cpp @@ -21,24 +21,46 @@ #include #include -void test_device_sycl(const Eigen::SyclDevice &sycl_device) { - std::cout <<"Helo from ComputeCpp: the requested device exists and the device name is : " - << sycl_device.m_queue.get_device(). template get_info() <() + << std::endl; int sizeDim1 = 100; array tensorRange = {{sizeDim1}}; Tensor in(tensorRange); Tensor in1(tensorRange); memset(in1.data(), 1,in1.size()*sizeof(int)); - int * gpu_in_data = static_cast(sycl_device.allocate(in.size()*sizeof(int))); - sycl_device.memset(gpu_in_data, 1,in.size()*sizeof(int) ); + int* gpu_in_data = static_cast(sycl_device.allocate(in.size()*sizeof(int))); + sycl_device.memset(gpu_in_data, 1, in.size()*sizeof(int) ); sycl_device.memcpyDeviceToHost(in.data(), gpu_in_data, in.size()*sizeof(int) ); - for (int i=0; i tensorDims = {{100}}; + int* gpu_data = static_cast(sycl_device.allocate(100*sizeof(int))); + TensorMap> in(gpu_data, tensorDims); + TensorMap> out(gpu_data, tensorDims); + try { + out.device(sycl_device) = in / in.constant(0); + } catch(...) { + threw_exception = true; + } + VERIFY(threw_exception); + sycl_device.deallocate(gpu_data); +} + + void test_cxx11_tensor_device_sycl() { cl::sycl::gpu_selector s; Eigen::SyclDevice sycl_device(s); - CALL_SUBTEST(test_device_sycl(sycl_device)); + CALL_SUBTEST(test_device_memory(sycl_device)); + // This deadlocks + // CALL_SUBTEST(test_device_exceptions(sycl_device)); }