1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#[cfg(feature = "opencl")]
use opencl3::{device::DeviceInfo, error_codes::ClError, program::ProgramInfo};
#[cfg(feature = "cuda")]
use rustacuda::error::CudaError;
#[derive(thiserror::Error, Debug)]
#[allow(clippy::upper_case_acronyms)]
pub enum GPUError {
#[cfg(feature = "opencl")]
#[error("Opencl3 Error: {0}{}", match .1 {
Some(message) => format!(" {}", message),
None => "".to_string(),
})]
Opencl3(ClError, Option<String>),
#[cfg(feature = "opencl")]
#[error("Program info not available!")]
ProgramInfoNotAvailable(ProgramInfo),
#[cfg(feature = "opencl")]
#[error("Device info not available!")]
DeviceInfoNotAvailable(DeviceInfo),
#[cfg(feature = "cuda")]
#[error("Cuda Error: {0}")]
Cuda(#[from] CudaError),
#[error("Device not found!")]
DeviceNotFound,
#[error("Kernel with name {0} not found!")]
KernelNotFound(String),
#[error("IO Error: {0}")]
IO(#[from] std::io::Error),
#[error("Vendor {0} is not supported.")]
UnsupportedVendor(String),
#[error("{0}")]
InvalidId(String),
#[error("{0}")]
Generic(String),
}
#[allow(clippy::upper_case_acronyms)]
pub type GPUResult<T> = std::result::Result<T, GPUError>;
#[cfg(feature = "opencl")]
impl From<ClError> for GPUError {
fn from(error: ClError) -> Self {
GPUError::Opencl3(error, None)
}
}