aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test/cxx11_tensor_device_sycl.cpp
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-11-17 20:27:54 -0800
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-11-17 20:27:54 -0800
commit4349fc640ee107ad1833a9f44f312e9becdfc7ed (patch)
tree34c18bb9a2348ee2a9d930931303d0ff35fc9d01 /unsupported/test/cxx11_tensor_device_sycl.cpp
parent004344cf5447f40166043c5003c7dbf097ff1a7c (diff)
Created a test to check that the sycl runtime can successfully report errors (like ivision by 0).
Small cleanup
Diffstat (limited to 'unsupported/test/cxx11_tensor_device_sycl.cpp')
-rw-r--r--unsupported/test/cxx11_tensor_device_sycl.cpp36
1 files changed, 29 insertions, 7 deletions
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 <unsupported/Eigen/CXX11/Tensor>
#include<stdint.h>
-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<cl::sycl::info::device::name>() <<std::endl;;
+void test_device_memory(const Eigen::SyclDevice &sycl_device) {
+ std::cout << "Running on: "
+ << sycl_device.m_queue.get_device(). template get_info<cl::sycl::info::device::name>()
+ << std::endl;
int sizeDim1 = 100;
array<int, 1> tensorRange = {{sizeDim1}};
Tensor<int, 1> in(tensorRange);
Tensor<int, 1> in1(tensorRange);
memset(in1.data(), 1,in1.size()*sizeof(int));
- int * gpu_in_data = static_cast<int*>(sycl_device.allocate(in.size()*sizeof(int)));
- sycl_device.memset(gpu_in_data, 1,in.size()*sizeof(int) );
+ int* gpu_in_data = static_cast<int*>(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<in.size(); i++)
+ for (int i=0; i<in.size(); i++) {
VERIFY_IS_APPROX(in(i), in1(i));
+ }
sycl_device.deallocate(gpu_in_data);
}
+
+
+void test_device_exceptions(const Eigen::SyclDevice &sycl_device) {
+ bool threw_exception = false;
+ 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);
+ 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));
}