mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-21 17:19:36 +08:00
adding Benoit changes on the TensorDeviceSycl.h
This commit is contained in:
parent
622805a0c5
commit
15e226d7d3
@ -21,6 +21,8 @@ namespace Eigen {
|
||||
|
||||
struct QueueInterface {
|
||||
/// class members:
|
||||
bool exception_caught_ = false;
|
||||
|
||||
/// std::map is the container used to make sure that we create only one buffer
|
||||
/// per pointer. The lifespan of the buffer now depends on the lifespan of SyclDevice.
|
||||
/// If a non-read-only pointer is needed to be accessed on the host we should manually deallocate it.
|
||||
@ -35,7 +37,7 @@ struct QueueInterface {
|
||||
for (const auto& e : l) {
|
||||
try {
|
||||
if(e){
|
||||
std::rethrow_exception(e);
|
||||
exception_caught_ = true;;
|
||||
}
|
||||
} catch (cl::sycl::exception e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
@ -86,6 +88,11 @@ struct QueueInterface {
|
||||
//return buffer_map.end();
|
||||
}
|
||||
|
||||
// This function checks if the runtime recorded an error for the
|
||||
// underlying stream device.
|
||||
EIGEN_STRONG_INLINE bool ok() const {
|
||||
return !exception_caught_;
|
||||
}
|
||||
// destructor
|
||||
~QueueInterface() { buffer_map.clear(); }
|
||||
};
|
||||
@ -227,8 +234,14 @@ struct SyclDevice {
|
||||
EIGEN_STRONG_INLINE void synchronize() const {
|
||||
sycl_queue().wait_and_throw();
|
||||
}
|
||||
// This function checks if the runtime recorded an error for the
|
||||
// underlying stream device.
|
||||
EIGEN_STRONG_INLINE bool ok() const {
|
||||
return m_queu_stream->ok();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
#endif // EIGEN_CXX11_TENSOR_TENSOR_DEVICE_SYCL_H
|
||||
|
@ -41,18 +41,15 @@ void test_device_sycl(const Eigen::SyclDevice &sycl_device) {
|
||||
|
||||
template <typename DataType, int DataLayout>
|
||||
void test_device_exceptions(const Eigen::SyclDevice &sycl_device) {
|
||||
bool threw_exception = false;
|
||||
VERIFY(sycl_device.ok());
|
||||
int sizeDim1 = 100;
|
||||
array<int, 1> tensorDims = {{sizeDim1}};
|
||||
DataType* gpu_data = static_cast<DataType*>(sycl_device.allocate(sizeDim1*sizeof(DataType)));
|
||||
TensorMap<Tensor<DataType, 1,DataLayout>> in(gpu_data, tensorDims);
|
||||
TensorMap<Tensor<DataType, 1,DataLayout>> out(gpu_data, tensorDims);
|
||||
try {
|
||||
out.device(sycl_device) = in / in.constant(0);
|
||||
} catch(...) {
|
||||
threw_exception = true;
|
||||
}
|
||||
VERIFY(threw_exception);
|
||||
|
||||
out.device(sycl_device) = in / in.constant(0);
|
||||
VERIFY(!sycl_device.ok());
|
||||
sycl_device.deallocate(gpu_data);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user