mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-27 07:29:52 +08:00
Created a test to check that the sycl runtime can successfully report errors (like ivision by 0).
Small cleanup
This commit is contained in:
parent
004344cf54
commit
4349fc640e
@ -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
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user