1#![allow(deprecated, non_camel_case_types)]
2
3use std::ptr;
4
5pub use num_complex::{Complex, Complex32, Complex64};
6use num_enum::{IntoPrimitive, TryFromPrimitive};
7use singe_cuda_sys::{driver, library_types};
8
9pub use half::{bf16, f16};
10
11use singe_core::{impl_enum_conversion, impl_enum_display};
12
13use crate::view::{DeviceRepr, ZeroableDeviceRepr};
14
15macro_rules! impl_float_storage {
16 ($name:ident, $bits:ty) => {
17 #[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Hash)]
18 #[repr(transparent)]
19 pub struct $name(pub $bits);
20
21 impl $name {
22 pub const fn from_bits(bits: $bits) -> Self {
23 Self(bits)
24 }
25
26 pub const fn to_bits(self) -> $bits {
27 self.0
28 }
29 }
30 };
31}
32
33impl_float_storage!(f8e4m3, u8);
34impl_float_storage!(f8e5m2, u8);
35impl_float_storage!(f8ue8m0, u8);
36impl_float_storage!(f6e2m3, u8);
37impl_float_storage!(f6e3m2, u8);
38impl_float_storage!(f4e2m1, u8);
39
40#[derive(Debug, Clone, Copy)]
41#[repr(transparent)]
42pub struct HostFunction(driver::CUhostFn);
46
47#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
48#[repr(transparent)]
49pub struct DeviceFunction(driver::CUfunction);
55
56#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
57#[repr(transparent)]
58pub struct DevicePtr(*mut ());
59
60unsafe impl DeviceRepr for DevicePtr {}
61unsafe impl ZeroableDeviceRepr for DevicePtr {}
62
63impl HostFunction {
64 pub const unsafe fn new(raw: driver::CUhostFn) -> Self {
71 Self(raw)
72 }
73
74 pub const unsafe fn from_raw(raw: driver::CUhostFn) -> Self {
81 unsafe { Self::new(raw) }
82 }
83
84 pub const fn as_raw(self) -> driver::CUhostFn {
85 self.0
86 }
87}
88
89impl DeviceFunction {
90 pub const unsafe fn new(raw: driver::CUfunction) -> Self {
98 Self(raw)
99 }
100
101 pub const unsafe fn from_raw(raw: driver::CUfunction) -> Self {
109 unsafe { Self::new(raw) }
110 }
111
112 pub const fn as_raw(self) -> driver::CUfunction {
113 self.0
114 }
115
116 pub const fn is_null(self) -> bool {
117 self.0.is_null()
118 }
119}
120
121impl DevicePtr {
122 pub const fn null() -> Self {
123 Self(ptr::null_mut())
124 }
125
126 pub const unsafe fn new(raw: *mut ()) -> Self {
134 Self(raw)
135 }
136
137 pub const unsafe fn from_raw(raw: *mut ()) -> Self {
145 unsafe { Self::new(raw.cast()) }
146 }
147
148 pub const fn as_raw(self) -> *mut () {
149 self.0.cast()
150 }
151
152 pub const fn as_ptr(self) -> *mut () {
153 self.0
154 }
155
156 pub const fn as_const_ptr(self) -> *const () {
157 self.0.cast_const()
158 }
159
160 pub const fn is_null(self) -> bool {
161 self.0.is_null()
162 }
163
164 pub const fn cast<T>(self) -> *mut T {
165 self.0.cast()
166 }
167}
168
169impl From<HostFunction> for driver::CUhostFn {
170 fn from(value: HostFunction) -> Self {
171 value.as_raw()
172 }
173}
174
175impl From<DeviceFunction> for driver::CUfunction {
176 fn from(value: DeviceFunction) -> Self {
177 value.as_raw()
178 }
179}
180
181impl From<DevicePtr> for *mut () {
182 fn from(value: DevicePtr) -> Self {
183 value.as_raw()
184 }
185}
186
187bitflags::bitflags! {
188 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
189 pub struct GraphicsRegisterFlags: u32 {
190 const NONE = driver::CUgraphicsRegisterFlags::CU_GRAPHICS_REGISTER_FLAGS_NONE as _;
191 const READ_ONLY = driver::CUgraphicsRegisterFlags::CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY as _;
192 const WRITE_DISCARD = driver::CUgraphicsRegisterFlags::CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD as _;
193 const SURFACE_LDST = driver::CUgraphicsRegisterFlags::CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST as _;
194 const TEXTURE_GATHER = driver::CUgraphicsRegisterFlags::CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER as _;
195 }
196}
197
198bitflags::bitflags! {
199 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
200 pub struct GraphicsMapResourceFlags: u32 {
201 const NONE = driver::CUgraphicsMapResourceFlags::CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE as _;
202 const READ_ONLY = driver::CUgraphicsMapResourceFlags::CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY as _;
203 const WRITE_DISCARD = driver::CUgraphicsMapResourceFlags::CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD as _;
204 }
205}
206
207#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
208#[repr(u32)]
209#[non_exhaustive]
210pub enum LibraryProperty {
211 Major = library_types::libraryPropertyType::MAJOR_VERSION as _,
212 Minor = library_types::libraryPropertyType::MINOR_VERSION as _,
213 Patch = library_types::libraryPropertyType::PATCH_LEVEL as _,
214}
215
216impl_enum_conversion!(library_types::libraryPropertyType, LibraryProperty);
217
218impl_enum_display!(LibraryProperty, {
219 Self::Major => "MAJOR_VERSION",
220 Self::Minor => "MINOR_VERSION",
221 Self::Patch => "PATCH_LEVEL",
222});
223
224#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
225#[repr(u32)]
226#[non_exhaustive]
227pub enum EmulationStrategy {
228 Default = library_types::cudaEmulationStrategy::CUDA_EMULATION_STRATEGY_DEFAULT as _,
229 Performant = library_types::cudaEmulationStrategy::CUDA_EMULATION_STRATEGY_PERFORMANT as _,
230 Eager = library_types::cudaEmulationStrategy::CUDA_EMULATION_STRATEGY_EAGER as _,
231}
232
233impl_enum_conversion!(library_types::cudaEmulationStrategy, EmulationStrategy);
234
235impl_enum_display!(EmulationStrategy, {
236 Self::Default => "CUDA_EMULATION_STRATEGY_DEFAULT",
237 Self::Performant => "CUDA_EMULATION_STRATEGY_PERFORMANT",
238 Self::Eager => "CUDA_EMULATION_STRATEGY_EAGER",
239});
240
241#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
242#[repr(u32)]
243#[non_exhaustive]
244pub enum EmulationMantissaControl {
245 Dynamic =
246 library_types::cudaEmulationMantissaControl::CUDA_EMULATION_MANTISSA_CONTROL_DYNAMIC as _,
247 Fixed = library_types::cudaEmulationMantissaControl::CUDA_EMULATION_MANTISSA_CONTROL_FIXED as _,
248}
249
250impl_enum_conversion!(
251 library_types::cudaEmulationMantissaControl,
252 EmulationMantissaControl
253);
254
255impl_enum_display!(EmulationMantissaControl, {
256 Self::Dynamic => "CUDA_EMULATION_MANTISSA_CONTROL_DYNAMIC",
257 Self::Fixed => "CUDA_EMULATION_MANTISSA_CONTROL_FIXED",
258});
259
260bitflags::bitflags! {
261 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
262 pub struct EmulationSpecialValuesSupport: u32 {
263 const NONE = library_types::cudaEmulationSpecialValuesSupport::CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_NONE as _;
264 const INFINITY = library_types::cudaEmulationSpecialValuesSupport::CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_INFINITY as _;
265 const NAN = library_types::cudaEmulationSpecialValuesSupport::CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_NAN as _;
266 const DEFAULT = library_types::cudaEmulationSpecialValuesSupport::CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_DEFAULT as _;
267 }
268}
269
270impl From<library_types::cudaEmulationSpecialValuesSupport> for EmulationSpecialValuesSupport {
271 fn from(value: library_types::cudaEmulationSpecialValuesSupport) -> Self {
272 Self::from_bits_retain(value as u32)
273 }
274}
275
276impl From<EmulationSpecialValuesSupport> for library_types::cudaEmulationSpecialValuesSupport {
277 fn from(value: EmulationSpecialValuesSupport) -> Self {
278 unsafe {
279 core::mem::transmute::<u32, library_types::cudaEmulationSpecialValuesSupport>(
280 value.bits(),
281 )
282 }
283 }
284}
285
286#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
287#[repr(u32)]
288#[non_exhaustive]
289pub enum PointerAttribute {
290 Context = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_CONTEXT as _,
291 MemoryType = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MEMORY_TYPE as _,
292 DevicePointer = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_DEVICE_POINTER as _,
293 HostPointer = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_HOST_POINTER as _,
294 P2pTokens = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_P2P_TOKENS as _,
295 SyncMemops = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_SYNC_MEMOPS as _,
296 BufferId = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_BUFFER_ID as _,
297 IsManaged = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_MANAGED as _,
298 DeviceOrdinal = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL as _,
299 IsLegacyCudaIpcCapable =
300 driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE as _,
301 RangeStartAddr = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_RANGE_START_ADDR as _,
302 RangeSize = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_RANGE_SIZE as _,
303 Mapped = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MAPPED as _,
304 AllowedHandleTypes =
305 driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES as _,
306 IsGpuDirectRdmaCapable =
307 driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE as _,
308 AccessFlags = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_ACCESS_FLAGS as _,
309 MempoolHandle = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MEMPOOL_HANDLE as _,
310 MappingSize = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MAPPING_SIZE as _,
311 MappingBaseAddr = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MAPPING_BASE_ADDR as _,
312 MemoryBlockId = driver::CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MEMORY_BLOCK_ID as _,
313}
314
315impl_enum_conversion!(u32, driver::CUpointer_attribute, PointerAttribute);
316
317impl_enum_display!(PointerAttribute, {
318 Self::Context => "CU_POINTER_ATTRIBUTE_CONTEXT",
319 Self::MemoryType => "CU_POINTER_ATTRIBUTE_MEMORY_TYPE",
320 Self::DevicePointer => "CU_POINTER_ATTRIBUTE_DEVICE_POINTER",
321 Self::HostPointer => "CU_POINTER_ATTRIBUTE_HOST_POINTER",
322 Self::P2pTokens => "CU_POINTER_ATTRIBUTE_P2P_TOKENS",
323 Self::SyncMemops => "CU_POINTER_ATTRIBUTE_SYNC_MEMOPS",
324 Self::BufferId => "CU_POINTER_ATTRIBUTE_BUFFER_ID",
325 Self::IsManaged => "CU_POINTER_ATTRIBUTE_IS_MANAGED",
326 Self::DeviceOrdinal => "CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL",
327 Self::IsLegacyCudaIpcCapable => "CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE",
328 Self::RangeStartAddr => "CU_POINTER_ATTRIBUTE_RANGE_START_ADDR",
329 Self::RangeSize => "CU_POINTER_ATTRIBUTE_RANGE_SIZE",
330 Self::Mapped => "CU_POINTER_ATTRIBUTE_MAPPED",
331 Self::AllowedHandleTypes => "CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES",
332 Self::IsGpuDirectRdmaCapable => "CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE",
333 Self::AccessFlags => "CU_POINTER_ATTRIBUTE_ACCESS_FLAGS",
334 Self::MempoolHandle => "CU_POINTER_ATTRIBUTE_MEMPOOL_HANDLE",
335 Self::MappingSize => "CU_POINTER_ATTRIBUTE_MAPPING_SIZE",
336 Self::MappingBaseAddr => "CU_POINTER_ATTRIBUTE_MAPPING_BASE_ADDR",
337 Self::MemoryBlockId => "CU_POINTER_ATTRIBUTE_MEMORY_BLOCK_ID",
338});
339
340#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
341#[repr(u32)]
342#[non_exhaustive]
343pub enum FunctionAttribute {
344 MaxThreadsPerBlock =
345 driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK as _,
346 SharedSizeBytes = driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES as _,
347 ConstSizeBytes = driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES as _,
348 LocalSizeBytes = driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES as _,
349 NumRegs = driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_NUM_REGS as _,
350 PtxVersion = driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_PTX_VERSION as _,
351 BinaryVersion = driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_BINARY_VERSION as _,
352 CacheModeCa = driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CACHE_MODE_CA as _,
353 MaxDynamicSharedSizeBytes =
354 driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES as _,
355 PreferredSharedMemoryCarveout =
356 driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT as _,
357 ClusterSizeMustBeSet =
358 driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET as _,
359 RequiredClusterWidth =
360 driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH as _,
361 RequiredClusterHeight =
362 driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT as _,
363 RequiredClusterDepth =
364 driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH as _,
365 NonPortableClusterSizeAllowed =
366 driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED as _,
367 ClusterSchedulingPolicyPreference =
368 driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE
369 as _,
370 Max = driver::CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX as _,
371}
372
373impl_enum_conversion!(u32, driver::CUfunction_attribute, FunctionAttribute);
374
375impl_enum_display!(FunctionAttribute, {
376 Self::MaxThreadsPerBlock => "CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK",
377 Self::SharedSizeBytes => "CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES",
378 Self::ConstSizeBytes => "CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES",
379 Self::LocalSizeBytes => "CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES",
380 Self::NumRegs => "CU_FUNC_ATTRIBUTE_NUM_REGS",
381 Self::PtxVersion => "CU_FUNC_ATTRIBUTE_PTX_VERSION",
382 Self::BinaryVersion => "CU_FUNC_ATTRIBUTE_BINARY_VERSION",
383 Self::CacheModeCa => "CU_FUNC_ATTRIBUTE_CACHE_MODE_CA",
384 Self::MaxDynamicSharedSizeBytes => "CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES",
385 Self::PreferredSharedMemoryCarveout => "CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT",
386 Self::ClusterSizeMustBeSet => "CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET",
387 Self::RequiredClusterWidth => "CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH",
388 Self::RequiredClusterHeight => "CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT",
389 Self::RequiredClusterDepth => "CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH",
390 Self::NonPortableClusterSizeAllowed => "CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED",
391 Self::ClusterSchedulingPolicyPreference => "CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE",
392 Self::Max => "CU_FUNC_ATTRIBUTE_MAX",
393});
394
395#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
396#[repr(u32)]
397#[non_exhaustive]
398pub enum FunctionCache {
399 PreferNone = driver::CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_NONE as _,
400 PreferShared = driver::CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_SHARED as _,
401 PreferL1 = driver::CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_L1 as _,
402 PreferEqual = driver::CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_EQUAL as _,
403}
404
405impl_enum_conversion!(u32, driver::CUfunc_cache, FunctionCache);
406
407impl_enum_display!(FunctionCache, {
408 Self::PreferNone => "CU_FUNC_CACHE_PREFER_NONE",
409 Self::PreferShared => "CU_FUNC_CACHE_PREFER_SHARED",
410 Self::PreferL1 => "CU_FUNC_CACHE_PREFER_L1",
411 Self::PreferEqual => "CU_FUNC_CACHE_PREFER_EQUAL",
412});
413
414#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
415#[repr(u32)]
416#[deprecated]
417#[non_exhaustive]
418pub enum SharedMemoryConfig {
419 DefaultBankSize = driver::CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE as _,
420 FourByteBankSize = driver::CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE as _,
421 EightByteBankSize = driver::CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE as _,
422}
423
424impl_enum_conversion!(u32, driver::CUsharedconfig, SharedMemoryConfig);
425
426impl_enum_display!(SharedMemoryConfig, {
427 Self::DefaultBankSize => "CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE",
428 Self::FourByteBankSize => "CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE",
429 Self::EightByteBankSize => "CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE",
430});
431
432#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
433#[repr(i32)]
434#[non_exhaustive]
435pub enum SharedMemoryCarveout {
436 Default = driver::CUshared_carveout_enum::CU_SHAREDMEM_CARVEOUT_DEFAULT as _,
437 MaxShared = driver::CUshared_carveout_enum::CU_SHAREDMEM_CARVEOUT_MAX_SHARED as _,
438 MaxL1 = driver::CUshared_carveout_enum::CU_SHAREDMEM_CARVEOUT_MAX_L1 as _,
439}
440
441impl_enum_conversion!(i32, driver::CUshared_carveout, SharedMemoryCarveout);
442
443impl_enum_display!(SharedMemoryCarveout, {
444 Self::Default => "CU_SHAREDMEM_CARVEOUT_DEFAULT",
445 Self::MaxShared => "CU_SHAREDMEM_CARVEOUT_MAX_SHARED",
446 Self::MaxL1 => "CU_SHAREDMEM_CARVEOUT_MAX_L1",
447});
448
449#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
450#[repr(u32)]
451#[non_exhaustive]
452pub enum MemoryType {
453 Host = driver::CUmemorytype_enum::CU_MEMORYTYPE_HOST as _,
454 Device = driver::CUmemorytype_enum::CU_MEMORYTYPE_DEVICE as _,
455 Array = driver::CUmemorytype_enum::CU_MEMORYTYPE_ARRAY as _,
456 Unified = driver::CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED as _,
457}
458
459impl_enum_conversion!(u32, driver::CUmemorytype, MemoryType);
460
461impl_enum_display!(MemoryType, {
462 Self::Host => "CU_MEMORYTYPE_HOST",
463 Self::Device => "CU_MEMORYTYPE_DEVICE",
464 Self::Array => "CU_MEMORYTYPE_ARRAY",
465 Self::Unified => "CU_MEMORYTYPE_UNIFIED",
466});
467
468#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
469#[repr(u32)]
470#[non_exhaustive]
471pub enum ComputeMode {
472 Default = driver::CUcomputemode_enum::CU_COMPUTEMODE_DEFAULT as _,
473 Prohibited = driver::CUcomputemode_enum::CU_COMPUTEMODE_PROHIBITED as _,
474 ExclusiveProcess = driver::CUcomputemode_enum::CU_COMPUTEMODE_EXCLUSIVE_PROCESS as _,
475}
476
477impl_enum_conversion!(u32, driver::CUcomputemode, ComputeMode);
478
479impl_enum_display!(ComputeMode, {
480 Self::Default => "CU_COMPUTEMODE_DEFAULT",
481 Self::Prohibited => "CU_COMPUTEMODE_PROHIBITED",
482 Self::ExclusiveProcess => "CU_COMPUTEMODE_EXCLUSIVE_PROCESS",
483});
484
485#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
486#[repr(u32)]
487#[non_exhaustive]
488pub enum MemoryAdvise {
489 SetReadMostly = driver::CUmem_advise_enum::CU_MEM_ADVISE_SET_READ_MOSTLY as _,
490 UnsetReadMostly = driver::CUmem_advise_enum::CU_MEM_ADVISE_UNSET_READ_MOSTLY as _,
491 SetPreferredLocation = driver::CUmem_advise_enum::CU_MEM_ADVISE_SET_PREFERRED_LOCATION as _,
492 UnsetPreferredLocation = driver::CUmem_advise_enum::CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION as _,
493 SetAccessedBy = driver::CUmem_advise_enum::CU_MEM_ADVISE_SET_ACCESSED_BY as _,
494 UnsetAccessedBy = driver::CUmem_advise_enum::CU_MEM_ADVISE_UNSET_ACCESSED_BY as _,
495}
496
497impl_enum_conversion!(u32, driver::CUmem_advise, MemoryAdvise);
498
499impl_enum_display!(MemoryAdvise, {
500 Self::SetReadMostly => "CU_MEM_ADVISE_SET_READ_MOSTLY",
501 Self::UnsetReadMostly => "CU_MEM_ADVISE_UNSET_READ_MOSTLY",
502 Self::SetPreferredLocation => "CU_MEM_ADVISE_SET_PREFERRED_LOCATION",
503 Self::UnsetPreferredLocation => "CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION",
504 Self::SetAccessedBy => "CU_MEM_ADVISE_SET_ACCESSED_BY",
505 Self::UnsetAccessedBy => "CU_MEM_ADVISE_UNSET_ACCESSED_BY",
506});
507
508#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
509#[repr(u32)]
510#[non_exhaustive]
511pub enum MemoryRangeAttribute {
512 ReadMostly = driver::CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY as _,
513 PreferredLocation =
514 driver::CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION as _,
515 AccessedBy = driver::CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY as _,
516 LastPrefetchLocation =
517 driver::CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION as _,
518}
519
520impl_enum_conversion!(u32, driver::CUmem_range_attribute, MemoryRangeAttribute);
521
522impl_enum_display!(MemoryRangeAttribute, {
523 Self::ReadMostly => "CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY",
524 Self::PreferredLocation => "CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION",
525 Self::AccessedBy => "CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY",
526 Self::LastPrefetchLocation => "CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION",
527});
528
529#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
530#[repr(u32)]
531#[non_exhaustive]
532pub enum CubemapFace {
533 PositiveX = driver::CUarray_cubemap_face_enum::CU_CUBEMAP_FACE_POSITIVE_X as _,
534 NegativeX = driver::CUarray_cubemap_face_enum::CU_CUBEMAP_FACE_NEGATIVE_X as _,
535 PositiveY = driver::CUarray_cubemap_face_enum::CU_CUBEMAP_FACE_POSITIVE_Y as _,
536 NegativeY = driver::CUarray_cubemap_face_enum::CU_CUBEMAP_FACE_NEGATIVE_Y as _,
537 PositiveZ = driver::CUarray_cubemap_face_enum::CU_CUBEMAP_FACE_POSITIVE_Z as _,
538 NegativeZ = driver::CUarray_cubemap_face_enum::CU_CUBEMAP_FACE_NEGATIVE_Z as _,
539}
540
541impl_enum_conversion!(u32, driver::CUarray_cubemap_face, CubemapFace);
542
543impl_enum_display!(CubemapFace, {
544 Self::PositiveX => "CU_CUBEMAP_FACE_POSITIVE_X",
545 Self::NegativeX => "CU_CUBEMAP_FACE_NEGATIVE_X",
546 Self::PositiveY => "CU_CUBEMAP_FACE_POSITIVE_Y",
547 Self::NegativeY => "CU_CUBEMAP_FACE_NEGATIVE_Y",
548 Self::PositiveZ => "CU_CUBEMAP_FACE_POSITIVE_Z",
549 Self::NegativeZ => "CU_CUBEMAP_FACE_NEGATIVE_Z",
550});
551
552#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
553#[repr(u32)]
554#[non_exhaustive]
555pub enum Limit {
556 StackSize = driver::CUlimit_enum::CU_LIMIT_STACK_SIZE as _,
557 PrintfFifoSize = driver::CUlimit_enum::CU_LIMIT_PRINTF_FIFO_SIZE as _,
558 MallocHeapSize = driver::CUlimit_enum::CU_LIMIT_MALLOC_HEAP_SIZE as _,
559 DevRuntimeSyncDepth = driver::CUlimit_enum::CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH as _,
560 DevRuntimePendingLaunchCount =
561 driver::CUlimit_enum::CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT as _,
562 MaxL2FetchGranularity = driver::CUlimit_enum::CU_LIMIT_MAX_L2_FETCH_GRANULARITY as _,
563 PersistingL2CacheSize = driver::CUlimit_enum::CU_LIMIT_PERSISTING_L2_CACHE_SIZE as _,
564 Max = driver::CUlimit_enum::CU_LIMIT_MAX as _,
565}
566
567impl_enum_conversion!(u32, driver::CUlimit, Limit);
568
569impl_enum_display!(Limit, {
570 Self::StackSize => "CU_LIMIT_STACK_SIZE",
571 Self::PrintfFifoSize => "CU_LIMIT_PRINTF_FIFO_SIZE",
572 Self::MallocHeapSize => "CU_LIMIT_MALLOC_HEAP_SIZE",
573 Self::DevRuntimeSyncDepth => "CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH",
574 Self::DevRuntimePendingLaunchCount => "CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT",
575 Self::MaxL2FetchGranularity => "CU_LIMIT_MAX_L2_FETCH_GRANULARITY",
576 Self::PersistingL2CacheSize => "CU_LIMIT_PERSISTING_L2_CACHE_SIZE",
577 Self::Max => "CU_LIMIT_MAX",
578});
579
580#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
581#[repr(u32)]
582#[non_exhaustive]
583pub enum ResourceType {
584 Array = driver::CUresourcetype_enum::CU_RESOURCE_TYPE_ARRAY as _,
585 MipmappedArray = driver::CUresourcetype_enum::CU_RESOURCE_TYPE_MIPMAPPED_ARRAY as _,
586 Linear = driver::CUresourcetype_enum::CU_RESOURCE_TYPE_LINEAR as _,
587 Pitch2d = driver::CUresourcetype_enum::CU_RESOURCE_TYPE_PITCH2D as _,
588}
589
590impl_enum_conversion!(u32, driver::CUresourcetype, ResourceType);
591
592impl_enum_display!(ResourceType, {
593 Self::Array => "CU_RESOURCE_TYPE_ARRAY",
594 Self::MipmappedArray => "CU_RESOURCE_TYPE_MIPMAPPED_ARRAY",
595 Self::Linear => "CU_RESOURCE_TYPE_LINEAR",
596 Self::Pitch2d => "CU_RESOURCE_TYPE_PITCH2D",
597});
598
599#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
600#[repr(u32)]
601#[non_exhaustive]
602pub enum AccessProperty {
603 Normal = driver::CUaccessProperty_enum::CU_ACCESS_PROPERTY_NORMAL as _,
604 Streaming = driver::CUaccessProperty_enum::CU_ACCESS_PROPERTY_STREAMING as _,
605 Persisting = driver::CUaccessProperty_enum::CU_ACCESS_PROPERTY_PERSISTING as _,
606}
607
608impl_enum_conversion!(u32, driver::CUaccessProperty, AccessProperty);
609
610impl_enum_display!(AccessProperty, {
611 Self::Normal => "CU_ACCESS_PROPERTY_NORMAL",
612 Self::Streaming => "CU_ACCESS_PROPERTY_STREAMING",
613 Self::Persisting => "CU_ACCESS_PROPERTY_PERSISTING",
614});