mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-13 18:03:13 +08:00
Added the ability to run test exclusively OpenCL devices that are listed by sycl::device::get_devices().
This commit is contained in:
parent
b5e3285e16
commit
dc601d79d1
@ -50,6 +50,28 @@ struct QueueInterface {
|
|||||||
#endif
|
#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.
|
/// 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
|
/// 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
|
/// pointer to be used in Eigen expression construction. When we convert the Eigen construction into the sycl construction we
|
||||||
|
@ -127,9 +127,11 @@ static void test_broadcast_sycl(const Eigen::SyclDevice &sycl_device){
|
|||||||
sycl_device.deallocate(gpu_out_data);
|
sycl_device.deallocate(gpu_out_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename DataType, typename dev_Selector> void sycl_broadcast_test_per_device(dev_Selector s){
|
template<typename DataType> void sycl_broadcast_test_per_device(const cl::sycl::device& d){
|
||||||
QueueInterface queueInterface(s);
|
std::cout << "Running on " << d.template get_info<cl::sycl::info::device::name>() << std::endl;
|
||||||
|
QueueInterface queueInterface(d);
|
||||||
auto sycl_device = Eigen::SyclDevice(&queueInterface);
|
auto sycl_device = Eigen::SyclDevice(&queueInterface);
|
||||||
|
|
||||||
test_broadcast_sycl_fixed<DataType, RowMajor, int>(sycl_device);
|
test_broadcast_sycl_fixed<DataType, RowMajor, int>(sycl_device);
|
||||||
test_broadcast_sycl<DataType, RowMajor, int>(sycl_device);
|
test_broadcast_sycl<DataType, RowMajor, int>(sycl_device);
|
||||||
test_broadcast_sycl_fixed<DataType, ColMajor, 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() {
|
void test_cxx11_tensor_broadcast_sycl() {
|
||||||
printf("Test on GPU: OpenCL\n");
|
for (const auto& device : cl::sycl::device::get_devices()) {
|
||||||
CALL_SUBTEST(sycl_broadcast_test_per_device<float>((cl::sycl::gpu_selector())));
|
CALL_SUBTEST(sycl_broadcast_test_per_device<float>(device));
|
||||||
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" );
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user