aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h22
-rw-r--r--unsupported/test/cxx11_tensor_broadcast_sycl.cpp16
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));
+ }
}