diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2016-11-18 16:26:50 -0800 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2016-11-18 16:26:50 -0800 |
commit | dc601d79d14b82bf54b2e90cfa32ee0ce955e3e4 (patch) | |
tree | 562899b36c755f5b118f90647f622eda77837ca8 /unsupported | |
parent | b5e3285e1695ab94e1ca9ae30a05b9e7d816cd03 (diff) |
Added the ability to run test exclusively OpenCL devices that are listed by sycl::device::get_devices().
Diffstat (limited to 'unsupported')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h | 22 | ||||
-rw-r--r-- | unsupported/test/cxx11_tensor_broadcast_sycl.cpp | 16 |
2 files changed, 29 insertions, 9 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h index 7954d4f6c..3fe0219ac 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h @@ -50,6 +50,28 @@ struct QueueInterface { #endif {} + /// creating device by using selector + /// SyclStreamDevice is not owned. it is the caller's responsibility to destroy it. + explicit QueueInterface(cl::sycl::device d): +#ifdef EIGEN_EXCEPTIONS + m_queue(cl::sycl::queue(d, [&](cl::sycl::exception_list l) { + for (const auto& e : l) { + try { + if (e) { + exception_caught_ = true; + std::rethrow_exception(e); + } + } catch (cl::sycl::exception e) { + std::cerr << e.what() << std::endl; + } + } + })) +#else + m_queue(cl::sycl::queue(d)) +#endif + {} + + /// Allocating device pointer. This pointer is actually an 8 bytes host pointer used as key to access the sycl device buffer. /// The reason is that we cannot use device buffer as a pointer as a m_data in Eigen leafNode expressions. So we create a key /// pointer to be used in Eigen expression construction. When we convert the Eigen construction into the sycl construction we diff --git a/unsupported/test/cxx11_tensor_broadcast_sycl.cpp b/unsupported/test/cxx11_tensor_broadcast_sycl.cpp index 6d6d762ad..3dbb8d553 100644 --- a/unsupported/test/cxx11_tensor_broadcast_sycl.cpp +++ b/unsupported/test/cxx11_tensor_broadcast_sycl.cpp @@ -127,9 +127,11 @@ static void test_broadcast_sycl(const Eigen::SyclDevice &sycl_device){ sycl_device.deallocate(gpu_out_data); } -template<typename DataType, typename dev_Selector> void sycl_broadcast_test_per_device(dev_Selector s){ - QueueInterface queueInterface(s); +template<typename DataType> void sycl_broadcast_test_per_device(const cl::sycl::device& d){ + std::cout << "Running on " << d.template get_info<cl::sycl::info::device::name>() << std::endl; + QueueInterface queueInterface(d); auto sycl_device = Eigen::SyclDevice(&queueInterface); + test_broadcast_sycl_fixed<DataType, RowMajor, int>(sycl_device); test_broadcast_sycl<DataType, RowMajor, int>(sycl_device); test_broadcast_sycl_fixed<DataType, ColMajor, int>(sycl_device); @@ -142,11 +144,7 @@ template<typename DataType, typename dev_Selector> void sycl_broadcast_test_per_ } void test_cxx11_tensor_broadcast_sycl() { - printf("Test on GPU: OpenCL\n"); - CALL_SUBTEST(sycl_broadcast_test_per_device<float>((cl::sycl::gpu_selector()))); - printf("repeating the test on CPU: OpenCL\n"); - CALL_SUBTEST(sycl_broadcast_test_per_device<float>((cl::sycl::cpu_selector()))); - printf("repeating the test on CPU: HOST\n"); - CALL_SUBTEST(sycl_broadcast_test_per_device<float>((cl::sycl::host_selector()))); - printf("Test Passed******************\n" ); + for (const auto& device : cl::sycl::device::get_devices()) { + CALL_SUBTEST(sycl_broadcast_test_per_device<float>(device)); + } } |