baracuda_cuda_sys/
status.rs1use baracuda_types::CudaStatus;
8
9#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
11#[repr(transparent)]
12pub struct CUresult(pub i32);
13
14impl CUresult {
15 pub const SUCCESS: Self = Self(0);
16 pub const ERROR_INVALID_VALUE: Self = Self(1);
17 pub const ERROR_OUT_OF_MEMORY: Self = Self(2);
18 pub const ERROR_NOT_INITIALIZED: Self = Self(3);
19 pub const ERROR_DEINITIALIZED: Self = Self(4);
20 pub const ERROR_PROFILER_DISABLED: Self = Self(5);
21 pub const ERROR_STUB_LIBRARY: Self = Self(34);
22 pub const ERROR_DEVICE_UNAVAILABLE: Self = Self(46);
23 pub const ERROR_NO_DEVICE: Self = Self(100);
24 pub const ERROR_INVALID_DEVICE: Self = Self(101);
25 pub const ERROR_DEVICE_NOT_LICENSED: Self = Self(102);
26 pub const ERROR_INVALID_IMAGE: Self = Self(200);
27 pub const ERROR_INVALID_CONTEXT: Self = Self(201);
28 pub const ERROR_CONTEXT_ALREADY_CURRENT: Self = Self(202);
29 pub const ERROR_MAP_FAILED: Self = Self(205);
30 pub const ERROR_UNMAP_FAILED: Self = Self(206);
31 pub const ERROR_ARRAY_IS_MAPPED: Self = Self(207);
32 pub const ERROR_ALREADY_MAPPED: Self = Self(208);
33 pub const ERROR_NO_BINARY_FOR_GPU: Self = Self(209);
34 pub const ERROR_ALREADY_ACQUIRED: Self = Self(210);
35 pub const ERROR_NOT_MAPPED: Self = Self(211);
36 pub const ERROR_NOT_MAPPED_AS_ARRAY: Self = Self(212);
37 pub const ERROR_NOT_MAPPED_AS_POINTER: Self = Self(213);
38 pub const ERROR_ECC_UNCORRECTABLE: Self = Self(214);
39 pub const ERROR_UNSUPPORTED_LIMIT: Self = Self(215);
40 pub const ERROR_CONTEXT_ALREADY_IN_USE: Self = Self(216);
41 pub const ERROR_PEER_ACCESS_UNSUPPORTED: Self = Self(217);
42 pub const ERROR_INVALID_PTX: Self = Self(218);
43 pub const ERROR_INVALID_GRAPHICS_CONTEXT: Self = Self(219);
44 pub const ERROR_NVLINK_UNCORRECTABLE: Self = Self(220);
45 pub const ERROR_JIT_COMPILER_NOT_FOUND: Self = Self(221);
46 pub const ERROR_UNSUPPORTED_PTX_VERSION: Self = Self(222);
47 pub const ERROR_JIT_COMPILATION_DISABLED: Self = Self(223);
48 pub const ERROR_UNSUPPORTED_EXEC_AFFINITY: Self = Self(224);
49 pub const ERROR_INVALID_SOURCE: Self = Self(300);
50 pub const ERROR_FILE_NOT_FOUND: Self = Self(301);
51 pub const ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND: Self = Self(302);
52 pub const ERROR_SHARED_OBJECT_INIT_FAILED: Self = Self(303);
53 pub const ERROR_OPERATING_SYSTEM: Self = Self(304);
54 pub const ERROR_INVALID_HANDLE: Self = Self(400);
55 pub const ERROR_ILLEGAL_STATE: Self = Self(401);
56 pub const ERROR_NOT_FOUND: Self = Self(500);
57 pub const ERROR_NOT_READY: Self = Self(600);
58 pub const ERROR_ILLEGAL_ADDRESS: Self = Self(700);
59 pub const ERROR_LAUNCH_OUT_OF_RESOURCES: Self = Self(701);
60 pub const ERROR_LAUNCH_TIMEOUT: Self = Self(702);
61 pub const ERROR_LAUNCH_INCOMPATIBLE_TEXTURING: Self = Self(703);
62 pub const ERROR_PEER_ACCESS_ALREADY_ENABLED: Self = Self(704);
63 pub const ERROR_PEER_ACCESS_NOT_ENABLED: Self = Self(705);
64 pub const ERROR_PRIMARY_CONTEXT_ACTIVE: Self = Self(708);
65 pub const ERROR_CONTEXT_IS_DESTROYED: Self = Self(709);
66 pub const ERROR_ASSERT: Self = Self(710);
67 pub const ERROR_TOO_MANY_PEERS: Self = Self(711);
68 pub const ERROR_HOST_MEMORY_ALREADY_REGISTERED: Self = Self(712);
69 pub const ERROR_HOST_MEMORY_NOT_REGISTERED: Self = Self(713);
70 pub const ERROR_HARDWARE_STACK_ERROR: Self = Self(714);
71 pub const ERROR_ILLEGAL_INSTRUCTION: Self = Self(715);
72 pub const ERROR_MISALIGNED_ADDRESS: Self = Self(716);
73 pub const ERROR_INVALID_ADDRESS_SPACE: Self = Self(717);
74 pub const ERROR_INVALID_PC: Self = Self(718);
75 pub const ERROR_LAUNCH_FAILED: Self = Self(719);
76 pub const ERROR_COOPERATIVE_LAUNCH_TOO_LARGE: Self = Self(720);
77 pub const ERROR_NOT_PERMITTED: Self = Self(800);
78 pub const ERROR_NOT_SUPPORTED: Self = Self(801);
79 pub const ERROR_SYSTEM_NOT_READY: Self = Self(802);
80 pub const ERROR_SYSTEM_DRIVER_MISMATCH: Self = Self(803);
81 pub const ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE: Self = Self(804);
82 pub const ERROR_MPS_CONNECTION_FAILED: Self = Self(805);
83 pub const ERROR_MPS_RPC_FAILURE: Self = Self(806);
84 pub const ERROR_MPS_SERVER_NOT_READY: Self = Self(807);
85 pub const ERROR_MPS_MAX_CLIENTS_REACHED: Self = Self(808);
86 pub const ERROR_MPS_MAX_CONNECTIONS_REACHED: Self = Self(809);
87 pub const ERROR_STREAM_CAPTURE_UNSUPPORTED: Self = Self(900);
88 pub const ERROR_STREAM_CAPTURE_INVALIDATED: Self = Self(901);
89 pub const ERROR_STREAM_CAPTURE_MERGE: Self = Self(902);
90 pub const ERROR_STREAM_CAPTURE_UNMATCHED: Self = Self(903);
91 pub const ERROR_STREAM_CAPTURE_UNJOINED: Self = Self(904);
92 pub const ERROR_STREAM_CAPTURE_ISOLATION: Self = Self(905);
93 pub const ERROR_STREAM_CAPTURE_IMPLICIT: Self = Self(906);
94 pub const ERROR_CAPTURED_EVENT: Self = Self(907);
95 pub const ERROR_STREAM_CAPTURE_WRONG_THREAD: Self = Self(908);
96 pub const ERROR_TIMEOUT: Self = Self(909);
97 pub const ERROR_GRAPH_EXEC_UPDATE_FAILURE: Self = Self(910);
98 pub const ERROR_EXTERNAL_DEVICE: Self = Self(911);
99 pub const ERROR_INVALID_CLUSTER_SIZE: Self = Self(912);
100 pub const ERROR_UNKNOWN: Self = Self(999);
101
102 pub const fn is_success(self) -> bool {
103 self.0 == 0
104 }
105}
106
107impl CudaStatus for CUresult {
108 fn code(self) -> i32 {
109 self.0
110 }
111
112 fn name(self) -> &'static str {
113 match self.0 {
114 0 => "CUDA_SUCCESS",
115 1 => "CUDA_ERROR_INVALID_VALUE",
116 2 => "CUDA_ERROR_OUT_OF_MEMORY",
117 3 => "CUDA_ERROR_NOT_INITIALIZED",
118 4 => "CUDA_ERROR_DEINITIALIZED",
119 5 => "CUDA_ERROR_PROFILER_DISABLED",
120 34 => "CUDA_ERROR_STUB_LIBRARY",
121 46 => "CUDA_ERROR_DEVICE_UNAVAILABLE",
122 100 => "CUDA_ERROR_NO_DEVICE",
123 101 => "CUDA_ERROR_INVALID_DEVICE",
124 200 => "CUDA_ERROR_INVALID_IMAGE",
125 201 => "CUDA_ERROR_INVALID_CONTEXT",
126 205 => "CUDA_ERROR_MAP_FAILED",
127 206 => "CUDA_ERROR_UNMAP_FAILED",
128 209 => "CUDA_ERROR_NO_BINARY_FOR_GPU",
129 214 => "CUDA_ERROR_ECC_UNCORRECTABLE",
130 216 => "CUDA_ERROR_CONTEXT_ALREADY_IN_USE",
131 218 => "CUDA_ERROR_INVALID_PTX",
132 220 => "CUDA_ERROR_NVLINK_UNCORRECTABLE",
133 300 => "CUDA_ERROR_INVALID_SOURCE",
134 301 => "CUDA_ERROR_FILE_NOT_FOUND",
135 400 => "CUDA_ERROR_INVALID_HANDLE",
136 500 => "CUDA_ERROR_NOT_FOUND",
137 600 => "CUDA_ERROR_NOT_READY",
138 700 => "CUDA_ERROR_ILLEGAL_ADDRESS",
139 701 => "CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES",
140 702 => "CUDA_ERROR_LAUNCH_TIMEOUT",
141 708 => "CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE",
142 709 => "CUDA_ERROR_CONTEXT_IS_DESTROYED",
143 710 => "CUDA_ERROR_ASSERT",
144 716 => "CUDA_ERROR_MISALIGNED_ADDRESS",
145 719 => "CUDA_ERROR_LAUNCH_FAILED",
146 800 => "CUDA_ERROR_NOT_PERMITTED",
147 801 => "CUDA_ERROR_NOT_SUPPORTED",
148 999 => "CUDA_ERROR_UNKNOWN",
149 _ => "CUDA_ERROR_UNRECOGNIZED",
150 }
151 }
152
153 fn description(self) -> &'static str {
154 match self.0 {
155 0 => "no error",
156 1 => "invalid argument",
157 2 => "out of memory",
158 3 => "driver not initialized",
159 4 => "driver has been deinitialized",
160 100 => "no CUDA-capable device is detected",
161 101 => "invalid device ordinal",
162 200 => "device kernel image is invalid",
163 201 => "invalid device context",
164 209 => "no kernel image is available for execution on the device",
165 214 => "uncorrectable ECC error encountered",
166 218 => "invalid PTX",
167 219 => "invalid graphics context",
168 300 => "invalid source",
169 301 => "file not found",
170 400 => "invalid resource handle",
171 500 => "named symbol not found",
172 600 => "operation not yet complete",
173 700 => "an illegal memory access was encountered",
174 701 => "launch requires resources the device cannot provide",
175 702 => "launch timed out and was terminated",
176 708 => "primary context is already active",
177 709 => "context is destroyed",
178 716 => "misaligned address",
179 719 => "unspecified launch failure",
180 800 => "operation not permitted",
181 801 => "operation not supported",
182 999 => "unknown error",
183 _ => "unrecognized CUDA driver error code",
184 }
185 }
186
187 fn is_success(self) -> bool {
188 CUresult::is_success(self)
189 }
190
191 fn library(self) -> &'static str {
192 "cuda-driver"
193 }
194}