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
69
70
71
72
73
74
75
76
77
use std::{fmt, error};
#[derive(Debug, Copy, Clone)]
pub enum Error {
NotInitialized,
AllocFailed,
InternalError(&'static str),
InvalidValue(&'static str),
ArchMismatch,
MappingError,
ExecutionFailed,
NotSupported(&'static str),
LicenseError,
Unknown(&'static str),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::NotInitialized => write!(f, "{:?}", error::Error::description(self)),
Error::AllocFailed => write!(f, "{:?}", error::Error::description(self)),
Error::InternalError(ref err) => write!(f, "{:?}", err),
Error::InvalidValue(ref err) => write!(f, "{:?}", err),
Error::ArchMismatch => write!(f, "{:?}", error::Error::description(self)),
Error::MappingError => write!(f, "{:?}", error::Error::description(self)),
Error::ExecutionFailed => write!(f, "{:?}", error::Error::description(self)),
Error::NotSupported(ref err) => write!(f, "{:?}", err),
Error::LicenseError => write!(f, "{:?}", error::Error::description(self)),
Error::Unknown(ref err) => write!(f, "{:?}", err),
}
}
}
impl error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::NotInitialized => "CUDA Driver/Runtime API not initialized.",
Error::AllocFailed => "The resources could not be allocated.",
Error::InternalError(ref err) => err,
Error::InvalidValue(ref err) => err,
Error::ArchMismatch => "cuBLAS only supports devices with compute capabilities greater than or equal to 1.3.",
Error::MappingError => "There was an error accessing GPU memory.",
Error::ExecutionFailed => "Execution failed to launch on the GPU.",
Error::NotSupported(ref err) => err,
Error::LicenseError => "There is an error with the license. Check that it is present, unexpired and the NVIDIA_LICENSE_FILE environment variable has been set correctly.",
Error::Unknown(ref err) => err,
}
}
fn cause(&self) -> Option<&error::Error> {
match *self {
Error::NotInitialized => None,
Error::AllocFailed => None,
Error::InternalError(_) => None,
Error::InvalidValue(_) => None,
Error::ArchMismatch => None,
Error::MappingError => None,
Error::ExecutionFailed => None,
Error::NotSupported(_) => None,
Error::LicenseError => None,
Error::Unknown(_) => None,
}
}
}