/* automatically generated by rust-bindgen 0.72.1 */
/// CUDA API version number.
pub const CUDA_VERSION: u32 = 13020;
/// CUDA IPC handle size.
pub const CU_IPC_HANDLE_SIZE: u32 = 64;
pub const CU_COMPUTE_ACCELERATED_TARGET_BASE: u32 = 65536;
pub const CU_COMPUTE_FAMILY_TARGET_BASE: u32 = 131072;
/// Conditional node handle flags Default value is applied when graph is launched.
pub const CU_GRAPH_COND_ASSIGN_DEFAULT: u32 = 1;
/// This port activates when the kernel has finished executing.
pub const CU_GRAPH_KERNEL_NODE_PORT_DEFAULT: u32 = 0;
/// This port activates when all blocks of the kernel have performed [cudaTriggerProgrammaticLaunchCompletion()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EXECUTION.html#group__CUDART__EXECUTION_1ge194af462d927583bed3acf60d450218) or have terminated. It must be used with edge type CU_GRAPH_DEPENDENCY_TYPE_PROGRAMMATIC. See also CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT.
pub const CU_GRAPH_KERNEL_NODE_PORT_PROGRAMMATIC: u32 = 1;
/// This port activates when all blocks of the kernel have begun execution. See also CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT.
pub const CU_GRAPH_KERNEL_NODE_PORT_LAUNCH_ORDER: u32 = 2;
/// If set, host memory is portable between CUDA contexts. Flag for [`cuMemHostAlloc`].
pub const CU_MEMHOSTALLOC_PORTABLE: u32 = 1;
/// If set, host memory is mapped into CUDA address space and [`cuMemHostGetDevicePointer_v2`] may be called on the host pointer. Flag for [`cuMemHostAlloc`].
pub const CU_MEMHOSTALLOC_DEVICEMAP: u32 = 2;
/// If set, host memory is allocated as write-combined - fast to write, faster to DMA, slow to read except via SSE4 streaming
/// load instruction (MOVNTDQA). Flag for [`cuMemHostAlloc`].
pub const CU_MEMHOSTALLOC_WRITECOMBINED: u32 = 4;
/// If set, host memory is portable between CUDA contexts. Flag for [`cuMemHostRegister_v2`].
pub const CU_MEMHOSTREGISTER_PORTABLE: u32 = 1;
/// If set, host memory is mapped into CUDA address space and [`cuMemHostGetDevicePointer_v2`] may be called on the host pointer. Flag for [`cuMemHostRegister_v2`].
pub const CU_MEMHOSTREGISTER_DEVICEMAP: u32 = 2;
/// If set, the passed memory pointer is treated as pointing to some memory-mapped I/O space, e.g. belonging to a third-party
/// PCIe device. On Windows the flag is a no-op. On Linux that memory is marked as non cache-coherent for the GPU and is expected
/// to be physically contiguous. It may return CUDA_ERROR_NOT_PERMITTED if run as an unprivileged user, CUDA_ERROR_NOT_SUPPORTED on older Linux kernel versions. On all other platforms, it is not supported and CUDA_ERROR_NOT_SUPPORTED is returned. Flag for [`cuMemHostRegister_v2`].
pub const CU_MEMHOSTREGISTER_IOMEMORY: u32 = 4;
/// If set, the passed memory pointer is treated as pointing to memory that is considered read-only by the device. On platforms
/// without CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES, this flag is required in order to register memory mapped to the CPU as read-only. Support for the use of this flag can be
/// queried from the device attribute CU_DEVICE_ATTRIBUTE_READ_ONLY_HOST_REGISTER_SUPPORTED. Using this flag with a current context associated with a device that does not have this attribute set will cause [`cuMemHostRegister_v2`] to error with CUDA_ERROR_NOT_SUPPORTED.
pub const CU_MEMHOSTREGISTER_READ_ONLY: u32 = 8;
/// Indicates that the layered sparse CUDA array or CUDA mipmapped array has a single mip tail region for all layers.
pub const CU_ARRAY_SPARSE_PROPERTIES_SINGLE_MIPTAIL: u32 = 1;
/// Size of tensor map descriptor.
pub const CU_TENSOR_MAP_NUM_QWORDS: u32 = 16;
/// Indicates that the external memory object is a dedicated resource.
pub const CUDA_EXTERNAL_MEMORY_DEDICATED: u32 = 1;
/// When the flags parameter of CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS contains this flag, it indicates that signaling an external semaphore
/// object should skip performing appropriate memory synchronization operations over all the external memory objects that are
/// imported as CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF, which otherwise are performed by default to ensure data coherency with other importers of the same NvSciBuf memory objects.
pub const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_SKIP_NVSCIBUF_MEMSYNC: u32 = 1;
/// When the flags parameter of CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS contains this flag, it indicates that waiting on an external semaphore object
/// should skip performing appropriate memory synchronization operations over all the external memory objects that are imported
/// as CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF, which otherwise are performed by default to ensure data coherency with other importers of the same NvSciBuf memory objects.
pub const CUDA_EXTERNAL_SEMAPHORE_WAIT_SKIP_NVSCIBUF_MEMSYNC: u32 = 2;
/// When flags of [`cuDeviceGetNvSciSyncAttributes`] is set to this, it indicates that application needs signaler specific NvSciSyncAttr to be filled by [`cuDeviceGetNvSciSyncAttributes`].
pub const CUDA_NVSCISYNC_ATTR_SIGNAL: u32 = 1;
/// When flags of [`cuDeviceGetNvSciSyncAttributes`] is set to this, it indicates that application needs waiter specific NvSciSyncAttr to be filled by [`cuDeviceGetNvSciSyncAttributes`].
pub const CUDA_NVSCISYNC_ATTR_WAIT: u32 = 2;
/// This flag if set indicates that the memory will be used as a tile pool.
pub const CU_MEM_CREATE_USAGE_TILE_POOL: u32 = 1;
/// This flag, if set, indicates that the memory will be used as a buffer for hardware accelerated decompression.
pub const CU_MEM_CREATE_USAGE_HW_DECOMPRESS: u32 = 2;
/// This flag, if set, indicates that the memory will be used as a buffer for hardware accelerated decompression.
pub const CU_MEM_POOL_CREATE_USAGE_HW_DECOMPRESS: u32 = 2;
/// If set, each kernel launched as part of [`cuLaunchCooperativeKernelMultiDevice`] only waits for prior work in the stream corresponding to that GPU to complete before the kernel begins execution.
pub const CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_PRE_LAUNCH_SYNC: u32 = 1;
/// If set, any subsequent work pushed in a stream that participated in a call to [`cuLaunchCooperativeKernelMultiDevice`] will only wait for the kernel launched on the GPU corresponding to that stream to complete before it begins execution.
pub const CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_POST_LAUNCH_SYNC: u32 = 2;
/// If set, the CUDA array is a collection of layers, where each layer is either a 1D or a 2D array and the Depth member of CUDA_ARRAY3D_DESCRIPTOR
/// specifies the number of layers, not the depth of a 3D array.
pub const CUDA_ARRAY3D_LAYERED: u32 = 1;
/// use [`CUDA_ARRAY3D_LAYERED`].
#[deprecated]
pub const CUDA_ARRAY3D_2DARRAY: u32 = 1;
/// This flag must be set in order to bind a surface reference to the CUDA array.
pub const CUDA_ARRAY3D_SURFACE_LDST: u32 = 2;
/// If set, the CUDA array is a collection of six 2D arrays, representing faces of a cube. The width of such a CUDA array must
/// be equal to its height, and Depth must be six. If [`CUDA_ARRAY3D_LAYERED`] flag is also set, then the CUDA array is a collection of cubemaps and Depth must be a multiple of six.
pub const CUDA_ARRAY3D_CUBEMAP: u32 = 4;
/// This flag must be set in order to perform texture gather operations on a CUDA array.
pub const CUDA_ARRAY3D_TEXTURE_GATHER: u32 = 8;
/// This flag if set indicates that the CUDA array is a DEPTH_TEXTURE.
pub const CUDA_ARRAY3D_DEPTH_TEXTURE: u32 = 16;
/// This flag indicates that the CUDA array may be bound as a color target in an external graphics API.
pub const CUDA_ARRAY3D_COLOR_ATTACHMENT: u32 = 32;
/// This flag if set indicates that the CUDA array or CUDA mipmapped array is a sparse CUDA array or CUDA mipmapped array respectively.
pub const CUDA_ARRAY3D_SPARSE: u32 = 64;
/// This flag if set indicates that the CUDA array or CUDA mipmapped array will allow deferred memory mapping.
pub const CUDA_ARRAY3D_DEFERRED_MAPPING: u32 = 128;
/// This flag indicates that the CUDA array will be used for hardware accelerated video encode/decode operations.
pub const CUDA_ARRAY3D_VIDEO_ENCODE_DECODE: u32 = 256;
/// Override the texref format with a format inferred from the array. Flag for [`cuTexRefSetArray`].
#[deprecated]
pub const CU_TRSA_OVERRIDE_FORMAT: u32 = 1;
/// Read the texture as integers rather than promoting the values to floats in the range \[0,1\]. Flag for [`cuTexRefSetFlags`] and [`cuTexObjectCreate`].
#[deprecated]
pub const CU_TRSF_READ_AS_INTEGER: u32 = 1;
/// Use normalized texture coordinates in the range 0,1) instead of [0,dim). Flag for [cuTexRefSetFlags() and [`cuTexObjectCreate`].
#[deprecated]
pub const CU_TRSF_NORMALIZED_COORDINATES: u32 = 2;
/// Perform sRGB->linear conversion during texture read. Flag for [`cuTexRefSetFlags`] and [`cuTexObjectCreate`].
#[deprecated]
pub const CU_TRSF_SRGB: u32 = 16;
/// Disable any trilinear filtering optimizations. Flag for [`cuTexRefSetFlags`] and [`cuTexObjectCreate`].
#[deprecated]
pub const CU_TRSF_DISABLE_TRILINEAR_OPTIMIZATION: u32 = 32;
/// Enable seamless cube map filtering. Flag for [`cuTexObjectCreate`].
pub const CU_TRSF_SEAMLESS_CUBEMAP: u32 = 64;
/// Launch with the required block dimension.
pub const CU_LAUNCH_KERNEL_REQUIRED_BLOCK_DIM: u32 = 1;
/// C++ compile time constant for CU_LAUNCH_PARAM_END.
pub const CU_LAUNCH_PARAM_END_AS_INT: u32 = 0;
/// C++ compile time constant for CU_LAUNCH_PARAM_BUFFER_POINTER.
pub const CU_LAUNCH_PARAM_BUFFER_POINTER_AS_INT: u32 = 1;
/// C++ compile time constant for CU_LAUNCH_PARAM_BUFFER_SIZE.
pub const CU_LAUNCH_PARAM_BUFFER_SIZE_AS_INT: u32 = 2;
/// For texture references loaded into the module, use default texunit from texture reference.
pub const CU_PARAM_TR_DEFAULT: i32 = -1;
pub type size_t = ::core::ffi::c_ulong;
pub type cuuint32_t = u32;
pub type cuuint64_t = u64;
/// CUDA device pointer CUdeviceptr is defined as an unsigned integer type whose size matches the size of a pointer on the target
/// platform.
pub type CUdeviceptr_v2 = ::core::ffi::c_ulonglong;
/// CUDA device pointer.
pub type CUdeviceptr = CUdeviceptr_v2;
/// CUDA device.
pub type CUdevice_v1 = ::core::ffi::c_int;
/// CUDA device.
pub type CUdevice = CUdevice_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUctx_st {
_unused: [u8; 0],
}
/// A regular context handle.
pub type CUcontext = *mut CUctx_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUmod_st {
_unused: [u8; 0],
}
/// CUDA module.
pub type CUmodule = *mut CUmod_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUfunc_st {
_unused: [u8; 0],
}
/// CUDA function.
pub type CUfunction = *mut CUfunc_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUlib_st {
_unused: [u8; 0],
}
/// CUDA library.
pub type CUlibrary = *mut CUlib_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUkern_st {
_unused: [u8; 0],
}
/// CUDA kernel.
pub type CUkernel = *mut CUkern_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUarray_st {
_unused: [u8; 0],
}
/// CUDA array.
pub type CUarray = *mut CUarray_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUmipmappedArray_st {
_unused: [u8; 0],
}
/// CUDA mipmapped array.
pub type CUmipmappedArray = *mut CUmipmappedArray_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUtexref_st {
_unused: [u8; 0],
}
/// CUDA texture reference.
pub type CUtexref = *mut CUtexref_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUsurfref_st {
_unused: [u8; 0],
}
/// CUDA surface reference.
pub type CUsurfref = *mut CUsurfref_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUevent_st {
_unused: [u8; 0],
}
/// CUDA event.
pub type CUevent = *mut CUevent_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUstream_st {
_unused: [u8; 0],
}
/// CUDA stream.
pub type CUstream = *mut CUstream_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUgraphicsResource_st {
_unused: [u8; 0],
}
/// CUDA graphics interop resource.
pub type CUgraphicsResource = *mut CUgraphicsResource_st;
/// An opaque value that represents a CUDA texture object.
pub type CUtexObject_v1 = ::core::ffi::c_ulonglong;
/// An opaque value that represents a CUDA texture object.
pub type CUtexObject = CUtexObject_v1;
/// An opaque value that represents a CUDA surface object.
pub type CUsurfObject_v1 = ::core::ffi::c_ulonglong;
/// An opaque value that represents a CUDA surface object.
pub type CUsurfObject = CUsurfObject_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUextMemory_st {
_unused: [u8; 0],
}
/// CUDA external memory.
pub type CUexternalMemory = *mut CUextMemory_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUextSemaphore_st {
_unused: [u8; 0],
}
/// CUDA external semaphore.
pub type CUexternalSemaphore = *mut CUextSemaphore_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUgraph_st {
_unused: [u8; 0],
}
/// CUDA graph.
pub type CUgraph = *mut CUgraph_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUgraphNode_st {
_unused: [u8; 0],
}
/// CUDA graph node.
pub type CUgraphNode = *mut CUgraphNode_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUgraphExec_st {
_unused: [u8; 0],
}
/// CUDA executable graph.
pub type CUgraphExec = *mut CUgraphExec_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUmemPoolHandle_st {
_unused: [u8; 0],
}
/// CUDA memory pool.
pub type CUmemoryPool = *mut CUmemPoolHandle_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUuserObject_st {
_unused: [u8; 0],
}
/// CUDA user object for graphs.
pub type CUuserObject = *mut CUuserObject_st;
/// CUDA graph conditional handle.
pub type CUgraphConditionalHandle = cuuint64_t;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUgraphDeviceUpdatableNode_st {
_unused: [u8; 0],
}
/// CUDA graph device node handle.
pub type CUgraphDeviceNode = *mut CUgraphDeviceUpdatableNode_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUasyncCallbackEntry_st {
_unused: [u8; 0],
}
/// CUDA async notification callback handle.
pub type CUasyncCallbackHandle = *mut CUasyncCallbackEntry_st;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUgreenCtx_st {
_unused: [u8; 0],
}
/// A green context handle. This handle can be used safely from only one CPU thread at a time. Created via [`cuGreenCtxCreate`].
pub type CUgreenCtx = *mut CUgreenCtx_st;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUuuid_st {
pub bytes: [::core::ffi::c_char; 16usize],
}
pub type CUuuid = CUuuid_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUmemFabricHandle_st {
pub data: [::core::ffi::c_uchar; 64usize],
}
impl Default for CUmemFabricHandle_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Fabric handle - An opaque handle representing a memory allocation that can be exported to processes in same or different nodes.
/// For IPC between processes on different nodes they must be connected via the NVSwitch fabric.
pub type CUmemFabricHandle_v1 = CUmemFabricHandle_st;
pub type CUmemFabricHandle = CUmemFabricHandle_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUipcEventHandle_st {
pub reserved: [::core::ffi::c_char; 64usize],
}
impl Default for CUipcEventHandle_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// CUDA IPC event handle.
pub type CUipcEventHandle_v1 = CUipcEventHandle_st;
pub type CUipcEventHandle = CUipcEventHandle_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUipcMemHandle_st {
pub reserved: [::core::ffi::c_char; 64usize],
}
impl Default for CUipcMemHandle_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// CUDA IPC mem handle.
pub type CUipcMemHandle_v1 = CUipcMemHandle_st;
pub type CUipcMemHandle = CUipcMemHandle_v1;
/// CUDA Ipc Mem Flags.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUipcMem_flags_enum {
/// Automatically enable peer access between remote devices as needed.
CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS = 1,
}
pub use self::CUipcMem_flags_enum as CUipcMem_flags;
/// CUDA Mem Attach Flags.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemAttach_flags_enum {
/// Memory can be accessed by any stream on any device.
CU_MEM_ATTACH_GLOBAL = 1,
/// Memory cannot be accessed by any stream on any device.
CU_MEM_ATTACH_HOST = 2,
/// Memory can only be accessed by a single stream on the associated device.
CU_MEM_ATTACH_SINGLE = 4,
}
pub use self::CUmemAttach_flags_enum as CUmemAttach_flags;
impl CUctx_flags_enum {
pub const CU_CTX_BLOCKING_SYNC: CUctx_flags_enum = CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC;
}
/// Context creation flags.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUctx_flags_enum {
/// Automatic scheduling.
CU_CTX_SCHED_AUTO = 0,
/// Set spin as default scheduling.
CU_CTX_SCHED_SPIN = 1,
/// Set yield as default scheduling.
CU_CTX_SCHED_YIELD = 2,
/// Set blocking synchronization as default scheduling.
CU_CTX_SCHED_BLOCKING_SYNC = 4,
CU_CTX_SCHED_MASK = 7,
/// flag is enabled.
#[deprecated]
CU_CTX_MAP_HOST = 8,
/// Keep local memory allocation after launch.
CU_CTX_LMEM_RESIZE_TO_MAX = 16,
/// Trigger coredumps from exceptions in this context.
CU_CTX_COREDUMP_ENABLE = 32,
/// Enable user pipe to trigger coredumps in this context.
CU_CTX_USER_COREDUMP_ENABLE = 64,
/// Ensure synchronous memory operations on this context will synchronize.
CU_CTX_SYNC_MEMOPS = 128,
CU_CTX_FLAGS_MASK = 255,
}
pub use self::CUctx_flags_enum as CUctx_flags;
/// Event sched flags.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUevent_sched_flags_enum {
/// Automatic scheduling.
CU_EVENT_SCHED_AUTO = 0,
/// Set spin as default scheduling.
CU_EVENT_SCHED_SPIN = 1,
/// Set yield as default scheduling.
CU_EVENT_SCHED_YIELD = 2,
/// Set blocking synchronization as default scheduling.
CU_EVENT_SCHED_BLOCKING_SYNC = 4,
}
pub use self::CUevent_sched_flags_enum as CUevent_sched_flags;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUhostTaskSyncMode_enum {
CU_HOST_TASK_BLOCKING = 0,
CU_HOST_TASK_SPINWAIT = 1,
}
pub use self::CUhostTaskSyncMode_enum as CUhostTaskSyncMode;
/// Stream creation flags.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUstream_flags_enum {
/// Default stream flag.
CU_STREAM_DEFAULT = 0,
/// Stream does not synchronize with stream 0 (the NULL stream).
CU_STREAM_NON_BLOCKING = 1,
}
pub use self::CUstream_flags_enum as CUstream_flags;
/// Event creation flags.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUevent_flags_enum {
/// Default event flag.
CU_EVENT_DEFAULT = 0,
/// Event uses blocking synchronization.
CU_EVENT_BLOCKING_SYNC = 1,
/// Event will not record timing data.
CU_EVENT_DISABLE_TIMING = 2,
/// Event is suitable for interprocess use. [`CUevent_flags::CU_EVENT_DISABLE_TIMING`] must be set.
CU_EVENT_INTERPROCESS = 4,
}
pub use self::CUevent_flags_enum as CUevent_flags;
/// Event record flags.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUevent_record_flags_enum {
/// Default event record flag.
CU_EVENT_RECORD_DEFAULT = 0,
/// When using stream capture, create an event record node instead of the default behavior. This flag is invalid when used outside
/// of capture.
CU_EVENT_RECORD_EXTERNAL = 1,
}
pub use self::CUevent_record_flags_enum as CUevent_record_flags;
/// Event wait flags.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUevent_wait_flags_enum {
/// Default event wait flag.
CU_EVENT_WAIT_DEFAULT = 0,
/// When using stream capture, create an event wait node instead of the default behavior. This flag is invalid when used outside
/// of capture.
CU_EVENT_WAIT_EXTERNAL = 1,
}
pub use self::CUevent_wait_flags_enum as CUevent_wait_flags;
/// CUDA-valid Atomic Operations.
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUatomicOperation_enum {
CU_ATOMIC_OPERATION_INTEGER_ADD = 0,
CU_ATOMIC_OPERATION_INTEGER_MIN = 1,
CU_ATOMIC_OPERATION_INTEGER_MAX = 2,
CU_ATOMIC_OPERATION_INTEGER_INCREMENT = 3,
CU_ATOMIC_OPERATION_INTEGER_DECREMENT = 4,
CU_ATOMIC_OPERATION_AND = 5,
CU_ATOMIC_OPERATION_OR = 6,
CU_ATOMIC_OPERATION_XOR = 7,
CU_ATOMIC_OPERATION_EXCHANGE = 8,
CU_ATOMIC_OPERATION_CAS = 9,
CU_ATOMIC_OPERATION_FLOAT_ADD = 10,
CU_ATOMIC_OPERATION_FLOAT_MIN = 11,
CU_ATOMIC_OPERATION_FLOAT_MAX = 12,
CU_ATOMIC_OPERATION_MAX = 13,
}
pub use self::CUatomicOperation_enum as CUatomicOperation;
/// CUDA-valid Atomic Operation capabilities.
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUatomicOperationCapability_enum {
CU_ATOMIC_CAPABILITY_SIGNED = 1,
CU_ATOMIC_CAPABILITY_UNSIGNED = 2,
CU_ATOMIC_CAPABILITY_REDUCTION = 4,
CU_ATOMIC_CAPABILITY_SCALAR_32 = 8,
CU_ATOMIC_CAPABILITY_SCALAR_64 = 16,
CU_ATOMIC_CAPABILITY_SCALAR_128 = 32,
CU_ATOMIC_CAPABILITY_VECTOR_32x4 = 64,
}
pub use self::CUatomicOperationCapability_enum as CUatomicOperationCapability;
/// Flags for [`cuStreamWaitValue32_v2`] and [`cuStreamWaitValue64_v2`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUstreamWaitValue_flags_enum {
/// Wait until (int32_t)(\*addr - value) >= 0 (or int64_t for 64 bit values). Note this is a cyclic comparison which ignores wraparound.
/// (Default behavior.)
CU_STREAM_WAIT_VALUE_GEQ = 0,
/// Wait until \*addr == value.
CU_STREAM_WAIT_VALUE_EQ = 1,
/// Wait until (\*addr & value) != 0.
CU_STREAM_WAIT_VALUE_AND = 2,
/// Wait until ~(\*addr | value) != 0. Support for this operation can be queried with [`cuDeviceGetAttribute`] and CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_WAIT_VALUE_NOR.
CU_STREAM_WAIT_VALUE_NOR = 3,
/// Follow the wait operation with a flush of outstanding remote writes. This means that, if a remote write operation is guaranteed
/// to have reached the device before the wait can be satisfied, that write is guaranteed to be visible to downstream device work.
/// The device is permitted to reorder remote writes internally. For example, this flag would be required if two remote writes
/// arrive in a defined order, the wait is satisfied by the second write, and downstream work needs to observe the first write.
/// Support for this operation is restricted to selected platforms and can be queried with CU_DEVICE_ATTRIBUTE_CAN_FLUSH_REMOTE_WRITES.
CU_STREAM_WAIT_VALUE_FLUSH = 1073741824,
}
pub use self::CUstreamWaitValue_flags_enum as CUstreamWaitValue_flags;
/// Flags for [`cuStreamWriteValue32_v2`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUstreamWriteValue_flags_enum {
/// Default behavior.
CU_STREAM_WRITE_VALUE_DEFAULT = 0,
/// Permits the write to be reordered with writes which were issued before it, as a performance optimization. Normally, [`cuStreamWriteValue32_v2`] will provide a memory fence before the write, which has similar semantics to __threadfence_system() but is scoped to the
/// stream rather than a CUDA thread. This flag is not supported in the v2 API.
CU_STREAM_WRITE_VALUE_NO_MEMORY_BARRIER = 1,
}
pub use self::CUstreamWriteValue_flags_enum as CUstreamWriteValue_flags;
/// Operations for [`cuStreamBatchMemOp_v2`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUstreamBatchMemOpType_enum {
/// Represents a [`cuStreamWaitValue32_v2`] operation.
CU_STREAM_MEM_OP_WAIT_VALUE_32 = 1,
/// Represents a [`cuStreamWriteValue32_v2`] operation.
CU_STREAM_MEM_OP_WRITE_VALUE_32 = 2,
/// Represents a [`cuStreamWaitValue64_v2`] operation.
CU_STREAM_MEM_OP_WAIT_VALUE_64 = 4,
/// Represents a [`cuStreamWriteValue64_v2`] operation.
CU_STREAM_MEM_OP_WRITE_VALUE_64 = 5,
/// Insert a memory barrier of the specified type.
CU_STREAM_MEM_OP_BARRIER = 6,
/// Perform a atomic reduction. See CUstreamBatchMemOpParams::atomicReduction.
CU_STREAM_MEM_OP_ATOMIC_REDUCTION = 8,
/// This has the same effect as CU_STREAM_WAIT_VALUE_FLUSH, but as a standalone operation.
CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES = 3,
}
pub use self::CUstreamBatchMemOpType_enum as CUstreamBatchMemOpType;
/// Flags for [CUstreamBatchMemOpParams::memoryBarrier](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUstreamBatchMemOpParams__v1.html#unionCUstreamBatchMemOpParams__v1_16133c06182986968a5f5e381194566ef).
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUstreamMemoryBarrier_flags_enum {
/// System-wide memory barrier.
CU_STREAM_MEMORY_BARRIER_TYPE_SYS = 0,
/// Limit memory barrier scope to the GPU.
CU_STREAM_MEMORY_BARRIER_TYPE_GPU = 1,
}
pub use self::CUstreamMemoryBarrier_flags_enum as CUstreamMemoryBarrier_flags;
/// Atomic reduction operation types for CUstreamBatchMemOpParams::atomicReduction::reductionOp.
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUstreamAtomicReductionOpType_enum {
/// Performs an atomic OR: \*(address) = \*(address) | value.
CU_STREAM_ATOMIC_REDUCTION_OP_OR = 6,
/// Performs an atomic AND: \*(address) = \*(address) & value.
CU_STREAM_ATOMIC_REDUCTION_OP_AND = 5,
/// Performs an atomic ADD: \*(address) = \*(address) + value.
CU_STREAM_ATOMIC_REDUCTION_OP_ADD = 0,
}
pub use self::CUstreamAtomicReductionOpType_enum as CUstreamAtomicReductionOpType;
/// Atomic reduction data types for CUstreamBatchMemOpParams::atomicReduction::dataType.
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUstreamAtomicReductionDataType_enum {
CU_STREAM_ATOMIC_REDUCTION_UNSIGNED_32 = 14,
CU_STREAM_ATOMIC_REDUCTION_UNSIGNED_64 = 22,
}
pub use self::CUstreamAtomicReductionDataType_enum as CUstreamAtomicReductionDataType;
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUstreamBatchMemOpParams_union {
pub operation: CUstreamBatchMemOpType,
pub waitValue: CUstreamBatchMemOpParams_union_CUstreamMemOpWaitValueParams_st,
pub writeValue: CUstreamBatchMemOpParams_union_CUstreamMemOpWriteValueParams_st,
pub flushRemoteWrites: CUstreamBatchMemOpParams_union_CUstreamMemOpFlushRemoteWritesParams_st,
pub memoryBarrier: CUstreamBatchMemOpParams_union_CUstreamMemOpMemoryBarrierParams_st,
pub atomicReduction: CUstreamBatchMemOpParams_union_CUstreamMemOpAtomicReductionParams_st,
pub pad: [cuuint64_t; 6usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUstreamBatchMemOpParams_union_CUstreamMemOpWaitValueParams_st {
pub operation: CUstreamBatchMemOpType,
pub address: CUdeviceptr,
pub __bindgen_anon_1: CUstreamBatchMemOpParams_union_CUstreamMemOpWaitValueParams_st__bindgen_ty_1,
pub flags: ::core::ffi::c_uint,
pub alias: CUdeviceptr,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUstreamBatchMemOpParams_union_CUstreamMemOpWaitValueParams_st__bindgen_ty_1 {
pub value: cuuint32_t,
pub value64: cuuint64_t,
}
impl Default
for CUstreamBatchMemOpParams_union_CUstreamMemOpWaitValueParams_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUstreamBatchMemOpParams_union_CUstreamMemOpWaitValueParams_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUstreamBatchMemOpParams_union_CUstreamMemOpWriteValueParams_st {
pub operation: CUstreamBatchMemOpType,
pub address: CUdeviceptr,
pub __bindgen_anon_1: CUstreamBatchMemOpParams_union_CUstreamMemOpWriteValueParams_st__bindgen_ty_1,
pub flags: ::core::ffi::c_uint,
pub alias: CUdeviceptr,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUstreamBatchMemOpParams_union_CUstreamMemOpWriteValueParams_st__bindgen_ty_1 {
pub value: cuuint32_t,
pub value64: cuuint64_t,
}
impl Default
for CUstreamBatchMemOpParams_union_CUstreamMemOpWriteValueParams_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUstreamBatchMemOpParams_union_CUstreamMemOpWriteValueParams_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUstreamBatchMemOpParams_union_CUstreamMemOpFlushRemoteWritesParams_st {
pub operation: CUstreamBatchMemOpType,
pub flags: ::core::ffi::c_uint,
}
impl Default for CUstreamBatchMemOpParams_union_CUstreamMemOpFlushRemoteWritesParams_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUstreamBatchMemOpParams_union_CUstreamMemOpMemoryBarrierParams_st {
pub operation: CUstreamBatchMemOpType,
pub flags: ::core::ffi::c_uint,
}
impl Default for CUstreamBatchMemOpParams_union_CUstreamMemOpMemoryBarrierParams_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUstreamBatchMemOpParams_union_CUstreamMemOpAtomicReductionParams_st {
pub operation: CUstreamBatchMemOpType,
pub flags: ::core::ffi::c_uint,
pub reductionOp: CUstreamAtomicReductionOpType,
pub dataType: CUstreamAtomicReductionDataType,
pub address: CUdeviceptr,
pub value: cuuint64_t,
pub alias: CUdeviceptr,
}
impl Default for CUstreamBatchMemOpParams_union_CUstreamMemOpAtomicReductionParams_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUstreamBatchMemOpParams_union {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Per-operation parameters for [`cuStreamBatchMemOp_v2`].
pub type CUstreamBatchMemOpParams_v1 = CUstreamBatchMemOpParams_union;
pub type CUstreamBatchMemOpParams = CUstreamBatchMemOpParams_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_BATCH_MEM_OP_NODE_PARAMS_v1_st {
pub ctx: CUcontext,
pub count: ::core::ffi::c_uint,
pub paramArray: *mut CUstreamBatchMemOpParams,
pub flags: ::core::ffi::c_uint,
}
impl Default for CUDA_BATCH_MEM_OP_NODE_PARAMS_v1_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Batch memory operation node parameters
///
/// Used in the legacy [`cuGraphAddBatchMemOpNode`] api. New code should use [`cuGraphAddNode_v2`].
pub type CUDA_BATCH_MEM_OP_NODE_PARAMS_v1 = CUDA_BATCH_MEM_OP_NODE_PARAMS_v1_st;
pub type CUDA_BATCH_MEM_OP_NODE_PARAMS = CUDA_BATCH_MEM_OP_NODE_PARAMS_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_BATCH_MEM_OP_NODE_PARAMS_v2_st {
pub ctx: CUcontext,
pub count: ::core::ffi::c_uint,
pub paramArray: *mut CUstreamBatchMemOpParams,
pub flags: ::core::ffi::c_uint,
}
impl Default for CUDA_BATCH_MEM_OP_NODE_PARAMS_v2_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub type CUDA_BATCH_MEM_OP_NODE_PARAMS_v2 = CUDA_BATCH_MEM_OP_NODE_PARAMS_v2_st;
/// Occupancy calculator flag.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUoccupancy_flags_enum {
/// Default behavior.
CU_OCCUPANCY_DEFAULT = 0,
/// Assume global caching is enabled and cannot be automatically turned off.
CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE = 1,
}
pub use self::CUoccupancy_flags_enum as CUoccupancy_flags;
/// Flags for [`cuStreamUpdateCaptureDependencies_v2`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUstreamUpdateCaptureDependencies_flags_enum {
/// Add new nodes to the dependency set.
CU_STREAM_ADD_CAPTURE_DEPENDENCIES = 0,
/// Replace the dependency set with the new nodes.
CU_STREAM_SET_CAPTURE_DEPENDENCIES = 1,
}
pub use self::CUstreamUpdateCaptureDependencies_flags_enum as CUstreamUpdateCaptureDependencies_flags;
/// Types of async notification that can be sent.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUasyncNotificationType_enum {
/// Sent when the process has exceeded its device memory budget.
CU_ASYNC_NOTIFICATION_TYPE_OVER_BUDGET = 1,
}
pub use self::CUasyncNotificationType_enum as CUasyncNotificationType;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUasyncNotificationInfo_st {
pub type_: CUasyncNotificationType,
pub info: CUasyncNotificationInfo_st__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUasyncNotificationInfo_st__bindgen_ty_1 {
pub overBudget: CUasyncNotificationInfo_st__bindgen_ty_1__bindgen_ty_1,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUasyncNotificationInfo_st__bindgen_ty_1__bindgen_ty_1 {
pub bytesOverBudget: ::core::ffi::c_ulonglong,
}
impl Default for CUasyncNotificationInfo_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUasyncNotificationInfo_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Information passed to the user via the async notification callback.
pub type CUasyncNotificationInfo = CUasyncNotificationInfo_st;
/// CUDA async notification callback.
pub type CUasyncCallback = ::core::option::Option<
unsafe extern "C" fn(
info: *mut CUasyncNotificationInfo,
userData: *mut ::core::ffi::c_void,
callback: CUasyncCallbackHandle,
),
>;
/// Array formats.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUarray_format_enum {
/// Unsigned 8-bit integers.
CU_AD_FORMAT_UNSIGNED_INT8 = 1,
/// Unsigned 16-bit integers.
CU_AD_FORMAT_UNSIGNED_INT16 = 2,
/// Unsigned 32-bit integers.
CU_AD_FORMAT_UNSIGNED_INT32 = 3,
/// Signed 8-bit integers.
CU_AD_FORMAT_SIGNED_INT8 = 8,
/// Signed 16-bit integers.
CU_AD_FORMAT_SIGNED_INT16 = 9,
/// Signed 32-bit integers.
CU_AD_FORMAT_SIGNED_INT32 = 10,
/// 16-bit floating point.
CU_AD_FORMAT_HALF = 16,
/// 32-bit floating point.
CU_AD_FORMAT_FLOAT = 32,
/// 8-bit YUV planar format, with 4:2:0 sampling.
CU_AD_FORMAT_NV12 = 176,
/// 1 channel unsigned 8-bit normalized integer.
CU_AD_FORMAT_UNORM_INT8X1 = 192,
/// 2 channel unsigned 8-bit normalized integer.
CU_AD_FORMAT_UNORM_INT8X2 = 193,
/// 4 channel unsigned 8-bit normalized integer.
CU_AD_FORMAT_UNORM_INT8X4 = 194,
/// 1 channel unsigned 16-bit normalized integer.
CU_AD_FORMAT_UNORM_INT16X1 = 195,
/// 2 channel unsigned 16-bit normalized integer.
CU_AD_FORMAT_UNORM_INT16X2 = 196,
/// 4 channel unsigned 16-bit normalized integer.
CU_AD_FORMAT_UNORM_INT16X4 = 197,
/// 1 channel signed 8-bit normalized integer.
CU_AD_FORMAT_SNORM_INT8X1 = 198,
/// 2 channel signed 8-bit normalized integer.
CU_AD_FORMAT_SNORM_INT8X2 = 199,
/// 4 channel signed 8-bit normalized integer.
CU_AD_FORMAT_SNORM_INT8X4 = 200,
/// 1 channel signed 16-bit normalized integer.
CU_AD_FORMAT_SNORM_INT16X1 = 201,
/// 2 channel signed 16-bit normalized integer.
CU_AD_FORMAT_SNORM_INT16X2 = 202,
/// 4 channel signed 16-bit normalized integer.
CU_AD_FORMAT_SNORM_INT16X4 = 203,
/// 4 channel unsigned normalized block-compressed (BC1 compression) format.
CU_AD_FORMAT_BC1_UNORM = 145,
/// 4 channel unsigned normalized block-compressed (BC1 compression) format with sRGB encoding.
CU_AD_FORMAT_BC1_UNORM_SRGB = 146,
/// 4 channel unsigned normalized block-compressed (BC2 compression) format.
CU_AD_FORMAT_BC2_UNORM = 147,
/// 4 channel unsigned normalized block-compressed (BC2 compression) format with sRGB encoding.
CU_AD_FORMAT_BC2_UNORM_SRGB = 148,
/// 4 channel unsigned normalized block-compressed (BC3 compression) format.
CU_AD_FORMAT_BC3_UNORM = 149,
/// 4 channel unsigned normalized block-compressed (BC3 compression) format with sRGB encoding.
CU_AD_FORMAT_BC3_UNORM_SRGB = 150,
/// 1 channel unsigned normalized block-compressed (BC4 compression) format.
CU_AD_FORMAT_BC4_UNORM = 151,
/// 1 channel signed normalized block-compressed (BC4 compression) format.
CU_AD_FORMAT_BC4_SNORM = 152,
/// 2 channel unsigned normalized block-compressed (BC5 compression) format.
CU_AD_FORMAT_BC5_UNORM = 153,
/// 2 channel signed normalized block-compressed (BC5 compression) format.
CU_AD_FORMAT_BC5_SNORM = 154,
/// 3 channel unsigned half-float block-compressed (BC6H compression) format.
CU_AD_FORMAT_BC6H_UF16 = 155,
/// 3 channel signed half-float block-compressed (BC6H compression) format.
CU_AD_FORMAT_BC6H_SF16 = 156,
/// 4 channel unsigned normalized block-compressed (BC7 compression) format.
CU_AD_FORMAT_BC7_UNORM = 157,
/// 4 channel unsigned normalized block-compressed (BC7 compression) format with sRGB encoding.
CU_AD_FORMAT_BC7_UNORM_SRGB = 158,
/// 10-bit YUV planar format, with 4:2:0 sampling.
CU_AD_FORMAT_P010 = 159,
/// 16-bit YUV planar format, with 4:2:0 sampling.
CU_AD_FORMAT_P016 = 161,
/// 8-bit YUV planar format, with 4:2:2 sampling.
CU_AD_FORMAT_NV16 = 162,
/// 10-bit YUV planar format, with 4:2:2 sampling.
CU_AD_FORMAT_P210 = 163,
/// 16-bit YUV planar format, with 4:2:2 sampling.
CU_AD_FORMAT_P216 = 164,
/// 2 channel, 8-bit YUV packed planar format, with 4:2:2 sampling.
CU_AD_FORMAT_YUY2 = 165,
/// 2 channel, 10-bit YUV packed planar format, with 4:2:2 sampling.
CU_AD_FORMAT_Y210 = 166,
/// 2 channel, 16-bit YUV packed planar format, with 4:2:2 sampling.
CU_AD_FORMAT_Y216 = 167,
/// 4 channel, 8-bit YUV packed planar format, with 4:4:4 sampling.
CU_AD_FORMAT_AYUV = 168,
/// 10-bit YUV packed planar format, with 4:4:4 sampling.
CU_AD_FORMAT_Y410 = 169,
/// 4 channel, 12-bit YUV packed planar format, with 4:4:4 sampling.
CU_AD_FORMAT_Y416 = 177,
/// 3 channel 8-bit YUV planar format, with 4:4:4 sampling.
CU_AD_FORMAT_Y444_PLANAR8 = 178,
/// 3 channel 10-bit YUV planar format, with 4:4:4 sampling.
CU_AD_FORMAT_Y444_PLANAR10 = 179,
/// 3 channel 8-bit YUV semi-planar format, with 4:4:4 sampling.
CU_AD_FORMAT_YUV444_8bit_SemiPlanar = 180,
/// 3 channel 16-bit YUV semi-planar format, with 4:4:4 sampling.
CU_AD_FORMAT_YUV444_16bit_SemiPlanar = 181,
/// 4 channel unorm R10G10B10A2 RGB format.
CU_AD_FORMAT_UNORM_INT_101010_2 = 80,
/// 4 channel unsigned 8-bit YUV packed format, with 4:2:2 sampling.
CU_AD_FORMAT_UINT8_PACKED_422 = 81,
/// 4 channel unsigned 8-bit YUV packed format, with 4:4:4 sampling.
CU_AD_FORMAT_UINT8_PACKED_444 = 82,
/// 3 channel unsigned 8-bit YUV semi-planar format, with 4:2:0 sampling.
CU_AD_FORMAT_UINT8_SEMIPLANAR_420 = 83,
/// 3 channel unsigned 16-bit YUV semi-planar format, with 4:2:0 sampling.
CU_AD_FORMAT_UINT16_SEMIPLANAR_420 = 84,
/// 3 channel unsigned 8-bit YUV semi-planar format, with 4:2:2 sampling.
CU_AD_FORMAT_UINT8_SEMIPLANAR_422 = 85,
/// 3 channel unsigned 16-bit YUV semi-planar format, with 4:2:2 sampling.
CU_AD_FORMAT_UINT16_SEMIPLANAR_422 = 86,
/// 3 channel unsigned 8-bit YUV semi-planar format, with 4:4:4 sampling.
CU_AD_FORMAT_UINT8_SEMIPLANAR_444 = 87,
/// 3 channel unsigned 16-bit YUV semi-planar format, with 4:4:4 sampling.
CU_AD_FORMAT_UINT16_SEMIPLANAR_444 = 88,
/// 3 channel unsigned 8-bit YUV planar format, with 4:2:0 sampling.
CU_AD_FORMAT_UINT8_PLANAR_420 = 89,
/// 3 channel unsigned 16-bit YUV planar format, with 4:2:0 sampling.
CU_AD_FORMAT_UINT16_PLANAR_420 = 90,
/// 3 channel unsigned 8-bit YUV planar format, with 4:2:2 sampling.
CU_AD_FORMAT_UINT8_PLANAR_422 = 91,
/// 3 channel unsigned 16-bit YUV planar format, with 4:2:2 sampling.
CU_AD_FORMAT_UINT16_PLANAR_422 = 92,
/// 3 channel unsigned 8-bit YUV planar format, with 4:4:4 sampling.
CU_AD_FORMAT_UINT8_PLANAR_444 = 93,
/// 3 channel unsigned 16-bit YUV planar format, with 4:4:4 sampling.
CU_AD_FORMAT_UINT16_PLANAR_444 = 94,
CU_AD_FORMAT_MAX = 2147483647,
}
pub use self::CUarray_format_enum as CUarray_format;
/// Texture reference addressing modes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUaddress_mode_enum {
/// Wrapping address mode.
CU_TR_ADDRESS_MODE_WRAP = 0,
/// Clamp to edge address mode.
CU_TR_ADDRESS_MODE_CLAMP = 1,
/// Mirror address mode.
CU_TR_ADDRESS_MODE_MIRROR = 2,
/// Border address mode.
CU_TR_ADDRESS_MODE_BORDER = 3,
}
pub use self::CUaddress_mode_enum as CUaddress_mode;
/// Texture reference filtering modes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUfilter_mode_enum {
/// Point filter mode.
CU_TR_FILTER_MODE_POINT = 0,
/// Linear filter mode.
CU_TR_FILTER_MODE_LINEAR = 1,
}
pub use self::CUfilter_mode_enum as CUfilter_mode;
impl CUdevice_attribute_enum {
pub const CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK: CUdevice_attribute_enum = CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK;
}
impl CUdevice_attribute_enum {
pub const CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK: CUdevice_attribute_enum = CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK;
}
impl CUdevice_attribute_enum {
pub const CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH: CUdevice_attribute_enum = CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH;
}
impl CUdevice_attribute_enum {
pub const CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT: CUdevice_attribute_enum = CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT;
}
impl CUdevice_attribute_enum {
pub const CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES: CUdevice_attribute_enum = CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS;
}
impl CUdevice_attribute_enum {
pub const CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED: CUdevice_attribute_enum = CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_VIRTUAL_ADDRESS_MANAGEMENT_SUPPORTED;
}
/// Device properties.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUdevice_attribute_enum {
/// Maximum number of threads per block.
CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 1,
/// Maximum block dimension X.
CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X = 2,
/// Maximum block dimension Y.
CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y = 3,
/// Maximum block dimension Z.
CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z = 4,
/// Maximum grid dimension X.
CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 5,
/// Maximum grid dimension Y.
CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y = 6,
/// Maximum grid dimension Z.
CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z = 7,
/// Maximum shared memory available per block in bytes.
CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK = 8,
/// Memory available on device for __constant__ variables in a CUDA C kernel in bytes.
CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY = 9,
/// Warp size in threads.
CU_DEVICE_ATTRIBUTE_WARP_SIZE = 10,
/// Maximum pitch in bytes allowed by memory copies.
CU_DEVICE_ATTRIBUTE_MAX_PITCH = 11,
/// Maximum number of 32-bit registers available per block.
CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK = 12,
/// Typical clock frequency in kilohertz.
CU_DEVICE_ATTRIBUTE_CLOCK_RATE = 13,
/// Alignment requirement for textures.
CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT = 14,
/// Device can possibly copy memory and execute a kernel concurrently. Deprecated. Use instead [`CUdevice_attribute::CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT`].
#[deprecated]
CU_DEVICE_ATTRIBUTE_GPU_OVERLAP = 15,
/// Number of multiprocessors on device.
CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT = 16,
/// Specifies whether there is a run time limit on kernels.
CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT = 17,
/// Device is integrated with host memory.
CU_DEVICE_ATTRIBUTE_INTEGRATED = 18,
/// Device can map host memory into CUDA address space.
CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY = 19,
/// Compute mode (See `CUcomputemode` for details).
CU_DEVICE_ATTRIBUTE_COMPUTE_MODE = 20,
/// Maximum 1D texture width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH = 21,
/// Maximum 2D texture width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH = 22,
/// Maximum 2D texture height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT = 23,
/// Maximum 3D texture width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH = 24,
/// Maximum 3D texture height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT = 25,
/// Maximum 3D texture depth.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH = 26,
/// Maximum 2D layered texture width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH = 27,
/// Maximum 2D layered texture height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT = 28,
/// Maximum layers in a 2D layered texture.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS = 29,
/// Alignment requirement for surfaces.
CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT = 30,
/// Device can possibly execute multiple kernels concurrently.
CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS = 31,
/// Device has ECC support enabled.
CU_DEVICE_ATTRIBUTE_ECC_ENABLED = 32,
/// PCI bus ID of the device.
CU_DEVICE_ATTRIBUTE_PCI_BUS_ID = 33,
/// PCI device ID of the device.
CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID = 34,
/// Device is using TCC driver model.
CU_DEVICE_ATTRIBUTE_TCC_DRIVER = 35,
/// Peak memory clock frequency in kilohertz.
CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE = 36,
/// Global memory bus width in bits.
CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH = 37,
/// Size of L2 cache in bytes.
CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE = 38,
/// Maximum resident threads per multiprocessor.
CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR = 39,
/// Number of asynchronous engines.
CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT = 40,
/// Device shares a unified address space with the host.
CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING = 41,
/// Maximum 1D layered texture width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH = 42,
/// Maximum layers in a 1D layered texture.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS = 43,
/// do not use.
#[deprecated]
CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER = 44,
/// Maximum 2D texture width if CUDA_ARRAY3D_TEXTURE_GATHER is set.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH = 45,
/// Maximum 2D texture height if CUDA_ARRAY3D_TEXTURE_GATHER is set.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT = 46,
/// Alternate maximum 3D texture width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE = 47,
/// Alternate maximum 3D texture height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE = 48,
/// Alternate maximum 3D texture depth.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE = 49,
/// PCI domain ID of the device.
CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID = 50,
/// Pitch alignment requirement for textures.
CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT = 51,
/// Maximum cubemap texture width/height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH = 52,
/// Maximum cubemap layered texture width/height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH = 53,
/// Maximum layers in a cubemap layered texture.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS = 54,
/// Maximum 1D surface width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH = 55,
/// Maximum 2D surface width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH = 56,
/// Maximum 2D surface height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT = 57,
/// Maximum 3D surface width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH = 58,
/// Maximum 3D surface height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT = 59,
/// Maximum 3D surface depth.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH = 60,
/// Maximum 1D layered surface width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH = 61,
/// Maximum layers in a 1D layered surface.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS = 62,
/// Maximum 2D layered surface width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH = 63,
/// Maximum 2D layered surface height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT = 64,
/// Maximum layers in a 2D layered surface.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS = 65,
/// Maximum cubemap surface width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH = 66,
/// Maximum cubemap layered surface width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH = 67,
/// Maximum layers in a cubemap layered surface.
CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS = 68,
/// do not use. Use [cudaDeviceGetTexture1DLinearMaxWidth()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g45f0345fd7a3697d0766596593920f61) or [`cuDeviceGetTexture1DLinearMaxWidth`] instead.
#[deprecated]
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH = 69,
/// Maximum 2D linear texture width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH = 70,
/// Maximum 2D linear texture height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT = 71,
/// Maximum 2D linear texture pitch in bytes.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH = 72,
/// Maximum mipmapped 2D texture width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH = 73,
/// Maximum mipmapped 2D texture height.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT = 74,
/// Major compute capability version number.
CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75,
/// Minor compute capability version number.
CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76,
/// Maximum mipmapped 1D texture width.
CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH = 77,
/// Device supports stream priorities.
CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED = 78,
/// Device supports caching globals in L1.
CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED = 79,
/// Device supports caching locals in L1.
CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED = 80,
/// Maximum shared memory available per multiprocessor in bytes.
CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR = 81,
/// Maximum number of 32-bit registers available per multiprocessor.
CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR = 82,
/// Device can allocate managed memory on this system.
CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY = 83,
/// Device is on a multi-GPU board.
CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD = 84,
/// Unique id for a group of devices on the same multi-GPU board.
CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID = 85,
/// Link between the device and the host supports all native atomic operations.
CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED = 86,
/// Ratio of single precision performance (in floating-point operations per second) to double precision performance.
CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO = 87,
/// Device supports coherently accessing pageable memory without calling cudaHostRegister on it.
CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS = 88,
/// Device can coherently access managed memory concurrently with the CPU.
CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS = 89,
/// Device supports compute preemption.
CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED = 90,
/// Device can access host registered memory at the same virtual address as the CPU.
CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM = 91,
/// along with v1 MemOps API, [`cuStreamBatchMemOp_v2`] and related APIs are supported.
#[deprecated]
CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_MEM_OPS_V1 = 92,
/// along with v1 MemOps API, 64-bit operations are supported in [`cuStreamBatchMemOp_v2`] and related APIs.
#[deprecated]
CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS_V1 = 93,
/// along with v1 MemOps API, CU_STREAM_WAIT_VALUE_NOR is supported.
#[deprecated]
CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_WAIT_VALUE_NOR_V1 = 94,
/// Device supports launching cooperative kernels via [`cuLaunchCooperativeKernel`].
CU_DEVICE_ATTRIBUTE_COOPERATIVE_LAUNCH = 95,
/// [`cuLaunchCooperativeKernelMultiDevice`] is deprecated.
#[deprecated]
CU_DEVICE_ATTRIBUTE_COOPERATIVE_MULTI_DEVICE_LAUNCH = 96,
/// Maximum optin shared memory per block.
CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN = 97,
/// The CU_STREAM_WAIT_VALUE_FLUSH flag and the CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES MemOp are supported on the device. See [Stream Memory Operations](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-memory-operations.html#group__CUDA__MEMOP) for additional details.
CU_DEVICE_ATTRIBUTE_CAN_FLUSH_REMOTE_WRITES = 98,
/// Device supports host memory registration via [cudaHostRegister](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1ge8d5c17670f16ac4fc8fcb4181cb490c).
CU_DEVICE_ATTRIBUTE_HOST_REGISTER_SUPPORTED = 99,
/// Device accesses pageable memory via the host's page tables.
CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES = 100,
/// The host can directly access managed memory on the device without migration.
CU_DEVICE_ATTRIBUTE_DIRECT_MANAGED_MEM_ACCESS_FROM_HOST = 101,
/// Use [`CUdevice_attribute::CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED`].
#[deprecated]
CU_DEVICE_ATTRIBUTE_VIRTUAL_ADDRESS_MANAGEMENT_SUPPORTED = 102,
/// Device supports exporting memory to a posix file descriptor with [`cuMemExportToShareableHandle`], if requested via [`cuMemCreate`].
CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR_SUPPORTED = 103,
/// Device supports exporting memory to a Win32 NT handle with [`cuMemExportToShareableHandle`], if requested via [`cuMemCreate`].
CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_HANDLE_SUPPORTED = 104,
/// Device supports exporting memory to a Win32 KMT handle with [`cuMemExportToShareableHandle`], if requested via [`cuMemCreate`].
CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_KMT_HANDLE_SUPPORTED = 105,
/// Maximum number of blocks per multiprocessor.
CU_DEVICE_ATTRIBUTE_MAX_BLOCKS_PER_MULTIPROCESSOR = 106,
/// Device supports compression of memory.
CU_DEVICE_ATTRIBUTE_GENERIC_COMPRESSION_SUPPORTED = 107,
/// Maximum L2 persisting lines capacity setting in bytes.
CU_DEVICE_ATTRIBUTE_MAX_PERSISTING_L2_CACHE_SIZE = 108,
/// Maximum value of [CUaccessPolicyWindow::num_bytes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUaccessPolicyWindow__v1.html#structCUaccessPolicyWindow__v1_179ee4c983788bc68605d42aee2701eec).
CU_DEVICE_ATTRIBUTE_MAX_ACCESS_POLICY_WINDOW_SIZE = 109,
/// Device supports specifying the GPUDirect RDMA flag with [`cuMemCreate`].
CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED = 110,
/// Shared memory reserved by CUDA driver per block in bytes.
CU_DEVICE_ATTRIBUTE_RESERVED_SHARED_MEMORY_PER_BLOCK = 111,
/// Device supports sparse CUDA arrays and sparse CUDA mipmapped arrays.
CU_DEVICE_ATTRIBUTE_SPARSE_CUDA_ARRAY_SUPPORTED = 112,
/// Device supports using the [`cuMemHostRegister_v2`] flag CU_MEMHOSTERGISTER_READ_ONLY to register memory that must be mapped as read-only to the GPU.
CU_DEVICE_ATTRIBUTE_READ_ONLY_HOST_REGISTER_SUPPORTED = 113,
/// External timeline semaphore interop is supported on the device.
CU_DEVICE_ATTRIBUTE_TIMELINE_SEMAPHORE_INTEROP_SUPPORTED = 114,
/// Device supports using the [`cuMemAllocAsync`] and cuMemPool family of APIs.
CU_DEVICE_ATTRIBUTE_MEMORY_POOLS_SUPPORTED = 115,
/// Device supports GPUDirect RDMA APIs, like nvidia_p2p_get_pages (see <https://docs.nvidia.com/cuda/gpudirect-rdma> for more information).
CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_SUPPORTED = 116,
/// The returned attribute shall be interpreted as a bitmask, where the individual bits are described by the `CUflushGPUDirectRDMAWritesOptions` enum.
CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_FLUSH_WRITES_OPTIONS = 117,
/// GPUDirect RDMA writes to the device do not need to be flushed for consumers within the scope indicated by the returned attribute.
/// See `CUGPUDirectRDMAWritesOrdering` for the numerical values returned here.
CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WRITES_ORDERING = 118,
/// Handle types supported with mempool based IPC.
CU_DEVICE_ATTRIBUTE_MEMPOOL_SUPPORTED_HANDLE_TYPES = 119,
/// Indicates device supports cluster launch.
CU_DEVICE_ATTRIBUTE_CLUSTER_LAUNCH = 120,
/// Device supports deferred mapping CUDA arrays and CUDA mipmapped arrays.
CU_DEVICE_ATTRIBUTE_DEFERRED_MAPPING_CUDA_ARRAY_SUPPORTED = 121,
/// 64-bit operations are supported in [`cuStreamBatchMemOp_v2`] and related MemOp APIs.
CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS = 122,
/// CU_STREAM_WAIT_VALUE_NOR is supported by MemOp APIs.
CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_WAIT_VALUE_NOR = 123,
/// Device supports buffer sharing with dma_buf mechanism.
CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED = 124,
/// Device supports IPC Events.
CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED = 125,
/// Number of memory domains the device supports.
CU_DEVICE_ATTRIBUTE_MEM_SYNC_DOMAIN_COUNT = 126,
/// Device supports accessing memory using Tensor Map.
CU_DEVICE_ATTRIBUTE_TENSOR_MAP_ACCESS_SUPPORTED = 127,
/// Device supports exporting memory to a fabric handle with [`cuMemExportToShareableHandle`] or requested with [`cuMemCreate`].
CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_FABRIC_SUPPORTED = 128,
/// Device supports unified function pointers.
CU_DEVICE_ATTRIBUTE_UNIFIED_FUNCTION_POINTERS = 129,
/// NUMA configuration of a device: value is of type `CUdeviceNumaConfig` enum.
CU_DEVICE_ATTRIBUTE_NUMA_CONFIG = 130,
/// NUMA node ID of the GPU memory.
CU_DEVICE_ATTRIBUTE_NUMA_ID = 131,
/// Device supports switch multicast and reduction operations.
CU_DEVICE_ATTRIBUTE_MULTICAST_SUPPORTED = 132,
/// Indicates if contexts created on this device will be shared via MPS.
CU_DEVICE_ATTRIBUTE_MPS_ENABLED = 133,
/// NUMA ID of the host node closest to the device. Returns -1 when system does not support NUMA.
CU_DEVICE_ATTRIBUTE_HOST_NUMA_ID = 134,
/// Device supports CIG with D3D12.
CU_DEVICE_ATTRIBUTE_D3D12_CIG_SUPPORTED = 135,
/// The returned valued shall be interpreted as a bitmask, where the individual bits are described by the `CUmemDecompressAlgorithm` enum.
CU_DEVICE_ATTRIBUTE_MEM_DECOMPRESS_ALGORITHM_MASK = 136,
/// The returned valued is the maximum length in bytes of a single decompress operation that is allowed.
CU_DEVICE_ATTRIBUTE_MEM_DECOMPRESS_MAXIMUM_LENGTH = 137,
/// Device supports CIG with Vulkan.
CU_DEVICE_ATTRIBUTE_VULKAN_CIG_SUPPORTED = 138,
/// The combined 16-bit PCI device ID and 16-bit PCI vendor ID.
CU_DEVICE_ATTRIBUTE_GPU_PCI_DEVICE_ID = 139,
/// The combined 16-bit PCI subsystem ID and 16-bit PCI subsystem vendor ID.
CU_DEVICE_ATTRIBUTE_GPU_PCI_SUBSYSTEM_ID = 140,
/// Device supports HOST_NUMA location with the virtual memory management APIs like [`cuMemCreate`], [`cuMemMap`] and related APIs.
CU_DEVICE_ATTRIBUTE_HOST_NUMA_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED = 141,
/// Device supports HOST_NUMA location with the [`cuMemAllocAsync`] and cuMemPool family of APIs.
CU_DEVICE_ATTRIBUTE_HOST_NUMA_MEMORY_POOLS_SUPPORTED = 142,
/// Device supports HOST_NUMA location IPC between nodes in a multi-node system.
CU_DEVICE_ATTRIBUTE_HOST_NUMA_MULTINODE_IPC_SUPPORTED = 143,
/// Device suports HOST location with the [`cuMemAllocAsync`] and cuMemPool family of APIs.
CU_DEVICE_ATTRIBUTE_HOST_MEMORY_POOLS_SUPPORTED = 144,
/// Device supports HOST location with the virtual memory management APIs like [`cuMemCreate`], [`cuMemMap`] and related APIs.
CU_DEVICE_ATTRIBUTE_HOST_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED = 145,
/// Device supports page-locked host memory buffer sharing with dma_buf mechanism.
CU_DEVICE_ATTRIBUTE_HOST_ALLOC_DMA_BUF_SUPPORTED = 146,
/// Link between the device and the host supports only some native atomic operations.
CU_DEVICE_ATTRIBUTE_ONLY_PARTIAL_HOST_NATIVE_ATOMIC_SUPPORTED = 147,
/// Device supports atomic reduction operations in stream batch memory operations.
CU_DEVICE_ATTRIBUTE_ATOMIC_REDUCTION_SUPPORTED = 148,
CU_DEVICE_ATTRIBUTE_MAX = 149,
}
pub use self::CUdevice_attribute_enum as CUdevice_attribute;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUdevprop_st {
pub maxThreadsPerBlock: ::core::ffi::c_int,
pub maxThreadsDim: [::core::ffi::c_int; 3usize],
pub maxGridSize: [::core::ffi::c_int; 3usize],
pub sharedMemPerBlock: ::core::ffi::c_int,
pub totalConstantMemory: ::core::ffi::c_int,
pub SIMDWidth: ::core::ffi::c_int,
pub memPitch: ::core::ffi::c_int,
pub regsPerBlock: ::core::ffi::c_int,
pub clockRate: ::core::ffi::c_int,
pub textureAlign: ::core::ffi::c_int,
}
/// Legacy device properties.
pub type CUdevprop_v1 = CUdevprop_st;
pub type CUdevprop = CUdevprop_v1;
/// Pointer information.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUpointer_attribute_enum {
/// The [`CUcontext`] on which a pointer was allocated or registered.
CU_POINTER_ATTRIBUTE_CONTEXT = 1,
/// The `CUmemorytype` describing the physical location of a pointer.
CU_POINTER_ATTRIBUTE_MEMORY_TYPE = 2,
/// The address at which a pointer's memory may be accessed on the device.
CU_POINTER_ATTRIBUTE_DEVICE_POINTER = 3,
/// The address at which a pointer's memory may be accessed on the host.
CU_POINTER_ATTRIBUTE_HOST_POINTER = 4,
/// A pair of tokens for use with the nv-p2p.h Linux kernel interface.
CU_POINTER_ATTRIBUTE_P2P_TOKENS = 5,
/// Synchronize every synchronous memory operation initiated on this region.
CU_POINTER_ATTRIBUTE_SYNC_MEMOPS = 6,
/// A process-wide unique ID for an allocated memory region.
CU_POINTER_ATTRIBUTE_BUFFER_ID = 7,
/// Indicates if the pointer points to managed memory.
CU_POINTER_ATTRIBUTE_IS_MANAGED = 8,
/// A device ordinal of a device on which a pointer was allocated or registered.
CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL = 9,
/// 1 if this pointer maps to an allocation that is suitable for [cudaIpcGetMemHandle](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g8a37f7dfafaca652391d0758b3667539), 0 otherwise.
CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE = 10,
/// Starting address for this requested pointer.
CU_POINTER_ATTRIBUTE_RANGE_START_ADDR = 11,
/// Size of the address range for this requested pointer.
CU_POINTER_ATTRIBUTE_RANGE_SIZE = 12,
/// 1 if this pointer is in a valid address range that is mapped to a backing allocation, 0 otherwise.
CU_POINTER_ATTRIBUTE_MAPPED = 13,
/// Bitmask of allowed `CUmemAllocationHandleType` for this allocation.
CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES = 14,
/// 1 if the memory this pointer is referencing can be used with the GPUDirect RDMA API.
CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE = 15,
/// Returns the access flags the device associated with the current context has on the corresponding memory referenced by the
/// pointer given.
CU_POINTER_ATTRIBUTE_ACCESS_FLAGS = 16,
/// Returns the mempool handle for the allocation if it was allocated from a mempool. Otherwise returns NULL.
CU_POINTER_ATTRIBUTE_MEMPOOL_HANDLE = 17,
/// Size of the actual underlying mapping that the pointer belongs to.
CU_POINTER_ATTRIBUTE_MAPPING_SIZE = 18,
/// The start address of the mapping that the pointer belongs to.
CU_POINTER_ATTRIBUTE_MAPPING_BASE_ADDR = 19,
/// A process-wide unique id corresponding to the physical allocation the pointer belongs to.
CU_POINTER_ATTRIBUTE_MEMORY_BLOCK_ID = 20,
/// Returns in \*data a boolean that indicates whether the pointer points to memory that is capable to be used for hardware accelerated decompression.
CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE = 21,
}
pub use self::CUpointer_attribute_enum as CUpointer_attribute;
/// Function properties.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUfunction_attribute_enum {
/// The maximum number of threads per block, beyond which a launch of the function would fail. This number depends on both the
/// function and the device on which the function is currently loaded.
CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 0,
/// The size in bytes of statically-allocated shared memory required by this function. This does not include dynamically-allocated
/// shared memory requested by the user at runtime.
CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES = 1,
/// The size in bytes of user-allocated constant memory required by this function.
CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES = 2,
/// The size in bytes of local memory used by each thread of this function.
CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES = 3,
/// The number of registers used by each thread of this function.
CU_FUNC_ATTRIBUTE_NUM_REGS = 4,
/// The PTX virtual architecture version for which the function was compiled. This value is the major PTX version \* 10 + the minor
/// PTX version, so a PTX version 1.3 function would return the value 13. Note that this may return the undefined value of 0 for
/// cubins compiled prior to CUDA 3.0.
CU_FUNC_ATTRIBUTE_PTX_VERSION = 5,
/// The binary architecture version for which the function was compiled. This value is the major binary version \* 10 + the minor
/// binary version, so a binary version 1.3 function would return the value 13. Note that this will return a value of 10 for legacy
/// cubins that do not have a properly-encoded binary architecture version.
CU_FUNC_ATTRIBUTE_BINARY_VERSION = 6,
/// The attribute to indicate whether the function has been compiled with user specified option "-Xptxas --dlcm=ca" set .
CU_FUNC_ATTRIBUTE_CACHE_MODE_CA = 7,
/// The maximum size in bytes of dynamically-allocated shared memory that can be used by this function. If the user-specified
/// dynamic shared memory size is larger than this value, the launch will fail. The default value of this attribute is CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK - CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES, except when CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES is greater than CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK, then the default value of this attribute is 0. The value can be increased to CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN - CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES. See [`cuFuncSetAttribute`], [`cuKernelSetAttribute`].
CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES = 8,
/// On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference,
/// in percent of the total shared memory. Refer to CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR. This is only a hint, and the driver can choose a different ratio if required to execute the function. See [`cuFuncSetAttribute`], [`cuKernelSetAttribute`].
CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT = 9,
/// If this attribute is set, the kernel must launch with a valid cluster size specified. See [`cuFuncSetAttribute`], [`cuKernelSetAttribute`].
CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET = 10,
/// The required cluster width in blocks. The values must either all be 0 or all be positive. The validity of the cluster dimensions
/// is otherwise checked at launch time.If the value is set during compile time, it cannot be set at runtime. Setting it at runtime
/// will return [`CUresult::CUDA_ERROR_NOT_PERMITTED`]. See [`cuFuncSetAttribute`], [`cuKernelSetAttribute`].
CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH = 11,
/// The required cluster height in blocks. The values must either all be 0 or all be positive. The validity of the cluster dimensions
/// is otherwise checked at launch time.If the value is set during compile time, it cannot be set at runtime. Setting it at runtime
/// should return [`CUresult::CUDA_ERROR_NOT_PERMITTED`]. See [`cuFuncSetAttribute`], [`cuKernelSetAttribute`].
CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT = 12,
/// The required cluster depth in blocks. The values must either all be 0 or all be positive. The validity of the cluster dimensions
/// is otherwise checked at launch time.If the value is set during compile time, it cannot be set at runtime. Setting it at runtime
/// should return [`CUresult::CUDA_ERROR_NOT_PERMITTED`]. See [`cuFuncSetAttribute`], [`cuKernelSetAttribute`].
CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH = 13,
/// Whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. A non-portable cluster
/// size may only function on the specific SKUs the program is tested on. The launch might fail if the program is run on a different
/// hardware platform.CUDA API provides cudaOccupancyMaxActiveClusters to assist with checking whether the desired size can be
/// launched on the current device.Portable Cluster SizeA portable cluster size is guaranteed to be functional on all compute
/// capabilities higher than the target compute capability. The portable cluster size for sm_90 is 8 blocks per cluster. This
/// value may increase for future compute capabilities.The specific hardware unit may support higher cluster sizes that’s not
/// guaranteed to be portable. See [`cuFuncSetAttribute`], [`cuKernelSetAttribute`].
CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED = 14,
/// The block scheduling policy of a function. The value type is CUclusterSchedulingPolicy / cudaClusterSchedulingPolicy. See
/// [`cuFuncSetAttribute`], [`cuKernelSetAttribute`].
CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE = 15,
CU_FUNC_ATTRIBUTE_MAX = 16,
}
pub use self::CUfunction_attribute_enum as CUfunction_attribute;
/// Function cache configurations.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUfunc_cache_enum {
/// no preference for shared memory or L1 (default).
CU_FUNC_CACHE_PREFER_NONE = 0,
/// prefer larger shared memory and smaller L1 cache.
CU_FUNC_CACHE_PREFER_SHARED = 1,
/// prefer larger L1 cache and smaller shared memory.
CU_FUNC_CACHE_PREFER_L1 = 2,
/// prefer equal sized L1 cache and shared memory.
CU_FUNC_CACHE_PREFER_EQUAL = 3,
}
pub use self::CUfunc_cache_enum as CUfunc_cache;
/// Shared memory configurations.
#[deprecated]
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUsharedconfig_enum {
/// set default shared memory bank size.
#[deprecated]
CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE = 0,
/// set shared memory bank width to four bytes.
#[deprecated]
CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE = 1,
/// set shared memory bank width to eight bytes.
#[deprecated]
CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE = 2,
}
pub use self::CUsharedconfig_enum as CUsharedconfig;
/// Shared memory carveout configurations. These may be passed to [`cuFuncSetAttribute`] or [`cuKernelSetAttribute`].
#[repr(i32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUshared_carveout_enum {
/// No preference for shared memory or L1 (default).
CU_SHAREDMEM_CARVEOUT_DEFAULT = -1,
/// Prefer maximum available shared memory, minimum L1 cache.
CU_SHAREDMEM_CARVEOUT_MAX_SHARED = 100,
/// Prefer maximum available L1 cache, minimum shared memory.
CU_SHAREDMEM_CARVEOUT_MAX_L1 = 0,
}
pub use self::CUshared_carveout_enum as CUshared_carveout;
/// Memory types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemorytype_enum {
/// Host memory.
CU_MEMORYTYPE_HOST = 1,
/// Device memory.
CU_MEMORYTYPE_DEVICE = 2,
/// Array memory.
CU_MEMORYTYPE_ARRAY = 3,
/// Unified device or host memory.
CU_MEMORYTYPE_UNIFIED = 4,
}
pub use self::CUmemorytype_enum as CUmemorytype;
/// Compute Modes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUcomputemode_enum {
/// Default compute mode (Multiple contexts allowed per device).
CU_COMPUTEMODE_DEFAULT = 0,
/// Compute-prohibited mode (No contexts can be created on this device at this time).
CU_COMPUTEMODE_PROHIBITED = 2,
/// Compute-exclusive-process mode (Only one context used by a single process can be present on this device at a time).
CU_COMPUTEMODE_EXCLUSIVE_PROCESS = 3,
}
pub use self::CUcomputemode_enum as CUcomputemode;
/// Memory advise values.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmem_advise_enum {
/// Data will mostly be read and only occasionally be written to.
CU_MEM_ADVISE_SET_READ_MOSTLY = 1,
/// Undo the effect of CU_MEM_ADVISE_SET_READ_MOSTLY.
CU_MEM_ADVISE_UNSET_READ_MOSTLY = 2,
/// Set the preferred location for the data as the specified device.
CU_MEM_ADVISE_SET_PREFERRED_LOCATION = 3,
/// Clear the preferred location for the data.
CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION = 4,
/// Data will be accessed by the specified device, so prevent page faults as much as possible.
CU_MEM_ADVISE_SET_ACCESSED_BY = 5,
/// Let the Unified Memory subsystem decide on the page faulting policy for the specified device.
CU_MEM_ADVISE_UNSET_ACCESSED_BY = 6,
}
pub use self::CUmem_advise_enum as CUmem_advise;
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmem_range_attribute_enum {
CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY = 1,
CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION = 2,
CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY = 3,
CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION = 4,
CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE = 5,
CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_ID = 6,
CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE = 7,
CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_ID = 8,
}
pub use self::CUmem_range_attribute_enum as CUmem_range_attribute;
/// Online compiler and linker options.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUjit_option_enum {
/// Max number of registers that a thread may use.
/// Option type: unsigned int
/// Applies to: compiler only.
CU_JIT_MAX_REGISTERS = 0,
/// IN: Specifies minimum number of threads per block to target compilation for
/// OUT: Returns the number of threads the compiler actually targeted. This restricts the resource utilization of the compiler
/// (e.g. max registers) such that a block with the given number of threads should be able to launch based on register limitations.
/// Note, this option does not currently take into account any other resource limitations, such as shared memory utilization.
/// Cannot be combined with CU_JIT_TARGET.
/// Option type: unsigned int
/// Applies to: compiler only.
CU_JIT_THREADS_PER_BLOCK = 1,
/// Overwrites the option value with the total wall clock time, in milliseconds, spent in the compiler and linker
/// Option type: float
/// Applies to: compiler and linker.
CU_JIT_WALL_TIME = 2,
/// Pointer to a buffer in which to print any log messages that are informational in nature (the buffer size is specified via
/// option CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES)
/// Option type: char \*
/// Applies to: compiler and linker.
CU_JIT_INFO_LOG_BUFFER = 3,
/// IN: Log buffer size in bytes. Log messages will be capped at this size (including null terminator)
/// OUT: Amount of log buffer filled with messages
/// Option type: unsigned int
/// Applies to: compiler and linker.
CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES = 4,
/// Pointer to a buffer in which to print any log messages that reflect errors (the buffer size is specified via option CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES)
/// Option type: char \*
/// Applies to: compiler and linker.
CU_JIT_ERROR_LOG_BUFFER = 5,
/// IN: Log buffer size in bytes. Log messages will be capped at this size (including null terminator)
/// OUT: Amount of log buffer filled with messages
/// Option type: unsigned int
/// Applies to: compiler and linker.
CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES = 6,
/// Level of optimizations to apply to generated code (0 - 4), with 4 being the default and highest level of optimizations.
/// Option type: unsigned int
/// Applies to: compiler only.
CU_JIT_OPTIMIZATION_LEVEL = 7,
/// No option value required. Determines the target based on the current attached context (default)
/// Option type: No option value needed
/// Applies to: compiler and linker.
CU_JIT_TARGET_FROM_CUCONTEXT = 8,
/// Target is chosen based on supplied `CUjit_target`. Cannot be combined with CU_JIT_THREADS_PER_BLOCK.
/// Option type: unsigned int for enumerated type `CUjit_target`
/// Applies to: compiler and linker.
CU_JIT_TARGET = 9,
/// Specifies choice of fallback strategy if matching cubin is not found. Choice is based on supplied `CUjit_fallback`. This option cannot be used with cuLink\* APIs as the linker requires exact matches.
/// Option type: unsigned int for enumerated type `CUjit_fallback`
/// Applies to: compiler only.
CU_JIT_FALLBACK_STRATEGY = 10,
/// Specifies whether to create debug information in output (-g) (0: false, default)
/// Option type: int
/// Applies to: compiler and linker.
CU_JIT_GENERATE_DEBUG_INFO = 11,
/// Generate verbose log messages (0: false, default)
/// Option type: int
/// Applies to: compiler and linker.
CU_JIT_LOG_VERBOSE = 12,
/// Generate line number information (-lineinfo) (0: false, default)
/// Option type: int
/// Applies to: compiler only.
CU_JIT_GENERATE_LINE_INFO = 13,
/// Specifies whether to enable caching explicitly (-dlcm)
/// Choice is based on supplied CUjit_cacheMode_enum.
/// Option type: unsigned int for enumerated type CUjit_cacheMode_enum
/// Applies to: compiler only.
CU_JIT_CACHE_MODE = 14,
#[deprecated]
CU_JIT_NEW_SM3X_OPT = 15,
/// This jit option is used for internal purpose only.
CU_JIT_FAST_COMPILE = 16,
/// Array of device symbol names that will be relocated to the corresponding host addresses stored in CU_JIT_GLOBAL_SYMBOL_ADDRESSES.
/// Must contain CU_JIT_GLOBAL_SYMBOL_COUNT entries.
/// When loading a device module, driver will relocate all encountered unresolved symbols to the host addresses.
/// It is only allowed to register symbols that correspond to unresolved global variables.
/// It is illegal to register the same device symbol at multiple addresses.
/// Option type: const char \*\*
/// Applies to: dynamic linker only.
CU_JIT_GLOBAL_SYMBOL_NAMES = 17,
/// Array of host addresses that will be used to relocate corresponding device symbols stored in CU_JIT_GLOBAL_SYMBOL_NAMES.
/// Must contain CU_JIT_GLOBAL_SYMBOL_COUNT entries.
/// Option type: void \*\*
/// Applies to: dynamic linker only.
CU_JIT_GLOBAL_SYMBOL_ADDRESSES = 18,
/// Number of entries in CU_JIT_GLOBAL_SYMBOL_NAMES and CU_JIT_GLOBAL_SYMBOL_ADDRESSES arrays.
/// Option type: unsigned int
/// Applies to: dynamic linker only.
CU_JIT_GLOBAL_SYMBOL_COUNT = 19,
/// Enable link-time optimization (-dlto) for device code (Disabled by default).
/// This option is not supported on 32-bit platforms.
/// Option type: int
/// Applies to: compiler and linker
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_LTO = 20,
/// Control single-precision denormals (-ftz) support (0: false, default). 1 : flushes denormal values to zero 0 : preserves denormal
/// values Option type: int
/// Applies to: link-time optimization specified with [`CUjit_option::CU_JIT_LTO`]
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_FTZ = 21,
/// Control single-precision floating-point division and reciprocals (-prec-div) support (1: true, default). 1 : Enables the IEEE
/// round-to-nearest mode 0 : Enables the fast approximation mode Option type: int
/// Applies to: link-time optimization specified with [`CUjit_option::CU_JIT_LTO`]
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_PREC_DIV = 22,
/// Control single-precision floating-point square root (-prec-sqrt) support (1: true, default). 1 : Enables the IEEE round-to-nearest
/// mode 0 : Enables the fast approximation mode Option type: int
/// Applies to: link-time optimization specified with [`CUjit_option::CU_JIT_LTO`]
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_PREC_SQRT = 23,
/// Enable/Disable the contraction of floating-point multiplies and adds/subtracts into floating-point multiply-add (-fma) operations
/// ```text
/// (1: Enable, default; 0: Disable). Option type: int
/// Applies to: link-time optimization specified with [`CUjit_option::CU_JIT_LTO`]
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0
/// ```
#[deprecated]
CU_JIT_FMA = 24,
/// Array of kernel names that should be preserved at link time while others can be removed.
/// Must contain CU_JIT_REFERENCED_KERNEL_COUNT entries.
/// Note that kernel names can be mangled by the compiler in which case the mangled name needs to be specified.
/// Wildcard "\*" can be used to represent zero or more characters instead of specifying the full or mangled name.
/// It is important to note that the wildcard "\*" is also added implicitly. For example, specifying "foo" will match "foobaz",
/// "barfoo", "barfoobaz" and thus preserve all kernels with those names. This can be avoided by providing a more specific name
/// like "barfoobaz".
/// Option type: const char \*\*
/// Applies to: dynamic linker only
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_REFERENCED_KERNEL_NAMES = 25,
/// Number of entries in CU_JIT_REFERENCED_KERNEL_NAMES array.
/// Option type: unsigned int
/// Applies to: dynamic linker only
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_REFERENCED_KERNEL_COUNT = 26,
/// Array of variable names (__device__ and/or __constant__) that should be preserved at link time while others can be removed.
/// Must contain CU_JIT_REFERENCED_VARIABLE_COUNT entries.
/// Note that variable names can be mangled by the compiler in which case the mangled name needs to be specified.
/// Wildcard "\*" can be used to represent zero or more characters instead of specifying the full or mangled name.
/// It is important to note that the wildcard "\*" is also added implicitly. For example, specifying "foo" will match "foobaz",
/// "barfoo", "barfoobaz" and thus preserve all variables with those names. This can be avoided by providing a more specific name
/// like "barfoobaz".
/// Option type: const char \*\*
/// Applies to: link-time optimization specified with [`CUjit_option::CU_JIT_LTO`]
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_REFERENCED_VARIABLE_NAMES = 27,
/// Number of entries in CU_JIT_REFERENCED_VARIABLE_NAMES array.
/// Option type: unsigned int
/// Applies to: link-time optimization specified with [`CUjit_option::CU_JIT_LTO`]
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_REFERENCED_VARIABLE_COUNT = 28,
/// This option serves as a hint to enable the JIT compiler/linker to remove constant (__constant__) and device (__device__) variables
/// unreferenced in device code (Disabled by default).
/// Note that host references to constant and device variables using APIs like [`cuModuleGetGlobal_v2`] with this option specified may result in undefined behavior unless the variables are explicitly specified using CU_JIT_REFERENCED_VARIABLE_NAMES.
/// Option type: int
/// Applies to: link-time optimization specified with [`CUjit_option::CU_JIT_LTO`]
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_OPTIMIZE_UNUSED_DEVICE_VARIABLES = 29,
/// Generate position independent code (0: false)
/// Option type: int
/// Applies to: compiler only.
CU_JIT_POSITION_INDEPENDENT_CODE = 30,
/// This option hints to the JIT compiler the minimum number of CTAs from the kernel’s grid to be mapped to a SM. This option
/// is ignored when used together with CU_JIT_MAX_REGISTERS or CU_JIT_THREADS_PER_BLOCK. Optimizations based on this option need CU_JIT_MAX_THREADS_PER_BLOCK to be specified as well. For kernels already using PTX directive .minnctapersm, this option will be ignored by default. Use
/// CU_JIT_OVERRIDE_DIRECTIVE_VALUES to let this option take precedence over the PTX directive. Option type: unsigned int
/// Applies to: compiler only.
CU_JIT_MIN_CTA_PER_SM = 31,
/// Maximum number threads in a thread block, computed as the product of the maximum extent specifed for each dimension of the
/// block. This limit is guaranteed not to be exeeded in any invocation of the kernel. Exceeding the maximum number of threads
/// results in runtime error or kernel launch failure. For kernels already using PTX directive .maxntid, this option will be ignored
/// by default. Use CU_JIT_OVERRIDE_DIRECTIVE_VALUES to let this option take precedence over the PTX directive. Option type: int
/// Applies to: compiler only.
CU_JIT_MAX_THREADS_PER_BLOCK = 32,
/// This option lets the values specified using CU_JIT_MAX_REGISTERS, CU_JIT_THREADS_PER_BLOCK, CU_JIT_MAX_THREADS_PER_BLOCK and CU_JIT_MIN_CTA_PER_SM take precedence over any PTX directives. (0: Disable, default; 1: Enable) Option type: int
/// Applies to: compiler only.
CU_JIT_OVERRIDE_DIRECTIVE_VALUES = 33,
/// This option specifies the maximum number of concurrent threads to use when running compiler optimizations. If the specified
/// value is 1, the option will be ignored. If the specified value is 0, the number of threads will match the number of CPUs on
/// the underlying machine. Otherwise, if the option is N, then up to N threads will be used. Option type: unsigned int
/// Applies to: compiler only.
CU_JIT_SPLIT_COMPILE = 34,
/// This option specifies the maximum number of concurrent threads to use when compiling device code. If the specified value is
/// ```text
/// 1, the option will be ignored. If the specified value is 0, the number of threads will match the number of CPUs on the underlying
/// machine. Otherwise, if the option is N, then up to N threads will be used. This option is ignored if the env var CUDA_BINARY_LOADER_THREAD_COUNT
/// is set. Option type: unsigned int
/// Applies to: compiler and linker
/// ```
CU_JIT_BINARY_LOADER_THREAD_COUNT = 35,
CU_JIT_NUM_OPTIONS = 36,
}
pub use self::CUjit_option_enum as CUjit_option;
/// Online compilation targets.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUjit_target_enum {
/// Compute device class 3.0.
CU_TARGET_COMPUTE_30 = 30,
/// Compute device class 3.2.
CU_TARGET_COMPUTE_32 = 32,
/// Compute device class 3.5.
CU_TARGET_COMPUTE_35 = 35,
/// Compute device class 3.7.
CU_TARGET_COMPUTE_37 = 37,
/// Compute device class 5.0.
CU_TARGET_COMPUTE_50 = 50,
/// Compute device class 5.2.
CU_TARGET_COMPUTE_52 = 52,
/// Compute device class 5.3.
CU_TARGET_COMPUTE_53 = 53,
/// Compute device class 6.0.
CU_TARGET_COMPUTE_60 = 60,
/// Compute device class 6.1.
CU_TARGET_COMPUTE_61 = 61,
/// Compute device class 6.2.
CU_TARGET_COMPUTE_62 = 62,
/// Compute device class 7.0.
CU_TARGET_COMPUTE_70 = 70,
/// Compute device class 7.2.
CU_TARGET_COMPUTE_72 = 72,
/// Compute device class 7.5.
CU_TARGET_COMPUTE_75 = 75,
/// Compute device class 8.0.
CU_TARGET_COMPUTE_80 = 80,
/// Compute device class 8.6.
CU_TARGET_COMPUTE_86 = 86,
/// Compute device class 8.7.
CU_TARGET_COMPUTE_87 = 87,
/// Compute device class 8.9.
CU_TARGET_COMPUTE_89 = 89,
/// Compute device class 9.0.
CU_TARGET_COMPUTE_90 = 90,
/// Compute device class 10.0.
CU_TARGET_COMPUTE_100 = 100,
/// Compute device class 11.0.
CU_TARGET_COMPUTE_110 = 110,
/// Compute device class 10.3.
CU_TARGET_COMPUTE_103 = 103,
/// Compute device class 12.0.
CU_TARGET_COMPUTE_120 = 120,
/// Compute device class 12.1. Compute device class 9.0. with accelerated features.
CU_TARGET_COMPUTE_121 = 121,
/// Compute device class 10.0. with accelerated features.
CU_TARGET_COMPUTE_90A = 65626,
/// Compute device class 11.0 with accelerated features.
CU_TARGET_COMPUTE_100A = 65636,
/// Compute device class 10.3. with accelerated features.
CU_TARGET_COMPUTE_110A = 65646,
/// Compute device class 12.0. with accelerated features.
CU_TARGET_COMPUTE_103A = 65639,
/// Compute device class 12.1. with accelerated features.
CU_TARGET_COMPUTE_120A = 65656,
/// Compute device class 10.x with family features.
CU_TARGET_COMPUTE_121A = 65657,
/// Compute device class 11.0 with family features.
CU_TARGET_COMPUTE_100F = 131172,
/// Compute device class 10.3. with family features.
CU_TARGET_COMPUTE_110F = 131182,
/// Compute device class 12.0. with family features.
CU_TARGET_COMPUTE_103F = 131175,
/// Compute device class 12.1. with family features.
CU_TARGET_COMPUTE_120F = 131192,
CU_TARGET_COMPUTE_121F = 131193,
}
pub use self::CUjit_target_enum as CUjit_target;
/// Cubin matching fallback strategies.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUjit_fallback_enum {
/// Prefer to compile ptx if exact binary match not found.
CU_PREFER_PTX = 0,
/// Prefer to fall back to compatible binary code if exact match not found.
CU_PREFER_BINARY = 1,
}
pub use self::CUjit_fallback_enum as CUjit_fallback;
/// Caching modes for dlcm.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUjit_cacheMode_enum {
/// Compile with no -dlcm flag specified.
CU_JIT_CACHE_OPTION_NONE = 0,
/// Compile with L1 cache disabled.
CU_JIT_CACHE_OPTION_CG = 1,
/// Compile with L1 cache enabled.
CU_JIT_CACHE_OPTION_CA = 2,
}
pub use self::CUjit_cacheMode_enum as CUjit_cacheMode;
/// Device code formats.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUjitInputType_enum {
/// Compiled device-class-specific device code
/// Applicable options: none.
CU_JIT_INPUT_CUBIN = 0,
/// PTX source code
/// Applicable options: PTX compiler options.
CU_JIT_INPUT_PTX = 1,
/// Bundle of multiple cubins and/or PTX of some device code
/// Applicable options: PTX compiler options, CU_JIT_FALLBACK_STRATEGY.
CU_JIT_INPUT_FATBINARY = 2,
/// Host object with embedded device code
/// Applicable options: PTX compiler options, CU_JIT_FALLBACK_STRATEGY.
CU_JIT_INPUT_OBJECT = 3,
/// Archive of host objects with embedded device code
/// Applicable options: PTX compiler options, CU_JIT_FALLBACK_STRATEGY.
CU_JIT_INPUT_LIBRARY = 4,
/// High-level intermediate code for link-time optimization
/// Applicable options: NVVM compiler options, PTX compiler options
///
/// Only valid with LTO-IR compiled with toolkits prior to CUDA 12.0.
#[deprecated]
CU_JIT_INPUT_NVVM = 5,
CU_JIT_NUM_INPUT_TYPES = 6,
}
pub use self::CUjitInputType_enum as CUjitInputType;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUlinkState_st {
_unused: [u8; 0],
}
pub type CUlinkState = *mut CUlinkState_st;
/// Flags to register a graphics resource.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphicsRegisterFlags_enum {
CU_GRAPHICS_REGISTER_FLAGS_NONE = 0,
CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY = 1,
CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD = 2,
CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST = 4,
CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER = 8,
}
pub use self::CUgraphicsRegisterFlags_enum as CUgraphicsRegisterFlags;
/// Flags for mapping and unmapping interop resources.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphicsMapResourceFlags_enum {
CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = 0,
CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = 1,
CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 2,
}
pub use self::CUgraphicsMapResourceFlags_enum as CUgraphicsMapResourceFlags;
/// Array indices for cube faces.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUarray_cubemap_face_enum {
/// Positive X face of cubemap.
CU_CUBEMAP_FACE_POSITIVE_X = 0,
/// Negative X face of cubemap.
CU_CUBEMAP_FACE_NEGATIVE_X = 1,
/// Positive Y face of cubemap.
CU_CUBEMAP_FACE_POSITIVE_Y = 2,
/// Negative Y face of cubemap.
CU_CUBEMAP_FACE_NEGATIVE_Y = 3,
/// Positive Z face of cubemap.
CU_CUBEMAP_FACE_POSITIVE_Z = 4,
/// Negative Z face of cubemap.
CU_CUBEMAP_FACE_NEGATIVE_Z = 5,
}
pub use self::CUarray_cubemap_face_enum as CUarray_cubemap_face;
/// Limits.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUlimit_enum {
/// GPU thread stack size.
CU_LIMIT_STACK_SIZE = 0,
/// GPU printf FIFO size.
CU_LIMIT_PRINTF_FIFO_SIZE = 1,
/// GPU malloc heap size.
CU_LIMIT_MALLOC_HEAP_SIZE = 2,
/// GPU device runtime launch synchronize depth.
CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH = 3,
/// GPU device runtime pending launch count.
CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT = 4,
/// A value between 0 and 128 that indicates the maximum fetch granularity of L2 (in Bytes). This is a hint.
CU_LIMIT_MAX_L2_FETCH_GRANULARITY = 5,
/// A size in bytes for L2 persisting lines cache size.
CU_LIMIT_PERSISTING_L2_CACHE_SIZE = 6,
/// A maximum size in bytes of shared memory available to CUDA kernels on a CIG context. Can only be queried, cannot be set.
CU_LIMIT_SHMEM_SIZE = 7,
/// A non-zero value indicates this CUDA context is a CIG-enabled context. Can only be queried, cannot be set.
CU_LIMIT_CIG_ENABLED = 8,
/// When set to zero, CUDA will fail to launch a kernel on a CIG context, instead of using the fallback path, if the kernel uses
/// more shared memory than available.
CU_LIMIT_CIG_SHMEM_FALLBACK_ENABLED = 9,
CU_LIMIT_MAX = 10,
}
pub use self::CUlimit_enum as CUlimit;
/// Resource types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUresourcetype_enum {
/// Array resource.
CU_RESOURCE_TYPE_ARRAY = 0,
/// Mipmapped array resource.
CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 1,
/// Linear resource.
CU_RESOURCE_TYPE_LINEAR = 2,
/// Pitch 2D resource.
CU_RESOURCE_TYPE_PITCH2D = 3,
}
pub use self::CUresourcetype_enum as CUresourcetype;
/// CUDA host function.
pub type CUhostFn = ::core::option::Option<
unsafe extern "C" fn(userData: *mut ::core::ffi::c_void),
>;
/// Specifies performance hint with [`CUaccessPolicyWindow`] for hitProp and missProp members.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUaccessProperty_enum {
/// Normal cache persistence.
CU_ACCESS_PROPERTY_NORMAL = 0,
/// Streaming access is less likely to persit from cache.
CU_ACCESS_PROPERTY_STREAMING = 1,
/// Persisting access is more likely to persist in cache.
CU_ACCESS_PROPERTY_PERSISTING = 2,
}
pub use self::CUaccessProperty_enum as CUaccessProperty;
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
pub struct CUaccessPolicyWindow_st {
pub base_ptr: *mut ::core::ffi::c_void,
pub num_bytes: size_t,
pub hitRatio: f32,
pub hitProp: CUaccessProperty,
pub missProp: CUaccessProperty,
}
impl Default for CUaccessPolicyWindow_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Specifies an access policy for a window, a contiguous extent of memory beginning at base_ptr and ending at base_ptr + num_bytes.
/// num_bytes is limited by [`CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAX_ACCESS_POLICY_WINDOW_SIZE`]. Partition into many segments and assign segments
/// such that: sum of "hit segments" / window == approx. ratio. sum of "miss segments" / window == approx 1-ratio. Segments and
/// ratio specifications are fitted to the capabilities of the architecture. Accesses in a hit segment apply the hitProp access
/// policy. Accesses in a miss segment apply the missProp access policy.
pub type CUaccessPolicyWindow_v1 = CUaccessPolicyWindow_st;
/// Access policy window.
pub type CUaccessPolicyWindow = CUaccessPolicyWindow_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_KERNEL_NODE_PARAMS_st {
pub func: CUfunction,
pub gridDimX: ::core::ffi::c_uint,
pub gridDimY: ::core::ffi::c_uint,
pub gridDimZ: ::core::ffi::c_uint,
pub blockDimX: ::core::ffi::c_uint,
pub blockDimY: ::core::ffi::c_uint,
pub blockDimZ: ::core::ffi::c_uint,
pub sharedMemBytes: ::core::ffi::c_uint,
pub kernelParams: *mut *mut ::core::ffi::c_void,
pub extra: *mut *mut ::core::ffi::c_void,
}
impl Default for CUDA_KERNEL_NODE_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// GPU kernel node parameters.
pub type CUDA_KERNEL_NODE_PARAMS_v1 = CUDA_KERNEL_NODE_PARAMS_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_KERNEL_NODE_PARAMS_v2_st {
pub func: CUfunction,
pub gridDimX: ::core::ffi::c_uint,
pub gridDimY: ::core::ffi::c_uint,
pub gridDimZ: ::core::ffi::c_uint,
pub blockDimX: ::core::ffi::c_uint,
pub blockDimY: ::core::ffi::c_uint,
pub blockDimZ: ::core::ffi::c_uint,
pub sharedMemBytes: ::core::ffi::c_uint,
pub kernelParams: *mut *mut ::core::ffi::c_void,
pub extra: *mut *mut ::core::ffi::c_void,
pub kern: CUkernel,
pub ctx: CUcontext,
}
impl Default for CUDA_KERNEL_NODE_PARAMS_v2_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// GPU kernel node parameters.
pub type CUDA_KERNEL_NODE_PARAMS_v2 = CUDA_KERNEL_NODE_PARAMS_v2_st;
pub type CUDA_KERNEL_NODE_PARAMS = CUDA_KERNEL_NODE_PARAMS_v2;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_KERNEL_NODE_PARAMS_v3_st {
pub func: CUfunction,
pub gridDimX: ::core::ffi::c_uint,
pub gridDimY: ::core::ffi::c_uint,
pub gridDimZ: ::core::ffi::c_uint,
pub blockDimX: ::core::ffi::c_uint,
pub blockDimY: ::core::ffi::c_uint,
pub blockDimZ: ::core::ffi::c_uint,
pub sharedMemBytes: ::core::ffi::c_uint,
pub kernelParams: *mut *mut ::core::ffi::c_void,
pub extra: *mut *mut ::core::ffi::c_void,
pub kern: CUkernel,
pub ctx: CUcontext,
}
impl Default for CUDA_KERNEL_NODE_PARAMS_v3_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// GPU kernel node parameters.
pub type CUDA_KERNEL_NODE_PARAMS_v3 = CUDA_KERNEL_NODE_PARAMS_v3_st;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_MEMSET_NODE_PARAMS_st {
pub dst: CUdeviceptr,
pub pitch: size_t,
pub value: ::core::ffi::c_uint,
pub elementSize: ::core::ffi::c_uint,
pub width: size_t,
pub height: size_t,
}
/// Memset node parameters.
pub type CUDA_MEMSET_NODE_PARAMS_v1 = CUDA_MEMSET_NODE_PARAMS_st;
pub type CUDA_MEMSET_NODE_PARAMS = CUDA_MEMSET_NODE_PARAMS_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_MEMSET_NODE_PARAMS_v2_st {
pub dst: CUdeviceptr,
pub pitch: size_t,
pub value: ::core::ffi::c_uint,
pub elementSize: ::core::ffi::c_uint,
pub width: size_t,
pub height: size_t,
pub ctx: CUcontext,
}
impl Default for CUDA_MEMSET_NODE_PARAMS_v2_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Memset node parameters.
pub type CUDA_MEMSET_NODE_PARAMS_v2 = CUDA_MEMSET_NODE_PARAMS_v2_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_HOST_NODE_PARAMS_st {
pub fn_: CUhostFn,
pub userData: *mut ::core::ffi::c_void,
}
impl Default for CUDA_HOST_NODE_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Host node parameters.
pub type CUDA_HOST_NODE_PARAMS_v1 = CUDA_HOST_NODE_PARAMS_st;
pub type CUDA_HOST_NODE_PARAMS = CUDA_HOST_NODE_PARAMS_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_HOST_NODE_PARAMS_v2_st {
pub fn_: CUhostFn,
pub userData: *mut ::core::ffi::c_void,
pub syncMode: ::core::ffi::c_uint,
}
impl Default for CUDA_HOST_NODE_PARAMS_v2_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Host node parameters.
pub type CUDA_HOST_NODE_PARAMS_v2 = CUDA_HOST_NODE_PARAMS_v2_st;
/// Conditional node types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphConditionalNodeType_enum {
/// Conditional 'if/else' Node. Body\[0\] executed if condition is non-zero. If size == 2, an optional ELSE graph is created and this is executed if the condition is zero.
CU_GRAPH_COND_TYPE_IF = 0,
/// Conditional 'while' Node. Body executed repeatedly while condition value is non-zero.
CU_GRAPH_COND_TYPE_WHILE = 1,
/// Conditional 'switch' Node. Body\[n\] is executed once, where 'n' is the value of the condition. If the condition does not match
/// a body index, no body is launched.
CU_GRAPH_COND_TYPE_SWITCH = 2,
}
pub use self::CUgraphConditionalNodeType_enum as CUgraphConditionalNodeType;
/// Conditional node parameters.
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_CONDITIONAL_NODE_PARAMS {
/// Conditional node handle. Handles must be created in advance of creating the node using [`cuGraphConditionalHandleCreate`].
pub handle: CUgraphConditionalHandle,
pub type_: CUgraphConditionalNodeType,
/// Size of graph output array. Allowed values are 1 for [`CUgraphConditionalNodeType::CU_GRAPH_COND_TYPE_WHILE`], 1 or 2 for [`CUgraphConditionalNodeType::CU_GRAPH_COND_TYPE_IF`], or any value
/// greater than zero for [`CUgraphConditionalNodeType::CU_GRAPH_COND_TYPE_SWITCH`].
pub size: ::core::ffi::c_uint,
/// CUDA-owned array populated with conditional node child graphs during creation of the node. Valid for the lifetime of the
/// conditional node. The contents of the graph(s) are subject to the following constraints:
///
/// * Allowed node types are kernel nodes, empty nodes, child graphs, memsets, memcopies, and conditionals. This applies recursively
/// to child graphs and conditional bodies.
/// * All kernels, including kernels in nested conditionals or child graphs at any level, must belong to the same CUDA context.
///
/// These graphs may be populated using graph node creation APIs or [`cuStreamBeginCaptureToGraph`].
///
/// [`CUgraphConditionalNodeType::CU_GRAPH_COND_TYPE_IF`]: phGraph_out\[0\] is executed when the condition is non-zero. If size == 2, phGraph_out\[1\] will be executed when the condition is zero. [`CUgraphConditionalNodeType::CU_GRAPH_COND_TYPE_WHILE`]: phGraph_out\[0\] is executed as
/// long as the condition is non-zero. [`CUgraphConditionalNodeType::CU_GRAPH_COND_TYPE_SWITCH`]: phGraph_out\[n\] is executed when the condition is equal to n.
/// If the condition >= size, no body graph is executed.
pub phGraph_out: *mut CUgraph,
/// Context on which to run the node. Must match context used to create the handle and all body nodes.
pub ctx: CUcontext,
}
impl Default for CUDA_CONDITIONAL_NODE_PARAMS {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Graph node types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphNodeType_enum {
/// GPU kernel node.
CU_GRAPH_NODE_TYPE_KERNEL = 0,
/// Memcpy node.
CU_GRAPH_NODE_TYPE_MEMCPY = 1,
/// Memset node.
CU_GRAPH_NODE_TYPE_MEMSET = 2,
/// Host (executable) node.
CU_GRAPH_NODE_TYPE_HOST = 3,
/// Node which executes an embedded graph.
CU_GRAPH_NODE_TYPE_GRAPH = 4,
/// Empty (no-op) node.
CU_GRAPH_NODE_TYPE_EMPTY = 5,
/// External event wait node.
CU_GRAPH_NODE_TYPE_WAIT_EVENT = 6,
/// External event record node.
CU_GRAPH_NODE_TYPE_EVENT_RECORD = 7,
/// External semaphore signal node.
CU_GRAPH_NODE_TYPE_EXT_SEMAS_SIGNAL = 8,
/// External semaphore wait node.
CU_GRAPH_NODE_TYPE_EXT_SEMAS_WAIT = 9,
/// Memory Allocation Node.
CU_GRAPH_NODE_TYPE_MEM_ALLOC = 10,
/// Memory Free Node.
CU_GRAPH_NODE_TYPE_MEM_FREE = 11,
/// Batch MemOp Node See [`cuStreamBatchMemOp_v2`] and `CUstreamBatchMemOpType` for what these nodes can do.
CU_GRAPH_NODE_TYPE_BATCH_MEM_OP = 12,
/// Conditional NodeMay be used to implement a conditional execution path or loop inside of a graph. The graph(s) contained within
/// the body of the conditional node can be selectively executed or iterated upon based on the value of a conditional variable.Handles
/// must be created in advance of creating the node using [`cuGraphConditionalHandleCreate`].The following restrictions apply to graphs which contain conditional nodes: The graph cannot be used in a child node. Only
/// one instantiation of the graph may exist at any point in time. The graph cannot be cloned.To set the control value, supply
/// a default value when creating the handle and/or call [cudaGraphSetConditional](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1gde392fa316b963233219ab3caac9f1b3) from device code.
CU_GRAPH_NODE_TYPE_CONDITIONAL = 13,
}
pub use self::CUgraphNodeType_enum as CUgraphNodeType;
/// Type annotations that can be applied to graph edges as part of [`CUgraphEdgeData`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphDependencyType_enum {
/// This is an ordinary dependency.
CU_GRAPH_DEPENDENCY_TYPE_DEFAULT = 0,
/// This dependency type allows the downstream node to use <cudaGridDependencySynchronize()>. It may only be used between kernel nodes, and must be used with either the [`CU_GRAPH_KERNEL_NODE_PORT_PROGRAMMATIC`] or [`CU_GRAPH_KERNEL_NODE_PORT_LAUNCH_ORDER`] outgoing port.
CU_GRAPH_DEPENDENCY_TYPE_PROGRAMMATIC = 1,
}
pub use self::CUgraphDependencyType_enum as CUgraphDependencyType;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUgraphEdgeData_st {
pub from_port: ::core::ffi::c_uchar,
pub to_port: ::core::ffi::c_uchar,
pub type_: ::core::ffi::c_uchar,
pub reserved: [::core::ffi::c_uchar; 5usize],
}
/// Optional annotation for edges in a CUDA graph. Note, all edges implicitly have annotations and default to a zero-initialized
/// value if not specified. A zero-initialized struct indicates a standard full serialization of two nodes with memory visibility.
pub type CUgraphEdgeData = CUgraphEdgeData_st;
/// Graph instantiation results.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphInstantiateResult_enum {
/// Instantiation succeeded.
CUDA_GRAPH_INSTANTIATE_SUCCESS = 0,
/// Instantiation failed for an unexpected reason which is described in the return value of the function.
CUDA_GRAPH_INSTANTIATE_ERROR = 1,
/// Instantiation failed due to invalid structure, such as cycles.
CUDA_GRAPH_INSTANTIATE_INVALID_STRUCTURE = 2,
/// Instantiation for device launch failed because the graph contained an unsupported operation.
CUDA_GRAPH_INSTANTIATE_NODE_OPERATION_NOT_SUPPORTED = 3,
/// Instantiation for device launch failed due to the nodes belonging to different contexts.
CUDA_GRAPH_INSTANTIATE_MULTIPLE_CTXS_NOT_SUPPORTED = 4,
/// One or more conditional handles are not associated with conditional nodes.
CUDA_GRAPH_INSTANTIATE_CONDITIONAL_HANDLE_UNUSED = 5,
}
pub use self::CUgraphInstantiateResult_enum as CUgraphInstantiateResult;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_GRAPH_INSTANTIATE_PARAMS_st {
pub flags: cuuint64_t,
pub hUploadStream: CUstream,
pub hErrNode_out: CUgraphNode,
pub result_out: CUgraphInstantiateResult,
}
impl Default for CUDA_GRAPH_INSTANTIATE_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Graph instantiation parameters.
pub type CUDA_GRAPH_INSTANTIATE_PARAMS = CUDA_GRAPH_INSTANTIATE_PARAMS_st;
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUsynchronizationPolicy_enum {
CU_SYNC_POLICY_AUTO = 1,
CU_SYNC_POLICY_SPIN = 2,
CU_SYNC_POLICY_YIELD = 3,
CU_SYNC_POLICY_BLOCKING_SYNC = 4,
}
pub use self::CUsynchronizationPolicy_enum as CUsynchronizationPolicy;
/// Cluster scheduling policies. These may be passed to [`cuFuncSetAttribute`] or [`cuKernelSetAttribute`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUclusterSchedulingPolicy_enum {
/// the default policy.
CU_CLUSTER_SCHEDULING_POLICY_DEFAULT = 0,
/// spread the blocks within a cluster to the SMs.
CU_CLUSTER_SCHEDULING_POLICY_SPREAD = 1,
/// allow the hardware to load-balance the blocks in a cluster to the SMs.
CU_CLUSTER_SCHEDULING_POLICY_LOAD_BALANCING = 2,
}
pub use self::CUclusterSchedulingPolicy_enum as CUclusterSchedulingPolicy;
/// Memory Synchronization Domain
///
/// A kernel can be launched in a specified memory synchronization domain that affects all memory operations issued by that kernel.
/// A memory barrier issued in one domain will only order memory operations in that domain, thus eliminating latency increase
/// from memory barriers ordering unrelated traffic.
///
/// By default, kernels are launched in domain 0. Kernel launched with CU_LAUNCH_MEM_SYNC_DOMAIN_REMOTE will have a different domain ID. User may also alter the domain ID with [`CUlaunchMemSyncDomainMap`] for a specific stream / graph node / kernel launch. See CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN, [`cuStreamSetAttribute`], [`cuLaunchKernelEx`], [`cuGraphKernelNodeSetAttribute`].
///
/// Memory operations done in kernels launched in different domains are considered system-scope distanced. In other words, a GPU
/// scoped memory synchronization is not sufficient for memory order to be observed by kernels in another memory synchronization
/// domain even if they are on the same GPU.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUlaunchMemSyncDomain_enum {
/// Launch kernels in the default domain.
CU_LAUNCH_MEM_SYNC_DOMAIN_DEFAULT = 0,
/// Launch kernels in the remote domain.
CU_LAUNCH_MEM_SYNC_DOMAIN_REMOTE = 1,
}
pub use self::CUlaunchMemSyncDomain_enum as CUlaunchMemSyncDomain;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUlaunchMemSyncDomainMap_st {
pub default_: ::core::ffi::c_uchar,
pub remote: ::core::ffi::c_uchar,
}
/// Memory Synchronization Domain map
///
/// See [cudaLaunchMemSyncDomain](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1gafb98f7ea7b0397ed6503780f3e672d5).
///
/// By default, kernels are launched in domain 0. Kernel launched with [`CUlaunchMemSyncDomain_enum::CU_LAUNCH_MEM_SYNC_DOMAIN_REMOTE`] will have a different domain ID. User may also alter the domain ID with [`CUlaunchMemSyncDomainMap`] for a specific stream / graph node / kernel launch. See [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP`].
///
/// Domain ID range is available through [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MEM_SYNC_DOMAIN_COUNT`].
pub type CUlaunchMemSyncDomainMap = CUlaunchMemSyncDomainMap_st;
/// Enum for defining applicability of portable cluster size, used with [`cuLaunchKernelEx`].
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUlaunchAttributePortableClusterMode_enum {
/// The default to use for allowing non-portable cluster size on launch - uses current function attribute for CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED.
CU_LAUNCH_PORTABLE_CLUSTER_MODE_DEFAULT = 0,
/// Specifies that the cluster size requested must be a portable size.
CU_LAUNCH_PORTABLE_CLUSTER_MODE_REQUIRE_PORTABLE = 1,
/// Specifies that the cluster size requested may be a non-portable size.
CU_LAUNCH_PORTABLE_CLUSTER_MODE_ALLOW_NON_PORTABLE = 2,
}
pub use self::CUlaunchAttributePortableClusterMode_enum as CUlaunchAttributePortableClusterMode;
/// Shared memory related attributes for use with [`cuLaunchKernelEx`].
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUsharedMemoryMode_enum {
/// The default to use for shared memory on launch - uses current function attribute for CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES.
CU_SHARED_MEMORY_MODE_DEFAULT = 0,
/// Specifies that the dynamic shared size bytes requested must be a portable size within the bounds of CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK.
CU_SHARED_MEMORY_MODE_REQUIRE_PORTABLE = 1,
/// Specifies that the dynamic shared size bytes requested may be a non-portable size but still within the bounds of CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN.
CU_SHARED_MEMORY_MODE_ALLOW_NON_PORTABLE = 2,
}
pub use self::CUsharedMemoryMode_enum as CUsharedMemoryMode;
/// Launch attributes enum; used as id field of [`CUlaunchAttribute`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUlaunchAttributeID_enum {
/// Ignored entry, for convenient composition.
CU_LAUNCH_ATTRIBUTE_IGNORE = 0,
/// Valid for streams, graph nodes, launches. See [CUlaunchAttributeValue::accessPolicyWindow](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_1154aa6110d2610fb68ec60bc9337073b).
CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW = 1,
/// Valid for graph nodes, launches. See [CUlaunchAttributeValue::cooperative](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_13015f3dc785dce3a2c250b852457082a).
CU_LAUNCH_ATTRIBUTE_COOPERATIVE = 2,
/// Valid for streams. See [CUlaunchAttributeValue::syncPolicy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_1bfc7b2566d09fbd679636513d5c07cd8).
CU_LAUNCH_ATTRIBUTE_SYNCHRONIZATION_POLICY = 3,
/// Valid for graph nodes, launches. See [CUlaunchAttributeValue::clusterDim](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_171f9182ab9f932025a038def93ce1a94).
CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION = 4,
/// Valid for graph nodes, launches. See [CUlaunchAttributeValue::clusterSchedulingPolicyPreference](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_1714fd4571d6ef99a53a20d378eebb2ba).
CU_LAUNCH_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE = 5,
/// Valid for launches. Setting [CUlaunchAttributeValue::programmaticStreamSerializationAllowed](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_121590ca9c3de21690d12d9c7f73917ab) to non-0 signals that the kernel will use programmatic means to resolve its stream dependency, so that the CUDA runtime should
/// opportunistically allow the grid's execution to overlap with the previous kernel in the stream, if that kernel requests the
/// overlap. The dependent launches can choose to wait on the dependency using the programmatic sync ([cudaGridDependencySynchronize()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EXECUTION.html#group__CUDART__EXECUTION_1g9057f99234a8311c4c5d426cd501d99d) or equivalent PTX instructions).
CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION = 6,
/// Valid for launches. Set [CUlaunchAttributeValue::programmaticEvent](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_149992756050c46d440486034949a2c0c) to record the event. Event recorded through this launch attribute is guaranteed to only trigger after all block in the associated
/// kernel trigger the event. A block can trigger the event through PTX launchdep.release or CUDA builtin function [cudaTriggerProgrammaticLaunchCompletion()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EXECUTION.html#group__CUDART__EXECUTION_1ge194af462d927583bed3acf60d450218). A trigger can also be inserted at the beginning of each block's execution if triggerAtBlockStart is set to non-0. The dependent
/// launches can choose to wait on the dependency using the programmatic sync ([cudaGridDependencySynchronize()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EXECUTION.html#group__CUDART__EXECUTION_1g9057f99234a8311c4c5d426cd501d99d) or equivalent PTX instructions). Note that dependents (including the CPU thread calling [`cuEventSynchronize`]) are not guaranteed to observe the release precisely when it is released. For example, [`cuEventSynchronize`] may only observe the event trigger long after the associated kernel has completed. This recording type is primarily meant
/// for establishing programmatic dependency between device tasks. Note also this type of dependency allows, but does not guarantee,
/// concurrent execution of tasks.
/// The event supplied must not be an interprocess or interop event. The event must disable timing (i.e. must be created with
/// the CU_EVENT_DISABLE_TIMING flag set).
CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT = 7,
/// Valid for streams, graph nodes, launches. See [CUlaunchAttributeValue::priority](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_18b3a370124a50866fcdb1c9cb5580e96).
CU_LAUNCH_ATTRIBUTE_PRIORITY = 8,
/// Valid for streams, graph nodes, launches. See [CUlaunchAttributeValue::memSyncDomainMap](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_134552cdc66a0a5373d8515108d9c63d6).
CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP = 9,
/// Valid for streams, graph nodes, launches. See [CUlaunchAttributeValue::memSyncDomain](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_168b8301d88ce5c6e69fc5f08734e55a8).
CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN = 10,
/// Valid for graph nodes, launches. Set [CUlaunchAttributeValue::preferredClusterDim](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_12e4405d769d2302fd8d0f9b7764f3cb3) to allow the kernel launch to specify a preferred substitute cluster dimension. Blocks may be grouped according to either
/// the dimensions specified with this attribute (grouped into a "preferred substitute cluster"), or the one specified with CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION attribute (grouped into a "regular cluster"). The cluster dimensions of a "preferred substitute cluster" shall be an integer
/// multiple greater than zero of the regular cluster dimensions. The device will attempt - on a best-effort basis - to group
/// thread blocks into preferred clusters over grouping them into regular clusters. When it deems necessary (primarily when the
/// device temporarily runs out of physical resources to launch the larger preferred clusters), the device may switch to launch
/// the regular clusters instead to attempt to utilize as much of the physical device resources as possible.
/// Each type of cluster will have its enumeration / coordinate setup as if the grid consists solely of its type of cluster. For
/// example, if the preferred substitute cluster dimensions double the regular cluster dimensions, there might be simultaneously
/// a regular cluster indexed at (1,0,0), and a preferred cluster indexed at (1,0,0). In this example, the preferred substitute
/// cluster (1,0,0) replaces regular clusters (2,0,0) and (3,0,0) and groups their blocks.
/// This attribute will only take effect when a regular cluster dimension has been specified. The preferred substitute cluster
/// dimension must be an integer multiple greater than zero of the regular cluster dimension and must divide the grid. It must
/// also be no more than `maxBlocksPerCluster`, if it is set in the kernel's `__launch_bounds__`. Otherwise it must be less than
/// the maximum value the driver can support. Otherwise, setting this attribute to a value physically unable to fit on any particular
/// device is permitted.
CU_LAUNCH_ATTRIBUTE_PREFERRED_CLUSTER_DIMENSION = 11,
/// Valid for launches. Set [CUlaunchAttributeValue::launchCompletionEvent](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_1af92a022a05eba8d91f8c6b39c8d3db2) to record the event.
/// Nominally, the event is triggered once all blocks of the kernel have begun execution. Currently this is a best effort. If
/// a kernel B has a launch completion dependency on a kernel A, B may wait until A is complete. Alternatively, blocks of B may
/// begin before all blocks of A have begun, for example if B can claim execution resources unavailable to A (e.g. they run on
/// different GPUs) or if B is a higher priority than A. Exercise caution if such an ordering inversion could lead to deadlock.
/// A launch completion event is nominally similar to a programmatic event with triggerAtBlockStart set except that it is not visible to <cudaGridDependencySynchronize()> and can be used with compute capability less than 9.0.
/// The event supplied must not be an interprocess or interop event. The event must disable timing (i.e. must be created with
/// the CU_EVENT_DISABLE_TIMING flag set).
CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT = 12,
/// Valid for graph nodes, launches. This attribute is graphs-only, and passing it to a launch in a non-capturing stream will
/// result in an error.
/// CUlaunchAttributeValue::deviceUpdatableKernelNode::deviceUpdatable can only be set to 0 or 1. Setting the field to 1 indicates
/// that the corresponding kernel node should be device-updatable. On success, a handle will be returned via CUlaunchAttributeValue::deviceUpdatableKernelNode::devNode
/// which can be passed to the various device-side update functions to update the node's kernel parameters from within another
/// kernel. For more information on the types of device updates that can be made, as well as the relevant limitations thereof,
/// see [cudaGraphKernelNodeUpdatesApply](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g2d558cf37c9616365c67447e61ac0d6a).
/// Nodes which are device-updatable have additional restrictions compared to regular kernel nodes. Firstly, device-updatable
/// nodes cannot be removed from their graph via [`cuGraphDestroyNode`]. Additionally, once opted-in to this functionality, a node cannot opt out, and any attempt to set the deviceUpdatable attribute
/// to 0 will result in an error. Device-updatable kernel nodes also cannot have their attributes copied to/from another kernel
/// node via [`cuGraphKernelNodeCopyAttributes`]. Graphs containing one or more device-updatable nodes also do not allow multiple instantiation, and neither the graph nor
/// its instantiated version can be passed to [`cuGraphExecUpdate_v2`].
/// If a graph contains device-updatable nodes and updates those nodes from the device from within the graph, the graph must be
/// uploaded with [`cuGraphUpload`] before it is launched. For such a graph, if host-side executable graph updates are made to the device-updatable nodes, the
/// graph must be uploaded before it is launched again.
CU_LAUNCH_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE = 13,
/// Valid for launches. On devices where the L1 cache and shared memory use the same hardware resources, setting [CUlaunchAttributeValue::sharedMemCarveout](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_1b4890866538ded7d27e648d399caaff2) to a percentage between 0-100 signals the CUDA driver to set the shared memory carveout preference, in percent of the total
/// shared memory for that kernel launch. This attribute takes precedence over CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT. This is only a hint, and the CUDA driver can choose a different configuration if required for the launch.
CU_LAUNCH_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT = 14,
/// Valid for streams, graph nodes, launches. This attribute is a hint to the CUDA runtime that the launch should attempt to make
/// the kernel maximize its NVLINK utilization.
/// When possible to honor this hint, CUDA will assume each block in the grid launch will carry out an even amount of NVLINK traffic,
/// and make a best-effort attempt to adjust the kernel launch based on that assumption.
/// This attribute is a hint only. CUDA makes no functional or performance guarantee. Its applicability can be affected by many
/// different factors, including driver version (i.e. CUDA doesn't guarantee the performance characteristics will be maintained
/// between driver versions or a driver update could alter or regress previously observed perf characteristics.) It also doesn't
/// guarantee a successful result, i.e. applying the attribute may not improve the performance of either the targeted kernel or
/// the encapsulating application.
/// Valid values for CUlaunchAttributeValue::nvlinkUtilCentricScheduling are 0 (disabled) and 1 (enabled).
CU_LAUNCH_ATTRIBUTE_NVLINK_UTIL_CENTRIC_SCHEDULING = 16,
/// Valid for graph nodes, launches. This controls whether the kernel launch is allowed to use a non-portable cluster size. Valid
/// values for [CUlaunchAttributeValue::portableClusterSizeMode](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unionCUlaunchAttributeValue.html#unionCUlaunchAttributeValue_1b59ceb6906a7de4ce07de5f2269d18b3) are described in `CUlaunchAttributePortableClusterMode`. Any other value will return CUDA_ERROR_INVALID_VALUE.
CU_LAUNCH_ATTRIBUTE_PORTABLE_CLUSTER_SIZE_MODE = 17,
/// Valid for graph nodes, launches. This indicates if the kernel is allowed to use a non-portable dynamic shared memory mode.
CU_LAUNCH_ATTRIBUTE_SHARED_MEMORY_MODE = 18,
}
pub use self::CUlaunchAttributeID_enum as CUlaunchAttributeID;
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUlaunchAttributeValue_union {
pub pad: [::core::ffi::c_char; 64usize],
pub accessPolicyWindow: CUaccessPolicyWindow,
pub cooperative: ::core::ffi::c_int,
pub syncPolicy: CUsynchronizationPolicy,
pub clusterDim: CUlaunchAttributeValue_union__bindgen_ty_1,
pub clusterSchedulingPolicyPreference: CUclusterSchedulingPolicy,
pub programmaticStreamSerializationAllowed: ::core::ffi::c_int,
pub programmaticEvent: CUlaunchAttributeValue_union__bindgen_ty_2,
pub launchCompletionEvent: CUlaunchAttributeValue_union__bindgen_ty_3,
pub priority: ::core::ffi::c_int,
pub memSyncDomainMap: CUlaunchMemSyncDomainMap,
pub memSyncDomain: CUlaunchMemSyncDomain,
pub preferredClusterDim: CUlaunchAttributeValue_union__bindgen_ty_4,
pub deviceUpdatableKernelNode: CUlaunchAttributeValue_union__bindgen_ty_5,
pub sharedMemCarveout: ::core::ffi::c_uint,
pub nvlinkUtilCentricScheduling: ::core::ffi::c_uint,
pub portableClusterSizeMode: CUlaunchAttributePortableClusterMode,
pub sharedMemoryMode: CUsharedMemoryMode,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUlaunchAttributeValue_union__bindgen_ty_1 {
pub x: ::core::ffi::c_uint,
pub y: ::core::ffi::c_uint,
pub z: ::core::ffi::c_uint,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUlaunchAttributeValue_union__bindgen_ty_2 {
pub event: CUevent,
pub flags: ::core::ffi::c_int,
pub triggerAtBlockStart: ::core::ffi::c_int,
}
impl Default for CUlaunchAttributeValue_union__bindgen_ty_2 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUlaunchAttributeValue_union__bindgen_ty_3 {
pub event: CUevent,
pub flags: ::core::ffi::c_int,
}
impl Default for CUlaunchAttributeValue_union__bindgen_ty_3 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUlaunchAttributeValue_union__bindgen_ty_4 {
pub x: ::core::ffi::c_uint,
pub y: ::core::ffi::c_uint,
pub z: ::core::ffi::c_uint,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUlaunchAttributeValue_union__bindgen_ty_5 {
pub deviceUpdatable: ::core::ffi::c_int,
pub devNode: CUgraphDeviceNode,
}
impl Default for CUlaunchAttributeValue_union__bindgen_ty_5 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUlaunchAttributeValue_union {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Launch attributes union; used as value field of [`CUlaunchAttribute`].
pub type CUlaunchAttributeValue = CUlaunchAttributeValue_union;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUlaunchAttribute_st {
pub id: CUlaunchAttributeID,
pub pad: [::core::ffi::c_char; 4usize],
pub value: CUlaunchAttributeValue,
}
impl Default for CUlaunchAttribute_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Launch attribute.
pub type CUlaunchAttribute = CUlaunchAttribute_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUlaunchConfig_st {
pub gridDimX: ::core::ffi::c_uint,
pub gridDimY: ::core::ffi::c_uint,
pub gridDimZ: ::core::ffi::c_uint,
pub blockDimX: ::core::ffi::c_uint,
pub blockDimY: ::core::ffi::c_uint,
pub blockDimZ: ::core::ffi::c_uint,
pub sharedMemBytes: ::core::ffi::c_uint,
pub hStream: CUstream,
pub attrs: *mut CUlaunchAttribute,
pub numAttrs: ::core::ffi::c_uint,
}
impl Default for CUlaunchConfig_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// CUDA extensible launch configuration.
pub type CUlaunchConfig = CUlaunchConfig_st;
pub use self::CUlaunchAttributeID as CUkernelNodeAttrID;
pub type CUkernelNodeAttrValue_v1 = CUlaunchAttributeValue;
pub type CUkernelNodeAttrValue = CUkernelNodeAttrValue_v1;
/// Possible stream capture statuses returned by [`cuStreamIsCapturing`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUstreamCaptureStatus_enum {
/// Stream is not capturing.
CU_STREAM_CAPTURE_STATUS_NONE = 0,
/// Stream is actively capturing.
CU_STREAM_CAPTURE_STATUS_ACTIVE = 1,
/// Stream is part of a capture sequence that has been invalidated, but not terminated.
CU_STREAM_CAPTURE_STATUS_INVALIDATED = 2,
}
pub use self::CUstreamCaptureStatus_enum as CUstreamCaptureStatus;
/// Possible modes for stream capture thread interactions. For more details see [`cuStreamBeginCapture_v2`] and [`cuThreadExchangeStreamCaptureMode`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUstreamCaptureMode_enum {
CU_STREAM_CAPTURE_MODE_GLOBAL = 0,
CU_STREAM_CAPTURE_MODE_THREAD_LOCAL = 1,
CU_STREAM_CAPTURE_MODE_RELAXED = 2,
}
pub use self::CUlaunchAttributeID as CUstreamAttrID;
pub use self::CUstreamCaptureMode_enum as CUstreamCaptureMode;
pub type CUstreamAttrValue_v1 = CUlaunchAttributeValue;
pub type CUstreamAttrValue = CUstreamAttrValue_v1;
/// Flags to specify search options. For more details see [`cuGetProcAddress_v2`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUdriverProcAddress_flags_enum {
/// Default search mode for driver symbols.
CU_GET_PROC_ADDRESS_DEFAULT = 0,
/// Search for legacy versions of driver symbols.
CU_GET_PROC_ADDRESS_LEGACY_STREAM = 1,
/// Search for per-thread versions of driver symbols.
CU_GET_PROC_ADDRESS_PER_THREAD_DEFAULT_STREAM = 2,
}
pub use self::CUdriverProcAddress_flags_enum as CUdriverProcAddress_flags;
/// Flags to indicate search status. For more details see [`cuGetProcAddress_v2`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUdriverProcAddressQueryResult_enum {
/// Symbol was succesfully found.
CU_GET_PROC_ADDRESS_SUCCESS = 0,
/// Symbol was not found in search.
CU_GET_PROC_ADDRESS_SYMBOL_NOT_FOUND = 1,
/// Symbol was found but version supplied was not sufficient.
CU_GET_PROC_ADDRESS_VERSION_NOT_SUFFICIENT = 2,
}
pub use self::CUdriverProcAddressQueryResult_enum as CUdriverProcAddressQueryResult;
/// Execution Affinity Types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUexecAffinityType_enum {
/// Create a context with limited SMs.
CU_EXEC_AFFINITY_TYPE_SM_COUNT = 0,
CU_EXEC_AFFINITY_TYPE_MAX = 1,
}
pub use self::CUexecAffinityType_enum as CUexecAffinityType;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUexecAffinitySmCount_st {
pub val: ::core::ffi::c_uint,
}
/// Value for [`CUexecAffinityType_enum::CU_EXEC_AFFINITY_TYPE_SM_COUNT`].
pub type CUexecAffinitySmCount_v1 = CUexecAffinitySmCount_st;
pub type CUexecAffinitySmCount = CUexecAffinitySmCount_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUexecAffinityParam_st {
pub type_: CUexecAffinityType,
pub param: CUexecAffinityParam_st__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUexecAffinityParam_st__bindgen_ty_1 {
pub smCount: CUexecAffinitySmCount,
}
impl Default for CUexecAffinityParam_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUexecAffinityParam_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Execution Affinity Parameters.
pub type CUexecAffinityParam_v1 = CUexecAffinityParam_st;
/// Execution Affinity Parameters.
pub type CUexecAffinityParam = CUexecAffinityParam_v1;
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUcigDataType_enum {
CIG_DATA_TYPE_D3D12_COMMAND_QUEUE = 1,
CIG_DATA_TYPE_NV_BLOB = 2,
}
pub use self::CUcigDataType_enum as CUcigDataType;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUctxCigParam_st {
pub sharedDataType: CUcigDataType,
pub sharedData: *mut ::core::ffi::c_void,
}
impl Default for CUctxCigParam_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// CIG Context Create Params.
pub type CUctxCigParam = CUctxCigParam_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUctxCreateParams_st {
pub execAffinityParams: *mut CUexecAffinityParam,
pub numExecAffinityParams: ::core::ffi::c_int,
pub cigParams: *mut CUctxCigParam,
}
impl Default for CUctxCreateParams_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Params for creating CUDA context. Both execAffinityParams and cigParams cannot be non-NULL at the same time. If both are NULL,
/// the context will be created as a regular CUDA context.
pub type CUctxCreateParams = CUctxCreateParams_st;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUstreamCigDataType_enum {
STREAM_CIG_DATA_TYPE_D3D12_COMMAND_LIST = 1,
}
pub use self::CUstreamCigDataType_enum as CUstreamCigDataType;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUstreamCigParam_st {
pub streamSharedDataType: CUstreamCigDataType,
pub streamSharedData: *mut ::core::ffi::c_void,
}
impl Default for CUstreamCigParam_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub type CUstreamCigParam = CUstreamCigParam_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUstreamCigCaptureParams_st {
pub streamCigParams: *mut CUstreamCigParam,
}
impl Default for CUstreamCigCaptureParams_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub type CUstreamCigCaptureParams = CUstreamCigCaptureParams_st;
/// Library options to be specified with [`cuLibraryLoadData`] or [`cuLibraryLoadFromFile`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUlibraryOption_enum {
CU_LIBRARY_HOST_UNIVERSAL_FUNCTION_AND_DATA_TABLE = 0,
/// Specifes that the argument code passed to [`cuLibraryLoadData`] will be preserved. Specifying this option will let the driver know that code can be accessed at any point until [`cuLibraryUnload`]. The default behavior is for the driver to allocate and maintain its own copy of code. Note that this is only a memory usage optimization hint and the driver can choose to ignore it if required. Specifying this
/// option with [`cuLibraryLoadFromFile`] is invalid and will return CUDA_ERROR_INVALID_VALUE.
CU_LIBRARY_BINARY_IS_PRESERVED = 1,
CU_LIBRARY_NUM_OPTIONS = 2,
}
pub use self::CUlibraryOption_enum as CUlibraryOption;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUlibraryHostUniversalFunctionAndDataTable_st {
pub functionTable: *mut ::core::ffi::c_void,
pub functionWindowSize: size_t,
pub dataTable: *mut ::core::ffi::c_void,
pub dataWindowSize: size_t,
}
impl Default for CUlibraryHostUniversalFunctionAndDataTable_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub type CUlibraryHostUniversalFunctionAndDataTable = CUlibraryHostUniversalFunctionAndDataTable_st;
/// Error codes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum cudaError_enum {
/// The API call returned with no errors. In the case of query calls, this also means that the operation being queried is complete
/// (see [`cuEventQuery`] and [`cuStreamQuery`]).
CUDA_SUCCESS = 0,
/// This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values.
CUDA_ERROR_INVALID_VALUE = 1,
/// The API call failed because it was unable to allocate enough memory or other resources to perform the requested operation.
CUDA_ERROR_OUT_OF_MEMORY = 2,
/// This indicates that the CUDA driver has not been initialized with [`cuInit`] has not been called, any function from the driver API will return [`CUresult::CUDA_ERROR_NOT_INITIALIZED`].") or that initialization has failed.
CUDA_ERROR_NOT_INITIALIZED = 3,
/// This indicates that the CUDA driver is in the process of shutting down.
CUDA_ERROR_DEINITIALIZED = 4,
/// This indicates profiler is not initialized for this run. This can happen when the application is running with external profiling
/// tools like visual profiler.
CUDA_ERROR_PROFILER_DISABLED = 5,
#[deprecated]
CUDA_ERROR_PROFILER_NOT_INITIALIZED = 6,
#[deprecated]
CUDA_ERROR_PROFILER_ALREADY_STARTED = 7,
#[deprecated]
CUDA_ERROR_PROFILER_ALREADY_STOPPED = 8,
/// This indicates that the CUDA driver that the application has loaded is a stub library. Applications that run with the stub
/// rather than a real driver loaded will result in CUDA API returning this error.
CUDA_ERROR_STUB_LIBRARY = 34,
/// This indicates that the API call requires a newer CUDA driver than the one currently installed. Users should install an updated
/// NVIDIA CUDA driver to allow the API call to succeed.
CUDA_ERROR_CALL_REQUIRES_NEWER_DRIVER = 36,
/// This indicates that requested CUDA device is unavailable at the current time. Devices are often unavailable due to use of
/// CU_COMPUTEMODE_EXCLUSIVE_PROCESS or CU_COMPUTEMODE_PROHIBITED.
CUDA_ERROR_DEVICE_UNAVAILABLE = 46,
/// This indicates that no CUDA-capable devices were detected by the installed CUDA driver.
CUDA_ERROR_NO_DEVICE = 100,
/// This indicates that the device ordinal supplied by the user does not correspond to a valid CUDA device or that the action
/// requested is invalid for the specified device.
CUDA_ERROR_INVALID_DEVICE = 101,
/// This error indicates that the Grid license is not applied.
CUDA_ERROR_DEVICE_NOT_LICENSED = 102,
/// This indicates that the device kernel image is invalid. This can also indicate an invalid CUDA module.
CUDA_ERROR_INVALID_IMAGE = 200,
/// This most frequently indicates that there is no context bound to the current thread. This can also be returned if the context
/// passed to an API call is not a valid handle (such as a context that has had [`cuCtxDestroy_v2`] invoked on it). This can also be returned if a user mixes different API versions (i.e. 3010 context with 3020 API calls).
/// See [`cuCtxGetApiVersion`] for more details. This can also be returned if the green context passed to an API call was not converted to a [`CUcontext`] using [`cuCtxFromGreenCtx`] API.
CUDA_ERROR_INVALID_CONTEXT = 201,
/// This indicated that the context being supplied as a parameter to the API call was already the active context.
#[deprecated]
CUDA_ERROR_CONTEXT_ALREADY_CURRENT = 202,
/// This indicates that a map or register operation has failed.
CUDA_ERROR_MAP_FAILED = 205,
/// This indicates that an unmap or unregister operation has failed.
CUDA_ERROR_UNMAP_FAILED = 206,
/// This indicates that the specified array is currently mapped and thus cannot be destroyed.
CUDA_ERROR_ARRAY_IS_MAPPED = 207,
/// This indicates that the resource is already mapped.
CUDA_ERROR_ALREADY_MAPPED = 208,
/// This indicates that there is no kernel image available that is suitable for the device. This can occur when a user specifies
/// code generation options for a particular CUDA source file that do not include the corresponding device configuration.
CUDA_ERROR_NO_BINARY_FOR_GPU = 209,
/// This indicates that a resource has already been acquired.
CUDA_ERROR_ALREADY_ACQUIRED = 210,
/// This indicates that a resource is not mapped.
CUDA_ERROR_NOT_MAPPED = 211,
/// This indicates that a mapped resource is not available for access as an array.
CUDA_ERROR_NOT_MAPPED_AS_ARRAY = 212,
/// This indicates that a mapped resource is not available for access as a pointer.
CUDA_ERROR_NOT_MAPPED_AS_POINTER = 213,
/// This indicates that an uncorrectable ECC error was detected during execution.
CUDA_ERROR_ECC_UNCORRECTABLE = 214,
/// This indicates that the `CUlimit` passed to the API call is not supported by the active device.
CUDA_ERROR_UNSUPPORTED_LIMIT = 215,
/// This indicates that the [`CUcontext`] passed to the API call can only be bound to a single CPU thread at a time but is already bound to a CPU thread.
CUDA_ERROR_CONTEXT_ALREADY_IN_USE = 216,
/// This indicates that peer access is not supported across the given devices.
CUDA_ERROR_PEER_ACCESS_UNSUPPORTED = 217,
/// This indicates that a PTX JIT compilation failed.
CUDA_ERROR_INVALID_PTX = 218,
/// This indicates an error with OpenGL or DirectX context.
CUDA_ERROR_INVALID_GRAPHICS_CONTEXT = 219,
/// This indicates that an uncorrectable NVLink error was detected during the execution.
CUDA_ERROR_NVLINK_UNCORRECTABLE = 220,
/// This indicates that the PTX JIT compiler library was not found.
CUDA_ERROR_JIT_COMPILER_NOT_FOUND = 221,
/// This indicates that the provided PTX was compiled with an unsupported toolchain.
CUDA_ERROR_UNSUPPORTED_PTX_VERSION = 222,
/// This indicates that the PTX JIT compilation was disabled.
CUDA_ERROR_JIT_COMPILATION_DISABLED = 223,
/// This indicates that the `CUexecAffinityType` passed to the API call is not supported by the active device.
CUDA_ERROR_UNSUPPORTED_EXEC_AFFINITY = 224,
/// This indicates that the code to be compiled by the PTX JIT contains unsupported call to cudaDeviceSynchronize.
CUDA_ERROR_UNSUPPORTED_DEVSIDE_SYNC = 225,
/// This indicates that an exception occurred on the device that is now contained by the GPU's error containment capability. Common
/// causes are - a. Certain types of invalid accesses of peer GPU memory over nvlink b. Certain classes of hardware errors This
/// leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA,
/// the process must be terminated and relaunched.
CUDA_ERROR_CONTAINED = 226,
/// This indicates that the device kernel source is invalid. This includes compilation/linker errors encountered in device code
/// or user error.
CUDA_ERROR_INVALID_SOURCE = 300,
/// This indicates that the file specified was not found.
CUDA_ERROR_FILE_NOT_FOUND = 301,
/// This indicates that a link to a shared object failed to resolve.
CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = 302,
/// This indicates that initialization of a shared object failed.
CUDA_ERROR_SHARED_OBJECT_INIT_FAILED = 303,
/// This indicates that an OS call failed.
CUDA_ERROR_OPERATING_SYSTEM = 304,
/// This indicates that a resource handle passed to the API call was not valid. Resource handles are opaque types like [`CUstream`] and [`CUevent`].
CUDA_ERROR_INVALID_HANDLE = 400,
/// This indicates that a resource required by the API call is not in a valid state to perform the requested operation.
CUDA_ERROR_ILLEGAL_STATE = 401,
/// This indicates an attempt was made to introspect an object in a way that would discard semantically important information.
/// This is either due to the object using funtionality newer than the API version used to introspect it or omission of optional
/// return arguments.
CUDA_ERROR_LOSSY_QUERY = 402,
/// This indicates that a named symbol was not found. Examples of symbols are global/constant variable names, driver function
/// names, texture names, and surface names.
CUDA_ERROR_NOT_FOUND = 500,
/// This indicates that asynchronous operations issued previously have not completed yet. This result is not actually an error,
/// but must be indicated differently than CUDA_SUCCESS (which indicates completion). Calls that may return this value include [`cuEventQuery`] and [`cuStreamQuery`].
CUDA_ERROR_NOT_READY = 600,
/// While executing a kernel, the device encountered a load or store instruction on an invalid memory address. This leaves the
/// process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process
/// must be terminated and relaunched.
CUDA_ERROR_ILLEGAL_ADDRESS = 700,
/// This indicates that a launch did not occur because it did not have appropriate resources. This error usually indicates that
/// the user has attempted to pass too many arguments to the device kernel, or the kernel launch specifies too many threads for
/// the kernel's register count. Passing arguments of the wrong size (i.e. a 64-bit pointer when a 32-bit int is expected) is
/// equivalent to passing too many arguments and can also result in this error.
CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES = 701,
/// This indicates that the device kernel took too long to execute. This can only occur if timeouts are enabled - see the device
/// attribute CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT for more information. This leaves the process in an inconsistent state and any further CUDA work will return the same error.
/// To continue using CUDA, the process must be terminated and relaunched.
CUDA_ERROR_LAUNCH_TIMEOUT = 702,
/// This error indicates a kernel launch that uses an incompatible texturing mode.
CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING = 703,
/// This error indicates that a call to [`cuCtxEnablePeerAccess`] is trying to re-enable peer access to a context which has already had peer access to it enabled.
CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED = 704,
/// This error indicates that [`cuCtxDisablePeerAccess`] is trying to disable peer access which has not been enabled yet via [`cuCtxEnablePeerAccess`].
CUDA_ERROR_PEER_ACCESS_NOT_ENABLED = 705,
/// This error indicates that the primary context for the specified device has already been initialized.
CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE = 708,
/// This error indicates that the context current to the calling thread has been destroyed using [`cuCtxDestroy_v2`], or is a primary context which has not yet been initialized.
CUDA_ERROR_CONTEXT_IS_DESTROYED = 709,
/// A device-side assert triggered during kernel execution. The context cannot be used anymore, and must be destroyed. All existing
/// device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.
CUDA_ERROR_ASSERT = 710,
/// This error indicates that the hardware resources required to enable peer access have been exhausted for one or more of the
/// devices passed to [`cuCtxEnablePeerAccess`].
CUDA_ERROR_TOO_MANY_PEERS = 711,
/// This error indicates that the memory range passed to [`cuMemHostRegister_v2`] has already been registered.
CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED = 712,
/// This error indicates that the pointer passed to [`cuMemHostUnregister`] does not correspond to any currently registered memory region.
CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED = 713,
/// While executing a kernel, the device encountered a stack error. This can be due to stack corruption or exceeding the stack
/// size limit. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue
/// using CUDA, the process must be terminated and relaunched.
CUDA_ERROR_HARDWARE_STACK_ERROR = 714,
/// While executing a kernel, the device encountered an illegal instruction. This leaves the process in an inconsistent state
/// and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.
CUDA_ERROR_ILLEGAL_INSTRUCTION = 715,
/// While executing a kernel, the device encountered a load or store instruction on a memory address which is not aligned. This
/// leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA,
/// the process must be terminated and relaunched.
CUDA_ERROR_MISALIGNED_ADDRESS = 716,
/// While executing a kernel, the device encountered an instruction which can only operate on memory locations in certain address
/// spaces (global, shared, or local), but was supplied a memory address not belonging to an allowed address space. This leaves
/// the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA, the process
/// must be terminated and relaunched.
CUDA_ERROR_INVALID_ADDRESS_SPACE = 717,
/// While executing a kernel, the device program counter wrapped its address space. This leaves the process in an inconsistent
/// state and any further CUDA work will return the same error. To continue using CUDA, the process must be terminated and relaunched.
CUDA_ERROR_INVALID_PC = 718,
/// An exception occurred on the device while executing a kernel. Common causes include dereferencing an invalid device pointer
/// and accessing out of bounds shared memory. Less common cases can be system specific - more information about these cases can
/// be found in the system specific user guide. This leaves the process in an inconsistent state and any further CUDA work will
/// return the same error. To continue using CUDA, the process must be terminated and relaunched.
CUDA_ERROR_LAUNCH_FAILED = 719,
/// This error indicates that the number of blocks launched per grid for a kernel that was launched via either [`cuLaunchCooperativeKernel`] or [`cuLaunchCooperativeKernelMultiDevice`] exceeds the maximum number of blocks as allowed by [`cuOccupancyMaxActiveBlocksPerMultiprocessor`] or [`cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags`] times the number of multiprocessors as specified by the device attribute CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT.
CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE = 720,
/// An exception occurred on the device while exiting a kernel using tensor memory: the tensor memory was not completely deallocated.
/// This leaves the process in an inconsistent state and any further CUDA work will return the same error. To continue using CUDA,
/// the process must be terminated and relaunched.
CUDA_ERROR_TENSOR_MEMORY_LEAK = 721,
/// This error indicates that the attempted operation is not permitted.
CUDA_ERROR_NOT_PERMITTED = 800,
/// This error indicates that the attempted operation is not supported on the current system or device.
CUDA_ERROR_NOT_SUPPORTED = 801,
/// This error indicates that the system is not yet ready to start any CUDA work. To continue using CUDA, verify the system configuration
/// is in a valid state and all required driver daemons are actively running. More information about this error can be found in
/// the system specific user guide.
CUDA_ERROR_SYSTEM_NOT_READY = 802,
/// This error indicates that there is a mismatch between the versions of the display driver and the CUDA driver. Refer to the
/// compatibility documentation for supported versions.
CUDA_ERROR_SYSTEM_DRIVER_MISMATCH = 803,
/// This error indicates that the system was upgraded to run with forward compatibility but the visible hardware detected by CUDA
/// does not support this configuration. Refer to the compatibility documentation for the supported hardware matrix or ensure
/// that only supported hardware is visible during initialization via the CUDA_VISIBLE_DEVICES environment variable.
CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE = 804,
/// This error indicates that the MPS client failed to connect to the MPS control daemon or the MPS server.
CUDA_ERROR_MPS_CONNECTION_FAILED = 805,
/// This error indicates that the remote procedural call between the MPS server and the MPS client failed.
CUDA_ERROR_MPS_RPC_FAILURE = 806,
/// This error indicates that the MPS server is not ready to accept new MPS client requests. This error can be returned when the
/// MPS server is in the process of recovering from a fatal failure.
CUDA_ERROR_MPS_SERVER_NOT_READY = 807,
/// This error indicates that the hardware resources required to create MPS client have been exhausted.
CUDA_ERROR_MPS_MAX_CLIENTS_REACHED = 808,
/// This error indicates the hardware resources required to support device connections have been exhausted.
CUDA_ERROR_MPS_MAX_CONNECTIONS_REACHED = 809,
/// This error indicates that the MPS client has been terminated by the server. To continue using CUDA, the process must be terminated
/// and relaunched.
CUDA_ERROR_MPS_CLIENT_TERMINATED = 810,
/// This error indicates that the module is using CUDA Dynamic Parallelism, but the current configuration, like MPS, does not
/// support it.
CUDA_ERROR_CDP_NOT_SUPPORTED = 811,
/// This error indicates that a module contains an unsupported interaction between different versions of CUDA Dynamic Parallelism.
CUDA_ERROR_CDP_VERSION_MISMATCH = 812,
/// This error indicates that the operation is not permitted when the stream is capturing.
CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED = 900,
/// This error indicates that the current capture sequence on the stream has been invalidated due to a previous error.
CUDA_ERROR_STREAM_CAPTURE_INVALIDATED = 901,
/// This error indicates that the operation would have resulted in a merge of two independent capture sequences.
CUDA_ERROR_STREAM_CAPTURE_MERGE = 902,
/// This error indicates that the capture was not initiated in this stream.
CUDA_ERROR_STREAM_CAPTURE_UNMATCHED = 903,
/// This error indicates that the capture sequence contains a fork that was not joined to the primary stream.
CUDA_ERROR_STREAM_CAPTURE_UNJOINED = 904,
/// This error indicates that a dependency would have been created which crosses the capture sequence boundary. Only implicit
/// in-stream ordering dependencies are allowed to cross the boundary.
CUDA_ERROR_STREAM_CAPTURE_ISOLATION = 905,
/// This error indicates a disallowed implicit dependency on a current capture sequence from cudaStreamLegacy.
CUDA_ERROR_STREAM_CAPTURE_IMPLICIT = 906,
/// This error indicates that the operation is not permitted on an event which was last recorded in a capturing stream.
CUDA_ERROR_CAPTURED_EVENT = 907,
/// A stream capture sequence not initiated with the [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`] argument to [`cuStreamBeginCapture_v2`] was passed to [`cuStreamEndCapture`] in a different thread.
CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD = 908,
/// This error indicates that the timeout specified for the wait operation has lapsed.
CUDA_ERROR_TIMEOUT = 909,
/// This error indicates that the graph update was not performed because it included changes which violated constraints specific
/// to instantiated graph update.
CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE = 910,
/// This indicates that an error has occurred in a device outside of GPU. It can be a synchronous error with respect to CUDA API or an
/// asynchronous error from the external device. In case of asynchronous error, it means that if CUDA was waiting for an external
/// device's signal before consuming shared data, the external device signaled an error indicating that the data is not valid
/// for consumption. This leaves the process in an inconsistent state and any further CUDA work will return the same error. To
/// continue using CUDA, the process must be terminated and relaunched. In case of synchronous error, it means that one or more
/// external devices have encountered an error and cannot complete the operation.
CUDA_ERROR_EXTERNAL_DEVICE = 911,
/// Indicates a kernel launch error due to cluster misconfiguration.
CUDA_ERROR_INVALID_CLUSTER_SIZE = 912,
/// Indiciates a function handle is not loaded when calling an API that requires a loaded function.
CUDA_ERROR_FUNCTION_NOT_LOADED = 913,
/// This error indicates one or more resources passed in are not valid resource types for the operation.
CUDA_ERROR_INVALID_RESOURCE_TYPE = 914,
/// This error indicates one or more resources are insufficient or non-applicable for the operation.
CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION = 915,
/// This error indicates that an error happened during the key rotation sequence.
CUDA_ERROR_KEY_ROTATION = 916,
/// This error indicates that the requested operation is not permitted because the stream is in a detached state. This can occur
/// if the green context associated with the stream has been destroyed, limiting the stream's operational capabilities.
CUDA_ERROR_STREAM_DETACHED = 917,
/// This indicates that an unknown internal error has occurred.
CUDA_ERROR_UNKNOWN = 999,
}
pub use self::cudaError_enum as CUresult;
impl CUdevice_P2PAttribute_enum {
pub const CU_DEVICE_P2P_ATTRIBUTE_CUDA_ARRAY_ACCESS_SUPPORTED: CUdevice_P2PAttribute_enum = CUdevice_P2PAttribute_enum::CU_DEVICE_P2P_ATTRIBUTE_ACCESS_ACCESS_SUPPORTED;
}
/// P2P Attributes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUdevice_P2PAttribute_enum {
/// A relative value indicating the performance of the link between two devices.
CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK = 1,
/// P2P Access is enable.
CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED = 2,
/// All CUDA-valid atomic operation over the link are supported.
CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED = 3,
/// use [`CUdevice_P2PAttribute::CU_DEVICE_P2P_ATTRIBUTE_CUDA_ARRAY_ACCESS_SUPPORTED`] instead.
#[deprecated]
CU_DEVICE_P2P_ATTRIBUTE_ACCESS_ACCESS_SUPPORTED = 4,
/// Only some CUDA-valid atomic operations over the link are supported.
CU_DEVICE_P2P_ATTRIBUTE_ONLY_PARTIAL_NATIVE_ATOMIC_SUPPORTED = 5,
}
pub use self::CUdevice_P2PAttribute_enum as CUdevice_P2PAttribute;
/// CUDA stream callback.
pub type CUstreamCallback = ::core::option::Option<
unsafe extern "C" fn(
hStream: CUstream,
status: CUresult,
userData: *mut ::core::ffi::c_void,
),
>;
/// Block size to per-block dynamic shared memory mapping for a certain kernel.
pub type CUoccupancyB2DSize = ::core::option::Option<
unsafe extern "C" fn(blockSize: ::core::ffi::c_int) -> size_t,
>;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_MEMCPY2D_st {
pub srcXInBytes: size_t,
pub srcY: size_t,
pub srcMemoryType: CUmemorytype,
pub srcHost: *const ::core::ffi::c_void,
pub srcDevice: CUdeviceptr,
pub srcArray: CUarray,
pub srcPitch: size_t,
pub dstXInBytes: size_t,
pub dstY: size_t,
pub dstMemoryType: CUmemorytype,
pub dstHost: *mut ::core::ffi::c_void,
pub dstDevice: CUdeviceptr,
pub dstArray: CUarray,
pub dstPitch: size_t,
pub WidthInBytes: size_t,
pub Height: size_t,
}
impl Default for CUDA_MEMCPY2D_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// 2D memory copy parameters.
pub type CUDA_MEMCPY2D_v2 = CUDA_MEMCPY2D_st;
pub type CUDA_MEMCPY2D = CUDA_MEMCPY2D_v2;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_MEMCPY3D_st {
pub srcXInBytes: size_t,
pub srcY: size_t,
pub srcZ: size_t,
pub srcLOD: size_t,
pub srcMemoryType: CUmemorytype,
pub srcHost: *const ::core::ffi::c_void,
pub srcDevice: CUdeviceptr,
pub srcArray: CUarray,
pub reserved0: *mut ::core::ffi::c_void,
pub srcPitch: size_t,
pub srcHeight: size_t,
pub dstXInBytes: size_t,
pub dstY: size_t,
pub dstZ: size_t,
pub dstLOD: size_t,
pub dstMemoryType: CUmemorytype,
pub dstHost: *mut ::core::ffi::c_void,
pub dstDevice: CUdeviceptr,
pub dstArray: CUarray,
pub reserved1: *mut ::core::ffi::c_void,
pub dstPitch: size_t,
pub dstHeight: size_t,
pub WidthInBytes: size_t,
pub Height: size_t,
pub Depth: size_t,
}
impl Default for CUDA_MEMCPY3D_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// 3D memory copy parameters.
pub type CUDA_MEMCPY3D_v2 = CUDA_MEMCPY3D_st;
pub type CUDA_MEMCPY3D = CUDA_MEMCPY3D_v2;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_MEMCPY3D_PEER_st {
pub srcXInBytes: size_t,
pub srcY: size_t,
pub srcZ: size_t,
pub srcLOD: size_t,
pub srcMemoryType: CUmemorytype,
pub srcHost: *const ::core::ffi::c_void,
pub srcDevice: CUdeviceptr,
pub srcArray: CUarray,
pub srcContext: CUcontext,
pub srcPitch: size_t,
pub srcHeight: size_t,
pub dstXInBytes: size_t,
pub dstY: size_t,
pub dstZ: size_t,
pub dstLOD: size_t,
pub dstMemoryType: CUmemorytype,
pub dstHost: *mut ::core::ffi::c_void,
pub dstDevice: CUdeviceptr,
pub dstArray: CUarray,
pub dstContext: CUcontext,
pub dstPitch: size_t,
pub dstHeight: size_t,
pub WidthInBytes: size_t,
pub Height: size_t,
pub Depth: size_t,
}
impl Default for CUDA_MEMCPY3D_PEER_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// 3D memory cross-context copy parameters.
pub type CUDA_MEMCPY3D_PEER_v1 = CUDA_MEMCPY3D_PEER_st;
pub type CUDA_MEMCPY3D_PEER = CUDA_MEMCPY3D_PEER_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_MEMCPY_NODE_PARAMS_st {
pub flags: ::core::ffi::c_int,
pub reserved: ::core::ffi::c_int,
pub copyCtx: CUcontext,
pub copyParams: CUDA_MEMCPY3D,
}
impl Default for CUDA_MEMCPY_NODE_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Memcpy node parameters.
pub type CUDA_MEMCPY_NODE_PARAMS = CUDA_MEMCPY_NODE_PARAMS_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_ARRAY_DESCRIPTOR_st {
pub Width: size_t,
pub Height: size_t,
pub Format: CUarray_format,
pub NumChannels: ::core::ffi::c_uint,
}
impl Default for CUDA_ARRAY_DESCRIPTOR_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Array descriptor.
pub type CUDA_ARRAY_DESCRIPTOR_v2 = CUDA_ARRAY_DESCRIPTOR_st;
pub type CUDA_ARRAY_DESCRIPTOR = CUDA_ARRAY_DESCRIPTOR_v2;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_ARRAY3D_DESCRIPTOR_st {
pub Width: size_t,
pub Height: size_t,
pub Depth: size_t,
pub Format: CUarray_format,
pub NumChannels: ::core::ffi::c_uint,
pub Flags: ::core::ffi::c_uint,
}
impl Default for CUDA_ARRAY3D_DESCRIPTOR_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// 3D array descriptor.
pub type CUDA_ARRAY3D_DESCRIPTOR_v2 = CUDA_ARRAY3D_DESCRIPTOR_st;
pub type CUDA_ARRAY3D_DESCRIPTOR = CUDA_ARRAY3D_DESCRIPTOR_v2;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_ARRAY_SPARSE_PROPERTIES_st {
pub tileExtent: CUDA_ARRAY_SPARSE_PROPERTIES_st__bindgen_ty_1,
pub miptailFirstLevel: ::core::ffi::c_uint,
pub miptailSize: ::core::ffi::c_ulonglong,
pub flags: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 4usize],
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_ARRAY_SPARSE_PROPERTIES_st__bindgen_ty_1 {
pub width: ::core::ffi::c_uint,
pub height: ::core::ffi::c_uint,
pub depth: ::core::ffi::c_uint,
}
/// CUDA array sparse properties.
pub type CUDA_ARRAY_SPARSE_PROPERTIES_v1 = CUDA_ARRAY_SPARSE_PROPERTIES_st;
pub type CUDA_ARRAY_SPARSE_PROPERTIES = CUDA_ARRAY_SPARSE_PROPERTIES_v1;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_ARRAY_MEMORY_REQUIREMENTS_st {
pub size: size_t,
pub alignment: size_t,
pub reserved: [::core::ffi::c_uint; 4usize],
}
/// CUDA array memory requirements.
pub type CUDA_ARRAY_MEMORY_REQUIREMENTS_v1 = CUDA_ARRAY_MEMORY_REQUIREMENTS_st;
pub type CUDA_ARRAY_MEMORY_REQUIREMENTS = CUDA_ARRAY_MEMORY_REQUIREMENTS_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_RESOURCE_DESC_st {
pub resType: CUresourcetype,
pub res: CUDA_RESOURCE_DESC_st__bindgen_ty_1,
pub flags: ::core::ffi::c_uint,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUDA_RESOURCE_DESC_st__bindgen_ty_1 {
pub array: CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_1,
pub mipmap: CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_2,
pub linear: CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_3,
pub pitch2D: CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_4,
pub reserved: CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_5,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_1 {
pub hArray: CUarray,
}
impl Default for CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_2 {
pub hMipmappedArray: CUmipmappedArray,
}
impl Default for CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_2 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_3 {
pub devPtr: CUdeviceptr,
pub format: CUarray_format,
pub numChannels: ::core::ffi::c_uint,
pub sizeInBytes: size_t,
}
impl Default for CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_3 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_4 {
pub devPtr: CUdeviceptr,
pub format: CUarray_format,
pub numChannels: ::core::ffi::c_uint,
pub width: size_t,
pub height: size_t,
pub pitchInBytes: size_t,
}
impl Default for CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_4 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_RESOURCE_DESC_st__bindgen_ty_1__bindgen_ty_5 {
pub reserved: [::core::ffi::c_int; 32usize],
}
impl Default for CUDA_RESOURCE_DESC_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUDA_RESOURCE_DESC_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// CUDA Resource descriptor.
pub type CUDA_RESOURCE_DESC_v1 = CUDA_RESOURCE_DESC_st;
pub type CUDA_RESOURCE_DESC = CUDA_RESOURCE_DESC_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
pub struct CUDA_TEXTURE_DESC_st {
pub addressMode: [CUaddress_mode; 3usize],
pub filterMode: CUfilter_mode,
pub flags: ::core::ffi::c_uint,
pub maxAnisotropy: ::core::ffi::c_uint,
pub mipmapFilterMode: CUfilter_mode,
pub mipmapLevelBias: f32,
pub minMipmapLevelClamp: f32,
pub maxMipmapLevelClamp: f32,
pub borderColor: [f32; 4usize],
pub reserved: [::core::ffi::c_int; 12usize],
}
impl Default for CUDA_TEXTURE_DESC_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Texture descriptor.
pub type CUDA_TEXTURE_DESC_v1 = CUDA_TEXTURE_DESC_st;
pub type CUDA_TEXTURE_DESC = CUDA_TEXTURE_DESC_v1;
/// Resource view format.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUresourceViewFormat_enum {
/// No resource view format (use underlying resource format).
CU_RES_VIEW_FORMAT_NONE = 0,
/// 1 channel unsigned 8-bit integers.
CU_RES_VIEW_FORMAT_UINT_1X8 = 1,
/// 2 channel unsigned 8-bit integers.
CU_RES_VIEW_FORMAT_UINT_2X8 = 2,
/// 4 channel unsigned 8-bit integers.
CU_RES_VIEW_FORMAT_UINT_4X8 = 3,
/// 1 channel signed 8-bit integers.
CU_RES_VIEW_FORMAT_SINT_1X8 = 4,
/// 2 channel signed 8-bit integers.
CU_RES_VIEW_FORMAT_SINT_2X8 = 5,
/// 4 channel signed 8-bit integers.
CU_RES_VIEW_FORMAT_SINT_4X8 = 6,
/// 1 channel unsigned 16-bit integers.
CU_RES_VIEW_FORMAT_UINT_1X16 = 7,
/// 2 channel unsigned 16-bit integers.
CU_RES_VIEW_FORMAT_UINT_2X16 = 8,
/// 4 channel unsigned 16-bit integers.
CU_RES_VIEW_FORMAT_UINT_4X16 = 9,
/// 1 channel signed 16-bit integers.
CU_RES_VIEW_FORMAT_SINT_1X16 = 10,
/// 2 channel signed 16-bit integers.
CU_RES_VIEW_FORMAT_SINT_2X16 = 11,
/// 4 channel signed 16-bit integers.
CU_RES_VIEW_FORMAT_SINT_4X16 = 12,
/// 1 channel unsigned 32-bit integers.
CU_RES_VIEW_FORMAT_UINT_1X32 = 13,
/// 2 channel unsigned 32-bit integers.
CU_RES_VIEW_FORMAT_UINT_2X32 = 14,
/// 4 channel unsigned 32-bit integers.
CU_RES_VIEW_FORMAT_UINT_4X32 = 15,
/// 1 channel signed 32-bit integers.
CU_RES_VIEW_FORMAT_SINT_1X32 = 16,
/// 2 channel signed 32-bit integers.
CU_RES_VIEW_FORMAT_SINT_2X32 = 17,
/// 4 channel signed 32-bit integers.
CU_RES_VIEW_FORMAT_SINT_4X32 = 18,
/// 1 channel 16-bit floating point.
CU_RES_VIEW_FORMAT_FLOAT_1X16 = 19,
/// 2 channel 16-bit floating point.
CU_RES_VIEW_FORMAT_FLOAT_2X16 = 20,
/// 4 channel 16-bit floating point.
CU_RES_VIEW_FORMAT_FLOAT_4X16 = 21,
/// 1 channel 32-bit floating point.
CU_RES_VIEW_FORMAT_FLOAT_1X32 = 22,
/// 2 channel 32-bit floating point.
CU_RES_VIEW_FORMAT_FLOAT_2X32 = 23,
/// 4 channel 32-bit floating point.
CU_RES_VIEW_FORMAT_FLOAT_4X32 = 24,
/// Block compressed 1.
CU_RES_VIEW_FORMAT_UNSIGNED_BC1 = 25,
/// Block compressed 2.
CU_RES_VIEW_FORMAT_UNSIGNED_BC2 = 26,
/// Block compressed 3.
CU_RES_VIEW_FORMAT_UNSIGNED_BC3 = 27,
/// Block compressed 4 unsigned.
CU_RES_VIEW_FORMAT_UNSIGNED_BC4 = 28,
/// Block compressed 4 signed.
CU_RES_VIEW_FORMAT_SIGNED_BC4 = 29,
/// Block compressed 5 unsigned.
CU_RES_VIEW_FORMAT_UNSIGNED_BC5 = 30,
/// Block compressed 5 signed.
CU_RES_VIEW_FORMAT_SIGNED_BC5 = 31,
/// Block compressed 6 unsigned half-float.
CU_RES_VIEW_FORMAT_UNSIGNED_BC6H = 32,
/// Block compressed 6 signed half-float.
CU_RES_VIEW_FORMAT_SIGNED_BC6H = 33,
/// Block compressed 7.
CU_RES_VIEW_FORMAT_UNSIGNED_BC7 = 34,
}
pub use self::CUresourceViewFormat_enum as CUresourceViewFormat;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_RESOURCE_VIEW_DESC_st {
pub format: CUresourceViewFormat,
pub width: size_t,
pub height: size_t,
pub depth: size_t,
pub firstMipmapLevel: ::core::ffi::c_uint,
pub lastMipmapLevel: ::core::ffi::c_uint,
pub firstLayer: ::core::ffi::c_uint,
pub lastLayer: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 16usize],
}
impl Default for CUDA_RESOURCE_VIEW_DESC_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Resource view descriptor.
pub type CUDA_RESOURCE_VIEW_DESC_v1 = CUDA_RESOURCE_VIEW_DESC_st;
pub type CUDA_RESOURCE_VIEW_DESC = CUDA_RESOURCE_VIEW_DESC_v1;
#[repr(C)]
#[repr(align(128))]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUtensorMap_st {
pub opaque: [cuuint64_t; 16usize],
}
impl Default for CUtensorMap_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Tensor map descriptor. Requires compiler support for aligning to 128 bytes.
pub type CUtensorMap = CUtensorMap_st;
/// Tensor map data type.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUtensorMapDataType_enum {
CU_TENSOR_MAP_DATA_TYPE_UINT8 = 0,
CU_TENSOR_MAP_DATA_TYPE_UINT16 = 1,
CU_TENSOR_MAP_DATA_TYPE_UINT32 = 2,
CU_TENSOR_MAP_DATA_TYPE_INT32 = 3,
CU_TENSOR_MAP_DATA_TYPE_UINT64 = 4,
CU_TENSOR_MAP_DATA_TYPE_INT64 = 5,
CU_TENSOR_MAP_DATA_TYPE_FLOAT16 = 6,
CU_TENSOR_MAP_DATA_TYPE_FLOAT32 = 7,
CU_TENSOR_MAP_DATA_TYPE_FLOAT64 = 8,
CU_TENSOR_MAP_DATA_TYPE_BFLOAT16 = 9,
CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ = 10,
CU_TENSOR_MAP_DATA_TYPE_TFLOAT32 = 11,
CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ = 12,
CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B = 13,
CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B = 14,
CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B = 15,
}
pub use self::CUtensorMapDataType_enum as CUtensorMapDataType;
/// Tensor map interleave layout type.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUtensorMapInterleave_enum {
CU_TENSOR_MAP_INTERLEAVE_NONE = 0,
CU_TENSOR_MAP_INTERLEAVE_16B = 1,
CU_TENSOR_MAP_INTERLEAVE_32B = 2,
}
pub use self::CUtensorMapInterleave_enum as CUtensorMapInterleave;
/// Tensor map swizzling mode of shared memory banks.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUtensorMapSwizzle_enum {
CU_TENSOR_MAP_SWIZZLE_NONE = 0,
CU_TENSOR_MAP_SWIZZLE_32B = 1,
CU_TENSOR_MAP_SWIZZLE_64B = 2,
CU_TENSOR_MAP_SWIZZLE_128B = 3,
CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B = 4,
CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B_FLIP_8B = 5,
CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B = 6,
}
pub use self::CUtensorMapSwizzle_enum as CUtensorMapSwizzle;
/// Tensor map L2 promotion type.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUtensorMapL2promotion_enum {
CU_TENSOR_MAP_L2_PROMOTION_NONE = 0,
CU_TENSOR_MAP_L2_PROMOTION_L2_64B = 1,
CU_TENSOR_MAP_L2_PROMOTION_L2_128B = 2,
CU_TENSOR_MAP_L2_PROMOTION_L2_256B = 3,
}
pub use self::CUtensorMapL2promotion_enum as CUtensorMapL2promotion;
/// Tensor map out-of-bounds fill type.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUtensorMapFloatOOBfill_enum {
CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE = 0,
CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA = 1,
}
pub use self::CUtensorMapFloatOOBfill_enum as CUtensorMapFloatOOBfill;
/// Tensor map Im2Col wide mode.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUtensorMapIm2ColWideMode_enum {
CU_TENSOR_MAP_IM2COL_WIDE_MODE_W = 0,
CU_TENSOR_MAP_IM2COL_WIDE_MODE_W128 = 1,
}
pub use self::CUtensorMapIm2ColWideMode_enum as CUtensorMapIm2ColWideMode;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_POINTER_ATTRIBUTE_P2P_TOKENS_st {
pub p2pToken: ::core::ffi::c_ulonglong,
pub vaSpaceToken: ::core::ffi::c_uint,
}
/// GPU Direct v3 tokens.
pub type CUDA_POINTER_ATTRIBUTE_P2P_TOKENS_v1 = CUDA_POINTER_ATTRIBUTE_P2P_TOKENS_st;
pub type CUDA_POINTER_ATTRIBUTE_P2P_TOKENS = CUDA_POINTER_ATTRIBUTE_P2P_TOKENS_v1;
/// Access flags that specify the level of access the current context's device has on the memory referenced.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUDA_POINTER_ATTRIBUTE_ACCESS_FLAGS_enum {
/// No access, meaning the device cannot access this memory at all, thus must be staged through accessible memory in order to
/// complete certain operations.
CU_POINTER_ATTRIBUTE_ACCESS_FLAG_NONE = 0,
/// Read-only access, meaning writes to this memory are considered invalid accesses and thus return error in that case.
CU_POINTER_ATTRIBUTE_ACCESS_FLAG_READ = 1,
/// Read-write access, the device has full read-write access to the memory.
CU_POINTER_ATTRIBUTE_ACCESS_FLAG_READWRITE = 3,
}
pub use self::CUDA_POINTER_ATTRIBUTE_ACCESS_FLAGS_enum as CUDA_POINTER_ATTRIBUTE_ACCESS_FLAGS;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_LAUNCH_PARAMS_st {
pub function: CUfunction,
pub gridDimX: ::core::ffi::c_uint,
pub gridDimY: ::core::ffi::c_uint,
pub gridDimZ: ::core::ffi::c_uint,
pub blockDimX: ::core::ffi::c_uint,
pub blockDimY: ::core::ffi::c_uint,
pub blockDimZ: ::core::ffi::c_uint,
pub sharedMemBytes: ::core::ffi::c_uint,
pub hStream: CUstream,
pub kernelParams: *mut *mut ::core::ffi::c_void,
}
impl Default for CUDA_LAUNCH_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Kernel launch parameters.
pub type CUDA_LAUNCH_PARAMS_v1 = CUDA_LAUNCH_PARAMS_st;
pub type CUDA_LAUNCH_PARAMS = CUDA_LAUNCH_PARAMS_v1;
/// External memory handle types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUexternalMemoryHandleType_enum {
/// Handle is an opaque file descriptor.
CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD = 1,
/// Handle is an opaque shared NT handle.
CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32 = 2,
/// Handle is an opaque, globally shared handle.
CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
/// Handle is a D3D12 heap object.
CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP = 4,
/// Handle is a D3D12 committed resource.
CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE = 5,
/// Handle is a shared NT handle to a D3D11 resource.
CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE = 6,
/// Handle is a globally shared handle to a D3D11 resource.
CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT = 7,
/// Handle is an NvSciBuf object.
CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF = 8,
/// Handle is a dma_buf file descriptor.
CU_EXTERNAL_MEMORY_HANDLE_TYPE_DMABUF_FD = 9,
}
pub use self::CUexternalMemoryHandleType_enum as CUexternalMemoryHandleType;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st {
pub type_: CUexternalMemoryHandleType,
pub handle: CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st__bindgen_ty_1,
pub size: ::core::ffi::c_ulonglong,
pub flags: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 16usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st__bindgen_ty_1 {
pub fd: ::core::ffi::c_int,
pub win32: CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st__bindgen_ty_1__bindgen_ty_1,
pub nvSciBufObject: *const ::core::ffi::c_void,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st__bindgen_ty_1__bindgen_ty_1 {
pub handle: *mut ::core::ffi::c_void,
pub name: *const ::core::ffi::c_void,
}
impl Default for CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st__bindgen_ty_1__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// External memory handle descriptor.
pub type CUDA_EXTERNAL_MEMORY_HANDLE_DESC_v1 = CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st;
pub type CUDA_EXTERNAL_MEMORY_HANDLE_DESC = CUDA_EXTERNAL_MEMORY_HANDLE_DESC_v1;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXTERNAL_MEMORY_BUFFER_DESC_st {
pub offset: ::core::ffi::c_ulonglong,
pub size: ::core::ffi::c_ulonglong,
pub flags: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 16usize],
}
/// External memory buffer descriptor.
pub type CUDA_EXTERNAL_MEMORY_BUFFER_DESC_v1 = CUDA_EXTERNAL_MEMORY_BUFFER_DESC_st;
pub type CUDA_EXTERNAL_MEMORY_BUFFER_DESC = CUDA_EXTERNAL_MEMORY_BUFFER_DESC_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_st {
pub offset: ::core::ffi::c_ulonglong,
pub arrayDesc: CUDA_ARRAY3D_DESCRIPTOR,
pub numLevels: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 16usize],
}
impl Default for CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// External memory mipmap descriptor.
pub type CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_v1 = CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_st;
pub type CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC = CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_v1;
/// External semaphore handle types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUexternalSemaphoreHandleType_enum {
/// Handle is an opaque file descriptor.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD = 1,
/// Handle is an opaque shared NT handle.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32 = 2,
/// Handle is an opaque, globally shared handle.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
/// Handle is a shared NT handle referencing a D3D12 fence object.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE = 4,
/// Handle is a shared NT handle referencing a D3D11 fence object.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE = 5,
/// Opaque handle to NvSciSync Object.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC = 6,
/// Handle is a shared NT handle referencing a D3D11 keyed mutex object.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX = 7,
/// Handle is a globally shared handle referencing a D3D11 keyed mutex object.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT = 8,
/// Handle is an opaque file descriptor referencing a timeline semaphore.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD = 9,
/// Handle is an opaque shared NT handle referencing a timeline semaphore.
CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32 = 10,
}
pub use self::CUexternalSemaphoreHandleType_enum as CUexternalSemaphoreHandleType;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st {
pub type_: CUexternalSemaphoreHandleType,
pub handle: CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st__bindgen_ty_1,
pub flags: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 16usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st__bindgen_ty_1 {
pub fd: ::core::ffi::c_int,
pub win32: CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st__bindgen_ty_1__bindgen_ty_1,
pub nvSciSyncObj: *const ::core::ffi::c_void,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st__bindgen_ty_1__bindgen_ty_1 {
pub handle: *mut ::core::ffi::c_void,
pub name: *const ::core::ffi::c_void,
}
impl Default for CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st__bindgen_ty_1__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// External semaphore handle descriptor.
pub type CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_v1 = CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st;
pub type CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC = CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st {
pub params: CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1,
pub flags: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 16usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1 {
pub fence: CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1__bindgen_ty_1,
pub nvSciSync: CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1__bindgen_ty_2,
pub keyedMutex: CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1__bindgen_ty_3,
pub reserved: [::core::ffi::c_uint; 12usize],
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1__bindgen_ty_1 {
pub value: ::core::ffi::c_ulonglong,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1__bindgen_ty_2 {
pub fence: *mut ::core::ffi::c_void,
pub reserved: ::core::ffi::c_ulonglong,
}
impl Default for CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1__bindgen_ty_2 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1__bindgen_ty_3 {
pub key: ::core::ffi::c_ulonglong,
}
impl Default for CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// External semaphore signal parameters.
pub type CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_v1 = CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st;
pub type CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS = CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st {
pub params: CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1,
pub flags: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 16usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1 {
pub fence: CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1__bindgen_ty_1,
pub nvSciSync: CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1__bindgen_ty_2,
pub keyedMutex: CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1__bindgen_ty_3,
pub reserved: [::core::ffi::c_uint; 10usize],
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1__bindgen_ty_1 {
pub value: ::core::ffi::c_ulonglong,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1__bindgen_ty_2 {
pub fence: *mut ::core::ffi::c_void,
pub reserved: ::core::ffi::c_ulonglong,
}
impl Default for CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1__bindgen_ty_2 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1__bindgen_ty_3 {
pub key: ::core::ffi::c_ulonglong,
pub timeoutMs: ::core::ffi::c_uint,
}
impl Default for CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// External semaphore wait parameters.
pub type CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_v1 = CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_st;
pub type CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS = CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_st {
pub extSemArray: *mut CUexternalSemaphore,
pub paramsArray: *const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS,
pub numExtSems: ::core::ffi::c_uint,
}
impl Default for CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Semaphore signal node parameters.
pub type CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v1 = CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_st;
pub type CUDA_EXT_SEM_SIGNAL_NODE_PARAMS = CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v2_st {
pub extSemArray: *mut CUexternalSemaphore,
pub paramsArray: *const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS,
pub numExtSems: ::core::ffi::c_uint,
}
impl Default for CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v2_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Semaphore signal node parameters.
pub type CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v2 = CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v2_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXT_SEM_WAIT_NODE_PARAMS_st {
pub extSemArray: *mut CUexternalSemaphore,
pub paramsArray: *const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS,
pub numExtSems: ::core::ffi::c_uint,
}
impl Default for CUDA_EXT_SEM_WAIT_NODE_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Semaphore wait node parameters.
pub type CUDA_EXT_SEM_WAIT_NODE_PARAMS_v1 = CUDA_EXT_SEM_WAIT_NODE_PARAMS_st;
pub type CUDA_EXT_SEM_WAIT_NODE_PARAMS = CUDA_EXT_SEM_WAIT_NODE_PARAMS_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EXT_SEM_WAIT_NODE_PARAMS_v2_st {
pub extSemArray: *mut CUexternalSemaphore,
pub paramsArray: *const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS,
pub numExtSems: ::core::ffi::c_uint,
}
impl Default for CUDA_EXT_SEM_WAIT_NODE_PARAMS_v2_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Semaphore wait node parameters.
pub type CUDA_EXT_SEM_WAIT_NODE_PARAMS_v2 = CUDA_EXT_SEM_WAIT_NODE_PARAMS_v2_st;
pub type CUmemGenericAllocationHandle_v1 = ::core::ffi::c_ulonglong;
pub type CUmemGenericAllocationHandle = CUmemGenericAllocationHandle_v1;
/// Flags for specifying particular handle types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemAllocationHandleType_enum {
/// Does not allow any export mechanism. >.
CU_MEM_HANDLE_TYPE_NONE = 0,
/// Allows a file descriptor to be used for exporting. Permitted only on POSIX systems. (int).
CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR = 1,
/// Allows a Win32 NT handle to be used for exporting. (HANDLE).
CU_MEM_HANDLE_TYPE_WIN32 = 2,
/// Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE).
CU_MEM_HANDLE_TYPE_WIN32_KMT = 4,
/// Allows a fabric handle to be used for exporting. (CUmemFabricHandle).
CU_MEM_HANDLE_TYPE_FABRIC = 8,
CU_MEM_HANDLE_TYPE_MAX = 2147483647,
}
pub use self::CUmemAllocationHandleType_enum as CUmemAllocationHandleType;
/// Specifies the memory protection flags for mapping.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemAccess_flags_enum {
/// Default, make the address range not accessible.
CU_MEM_ACCESS_FLAGS_PROT_NONE = 0,
/// Make the address range read accessible.
CU_MEM_ACCESS_FLAGS_PROT_READ = 1,
/// Make the address range read-write accessible.
CU_MEM_ACCESS_FLAGS_PROT_READWRITE = 3,
CU_MEM_ACCESS_FLAGS_PROT_MAX = 2147483647,
}
pub use self::CUmemAccess_flags_enum as CUmemAccess_flags;
impl CUmemLocationType_enum {
pub const CU_MEM_LOCATION_TYPE_NONE: CUmemLocationType_enum = CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_INVALID;
}
/// Specifies the type of location.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemLocationType_enum {
CU_MEM_LOCATION_TYPE_INVALID = 0,
/// Location is a device location, thus id is a device ordinal.
CU_MEM_LOCATION_TYPE_DEVICE = 1,
/// Location is host, id is ignored.
CU_MEM_LOCATION_TYPE_HOST = 2,
/// Location is a host NUMA node, thus id is a host NUMA node id.
CU_MEM_LOCATION_TYPE_HOST_NUMA = 3,
/// Location is a host NUMA node of the current thread, id is ignored.
CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT = 4,
/// Location is not visible but device is accessible, id is always CU_DEVICE_INVALID.
CU_MEM_LOCATION_TYPE_INVISIBLE = 5,
CU_MEM_LOCATION_TYPE_MAX = 2147483647,
}
pub use self::CUmemLocationType_enum as CUmemLocationType;
/// Defines the allocation types available.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemAllocationType_enum {
CU_MEM_ALLOCATION_TYPE_INVALID = 0,
/// This allocation type is 'pinned', i.e. cannot migrate from its current location while the application is actively using it.
CU_MEM_ALLOCATION_TYPE_PINNED = 1,
/// This allocation type is managed memory.
CU_MEM_ALLOCATION_TYPE_MANAGED = 2,
CU_MEM_ALLOCATION_TYPE_MAX = 2147483647,
}
pub use self::CUmemAllocationType_enum as CUmemAllocationType;
/// Flag for requesting different optimal and required granularities for an allocation.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemAllocationGranularity_flags_enum {
/// Minimum required granularity for allocation.
CU_MEM_ALLOC_GRANULARITY_MINIMUM = 0,
/// Recommended granularity for allocation for best performance.
CU_MEM_ALLOC_GRANULARITY_RECOMMENDED = 1,
}
pub use self::CUmemAllocationGranularity_flags_enum as CUmemAllocationGranularity_flags;
/// Specifies the handle type for address range.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemRangeHandleType_enum {
CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD = 1,
CU_MEM_RANGE_HANDLE_TYPE_MAX = 2147483647,
}
pub use self::CUmemRangeHandleType_enum as CUmemRangeHandleType;
/// Flag for requesting handle type for address range.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemRangeFlags_enum {
/// Indicates that DMA_BUF handle should be mapped via PCIe BAR1.
CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE = 1,
}
pub use self::CUmemRangeFlags_enum as CUmemRangeFlags;
/// Sparse subresource types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUarraySparseSubresourceType_enum {
CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_SPARSE_LEVEL = 0,
CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_MIPTAIL = 1,
}
pub use self::CUarraySparseSubresourceType_enum as CUarraySparseSubresourceType;
/// Memory operation types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemOperationType_enum {
CU_MEM_OPERATION_TYPE_MAP = 1,
CU_MEM_OPERATION_TYPE_UNMAP = 2,
}
pub use self::CUmemOperationType_enum as CUmemOperationType;
/// Memory handle types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemHandleType_enum {
CU_MEM_HANDLE_TYPE_GENERIC = 0,
}
pub use self::CUmemHandleType_enum as CUmemHandleType;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUarrayMapInfo_st {
pub resourceType: CUresourcetype,
pub resource: CUarrayMapInfo_st__bindgen_ty_1,
pub subresourceType: CUarraySparseSubresourceType,
pub subresource: CUarrayMapInfo_st__bindgen_ty_2,
pub memOperationType: CUmemOperationType,
pub memHandleType: CUmemHandleType,
pub memHandle: CUarrayMapInfo_st__bindgen_ty_3,
pub offset: ::core::ffi::c_ulonglong,
pub deviceBitMask: ::core::ffi::c_uint,
pub flags: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 2usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUarrayMapInfo_st__bindgen_ty_1 {
pub mipmap: CUmipmappedArray,
pub array: CUarray,
}
impl Default for CUarrayMapInfo_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUarrayMapInfo_st__bindgen_ty_2 {
pub sparseLevel: CUarrayMapInfo_st__bindgen_ty_2__bindgen_ty_1,
pub miptail: CUarrayMapInfo_st__bindgen_ty_2__bindgen_ty_2,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUarrayMapInfo_st__bindgen_ty_2__bindgen_ty_1 {
pub level: ::core::ffi::c_uint,
pub layer: ::core::ffi::c_uint,
pub offsetX: ::core::ffi::c_uint,
pub offsetY: ::core::ffi::c_uint,
pub offsetZ: ::core::ffi::c_uint,
pub extentWidth: ::core::ffi::c_uint,
pub extentHeight: ::core::ffi::c_uint,
pub extentDepth: ::core::ffi::c_uint,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUarrayMapInfo_st__bindgen_ty_2__bindgen_ty_2 {
pub layer: ::core::ffi::c_uint,
pub offset: ::core::ffi::c_ulonglong,
pub size: ::core::ffi::c_ulonglong,
}
impl Default for CUarrayMapInfo_st__bindgen_ty_2 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUarrayMapInfo_st__bindgen_ty_3 {
pub memHandle: CUmemGenericAllocationHandle,
}
impl Default for CUarrayMapInfo_st__bindgen_ty_3 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUarrayMapInfo_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Specifies the CUDA array or CUDA mipmapped array memory mapping information.
pub type CUarrayMapInfo_v1 = CUarrayMapInfo_st;
pub type CUarrayMapInfo = CUarrayMapInfo_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUmemLocation_st {
pub type_: CUmemLocationType,
pub __bindgen_anon_1: CUmemLocation_st__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUmemLocation_st__bindgen_ty_1 {
pub id: ::core::ffi::c_int,
}
impl Default for CUmemLocation_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUmemLocation_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Specifies a memory location.
pub type CUmemLocation_v1 = CUmemLocation_st;
pub type CUmemLocation = CUmemLocation_v1;
/// Specifies compression attribute for an allocation.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemAllocationCompType_enum {
/// Allocating non-compressible memory.
CU_MEM_ALLOCATION_COMP_NONE = 0,
/// Allocating compressible memory.
CU_MEM_ALLOCATION_COMP_GENERIC = 1,
}
pub use self::CUmemAllocationCompType_enum as CUmemAllocationCompType;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUmemAllocationProp_st {
pub type_: CUmemAllocationType,
pub requestedHandleTypes: CUmemAllocationHandleType,
pub location: CUmemLocation,
pub win32HandleMetaData: *mut ::core::ffi::c_void,
pub allocFlags: CUmemAllocationProp_st__bindgen_ty_1,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUmemAllocationProp_st__bindgen_ty_1 {
pub compressionType: ::core::ffi::c_uchar,
pub gpuDirectRDMACapable: ::core::ffi::c_uchar,
pub usage: ::core::ffi::c_ushort,
pub reserved: [::core::ffi::c_uchar; 4usize],
}
impl Default for CUmemAllocationProp_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Specifies the allocation properties for a allocation.
pub type CUmemAllocationProp_v1 = CUmemAllocationProp_st;
pub type CUmemAllocationProp = CUmemAllocationProp_v1;
/// Flags for querying different granularities for a multicast object.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmulticastGranularity_flags_enum {
/// Minimum required granularity.
CU_MULTICAST_GRANULARITY_MINIMUM = 0,
/// Recommended granularity for best performance.
CU_MULTICAST_GRANULARITY_RECOMMENDED = 1,
}
pub use self::CUmulticastGranularity_flags_enum as CUmulticastGranularity_flags;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUmulticastObjectProp_st {
pub numDevices: ::core::ffi::c_uint,
pub size: size_t,
pub handleTypes: ::core::ffi::c_ulonglong,
pub flags: ::core::ffi::c_ulonglong,
}
/// Specifies the properties for a multicast object.
pub type CUmulticastObjectProp_v1 = CUmulticastObjectProp_st;
pub type CUmulticastObjectProp = CUmulticastObjectProp_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUmemAccessDesc_st {
pub location: CUmemLocation,
pub flags: CUmemAccess_flags,
}
impl Default for CUmemAccessDesc_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Memory access descriptor.
pub type CUmemAccessDesc_v1 = CUmemAccessDesc_st;
pub type CUmemAccessDesc = CUmemAccessDesc_v1;
/// CUDA Graph Update error types.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphExecUpdateResult_enum {
/// The update succeeded.
CU_GRAPH_EXEC_UPDATE_SUCCESS = 0,
/// The update failed for an unexpected reason which is described in the return value of the function.
CU_GRAPH_EXEC_UPDATE_ERROR = 1,
/// The update failed because the topology changed.
CU_GRAPH_EXEC_UPDATE_ERROR_TOPOLOGY_CHANGED = 2,
/// The update failed because a node type changed.
CU_GRAPH_EXEC_UPDATE_ERROR_NODE_TYPE_CHANGED = 3,
/// The update failed because the function of a kernel node changed (CUDA driver < 11.2).
CU_GRAPH_EXEC_UPDATE_ERROR_FUNCTION_CHANGED = 4,
/// The update failed because the parameters changed in a way that is not supported.
CU_GRAPH_EXEC_UPDATE_ERROR_PARAMETERS_CHANGED = 5,
/// The update failed because something about the node is not supported.
CU_GRAPH_EXEC_UPDATE_ERROR_NOT_SUPPORTED = 6,
/// The update failed because the function of a kernel node changed in an unsupported way.
CU_GRAPH_EXEC_UPDATE_ERROR_UNSUPPORTED_FUNCTION_CHANGE = 7,
/// The update failed because the node attributes changed in a way that is not supported.
CU_GRAPH_EXEC_UPDATE_ERROR_ATTRIBUTES_CHANGED = 8,
}
pub use self::CUgraphExecUpdateResult_enum as CUgraphExecUpdateResult;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUgraphExecUpdateResultInfo_st {
pub result: CUgraphExecUpdateResult,
pub errorNode: CUgraphNode,
pub errorFromNode: CUgraphNode,
}
impl Default for CUgraphExecUpdateResultInfo_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Result information returned by cuGraphExecUpdate.
pub type CUgraphExecUpdateResultInfo_v1 = CUgraphExecUpdateResultInfo_st;
pub type CUgraphExecUpdateResultInfo = CUgraphExecUpdateResultInfo_v1;
/// CUDA memory pool attributes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemPool_attribute_enum {
/// (value type = int) Allow cuMemAllocAsync to use memory asynchronously freed in another streams as long as a stream ordering
/// dependency of the allocating stream on the free action exists. CUDA events and null stream interactions can create the required
/// stream ordered dependencies. (default enabled).
CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES = 1,
/// (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default
/// ```text
/// enabled)
/// ```
CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC = 2,
/// (value type = int) Allow cuMemAllocAsync to insert new stream dependencies in order to establish the stream ordering required
/// to reuse a piece of memory released by cuMemFreeAsync (default enabled).
CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES = 3,
/// (value type = cuuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS.
/// When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory
/// back to the OS on the next call to stream, event or context synchronize. (default 0).
CU_MEMPOOL_ATTR_RELEASE_THRESHOLD = 4,
/// (value type = cuuint64_t) Amount of backing memory currently allocated for the mempool.
CU_MEMPOOL_ATTR_RESERVED_MEM_CURRENT = 5,
/// (value type = cuuint64_t) High watermark of backing memory allocated for the mempool since the last time it was reset. High
/// watermark can only be reset to zero.
CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH = 6,
/// (value type = cuuint64_t) Amount of memory from the pool that is currently in use by the application.
CU_MEMPOOL_ATTR_USED_MEM_CURRENT = 7,
/// (value type = cuuint64_t) High watermark of the amount of memory from the pool that was in use by the application since the
/// last time it was reset. High watermark can only be reset to zero.
CU_MEMPOOL_ATTR_USED_MEM_HIGH = 8,
/// (value type = CUmemAllocationType) The allocation type of the mempool.
CU_MEMPOOL_ATTR_ALLOCATION_TYPE = 9,
/// (value type = CUmemAllocationHandleType) Available export handle types for the mempool. For imported pools this value is always
/// [`CUmemAllocationHandleType::CU_MEM_HANDLE_TYPE_NONE`] as an imported pool cannot be re-exported.
CU_MEMPOOL_ATTR_EXPORT_HANDLE_TYPES = 10,
/// (value type = int) The location id for the mempool. If the location type for this pool is [`CUmemLocationType::CU_MEM_LOCATION_TYPE_INVISIBLE`] then
/// ID will be CU_DEVICE_INVALID.
CU_MEMPOOL_ATTR_LOCATION_ID = 11,
/// (value type = CUmemLocationType) The location type for the mempool. For imported memory pools where the device is not directly
/// visible to the importing process or pools imported via fabric handles across nodes this will be [`CUmemLocationType::CU_MEM_LOCATION_TYPE_INVISIBLE`].
CU_MEMPOOL_ATTR_LOCATION_TYPE = 12,
/// (value type = cuuint64_t) Maximum size of the pool in bytes, this value may be higher than what was initially passed to cuMemPoolCreate
/// due to alignment requirements. A value of 0 indicates no maximum size. For [`CUmemAllocationType::CU_MEM_ALLOCATION_TYPE_MANAGED`] and IPC imported
/// pools this value will be system dependent.
CU_MEMPOOL_ATTR_MAX_POOL_SIZE = 13,
/// (value type = int) Indicates whether the pool has hardware compresssion enabled.
CU_MEMPOOL_ATTR_HW_DECOMPRESS_ENABLED = 14,
}
pub use self::CUmemPool_attribute_enum as CUmemPool_attribute;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUmemPoolProps_st {
pub allocType: CUmemAllocationType,
pub handleTypes: CUmemAllocationHandleType,
pub location: CUmemLocation,
pub win32SecurityAttributes: *mut ::core::ffi::c_void,
pub maxSize: size_t,
pub usage: ::core::ffi::c_ushort,
pub reserved: [::core::ffi::c_uchar; 54usize],
}
impl Default for CUmemPoolProps_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Specifies the properties of allocations made from the pool.
pub type CUmemPoolProps_v1 = CUmemPoolProps_st;
pub type CUmemPoolProps = CUmemPoolProps_v1;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUmemPoolPtrExportData_st {
pub reserved: [::core::ffi::c_uchar; 64usize],
}
impl Default for CUmemPoolPtrExportData_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Opaque data for exporting a pool allocation.
pub type CUmemPoolPtrExportData_v1 = CUmemPoolPtrExportData_st;
pub type CUmemPoolPtrExportData = CUmemPoolPtrExportData_v1;
/// Flags to specify for copies within a batch. For more details see [`cuMemcpyBatchAsync_v2`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemcpyFlags_enum {
CU_MEMCPY_FLAG_DEFAULT = 0,
/// Hint to the driver to try and overlap the copy with compute work on the SMs.
CU_MEMCPY_FLAG_PREFER_OVERLAP_WITH_COMPUTE = 1,
}
pub use self::CUmemcpyFlags_enum as CUmemcpyFlags;
/// These flags allow applications to convey the source access ordering CUDA must maintain. The destination will always be accessed
/// in stream order.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemcpySrcAccessOrder_enum {
/// Default invalid.
CU_MEMCPY_SRC_ACCESS_ORDER_INVALID = 0,
/// Indicates that access to the source pointer must be in stream order.
CU_MEMCPY_SRC_ACCESS_ORDER_STREAM = 1,
/// Indicates that access to the source pointer can be out of stream order and all accesses must be complete before the API call
/// returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations in the
/// stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source variable
/// was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to synchronize
/// the stream after the API call.
CU_MEMCPY_SRC_ACCESS_ORDER_DURING_API_CALL = 2,
/// Indicates that access to the source pointer can be out of stream order and the accesses can happen even after the API call
/// returns. This flag is suited for host pointers allocated outside CUDA (ex., via malloc) when it's known that no prior operations
/// in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain platforms.
CU_MEMCPY_SRC_ACCESS_ORDER_ANY = 3,
CU_MEMCPY_SRC_ACCESS_ORDER_MAX = 2147483647,
}
pub use self::CUmemcpySrcAccessOrder_enum as CUmemcpySrcAccessOrder;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUmemcpyAttributes_st {
pub srcAccessOrder: CUmemcpySrcAccessOrder,
pub srcLocHint: CUmemLocation,
pub dstLocHint: CUmemLocation,
pub flags: ::core::ffi::c_uint,
}
impl Default for CUmemcpyAttributes_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Attributes specific to copies within a batch. For more details on usage see [`cuMemcpyBatchAsync_v2`].
pub type CUmemcpyAttributes_v1 = CUmemcpyAttributes_st;
pub type CUmemcpyAttributes = CUmemcpyAttributes_v1;
/// These flags allow applications to convey the operand type for individual copies specified in [`cuMemcpy3DBatchAsync_v2`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmemcpy3DOperandType_enum {
/// Memcpy operand is a valid pointer.
CU_MEMCPY_OPERAND_TYPE_POINTER = 1,
/// Memcpy operand is a CUarray.
CU_MEMCPY_OPERAND_TYPE_ARRAY = 2,
CU_MEMCPY_OPERAND_TYPE_MAX = 2147483647,
}
pub use self::CUmemcpy3DOperandType_enum as CUmemcpy3DOperandType;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUoffset3D_st {
pub x: size_t,
pub y: size_t,
pub z: size_t,
}
/// Struct representing a 3D offset.
pub type CUoffset3D_v1 = CUoffset3D_st;
pub type CUoffset3D = CUoffset3D_v1;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUextent3D_st {
pub width: size_t,
pub height: size_t,
pub depth: size_t,
}
/// Struct representing width/height/depth of a CUarray in elements.
pub type CUextent3D_v1 = CUextent3D_st;
pub type CUextent3D = CUextent3D_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUmemcpy3DOperand_st {
pub type_: CUmemcpy3DOperandType,
pub op: CUmemcpy3DOperand_st__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUmemcpy3DOperand_st__bindgen_ty_1 {
pub ptr: CUmemcpy3DOperand_st__bindgen_ty_1__bindgen_ty_1,
pub array: CUmemcpy3DOperand_st__bindgen_ty_1__bindgen_ty_2,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUmemcpy3DOperand_st__bindgen_ty_1__bindgen_ty_1 {
pub ptr: CUdeviceptr,
pub rowLength: size_t,
pub layerHeight: size_t,
pub locHint: CUmemLocation,
}
impl Default for CUmemcpy3DOperand_st__bindgen_ty_1__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUmemcpy3DOperand_st__bindgen_ty_1__bindgen_ty_2 {
pub array: CUarray,
pub offset: CUoffset3D,
}
impl Default for CUmemcpy3DOperand_st__bindgen_ty_1__bindgen_ty_2 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUmemcpy3DOperand_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUmemcpy3DOperand_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Struct representing an operand for copy with [`cuMemcpy3DBatchAsync_v2`].
pub type CUmemcpy3DOperand_v1 = CUmemcpy3DOperand_st;
pub type CUmemcpy3DOperand = CUmemcpy3DOperand_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_MEMCPY3D_BATCH_OP_st {
pub src: CUmemcpy3DOperand,
pub dst: CUmemcpy3DOperand,
pub extent: CUextent3D,
pub srcAccessOrder: CUmemcpySrcAccessOrder,
pub flags: ::core::ffi::c_uint,
}
impl Default for CUDA_MEMCPY3D_BATCH_OP_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub type CUDA_MEMCPY3D_BATCH_OP_v1 = CUDA_MEMCPY3D_BATCH_OP_st;
pub type CUDA_MEMCPY3D_BATCH_OP = CUDA_MEMCPY3D_BATCH_OP_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_MEM_ALLOC_NODE_PARAMS_v1_st {
pub poolProps: CUmemPoolProps,
pub accessDescs: *const CUmemAccessDesc,
pub accessDescCount: size_t,
pub bytesize: size_t,
pub dptr: CUdeviceptr,
}
impl Default for CUDA_MEM_ALLOC_NODE_PARAMS_v1_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Memory allocation node parameters.
pub type CUDA_MEM_ALLOC_NODE_PARAMS_v1 = CUDA_MEM_ALLOC_NODE_PARAMS_v1_st;
pub type CUDA_MEM_ALLOC_NODE_PARAMS = CUDA_MEM_ALLOC_NODE_PARAMS_v1;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUDA_MEM_ALLOC_NODE_PARAMS_v2_st {
pub poolProps: CUmemPoolProps,
pub accessDescs: *const CUmemAccessDesc,
pub accessDescCount: size_t,
pub bytesize: size_t,
pub dptr: CUdeviceptr,
}
impl Default for CUDA_MEM_ALLOC_NODE_PARAMS_v2_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Memory allocation node parameters.
pub type CUDA_MEM_ALLOC_NODE_PARAMS_v2 = CUDA_MEM_ALLOC_NODE_PARAMS_v2_st;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_MEM_FREE_NODE_PARAMS_st {
pub dptr: CUdeviceptr,
}
/// Memory free node parameters.
pub type CUDA_MEM_FREE_NODE_PARAMS = CUDA_MEM_FREE_NODE_PARAMS_st;
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphMem_attribute_enum {
CU_GRAPH_MEM_ATTR_USED_MEM_CURRENT = 0,
CU_GRAPH_MEM_ATTR_USED_MEM_HIGH = 1,
CU_GRAPH_MEM_ATTR_RESERVED_MEM_CURRENT = 2,
CU_GRAPH_MEM_ATTR_RESERVED_MEM_HIGH = 3,
}
pub use self::CUgraphMem_attribute_enum as CUgraphMem_attribute;
/// Child graph node ownership.
#[repr(i32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUgraphChildGraphNodeOwnership_enum {
/// Default behavior for a child graph node. Child graph is cloned into the parent and memory allocation/free nodes can't be present
/// in the child graph.
CU_GRAPH_CHILD_GRAPH_OWNERSHIP_CLONE = 0,
/// The child graph is moved to the parent. The handle to the child graph is owned by the parent and will be destroyed when the
/// ```text
/// parent is destroyed.The following restrictions apply to child graphs after they have been moved: Cannot be independently instantiated
/// or destroyed; Cannot be added as a child graph of a separate parent graph; Cannot be used as an argument to cuGraphExecUpdate;
/// Cannot have additional memory allocation or free nodes added.
/// ```
CU_GRAPH_CHILD_GRAPH_OWNERSHIP_MOVE = 1,
/// Invalid ownership flag. Set when params are queried to prevent accidentally reusing the driver-owned graph object.
CU_GRAPH_CHILD_GRAPH_OWNERSHIP_INVALID = -1,
}
pub use self::CUgraphChildGraphNodeOwnership_enum as CUgraphChildGraphNodeOwnership;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_CHILD_GRAPH_NODE_PARAMS_st {
pub graph: CUgraph,
pub ownership: CUgraphChildGraphNodeOwnership,
}
impl Default for CUDA_CHILD_GRAPH_NODE_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Child graph node parameters.
pub type CUDA_CHILD_GRAPH_NODE_PARAMS = CUDA_CHILD_GRAPH_NODE_PARAMS_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EVENT_RECORD_NODE_PARAMS_st {
pub event: CUevent,
}
impl Default for CUDA_EVENT_RECORD_NODE_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Event record node parameters.
pub type CUDA_EVENT_RECORD_NODE_PARAMS = CUDA_EVENT_RECORD_NODE_PARAMS_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUDA_EVENT_WAIT_NODE_PARAMS_st {
pub event: CUevent,
}
impl Default for CUDA_EVENT_WAIT_NODE_PARAMS_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Event wait node parameters.
pub type CUDA_EVENT_WAIT_NODE_PARAMS = CUDA_EVENT_WAIT_NODE_PARAMS_st;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUgraphNodeParams_st {
pub type_: CUgraphNodeType,
pub reserved0: [::core::ffi::c_int; 3usize],
pub __bindgen_anon_1: CUgraphNodeParams_st__bindgen_ty_1,
pub reserved2: ::core::ffi::c_longlong,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUgraphNodeParams_st__bindgen_ty_1 {
pub reserved1: [::core::ffi::c_longlong; 29usize],
pub kernel: CUDA_KERNEL_NODE_PARAMS_v3,
pub memcpy: CUDA_MEMCPY_NODE_PARAMS,
pub memset: CUDA_MEMSET_NODE_PARAMS_v2,
pub host: CUDA_HOST_NODE_PARAMS_v2,
pub graph: CUDA_CHILD_GRAPH_NODE_PARAMS,
pub eventWait: CUDA_EVENT_WAIT_NODE_PARAMS,
pub eventRecord: CUDA_EVENT_RECORD_NODE_PARAMS,
pub extSemSignal: CUDA_EXT_SEM_SIGNAL_NODE_PARAMS_v2,
pub extSemWait: CUDA_EXT_SEM_WAIT_NODE_PARAMS_v2,
pub alloc: CUDA_MEM_ALLOC_NODE_PARAMS_v2,
pub free: CUDA_MEM_FREE_NODE_PARAMS,
pub memOp: CUDA_BATCH_MEM_OP_NODE_PARAMS_v2,
pub conditional: CUDA_CONDITIONAL_NODE_PARAMS,
}
impl Default for CUgraphNodeParams_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUgraphNodeParams_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Graph node parameters. See [`cuGraphAddNode_v2`].
pub type CUgraphNodeParams = CUgraphNodeParams_st;
/// Bitmasks for CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_FLUSH_WRITES_OPTIONS.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUflushGPUDirectRDMAWritesOptions_enum {
/// [`cuFlushGPUDirectRDMAWrites`] and its CUDA Runtime API counterpart are supported on the device.
CU_FLUSH_GPU_DIRECT_RDMA_WRITES_OPTION_HOST = 1,
/// The CU_STREAM_WAIT_VALUE_FLUSH flag and the CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES MemOp are supported on the device.
CU_FLUSH_GPU_DIRECT_RDMA_WRITES_OPTION_MEMOPS = 2,
}
pub use self::CUflushGPUDirectRDMAWritesOptions_enum as CUflushGPUDirectRDMAWritesOptions;
/// Platform native ordering for GPUDirect RDMA writes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUGPUDirectRDMAWritesOrdering_enum {
/// The device does not natively support ordering of remote writes. [`cuFlushGPUDirectRDMAWrites`] can be leveraged if supported.
CU_GPU_DIRECT_RDMA_WRITES_ORDERING_NONE = 0,
/// Natively, the device can consistently consume remote writes, although other CUDA devices may not.
CU_GPU_DIRECT_RDMA_WRITES_ORDERING_OWNER = 100,
/// Any CUDA device in the system can consistently consume remote writes to this device.
CU_GPU_DIRECT_RDMA_WRITES_ORDERING_ALL_DEVICES = 200,
}
pub use self::CUGPUDirectRDMAWritesOrdering_enum as CUGPUDirectRDMAWritesOrdering;
/// The scopes for [`cuFlushGPUDirectRDMAWrites`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUflushGPUDirectRDMAWritesScope_enum {
/// Blocks until remote writes are visible to the CUDA device context owning the data.
CU_FLUSH_GPU_DIRECT_RDMA_WRITES_TO_OWNER = 100,
/// Blocks until remote writes are visible to all CUDA device contexts.
CU_FLUSH_GPU_DIRECT_RDMA_WRITES_TO_ALL_DEVICES = 200,
}
pub use self::CUflushGPUDirectRDMAWritesScope_enum as CUflushGPUDirectRDMAWritesScope;
/// The targets for [`cuFlushGPUDirectRDMAWrites`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUflushGPUDirectRDMAWritesTarget_enum {
/// Sets the target for [`cuFlushGPUDirectRDMAWrites`] to the currently active CUDA device context.
CU_FLUSH_GPU_DIRECT_RDMA_WRITES_TARGET_CURRENT_CTX = 0,
}
pub use self::CUflushGPUDirectRDMAWritesTarget_enum as CUflushGPUDirectRDMAWritesTarget;
/// The additional write options for [`cuGraphDebugDotPrint`].
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphDebugDot_flags_enum {
/// Output all debug data as if every debug flag is enabled.
CU_GRAPH_DEBUG_DOT_FLAGS_VERBOSE = 1,
/// Use CUDA Runtime structures for output.
CU_GRAPH_DEBUG_DOT_FLAGS_RUNTIME_TYPES = 2,
/// Adds CUDA_KERNEL_NODE_PARAMS values to output.
CU_GRAPH_DEBUG_DOT_FLAGS_KERNEL_NODE_PARAMS = 4,
/// Adds CUDA_MEMCPY3D values to output.
CU_GRAPH_DEBUG_DOT_FLAGS_MEMCPY_NODE_PARAMS = 8,
/// Adds CUDA_MEMSET_NODE_PARAMS values to output.
CU_GRAPH_DEBUG_DOT_FLAGS_MEMSET_NODE_PARAMS = 16,
/// Adds CUDA_HOST_NODE_PARAMS values to output.
CU_GRAPH_DEBUG_DOT_FLAGS_HOST_NODE_PARAMS = 32,
/// Adds CUevent handle from record and wait nodes to output.
CU_GRAPH_DEBUG_DOT_FLAGS_EVENT_NODE_PARAMS = 64,
/// Adds CUDA_EXT_SEM_SIGNAL_NODE_PARAMS values to output.
CU_GRAPH_DEBUG_DOT_FLAGS_EXT_SEMAS_SIGNAL_NODE_PARAMS = 128,
/// Adds CUDA_EXT_SEM_WAIT_NODE_PARAMS values to output.
CU_GRAPH_DEBUG_DOT_FLAGS_EXT_SEMAS_WAIT_NODE_PARAMS = 256,
/// Adds CUkernelNodeAttrValue values to output.
CU_GRAPH_DEBUG_DOT_FLAGS_KERNEL_NODE_ATTRIBUTES = 512,
/// Adds node handles and every kernel function handle to output.
CU_GRAPH_DEBUG_DOT_FLAGS_HANDLES = 1024,
/// Adds memory alloc node parameters to output.
CU_GRAPH_DEBUG_DOT_FLAGS_MEM_ALLOC_NODE_PARAMS = 2048,
/// Adds memory free node parameters to output.
CU_GRAPH_DEBUG_DOT_FLAGS_MEM_FREE_NODE_PARAMS = 4096,
/// Adds batch mem op node parameters to output.
CU_GRAPH_DEBUG_DOT_FLAGS_BATCH_MEM_OP_NODE_PARAMS = 8192,
/// Adds edge numbering information.
CU_GRAPH_DEBUG_DOT_FLAGS_EXTRA_TOPO_INFO = 16384,
/// Adds conditional node parameters to output.
CU_GRAPH_DEBUG_DOT_FLAGS_CONDITIONAL_NODE_PARAMS = 32768,
}
pub use self::CUgraphDebugDot_flags_enum as CUgraphDebugDot_flags;
/// Flags for user objects for graphs.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUuserObject_flags_enum {
/// Indicates the destructor execution is not synchronized by any CUDA handle.
CU_USER_OBJECT_NO_DESTRUCTOR_SYNC = 1,
}
pub use self::CUuserObject_flags_enum as CUuserObject_flags;
/// Flags for retaining user object references for graphs.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUuserObjectRetain_flags_enum {
/// Transfer references from the caller rather than creating new references.
CU_GRAPH_USER_OBJECT_MOVE = 1,
}
pub use self::CUuserObjectRetain_flags_enum as CUuserObjectRetain_flags;
/// Flags for instantiating a graph.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgraphInstantiate_flags_enum {
/// Automatically free memory allocated in a graph before relaunching.
CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH = 1,
/// Automatically upload the graph after instantiation. Only supported by [`cuGraphInstantiateWithParams`]. The upload will be performed using the stream provided in instantiateParams.
CUDA_GRAPH_INSTANTIATE_FLAG_UPLOAD = 2,
/// Instantiate the graph to be launchable from the device. This flag can only be used on platforms which support unified addressing.
/// This flag cannot be used in conjunction with [`CUgraphInstantiate_flags::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH`].
CUDA_GRAPH_INSTANTIATE_FLAG_DEVICE_LAUNCH = 4,
/// Run the graph using the per-node priority attributes rather than the priority of the stream it is launched into.
CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY = 8,
}
pub use self::CUgraphInstantiate_flags_enum as CUgraphInstantiate_flags;
/// CUDA device NUMA configuration.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUdeviceNumaConfig_enum {
/// The GPU is not a NUMA node.
CU_DEVICE_NUMA_CONFIG_NONE = 0,
/// The GPU is a NUMA node, [`CUdevice_attribute::CU_DEVICE_ATTRIBUTE_NUMA_ID`] contains its NUMA ID.
CU_DEVICE_NUMA_CONFIG_NUMA_NODE = 1,
}
pub use self::CUdeviceNumaConfig_enum as CUdeviceNumaConfig;
/// CUDA Process States.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUprocessState_enum {
/// Default process state.
CU_PROCESS_STATE_RUNNING = 0,
/// CUDA API locks are taken so further CUDA API calls will block.
CU_PROCESS_STATE_LOCKED = 1,
/// Application memory contents have been checkpointed and underlying allocations and device handles have been released.
CU_PROCESS_STATE_CHECKPOINTED = 2,
/// Application entered an uncorrectable error during the checkpoint/restore process.
CU_PROCESS_STATE_FAILED = 3,
}
pub use self::CUprocessState_enum as CUprocessState;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUcheckpointLockArgs_st {
pub timeoutMs: ::core::ffi::c_uint,
pub reserved0: ::core::ffi::c_uint,
pub reserved1: [cuuint64_t; 7usize],
}
/// CUDA checkpoint optional lock arguments.
pub type CUcheckpointLockArgs = CUcheckpointLockArgs_st;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUcheckpointCheckpointArgs_st {
pub reserved: [cuuint64_t; 8usize],
}
/// CUDA checkpoint optional checkpoint arguments.
pub type CUcheckpointCheckpointArgs = CUcheckpointCheckpointArgs_st;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUcheckpointGpuPair_st {
pub oldUuid: CUuuid,
pub newUuid: CUuuid,
}
/// CUDA checkpoint GPU UUID pairs for device remapping during restore.
pub type CUcheckpointGpuPair = CUcheckpointGpuPair_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUcheckpointRestoreArgs_st {
pub gpuPairs: *mut CUcheckpointGpuPair,
pub gpuPairsCount: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_char; 44usize],
pub reserved1: cuuint64_t,
}
impl Default for CUcheckpointRestoreArgs_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// CUDA checkpoint optional restore arguments.
pub type CUcheckpointRestoreArgs = CUcheckpointRestoreArgs_st;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUcheckpointUnlockArgs_st {
pub reserved: [cuuint64_t; 8usize],
}
/// CUDA checkpoint optional unlock arguments.
pub type CUcheckpointUnlockArgs = CUcheckpointUnlockArgs_st;
unsafe extern "C" {
/// Gets the string description of an error code.
///
/// Sets \*pStr to the address of a NULL-terminated string description of the error code error. If the error code is not recognized, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] will be returned and \*pStr will be set to the NULL address.
///
/// **See also:**
///
/// `CUresult`, [cudaGetErrorString](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__ERROR.html#group__CUDART__ERROR_1g4bc9e35a618dfd0877c29c8ee45148f1).
///
/// # Parameters
///
/// - `error`: Error code to convert to string.
/// - `pStr`: Address of the string pointer.
pub fn cuGetErrorString(
error: CUresult,
pStr: *mut *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Gets the string representation of an error code enum name.
///
/// Sets \*pStr to the address of a NULL-terminated string representation of the name of the enum error code error. If the error code is not recognized, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] will be returned and \*pStr will be set to the NULL address.
///
/// **See also:**
///
/// `CUresult`, [cudaGetErrorName](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__ERROR.html#group__CUDART__ERROR_1gb3de7da2f23736878270026dcfc70075).
///
/// # Parameters
///
/// - `error`: Error code to convert to string.
/// - `pStr`: Address of the string pointer.
pub fn cuGetErrorName(
error: CUresult,
pStr: *mut *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Initialize the CUDA driver API Initializes the driver API and must be called before any other function from the driver API
/// in the current process. Currently, the Flags parameter must be 0. If cuInit() has not been called, any function from the driver API will return [`CUresult::CUDA_ERROR_NOT_INITIALIZED`].
///
/// Note: cuInit preloads various libraries needed for JIT compilation. To opt-out of this behavior, set the environment variable
/// CUDA_FORCE_PRELOAD_LIBRARIES=0. CUDA will lazily load JIT libraries as needed. To disable JIT entirely, set the environment
/// variable CUDA_DISABLE_JIT=1.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `Flags`: Initialization flag for CUDA.
pub fn cuInit(Flags: ::core::ffi::c_uint) -> CUresult;
}
unsafe extern "C" {
/// Returns the latest CUDA version supported by driver.
///
/// Returns in \*driverVersion the version of CUDA supported by the driver. The version is returned as (1000 \* major + 10 \* minor). For example, CUDA 9.2
/// would be represented by 9020.
///
/// This function automatically returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] if driverVersion is NULL.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaDriverGetVersion](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART____VERSION.html#group__CUDART____VERSION_1g8a06ee14a0551606b7c780084d5564ab), [cudaRuntimeGetVersion](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART____VERSION.html#group__CUDART____VERSION_1g0e3952c7802fd730432180f1f4a6cdc6).
///
/// # Parameters
///
/// - `driverVersion`: Returns the CUDA driver version.
pub fn cuDriverGetVersion(driverVersion: *mut ::core::ffi::c_int) -> CUresult;
}
unsafe extern "C" {
/// Returns a handle to a compute device.
///
/// Returns in \*device a device handle given an ordinal in the range **0, \[cuDeviceGetCount()-1\]**.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetCount`], [`cuDeviceGetName`], [`cuDeviceGetUuid_v2`], [`cuDeviceGetLuid`], [`cuDeviceTotalMem_v2`], [`cuDeviceGetExecAffinitySupport`].
///
/// # Parameters
///
/// - `device`: Returned device handle.
/// - `ordinal`: Device number to get handle for.
pub fn cuDeviceGet(device: *mut CUdevice, ordinal: ::core::ffi::c_int) -> CUresult;
}
unsafe extern "C" {
/// Returns the number of compute-capable devices.
///
/// Returns in \*count the number of devices with compute capability greater than or equal to 2.0 that are available for execution. If there is
/// no such device, [`cuDeviceGetCount`] returns 0.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetName`], [`cuDeviceGetUuid_v2`], [`cuDeviceGetLuid`], [`cuDeviceGet`], [`cuDeviceTotalMem_v2`], [`cuDeviceGetExecAffinitySupport`], [cudaGetDeviceCount](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g18808e54893cfcaafefeab31a73cc55f).
///
/// # Parameters
///
/// - `count`: Returned number of compute-capable devices.
pub fn cuDeviceGetCount(count: *mut ::core::ffi::c_int) -> CUresult;
}
unsafe extern "C" {
/// Returns an identifier string for the device.
///
/// Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by name. len specifies the maximum length of the string that may be returned. name is shortened to the specified len, if len is less than the device name
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetUuid_v2`], [`cuDeviceGetLuid`], [`cuDeviceGetCount`], [`cuDeviceGet`], [`cuDeviceTotalMem_v2`], [`cuDeviceGetExecAffinitySupport`], [cudaGetDeviceProperties](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g1bf9d625a931d657e08db2b4391170f0).
///
/// # Parameters
///
/// - `name`: Returned identifier string for the device.
/// - `len`: Maximum length of string to store in name.
/// - `dev`: Device to get identifier string for.
pub fn cuDeviceGetName(
name: *mut ::core::ffi::c_char,
len: ::core::ffi::c_int,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Return an UUID for the device.
///
/// Returns 16-octets identifying the device dev in the structure pointed by the uuid. If the device is in MIG mode, returns its MIG UUID which uniquely identifies the subscribed MIG compute instance.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetCount`], [`cuDeviceGetName`], [`cuDeviceGetLuid`], [`cuDeviceGet`], [`cuDeviceTotalMem_v2`], [cudaGetDeviceProperties](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g1bf9d625a931d657e08db2b4391170f0).
///
/// # Parameters
///
/// - `uuid`: Returned UUID.
/// - `dev`: Device to get identifier string for.
pub fn cuDeviceGetUuid_v2(uuid: *mut CUuuid, dev: CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Return an LUID and device node mask for the device.
///
/// Return identifying information (luid and deviceNodeMask) to allow matching device with graphics APIs.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetCount`], [`cuDeviceGetName`], [`cuDeviceGet`], [`cuDeviceTotalMem_v2`], [`cuDeviceGetExecAffinitySupport`], [cudaGetDeviceProperties](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g1bf9d625a931d657e08db2b4391170f0).
///
/// # Parameters
///
/// - `luid`: Returned LUID.
/// - `deviceNodeMask`: Returned device node mask.
/// - `dev`: Device to get identifier string for.
pub fn cuDeviceGetLuid(
luid: *mut ::core::ffi::c_char,
deviceNodeMask: *mut ::core::ffi::c_uint,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the total amount of memory on the device.
///
/// Returns in \*bytes the total amount of memory available on the device dev in bytes.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetCount`], [`cuDeviceGetName`], [`cuDeviceGetUuid_v2`], [`cuDeviceGet`], [`cuDeviceGetExecAffinitySupport`], [cudaMemGetInfo](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g376b97f5ab20321ca46f7cfa9511b978).
///
/// # Parameters
///
/// - `bytes`: Returned memory available on device in bytes.
/// - `dev`: Device handle.
pub fn cuDeviceTotalMem_v2(bytes: *mut size_t, dev: CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Returns the maximum number of elements allocatable in a 1D linear texture for a given texture element size.
///
/// Returns in maxWidthInElements the maximum number of texture elements allocatable in a 1D linear texture for given format and numChannels.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetCount`], [`cuDeviceGetName`], [`cuDeviceGetUuid_v2`], [`cuDeviceGet`], [cudaMemGetInfo](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g376b97f5ab20321ca46f7cfa9511b978), [`cuDeviceTotalMem_v2`].
///
/// # Parameters
///
/// - `maxWidthInElements`: Returned maximum number of texture elements allocatable for given format and numChannels.
/// - `format`: Texture format.
/// - `numChannels`: Number of channels per texture element.
/// - `dev`: Device handle.
pub fn cuDeviceGetTexture1DLinearMaxWidth(
maxWidthInElements: *mut size_t,
format: CUarray_format,
numChannels: ::core::ffi::c_uint,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Returns information about the device.
///
/// Returns in \*pi the integer value of the attribute attrib on device dev.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetCount`], [`cuDeviceGetName`], [`cuDeviceGetUuid_v2`], [`cuDeviceGet`], [`cuDeviceTotalMem_v2`], [`cuDeviceGetExecAffinitySupport`], [cudaDeviceGetAttribute](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gb22e8256592b836df9a9cc36c9db7151), [cudaGetDeviceProperties](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g1bf9d625a931d657e08db2b4391170f0).
///
/// # Parameters
///
/// - `pi`: Returned device attribute value.
/// - `attrib`: Device attribute to query.
/// - `dev`: Device handle.
pub fn cuDeviceGetAttribute(
pi: *mut ::core::ffi::c_int,
attrib: CUdevice_attribute,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Queries details about atomic operations supported between the device and host.
///
/// Returns in \*capabilities the details about requested atomic \*operations over the link between dev and the host. The allocated size of \*operations and \*capabilities must be count.
///
/// For each `CUatomicOperation` in \*operations, the corresponding result in \*capabilities will be a bitmask indicating which of `CUatomicOperationCapability` the link supports natively.
///
/// Returns [`cudaError_enum::CUDA_ERROR_INVALID_DEVICE`] if dev is not valid.
///
/// Returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] if \*capabilities or \*operations is NULL, if count is 0, or if any of \*operations is not valid.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetP2PAtomicCapabilities`], cudaDeviceGeHostAtomicCapabilities.
///
/// # Parameters
///
/// - `capabilities`: Returned capability details of each requested operation.
/// - `operations`: Requested operations.
/// - `count`: Count of requested operations and size of capabilities.
/// - `dev`: Device handle.
pub fn cuDeviceGetHostAtomicCapabilities(
capabilities: *mut ::core::ffi::c_uint,
operations: *const CUatomicOperation,
count: ::core::ffi::c_uint,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Return NvSciSync attributes that this device can support.
///
/// Returns in nvSciSyncAttrList, the properties of NvSciSync that this CUDA device, dev can support. The returned nvSciSyncAttrList can be used to create an NvSciSync object that matches this device's capabilities.
///
/// If NvSciSyncAttrKey_RequiredPerm field in nvSciSyncAttrList is already set this API will return [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// The applications should set nvSciSyncAttrList to a valid NvSciSyncAttrList failing which this API will return [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`].
///
/// The flags controls how applications intends to use the NvSciSync created from the nvSciSyncAttrList. The valid flags are:
///
/// * [`CUDA_NVSCISYNC_ATTR_SIGNAL`], specifies that the applications intends to signal an NvSciSync on this CUDA device.
/// * [`CUDA_NVSCISYNC_ATTR_WAIT`], specifies that the applications intends to wait on an NvSciSync on this CUDA device.
///
/// At least one of these flags must be set, failing which the API returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]. Both the flags are orthogonal to one another: a developer may set both these flags that allows to set both wait and signal
/// specific attributes in the same nvSciSyncAttrList.
///
/// Note that this API updates the input nvSciSyncAttrList with values equivalent to the following public attribute key-values: NvSciSyncAttrKey_RequiredPerm is set to
///
/// * NvSciSyncAccessPerm_SignalOnly if [`CUDA_NVSCISYNC_ATTR_SIGNAL`] is set in flags.
/// * NvSciSyncAccessPerm_WaitOnly if [`CUDA_NVSCISYNC_ATTR_WAIT`] is set in flags.
/// * NvSciSyncAccessPerm_WaitSignal if both [`CUDA_NVSCISYNC_ATTR_WAIT`] and [`CUDA_NVSCISYNC_ATTR_SIGNAL`] are set in flags. NvSciSyncAttrKey_PrimitiveInfo is set to
/// * NvSciSyncAttrValPrimitiveType_SysmemSemaphore on any valid device.
/// * NvSciSyncAttrValPrimitiveType_Syncpoint if device is a Tegra device.
/// * NvSciSyncAttrValPrimitiveType_SysmemSemaphorePayload64b if device is GA10X+. NvSciSyncAttrKey_GpuId is set to the same UUID that is returned for this device from [`cuDeviceGetUuid_v2`].
///
/// [`cudaError_enum::CUDA_SUCCESS`], [`cudaError_enum::CUDA_ERROR_DEINITIALIZED`], [`cudaError_enum::CUDA_ERROR_NOT_INITIALIZED`], [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`], [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`], [`cudaError_enum::CUDA_ERROR_INVALID_DEVICE`], [`cudaError_enum::CUDA_ERROR_NOT_SUPPORTED`], [`cudaError_enum::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// **See also:**
///
/// [`cuImportExternalSemaphore`], [`cuDestroyExternalSemaphore`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`].
///
/// # Parameters
///
/// - `nvSciSyncAttrList`: Return NvSciSync attributes supported.
/// - `dev`: Valid CUDA Device to get NvSciSync attributes for.
/// - `flags`: flags describing NvSciSync usage.
pub fn cuDeviceGetNvSciSyncAttributes(
nvSciSyncAttrList: *mut ::core::ffi::c_void,
dev: CUdevice,
flags: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the current memory pool of a device.
///
/// The memory pool must be local to the specified device. [`cuMemAllocAsync`] allocates from the current mempool of the provided stream's device. By default, a device's current memory pool is its default
/// memory pool.
///
/// Note:
///
/// Use [`cuMemAllocFromPoolAsync`] to specify asynchronous allocations from a device different than the one the stream runs on.
///
/// **See also:**
///
/// [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`], [`cuMemPoolDestroy`], [`cuMemAllocFromPoolAsync`].
pub fn cuDeviceSetMemPool(dev: CUdevice, pool: CUmemoryPool) -> CUresult;
}
unsafe extern "C" {
/// Gets the current mempool for a device.
///
/// Returns the last pool provided to [`cuDeviceSetMemPool`] for this device or the device's default memory pool if [`cuDeviceSetMemPool`] has never been called. By default the current mempool is the default mempool for a device. Otherwise the returned pool must
/// have been set with [`cuDeviceSetMemPool`].
///
/// **See also:**
///
/// [`cuDeviceGetDefaultMemPool`], [`cuMemPoolCreate`], [`cuDeviceSetMemPool`].
pub fn cuDeviceGetMemPool(pool: *mut CUmemoryPool, dev: CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Returns the default mempool of a device.
///
/// The default mempool of a device contains device memory from that device.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMemAllocAsync`], [`cuMemPoolTrimTo`], [`cuMemPoolGetAttribute`], [`cuMemPoolSetAttribute`], [`cuMemPoolSetAccess`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`].
pub fn cuDeviceGetDefaultMemPool(
pool_out: *mut CUmemoryPool,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Returns information about the execution affinity support of the device.
///
/// Returns in \*pi whether execution affinity type type is supported by device dev. The supported types are:
///
/// * [`CUexecAffinityType_enum::CU_EXEC_AFFINITY_TYPE_SM_COUNT`]: 1 if context with limited SMs is supported by the device, or 0 if not;
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetCount`], [`cuDeviceGetName`], [`cuDeviceGetUuid_v2`], [`cuDeviceGet`], [`cuDeviceTotalMem_v2`].
///
/// # Parameters
///
/// - `pi`: 1 if the execution affinity type type is supported by the device, or 0 if not.
/// - `dev`: Device handle.
pub fn cuDeviceGetExecAffinitySupport(
pi: *mut ::core::ffi::c_int,
type_: CUexecAffinityType,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Blocks until remote writes are visible to the specified scope.
///
/// Blocks until GPUDirect RDMA writes to the target context via mappings created through APIs like nvidia_p2p_get_pages (see
/// <https://docs.nvidia.com/cuda/gpudirect-rdma> for more information), are visible to the specified scope.
///
/// If the scope equals or lies within the scope indicated by [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WRITES_ORDERING`], the call will be a no-op and can be safely omitted for performance. This can be determined by comparing the numerical values
/// between the two enums, with smaller scopes having smaller values.
///
/// On platforms that support GPUDirect RDMA writes via more than one path in hardware (see [`CUmemRangeFlags_enum::CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE`]), the user should consider those paths as belonging to separate ordering domains. Note that in such cases CUDA driver will
/// report both RDMA writes ordering and RDMA write scope as ALL_DEVICES and a call to cuFlushGPUDirectRDMA will be a no-op, but
/// when these multiple paths are used simultaneously, it is the user's responsibility to ensure ordering by using mechanisms
/// outside the scope of CUDA.
///
/// Users may query support for this API via CU_DEVICE_ATTRIBUTE_FLUSH_FLUSH_GPU_DIRECT_RDMA_OPTIONS.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `target`: The target of the operation, see `CUflushGPUDirectRDMAWritesTarget`.
/// - `scope`: The scope of the operation, see `CUflushGPUDirectRDMAWritesScope`.
pub fn cuFlushGPUDirectRDMAWrites(
target: CUflushGPUDirectRDMAWritesTarget,
scope: CUflushGPUDirectRDMAWritesScope,
) -> CUresult;
}
unsafe extern "C" {
/// Returns properties for a selected device.
///
/// Returns in \*prop the properties of device dev. The CUdevprop structure is defined as:
///
/// ```text
/// typedef struct CUdevprop_st {
/// int maxThreadsPerBlock;
/// int maxThreadsDim\[3\];
/// int maxGridSize\[3\];
/// int sharedMemPerBlock;
/// int totalConstantMemory;
/// int SIMDWidth;
/// int memPitch;
/// int regsPerBlock;
/// int clockRate;
/// int textureAlign
/// } CUdevprop;
/// ```
///
/// * maxThreadsPerBlock is the maximum number of threads per block;
/// * maxThreadsDim\[3\] is the maximum sizes of each dimension of a block;
/// * maxGridSize\[3\] is the maximum sizes of each dimension of a grid;
/// * sharedMemPerBlock is the total amount of shared memory available per block in bytes;
/// * totalConstantMemory is the total amount of constant memory available on the device in bytes;
/// * SIMDWidth is the warp size;
/// * memPitch is the maximum pitch allowed by the memory copy functions that involve memory regions allocated through [`cuMemAllocPitch_v2`];
/// * regsPerBlock is the total number of registers available per block;
/// * clockRate is the clock frequency in kilohertz;
/// * textureAlign is the alignment requirement; texture base addresses that are aligned to textureAlign bytes do not need an offset
/// applied to texture fetches.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetCount`], [`cuDeviceGetName`], [`cuDeviceGetUuid_v2`], [`cuDeviceGet`], [`cuDeviceTotalMem_v2`].
///
/// # Parameters
///
/// - `prop`: Returned properties of device.
/// - `dev`: Device to get properties for.
#[deprecated]
pub fn cuDeviceGetProperties(prop: *mut CUdevprop, dev: CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Returns the compute capability of the device.
///
/// Returns in \*major and \*minor the major and minor revision numbers that define the compute capability of the device dev.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetAttribute`], [`cuDeviceGetCount`], [`cuDeviceGetName`], [`cuDeviceGetUuid_v2`], [`cuDeviceGet`], [`cuDeviceTotalMem_v2`].
///
/// # Parameters
///
/// - `major`: Major revision number.
/// - `minor`: Minor revision number.
/// - `dev`: Device handle.
#[deprecated]
pub fn cuDeviceComputeCapability(
major: *mut ::core::ffi::c_int,
minor: *mut ::core::ffi::c_int,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Retain the primary context on the GPU.
///
/// Retains the primary context on the device. Once the user successfully retains the primary context, the primary context will
/// be active and available to the user until the user releases it with [`cuDevicePrimaryCtxRelease_v2`] or resets it with [`cuDevicePrimaryCtxReset_v2`]. Unlike [`cuCtxCreate_v4`] the newly retained context is not pushed onto the stack.
///
/// Retaining the primary context for the first time will fail with [`cudaError_enum::CUDA_ERROR_UNKNOWN`] if the compute mode of the device is [`CUcomputemode_enum::CU_COMPUTEMODE_PROHIBITED`]. The function [`cuDeviceGetAttribute`] can be used with [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_COMPUTE_MODE`] to determine the compute mode of the device. The nvidia-smi tool can be used to set the compute mode for devices. Documentation
/// for nvidia-smi can be obtained by passing a -h option to it.
///
/// Please note that the primary context always supports pinned allocations. Other flags can be specified by [`cuDevicePrimaryCtxSetFlags_v2`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDevicePrimaryCtxRelease_v2`], [`cuDevicePrimaryCtxSetFlags_v2`], [`cuCtxCreate_v4`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`].
///
/// # Parameters
///
/// - `pctx`: Returned context handle of the new context.
/// - `dev`: Device for which primary context is requested.
pub fn cuDevicePrimaryCtxRetain(pctx: *mut CUcontext, dev: CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Release the primary context on the GPU.
///
/// Releases the primary context interop on the device. A retained context should always be released once the user is done using
/// it. The context is automatically reset once the last reference to it is released. This behavior is different when the primary
/// context was retained by the CUDA runtime from CUDA 4.0 and earlier. In this case, the primary context remains always active.
///
/// Releasing a primary context that has not been previously retained will fail with [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`].
///
/// Please note that unlike [`cuCtxDestroy_v2`] this method does not pop the context from stack in any circumstances.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDevicePrimaryCtxRetain`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`].
///
/// # Parameters
///
/// - `dev`: Device which primary context is released.
pub fn cuDevicePrimaryCtxRelease_v2(dev: CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Set flags for the primary context.
///
/// Sets the flags for the primary context on the device overwriting previously set ones.
///
/// The three LSBs of the flags parameter can be used to control how the OS thread, which owns the CUDA context at the time of an API call, interacts with
/// the OS scheduler when waiting for results from the GPU. Only one of the scheduling flags can be set when creating a context.
///
/// * [`CUctx_flags_enum::CU_CTX_SCHED_SPIN`]: Instruct CUDA to actively spin when waiting for results from the GPU. This can decrease latency when waiting for the GPU,
/// but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread.
///
/// * [`CUctx_flags_enum::CU_CTX_SCHED_YIELD`]: Instruct CUDA to yield its thread when waiting for results from the GPU. This can increase latency when waiting for the
/// GPU, but can increase the performance of CPU threads performing work in parallel with the GPU.
///
/// * [`CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC`]: Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work.
///
/// * [CU_CTX_BLOCKING_SYNC](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/types.html#group__CUDA__TYPES_1gg9f889e28a45a295b5c8ce13aa05f6cd4b5bf395cc60a8cbded4c329ae9430b91): Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work.
///
/// **Deprecated:** This flag was deprecated as of CUDA 4.0 and was replaced with [`CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC`].
///
/// * [`CUctx_flags_enum::CU_CTX_SCHED_AUTO`]: The default value if the flags parameter is zero, uses a heuristic based on the number of active CUDA contexts in the process C and the number of logical
/// processors in the system P. If C > P, then CUDA will yield to other OS threads when waiting for the GPU ([`CUctx_flags_enum::CU_CTX_SCHED_YIELD`]), otherwise CUDA will not yield while waiting for results and actively spin on the processor ([`CUctx_flags_enum::CU_CTX_SCHED_SPIN`]). Additionally, on Tegra devices, [`CUctx_flags_enum::CU_CTX_SCHED_AUTO`] uses a heuristic based on the power profile of the platform and may choose [`CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC`] for low-powered devices.
///
/// * [`CUctx_flags_enum::CU_CTX_LMEM_RESIZE_TO_MAX`]: Instruct CUDA to not reduce local memory after resizing local memory for a kernel. This can prevent thrashing by local memory
/// allocations when launching many kernels with high local memory usage at the cost of potentially increased memory usage.
///
/// **Deprecated:** This flag is deprecated and the behavior enabled by this flag is now the default and cannot be disabled.
///
/// * [`CUctx_flags_enum::CU_CTX_COREDUMP_ENABLE`]: If GPU coredumps have not been enabled globally with [`cuCoredumpSetAttributeGlobal`] or environment variables, this flag can be set during context creation to instruct CUDA to create a coredump if this context
/// raises an exception during execution. These environment variables are described in the CUDA-GDB user guide under the "GPU
/// core dump support" section. The initial settings will be taken from the global settings at the time of context creation. The
/// other settings that control coredump output can be modified by calling [`cuCoredumpSetAttribute`] from the created context after it becomes current.
///
/// * [`CUctx_flags_enum::CU_CTX_USER_COREDUMP_ENABLE`]: If user-triggered GPU coredumps have not been enabled globally with [`cuCoredumpSetAttributeGlobal`] or environment variables, this flag can be set during context creation to instruct CUDA to create a coredump if data is written
/// to a certain pipe that is present in the OS space. These environment variables are described in the CUDA-GDB user guide under
/// the "GPU core dump support" section. It is important to note that the pipe name \*must\* be set with [`cuCoredumpSetAttributeGlobal`] before creating the context if this flag is used. Setting this flag implies that [`CUctx_flags_enum::CU_CTX_COREDUMP_ENABLE`] is set. The initial settings will be taken from the global settings at the time of context creation. The other settings that
/// control coredump output can be modified by calling [`cuCoredumpSetAttribute`] from the created context after it becomes current.
///
/// * [`CUctx_flags_enum::CU_CTX_SYNC_MEMOPS`]: Ensures that synchronous memory operations initiated on this context will always synchronize. See further documentation
/// in the section titled "API Synchronization behavior" to learn more about cases when synchronous memory operations can exhibit
/// asynchronous behavior.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDevicePrimaryCtxRetain`], [`cuDevicePrimaryCtxGetState`], [`cuCtxCreate_v4`], [`cuCtxGetFlags`], [`cuCtxSetFlags`], [cudaSetDeviceFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g69e73c7dda3fc05306ae7c811a690fac).
///
/// # Parameters
///
/// - `dev`: Device for which the primary context flags are set.
/// - `flags`: New flags for the device.
pub fn cuDevicePrimaryCtxSetFlags_v2(
dev: CUdevice,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Get the state of the primary context.
///
/// Returns in \*flags the flags for the primary context of dev, and in \*active whether it is active. See [`cuDevicePrimaryCtxSetFlags_v2`] for flag values.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDevicePrimaryCtxSetFlags_v2`], [`cuCtxGetFlags`], [`cuCtxSetFlags`], [cudaGetDeviceFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gf830794caf068b71638c6182bba8f77a).
///
/// # Parameters
///
/// - `dev`: Device to get primary context flags for.
/// - `flags`: Pointer to store flags.
/// - `active`: Pointer to store context state; 0 = inactive, 1 = active.
pub fn cuDevicePrimaryCtxGetState(
dev: CUdevice,
flags: *mut ::core::ffi::c_uint,
active: *mut ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Destroy all allocations and reset all state on the primary context.
///
/// Explicitly destroys and cleans up all resources associated with the current device in the current process.
///
/// Note that it is responsibility of the calling function to ensure that no other module in the process is using the device any
/// more. For that reason it is recommended to use [`cuDevicePrimaryCtxRelease_v2`] in most cases. However it is safe for other modules to call [`cuDevicePrimaryCtxRelease_v2`] even after resetting the device. Resetting the primary context does not release it, an application that has retained the
/// primary context should explicitly release its usage.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDevicePrimaryCtxRetain`], [`cuDevicePrimaryCtxRelease_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`], [cudaDeviceReset](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gef69dd5c6d0206c2b8d099abac61f217).
///
/// # Parameters
///
/// - `dev`: Device for which primary context is destroyed.
pub fn cuDevicePrimaryCtxReset_v2(dev: CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Create a CUDA context.
///
/// Creates a new CUDA context and associates it with the calling thread. The flags parameter is described below. The context is created with a usage count of 1 and the caller of [`cuCtxCreate_v4`] must call [`cuCtxDestroy_v2`] when done using the context. If a context is already current to the thread, it is supplanted by the newly created context
/// and may be restored by a subsequent call to [`cuCtxPopCurrent_v2`].
///
/// A regular CUDA context can be created by setting ctxCreateParams to NULL.
///
/// A CUDA context can be created with execution affinity. The type and the amount of execution resource the context can use is
/// limited by paramsArray and numExecAffinityParams in execAffinity. The paramsArray is an array of CUexecAffinityParam and the numExecAffinityParams describes the size of the paramsArray. If two CUexecAffinityParam in the array have the same type, the latter execution affinity parameter overrides the former execution affinity parameter.
/// The supported execution affinity types are:
///
/// * [`CUexecAffinityType_enum::CU_EXEC_AFFINITY_TYPE_SM_COUNT`] limits the portion of SMs that the context can use. The portion of SMs is specified as the number of SMs via CUexecAffinitySmCount. This limit will be internally rounded up to the next hardware-supported amount. Hence, it is imperative to query the actual
/// execution affinity of the context via [`cuCtxGetExecAffinity`] after context creation. Currently, this attribute is only supported under Volta+ MPS.
///
/// A CUDA context can be created in CIG(CUDA in Graphics) mode by setting cigParams. Data from graphics client is shared with CUDA via the sharedData in cigParams. Support for D3D12 graphics client can be determined using [`cuDeviceGetAttribute`] with [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_D3D12_CIG_SUPPORTED`]. sharedData is a ID3D12CommandQueue handle. Support for Vulkan graphics client can be determined using [`cuDeviceGetAttribute`] with [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_VULKAN_CIG_SUPPORTED`]. sharedData is a Nvidia specific data blob populated by calling vkGetExternalComputeQueueDataNV(). execAffinityParams and cigParams are mutually exclusive and cannot both be non-NULL. Setting both to non-NULL values will result in undefined behavior. If
/// both execAffinityParams and cigParams are NULL, the context will be created as a regular CUDA context.
///
/// The three LSBs of the flags parameter can be used to control how the OS thread, which owns the CUDA context at the time of an API call, interacts with
/// the OS scheduler when waiting for results from the GPU. Only one of the scheduling flags can be set when creating a context.
///
/// * [`CUctx_flags_enum::CU_CTX_SCHED_SPIN`]: Instruct CUDA to actively spin when waiting for results from the GPU. This can decrease latency when waiting for the GPU,
/// but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread.
///
/// * [`CUctx_flags_enum::CU_CTX_SCHED_YIELD`]: Instruct CUDA to yield its thread when waiting for results from the GPU. This can increase latency when waiting for the
/// GPU, but can increase the performance of CPU threads performing work in parallel with the GPU.
///
/// * [`CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC`]: Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work.
///
/// * [CU_CTX_BLOCKING_SYNC](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/types.html#group__CUDA__TYPES_1gg9f889e28a45a295b5c8ce13aa05f6cd4b5bf395cc60a8cbded4c329ae9430b91): Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work.
///
/// **Deprecated:** This flag was deprecated as of CUDA 4.0 and was replaced with [`CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC`].
///
/// * [`CUctx_flags_enum::CU_CTX_SCHED_AUTO`]: The default value if the flags parameter is zero, uses a heuristic based on the number of active CUDA contexts in the process C and the number of logical
/// processors in the system P. If C > P, then CUDA will yield to other OS threads when waiting for the GPU ([`CUctx_flags_enum::CU_CTX_SCHED_YIELD`]), otherwise CUDA will not yield while waiting for results and actively spin on the processor ([`CUctx_flags_enum::CU_CTX_SCHED_SPIN`]). Additionally, on Tegra devices, [`CUctx_flags_enum::CU_CTX_SCHED_AUTO`] uses a heuristic based on the power profile of the platform and may choose [`CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC`] for low-powered devices.
///
/// * [`CUctx_flags_enum::CU_CTX_MAP_HOST`]: Instruct CUDA to support mapped pinned allocations. This flag must be set in order to allocate pinned host memory that is
/// accessible to the GPU.
///
/// * [`CUctx_flags_enum::CU_CTX_LMEM_RESIZE_TO_MAX`]: Instruct CUDA to not reduce local memory after resizing local memory for a kernel. This can prevent thrashing by local memory
/// allocations when launching many kernels with high local memory usage at the cost of potentially increased memory usage.
///
/// **Deprecated:** This flag is deprecated and the behavior enabled by this flag is now the default and cannot be disabled. Instead, the per-thread
/// stack size can be controlled with [`cuCtxSetLimit`].
///
/// * [`CUctx_flags_enum::CU_CTX_COREDUMP_ENABLE`]: If GPU coredumps have not been enabled globally with [`cuCoredumpSetAttributeGlobal`] or environment variables, this flag can be set during context creation to instruct CUDA to create a coredump if this context
/// raises an exception during execution. These environment variables are described in the CUDA-GDB user guide under the "GPU
/// core dump support" section. The initial attributes will be taken from the global attributes at the time of context creation.
/// The other attributes that control coredump output can be modified by calling [`cuCoredumpSetAttribute`] from the created context after it becomes current. This flag is not supported when CUDA context is created in CIG(CUDA in
/// Graphics) mode.
///
/// * [`CUctx_flags_enum::CU_CTX_USER_COREDUMP_ENABLE`]: If user-triggered GPU coredumps have not been enabled globally with [`cuCoredumpSetAttributeGlobal`] or environment variables, this flag can be set during context creation to instruct CUDA to create a coredump if data is written
/// to a certain pipe that is present in the OS space. These environment variables are described in the CUDA-GDB user guide under
/// the "GPU core dump support" section. It is important to note that the pipe name \*must\* be set with [`cuCoredumpSetAttributeGlobal`] before creating the context if this flag is used. Setting this flag implies that [`CUctx_flags_enum::CU_CTX_COREDUMP_ENABLE`] is set. The initial attributes will be taken from the global attributes at the time of context creation. The other attributes
/// that control coredump output can be modified by calling [`cuCoredumpSetAttribute`] from the created context after it becomes current. Setting this flag on any context creation is equivalent to setting the
/// [`CUcoredumpSettings::CU_COREDUMP_ENABLE_USER_TRIGGER`] attribute to true globally. This flag is not supported when CUDA context is created in CIG(CUDA in Graphics) mode.
///
/// * [`CUctx_flags_enum::CU_CTX_SYNC_MEMOPS`]: Ensures that synchronous memory operations initiated on this context will always synchronize. See further documentation
/// in the section titled "API Synchronization behavior" to learn more about cases when synchronous memory operations can exhibit
/// asynchronous behavior.
///
/// Context creation will fail with [`cudaError_enum::CUDA_ERROR_UNKNOWN`] if the compute mode of the device is [`CUcomputemode_enum::CU_COMPUTEMODE_PROHIBITED`]. The function [`cuDeviceGetAttribute`] can be used with [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_COMPUTE_MODE`] to determine the compute mode of the device. The nvidia-smi tool can be used to set the compute mode for \* devices. Documentation
/// for nvidia-smi can be obtained by passing a -h option to it.
///
/// Context creation will fail with [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] if invalid parameter was passed by client to create the CUDA context.
///
/// Context creation in CIG mode will fail with [`cudaError_enum::CUDA_ERROR_NOT_SUPPORTED`] if CIG is not supported by the device or the driver.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCoredumpSetAttributeGlobal`], [`cuCoredumpSetAttribute`], [`cuCtxSynchronize`][`cuCtxGetExecAffinity`],.
///
/// # Parameters
///
/// - `pctx`: Returned context handle of the new context.
/// - `ctxCreateParams`: Context creation parameters. Can be NULL to create a regular CUDA context. See [`CUctxCreateParams`] for details.
/// - `flags`: Context creation flags.
/// - `dev`: Device to create context on.
pub fn cuCtxCreate_v4(
pctx: *mut CUcontext,
ctxCreateParams: *mut CUctxCreateParams,
flags: ::core::ffi::c_uint,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Destroy a CUDA context.
///
/// Destroys the CUDA context specified by ctx. The context ctx will be destroyed regardless of how many threads it is current to. It is the responsibility of the calling function to ensure
/// that no API call issues using ctx while [`cuCtxDestroy_v2`] is executing.
///
/// Destroys and cleans up all resources associated with the context. It is the caller's responsibility to ensure that the context
/// or its resources are not accessed or passed in subsequent API calls and doing so will result in undefined behavior. These
/// resources include CUDA types [`CUmodule`], [`CUfunction`], [`CUstream`], [`CUevent`], [`CUarray`], [`CUmipmappedArray`], [`CUtexObject`], [`CUsurfObject`], [`CUtexref`], [`CUsurfref`], [`CUgraphicsResource`], CUlinkState, [`CUexternalMemory`] and [`CUexternalSemaphore`]. These resources also include memory allocations by [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocManaged`] and [`cuMemAllocPitch_v2`].
///
/// If ctx is current to the calling thread then ctx will also be popped from the current thread's context stack (as though [`cuCtxPopCurrent_v2`] were called). If ctx is current to other threads, then ctx will remain current to those threads, and attempting to access ctx from those threads will result in the error [`cudaError_enum::CUDA_ERROR_CONTEXT_IS_DESTROYED`].
///
/// Note:
///
/// [`cuCtxDestroy_v2`] will not destroy memory allocations by [`cuMemCreate`], [`cuMemAllocAsync`] and [`cuMemAllocFromPoolAsync`]. These memory allocations are not associated with any CUDA context and need to be destroyed explicitly.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`].
///
/// # Parameters
///
/// - `ctx`: Context to destroy.
pub fn cuCtxDestroy_v2(ctx: CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Pushes a context on the current CPU thread.
///
/// Pushes the given context ctx onto the CPU thread's stack of current contexts. The specified context becomes the CPU thread's current context, so all CUDA
/// functions that operate on the current context are affected.
///
/// The previous current context may be made current again by calling [`cuCtxDestroy_v2`] or [`cuCtxPopCurrent_v2`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`].
///
/// # Parameters
///
/// - `ctx`: Context to push.
pub fn cuCtxPushCurrent_v2(ctx: CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Pops the current CUDA context from the current CPU thread.
///
/// Pops the current CUDA context from the CPU thread and passes back the old context handle in \*pctx. That context may then be made current to a different CPU thread by calling [`cuCtxPushCurrent_v2`].
///
/// If a context was current to the CPU thread before [`cuCtxCreate_v4`] or [`cuCtxPushCurrent_v2`] was called, this function makes that context current to the CPU thread again.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`].
///
/// # Parameters
///
/// - `pctx`: Returned popped context handle.
pub fn cuCtxPopCurrent_v2(pctx: *mut CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Binds the specified CUDA context to the calling CPU thread.
///
/// Binds the specified CUDA context to the calling CPU thread. If ctx is NULL then the CUDA context previously bound to the calling CPU thread is unbound and [`cudaError_enum::CUDA_SUCCESS`] is returned.
///
/// If there exists a CUDA context stack on the calling CPU thread, this will replace the top of that stack with ctx. If ctx is NULL then this will be equivalent to popping the top of the calling CPU thread's CUDA context stack (or a no-op if the
/// calling CPU thread's CUDA context stack is empty).
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCurrent`], [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [cudaSetDevice](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g159587909ffa0791bbe4b40187a4c6bb).
///
/// # Parameters
///
/// - `ctx`: Context to bind to the calling CPU thread.
pub fn cuCtxSetCurrent(ctx: CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Returns the CUDA context bound to the calling CPU thread.
///
/// Returns in \*pctx the CUDA context bound to the calling CPU thread. If no context is bound to the calling CPU thread then \*pctx is set to NULL and [`cudaError_enum::CUDA_SUCCESS`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxSetCurrent`], [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [cudaGetDevice](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g80861db2ce7c29b6e8055af8ae01bc78).
///
/// # Parameters
///
/// - `pctx`: Returned context handle.
pub fn cuCtxGetCurrent(pctx: *mut CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Returns the device handle for the current context.
///
/// Returns in \*device the handle of the current context's device.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`], [cudaGetDevice](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g80861db2ce7c29b6e8055af8ae01bc78).
///
/// # Parameters
///
/// - `device`: Returned device handle for the current context.
pub fn cuCtxGetDevice(device: *mut CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Returns the device handle for the specified context.
///
/// Returns in \*device the handle of the specified context's device. If the specified context is NULL, the API will return the current context's
/// device.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCurrent`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`].
///
/// # Parameters
///
/// - `device`: Returned device handle for the specified context.
/// - `ctx`: Context for which to obtain the device.
pub fn cuCtxGetDevice_v2(device: *mut CUdevice, ctx: CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Returns the flags for the current context.
///
/// Returns in \*flags the flags of the current context. See [`cuCtxCreate_v4`] for flag values.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetCurrent`], [`cuCtxGetDevice`], [`cuCtxGetLimit`], [`cuCtxGetSharedMemConfig`], [`cuCtxGetStreamPriorityRange`], [`cuCtxSetFlags`], [cudaGetDeviceFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gf830794caf068b71638c6182bba8f77a).
///
/// # Parameters
///
/// - `flags`: Pointer to store flags of current context.
pub fn cuCtxGetFlags(flags: *mut ::core::ffi::c_uint) -> CUresult;
}
unsafe extern "C" {
/// Sets the flags for the current context.
///
/// Sets the flags for the current context overwriting previously set ones. See [`cuDevicePrimaryCtxSetFlags_v2`] for flag values.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetCurrent`], [`cuCtxGetDevice`], [`cuCtxGetLimit`], [`cuCtxGetSharedMemConfig`], [`cuCtxGetStreamPriorityRange`], [`cuCtxGetFlags`], [cudaGetDeviceFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gf830794caf068b71638c6182bba8f77a), [`cuDevicePrimaryCtxSetFlags_v2`],.
///
/// # Parameters
///
/// - `flags`: Flags to set on the current context.
pub fn cuCtxSetFlags(flags: ::core::ffi::c_uint) -> CUresult;
}
unsafe extern "C" {
/// Returns the unique Id associated with the context supplied.
///
/// Returns in ctxId the unique Id which is associated with a given context. The Id is unique for the life of the program for this instance of
/// CUDA. If context is supplied as NULL and there is one current, the Id of the current context is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPushCurrent_v2`].
///
/// # Parameters
///
/// - `ctx`: Context for which to obtain the Id.
/// - `ctxId`: Pointer to store the Id of the context.
pub fn cuCtxGetId(ctx: CUcontext, ctxId: *mut ::core::ffi::c_ulonglong) -> CUresult;
}
unsafe extern "C" {
/// Block for the current context's tasks to complete.
///
/// Blocks until the current context has completed all preceding requested tasks. If the current context is the primary context,
/// green contexts that have been created will also be synchronized. [`cuCtxSynchronize`] returns an error if one of the preceding tasks failed. If the context was created with the [`CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC`] flag, the CPU thread will block until the GPU context has finished its work.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [cudaDeviceSynchronize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g10e20b05a95f638a4071a655503df25d).
pub fn cuCtxSynchronize() -> CUresult;
}
unsafe extern "C" {
/// Block for the specified context's tasks to complete.
///
/// Blocks until the specified context has completed all preceding requested tasks. If the specified context is the primary context,
/// green contexts that have been created will also be synchronized. The API returns an error if one of the preceding tasks failed.
///
/// If the context was created with the [`CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC`] flag, the CPU thread will block until the GPU context has finished its work.
///
/// If the specified context is NULL, the API will operate on the current context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCurrent`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuGreenCtxCreate`], [`cuCtxFromGreenCtx`], [cudaDeviceSynchronize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g10e20b05a95f638a4071a655503df25d).
///
/// # Parameters
///
/// - `ctx`: Context to synchronize.
pub fn cuCtxSynchronize_v2(ctx: CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Set resource limits.
///
/// Setting limit to value is a request by the application to update the current limit maintained by the context. The driver is free to modify the requested
/// value to meet h/w requirements (this could be clamping to minimum or maximum values, rounding up to nearest element size,
/// etc). The application can use [`cuCtxGetLimit`] to find out exactly what the limit has been set to.
///
/// Setting each `CUlimit` has its own specific restrictions, so each is discussed here.
///
/// * [`CUlimit_enum::CU_LIMIT_STACK_SIZE`] controls the stack size in bytes of each GPU thread. The driver automatically increases the per-thread stack size for each
/// kernel launch as needed. This size isn't reset back to the original value after each launch. Setting this value will take
/// effect immediately, and if necessary, the device will block until all preceding requested tasks are complete.
///
/// * [`CUlimit_enum::CU_LIMIT_PRINTF_FIFO_SIZE`] controls the size in bytes of the FIFO used by the printf() device system call. Setting [`CUlimit_enum::CU_LIMIT_PRINTF_FIFO_SIZE`] must be performed before launching any kernel that uses the printf() device system call, otherwise [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] will be returned.
///
/// * [`CUlimit_enum::CU_LIMIT_MALLOC_HEAP_SIZE`] controls the size in bytes of the heap used by the malloc() and free() device system calls. Setting [`CUlimit_enum::CU_LIMIT_MALLOC_HEAP_SIZE`] must be performed before launching any kernel that uses the malloc() or free() device system calls, otherwise [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] will be returned.
///
/// * [`CUlimit_enum::CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH`] controls the maximum nesting depth of a grid at which a thread can safely call [cudaDeviceSynchronize()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g10e20b05a95f638a4071a655503df25d). Setting this limit must be performed before any launch of a kernel that uses the device runtime and calls [cudaDeviceSynchronize()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g10e20b05a95f638a4071a655503df25d) above the default sync depth, two levels of grids. Calls to [cudaDeviceSynchronize()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g10e20b05a95f638a4071a655503df25d) will fail with error code [cudaErrorSyncDepthExceeded](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038265dbf94c45903cd582cfc40f93a176a) if the limitation is violated. This limit can be set smaller than the default or up the maximum launch depth of 24. When
/// setting this limit, keep in mind that additional levels of sync depth require the driver to reserve large amounts of device
/// memory which can no longer be used for user allocations. If these reservations of device memory fail, [`cuCtxSetLimit`] will return [`cudaError_enum::CUDA_ERROR_OUT_OF_MEMORY`], and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability < 9.0. Attempting
/// to set this limit on devices of other compute capability versions will result in the error [`cudaError_enum::CUDA_ERROR_UNSUPPORTED_LIMIT`] being returned.
///
/// * [`CUlimit_enum::CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT`] controls the maximum number of outstanding device runtime launches that can be made from the current context. A grid is outstanding
/// from the point of launch up until the grid is known to have been completed. Device runtime launches which violate this limitation
/// fail and return [cudaErrorLaunchPendingCountExceeded](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382372902b9ffd65825d138e16125b1376) when [cudaGetLastError()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__ERROR.html#group__CUDART__ERROR_1g3529f94cb530a83a76613616782bd233) is called after launch. If more pending launches than the default (2048 launches) are needed for a module using the device
/// runtime, this limit can be increased. Keep in mind that being able to sustain additional pending launches will require the
/// driver to reserve larger amounts of device memory upfront which can no longer be used for allocations. If these reservations
/// fail, [`cuCtxSetLimit`] will return [`cudaError_enum::CUDA_ERROR_OUT_OF_MEMORY`], and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability 3.5 and higher.
/// Attempting to set this limit on devices of compute capability less than 3.5 will result in the error [`cudaError_enum::CUDA_ERROR_UNSUPPORTED_LIMIT`] being returned.
///
/// * [`CUlimit_enum::CU_LIMIT_MAX_L2_FETCH_GRANULARITY`] controls the L2 cache fetch granularity. Values can range from 0B to 128B. This is purely a performance hint and it can be
/// ignored or clamped depending on the platform.
///
/// * [`CUlimit_enum::CU_LIMIT_PERSISTING_L2_CACHE_SIZE`] controls size in bytes available for persisting L2 cache. This is purely a performance hint and it can be ignored or clamped
/// depending on the platform.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSynchronize`], [cudaDeviceSetLimit](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g05956f16eaa47ef3a4efee84563ccb7d).
///
/// # Parameters
///
/// - `limit`: Limit to set.
/// - `value`: Size of limit.
pub fn cuCtxSetLimit(limit: CUlimit, value: size_t) -> CUresult;
}
unsafe extern "C" {
/// Returns resource limits.
///
/// Returns in \*pvalue the current size of limit. The supported `CUlimit` values are:
///
/// * [`CUlimit_enum::CU_LIMIT_STACK_SIZE`]: stack size in bytes of each GPU thread.
/// * [`CUlimit_enum::CU_LIMIT_PRINTF_FIFO_SIZE`]: size in bytes of the FIFO used by the printf() device system call.
/// * [`CUlimit_enum::CU_LIMIT_MALLOC_HEAP_SIZE`]: size in bytes of the heap used by the malloc() and free() device system calls.
/// * [`CUlimit_enum::CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH`]: maximum grid depth at which a thread can issue the device runtime call [cudaDeviceSynchronize()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g10e20b05a95f638a4071a655503df25d) to wait on child grid launches to complete.
/// * [`CUlimit_enum::CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT`]: maximum number of outstanding device runtime launches that can be made from this context.
/// * [`CUlimit_enum::CU_LIMIT_MAX_L2_FETCH_GRANULARITY`]: L2 cache fetch granularity.
/// * [`CUlimit_enum::CU_LIMIT_PERSISTING_L2_CACHE_SIZE`]: Persisting L2 cache size in bytes
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`], [cudaDeviceGetLimit](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g720e159aeb125910c22aa20fe9611ec2).
///
/// # Parameters
///
/// - `pvalue`: Returned size of limit.
/// - `limit`: Limit to query.
pub fn cuCtxGetLimit(pvalue: *mut size_t, limit: CUlimit) -> CUresult;
}
unsafe extern "C" {
/// Returns the preferred cache configuration for the current context.
///
/// On devices where the L1 cache and shared memory use the same hardware resources, this function returns through pconfig the preferred cache configuration for the current context. This is only a preference. The driver will use the requested configuration
/// if possible, but it is free to choose a different configuration if required to execute functions.
///
/// This will return a pconfig of [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_NONE`] on devices where the size of the L1 cache and shared memory are fixed.
///
/// The supported cache configurations are:
///
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_NONE`]: no preference for shared memory or L1 (default)
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_SHARED`]: prefer larger shared memory and smaller L1 cache
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_L1`]: prefer larger L1 cache and smaller shared memory
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_EQUAL`]: prefer equal sized L1 cache and shared memory
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`], [`cuFuncSetCacheConfig`], [cudaDeviceGetCacheConfig](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gd9bf5eae6d464de05aa3840df9f5deeb).
///
/// # Parameters
///
/// - `pconfig`: Returned cache configuration.
pub fn cuCtxGetCacheConfig(pconfig: *mut CUfunc_cache) -> CUresult;
}
unsafe extern "C" {
/// Sets the preferred cache configuration for the current context.
///
/// On devices where the L1 cache and shared memory use the same hardware resources, this sets through config the preferred cache configuration for the current context. This is only a preference. The driver will use the requested configuration
/// if possible, but it is free to choose a different configuration if required to execute the function. Any function preference
/// set via [`cuFuncSetCacheConfig`] or [`cuKernelSetCacheConfig`] will be preferred over this context-wide setting. Setting the context-wide cache configuration to [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_NONE`] will cause subsequent kernel launches to prefer to not change the cache configuration unless required to launch the kernel.
///
/// This setting does nothing on devices where the size of the L1 cache and shared memory are fixed.
///
/// Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization
/// point.
///
/// The supported cache configurations are:
///
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_NONE`]: no preference for shared memory or L1 (default)
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_SHARED`]: prefer larger shared memory and smaller L1 cache
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_L1`]: prefer larger L1 cache and smaller shared memory
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_EQUAL`]: prefer equal sized L1 cache and shared memory
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetLimit`], [`cuCtxSynchronize`], [`cuFuncSetCacheConfig`], [cudaDeviceSetCacheConfig](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g6c9cc78ca80490386cf593b4baa35a15), [`cuKernelSetCacheConfig`].
///
/// # Parameters
///
/// - `config`: Requested cache configuration.
pub fn cuCtxSetCacheConfig(config: CUfunc_cache) -> CUresult;
}
unsafe extern "C" {
/// Gets the context's API version.
///
/// Returns a version number in version corresponding to the capabilities of the context (e.g. 3010 or 3020), which library developers can use to direct callers
/// to a specific API version. If ctx is NULL, returns the API version used to create the currently bound context.
///
/// Note that new API versions are only introduced when context capabilities are changed that break binary compatibility, so the
/// API version and driver version may be different. For example, it is valid for the API version to be 3020 while the driver
/// version is 4020.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`].
///
/// # Parameters
///
/// - `ctx`: Context to check.
/// - `version`: Pointer to version.
pub fn cuCtxGetApiVersion(
ctx: CUcontext,
version: *mut ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Returns numerical values that correspond to the least and greatest stream priorities.
///
/// Returns in \*leastPriority and \*greatestPriority the numerical values that correspond to the least and greatest stream priorities respectively. Stream priorities follow a
/// convention where lower numbers imply greater priorities. The range of meaningful stream priorities is given by \[\*greatestPriority, \*leastPriority\]. If the user attempts to create a stream with a priority value that is outside the meaningful range as specified by this
/// API, the priority is automatically clamped down or up to either \*leastPriority or \*greatestPriority respectively. See [`cuStreamCreateWithPriority`] for details on creating a priority stream. A NULL may be passed in for \*leastPriority or \*greatestPriority if the value is not desired.
///
/// This function will return '0' in both \*leastPriority and \*greatestPriority if the current context's device does not support stream priorities (see [`cuDeviceGetAttribute`]).
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreateWithPriority`], [`cuStreamGetPriority`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxSetLimit`], [`cuCtxSynchronize`], [cudaDeviceGetStreamPriorityRange](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gfdb79818f7c0ee7bc585648c91770275).
///
/// # Parameters
///
/// - `leastPriority`: Pointer to an int in which the numerical value for least stream priority is returned.
/// - `greatestPriority`: Pointer to an int in which the numerical value for greatest stream priority is returned.
pub fn cuCtxGetStreamPriorityRange(
leastPriority: *mut ::core::ffi::c_int,
greatestPriority: *mut ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Resets all persisting lines in cache to normal status.
///
/// [`cuCtxResetPersistingL2Cache`] Resets all persisting lines in cache to normal status. Takes effect on function return.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`CUaccessPolicyWindow`].
pub fn cuCtxResetPersistingL2Cache() -> CUresult;
}
unsafe extern "C" {
/// Returns the execution affinity setting for the current context.
///
/// Returns in \*pExecAffinity the current value of type. The supported `CUexecAffinityType` values are:
///
/// * [`CUexecAffinityType_enum::CU_EXEC_AFFINITY_TYPE_SM_COUNT`]: number of SMs the context is limited to use.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`CUexecAffinityParam`].
///
/// # Parameters
///
/// - `pExecAffinity`: Returned execution affinity.
pub fn cuCtxGetExecAffinity(
pExecAffinity: *mut CUexecAffinityParam,
type_: CUexecAffinityType,
) -> CUresult;
}
unsafe extern "C" {
/// Records an event.
///
/// Captures in hEvent all the activities of the context hCtx at the time of this call. hEvent and hCtx must be from the same CUDA context, otherwise [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`] will be returned. Calls such as [`cuEventQuery`] or [`cuCtxWaitEvent`] will then examine or wait for completion of the work that was captured. Uses of hCtx after this call do not modify hEvent. If the context passed to hCtx is the primary context, hEvent will capture all the activities of the primary context and its green contexts. If the context passed to hCtx is a context converted from green context via [`cuCtxFromGreenCtx`], hEvent will capture only the activities of the green context.
///
/// Note:
///
/// The API will return [`cudaError_enum::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED`] if the specified context hCtx has a stream in the capture mode. In such a case, the call will invalidate all the conflicting captures.
///
/// **See also:**
///
/// [`cuCtxWaitEvent`], [`cuGreenCtxRecordEvent`], [`cuGreenCtxWaitEvent`], [`cuEventRecord`].
///
/// # Parameters
///
/// - `hCtx`: Context to record event for.
/// - `hEvent`: Event to record.
pub fn cuCtxRecordEvent(hCtx: CUcontext, hEvent: CUevent) -> CUresult;
}
unsafe extern "C" {
/// Make a context wait on an event.
///
/// Makes all future work submitted to context hCtx wait for all work captured in hEvent. The synchronization will be performed on the device and will not block the calling CPU thread. See [`cuCtxRecordEvent`] for details on what is captured by an event. If the context passed to hCtx is the primary context, the primary context and its green contexts will wait for hEvent. If the context passed to hCtx is a context converted from green context via [`cuCtxFromGreenCtx`], the green context will wait for hEvent.
///
/// Note:
///
/// * hEvent may be from a different context or device than hCtx.
/// * The API will return [`cudaError_enum::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED`] and invalidate the capture if the specified event hEvent is part of an ongoing capture sequence or if the specified context hCtx has a stream in the capture mode.
///
/// **See also:**
///
/// [`cuCtxRecordEvent`], [`cuGreenCtxRecordEvent`], [`cuGreenCtxWaitEvent`], [`cuStreamWaitEvent`].
///
/// # Parameters
///
/// - `hCtx`: Context to wait.
/// - `hEvent`: Event to wait on.
pub fn cuCtxWaitEvent(hCtx: CUcontext, hEvent: CUevent) -> CUresult;
}
unsafe extern "C" {
/// Increment a context's usage-count.
///
/// Note that
///
/// Increments the usage count of the context and passes back a context handle in \*pctx that must be passed to [`cuCtxDetach`] when the application is done with the context. [`cuCtxAttach`] fails if there is no context current to the thread.
///
/// Currently, the flags parameter must be 0.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxDetach`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`].
///
/// # Parameters
///
/// - `pctx`: Returned context handle of the current context.
/// - `flags`: Context attach flags (must be 0).
#[deprecated]
pub fn cuCtxAttach(pctx: *mut CUcontext, flags: ::core::ffi::c_uint) -> CUresult;
}
unsafe extern "C" {
/// Decrement a context's usage-count.
///
/// Note that
///
/// Decrements the usage count of the context ctx, and destroys the context if the usage count goes to 0. The context must be a handle that was passed back by [`cuCtxCreate_v4`] or [`cuCtxAttach`], and must be current to the calling thread.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetCacheConfig`], [`cuCtxSetLimit`], [`cuCtxSynchronize`].
///
/// # Parameters
///
/// - `ctx`: Context to destroy.
#[deprecated]
pub fn cuCtxDetach(ctx: CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Returns the current shared memory configuration for the current context.
///
/// pConfig
///
/// [`cuCtxSetSharedMemConfig`]
///
/// [`cuCtxGetSharedMemConfig`]
///
/// The returned bank configurations can be either:
///
/// * [`CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE`]: shared memory bank width is four bytes.
/// * [`CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE`]: shared memory bank width will eight bytes.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetLimit`], [`cuCtxSynchronize`], [`cuCtxGetSharedMemConfig`], [`cuFuncSetCacheConfig`], [cudaDeviceGetSharedMemConfig](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE__DEPRECATED.html#group__CUDART__DEVICE__DEPRECATED_1g542246258996a39a3ce2bc311bbb2421).
///
/// # Parameters
///
/// - `pConfig`: returned shared memory configuration.
#[deprecated]
pub fn cuCtxGetSharedMemConfig(pConfig: *mut CUsharedconfig) -> CUresult;
}
unsafe extern "C" {
/// Sets the shared memory configuration for the current context.
///
/// Changed the shared memory configuration between launches may insert a device side synchronization point between those launches.
///
/// Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major
/// effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what
/// kinds of accesses to shared memory will result in bank conflicts.
///
/// This function will do nothing on devices with fixed shared memory bank size.
///
/// The supported bank configurations are:
///
/// * [`CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE`]: set bank width to the default initial setting (currently, four bytes).
/// * [`CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE`]: set shared memory bank width to be natively four bytes.
/// * [`CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE`]: set shared memory bank width to be natively eight bytes.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxCreate_v4`], [`cuCtxDestroy_v2`], [`cuCtxGetApiVersion`], [`cuCtxGetCacheConfig`], [`cuCtxGetDevice`], [`cuCtxGetFlags`], [`cuCtxGetLimit`], [`cuCtxPopCurrent_v2`], [`cuCtxPushCurrent_v2`], [`cuCtxSetLimit`], [`cuCtxSynchronize`], [`cuCtxGetSharedMemConfig`], [`cuFuncSetCacheConfig`], [cudaDeviceSetSharedMemConfig](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE__DEPRECATED.html#group__CUDART__DEVICE__DEPRECATED_1g76cb4f94c7af96c1247dfc7f105eabae).
///
/// # Parameters
///
/// - `config`: requested shared memory configuration.
#[deprecated]
pub fn cuCtxSetSharedMemConfig(config: CUsharedconfig) -> CUresult;
}
unsafe extern "C" {
/// Loads a compute module.
///
/// Takes a filename fname and loads the corresponding module module into the current context. The CUDA driver API does not attempt to lazily allocate the resources needed by a module; if the
/// memory for functions and data (constant and global) needed by the module cannot be allocated, [`cuModuleLoad`] fails. The file should be a cubin file as output by **nvcc**, or a PTX file either as output by **nvcc** or handwritten, or a fatbin file as output by **nvcc** from toolchain 4.0 or later, or a Tile IR file.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuModuleGetFunction`], [`cuModuleGetGlobal_v2`], [`cuModuleGetTexRef`], [`cuModuleLoadData`], [`cuModuleLoadDataEx`], [`cuModuleLoadFatBinary`], [`cuModuleUnload`].
///
/// # Parameters
///
/// - `module`: Returned module.
/// - `fname`: Filename of module to load.
pub fn cuModuleLoad(
module: *mut CUmodule,
fname: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Load a module's data.
///
/// Takes a pointer image and loads the corresponding module module into the current context. The image may be a cubin or fatbin as output by **nvcc**, or a NULL-terminated PTX, either as output by **nvcc** or hand-written, or Tile IR data.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuModuleGetFunction`], [`cuModuleGetGlobal_v2`], [`cuModuleGetTexRef`], [`cuModuleLoad`], [`cuModuleLoadDataEx`], [`cuModuleLoadFatBinary`], [`cuModuleUnload`].
///
/// # Parameters
///
/// - `module`: Returned module.
/// - `image`: Module data to load.
pub fn cuModuleLoadData(
module: *mut CUmodule,
image: *const ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Load a module's data with options.
///
/// Takes a pointer image and loads the corresponding module module into the current context. The image may be a cubin or fatbin as output by **nvcc**, or a NULL-terminated PTX, either as output by **nvcc** or hand-written, or Tile IR data.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuModuleGetFunction`], [`cuModuleGetGlobal_v2`], [`cuModuleGetTexRef`], [`cuModuleLoad`], [`cuModuleLoadData`], [`cuModuleLoadFatBinary`], [`cuModuleUnload`].
///
/// # Parameters
///
/// - `module`: Returned module.
/// - `image`: Module data to load.
/// - `numOptions`: Number of options.
/// - `options`: Options for JIT.
/// - `optionValues`: Option values for JIT.
pub fn cuModuleLoadDataEx(
module: *mut CUmodule,
image: *const ::core::ffi::c_void,
numOptions: ::core::ffi::c_uint,
options: *mut CUjit_option,
optionValues: *mut *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Load a module's data.
///
/// Takes a pointer fatCubin and loads the corresponding module module into the current context. The pointer represents a fat binary object, which is a collection of different cubin and/or PTX
/// files, all representing the same device code, but compiled and optimized for different architectures.
///
/// Prior to CUDA 4.0, there was no documented API for constructing and using fat binary objects by programmers. Starting with
/// CUDA 4.0, fat binary objects can be constructed by providing the -fatbin option to **nvcc**. More information can be found in the **nvcc** document.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuModuleGetFunction`], [`cuModuleGetGlobal_v2`], [`cuModuleGetTexRef`], [`cuModuleLoad`], [`cuModuleLoadData`], [`cuModuleLoadDataEx`], [`cuModuleUnload`].
///
/// # Parameters
///
/// - `module`: Returned module.
/// - `fatCubin`: Fat binary to load.
pub fn cuModuleLoadFatBinary(
module: *mut CUmodule,
fatCubin: *const ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Unloads a module.
///
/// Unloads a module hmod from the current context. Attempting to unload a module which was obtained from the Library Management API such as [`cuLibraryGetModule`] will return [`cudaError_enum::CUDA_ERROR_NOT_PERMITTED`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [`cuModuleGetFunction`], [`cuModuleGetGlobal_v2`], [`cuModuleGetTexRef`], [`cuModuleLoad`], [`cuModuleLoadData`], [`cuModuleLoadDataEx`], [`cuModuleLoadFatBinary`].
///
/// # Parameters
///
/// - `hmod`: Module to unload.
pub fn cuModuleUnload(hmod: CUmodule) -> CUresult;
}
/// CUDA Lazy Loading status.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUmoduleLoadingMode_enum {
/// Lazy Kernel Loading is not enabled.
CU_MODULE_EAGER_LOADING = 1,
/// Lazy Kernel Loading is enabled.
CU_MODULE_LAZY_LOADING = 2,
}
pub use self::CUmoduleLoadingMode_enum as CUmoduleLoadingMode;
unsafe extern "C" {
/// Query lazy loading mode.
///
/// Returns lazy loading mode Module loading mode is controlled by CUDA_MODULE_LOADING env variable
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuModuleLoad`],.
///
/// # Parameters
///
/// - `mode`: Returns the lazy loading mode.
pub fn cuModuleGetLoadingMode(mode: *mut CUmoduleLoadingMode) -> CUresult;
}
unsafe extern "C" {
/// Returns a function handle.
///
/// Returns in \*hfunc the handle of the function of name name located in module hmod. If no function of that name exists, [`cuModuleGetFunction`] returns [`cudaError_enum::CUDA_ERROR_NOT_FOUND`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuModuleGetGlobal_v2`], [`cuModuleGetTexRef`], [`cuModuleLoad`], [`cuModuleLoadData`], [`cuModuleLoadDataEx`], [`cuModuleLoadFatBinary`], [`cuModuleUnload`].
///
/// # Parameters
///
/// - `hfunc`: Returned function handle.
/// - `hmod`: Module to retrieve function from.
/// - `name`: Name of function to retrieve.
pub fn cuModuleGetFunction(
hfunc: *mut CUfunction,
hmod: CUmodule,
name: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the number of functions within a module.
///
/// Returns in count the number of functions in mod.
///
/// # Parameters
///
/// - `count`: Number of functions found within the module.
pub fn cuModuleGetFunctionCount(
count: *mut ::core::ffi::c_uint,
mod_: CUmodule,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the function handles within a module.
///
/// Returns in functions a maximum number of numFunctions function handles within mod. When function loading mode is set to LAZY the function retrieved may be partially loaded. The loading state of a function
/// can be queried using cuFunctionIsLoaded. CUDA APIs may load the function automatically when called with partially loaded function
/// handle which may incur additional latency. Alternatively, cuFunctionLoad can be used to explicitly load a function. The returned
/// function handles become invalid when the module is unloaded.
///
/// **See also:**
///
/// [`cuModuleGetFunction`], [`cuModuleGetFunctionCount`], [`cuFuncIsLoaded`], [`cuFuncLoad`].
///
/// # Parameters
///
/// - `functions`: Buffer where the function handles are returned to.
/// - `numFunctions`: Maximum number of function handles may be returned to the buffer.
pub fn cuModuleEnumerateFunctions(
functions: *mut CUfunction,
numFunctions: ::core::ffi::c_uint,
mod_: CUmodule,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a global pointer from a module.
///
/// Returns in \*dptr and \*bytes the base pointer and size of the global of name name located in module hmod. If no variable of that name exists, [`cuModuleGetGlobal_v2`] returns [`cudaError_enum::CUDA_ERROR_NOT_FOUND`]. One of the parameters dptr or bytes (not both) can be NULL in which case it is ignored.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuModuleGetFunction`], [`cuModuleGetTexRef`], [`cuModuleLoad`], [`cuModuleLoadData`], [`cuModuleLoadDataEx`], [`cuModuleLoadFatBinary`], [`cuModuleUnload`], [cudaGetSymbolAddress](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g3a0f010e70a3343db18227cec9615177), [cudaGetSymbolSize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g0561c8ffee270bff0bbb7deb81ad865c).
///
/// # Parameters
///
/// - `dptr`: Returned global device pointer.
/// - `bytes`: Returned global size in bytes.
/// - `hmod`: Module to retrieve global from.
/// - `name`: Name of global to retrieve.
pub fn cuModuleGetGlobal_v2(
dptr: *mut CUdeviceptr,
bytes: *mut size_t,
hmod: CUmodule,
name: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a pending JIT linker invocation.
///
/// If the call is successful, the caller owns the returned CUlinkState, which should eventually be destroyed with [`cuLinkDestroy`]. The device code machine size (32 or 64 bit) will match the calling application.
///
/// Both linker and compiler options may be specified. Compiler options will be applied to inputs to this linker action which
/// must be compiled from PTX. The options [`CUjit_option_enum::CU_JIT_WALL_TIME`], [`CUjit_option_enum::CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES`], and [`CUjit_option_enum::CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES`] will accumulate data until the CUlinkState is destroyed.
///
/// The data passed in via [`cuLinkAddData_v2`] and [`cuLinkAddFile_v2`] will be treated as relocatable (-rdc=true to nvcc) when linking the final cubin during [`cuLinkComplete`] and will have similar consequences as offline relocatable device code linking.
///
/// optionValues must remain valid for the life of the CUlinkState if output options are used. No other references to inputs are maintained
/// after this call returns.
///
/// Note:
///
/// For LTO-IR input, only LTO-IR compiled with toolkits prior to CUDA 12.0 will be accepted
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuLinkAddData_v2`], [`cuLinkAddFile_v2`], [`cuLinkComplete`], [`cuLinkDestroy`].
///
/// # Parameters
///
/// - `numOptions`: Size of options arrays.
/// - `options`: Array of linker and compiler options.
/// - `optionValues`: Array of option values, each cast to void \*.
/// - `stateOut`: On success, this will contain a CUlinkState to specify and complete this action.
pub fn cuLinkCreate_v2(
numOptions: ::core::ffi::c_uint,
options: *mut CUjit_option,
optionValues: *mut *mut ::core::ffi::c_void,
stateOut: *mut CUlinkState,
) -> CUresult;
}
unsafe extern "C" {
/// Add an input to a pending linker invocation.
///
/// Ownership of data is retained by the caller. No reference is retained to any inputs after this call returns.
///
/// This method accepts only compiler options, which are used if the data must be compiled from PTX, and does not accept any of
/// [`CUjit_option_enum::CU_JIT_WALL_TIME`], [`CUjit_option_enum::CU_JIT_INFO_LOG_BUFFER`], [`CUjit_option_enum::CU_JIT_ERROR_LOG_BUFFER`], [`CUjit_option_enum::CU_JIT_TARGET_FROM_CUCONTEXT`], or [`CUjit_option_enum::CU_JIT_TARGET`].
///
/// Note:
///
/// For LTO-IR input, only LTO-IR compiled with toolkits prior to CUDA 12.0 will be accepted
///
/// **See also:**
///
/// [`cuLinkCreate_v2`], [`cuLinkAddFile_v2`], [`cuLinkComplete`], [`cuLinkDestroy`].
///
/// # Parameters
///
/// - `state`: A pending linker action.
/// - `data`: The input data. PTX must be NULL-terminated.
/// - `size`: The length of the input data.
/// - `name`: An optional name for this input in log messages.
/// - `numOptions`: Size of options.
/// - `options`: Options to be applied only for this input (overrides options from [`cuLinkCreate_v2`]).
/// - `optionValues`: Array of option values, each cast to void \*.
pub fn cuLinkAddData_v2(
state: CUlinkState,
type_: CUjitInputType,
data: *mut ::core::ffi::c_void,
size: size_t,
name: *const ::core::ffi::c_char,
numOptions: ::core::ffi::c_uint,
options: *mut CUjit_option,
optionValues: *mut *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Add a file input to a pending linker invocation.
///
/// No reference is retained to any inputs after this call returns.
///
/// This method accepts only compiler options, which are used if the input must be compiled from PTX, and does not accept any
/// of [`CUjit_option_enum::CU_JIT_WALL_TIME`], [`CUjit_option_enum::CU_JIT_INFO_LOG_BUFFER`], [`CUjit_option_enum::CU_JIT_ERROR_LOG_BUFFER`], [`CUjit_option_enum::CU_JIT_TARGET_FROM_CUCONTEXT`], or [`CUjit_option_enum::CU_JIT_TARGET`].
///
/// This method is equivalent to invoking [`cuLinkAddData_v2`] on the contents of the file.
///
/// Note:
///
/// For LTO-IR input, only LTO-IR compiled with toolkits prior to CUDA 12.0 will be accepted
///
/// **See also:**
///
/// [`cuLinkCreate_v2`], [`cuLinkAddData_v2`], [`cuLinkComplete`], [`cuLinkDestroy`].
///
/// # Parameters
///
/// - `state`: A pending linker action.
/// - `path`: Path to the input file.
/// - `numOptions`: Size of options.
/// - `options`: Options to be applied only for this input (overrides options from [`cuLinkCreate_v2`]).
/// - `optionValues`: Array of option values, each cast to void \*.
pub fn cuLinkAddFile_v2(
state: CUlinkState,
type_: CUjitInputType,
path: *const ::core::ffi::c_char,
numOptions: ::core::ffi::c_uint,
options: *mut CUjit_option,
optionValues: *mut *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Complete a pending linker invocation.
///
/// Completes the pending linker action and returns the cubin image for the linked device code, which can be used with [`cuModuleLoadData`]. The cubin is owned by state, so it should be loaded before state is destroyed via [`cuLinkDestroy`]. This call does not destroy state.
///
/// **See also:**
///
/// [`cuLinkCreate_v2`], [`cuLinkAddData_v2`], [`cuLinkAddFile_v2`], [`cuLinkDestroy`], [`cuModuleLoadData`].
///
/// # Parameters
///
/// - `state`: A pending linker invocation.
/// - `cubinOut`: On success, this will point to the output image.
/// - `sizeOut`: Optional parameter to receive the size of the generated image.
pub fn cuLinkComplete(
state: CUlinkState,
cubinOut: *mut *mut ::core::ffi::c_void,
sizeOut: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Destroys state for a JIT linker invocation.
///
/// **See also:**
///
/// [`cuLinkCreate_v2`].
///
/// # Parameters
///
/// - `state`: State object for the linker invocation.
pub fn cuLinkDestroy(state: CUlinkState) -> CUresult;
}
unsafe extern "C" {
/// Returns a handle to a texture reference.
///
/// \*pTexRef
///
/// name
///
/// hmod
///
/// [`cuModuleGetTexRef`]
///
/// [`cudaError_enum::CUDA_ERROR_NOT_FOUND`]
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuModuleGetFunction`], [`cuModuleGetGlobal_v2`], [`cuModuleGetSurfRef`], [`cuModuleLoad`], [`cuModuleLoadData`], [`cuModuleLoadDataEx`], [`cuModuleLoadFatBinary`], [`cuModuleUnload`].
///
/// # Parameters
///
/// - `pTexRef`: Returned texture reference.
/// - `hmod`: Module to retrieve texture reference from.
/// - `name`: Name of texture reference to retrieve.
#[deprecated]
pub fn cuModuleGetTexRef(
pTexRef: *mut CUtexref,
hmod: CUmodule,
name: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a handle to a surface reference.
///
/// \*pSurfRef
///
/// name
///
/// hmod
///
/// [`cuModuleGetSurfRef`]
///
/// [`cudaError_enum::CUDA_ERROR_NOT_FOUND`]
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuModuleGetFunction`], [`cuModuleGetGlobal_v2`], [`cuModuleGetTexRef`], [`cuModuleLoad`], [`cuModuleLoadData`], [`cuModuleLoadDataEx`], [`cuModuleLoadFatBinary`], [`cuModuleUnload`].
///
/// # Parameters
///
/// - `pSurfRef`: Returned surface reference.
/// - `hmod`: Module to retrieve surface reference from.
/// - `name`: Name of surface reference to retrieve.
#[deprecated]
pub fn cuModuleGetSurfRef(
pSurfRef: *mut CUsurfref,
hmod: CUmodule,
name: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Load a library with specified code and options.
///
/// Takes a pointer code and loads the corresponding library library based on the application defined library loading mode:
///
/// * If module loading is set to EAGER, via the environment variables described in "Module loading", library is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library
/// is unloaded with [`cuLibraryUnload`].
/// * If the environment variables are set to LAZY, library is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context,
/// such as a kernel launch.
///
/// These environment variables are described in the CUDA programming guide under the "CUDA environment variables" section.
///
/// The code may be a cubin or fatbin as output by **nvcc**, or a NULL-terminated PTX, either as output by **nvcc** or hand-written, or Tile IR data. A fatbin should also contain relocatable code when doing separate compilation.
///
/// Options are passed as an array via jitOptions and any corresponding parameters are passed in jitOptionsValues. The number of total JIT options is supplied via numJitOptions. Any outputs will be returned via jitOptionsValues.
///
/// Library load options are passed as an array via libraryOptions and any corresponding parameters are passed in libraryOptionValues. The number of total library load options is supplied via numLibraryOptions.
///
/// Note:
///
/// If the library contains managed variables and no device in the system supports managed variables this call is expected to
/// return [`cudaError_enum::CUDA_ERROR_NOT_SUPPORTED`]
///
/// **See also:**
///
/// [`cuLibraryLoadFromFile`], [`cuLibraryUnload`], [`cuModuleLoad`], [`cuModuleLoadData`], [`cuModuleLoadDataEx`].
///
/// # Parameters
///
/// - `library`: Returned library.
/// - `code`: Code to load.
/// - `jitOptions`: Options for JIT.
/// - `jitOptionsValues`: Option values for JIT.
/// - `numJitOptions`: Number of options.
/// - `libraryOptions`: Options for loading.
/// - `libraryOptionValues`: Option values for loading.
/// - `numLibraryOptions`: Number of options for loading.
pub fn cuLibraryLoadData(
library: *mut CUlibrary,
code: *const ::core::ffi::c_void,
jitOptions: *mut CUjit_option,
jitOptionsValues: *mut *mut ::core::ffi::c_void,
numJitOptions: ::core::ffi::c_uint,
libraryOptions: *mut CUlibraryOption,
libraryOptionValues: *mut *mut ::core::ffi::c_void,
numLibraryOptions: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Load a library with specified file and options.
///
/// Takes a pointer code and loads the corresponding library library based on the application defined library loading mode:
///
/// * If module loading is set to EAGER, via the environment variables described in "Module loading", library is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library
/// is unloaded with [`cuLibraryUnload`].
/// * If the environment variables are set to LAZY, library is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context,
/// such as a kernel launch.
///
/// These environment variables are described in the CUDA programming guide under the "CUDA environment variables" section.
///
/// The file should be a cubin file as output by **nvcc**, or a PTX file either as output by **nvcc** or handwritten, or a fatbin file as output by **nvcc** or hand-written, or Tile IR file. A fatbin should also contain relocatable code when doing separate compilation.
///
/// Options are passed as an array via jitOptions and any corresponding parameters are passed in jitOptionsValues. The number of total options is supplied via numJitOptions. Any outputs will be returned via jitOptionsValues.
///
/// Library load options are passed as an array via libraryOptions and any corresponding parameters are passed in libraryOptionValues. The number of total library load options is supplied via numLibraryOptions.
///
/// Note:
///
/// If the library contains managed variables and no device in the system supports managed variables this call is expected to
/// return [`cudaError_enum::CUDA_ERROR_NOT_SUPPORTED`]
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryUnload`], [`cuModuleLoad`], [`cuModuleLoadData`], [`cuModuleLoadDataEx`].
///
/// # Parameters
///
/// - `library`: Returned library.
/// - `fileName`: File to load from.
/// - `jitOptions`: Options for JIT.
/// - `jitOptionsValues`: Option values for JIT.
/// - `numJitOptions`: Number of options.
/// - `libraryOptions`: Options for loading.
/// - `libraryOptionValues`: Option values for loading.
/// - `numLibraryOptions`: Number of options for loading.
pub fn cuLibraryLoadFromFile(
library: *mut CUlibrary,
fileName: *const ::core::ffi::c_char,
jitOptions: *mut CUjit_option,
jitOptionsValues: *mut *mut ::core::ffi::c_void,
numJitOptions: ::core::ffi::c_uint,
libraryOptions: *mut CUlibraryOption,
libraryOptionValues: *mut *mut ::core::ffi::c_void,
numLibraryOptions: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Unloads a library.
///
/// Unloads the library specified with library
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuModuleUnload`].
///
/// # Parameters
///
/// - `library`: Library to unload.
pub fn cuLibraryUnload(library: CUlibrary) -> CUresult;
}
unsafe extern "C" {
/// Returns a kernel handle.
///
/// Returns in pKernel the handle of the kernel with name name located in library library. If kernel handle is not found, the call returns [`cudaError_enum::CUDA_ERROR_NOT_FOUND`].
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`], [`cuKernelGetFunction`], [`cuLibraryGetModule`], [`cuModuleGetFunction`].
///
/// # Parameters
///
/// - `pKernel`: Returned kernel handle.
/// - `library`: Library to retrieve kernel from.
/// - `name`: Name of kernel to retrieve.
pub fn cuLibraryGetKernel(
pKernel: *mut CUkernel,
library: CUlibrary,
name: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the number of kernels within a library.
///
/// Returns in count the number of kernels in lib.
///
/// # Parameters
///
/// - `count`: Number of kernels found within the library.
/// - `lib`: Library to query.
pub fn cuLibraryGetKernelCount(
count: *mut ::core::ffi::c_uint,
lib: CUlibrary,
) -> CUresult;
}
unsafe extern "C" {
/// Retrieve the kernel handles within a library.
///
/// Returns in kernels a maximum number of numKernels kernel handles within lib. The returned kernel handle becomes invalid when the library is unloaded.
///
/// **See also:**
///
/// [`cuLibraryGetKernelCount`].
///
/// # Parameters
///
/// - `kernels`: Buffer where the kernel handles are returned to.
/// - `numKernels`: Maximum number of kernel handles may be returned to the buffer.
/// - `lib`: Library to query from.
pub fn cuLibraryEnumerateKernels(
kernels: *mut CUkernel,
numKernels: ::core::ffi::c_uint,
lib: CUlibrary,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a module handle.
///
/// Returns in pMod the module handle associated with the current context located in library library. If module handle is not found, the call returns [`cudaError_enum::CUDA_ERROR_NOT_FOUND`].
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`], [`cuModuleGetFunction`].
///
/// # Parameters
///
/// - `pMod`: Returned module handle.
/// - `library`: Library to retrieve module from.
pub fn cuLibraryGetModule(pMod: *mut CUmodule, library: CUlibrary) -> CUresult;
}
unsafe extern "C" {
/// Returns a function handle.
///
/// Returns in pFunc the handle of the function for the requested kernel kernel and the current context. If function handle is not found, the call returns [`cudaError_enum::CUDA_ERROR_NOT_FOUND`].
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`], [`cuLibraryGetKernel`], [`cuLibraryGetModule`], [`cuModuleGetFunction`].
///
/// # Parameters
///
/// - `pFunc`: Returned function handle.
/// - `kernel`: Kernel to retrieve function for the requested context.
pub fn cuKernelGetFunction(pFunc: *mut CUfunction, kernel: CUkernel) -> CUresult;
}
unsafe extern "C" {
/// Returns a library handle.
///
/// Returns in pLib the handle of the library for the requested kernel kernel
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`], [`cuLibraryGetKernel`].
///
/// # Parameters
///
/// - `pLib`: Returned library handle.
/// - `kernel`: Kernel to retrieve library handle.
pub fn cuKernelGetLibrary(pLib: *mut CUlibrary, kernel: CUkernel) -> CUresult;
}
unsafe extern "C" {
/// Returns a global device pointer.
///
/// Returns in \*dptr and \*bytes the base pointer and size of the global with name name for the requested library library and the current context. If no global for the requested name name exists, the call returns [`cudaError_enum::CUDA_ERROR_NOT_FOUND`]. One of the parameters dptr or bytes (not both) can be NULL in which case it is ignored.
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`], [`cuLibraryGetModule`], [`cuModuleGetGlobal_v2`].
///
/// # Parameters
///
/// - `dptr`: Returned global device pointer for the requested context.
/// - `bytes`: Returned global size in bytes.
/// - `library`: Library to retrieve global from.
/// - `name`: Name of global to retrieve.
pub fn cuLibraryGetGlobal(
dptr: *mut CUdeviceptr,
bytes: *mut size_t,
library: CUlibrary,
name: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a pointer to managed memory.
///
/// Returns in \*dptr and \*bytes the base pointer and size of the managed memory with name name for the requested library library. If no managed memory with the requested name name exists, the call returns [`cudaError_enum::CUDA_ERROR_NOT_FOUND`]. One of the parameters dptr or bytes (not both) can be NULL in which case it is ignored. Note that managed memory for library library is shared across devices and is registered when the library is loaded into at least one context.
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`].
///
/// # Parameters
///
/// - `dptr`: Returned pointer to the managed memory.
/// - `bytes`: Returned memory size in bytes.
/// - `library`: Library to retrieve managed memory from.
/// - `name`: Name of managed memory to retrieve.
pub fn cuLibraryGetManaged(
dptr: *mut CUdeviceptr,
bytes: *mut size_t,
library: CUlibrary,
name: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a pointer to a unified function.
///
/// Returns in \*fptr the function pointer to a unified function denoted by symbol. If no unified function with name symbol exists, the call returns [`cudaError_enum::CUDA_ERROR_NOT_FOUND`]. If there is no device with attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_UNIFIED_FUNCTION_POINTERS`] present in the system, the call may return [`cudaError_enum::CUDA_ERROR_NOT_FOUND`].
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`].
///
/// # Parameters
///
/// - `fptr`: Returned pointer to a unified function.
/// - `library`: Library to retrieve function pointer memory from.
/// - `symbol`: Name of function pointer to retrieve.
pub fn cuLibraryGetUnifiedFunction(
fptr: *mut *mut ::core::ffi::c_void,
library: CUlibrary,
symbol: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Returns information about a kernel.
///
/// Returns in \*pi the integer value of the attribute attrib for the kernel kernel for the requested device dev. The supported attributes are:
///
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK`]: The maximum number of threads per block, beyond which a launch of the kernel would fail. This number depends on both the
/// kernel and the requested device.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES`]: The size in bytes of statically-allocated shared memory per block required by this kernel. This does not include dynamically-allocated
/// shared memory requested by the user at runtime.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES`]: The size in bytes of user-allocated constant memory required by this kernel.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES`]: The size in bytes of local memory used by each thread of this kernel.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_NUM_REGS`]: The number of registers used by each thread of this kernel.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_PTX_VERSION`]: The PTX virtual architecture version for which the kernel was compiled. This value is the major PTX version \* 10 + the minor
/// PTX version, so a PTX version 1.3 function would return the value 13. Note that this may return the undefined value of 0 for
/// cubins compiled prior to CUDA 3.0.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_BINARY_VERSION`]: The binary architecture version for which the kernel was compiled. This value is the major binary version \* 10 + the minor
/// binary version, so a binary version 1.3 function would return the value 13. Note that this will return a value of 10 for legacy
/// cubins that do not have a properly-encoded binary architecture version.
/// * CU_FUNC_CACHE_MODE_CA: The attribute to indicate whether the kernel has been compiled with user specified option "-Xptxas
/// --dlcm=ca" set.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES`]: The maximum size in bytes of dynamically-allocated shared memory.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT`]: Preferred shared memory-L1 cache split ratio in percent of total shared memory.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET`]: If this attribute is set, the kernel must launch with a valid cluster size specified.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH`]: The required cluster width in blocks.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT`]: The required cluster height in blocks.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH`]: The required cluster depth in blocks.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED`]: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. A non-portable
/// cluster size may only function on the specific SKUs the program is tested on. The launch might fail if the program is run
/// on a different hardware platform. CUDA API provides cudaOccupancyMaxActiveClusters to assist with checking whether the desired
/// size can be launched on the current device. A portable cluster size is guaranteed to be functional on all compute capabilities
/// higher than the target compute capability. The portable cluster size for sm_90 is 8 blocks per cluster. This value may increase
/// for future compute capabilities. The specific hardware unit may support higher cluster sizes that’s not guaranteed to be portable.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE`]: The block scheduling policy of a function. The value type is CUclusterSchedulingPolicy.
///
/// Note:
///
/// If another thread is trying to set the same attribute on the same device using [`cuKernelSetAttribute`] simultaneously, the attribute query will give the old or new value depending on the interleavings chosen by the OS scheduler
/// and memory consistency.
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`], [`cuKernelSetAttribute`], [`cuLibraryGetKernel`], [`cuLaunchKernel`], [`cuKernelGetFunction`], [`cuLibraryGetModule`], [`cuModuleGetFunction`], [`cuFuncGetAttribute`].
///
/// # Parameters
///
/// - `pi`: Returned attribute value.
/// - `attrib`: Attribute requested.
/// - `kernel`: Kernel to query attribute of.
/// - `dev`: Device to query attribute of.
pub fn cuKernelGetAttribute(
pi: *mut ::core::ffi::c_int,
attrib: CUfunction_attribute,
kernel: CUkernel,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Sets information about a kernel.
///
/// This call sets the value of a specified attribute attrib on the kernel kernel for the requested device dev to an integer value specified by val. This function returns [`CUresult::CUDA_SUCCESS`] if the new value of the attribute could be successfully set. If the set fails, this call
/// will return an error. Not all attributes can have values set. Attempting to set a value on a read-only attribute will result
/// in an error ([`CUresult::CUDA_ERROR_INVALID_VALUE`])
///
/// Note that attributes set using [`cuFuncSetAttribute`] will override the attribute set by this API irrespective of whether the call to [`cuFuncSetAttribute`] is made before or after this API call. However, [`cuKernelGetAttribute`] will always return the attribute value set by this API.
///
/// Supported attributes are:
///
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES`]: This is the maximum size in bytes of dynamically-allocated shared memory. The value should contain the requested maximum
/// size of dynamically-allocated shared memory. The sum of this value and the function attribute [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES`] cannot exceed the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN`]. The maximal size of requestable dynamic shared memory may differ by GPU architecture.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT`]: On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference,
/// in percent of the total shared memory. See [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR`] This is only a hint, and the driver can choose a different ratio if required to execute the function.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH`]: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity
/// of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime.
/// Setting it at runtime will return [`CUresult::CUDA_ERROR_NOT_PERMITTED`].
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT`]: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The
/// validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at
/// runtime. Setting it at runtime will return [`CUresult::CUDA_ERROR_NOT_PERMITTED`].
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH`]: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity
/// of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime.
/// Setting it at runtime will return [`CUresult::CUDA_ERROR_NOT_PERMITTED`].
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED`]: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE`]: The block scheduling policy of a function. The value type is CUclusterSchedulingPolicy.
///
/// Note:
///
/// The API has stricter locking requirements in comparison to its legacy counterpart [`cuFuncSetAttribute`] due to device-wide semantics. If multiple threads are trying to set the same attribute on the same device simultaneously,
/// the attribute setting will depend on the interleavings chosen by the OS scheduler and memory consistency.
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`], [`cuKernelGetAttribute`], [`cuLibraryGetKernel`], [`cuLaunchKernel`], [`cuKernelGetFunction`], [`cuLibraryGetModule`], [`cuModuleGetFunction`], [`cuFuncSetAttribute`].
///
/// # Parameters
///
/// - `attrib`: Attribute requested.
/// - `val`: Value to set.
/// - `kernel`: Kernel to set attribute of.
/// - `dev`: Device to set attribute of.
pub fn cuKernelSetAttribute(
attrib: CUfunction_attribute,
val: ::core::ffi::c_int,
kernel: CUkernel,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the preferred cache configuration for a device kernel.
///
/// On devices where the L1 cache and shared memory use the same hardware resources, this sets through config the preferred cache configuration for the device kernel kernel on the requested device dev. This is only a preference. The driver will use the requested configuration if possible, but it is free to choose a different
/// configuration if required to execute kernel. Any context-wide preference set via [`cuCtxSetCacheConfig`] will be overridden by this per-kernel setting.
///
/// Note that attributes set using [`cuFuncSetCacheConfig`] will override the attribute set by this API irrespective of whether the call to [`cuFuncSetCacheConfig`] is made before or after this API call.
///
/// This setting does nothing on devices where the size of the L1 cache and shared memory are fixed.
///
/// Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization
/// point.
///
/// The supported cache configurations are:
///
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_NONE`]: no preference for shared memory or L1 (default)
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_SHARED`]: prefer larger shared memory and smaller L1 cache
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_L1`]: prefer larger L1 cache and smaller shared memory
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_EQUAL`]: prefer equal sized L1 cache and shared memory
///
/// Note:
///
/// The API has stricter locking requirements in comparison to its legacy counterpart [`cuFuncSetCacheConfig`] due to device-wide semantics. If multiple threads are trying to set a config on the same device simultaneously, the cache
/// config setting will depend on the interleavings chosen by the OS scheduler and memory consistency.
///
/// **See also:**
///
/// [`cuLibraryLoadData`], [`cuLibraryLoadFromFile`], [`cuLibraryUnload`], [`cuLibraryGetKernel`], [`cuKernelGetFunction`], [`cuLibraryGetModule`], [`cuModuleGetFunction`], [`cuFuncSetCacheConfig`], [`cuCtxSetCacheConfig`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `kernel`: Kernel to configure cache for.
/// - `config`: Requested cache configuration.
/// - `dev`: Device to set attribute of.
pub fn cuKernelSetCacheConfig(
kernel: CUkernel,
config: CUfunc_cache,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the function name for a CUkernel handle.
///
/// Returns in \*\*name the function name associated with the kernel handle hfunc . The function name is returned as a null-terminated string. The returned name is only valid when the kernel handle is valid.
/// If the library is unloaded or reloaded, one must call the API again to get the updated name. This API may return a mangled
/// name if the function is not declared as having C linkage. If either \*\*name or hfunc is NULL, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `name`: The returned name of the function.
/// - `hfunc`: The function handle to retrieve the name for.
pub fn cuKernelGetName(
name: *mut *const ::core::ffi::c_char,
hfunc: CUkernel,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the offset and size of a kernel parameter in the device-side parameter layout.
///
/// Queries the kernel parameter at paramIndex into kernel's list of parameters, and returns in paramOffset and paramSize the offset and size, respectively, where the parameter will reside in the device-side parameter layout. This information
/// can be used to update kernel node parameters from the device via [cudaGraphKernelNodeSetParam()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g0c2bd161eff1e47531eedce282e66d21) and [cudaGraphKernelNodeUpdatesApply()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g2d558cf37c9616365c67447e61ac0d6a). paramIndex must be less than the number of parameters that kernel takes. paramSize can be set to NULL if only the parameter offset is desired.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncGetParamInfo`].
///
/// # Parameters
///
/// - `kernel`: The kernel to query.
/// - `paramIndex`: The parameter index to query.
/// - `paramOffset`: Returns the offset into the device-side parameter layout at which the parameter resides.
/// - `paramSize`: Optionally returns the size of the parameter in the device-side parameter layout.
pub fn cuKernelGetParamInfo(
kernel: CUkernel,
paramIndex: size_t,
paramOffset: *mut size_t,
paramSize: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the number of parameters used by the kernel.
///
/// Queries the number of kernel parameters used by kernel and returns it in paramCount.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuKernelGetParamInfo`].
///
/// # Parameters
///
/// - `kernel`: The kernel to query.
/// - `paramCount`: Returns the number of parameters used by the function.
pub fn cuKernelGetParamCount(kernel: CUkernel, paramCount: *mut size_t) -> CUresult;
}
unsafe extern "C" {
/// Gets free and total memory.
///
/// Returns in \*total the total amount of memory available to the current context. Returns in \*free the amount of memory on the device that is free according to the OS. CUDA is not guaranteed to be able to allocate all of
/// the memory that the OS reports as free. In a multi-tenet situation, free estimate returned is prone to race condition where
/// a new allocation/free done by a different process or a different thread in the same process between the time when free memory
/// was estimated and reported, will result in deviation in free value reported and actual free memory.
///
/// The integrated GPU on Tegra shares memory with CPU and other component of the SoC. The free and total values returned by the
/// API excludes the SWAP memory space maintained by the OS on some platforms. The OS may move some of the memory pages into swap
/// area as the GPU or CPU allocate or access memory. See Tegra app note on how to calculate total and free memory on Tegra.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemGetInfo](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g376b97f5ab20321ca46f7cfa9511b978).
///
/// # Parameters
///
/// - `free`: Returned free memory in bytes.
/// - `total`: Returned total memory in bytes.
pub fn cuMemGetInfo_v2(free: *mut size_t, total: *mut size_t) -> CUresult;
}
unsafe extern "C" {
/// Allocates device memory.
///
/// Allocates bytesize bytes of linear memory on the device and returns in \*dptr a pointer to the allocated memory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared.
/// If bytesize is 0, [`cuMemAlloc_v2`] returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMalloc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g37d37965bfb4803b6d4e59ff26856356).
///
/// # Parameters
///
/// - `dptr`: Returned device pointer.
/// - `bytesize`: Requested allocation size in bytes.
pub fn cuMemAlloc_v2(dptr: *mut CUdeviceptr, bytesize: size_t) -> CUresult;
}
unsafe extern "C" {
/// Allocates pitched device memory.
///
/// Allocates at least WidthInBytes \* Height bytes of linear memory on the device and returns in \*dptr a pointer to the allocated memory. The function may pad the allocation to ensure that corresponding pointers in any given
/// row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. ElementSizeBytes specifies the size of the largest reads and writes that will be performed on the memory range. ElementSizeBytes may be 4, 8 or 16 (since coalesced memory transactions are not possible on other data sizes). If ElementSizeBytes is smaller than the actual read/write size of a kernel, the kernel will run correctly, but possibly at reduced speed. The
/// pitch returned in \*pPitch by [`cuMemAllocPitch_v2`] is the width in bytes of the allocation. The intended usage of pitch is as a separate parameter of the allocation, used to
/// compute addresses within the 2D array. Given the row and column of an array element of type **T**, the address is computed as:
///
/// ```text
/// T* pElement = (T*)((char*)BaseAddress + Row * Pitch) + Column;
/// ```
///
/// The pitch returned by [`cuMemAllocPitch_v2`] is guaranteed to work with [`cuMemcpy2D_v2`] under all circumstances. For allocations of 2D arrays, it is recommended that programmers consider performing pitch allocations
/// using [`cuMemAllocPitch_v2`]. Due to alignment restrictions in the hardware, this is especially true if the application will be performing 2D memory copies
/// between different regions of device memory (whether linear memory or CUDA arrays).
///
/// The byte alignment of the pitch returned by [`cuMemAllocPitch_v2`] is guaranteed to match or exceed the alignment requirement for texture binding with [`cuTexRefSetAddress2D_v3`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMallocPitch](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g32bd7a39135594788a542ae72217775c).
///
/// # Parameters
///
/// - `dptr`: Returned device pointer.
/// - `pPitch`: Returned pitch of allocation in bytes.
/// - `WidthInBytes`: Requested allocation width in bytes.
/// - `Height`: Requested allocation height in rows.
/// - `ElementSizeBytes`: Size of largest reads/writes for range.
pub fn cuMemAllocPitch_v2(
dptr: *mut CUdeviceptr,
pPitch: *mut size_t,
WidthInBytes: size_t,
Height: size_t,
ElementSizeBytes: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Frees device memory.
///
/// Frees the memory space pointed to by dptr, which must have been returned by a previous call to one of the following memory allocation APIs - [`cuMemAlloc_v2`], [`cuMemAllocPitch_v2`], [`cuMemAllocManaged`], [`cuMemAllocAsync`], [`cuMemAllocFromPoolAsync`]
///
/// Note - This API will not perform any implict synchronization when the pointer was allocated with [`cuMemAllocAsync`] or [`cuMemAllocFromPoolAsync`]. Callers must ensure that all accesses to these pointer have completed before invoking [`cuMemFree_v2`]. For best performance and memory reuse, users should use [`cuMemFreeAsync`] to free memory allocated via the stream ordered memory allocator. For all other pointers, this API may perform implicit synchronization.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemAllocManaged`], [`cuMemAllocAsync`], [`cuMemAllocFromPoolAsync`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemFreeAsync`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaFree](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1ga042655cbbf3408f01061652a075e094).
///
/// # Parameters
///
/// - `dptr`: Pointer to memory to free.
pub fn cuMemFree_v2(dptr: CUdeviceptr) -> CUresult;
}
unsafe extern "C" {
/// Get information on memory allocations.
///
/// Returns the base address in \*pbase and size in \*psize of the allocation that contains the input pointer dptr. Both parameters pbase and psize are optional. If one of them is NULL, it is ignored.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`].
///
/// # Parameters
///
/// - `pbase`: Returned base address.
/// - `psize`: Returned size of device memory allocation.
/// - `dptr`: Device pointer to query.
pub fn cuMemGetAddressRange_v2(
pbase: *mut CUdeviceptr,
psize: *mut size_t,
dptr: CUdeviceptr,
) -> CUresult;
}
unsafe extern "C" {
/// Allocates page-locked host memory.
///
/// Allocates bytesize bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated
/// with this function and automatically accelerates calls to functions such as [`cuMemcpy`]. Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable
/// memory obtained with functions such as malloc().
///
/// On systems where [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`] is true, [`cuMemAllocHost_v2`] may not page-lock the allocated memory.
///
/// Page-locking excessive amounts of memory with [`cuMemAllocHost_v2`] may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this
/// function is best used sparingly to allocate staging areas for data exchange between host and device.
///
/// Note all host memory allocated using [`cuMemAllocHost_v2`] will automatically be immediately accessible to all contexts on all devices which support unified addressing (as may be queried
/// using [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING`]). The device pointer that may be used to access this host memory from those contexts is always equal to the returned host
/// pointer \*pp. See [Unified Addressing](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unified-addressing.html#group__CUDA__UNIFIED) for additional details.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMallocHost](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1gd5c991beb38e2b8419f50285707ae87e).
///
/// # Parameters
///
/// - `pp`: Returned pointer to host memory.
/// - `bytesize`: Requested allocation size in bytes.
pub fn cuMemAllocHost_v2(
pp: *mut *mut ::core::ffi::c_void,
bytesize: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Frees page-locked host memory.
///
/// Frees the memory space pointed to by p, which must have been returned by a previous call to [`cuMemAllocHost_v2`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaFreeHost](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g71c078689c17627566b2a91989184969).
///
/// # Parameters
///
/// - `p`: Pointer to memory to free.
pub fn cuMemFreeHost(p: *mut ::core::ffi::c_void) -> CUresult;
}
unsafe extern "C" {
/// Allocates page-locked host memory.
///
/// Allocates bytesize bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated
/// with this function and automatically accelerates calls to functions such as [`cuMemcpyHtoD_v2`]. Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable
/// memory obtained with functions such as malloc().
///
/// On systems where [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`] is true, [`cuMemHostAlloc`] may not page-lock the allocated memory.
///
/// Page-locking excessive amounts of memory may degrade system performance, since it reduces the amount of memory available to
/// the system for paging. As a result, this function is best used sparingly to allocate staging areas for data exchange between
/// host and device.
///
/// The Flags parameter enables different options to be specified that affect the allocation, as follows.
///
/// * [`CU_MEMHOSTALLOC_PORTABLE`]: The memory returned by this call will be considered as pinned memory by all CUDA contexts, not just the one that performed
/// the allocation.
///
/// * [`CU_MEMHOSTALLOC_DEVICEMAP`]: Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling [`cuMemHostGetDevicePointer_v2`].
///
/// * [`CU_MEMHOSTALLOC_WRITECOMBINED`]: Allocates the memory as write-combined (WC). WC memory can be transferred across the PCI Express bus more quickly on some
/// system configurations, but cannot be read efficiently by most CPUs. WC memory is a good option for buffers that will be written
/// by the CPU and read by the GPU via mapped pinned memory or host->device transfers.
///
/// All of these flags are orthogonal to one another: a developer may allocate memory that is portable, mapped and/or write-combined
/// with no restrictions.
///
/// The [`CU_MEMHOSTALLOC_DEVICEMAP`] flag may be specified on CUDA contexts for devices that do not support mapped pinned memory. The failure is deferred to [`cuMemHostGetDevicePointer_v2`] because the memory may be mapped into other CUDA contexts via the [`CU_MEMHOSTALLOC_PORTABLE`] flag.
///
/// The memory allocated by this function must be freed with [`cuMemFreeHost`].
///
/// Note all host memory allocated using [`cuMemHostAlloc`] will automatically be immediately accessible to all contexts on all devices which support unified addressing (as may be queried
/// using [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING`]). Unless the flag [`CU_MEMHOSTALLOC_WRITECOMBINED`] is specified, the device pointer that may be used to access this host memory from those contexts is always equal to the returned
/// host pointer \*pp. If the flag [`CU_MEMHOSTALLOC_WRITECOMBINED`] is specified, then the function [`cuMemHostGetDevicePointer_v2`] must be used to query the device pointer, even if the context supports unified addressing. See [Unified Addressing](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unified-addressing.html#group__CUDA__UNIFIED) for additional details.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaHostAlloc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gb65da58f444e7230d3322b6126bb4902).
///
/// # Parameters
///
/// - `pp`: Returned pointer to host memory.
/// - `bytesize`: Requested allocation size in bytes.
/// - `Flags`: Flags for allocation request.
pub fn cuMemHostAlloc(
pp: *mut *mut ::core::ffi::c_void,
bytesize: size_t,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Passes back device pointer of mapped pinned memory.
///
/// Passes back the device pointer pdptr corresponding to the mapped, pinned host buffer p allocated by [`cuMemHostAlloc`].
///
/// [`cuMemHostGetDevicePointer_v2`] will fail if the [`CU_MEMHOSTALLOC_DEVICEMAP`] flag was not specified at the time the memory was allocated, or if the function is called on a GPU that does not support
/// mapped pinned memory.
///
/// For devices that have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM`], the memory can also be accessed from the device using the host pointer p. The device pointer returned by [`cuMemHostGetDevicePointer_v2`] may or may not match the original host pointer p and depends on the devices visible to the application. If all devices visible to the application have a non-zero value for
/// the device attribute, the device pointer returned by [`cuMemHostGetDevicePointer_v2`] will match the original pointer p. If any device visible to the application has a zero value for the device attribute, the device pointer returned by [`cuMemHostGetDevicePointer_v2`] will not match the original host pointer p, but it will be suitable for use on all devices provided Unified Virtual Addressing is enabled. In such systems, it is valid
/// to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that
/// such devices should access the memory using only one of the two pointers and not both.
///
/// Flags provides for future releases. For now, it must be set to 0.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaHostGetDevicePointer](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gc00502b44e5f1bdc0b424487ebb08db0).
///
/// # Parameters
///
/// - `pdptr`: Returned device pointer.
/// - `p`: Host pointer.
/// - `Flags`: Options (must be 0).
pub fn cuMemHostGetDevicePointer_v2(
pdptr: *mut CUdeviceptr,
p: *mut ::core::ffi::c_void,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Passes back flags that were used for a pinned allocation.
///
/// Passes back the flags pFlags that were specified when allocating the pinned host buffer p allocated by [`cuMemHostAlloc`].
///
/// [`cuMemHostGetFlags`] will fail if the pointer does not reside in an allocation performed by [`cuMemAllocHost_v2`] or [`cuMemHostAlloc`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMemAllocHost_v2`], [`cuMemHostAlloc`], [cudaHostGetFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gc470e9220559109f5088d9a01c0aeeda).
///
/// # Parameters
///
/// - `pFlags`: Returned flags word.
/// - `p`: Host pointer.
pub fn cuMemHostGetFlags(
pFlags: *mut ::core::ffi::c_uint,
p: *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Allocates memory that will be automatically managed by the Unified Memory system.
///
/// Allocates bytesize bytes of managed memory on the device and returns in \*dptr a pointer to the allocated memory. If the device doesn't support allocating managed memory, [`cudaError_enum::CUDA_ERROR_NOT_SUPPORTED`] is returned. Support for managed memory can be queried using the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY`]. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. If bytesize is 0, [`cuMemAllocManaged`] returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]. The pointer is valid on the CPU and on all GPUs in the system that support managed memory. All accesses to this pointer
/// must obey the Unified Memory programming model.
///
/// flags specifies the default stream association for this allocation. flags must be one of [`CUmemAttach_flags_enum::CU_MEM_ATTACH_GLOBAL`] or [`CUmemAttach_flags_enum::CU_MEM_ATTACH_HOST`]. If [`CUmemAttach_flags_enum::CU_MEM_ATTACH_GLOBAL`] is specified, then this memory is accessible from any stream on any device. If [`CUmemAttach_flags_enum::CU_MEM_ATTACH_HOST`] is specified, then the allocation should not be accessed from devices that have a zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]; an explicit call to [`cuStreamAttachMemAsync`] will be required to enable access on such devices.
///
/// If the association is later changed via [`cuStreamAttachMemAsync`] to a single stream, the default association as specified during [`cuMemAllocManaged`] is restored when that stream is destroyed. For __managed__ variables, the default association is always [`CUmemAttach_flags_enum::CU_MEM_ATTACH_GLOBAL`]. Note that destroying a stream is an asynchronous operation, and as a result, the change to default association won't happen
/// until all work in the stream has completed.
///
/// Memory allocated with [`cuMemAllocManaged`] should be released with [`cuMemFree_v2`].
///
/// Device memory oversubscription is possible for GPUs that have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. Managed memory on such GPUs may be evicted from device memory to host memory at any time by the Unified Memory driver in
/// order to make room for other allocations.
///
/// In a system where all GPUs have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`], managed memory may not be populated when this API returns and instead may be populated on access. In such systems, managed
/// memory can migrate to any processor's memory at any time. The Unified Memory driver will employ heuristics to maintain data
/// locality and prevent excessive page faults to the extent possible. The application can also guide the driver about memory
/// usage patterns via [`cuMemAdvise_v2`]. The application can also explicitly migrate memory to a desired processor's memory via [`cuMemPrefetchAsync_v2`].
///
/// In a multi-GPU system where all of the GPUs have a zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] and all the GPUs have peer-to-peer support with each other, the physical storage for managed memory is created on the GPU
/// which is active at the time [`cuMemAllocManaged`] is called. All other GPUs will reference the data at reduced bandwidth via peer mappings over the PCIe bus. The Unified Memory
/// driver does not migrate memory among such GPUs.
///
/// In a multi-GPU system where not all GPUs have peer-to-peer support with each other and where the value of the device attribute
/// [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] is zero for at least one of those GPUs, the location chosen for physical storage of managed memory is system-dependent.
///
/// * On Linux, the location chosen will be device memory as long as the current set of active contexts are on devices that either
/// have peer-to-peer support with each other or have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. If there is an active context on a GPU that does not have a non-zero value for that device attribute and it does not have
/// peer-to-peer support with the other devices that have active contexts on them, then the location for physical storage will
/// be 'zero-copy' or host memory. Note that this means that managed memory that is located in device memory is migrated to host
/// memory if a new context is created on a GPU that doesn't have a non-zero value for the device attribute and does not support
/// peer-to-peer with at least one of the other devices that has an active context. This in turn implies that context creation
/// may fail if there is insufficient host memory to migrate all managed allocations.
/// * On Windows, the physical storage is always created in 'zero-copy' or host memory. All GPUs will reference the data at reduced
/// bandwidth over the PCIe bus. In these circumstances, use of the environment variable CUDA_VISIBLE_DEVICES is recommended to
/// restrict CUDA to only use those GPUs that have peer-to-peer support. Alternatively, users can also set CUDA_MANAGED_FORCE_DEVICE_ALLOC
/// to a non-zero value to force the driver to always use device memory for physical storage. When this environment variable is
/// set to a non-zero value, all contexts created in that process on devices that support managed memory have to be peer-to-peer
/// compatible with each other. Context creation will fail if a context is created on a device that supports managed memory and
/// is not peer-to-peer compatible with any of the other managed memory supporting devices on which contexts were previously created,
/// even if those contexts have been destroyed. These environment variables are described in the CUDA programming guide under
/// the "CUDA environment variables" section.
/// * On ARM, managed memory is not available on discrete gpu with Drive PX-2.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [`cuDeviceGetAttribute`], [`cuStreamAttachMemAsync`], [cudaMallocManaged](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e).
///
/// # Parameters
///
/// - `dptr`: Returned device pointer.
/// - `bytesize`: Requested allocation size in bytes.
/// - `flags`: Must be one of [`CUmemAttach_flags_enum::CU_MEM_ATTACH_GLOBAL`] or [`CUmemAttach_flags_enum::CU_MEM_ATTACH_HOST`].
pub fn cuMemAllocManaged(
dptr: *mut CUdeviceptr,
bytesize: size_t,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Registers a callback function to receive async notifications.
///
/// Registers callbackFunc to receive async notifications.
///
/// The userData parameter is passed to the callback function at async notification time. Likewise, callback is also passed to the callback function to distinguish between multiple registered callbacks.
///
/// The callback function being registered should be designed to return quickly (~10ms). Any long running tasks should be queued
/// for execution on an application thread.
///
/// Callbacks may not call cuDeviceRegisterAsyncNotification or cuDeviceUnregisterAsyncNotification. Doing so will result in [`cudaError_enum::CUDA_ERROR_NOT_PERMITTED`]. Async notification callbacks execute in an undefined order and may be serialized.
///
/// Returns in \*callback a handle representing the registered callback instance.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceUnregisterAsyncNotification`].
///
/// # Parameters
///
/// - `device`: The device on which to register the callback.
/// - `callbackFunc`: The function to register as a callback.
/// - `userData`: A generic pointer to user data. This is passed into the callback function.
/// - `callback`: A handle representing the registered callback instance.
pub fn cuDeviceRegisterAsyncNotification(
device: CUdevice,
callbackFunc: CUasyncCallback,
userData: *mut ::core::ffi::c_void,
callback: *mut CUasyncCallbackHandle,
) -> CUresult;
}
unsafe extern "C" {
/// Unregisters an async notification callback.
///
/// Unregisters callback so that the corresponding callback function will stop receiving async notifications.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceRegisterAsyncNotification`].
///
/// # Parameters
///
/// - `device`: The device from which to remove callback.
/// - `callback`: The callback instance to unregister from receiving async notifications.
pub fn cuDeviceUnregisterAsyncNotification(
device: CUdevice,
callback: CUasyncCallbackHandle,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a handle to a compute device.
///
/// Returns in \*device a device handle given a PCI bus ID string.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGet`], [`cuDeviceGetAttribute`], [`cuDeviceGetPCIBusId`], [cudaDeviceGetByPCIBusId](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g65f57fb8d0981ca03f6f9b20031c3e5d).
///
/// # Parameters
///
/// - `dev`: Returned device handle.
/// - `pciBusId`: String in one of the following forms: \[domain\]:\[bus\]:\[device\].\[function\] \[domain\]:\[bus\]:\[device\] \[bus\]:\[device\].\[function\]
/// where domain, bus, device, and function are all hexadecimal values.
pub fn cuDeviceGetByPCIBusId(
dev: *mut CUdevice,
pciBusId: *const ::core::ffi::c_char,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a PCI Bus Id string for the device.
///
/// Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by pciBusId. len specifies the maximum length of the string that may be returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGet`], [`cuDeviceGetAttribute`], [`cuDeviceGetByPCIBusId`], [cudaDeviceGetPCIBusId](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gea264dad3d8c4898e0b82213c0253def).
///
/// # Parameters
///
/// - `pciBusId`: Returned identifier string for the device in the following format \[domain\]:\[bus\]:\[device\].\[function\] where domain, bus, device, and function are all hexadecimal values. pciBusId should be large enough to store 13 characters including the NULL-terminator.
/// - `len`: Maximum length of string to store in name.
/// - `dev`: Device to get identifier string for.
pub fn cuDeviceGetPCIBusId(
pciBusId: *mut ::core::ffi::c_char,
len: ::core::ffi::c_int,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Gets an interprocess handle for a previously allocated event.
///
/// Takes as input a previously allocated event. This event must have been created with the [`CUevent_flags_enum::CU_EVENT_INTERPROCESS`] and [`CUevent_flags_enum::CU_EVENT_DISABLE_TIMING`] flags set. This opaque handle may be copied into other processes and opened with [`cuIpcOpenEventHandle`] to allow efficient hardware synchronization between GPU work in different processes.
///
/// After the event has been opened in the importing process, [`cuEventRecord`], [`cuEventSynchronize`], [`cuStreamWaitEvent`] and [`cuEventQuery`] may be used in either process. Performing operations on the imported event after the exported event has been freed with [`cuEventDestroy_v2`] will result in undefined behavior.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling [`cuDeviceGetAttribute`] with [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`]
///
/// **See also:**
///
/// [`cuEventCreate`], [`cuEventDestroy_v2`], [`cuEventSynchronize`], [`cuEventQuery`], [`cuStreamWaitEvent`], [`cuIpcOpenEventHandle`], [`cuIpcGetMemHandle`], [`cuIpcOpenMemHandle_v2`], [`cuIpcCloseMemHandle`], [cudaIpcGetEventHandle](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g89a3abe1e9a11d08c665176669109784).
///
/// # Parameters
///
/// - `pHandle`: Pointer to a user allocated CUipcEventHandle in which to return the opaque event handle.
/// - `event`: Event allocated with [`CUevent_flags_enum::CU_EVENT_INTERPROCESS`] and [`CUevent_flags_enum::CU_EVENT_DISABLE_TIMING`] flags.
pub fn cuIpcGetEventHandle(
pHandle: *mut CUipcEventHandle,
event: CUevent,
) -> CUresult;
}
unsafe extern "C" {
/// Opens an interprocess event handle for use in the current process.
///
/// Opens an interprocess event handle exported from another process with [`cuIpcGetEventHandle`]. This function returns a [`CUevent`] that behaves like a locally created event with the [`CUevent_flags_enum::CU_EVENT_DISABLE_TIMING`] flag specified. This event must be freed with [`cuEventDestroy_v2`].
///
/// Performing operations on the imported event after the exported event has been freed with [`cuEventDestroy_v2`] will result in undefined behavior.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling cuapiDeviceGetAttribute with [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`]
///
/// **See also:**
///
/// [`cuEventCreate`], [`cuEventDestroy_v2`], [`cuEventSynchronize`], [`cuEventQuery`], [`cuStreamWaitEvent`], [`cuIpcGetEventHandle`], [`cuIpcGetMemHandle`], [`cuIpcOpenMemHandle_v2`], [`cuIpcCloseMemHandle`], [cudaIpcOpenEventHandle](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g9691446ab0aec1d6e528357387ed87b2).
///
/// # Parameters
///
/// - `phEvent`: Returns the imported event.
/// - `handle`: Interprocess handle to open.
pub fn cuIpcOpenEventHandle(
phEvent: *mut CUevent,
handle: CUipcEventHandle,
) -> CUresult;
}
unsafe extern "C" {
/// Gets an interprocess memory handle for an existing device memory allocation.
///
/// Takes a pointer to the base of an existing device memory allocation created with [`cuMemAlloc_v2`] and exports it for use in another process. This is a lightweight operation and may be called multiple times on an allocation
/// without adverse effects.
///
/// If a region of memory is freed with [`cuMemFree_v2`] and a subsequent call to [`cuMemAlloc_v2`] returns memory with the same device address, [`cuIpcGetMemHandle`] will return a unique handle for the new memory.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling cuapiDeviceGetAttribute with [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`]
///
/// **See also:**
///
/// [`cuMemAlloc_v2`], [`cuMemFree_v2`], [`cuIpcGetEventHandle`], [`cuIpcOpenEventHandle`], [`cuIpcOpenMemHandle_v2`], [`cuIpcCloseMemHandle`], [cudaIpcGetMemHandle](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g8a37f7dfafaca652391d0758b3667539).
///
/// # Parameters
///
/// - `pHandle`: Pointer to user allocated CUipcMemHandle to return the handle in.
/// - `dptr`: Base pointer to previously allocated device memory.
pub fn cuIpcGetMemHandle(
pHandle: *mut CUipcMemHandle,
dptr: CUdeviceptr,
) -> CUresult;
}
unsafe extern "C" {
/// Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process.
///
/// Maps memory exported from another process with [`cuIpcGetMemHandle`] into the current device address space. For contexts on different devices [`cuIpcOpenMemHandle_v2`] can attempt to enable peer access between the devices as if the user called [`cuCtxEnablePeerAccess`]. This behavior is controlled by the [`CUipcMem_flags_enum::CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS`] flag. [`cuDeviceCanAccessPeer`] can determine if a mapping is possible.
///
/// Contexts that may open CUipcMemHandles are restricted in the following way. CUipcMemHandles from each [`CUdevice`] in a given process may only be opened by one [`CUcontext`] per [`CUdevice`] per other process.
///
/// If the memory handle has already been opened by the current context, the reference count on the handle is incremented by 1
/// and the existing device pointer is returned.
///
/// Memory returned from [`cuIpcOpenMemHandle_v2`] must be freed with [`cuIpcCloseMemHandle`].
///
/// Calling [`cuMemFree_v2`] on an exported memory region before calling [`cuIpcCloseMemHandle`] in the importing context will result in undefined behavior.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling cuapiDeviceGetAttribute with [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`]
///
/// Note:
///
/// No guarantees are made about the address returned in \*pdptr. In particular, multiple processes may not receive the same address for the same handle.
///
/// **See also:**
///
/// [`cuMemAlloc_v2`], [`cuMemFree_v2`], [`cuIpcGetEventHandle`], [`cuIpcOpenEventHandle`], [`cuIpcGetMemHandle`], [`cuIpcCloseMemHandle`], [`cuCtxEnablePeerAccess`], [`cuDeviceCanAccessPeer`], [cudaIpcOpenMemHandle](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g01050a29fefde385b1042081ada4cde9).
///
/// # Parameters
///
/// - `pdptr`: Returned device pointer.
/// - `handle`: CUipcMemHandle to open.
/// - `Flags`: Flags for this operation. Must be specified as [`CUipcMem_flags_enum::CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS`].
pub fn cuIpcOpenMemHandle_v2(
pdptr: *mut CUdeviceptr,
handle: CUipcMemHandle,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Attempts to close memory mapped with cuIpcOpenMemHandle.
///
/// Decrements the reference count of the memory returned by [`cuIpcOpenMemHandle_v2`] by 1. When the reference count reaches 0, this API unmaps the memory. The original allocation in the exporting process as
/// well as imported mappings in other processes will be unaffected.
///
/// Any resources used to enable peer access will be freed if this is the last mapping using them.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling cuapiDeviceGetAttribute with [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`]
///
/// **See also:**
///
/// [`cuMemAlloc_v2`], [`cuMemFree_v2`], [`cuIpcGetEventHandle`], [`cuIpcOpenEventHandle`], [`cuIpcGetMemHandle`], [`cuIpcOpenMemHandle_v2`], [cudaIpcCloseMemHandle](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g02bb3632b5d223db6acae5f8744e2c91).
///
/// # Parameters
///
/// - `dptr`: Device pointer returned by [`cuIpcOpenMemHandle_v2`].
pub fn cuIpcCloseMemHandle(dptr: CUdeviceptr) -> CUresult;
}
unsafe extern "C" {
/// Registers an existing host memory range for use by CUDA.
///
/// Page-locks the memory range specified by p and bytesize and maps it for the device(s) as specified by Flags. This memory range also is added to the same tracking mechanism as [`cuMemHostAlloc`] to automatically accelerate calls to functions such as [`cuMemcpyHtoD_v2`]. Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable
/// memory that has not been registered. Page-locking excessive amounts of memory may degrade system performance, since it reduces
/// the amount of memory available to the system for paging. As a result, this function is best used sparingly to register staging
/// areas for data exchange between host and device.
///
/// On systems where [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`] is true, [`cuMemHostRegister_v2`] will not page-lock the memory range specified by ptr but only populate unpopulated pages.
///
/// The Flags parameter enables different options to be specified that affect the allocation, as follows.
///
/// * [`CU_MEMHOSTREGISTER_PORTABLE`]: The memory returned by this call will be considered as pinned memory by all CUDA contexts, not just the one that performed
/// the allocation.
///
/// * [`CU_MEMHOSTREGISTER_DEVICEMAP`]: Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling [`cuMemHostGetDevicePointer_v2`].
///
/// * [`CU_MEMHOSTREGISTER_IOMEMORY`]: The pointer is treated as pointing to some I/O memory space, e.g. the PCI Express resource of a 3rd party device.
///
/// * [`CU_MEMHOSTREGISTER_READ_ONLY`]: The pointer is treated as pointing to memory that is considered read-only by the device. On platforms without [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`], this flag is required in order to register memory mapped to the CPU as read-only. Support for the use of this flag can be
/// queried from the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_READ_ONLY_HOST_REGISTER_SUPPORTED`]. Using this flag with a current context associated with a device that does not have this attribute set will cause [`cuMemHostRegister_v2`] to error with [`CUresult::CUDA_ERROR_NOT_SUPPORTED`].
///
/// All of these flags are orthogonal to one another: a developer may page-lock memory that is portable or mapped with no restrictions.
///
/// The [`CU_MEMHOSTREGISTER_DEVICEMAP`] flag may be specified on CUDA contexts for devices that do not support mapped pinned memory. The failure is deferred to [`cuMemHostGetDevicePointer_v2`] because the memory may be mapped into other CUDA contexts via the [`CU_MEMHOSTREGISTER_PORTABLE`] flag.
///
/// For devices that have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM`], the memory can also be accessed from the device using the host pointer p. The device pointer returned by [`cuMemHostGetDevicePointer_v2`] may or may not match the original host pointer ptr and depends on the devices visible to the application. If all devices visible to the application have a non-zero value for
/// the device attribute, the device pointer returned by [`cuMemHostGetDevicePointer_v2`] will match the original pointer ptr. If any device visible to the application has a zero value for the device attribute, the device pointer returned by [`cuMemHostGetDevicePointer_v2`] will not match the original host pointer ptr, but it will be suitable for use on all devices provided Unified Virtual Addressing is enabled. In such systems, it is valid
/// to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that
/// such devices should access the memory using only of the two pointers and not both.
///
/// The memory page-locked by this function must be unregistered with [`cuMemHostUnregister`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMemHostUnregister`], [`cuMemHostGetFlags`], [`cuMemHostGetDevicePointer_v2`], [cudaHostRegister](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1ge8d5c17670f16ac4fc8fcb4181cb490c).
///
/// # Parameters
///
/// - `p`: Host pointer to memory to page-lock.
/// - `bytesize`: Size in bytes of the address range to page-lock.
/// - `Flags`: Flags for allocation request.
pub fn cuMemHostRegister_v2(
p: *mut ::core::ffi::c_void,
bytesize: size_t,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Unregisters a memory range that was registered with cuMemHostRegister.
///
/// Unmaps the memory range whose base address is specified by p, and makes it pageable again.
///
/// The base address must be the same one specified to [`cuMemHostRegister_v2`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMemHostRegister_v2`], [cudaHostUnregister](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g81fd4101862bbefdb42a62d60e515eea).
///
/// # Parameters
///
/// - `p`: Host pointer to memory to unregister.
pub fn cuMemHostUnregister(p: *mut ::core::ffi::c_void) -> CUresult;
}
unsafe extern "C" {
/// Copies memory.
///
/// Copies data between two pointers. dst and src are base pointers of the destination and source, respectively. ByteCount specifies the number of bytes to copy. Note that this function infers the type of the transfer (host to host, host to device,
/// device to device, or device to host) from the pointer values. This function is only allowed in contexts which support unified
/// addressing.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gc263dbe6574220cc776b45438fc351e8), [cudaMemcpyToSymbol](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe), [cudaMemcpyFromSymbol](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f).
///
/// # Parameters
///
/// - `dst`: Destination unified virtual address space pointer.
/// - `src`: Source unified virtual address space pointer.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpy(dst: CUdeviceptr, src: CUdeviceptr, ByteCount: size_t) -> CUresult;
}
unsafe extern "C" {
/// Copies device memory between two contexts.
///
/// Copies from device memory in one context to device memory in another context. dstDevice is the base device pointer of the destination memory and dstContext is the destination context. srcDevice is the base device pointer of the source memory and srcContext is the source pointer. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuMemcpyDtoD_v2`], [`cuMemcpy3DPeer`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyPeerAsync`], [`cuMemcpy3DPeerAsync`], [cudaMemcpyPeer](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g88fd1245b2cb10d2d30c74900b7dfb9c).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `dstContext`: Destination context.
/// - `srcDevice`: Source device pointer.
/// - `srcContext`: Source context.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpyPeer(
dstDevice: CUdeviceptr,
dstContext: CUcontext,
srcDevice: CUdeviceptr,
srcContext: CUcontext,
ByteCount: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Host to Device.
///
/// Copies from host memory to device memory. dstDevice and srcHost are the base addresses of the destination and source, respectively. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gc263dbe6574220cc776b45438fc351e8), [cudaMemcpyToSymbol](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `srcHost`: Source host pointer.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpyHtoD_v2(
dstDevice: CUdeviceptr,
srcHost: *const ::core::ffi::c_void,
ByteCount: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Device to Host.
///
/// Copies from device to host memory. dstHost and srcDevice specify the base pointers of the destination and source, respectively. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gc263dbe6574220cc776b45438fc351e8), [cudaMemcpyFromSymbol](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f).
///
/// # Parameters
///
/// - `dstHost`: Destination host pointer.
/// - `srcDevice`: Source device pointer.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpyDtoH_v2(
dstHost: *mut ::core::ffi::c_void,
srcDevice: CUdeviceptr,
ByteCount: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Device to Device.
///
/// Copies from device memory to device memory. dstDevice and srcDevice are the base pointers of the destination and source, respectively. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gc263dbe6574220cc776b45438fc351e8), [cudaMemcpyToSymbol](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe), [cudaMemcpyFromSymbol](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `srcDevice`: Source device pointer.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpyDtoD_v2(
dstDevice: CUdeviceptr,
srcDevice: CUdeviceptr,
ByteCount: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Device to Array.
///
/// Copies from device memory to a 1D CUDA array. dstArray and dstOffset specify the CUDA array handle and starting index of the destination data. srcDevice specifies the base pointer of the source. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpyToArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY__DEPRECATED.html#group__CUDART__MEMORY__DEPRECATED_1g15b5d20cedf31dd13801c6015da0e828).
///
/// # Parameters
///
/// - `dstArray`: Destination array.
/// - `dstOffset`: Offset in bytes of destination array.
/// - `srcDevice`: Source device pointer.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpyDtoA_v2(
dstArray: CUarray,
dstOffset: size_t,
srcDevice: CUdeviceptr,
ByteCount: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Array to Device.
///
/// Copies from one 1D CUDA array to device memory. dstDevice specifies the base pointer of the destination and must be naturally aligned with the CUDA array elements. srcArray and srcOffset specify the CUDA array handle and the offset in bytes into the array where the copy is to begin. ByteCount specifies the number of bytes to copy and must be evenly divisible by the array element size.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpyFromArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY__DEPRECATED.html#group__CUDART__MEMORY__DEPRECATED_1g6fbe8ed786061afaeaf79dc17eef15e9).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `srcArray`: Source array.
/// - `srcOffset`: Offset in bytes of source array.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpyAtoD_v2(
dstDevice: CUdeviceptr,
srcArray: CUarray,
srcOffset: size_t,
ByteCount: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Host to Array.
///
/// Copies from host memory to a 1D CUDA array. dstArray and dstOffset specify the CUDA array handle and starting offset in bytes of the destination data. pSrc specifies the base address of the source. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpyToArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY__DEPRECATED.html#group__CUDART__MEMORY__DEPRECATED_1g15b5d20cedf31dd13801c6015da0e828).
///
/// # Parameters
///
/// - `dstArray`: Destination array.
/// - `dstOffset`: Offset in bytes of destination array.
/// - `srcHost`: Source host pointer.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpyHtoA_v2(
dstArray: CUarray,
dstOffset: size_t,
srcHost: *const ::core::ffi::c_void,
ByteCount: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Array to Host.
///
/// Copies from one 1D CUDA array to host memory. dstHost specifies the base pointer of the destination. srcArray and srcOffset specify the CUDA array handle and starting offset in bytes of the source data. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpyFromArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY__DEPRECATED.html#group__CUDART__MEMORY__DEPRECATED_1g6fbe8ed786061afaeaf79dc17eef15e9).
///
/// # Parameters
///
/// - `dstHost`: Destination device pointer.
/// - `srcArray`: Source array.
/// - `srcOffset`: Offset in bytes of source array.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpyAtoH_v2(
dstHost: *mut ::core::ffi::c_void,
srcArray: CUarray,
srcOffset: size_t,
ByteCount: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Array to Array.
///
/// Copies from one 1D CUDA array to another. dstArray and srcArray specify the handles of the destination and source CUDA arrays for the copy, respectively. dstOffset and srcOffset specify the destination and source offsets in bytes into the CUDA arrays. ByteCount is the number of bytes to be copied. The size of the elements in the CUDA arrays need not be the same format, but the elements
/// must be the same size; and count must be evenly divisible by that size.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpyArrayToArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY__DEPRECATED.html#group__CUDART__MEMORY__DEPRECATED_1g5daffa65811c6be7eba1ec3c6c19ddb0).
///
/// # Parameters
///
/// - `dstArray`: Destination array.
/// - `dstOffset`: Offset in bytes of destination array.
/// - `srcArray`: Source array.
/// - `srcOffset`: Offset in bytes of source array.
/// - `ByteCount`: Size of memory copy in bytes.
pub fn cuMemcpyAtoA_v2(
dstArray: CUarray,
dstOffset: size_t,
srcArray: CUarray,
srcOffset: size_t,
ByteCount: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory for 2D arrays.
///
/// Perform a 2D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY2D structure is defined as:
///
/// ```text
/// typedef struct CUDA_MEMCPY2D_st {
/// unsigned int srcXInBytes, srcY;
/// CUmemorytype srcMemoryType;
/// const void *srcHost;
/// CUdeviceptr srcDevice;
/// CUarray srcArray;
/// unsigned int srcPitch;
///
/// unsigned int dstXInBytes, dstY;
/// CUmemorytype dstMemoryType;
/// void *dstHost;
/// CUdeviceptr dstDevice;
/// CUarray dstArray;
/// unsigned int dstPitch;
///
/// unsigned int WidthInBytes;
/// unsigned int Height;
/// } CUDA_MEMCPY2D;
/// ```
///
/// * srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively; CUmemorytype_enum
/// is defined as:
///
/// ```text
/// typedef enum CUmemorytype_enum {
/// CU_MEMORYTYPE_HOST = 0x01,
/// CU_MEMORYTYPE_DEVICE = 0x02,
/// CU_MEMORYTYPE_ARRAY = 0x03,
/// CU_MEMORYTYPE_UNIFIED = 0x04
/// } CUmemorytype;
/// ```
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], srcDevice and srcPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. srcArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], srcHost and srcPitch specify the (host) base address of the source data and the bytes per row to apply. srcArray is ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], srcDevice and srcPitch specify the (device) base address of the source data and the bytes per row to apply. srcArray is
/// ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], srcArray specifies the handle of the source data. srcHost, srcDevice and srcPitch are ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], dstHost and dstPitch specify the (host) base address of the destination data and the bytes per row to apply. dstArray is
/// ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], dstDevice and dstPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. dstArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], dstDevice and dstPitch specify the (device) base address of the destination data and the bytes per row to apply. dstArray
/// is ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], dstArray specifies the handle of the destination data. dstHost, dstDevice and dstPitch are ignored.
///
/// * srcXInBytes and srcY specify the base address of the source data for the copy.
///
/// For host pointers, the starting address is
///
/// ```text
/// void* Start = (void*)((char*)srcHost+srcY*srcPitch + srcXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr Start = srcDevice+srcY*srcPitch+srcXInBytes;
/// ```
///
/// For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
///
/// * dstXInBytes and dstY specify the base address of the destination data for the copy.
///
/// For host pointers, the base address is
///
/// ```text
/// void* dstStart = (void*)((char*)dstHost+dstY*dstPitch + dstXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr dstStart = dstDevice+dstY*dstPitch+dstXInBytes;
/// ```
///
/// For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
///
/// * WidthInBytes and Height specify the width (in bytes) and height of the 2D copy being performed.
/// * If specified, srcPitch must be greater than or equal to WidthInBytes + srcXInBytes, and dstPitch must be greater than or equal
/// to WidthInBytes + dstXInBytes.
///
/// [`cuMemcpy2D_v2`] returns an error if any pitch is greater than the maximum allowed ([`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_PITCH`]). [`cuMemAllocPitch_v2`] passes back pitches that always work with [`cuMemcpy2D_v2`]. On intra-device memory copies (device to device, CUDA array to device, CUDA array to CUDA array), [`cuMemcpy2D_v2`] may fail for pitches not computed by [`cuMemAllocPitch_v2`]. [`cuMemcpy2DUnaligned_v2`] does not have this restriction, but may run significantly slower in the cases where [`cuMemcpy2D_v2`] would have returned an error code.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpy2D](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g3a58270f6775efe56c65ac47843e7cee), [cudaMemcpy2DToArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g9509226164aaa58baf0c5b8ed165df58), [cudaMemcpy2DFromArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g0f944b3fd3c81edad0a352cf22de24f0).
///
/// # Parameters
///
/// - `pCopy`: Parameters for the memory copy.
pub fn cuMemcpy2D_v2(pCopy: *const CUDA_MEMCPY2D) -> CUresult;
}
unsafe extern "C" {
/// Copies memory for 2D arrays.
///
/// Perform a 2D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY2D structure is defined as:
///
/// ```text
/// typedef struct CUDA_MEMCPY2D_st {
/// unsigned int srcXInBytes, srcY;
/// CUmemorytype srcMemoryType;
/// const void *srcHost;
/// CUdeviceptr srcDevice;
/// CUarray srcArray;
/// unsigned int srcPitch;
/// unsigned int dstXInBytes, dstY;
/// CUmemorytype dstMemoryType;
/// void *dstHost;
/// CUdeviceptr dstDevice;
/// CUarray dstArray;
/// unsigned int dstPitch;
/// unsigned int WidthInBytes;
/// unsigned int Height;
/// } CUDA_MEMCPY2D;
/// ```
///
/// * srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively; CUmemorytype_enum
/// is defined as:
///
/// ```text
/// typedef enum CUmemorytype_enum {
/// CU_MEMORYTYPE_HOST = 0x01,
/// CU_MEMORYTYPE_DEVICE = 0x02,
/// CU_MEMORYTYPE_ARRAY = 0x03,
/// CU_MEMORYTYPE_UNIFIED = 0x04
/// } CUmemorytype;
/// ```
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], srcDevice and srcPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. srcArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], srcHost and srcPitch specify the (host) base address of the source data and the bytes per row to apply. srcArray is ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], srcDevice and srcPitch specify the (device) base address of the source data and the bytes per row to apply. srcArray is
/// ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], srcArray specifies the handle of the source data. srcHost, srcDevice and srcPitch are ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], dstDevice and dstPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. dstArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], dstHost and dstPitch specify the (host) base address of the destination data and the bytes per row to apply. dstArray is
/// ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], dstDevice and dstPitch specify the (device) base address of the destination data and the bytes per row to apply. dstArray
/// is ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], dstArray specifies the handle of the destination data. dstHost, dstDevice and dstPitch are ignored.
///
/// * srcXInBytes and srcY specify the base address of the source data for the copy.
///
/// For host pointers, the starting address is
///
/// ```text
/// void* Start = (void*)((char*)srcHost+srcY*srcPitch + srcXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr Start = srcDevice+srcY*srcPitch+srcXInBytes;
/// ```
///
/// For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
///
/// * dstXInBytes and dstY specify the base address of the destination data for the copy.
///
/// For host pointers, the base address is
///
/// ```text
/// void* dstStart = (void*)((char*)dstHost+dstY*dstPitch + dstXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr dstStart = dstDevice+dstY*dstPitch+dstXInBytes;
/// ```
///
/// For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
///
/// * WidthInBytes and Height specify the width (in bytes) and height of the 2D copy being performed.
/// * If specified, srcPitch must be greater than or equal to WidthInBytes + srcXInBytes, and dstPitch must be greater than or equal
/// to WidthInBytes + dstXInBytes.
///
/// [`cuMemcpy2D_v2`] returns an error if any pitch is greater than the maximum allowed ([`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_PITCH`]). [`cuMemAllocPitch_v2`] passes back pitches that always work with [`cuMemcpy2D_v2`]. On intra-device memory copies (device to device, CUDA array to device, CUDA array to CUDA array), [`cuMemcpy2D_v2`] may fail for pitches not computed by [`cuMemAllocPitch_v2`]. [`cuMemcpy2DUnaligned_v2`] does not have this restriction, but may run significantly slower in the cases where [`cuMemcpy2D_v2`] would have returned an error code.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpy2D](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g3a58270f6775efe56c65ac47843e7cee), [cudaMemcpy2DToArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g9509226164aaa58baf0c5b8ed165df58), [cudaMemcpy2DFromArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g0f944b3fd3c81edad0a352cf22de24f0).
///
/// # Parameters
///
/// - `pCopy`: Parameters for the memory copy.
pub fn cuMemcpy2DUnaligned_v2(pCopy: *const CUDA_MEMCPY2D) -> CUresult;
}
unsafe extern "C" {
/// Copies memory for 3D arrays.
///
/// Perform a 3D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY3D structure is defined as:
///
/// ```text
/// typedef struct CUDA_MEMCPY3D_st {
///
/// unsigned int srcXInBytes, srcY, srcZ;
/// unsigned int srcLOD;
/// CUmemorytype srcMemoryType;
/// const void *srcHost;
/// CUdeviceptr srcDevice;
/// CUarray srcArray;
/// unsigned int srcPitch; // ignored when src is array
/// unsigned int srcHeight; // ignored when src is array; may be 0 if Depth==1
///
/// unsigned int dstXInBytes, dstY, dstZ;
/// unsigned int dstLOD;
/// CUmemorytype dstMemoryType;
/// void *dstHost;
/// CUdeviceptr dstDevice;
/// CUarray dstArray;
/// unsigned int dstPitch; // ignored when dst is array
/// unsigned int dstHeight; // ignored when dst is array; may be 0 if Depth==1
///
/// unsigned int WidthInBytes;
/// unsigned int Height;
/// unsigned int Depth;
/// } CUDA_MEMCPY3D;
/// ```
///
/// * srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively; CUmemorytype_enum
/// is defined as:
///
/// ```text
/// typedef enum CUmemorytype_enum {
/// CU_MEMORYTYPE_HOST = 0x01,
/// CU_MEMORYTYPE_DEVICE = 0x02,
/// CU_MEMORYTYPE_ARRAY = 0x03,
/// CU_MEMORYTYPE_UNIFIED = 0x04
/// } CUmemorytype;
/// ```
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], srcDevice and srcPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. srcArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], srcHost, srcPitch and srcHeight specify the (host) base address of the source data, the bytes per row, and the height of
/// each 2D slice of the 3D array. srcArray is ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], srcDevice, srcPitch and srcHeight specify the (device) base address of the source data, the bytes per row, and the height
/// of each 2D slice of the 3D array. srcArray is ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], srcArray specifies the handle of the source data. srcHost, srcDevice, srcPitch and srcHeight are ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], dstDevice and dstPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. dstArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], dstHost and dstPitch specify the (host) base address of the destination data, the bytes per row, and the height of each
/// 2D slice of the 3D array. dstArray is ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], dstDevice and dstPitch specify the (device) base address of the destination data, the bytes per row, and the height of each
/// 2D slice of the 3D array. dstArray is ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], dstArray specifies the handle of the destination data. dstHost, dstDevice, dstPitch and dstHeight are ignored.
///
/// * srcXInBytes, srcY and srcZ specify the base address of the source data for the copy.
///
/// For host pointers, the starting address is
///
/// ```text
/// void* Start = (void*)((char*)srcHost+(srcZ*srcHeight+srcY)*srcPitch + srcXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr Start = srcDevice+(srcZ*srcHeight+srcY)*srcPitch+srcXInBytes;
/// ```
///
/// For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
///
/// * dstXInBytes, dstY and dstZ specify the base address of the destination data for the copy.
///
/// For host pointers, the base address is
///
/// ```text
/// void* dstStart = (void*)((char*)dstHost+(dstZ*dstHeight+dstY)*dstPitch + dstXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr dstStart = dstDevice+(dstZ*dstHeight+dstY)*dstPitch+dstXInBytes;
/// ```
///
/// For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
///
/// * WidthInBytes, Height and Depth specify the width (in bytes), height and depth of the 3D copy being performed.
/// * If specified, srcPitch must be greater than or equal to WidthInBytes + srcXInBytes, and dstPitch must be greater than or equal
/// to WidthInBytes + dstXInBytes.
/// * If specified, srcHeight must be greater than or equal to Height + srcY, and dstHeight must be greater than or equal to Height
/// + dstY.
///
/// [`cuMemcpy3D_v2`] returns an error if any pitch is greater than the maximum allowed ([`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_PITCH`]).
///
/// The srcLOD and dstLOD members of the CUDA_MEMCPY3D structure must be set to 0.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMemcpy3D](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gfec7ee5257d48c8528a709ffad48d208).
///
/// # Parameters
///
/// - `pCopy`: Parameters for the memory copy.
pub fn cuMemcpy3D_v2(pCopy: *const CUDA_MEMCPY3D) -> CUresult;
}
unsafe extern "C" {
/// Copies memory between contexts.
///
/// Perform a 3D memory copy according to the parameters specified in pCopy. See the definition of the CUDA_MEMCPY3D_PEER structure for documentation of its parameters.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuMemcpyDtoD_v2`], [`cuMemcpyPeer`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyPeerAsync`], [`cuMemcpy3DPeerAsync`], [cudaMemcpy3DPeer](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1geeab4601354962a5968eefc8b79ec2dd).
///
/// # Parameters
///
/// - `pCopy`: Parameters for the memory copy.
pub fn cuMemcpy3DPeer(pCopy: *const CUDA_MEMCPY3D_PEER) -> CUresult;
}
unsafe extern "C" {
/// Copies memory asynchronously.
///
/// Copies data between two pointers. dst and src are base pointers of the destination and source, respectively. ByteCount specifies the number of bytes to copy. Note that this function infers the type of the transfer (host to host, host to device,
/// device to device, or device to host) from the pointer values. This function is only allowed in contexts which support unified
/// addressing.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemcpyAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a), [cudaMemcpyToSymbolAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5), [cudaMemcpyFromSymbolAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946).
///
/// # Parameters
///
/// - `dst`: Destination unified virtual address space pointer.
/// - `src`: Source unified virtual address space pointer.
/// - `ByteCount`: Size of memory copy in bytes.
/// - `hStream`: Stream identifier.
pub fn cuMemcpyAsync(
dst: CUdeviceptr,
src: CUdeviceptr,
ByteCount: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Copies device memory between two contexts asynchronously.
///
/// Copies from device memory in one context to device memory in another context. dstDevice is the base device pointer of the destination memory and dstContext is the destination context. srcDevice is the base device pointer of the source memory and srcContext is the source pointer. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuMemcpyDtoD_v2`], [`cuMemcpyPeer`], [`cuMemcpy3DPeer`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpy3DPeerAsync`], [cudaMemcpyPeerAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gbfde4ace9ff4823f4ac45e5c6bdcd2ee).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `dstContext`: Destination context.
/// - `srcDevice`: Source device pointer.
/// - `srcContext`: Source context.
/// - `ByteCount`: Size of memory copy in bytes.
/// - `hStream`: Stream identifier.
pub fn cuMemcpyPeerAsync(
dstDevice: CUdeviceptr,
dstContext: CUcontext,
srcDevice: CUdeviceptr,
srcContext: CUcontext,
ByteCount: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Host to Device.
///
/// Copies from host memory to device memory. dstDevice and srcHost are the base addresses of the destination and source, respectively. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemcpyAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a), [cudaMemcpyToSymbolAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `srcHost`: Source host pointer.
/// - `ByteCount`: Size of memory copy in bytes.
/// - `hStream`: Stream identifier.
pub fn cuMemcpyHtoDAsync_v2(
dstDevice: CUdeviceptr,
srcHost: *const ::core::ffi::c_void,
ByteCount: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Device to Host.
///
/// Copies from device to host memory. dstHost and srcDevice specify the base pointers of the destination and source, respectively. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemcpyAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a), [cudaMemcpyFromSymbolAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946).
///
/// # Parameters
///
/// - `dstHost`: Destination host pointer.
/// - `srcDevice`: Source device pointer.
/// - `ByteCount`: Size of memory copy in bytes.
/// - `hStream`: Stream identifier.
pub fn cuMemcpyDtoHAsync_v2(
dstHost: *mut ::core::ffi::c_void,
srcDevice: CUdeviceptr,
ByteCount: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Device to Device.
///
/// Copies from device memory to device memory. dstDevice and srcDevice are the base pointers of the destination and source, respectively. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemcpyAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a), [cudaMemcpyToSymbolAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5), [cudaMemcpyFromSymbolAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `srcDevice`: Source device pointer.
/// - `ByteCount`: Size of memory copy in bytes.
/// - `hStream`: Stream identifier.
pub fn cuMemcpyDtoDAsync_v2(
dstDevice: CUdeviceptr,
srcDevice: CUdeviceptr,
ByteCount: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Host to Array.
///
/// Copies from host memory to a 1D CUDA array. dstArray and dstOffset specify the CUDA array handle and starting offset in bytes of the destination data. srcHost specifies the base address of the source. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemcpyToArrayAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY__DEPRECATED.html#group__CUDART__MEMORY__DEPRECATED_1g92f0eaaaa772fd428dfc7c7ba699d272).
///
/// # Parameters
///
/// - `dstArray`: Destination array.
/// - `dstOffset`: Offset in bytes of destination array.
/// - `srcHost`: Source host pointer.
/// - `ByteCount`: Size of memory copy in bytes.
/// - `hStream`: Stream identifier.
pub fn cuMemcpyHtoAAsync_v2(
dstArray: CUarray,
dstOffset: size_t,
srcHost: *const ::core::ffi::c_void,
ByteCount: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory from Array to Host.
///
/// Copies from one 1D CUDA array to host memory. dstHost specifies the base pointer of the destination. srcArray and srcOffset specify the CUDA array handle and starting offset in bytes of the source data. ByteCount specifies the number of bytes to copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemcpyFromArrayAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY__DEPRECATED.html#group__CUDART__MEMORY__DEPRECATED_1gfa22cfe6148b4c82593ecf3582f1dc33).
///
/// # Parameters
///
/// - `dstHost`: Destination pointer.
/// - `srcArray`: Source array.
/// - `srcOffset`: Offset in bytes of source array.
/// - `ByteCount`: Size of memory copy in bytes.
/// - `hStream`: Stream identifier.
pub fn cuMemcpyAtoHAsync_v2(
dstHost: *mut ::core::ffi::c_void,
srcArray: CUarray,
srcOffset: size_t,
ByteCount: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory for 2D arrays.
///
/// Perform a 2D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY2D structure is defined as:
///
/// ```text
/// typedef struct CUDA_MEMCPY2D_st {
/// unsigned int srcXInBytes, srcY;
/// CUmemorytype srcMemoryType;
/// const void *srcHost;
/// CUdeviceptr srcDevice;
/// CUarray srcArray;
/// unsigned int srcPitch;
/// unsigned int dstXInBytes, dstY;
/// CUmemorytype dstMemoryType;
/// void *dstHost;
/// CUdeviceptr dstDevice;
/// CUarray dstArray;
/// unsigned int dstPitch;
/// unsigned int WidthInBytes;
/// unsigned int Height;
/// } CUDA_MEMCPY2D;
/// ```
///
/// * srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively; CUmemorytype_enum
/// is defined as:
///
/// ```text
/// typedef enum CUmemorytype_enum {
/// CU_MEMORYTYPE_HOST = 0x01,
/// CU_MEMORYTYPE_DEVICE = 0x02,
/// CU_MEMORYTYPE_ARRAY = 0x03,
/// CU_MEMORYTYPE_UNIFIED = 0x04
/// } CUmemorytype;
/// ```
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], srcHost and srcPitch specify the (host) base address of the source data and the bytes per row to apply. srcArray is ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], srcDevice and srcPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. srcArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], srcDevice and srcPitch specify the (device) base address of the source data and the bytes per row to apply. srcArray is
/// ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], srcArray specifies the handle of the source data. srcHost, srcDevice and srcPitch are ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], dstDevice and dstPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. dstArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], dstHost and dstPitch specify the (host) base address of the destination data and the bytes per row to apply. dstArray is
/// ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], dstDevice and dstPitch specify the (device) base address of the destination data and the bytes per row to apply. dstArray
/// is ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], dstArray specifies the handle of the destination data. dstHost, dstDevice and dstPitch are ignored.
///
/// * srcXInBytes and srcY specify the base address of the source data for the copy.
///
/// For host pointers, the starting address is
///
/// ```text
/// void* Start = (void*)((char*)srcHost+srcY*srcPitch + srcXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr Start = srcDevice+srcY*srcPitch+srcXInBytes;
/// ```
///
/// For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
///
/// * dstXInBytes and dstY specify the base address of the destination data for the copy.
///
/// For host pointers, the base address is
///
/// ```text
/// void* dstStart = (void*)((char*)dstHost+dstY*dstPitch + dstXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr dstStart = dstDevice+dstY*dstPitch+dstXInBytes;
/// ```
///
/// For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
///
/// * WidthInBytes and Height specify the width (in bytes) and height of the 2D copy being performed.
/// * If specified, srcPitch must be greater than or equal to WidthInBytes + srcXInBytes, and dstPitch must be greater than or equal
/// to WidthInBytes + dstXInBytes.
/// * If specified, srcPitch must be greater than or equal to WidthInBytes + srcXInBytes, and dstPitch must be greater than or equal
/// to WidthInBytes + dstXInBytes.
/// * If specified, srcHeight must be greater than or equal to Height + srcY, and dstHeight must be greater than or equal to Height
/// + dstY.
///
/// [`cuMemcpy2DAsync_v2`] returns an error if any pitch is greater than the maximum allowed ([`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_PITCH`]). [`cuMemAllocPitch_v2`] passes back pitches that always work with [`cuMemcpy2D_v2`]. On intra-device memory copies (device to device, CUDA array to device, CUDA array to CUDA array), [`cuMemcpy2DAsync_v2`] may fail for pitches not computed by [`cuMemAllocPitch_v2`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemcpy2DAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1ge529b926e8fb574c2666a9a1d58b0dc1), [cudaMemcpy2DToArrayAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g217af4b9e2de79d9252418fc661e6a6a), [cudaMemcpy2DFromArrayAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g1c81de45e9ed5e72008a8f28e706b599).
///
/// # Parameters
///
/// - `pCopy`: Parameters for the memory copy.
/// - `hStream`: Stream identifier.
pub fn cuMemcpy2DAsync_v2(
pCopy: *const CUDA_MEMCPY2D,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory for 3D arrays.
///
/// Perform a 3D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY3D structure is defined as:
///
/// ```text
/// typedef struct CUDA_MEMCPY3D_st {
///
/// unsigned int srcXInBytes, srcY, srcZ;
/// unsigned int srcLOD;
/// CUmemorytype srcMemoryType;
/// const void *srcHost;
/// CUdeviceptr srcDevice;
/// CUarray srcArray;
/// unsigned int srcPitch; // ignored when src is array
/// unsigned int srcHeight; // ignored when src is array; may be 0 if Depth==1
///
/// unsigned int dstXInBytes, dstY, dstZ;
/// unsigned int dstLOD;
/// CUmemorytype dstMemoryType;
/// void *dstHost;
/// CUdeviceptr dstDevice;
/// CUarray dstArray;
/// unsigned int dstPitch; // ignored when dst is array
/// unsigned int dstHeight; // ignored when dst is array; may be 0 if Depth==1
///
/// unsigned int WidthInBytes;
/// unsigned int Height;
/// unsigned int Depth;
/// } CUDA_MEMCPY3D;
/// ```
///
/// * srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively; CUmemorytype_enum
/// is defined as:
///
/// ```text
/// typedef enum CUmemorytype_enum {
/// CU_MEMORYTYPE_HOST = 0x01,
/// CU_MEMORYTYPE_DEVICE = 0x02,
/// CU_MEMORYTYPE_ARRAY = 0x03,
/// CU_MEMORYTYPE_UNIFIED = 0x04
/// } CUmemorytype;
/// ```
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], srcDevice and srcPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. srcArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], srcHost, srcPitch and srcHeight specify the (host) base address of the source data, the bytes per row, and the height of
/// each 2D slice of the 3D array. srcArray is ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], srcDevice, srcPitch and srcHeight specify the (device) base address of the source data, the bytes per row, and the height
/// of each 2D slice of the 3D array. srcArray is ignored.
///
/// If srcMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], srcArray specifies the handle of the source data. srcHost, srcDevice, srcPitch and srcHeight are ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`], dstDevice and dstPitch specify the (unified virtual address space) base address of the source data and the bytes per row
/// to apply. dstArray is ignored. This value may be used only if unified addressing is supported in the calling context.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`], dstHost and dstPitch specify the (host) base address of the destination data, the bytes per row, and the height of each
/// 2D slice of the 3D array. dstArray is ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`], dstDevice and dstPitch specify the (device) base address of the destination data, the bytes per row, and the height of each
/// 2D slice of the 3D array. dstArray is ignored.
///
/// If dstMemoryType is [`CUmemorytype_enum::CU_MEMORYTYPE_ARRAY`], dstArray specifies the handle of the destination data. dstHost, dstDevice, dstPitch and dstHeight are ignored.
///
/// * srcXInBytes, srcY and srcZ specify the base address of the source data for the copy.
///
/// For host pointers, the starting address is
///
/// ```text
/// void* Start = (void*)((char*)srcHost+(srcZ*srcHeight+srcY)*srcPitch + srcXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr Start = srcDevice+(srcZ*srcHeight+srcY)*srcPitch+srcXInBytes;
/// ```
///
/// For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
///
/// * dstXInBytes, dstY and dstZ specify the base address of the destination data for the copy.
///
/// For host pointers, the base address is
///
/// ```text
/// void* dstStart = (void*)((char*)dstHost+(dstZ*dstHeight+dstY)*dstPitch + dstXInBytes);
/// ```
///
/// For device pointers, the starting address is
///
/// ```text
/// CUdeviceptr dstStart = dstDevice+(dstZ*dstHeight+dstY)*dstPitch+dstXInBytes;
/// ```
///
/// For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
///
/// * WidthInBytes, Height and Depth specify the width (in bytes), height and depth of the 3D copy being performed.
/// * If specified, srcPitch must be greater than or equal to WidthInBytes + srcXInBytes, and dstPitch must be greater than or equal
/// to WidthInBytes + dstXInBytes.
/// * If specified, srcHeight must be greater than or equal to Height + srcY, and dstHeight must be greater than or equal to Height
/// + dstY.
///
/// [`cuMemcpy3DAsync_v2`] returns an error if any pitch is greater than the maximum allowed ([`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_PITCH`]).
///
/// The srcLOD and dstLOD members of the CUDA_MEMCPY3D structure must be set to 0.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemcpy3DAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g785bd0963e476a740533382a67674641).
///
/// # Parameters
///
/// - `pCopy`: Parameters for the memory copy.
/// - `hStream`: Stream identifier.
pub fn cuMemcpy3DAsync_v2(
pCopy: *const CUDA_MEMCPY3D,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Copies memory between contexts asynchronously.
///
/// Perform a 3D memory copy according to the parameters specified in pCopy. See the definition of the CUDA_MEMCPY3D_PEER structure for documentation of its parameters.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuMemcpyDtoD_v2`], [`cuMemcpyPeer`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyPeerAsync`], [`cuMemcpy3DPeerAsync`], [cudaMemcpy3DPeerAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g7386b2845149b48c87f82ea017690aa8).
///
/// # Parameters
///
/// - `pCopy`: Parameters for the memory copy.
/// - `hStream`: Stream identifier.
pub fn cuMemcpy3DPeerAsync(
pCopy: *const CUDA_MEMCPY3D_PEER,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Performs a batch of memory copies asynchronously.
///
/// Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a batch are not guaranteed
/// to execute in any specific order. This API only supports pointer-to-pointer copies. For copies involving CUDA arrays, please
/// see [`cuMemcpy3DBatchAsync_v2`].
///
/// Performs memory copies from source buffers specified in srcs to destination buffers specified in dsts. The size of each copy is specified in sizes. All three arrays must be of the same length as specified by count. Since there are no ordering guarantees for copies within a batch, specifying any dependent copies within a batch will result
/// in undefined behavior.
///
/// Every copy in the batch has to be associated with a set of attributes specified in the attrs array. Each entry in this array can apply to more than one copy. This can be done by specifying in the attrsIdxs array, the index of the first copy that the corresponding entry in the attrs array applies to. Both attrs and attrsIdxs must be of the same length as specified by numAttrs. For example, if a batch has 10 copies listed in dst/src/sizes, the first 6 of which have one set of attributes and the remaining
/// 4 another, then numAttrs will be 2, attrsIdxs will be {0, 6} and attrs will contains the two sets of attributes. Note that the first entry in attrsIdxs must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than count. Furthermore, numAttrs must be lesser than or equal to count.
///
/// The [CUmemcpyAttributes::srcAccessOrder](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemcpyAttributes__v1.html#structCUmemcpyAttributes__v1_1d152922b22834808ca5714f688400761) indicates the source access ordering to be observed for copies associated with the attribute. If the source access order
/// is set to [`CUmemcpySrcAccessOrder_enum::CU_MEMCPY_SRC_ACCESS_ORDER_STREAM`], then the source will be accessed in stream order. If the source access order is set to [`CUmemcpySrcAccessOrder_enum::CU_MEMCPY_SRC_ACCESS_ORDER_DURING_API_CALL`] then it indicates that access to the source pointer can be out of stream order and all accesses must be complete before the
/// API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations
/// in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source
/// variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to
/// synchronize the stream after the API call. If the source access order is set to [`CUmemcpySrcAccessOrder_enum::CU_MEMCPY_SRC_ACCESS_ORDER_ANY`] then it indicates that access to the source pointer can be out of stream order and the accesses can happen even after the
/// API call returns. This flag is suited for host pointers allocated outside CUDA (ex., via malloc) when it's known that no prior
/// operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain
/// platforms. Each memcpy operation in the batch must have a valid CUmemcpyAttributes corresponding to it including the appropriate
/// srcAccessOrder setting, otherwise the API will return [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// The [CUmemcpyAttributes::srcLocHint](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemcpyAttributes__v1.html#structCUmemcpyAttributes__v1_12b2ea7d3968f58243d6d94f99bab6a55) and [CUmemcpyAttributes::dstLocHint](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemcpyAttributes__v1.html#structCUmemcpyAttributes__v1_15ef6cafc9e673f19d946cd5517dd05ec) allows applications to specify hint locations for operands of a copy when the operand doesn't have a fixed location. That
/// is, these hints are only applicable for managed memory pointers on devices where [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] is true or system-allocated pageable memory on devices where [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`] is true. For other cases, these hints are ignored.
///
/// The [CUmemcpyAttributes::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemcpyAttributes__v1.html#structCUmemcpyAttributes__v1_10c9ad8770c38c992894a6870991127e4) field can be used to specify certain flags for copies. Setting the [`CUmemcpyFlags_enum::CU_MEMCPY_FLAG_PREFER_OVERLAP_WITH_COMPUTE`] flag indicates that the associated copies should preferably overlap with any compute work. Note that this flag is a hint
/// and can be ignored depending on the platform and other parameters of the copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// # Parameters
///
/// - `dsts`: Array of destination pointers.
/// - `srcs`: Array of memcpy source pointers.
/// - `sizes`: Array of sizes for memcpy operations.
/// - `count`: Size of dsts, srcs and sizes arrays.
/// - `attrs`: Array of memcpy attributes.
/// - `attrsIdxs`: Array of indices to specify which copies each entry in the attrs array applies to. The attributes specified in attrs\[k\] will be applied to copies starting from attrsIdxs\[k\] through attrsIdxs\[k+1\]
/// - 1. Also attrs\[numAttrs-1\] will apply to copies starting from attrsIdxs\[numAttrs-1\] through count - 1.
/// - `numAttrs`: Size of attrs and attrsIdxs arrays.
/// - `hStream`: The stream to enqueue the operations in. Must not be legacy NULL stream.
pub fn cuMemcpyBatchAsync_v2(
dsts: *mut CUdeviceptr,
srcs: *mut CUdeviceptr,
sizes: *mut size_t,
count: size_t,
attrs: *mut CUmemcpyAttributes,
attrsIdxs: *mut size_t,
numAttrs: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Performs a batch of 3D memory copies asynchronously.
///
/// Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a batch are not guaranteed
/// to execute in any specific order. Note that this means specifying any dependent copies within a batch will result in undefined
/// behavior.
///
/// Performs memory copies as specified in the opList array. The length of this array is specified in numOps. Each entry in this array describes a copy operation. This includes among other things, the source and destination operands
/// for the copy as specified in CUDA_MEMCPY3D_BATCH_OP::src and CUDA_MEMCPY3D_BATCH_OP::dst respectively. The source and destination
/// operands of a copy can either be a pointer or a CUDA array. The width, height and depth of a copy is specified in CUDA_MEMCPY3D_BATCH_OP::extent.
/// The width, height and depth of a copy are specified in elements and must not be zero. For pointer-to-pointer copies, the element
/// size is considered to be 1. For pointer to CUDA array or vice versa copies, the element size is determined by the CUDA array.
/// For CUDA array to CUDA array copies, the element size of the two CUDA arrays must match.
///
/// For a given operand, if CUmemcpy3DOperand::type is specified as [`CUmemcpy3DOperandType_enum::CU_MEMCPY_OPERAND_TYPE_POINTER`], then CUmemcpy3DOperand::op::ptr will be used. The CUmemcpy3DOperand::op::ptr::ptr field must contain the pointer where the
/// copy should begin. The CUmemcpy3DOperand::op::ptr::rowLength field specifies the length of each row in elements and must either
/// be zero or be greater than or equal to the width of the copy specified in CUDA_MEMCPY3D_BATCH_OP::extent::width. The CUmemcpy3DOperand::op::ptr::layerHeight
/// field specifies the height of each layer and must either be zero or be greater than or equal to the height of the copy specified
/// in CUDA_MEMCPY3D_BATCH_OP::extent::height. When either of these values is zero, that aspect of the operand is considered to
/// be tightly packed according to the copy extent. For managed memory pointers on devices where [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] is true or system-allocated pageable memory on devices where [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`] is true, the CUmemcpy3DOperand::op::ptr::locHint field can be used to hint the location of the operand.
///
/// If an operand's type is specified as [`CUmemcpy3DOperandType_enum::CU_MEMCPY_OPERAND_TYPE_ARRAY`], then CUmemcpy3DOperand::op::array will be used. The CUmemcpy3DOperand::op::array::array field specifies the CUDA array and
/// CUmemcpy3DOperand::op::array::offset specifies the 3D offset into that array where the copy begins.
///
/// The [CUmemcpyAttributes::srcAccessOrder](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemcpyAttributes__v1.html#structCUmemcpyAttributes__v1_1d152922b22834808ca5714f688400761) indicates the source access ordering to be observed for copies associated with the attribute. If the source access order
/// is set to [`CUmemcpySrcAccessOrder_enum::CU_MEMCPY_SRC_ACCESS_ORDER_STREAM`], then the source will be accessed in stream order. If the source access order is set to [`CUmemcpySrcAccessOrder_enum::CU_MEMCPY_SRC_ACCESS_ORDER_DURING_API_CALL`] then it indicates that access to the source pointer can be out of stream order and all accesses must be complete before the
/// API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations
/// in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source
/// variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to
/// synchronize the stream after the API call. If the source access order is set to [`CUmemcpySrcAccessOrder_enum::CU_MEMCPY_SRC_ACCESS_ORDER_ANY`] then it indicates that access to the source pointer can be out of stream order and the accesses can happen even after the
/// API call returns. This flag is suited for host pointers allocated outside CUDA (ex., via malloc) when it's known that no prior
/// operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain
/// platforms. Each memcopy operation in opList must have a valid srcAccessOrder setting, otherwise this API will return [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// The [CUmemcpyAttributes::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemcpyAttributes__v1.html#structCUmemcpyAttributes__v1_10c9ad8770c38c992894a6870991127e4) field can be used to specify certain flags for copies. Setting the [`CUmemcpyFlags_enum::CU_MEMCPY_FLAG_PREFER_OVERLAP_WITH_COMPUTE`] flag indicates that the associated copies should preferably overlap with any compute work. Note that this flag is a hint
/// and can be ignored depending on the platform and other parameters of the copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// # Parameters
///
/// - `numOps`: Total number of memcpy operations.
/// - `opList`: Array of size numOps containing the actual memcpy operations.
/// - `flags`: Flags for future use, must be zero now.
/// - `hStream`: The stream to enqueue the operations in. Must not be default NULL stream.
pub fn cuMemcpy3DBatchAsync_v2(
numOps: size_t,
opList: *mut CUDA_MEMCPY3D_BATCH_OP,
flags: ::core::ffi::c_ulonglong,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Performs asynchronous memory copy operation with the specified attributes.
///
/// Performs asynchronous memory copy operation where dst and src are the destination and source pointers respectively. size specifies the number of bytes to copy. attr specifies the attributes for the copy and hStream specifies the stream to enqueue the operation in.
///
/// For more information regarding the attributes, please refer to CUmemcpyAttributes and it's usage desciption [`cuMemcpyBatchAsync_v2`]
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuMemcpyBatchAsync_v2`].
///
/// # Parameters
///
/// - `dst`: Destination device pointer.
/// - `src`: Source device pointer.
/// - `size`: Number of bytes to copy.
/// - `attr`: Attributes for the copy.
/// - `hStream`: Stream to enqueue the operation in.
pub fn cuMemcpyWithAttributesAsync(
dst: CUdeviceptr,
src: CUdeviceptr,
size: size_t,
attr: *mut CUmemcpyAttributes,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Performs 3D memory copy with attributes asynchronously
///
/// Performs the copy operation specified in op. flags specifies the flags for the copy and hStream specifies the stream to enqueue the operation in.
///
/// For more information regarding the operation, please refer to CUDA_MEMCPY3D_BATCH_OP and it's usage desciption [`cuMemcpy3DBatchAsync_v2`]
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return [`CUresult::CUDA_ERROR_INVALID_VALUE`].
///
/// **See also:**
///
/// [`cuMemcpy3DBatchAsync_v2`].
///
/// # Parameters
///
/// - `op`: Operation to perform.
/// - `flags`: Flags for the copy, must be zero now.
/// - `hStream`: Stream to enqueue the operation in.
pub fn cuMemcpy3DWithAttributesAsync(
op: *mut CUDA_MEMCPY3D_BATCH_OP,
flags: ::core::ffi::c_ulonglong,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Initializes device memory.
///
/// Sets the memory range of N 8-bit values to the specified value uc.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemset](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gf7338650f7683c51ee26aadc6973c63a).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `uc`: Value to set.
/// - `N`: Number of elements.
pub fn cuMemsetD8_v2(
dstDevice: CUdeviceptr,
uc: ::core::ffi::c_uchar,
N: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Initializes device memory.
///
/// Sets the memory range of N 16-bit values to the specified value us. The dstDevice pointer must be two byte aligned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemset](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gf7338650f7683c51ee26aadc6973c63a).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `us`: Value to set.
/// - `N`: Number of elements.
pub fn cuMemsetD16_v2(
dstDevice: CUdeviceptr,
us: ::core::ffi::c_ushort,
N: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Initializes device memory.
///
/// Sets the memory range of N 32-bit values to the specified value ui. The dstDevice pointer must be four byte aligned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32Async`], [cudaMemset](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gf7338650f7683c51ee26aadc6973c63a).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `ui`: Value to set.
/// - `N`: Number of elements.
pub fn cuMemsetD32_v2(
dstDevice: CUdeviceptr,
ui: ::core::ffi::c_uint,
N: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Initializes device memory.
///
/// Sets the 2D memory range of Width 8-bit values to the specified value uc. Height specifies the number of rows to set, and dstPitch specifies the number of bytes between each row. This function performs fastest when the pitch is one that has been passed
/// back by [`cuMemAllocPitch_v2`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemset2D](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g120112b2bd627c7a896390efadc4d2c1).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `dstPitch`: Pitch of destination device pointer(Unused if Height is 1).
/// - `uc`: Value to set.
/// - `Width`: Width of row.
/// - `Height`: Number of rows.
pub fn cuMemsetD2D8_v2(
dstDevice: CUdeviceptr,
dstPitch: size_t,
uc: ::core::ffi::c_uchar,
Width: size_t,
Height: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Initializes device memory.
///
/// Sets the 2D memory range of Width 16-bit values to the specified value us. Height specifies the number of rows to set, and dstPitch specifies the number of bytes between each row. The dstDevice pointer and dstPitch offset must be two byte aligned. This function performs fastest when the pitch is one that has been passed back by [`cuMemAllocPitch_v2`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemset2D](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g120112b2bd627c7a896390efadc4d2c1).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `dstPitch`: Pitch of destination device pointer(Unused if Height is 1).
/// - `us`: Value to set.
/// - `Width`: Width of row.
/// - `Height`: Number of rows.
pub fn cuMemsetD2D16_v2(
dstDevice: CUdeviceptr,
dstPitch: size_t,
us: ::core::ffi::c_ushort,
Width: size_t,
Height: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Initializes device memory.
///
/// Sets the 2D memory range of Width 32-bit values to the specified value ui. Height specifies the number of rows to set, and dstPitch specifies the number of bytes between each row. The dstDevice pointer and dstPitch offset must be four byte aligned. This function performs fastest when the pitch is one that has been passed back by [`cuMemAllocPitch_v2`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemset2D](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g120112b2bd627c7a896390efadc4d2c1).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `dstPitch`: Pitch of destination device pointer(Unused if Height is 1).
/// - `ui`: Value to set.
/// - `Width`: Width of row.
/// - `Height`: Number of rows.
pub fn cuMemsetD2D32_v2(
dstDevice: CUdeviceptr,
dstPitch: size_t,
ui: ::core::ffi::c_uint,
Width: size_t,
Height: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Sets device memory.
///
/// Sets the memory range of N 8-bit values to the specified value uc.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemsetAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g7c9761e21d9f0999fd136c51e7b9b2a0).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `uc`: Value to set.
/// - `N`: Number of elements.
/// - `hStream`: Stream identifier.
pub fn cuMemsetD8Async(
dstDevice: CUdeviceptr,
uc: ::core::ffi::c_uchar,
N: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Sets device memory.
///
/// Sets the memory range of N 16-bit values to the specified value us. The dstDevice pointer must be two byte aligned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemsetAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g7c9761e21d9f0999fd136c51e7b9b2a0).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `us`: Value to set.
/// - `N`: Number of elements.
/// - `hStream`: Stream identifier.
pub fn cuMemsetD16Async(
dstDevice: CUdeviceptr,
us: ::core::ffi::c_ushort,
N: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Sets device memory.
///
/// Sets the memory range of N 32-bit values to the specified value ui. The dstDevice pointer must be four byte aligned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [cudaMemsetAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g7c9761e21d9f0999fd136c51e7b9b2a0).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `ui`: Value to set.
/// - `N`: Number of elements.
/// - `hStream`: Stream identifier.
pub fn cuMemsetD32Async(
dstDevice: CUdeviceptr,
ui: ::core::ffi::c_uint,
N: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Sets device memory.
///
/// Sets the 2D memory range of Width 8-bit values to the specified value uc. Height specifies the number of rows to set, and dstPitch specifies the number of bytes between each row. This function performs fastest when the pitch is one that has been passed
/// back by [`cuMemAllocPitch_v2`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemset2DAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g8fdcc53996ff49c570f4b5ead0256ef0).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `dstPitch`: Pitch of destination device pointer(Unused if Height is 1).
/// - `uc`: Value to set.
/// - `Width`: Width of row.
/// - `Height`: Number of rows.
/// - `hStream`: Stream identifier.
pub fn cuMemsetD2D8Async(
dstDevice: CUdeviceptr,
dstPitch: size_t,
uc: ::core::ffi::c_uchar,
Width: size_t,
Height: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Sets device memory.
///
/// Sets the 2D memory range of Width 16-bit values to the specified value us. Height specifies the number of rows to set, and dstPitch specifies the number of bytes between each row. The dstDevice pointer and dstPitch offset must be two byte aligned. This function performs fastest when the pitch is one that has been passed back by [`cuMemAllocPitch_v2`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD2D32Async`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemset2DAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g8fdcc53996ff49c570f4b5ead0256ef0).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `dstPitch`: Pitch of destination device pointer(Unused if Height is 1).
/// - `us`: Value to set.
/// - `Width`: Width of row.
/// - `Height`: Number of rows.
/// - `hStream`: Stream identifier.
pub fn cuMemsetD2D16Async(
dstDevice: CUdeviceptr,
dstPitch: size_t,
us: ::core::ffi::c_ushort,
Width: size_t,
Height: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Sets device memory.
///
/// Sets the 2D memory range of Width 32-bit values to the specified value ui. Height specifies the number of rows to set, and dstPitch specifies the number of bytes between each row. The dstDevice pointer and dstPitch offset must be four byte aligned. This function performs fastest when the pitch is one that has been passed back by [`cuMemAllocPitch_v2`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memset).
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D8Async`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D16Async`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD8Async`], [`cuMemsetD16_v2`], [`cuMemsetD16Async`], [`cuMemsetD32_v2`], [`cuMemsetD32Async`], [cudaMemset2DAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g8fdcc53996ff49c570f4b5ead0256ef0).
///
/// # Parameters
///
/// - `dstDevice`: Destination device pointer.
/// - `dstPitch`: Pitch of destination device pointer(Unused if Height is 1).
/// - `ui`: Value to set.
/// - `Width`: Width of row.
/// - `Height`: Number of rows.
/// - `hStream`: Stream identifier.
pub fn cuMemsetD2D32Async(
dstDevice: CUdeviceptr,
dstPitch: size_t,
ui: ::core::ffi::c_uint,
Width: size_t,
Height: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a 1D or 2D CUDA array.
///
/// Creates a CUDA array according to the CUDA_ARRAY_DESCRIPTOR structure pAllocateArray and returns a handle to the new CUDA array in \*pHandle. The CUDA_ARRAY_DESCRIPTOR is defined as:
///
/// ```text
/// typedef struct {
/// unsigned int Width;
/// unsigned int Height;
/// CUarray_format Format;
/// unsigned int NumChannels;
/// } CUDA_ARRAY_DESCRIPTOR;
/// ```
///
/// * Width, and Height are the width, and height of the CUDA array (in elements); the CUDA array is one-dimensional if height is 0, two-dimensional
/// otherwise;
/// * Format specifies the format of the elements; `CUarray_format` is defined as:
///
/// ```text
/// typedef enum CUarray_format_enum {
/// CU_AD_FORMAT_UNSIGNED_INT8 = 0x01,
/// CU_AD_FORMAT_UNSIGNED_INT16 = 0x02,
/// CU_AD_FORMAT_UNSIGNED_INT32 = 0x03,
/// CU_AD_FORMAT_SIGNED_INT8 = 0x08,
/// CU_AD_FORMAT_SIGNED_INT16 = 0x09,
/// CU_AD_FORMAT_SIGNED_INT32 = 0x0a,
/// CU_AD_FORMAT_HALF = 0x10,
/// CU_AD_FORMAT_FLOAT = 0x20,
/// CU_AD_FORMAT_NV12 = 0xb0,
/// CU_AD_FORMAT_UNORM_INT8X1 = 0xc0,
/// CU_AD_FORMAT_UNORM_INT8X2 = 0xc1,
/// CU_AD_FORMAT_UNORM_INT8X4 = 0xc2,
/// CU_AD_FORMAT_UNORM_INT16X1 = 0xc3,
/// CU_AD_FORMAT_UNORM_INT16X2 = 0xc4,
/// CU_AD_FORMAT_UNORM_INT16X4 = 0xc5,
/// CU_AD_FORMAT_SNORM_INT8X1 = 0xc6,
/// CU_AD_FORMAT_SNORM_INT8X2 = 0xc7,
/// CU_AD_FORMAT_SNORM_INT8X4 = 0xc8,
/// CU_AD_FORMAT_SNORM_INT16X1 = 0xc9,
/// CU_AD_FORMAT_SNORM_INT16X2 = 0xca,
/// CU_AD_FORMAT_SNORM_INT16X4 = 0xcb,
/// CU_AD_FORMAT_BC1_UNORM = 0x91,
/// CU_AD_FORMAT_BC1_UNORM_SRGB = 0x92,
/// CU_AD_FORMAT_BC2_UNORM = 0x93,
/// CU_AD_FORMAT_BC2_UNORM_SRGB = 0x94,
/// CU_AD_FORMAT_BC3_UNORM = 0x95,
/// CU_AD_FORMAT_BC3_UNORM_SRGB = 0x96,
/// CU_AD_FORMAT_BC4_UNORM = 0x97,
/// CU_AD_FORMAT_BC4_SNORM = 0x98,
/// CU_AD_FORMAT_BC5_UNORM = 0x99,
/// CU_AD_FORMAT_BC5_SNORM = 0x9a,
/// CU_AD_FORMAT_BC6H_UF16 = 0x9b,
/// CU_AD_FORMAT_BC6H_SF16 = 0x9c,
/// CU_AD_FORMAT_BC7_UNORM = 0x9d,
/// CU_AD_FORMAT_BC7_UNORM_SRGB = 0x9e,
/// CU_AD_FORMAT_P010 = 0x9f,
/// CU_AD_FORMAT_P016 = 0xa1,
/// CU_AD_FORMAT_NV16 = 0xa2,
/// CU_AD_FORMAT_P210 = 0xa3,
/// CU_AD_FORMAT_P216 = 0xa4,
/// CU_AD_FORMAT_YUY2 = 0xa5,
/// CU_AD_FORMAT_Y210 = 0xa6,
/// CU_AD_FORMAT_Y216 = 0xa7,
/// CU_AD_FORMAT_AYUV = 0xa8,
/// CU_AD_FORMAT_Y410 = 0xa9,
/// CU_AD_FORMAT_Y416 = 0xb1,
/// CU_AD_FORMAT_Y444_PLANAR8 = 0xb2,
/// CU_AD_FORMAT_Y444_PLANAR10 = 0xb3,
/// CU_AD_FORMAT_YUV444_8bit_SemiPlanar = 0xb4,
/// CU_AD_FORMAT_YUV444_16bit_SemiPlanar = 0xb5,
/// CU_AD_FORMAT_UNORM_INT_101010_2 = 0x50,
/// CU_AD_FORMAT_UINT8_PACKED_422 = 0x51,
/// CU_AD_FORMAT_UINT8_PACKED_444 = 0x52,
/// CU_AD_FORMAT_UINT8_SEMIPLANAR_420 = 0x53,
/// CU_AD_FORMAT_UINT16_SEMIPLANAR_420 = 0x54,
/// CU_AD_FORMAT_UINT8_SEMIPLANAR_422 = 0x55,
/// CU_AD_FORMAT_UINT16_SEMIPLANAR_422 = 0x56,
/// CU_AD_FORMAT_UINT8_SEMIPLANAR_444 = 0x57,
/// CU_AD_FORMAT_UINT16_SEMIPLANAR_444 = 0x58,
/// CU_AD_FORMAT_UINT8_PLANAR_420 = 0x59,
/// CU_AD_FORMAT_UINT16_PLANAR_420 = 0x5a,
/// CU_AD_FORMAT_UINT8_PLANAR_422 = 0x5b,
/// CU_AD_FORMAT_UINT16_PLANAR_422 = 0x5c,
/// CU_AD_FORMAT_UINT8_PLANAR_444 = 0x5d,
/// CU_AD_FORMAT_UINT16_PLANAR_444 = 0x5e,
/// } CUarray_format;
/// ```
/// * NumChannels specifies the number of packed components per CUDA array element; it may be 1, 2, or 4;
///
/// Here are examples of CUDA array descriptions:
///
/// Description for a CUDA array of 2048 floats:
///
/// ```text
/// CUDA_ARRAY_DESCRIPTOR desc;
/// desc.Format = CU_AD_FORMAT_FLOAT;
/// desc.NumChannels = 1;
/// desc.Width = 2048;
/// desc.Height = 1;
/// ```
///
/// Description for a 64 x 64 CUDA array of floats:
///
/// ```text
/// CUDA_ARRAY_DESCRIPTOR desc;
/// desc.Format = CU_AD_FORMAT_FLOAT;
/// desc.NumChannels = 1;
/// desc.Width = 64;
/// desc.Height = 64;
/// ```
///
/// Description for a width x height CUDA array of 64-bit, 4x16-bit float16's:
///
/// ```text
/// CUDA_ARRAY_DESCRIPTOR desc;
/// desc.Format = CU_AD_FORMAT_HALF;
/// desc.NumChannels = 4;
/// desc.Width = width;
/// desc.Height = height;
/// ```
///
/// Description for a width x height CUDA array of 16-bit elements, each of which is two 8-bit unsigned chars:
///
/// ```text
/// CUDA_ARRAY_DESCRIPTOR arrayDesc;
/// desc.Format = CU_AD_FORMAT_UNSIGNED_INT8;
/// desc.NumChannels = 2;
/// desc.Width = width;
/// desc.Height = height;
/// ```
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMallocArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g6728eb7dc25f332f50bdb16a19620d3d).
///
/// # Parameters
///
/// - `pHandle`: Returned array.
/// - `pAllocateArray`: Array descriptor.
pub fn cuArrayCreate_v2(
pHandle: *mut CUarray,
pAllocateArray: *const CUDA_ARRAY_DESCRIPTOR,
) -> CUresult;
}
unsafe extern "C" {
/// Get a 1D or 2D CUDA array descriptor.
///
/// Returns in \*pArrayDescriptor a descriptor containing information on the format and dimensions of the CUDA array hArray. It is useful for subroutines that have been passed a CUDA array, but need to know the CUDA array parameters for validation
/// or other purposes.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaArrayGetInfo](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g373dacf191566b0bf5e5b807517b6bf9).
///
/// # Parameters
///
/// - `pArrayDescriptor`: Returned array descriptor.
/// - `hArray`: Array to get descriptor of.
pub fn cuArrayGetDescriptor_v2(
pArrayDescriptor: *mut CUDA_ARRAY_DESCRIPTOR,
hArray: CUarray,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the layout properties of a sparse CUDA array.
///
/// Returns the layout properties of a sparse CUDA array in sparseProperties If the CUDA array is not allocated with flag [`CUDA_ARRAY3D_SPARSE`] will be returned.
///
/// If the returned value in [CUDA_ARRAY_SPARSE_PROPERTIES::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_10e842bb64091fa47809112c700cb5f0a) contains [`CU_ARRAY_SPARSE_PROPERTIES_SINGLE_MIPTAIL`], then [CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_1895ecb42681678271b0edba05bf1dcd9) represents the total size of the array. Otherwise, it will be zero. Also, the returned value in [CUDA_ARRAY_SPARSE_PROPERTIES::miptailFirstLevel](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_1edd0cca8fad1fcbb1789d537edd7e6b6) is always zero. Note that the array must have been allocated using [`cuArrayCreate_v2`] or [`cuArray3DCreate_v2`]. For CUDA arrays obtained using [`cuMipmappedArrayGetLevel`], [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] will be returned. Instead, [`cuMipmappedArrayGetSparseProperties`] must be used to obtain the sparse properties of the entire CUDA mipmapped array to which array belongs to.
///
/// **See also:**
///
/// [`cuMipmappedArrayGetSparseProperties`], [`cuMemMapArrayAsync`].
///
/// # Parameters
///
/// - `sparseProperties`: Pointer to CUDA_ARRAY_SPARSE_PROPERTIES.
/// - `array`: CUDA array to get the sparse properties of.
pub fn cuArrayGetSparseProperties(
sparseProperties: *mut CUDA_ARRAY_SPARSE_PROPERTIES,
array: CUarray,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the layout properties of a sparse CUDA mipmapped array.
///
/// Returns the sparse array layout properties in sparseProperties If the CUDA mipmapped array is not allocated with flag [`CUDA_ARRAY3D_SPARSE`] will be returned.
///
/// For non-layered CUDA mipmapped arrays, [CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_1895ecb42681678271b0edba05bf1dcd9) returns the size of the mip tail region. The mip tail region includes all mip levels whose width, height or depth is less
/// than that of the tile. For layered CUDA mipmapped arrays, if [CUDA_ARRAY_SPARSE_PROPERTIES::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_10e842bb64091fa47809112c700cb5f0a) contains [`CU_ARRAY_SPARSE_PROPERTIES_SINGLE_MIPTAIL`], then [CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_1895ecb42681678271b0edba05bf1dcd9) specifies the size of the mip tail of all layers combined. Otherwise, [CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_1895ecb42681678271b0edba05bf1dcd9) specifies mip tail size per layer. The returned value of [CUDA_ARRAY_SPARSE_PROPERTIES::miptailFirstLevel](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_1edd0cca8fad1fcbb1789d537edd7e6b6) is valid only if [CUDA_ARRAY_SPARSE_PROPERTIES::miptailSize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_1895ecb42681678271b0edba05bf1dcd9) is non-zero.
///
/// **See also:**
///
/// [`cuArrayGetSparseProperties`], [`cuMemMapArrayAsync`].
///
/// # Parameters
///
/// - `sparseProperties`: Pointer to CUDA_ARRAY_SPARSE_PROPERTIES.
/// - `mipmap`: CUDA mipmapped array to get the sparse properties of.
pub fn cuMipmappedArrayGetSparseProperties(
sparseProperties: *mut CUDA_ARRAY_SPARSE_PROPERTIES,
mipmap: CUmipmappedArray,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the memory requirements of a CUDA array.
///
/// Returns the memory requirements of a CUDA array in memoryRequirements If the CUDA array is not allocated with flag [`CUDA_ARRAY3D_DEFERRED_MAPPING`] will be returned.
///
/// The returned value in [CUDA_ARRAY_MEMORY_REQUIREMENTS::size](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__MEMORY__REQUIREMENTS__v1.html#structCUDA__ARRAY__MEMORY__REQUIREMENTS__v1_17a2851735a1d2c11af797f01b1d4969e) represents the total size of the CUDA array. The returned value in [CUDA_ARRAY_MEMORY_REQUIREMENTS::alignment](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__MEMORY__REQUIREMENTS__v1.html#structCUDA__ARRAY__MEMORY__REQUIREMENTS__v1_135c6c8106451b6313d1dffe9a28af755) represents the alignment necessary for mapping the CUDA array.
///
/// **See also:**
///
/// [`cuMipmappedArrayGetMemoryRequirements`], [`cuMemMapArrayAsync`].
///
/// # Parameters
///
/// - `memoryRequirements`: Pointer to CUDA_ARRAY_MEMORY_REQUIREMENTS.
/// - `array`: CUDA array to get the memory requirements of.
/// - `device`: Device to get the memory requirements for.
pub fn cuArrayGetMemoryRequirements(
memoryRequirements: *mut CUDA_ARRAY_MEMORY_REQUIREMENTS,
array: CUarray,
device: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the memory requirements of a CUDA mipmapped array.
///
/// Returns the memory requirements of a CUDA mipmapped array in memoryRequirements If the CUDA mipmapped array is not allocated with flag [`CUDA_ARRAY3D_DEFERRED_MAPPING`] will be returned.
///
/// The returned value in [CUDA_ARRAY_MEMORY_REQUIREMENTS::size](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__MEMORY__REQUIREMENTS__v1.html#structCUDA__ARRAY__MEMORY__REQUIREMENTS__v1_17a2851735a1d2c11af797f01b1d4969e) represents the total size of the CUDA mipmapped array. The returned value in [CUDA_ARRAY_MEMORY_REQUIREMENTS::alignment](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__MEMORY__REQUIREMENTS__v1.html#structCUDA__ARRAY__MEMORY__REQUIREMENTS__v1_135c6c8106451b6313d1dffe9a28af755) represents the alignment necessary for mapping the CUDA mipmapped array.
///
/// **See also:**
///
/// [`cuArrayGetMemoryRequirements`], [`cuMemMapArrayAsync`].
///
/// # Parameters
///
/// - `memoryRequirements`: Pointer to CUDA_ARRAY_MEMORY_REQUIREMENTS.
/// - `mipmap`: CUDA mipmapped array to get the memory requirements of.
/// - `device`: Device to get the memory requirements for.
pub fn cuMipmappedArrayGetMemoryRequirements(
memoryRequirements: *mut CUDA_ARRAY_MEMORY_REQUIREMENTS,
mipmap: CUmipmappedArray,
device: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Gets a CUDA array plane from a CUDA array.
///
/// Returns in pPlaneArray a CUDA array that represents a single format plane of the CUDA array hArray.
///
/// If planeIdx is greater than the maximum number of planes in this array or if the array does not have a multi-planar format e.g: [`CUarray_format_enum::CU_AD_FORMAT_NV12`], then [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Note that if the hArray has format [`CUarray_format_enum::CU_AD_FORMAT_NV12`], then passing in 0 for planeIdx returns a CUDA array of the same size as hArray but with one channel and [`CUarray_format_enum::CU_AD_FORMAT_UNSIGNED_INT8`] as its format. If 1 is passed for planeIdx, then the returned CUDA array has half the height and width of hArray with two channels and [`CUarray_format_enum::CU_AD_FORMAT_UNSIGNED_INT8`] as its format.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArrayCreate_v2`], [cudaArrayGetPlane](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g9a851663a2b9f222b549c727adc0e079).
///
/// # Parameters
///
/// - `pPlaneArray`: Returned CUDA array referenced by the planeIdx.
/// - `hArray`: Multiplanar CUDA array.
/// - `planeIdx`: Plane index.
pub fn cuArrayGetPlane(
pPlaneArray: *mut CUarray,
hArray: CUarray,
planeIdx: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Destroys a CUDA array.
///
/// Destroys the CUDA array hArray.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaFreeArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g1b553f5f4806d67525230ac305d50900).
///
/// # Parameters
///
/// - `hArray`: Array to destroy.
pub fn cuArrayDestroy(hArray: CUarray) -> CUresult;
}
unsafe extern "C" {
/// Creates a 3D CUDA array.
///
/// Creates a CUDA array according to the CUDA_ARRAY3D_DESCRIPTOR structure pAllocateArray and returns a handle to the new CUDA array in \*pHandle. The CUDA_ARRAY3D_DESCRIPTOR is defined as:
///
/// ```text
/// typedef struct {
/// unsigned int Width;
/// unsigned int Height;
/// unsigned int Depth;
/// CUarray_format Format;
/// unsigned int NumChannels;
/// unsigned int Flags;
/// } CUDA_ARRAY3D_DESCRIPTOR;
/// ```
///
/// * Width, Height, and Depth are the width, height, and depth of the CUDA array (in elements); the following types of CUDA arrays can be allocated:
/// + A 1D array is allocated if Height and Depth extents are both zero.
/// + A 2D array is allocated if only Depth extent is zero.
/// + A 3D array is allocated if all three extents are non-zero.
/// + A 1D layered CUDA array is allocated if only Height is zero and the [`CUDA_ARRAY3D_LAYERED`] flag is set. Each layer is a 1D array. The number of layers is determined by the depth extent.
/// + A 2D layered CUDA array is allocated if all three extents are non-zero and the [`CUDA_ARRAY3D_LAYERED`] flag is set. Each layer is a 2D array. The number of layers is determined by the depth extent.
/// + A cubemap CUDA array is allocated if all three extents are non-zero and the [`CUDA_ARRAY3D_CUBEMAP`] flag is set. Width must be equal to Height, and Depth must be six. A cubemap is a special type of 2D layered CUDA array, where the six layers represent the six faces of a cube.
/// The order of the six layers in memory is the same as that listed in `CUarray_cubemap_face`.
/// + A cubemap layered CUDA array is allocated if all three extents are non-zero, and both, [`CUDA_ARRAY3D_CUBEMAP`] and [`CUDA_ARRAY3D_LAYERED`] flags are set. Width must be equal to Height, and Depth must be a multiple of six. A cubemap layered CUDA array is a special type of 2D layered CUDA array that consists of a collection
/// of cubemaps. The first six layers represent the first cubemap, the next six layers form the second cubemap, and so on.
///
/// * Format specifies the format of the elements; `CUarray_format` is defined as:
///
/// ```text
/// typedef enum CUarray_format_enum {
/// CU_AD_FORMAT_UNSIGNED_INT8 = 0x01,
/// CU_AD_FORMAT_UNSIGNED_INT16 = 0x02,
/// CU_AD_FORMAT_UNSIGNED_INT32 = 0x03,
/// CU_AD_FORMAT_SIGNED_INT8 = 0x08,
/// CU_AD_FORMAT_SIGNED_INT16 = 0x09,
/// CU_AD_FORMAT_SIGNED_INT32 = 0x0a,
/// CU_AD_FORMAT_HALF = 0x10,
/// CU_AD_FORMAT_FLOAT = 0x20,
/// CU_AD_FORMAT_NV12 = 0xb0,
/// CU_AD_FORMAT_UNORM_INT8X1 = 0xc0,
/// CU_AD_FORMAT_UNORM_INT8X2 = 0xc1,
/// CU_AD_FORMAT_UNORM_INT8X4 = 0xc2,
/// CU_AD_FORMAT_UNORM_INT16X1 = 0xc3,
/// CU_AD_FORMAT_UNORM_INT16X2 = 0xc4,
/// CU_AD_FORMAT_UNORM_INT16X4 = 0xc5,
/// CU_AD_FORMAT_SNORM_INT8X1 = 0xc6,
/// CU_AD_FORMAT_SNORM_INT8X2 = 0xc7,
/// CU_AD_FORMAT_SNORM_INT8X4 = 0xc8,
/// CU_AD_FORMAT_SNORM_INT16X1 = 0xc9,
/// CU_AD_FORMAT_SNORM_INT16X2 = 0xca,
/// CU_AD_FORMAT_SNORM_INT16X4 = 0xcb,
/// CU_AD_FORMAT_BC1_UNORM = 0x91,
/// CU_AD_FORMAT_BC1_UNORM_SRGB = 0x92,
/// CU_AD_FORMAT_BC2_UNORM = 0x93,
/// CU_AD_FORMAT_BC2_UNORM_SRGB = 0x94,
/// CU_AD_FORMAT_BC3_UNORM = 0x95,
/// CU_AD_FORMAT_BC3_UNORM_SRGB = 0x96,
/// CU_AD_FORMAT_BC4_UNORM = 0x97,
/// CU_AD_FORMAT_BC4_SNORM = 0x98,
/// CU_AD_FORMAT_BC5_UNORM = 0x99,
/// CU_AD_FORMAT_BC5_SNORM = 0x9a,
/// CU_AD_FORMAT_BC6H_UF16 = 0x9b,
/// CU_AD_FORMAT_BC6H_SF16 = 0x9c,
/// CU_AD_FORMAT_BC7_UNORM = 0x9d,
/// CU_AD_FORMAT_BC7_UNORM_SRGB = 0x9e,
/// CU_AD_FORMAT_P010 = 0x9f,
/// CU_AD_FORMAT_P016 = 0xa1,
/// CU_AD_FORMAT_NV16 = 0xa2,
/// CU_AD_FORMAT_P210 = 0xa3,
/// CU_AD_FORMAT_P216 = 0xa4,
/// CU_AD_FORMAT_YUY2 = 0xa5,
/// CU_AD_FORMAT_Y210 = 0xa6,
/// CU_AD_FORMAT_Y216 = 0xa7,
/// CU_AD_FORMAT_AYUV = 0xa8,
/// CU_AD_FORMAT_Y410 = 0xa9,
/// CU_AD_FORMAT_Y416 = 0xb1,
/// CU_AD_FORMAT_Y444_PLANAR8 = 0xb2,
/// CU_AD_FORMAT_Y444_PLANAR10 = 0xb3,
/// CU_AD_FORMAT_YUV444_8bit_SemiPlanar = 0xb4,
/// CU_AD_FORMAT_YUV444_16bit_SemiPlanar = 0xb5,
/// CU_AD_FORMAT_UNORM_INT_101010_2 = 0x50,
/// } CUarray_format;
/// ```
///
/// * NumChannels specifies the number of packed components per CUDA array element; it may be 1, 2, or 4;
///
/// * Flags may be set to
/// + [`CUDA_ARRAY3D_LAYERED`] to enable creation of layered CUDA arrays. If this flag is set, Depth specifies the number of layers, not the depth of a 3D array.
/// + [`CUDA_ARRAY3D_SURFACE_LDST`] to enable surface references to be bound to the CUDA array. If this flag is not set, [`cuSurfRefSetArray`] will fail when attempting to bind the CUDA array to a surface reference.
/// + [`CUDA_ARRAY3D_CUBEMAP`] to enable creation of cubemaps. If this flag is set, Width must be equal to Height, and Depth must be six. If the [`CUDA_ARRAY3D_LAYERED`] flag is also set, then Depth must be a multiple of six.
/// + [`CUDA_ARRAY3D_TEXTURE_GATHER`] to indicate that the CUDA array will be used for texture gather. Texture gather can only be performed on 2D CUDA arrays.
///
/// Width, Height and Depth must meet certain size requirements as listed in the following table. All values are specified in elements. Note that for
/// brevity's sake, the full name of the device attribute is not specified. For ex., TEXTURE1D_WIDTH refers to the device attribute
/// [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH`].
///
/// Note that 2D CUDA arrays have different size requirements if the [`CUDA_ARRAY3D_TEXTURE_GATHER`] flag is set. Width and Height must not be greater than [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH`] and [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT`] respectively, in that case.
///
/// | | | |
/// | --- | --- | --- |
/// | **CUDA array type** | **Valid extents that must always be met {(width range in elements), (height range), (depth range)}** | **Valid extents with CUDA_ARRAY3D_SURFACE_LDST set {(width range in elements), (height range), (depth range)}** |
/// | 1D | { (1,TEXTURE1D_WIDTH), 0, 0 } | { (1,SURFACE1D_WIDTH), 0, 0 } |
/// | 2D | { (1,TEXTURE2D_WIDTH), (1,TEXTURE2D_HEIGHT), 0 } | { (1,SURFACE2D_WIDTH), (1,SURFACE2D_HEIGHT), 0 } |
/// | 3D | { (1,TEXTURE3D_WIDTH), (1,TEXTURE3D_HEIGHT), (1,TEXTURE3D_DEPTH) } OR { (1,TEXTURE3D_WIDTH_ALTERNATE), (1,TEXTURE3D_HEIGHT_ALTERNATE), (1,TEXTURE3D_DEPTH_ALTERNATE) } | { (1,SURFACE3D_WIDTH), (1,SURFACE3D_HEIGHT), (1,SURFACE3D_DEPTH) } |
/// | 1D Layered | { (1,TEXTURE1D_LAYERED_WIDTH), 0, (1,TEXTURE1D_LAYERED_LAYERS) } | { (1,SURFACE1D_LAYERED_WIDTH), 0, (1,SURFACE1D_LAYERED_LAYERS) } |
/// | 2D Layered | { (1,TEXTURE2D_LAYERED_WIDTH), (1,TEXTURE2D_LAYERED_HEIGHT), (1,TEXTURE2D_LAYERED_LAYERS) } | { (1,SURFACE2D_LAYERED_WIDTH), (1,SURFACE2D_LAYERED_HEIGHT), (1,SURFACE2D_LAYERED_LAYERS) } |
/// | Cubemap | { (1,TEXTURECUBEMAP_WIDTH), (1,TEXTURECUBEMAP_WIDTH), 6 } | { (1,SURFACECUBEMAP_WIDTH), (1,SURFACECUBEMAP_WIDTH), 6 } |
/// | Cubemap Layered | { (1,TEXTURECUBEMAP_LAYERED_WIDTH), (1,TEXTURECUBEMAP_LAYERED_WIDTH), (1,TEXTURECUBEMAP_LAYERED_LAYERS) } | { (1,SURFACECUBEMAP_LAYERED_WIDTH), (1,SURFACECUBEMAP_LAYERED_WIDTH), (1,SURFACECUBEMAP_LAYERED_LAYERS) } |
///
/// Here are examples of CUDA array descriptions:
///
/// Description for a CUDA array of 2048 floats:
///
/// ```text
/// CUDA_ARRAY3D_DESCRIPTOR desc;
/// desc.Format = CU_AD_FORMAT_FLOAT;
/// desc.NumChannels = 1;
/// desc.Width = 2048;
/// desc.Height = 0;
/// desc.Depth = 0;
/// ```
///
/// Description for a 64 x 64 CUDA array of floats:
///
/// ```text
/// CUDA_ARRAY3D_DESCRIPTOR desc;
/// desc.Format = CU_AD_FORMAT_FLOAT;
/// desc.NumChannels = 1;
/// desc.Width = 64;
/// desc.Height = 64;
/// desc.Depth = 0;
/// ```
///
/// Description for a width x height x depth CUDA array of 64-bit, 4x16-bit float16's:
///
/// ```text
/// CUDA_ARRAY3D_DESCRIPTOR desc;
/// desc.Format = CU_AD_FORMAT_HALF;
/// desc.NumChannels = 4;
/// desc.Width = width;
/// desc.Height = height;
/// desc.Depth = depth;
/// ```
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DGetDescriptor_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaMalloc3DArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g948143cf2423a072ac6a31fb635efd88).
///
/// # Parameters
///
/// - `pHandle`: Returned array.
/// - `pAllocateArray`: 3D array descriptor.
pub fn cuArray3DCreate_v2(
pHandle: *mut CUarray,
pAllocateArray: *const CUDA_ARRAY3D_DESCRIPTOR,
) -> CUresult;
}
unsafe extern "C" {
/// Get a 3D CUDA array descriptor.
///
/// Returns in \*pArrayDescriptor a descriptor containing information on the format and dimensions of the CUDA array hArray. It is useful for subroutines that have been passed a CUDA array, but need to know the CUDA array parameters for validation
/// or other purposes.
///
/// This function may be called on 1D and 2D arrays, in which case the Height and/or Depth members of the descriptor struct will be set to 0.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuArray3DCreate_v2`], [`cuArrayCreate_v2`], [`cuArrayDestroy`], [`cuArrayGetDescriptor_v2`], [`cuMemAlloc_v2`], [`cuMemAllocHost_v2`], [`cuMemAllocPitch_v2`], [`cuMemcpy2D_v2`], [`cuMemcpy2DAsync_v2`], [`cuMemcpy2DUnaligned_v2`], [`cuMemcpy3D_v2`], [`cuMemcpy3DAsync_v2`], [`cuMemcpyAtoA_v2`], [`cuMemcpyAtoD_v2`], [`cuMemcpyAtoH_v2`], [`cuMemcpyAtoHAsync_v2`], [`cuMemcpyDtoA_v2`], [`cuMemcpyDtoD_v2`], [`cuMemcpyDtoDAsync_v2`], [`cuMemcpyDtoH_v2`], [`cuMemcpyDtoHAsync_v2`], [`cuMemcpyHtoA_v2`], [`cuMemcpyHtoAAsync_v2`], [`cuMemcpyHtoD_v2`], [`cuMemcpyHtoDAsync_v2`], [`cuMemFree_v2`], [`cuMemFreeHost`], [`cuMemGetAddressRange_v2`], [`cuMemGetInfo_v2`], [`cuMemHostAlloc`], [`cuMemHostGetDevicePointer_v2`], [`cuMemsetD2D8_v2`], [`cuMemsetD2D16_v2`], [`cuMemsetD2D32_v2`], [`cuMemsetD8_v2`], [`cuMemsetD16_v2`], [`cuMemsetD32_v2`], [cudaArrayGetInfo](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g373dacf191566b0bf5e5b807517b6bf9).
///
/// # Parameters
///
/// - `pArrayDescriptor`: Returned 3D array descriptor.
/// - `hArray`: 3D array to get descriptor of.
pub fn cuArray3DGetDescriptor_v2(
pArrayDescriptor: *mut CUDA_ARRAY3D_DESCRIPTOR,
hArray: CUarray,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a CUDA mipmapped array.
///
/// Creates a CUDA mipmapped array according to the CUDA_ARRAY3D_DESCRIPTOR structure pMipmappedArrayDesc and returns a handle to the new CUDA mipmapped array in \*pHandle. numMipmapLevels specifies the number of mipmap levels to be allocated. This value is clamped to the range \[1, 1 + floor(log2(max(width, height,
/// depth)))\].
///
/// The CUDA_ARRAY3D_DESCRIPTOR is defined as:
///
/// ```text
/// typedef struct {
/// unsigned int Width;
/// unsigned int Height;
/// unsigned int Depth;
/// CUarray_format Format;
/// unsigned int NumChannels;
/// unsigned int Flags;
/// } CUDA_ARRAY3D_DESCRIPTOR;
/// ```
///
/// * Width, Height, and Depth are the width, height, and depth of the CUDA array (in elements); the following types of CUDA arrays can be allocated:
/// + A 1D mipmapped array is allocated if Height and Depth extents are both zero.
/// + A 2D mipmapped array is allocated if only Depth extent is zero.
/// + A 3D mipmapped array is allocated if all three extents are non-zero.
/// + A 1D layered CUDA mipmapped array is allocated if only Height is zero and the [`CUDA_ARRAY3D_LAYERED`] flag is set. Each layer is a 1D array. The number of layers is determined by the depth extent.
/// + A 2D layered CUDA mipmapped array is allocated if all three extents are non-zero and the [`CUDA_ARRAY3D_LAYERED`] flag is set. Each layer is a 2D array. The number of layers is determined by the depth extent.
/// + A cubemap CUDA mipmapped array is allocated if all three extents are non-zero and the [`CUDA_ARRAY3D_CUBEMAP`] flag is set. Width must be equal to Height, and Depth must be six. A cubemap is a special type of 2D layered CUDA array, where the six layers represent the six faces of a cube.
/// The order of the six layers in memory is the same as that listed in `CUarray_cubemap_face`.
/// + A cubemap layered CUDA mipmapped array is allocated if all three extents are non-zero, and both, [`CUDA_ARRAY3D_CUBEMAP`] and [`CUDA_ARRAY3D_LAYERED`] flags are set. Width must be equal to Height, and Depth must be a multiple of six. A cubemap layered CUDA array is a special type of 2D layered CUDA array that consists of a collection
/// of cubemaps. The first six layers represent the first cubemap, the next six layers form the second cubemap, and so on.
///
/// * Format specifies the format of the elements; `CUarray_format` is defined as:
///
/// ```text
/// typedef enum CUarray_format_enum {
/// CU_AD_FORMAT_UNSIGNED_INT8 = 0x01,
/// CU_AD_FORMAT_UNSIGNED_INT16 = 0x02,
/// CU_AD_FORMAT_UNSIGNED_INT32 = 0x03,
/// CU_AD_FORMAT_SIGNED_INT8 = 0x08,
/// CU_AD_FORMAT_SIGNED_INT16 = 0x09,
/// CU_AD_FORMAT_SIGNED_INT32 = 0x0a,
/// CU_AD_FORMAT_HALF = 0x10,
/// CU_AD_FORMAT_FLOAT = 0x20,
/// CU_AD_FORMAT_NV12 = 0xb0,
/// CU_AD_FORMAT_UNORM_INT8X1 = 0xc0,
/// CU_AD_FORMAT_UNORM_INT8X2 = 0xc1,
/// CU_AD_FORMAT_UNORM_INT8X4 = 0xc2,
/// CU_AD_FORMAT_UNORM_INT16X1 = 0xc3,
/// CU_AD_FORMAT_UNORM_INT16X2 = 0xc4,
/// CU_AD_FORMAT_UNORM_INT16X4 = 0xc5,
/// CU_AD_FORMAT_SNORM_INT8X1 = 0xc6,
/// CU_AD_FORMAT_SNORM_INT8X2 = 0xc7,
/// CU_AD_FORMAT_SNORM_INT8X4 = 0xc8,
/// CU_AD_FORMAT_SNORM_INT16X1 = 0xc9,
/// CU_AD_FORMAT_SNORM_INT16X2 = 0xca,
/// CU_AD_FORMAT_SNORM_INT16X4 = 0xcb,
/// CU_AD_FORMAT_BC1_UNORM = 0x91,
/// CU_AD_FORMAT_BC1_UNORM_SRGB = 0x92,
/// CU_AD_FORMAT_BC2_UNORM = 0x93,
/// CU_AD_FORMAT_BC2_UNORM_SRGB = 0x94,
/// CU_AD_FORMAT_BC3_UNORM = 0x95,
/// CU_AD_FORMAT_BC3_UNORM_SRGB = 0x96,
/// CU_AD_FORMAT_BC4_UNORM = 0x97,
/// CU_AD_FORMAT_BC4_SNORM = 0x98,
/// CU_AD_FORMAT_BC5_UNORM = 0x99,
/// CU_AD_FORMAT_BC5_SNORM = 0x9a,
/// CU_AD_FORMAT_BC6H_UF16 = 0x9b,
/// CU_AD_FORMAT_BC6H_SF16 = 0x9c,
/// CU_AD_FORMAT_BC7_UNORM = 0x9d,
/// CU_AD_FORMAT_BC7_UNORM_SRGB = 0x9e,
/// CU_AD_FORMAT_P010 = 0x9f,
/// CU_AD_FORMAT_P016 = 0xa1,
/// CU_AD_FORMAT_NV16 = 0xa2,
/// CU_AD_FORMAT_P210 = 0xa3,
/// CU_AD_FORMAT_P216 = 0xa4,
/// CU_AD_FORMAT_YUY2 = 0xa5,
/// CU_AD_FORMAT_Y210 = 0xa6,
/// CU_AD_FORMAT_Y216 = 0xa7,
/// CU_AD_FORMAT_AYUV = 0xa8,
/// CU_AD_FORMAT_Y410 = 0xa9,
/// CU_AD_FORMAT_Y416 = 0xb1,
/// CU_AD_FORMAT_Y444_PLANAR8 = 0xb2,
/// CU_AD_FORMAT_Y444_PLANAR10 = 0xb3,
/// CU_AD_FORMAT_YUV444_8bit_SemiPlanar = 0xb4,
/// CU_AD_FORMAT_YUV444_16bit_SemiPlanar = 0xb5,
/// CU_AD_FORMAT_UNORM_INT_101010_2 = 0x50,
/// CU_AD_FORMAT_UINT8_PACKED_422 = 0x51,
/// CU_AD_FORMAT_UINT8_PACKED_444 = 0x52,
/// CU_AD_FORMAT_UINT8_SEMIPLANAR_420 = 0x53,
/// CU_AD_FORMAT_UINT16_SEMIPLANAR_420 = 0x54,
/// CU_AD_FORMAT_UINT8_SEMIPLANAR_422 = 0x55,
/// CU_AD_FORMAT_UINT16_SEMIPLANAR_422 = 0x56,
/// CU_AD_FORMAT_UINT8_SEMIPLANAR_444 = 0x57,
/// CU_AD_FORMAT_UINT16_SEMIPLANAR_444 = 0x58,
/// CU_AD_FORMAT_UINT8_PLANAR_420 = 0x59,
/// CU_AD_FORMAT_UINT16_PLANAR_420 = 0x5a,
/// CU_AD_FORMAT_UINT8_PLANAR_422 = 0x5b,
/// CU_AD_FORMAT_UINT16_PLANAR_422 = 0x5c,
/// CU_AD_FORMAT_UINT8_PLANAR_444 = 0x5d,
/// CU_AD_FORMAT_UINT16_PLANAR_444 = 0x5e,
/// } CUarray_format;
/// ```
///
/// * NumChannels specifies the number of packed components per CUDA array element; it may be 1, 2, or 4;
///
/// * Flags may be set to
/// + [`CUDA_ARRAY3D_LAYERED`] to enable creation of layered CUDA mipmapped arrays. If this flag is set, Depth specifies the number of layers, not the depth of a 3D array.
/// + [`CUDA_ARRAY3D_SURFACE_LDST`] to enable surface references to be bound to individual mipmap levels of the CUDA mipmapped array. If this flag is not set,
/// [`cuSurfRefSetArray`] will fail when attempting to bind a mipmap level of the CUDA mipmapped array to a surface reference.
/// + [`CUDA_ARRAY3D_CUBEMAP`] to enable creation of mipmapped cubemaps. If this flag is set, Width must be equal to Height, and Depth must be six. If the [`CUDA_ARRAY3D_LAYERED`] flag is also set, then Depth must be a multiple of six.
/// + [`CUDA_ARRAY3D_TEXTURE_GATHER`] to indicate that the CUDA mipmapped array will be used for texture gather. Texture gather can only be performed on 2D CUDA
/// mipmapped arrays.
///
/// Width, Height and Depth must meet certain size requirements as listed in the following table. All values are specified in elements. Note that for
/// brevity's sake, the full name of the device attribute is not specified. For ex., TEXTURE1D_MIPMAPPED_WIDTH refers to the device
/// attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH`].
///
/// | | | |
/// | --- | --- | --- |
/// | **CUDA array type** | **Valid extents that must always be met {(width range in elements), (height range), (depth range)}** | **Valid extents with CUDA_ARRAY3D_SURFACE_LDST set {(width range in elements), (height range), (depth range)}** |
/// | 1D | { (1,TEXTURE1D_MIPMAPPED_WIDTH), 0, 0 } | { (1,SURFACE1D_WIDTH), 0, 0 } |
/// | 2D | { (1,TEXTURE2D_MIPMAPPED_WIDTH), (1,TEXTURE2D_MIPMAPPED_HEIGHT), 0 } | { (1,SURFACE2D_WIDTH), (1,SURFACE2D_HEIGHT), 0 } |
/// | 3D | { (1,TEXTURE3D_WIDTH), (1,TEXTURE3D_HEIGHT), (1,TEXTURE3D_DEPTH) } OR { (1,TEXTURE3D_WIDTH_ALTERNATE), (1,TEXTURE3D_HEIGHT_ALTERNATE), (1,TEXTURE3D_DEPTH_ALTERNATE) } | { (1,SURFACE3D_WIDTH), (1,SURFACE3D_HEIGHT), (1,SURFACE3D_DEPTH) } |
/// | 1D Layered | { (1,TEXTURE1D_LAYERED_WIDTH), 0, (1,TEXTURE1D_LAYERED_LAYERS) } | { (1,SURFACE1D_LAYERED_WIDTH), 0, (1,SURFACE1D_LAYERED_LAYERS) } |
/// | 2D Layered | { (1,TEXTURE2D_LAYERED_WIDTH), (1,TEXTURE2D_LAYERED_HEIGHT), (1,TEXTURE2D_LAYERED_LAYERS) } | { (1,SURFACE2D_LAYERED_WIDTH), (1,SURFACE2D_LAYERED_HEIGHT), (1,SURFACE2D_LAYERED_LAYERS) } |
/// | Cubemap | { (1,TEXTURECUBEMAP_WIDTH), (1,TEXTURECUBEMAP_WIDTH), 6 } | { (1,SURFACECUBEMAP_WIDTH), (1,SURFACECUBEMAP_WIDTH), 6 } |
/// | Cubemap Layered | { (1,TEXTURECUBEMAP_LAYERED_WIDTH), (1,TEXTURECUBEMAP_LAYERED_WIDTH), (1,TEXTURECUBEMAP_LAYERED_LAYERS) } | { (1,SURFACECUBEMAP_LAYERED_WIDTH), (1,SURFACECUBEMAP_LAYERED_WIDTH), (1,SURFACECUBEMAP_LAYERED_LAYERS) } |
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMipmappedArrayDestroy`], [`cuMipmappedArrayGetLevel`], [`cuArrayCreate_v2`], [cudaMallocMipmappedArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g9abd550dd3f655473d2640dc85be9774).
///
/// # Parameters
///
/// - `pHandle`: Returned mipmapped array.
/// - `pMipmappedArrayDesc`: mipmapped array descriptor.
/// - `numMipmapLevels`: Number of mipmap levels.
pub fn cuMipmappedArrayCreate(
pHandle: *mut CUmipmappedArray,
pMipmappedArrayDesc: *const CUDA_ARRAY3D_DESCRIPTOR,
numMipmapLevels: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Gets a mipmap level of a CUDA mipmapped array.
///
/// Returns in \*pLevelArray a CUDA array that represents a single mipmap level of the CUDA mipmapped array hMipmappedArray.
///
/// If level is greater than the maximum number of levels in this mipmapped array, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMipmappedArrayCreate`], [`cuMipmappedArrayDestroy`], [`cuArrayCreate_v2`], [cudaGetMipmappedArrayLevel](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g7086e6f81e6dda1ddf4cdb6c1764094a).
///
/// # Parameters
///
/// - `pLevelArray`: Returned mipmap level CUDA array.
/// - `hMipmappedArray`: CUDA mipmapped array.
/// - `level`: Mipmap level.
pub fn cuMipmappedArrayGetLevel(
pLevelArray: *mut CUarray,
hMipmappedArray: CUmipmappedArray,
level: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Destroys a CUDA mipmapped array.
///
/// Destroys the CUDA mipmapped array hMipmappedArray.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMipmappedArrayCreate`], [`cuMipmappedArrayGetLevel`], [`cuArrayCreate_v2`], [cudaFreeMipmappedArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g904669241eac5bdbfb410eb4124e4924).
///
/// # Parameters
///
/// - `hMipmappedArray`: Mipmapped array to destroy.
pub fn cuMipmappedArrayDestroy(hMipmappedArray: CUmipmappedArray) -> CUresult;
}
unsafe extern "C" {
/// Retrieve handle for an address range.
///
/// Get a handle of the specified type to an address range. When requesting CUmemRangeHandleType::CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD,
/// address range obtained by a prior call to either [`cuMemAlloc_v2`] or [`cuMemAddressReserve`] is supported if the [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED`] device attribute returns true. If the address range was obtained via [`cuMemAddressReserve`], it must also be fully mapped via [`cuMemMap`]. Address range obtained by a prior call to either [`cuMemAllocHost_v2`] or [`cuMemHostAlloc`] is supported if the [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_HOST_ALLOC_DMA_BUF_SUPPORTED`] device attribute returns true.
///
/// As of CUDA 13.0, querying support for address range obtained by calling [`cuMemAllocHost_v2`] or [`cuMemHostAlloc`] using the [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED`] device attribute is deprecated.
///
/// Users must ensure the dptr and size are aligned to the host page size.
///
/// The handle will be interpreted as a pointer to an integer to store the dma_buf file descriptor. Users must ensure the entire address
/// range is backed and mapped when the address range is allocated by [`cuMemAddressReserve`]. All the physical allocations backing the address range must be resident on the same device and have identical allocation
/// properties. Users are also expected to retrieve a new handle every time the underlying physical allocation(s) corresponding
/// to a previously queried VA range are changed.
///
/// For CUmemRangeHandleType::CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD, users may set flags to [`CUmemRangeFlags_enum::CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE`]. Which when set on a supported platform, will give a DMA_BUF handle mapped via PCIE BAR1 or will return an error otherwise.
///
/// # Parameters
///
/// - `handle`: Pointer to the location where the returned handle will be stored.
/// - `dptr`: Pointer to a valid CUDA device allocation. Must be aligned to host page size.
/// - `size`: Length of the address range. Must be aligned to host page size.
/// - `handleType`: Type of handle requested (defines type and size of the handle output parameter).
/// - `flags`: When requesting CUmemRangeHandleType::CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD the value could be [`CUmemRangeFlags_enum::CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE`], otherwise 0.
pub fn cuMemGetHandleForAddressRange(
handle: *mut ::core::ffi::c_void,
dptr: CUdeviceptr,
size: size_t,
handleType: CUmemRangeHandleType,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUmemDecompressAlgorithm_enum {
/// Decompression is unsupported.
CU_MEM_DECOMPRESS_UNSUPPORTED = 0,
/// Deflate is supported.
CU_MEM_DECOMPRESS_ALGORITHM_DEFLATE = 1,
/// Snappy is supported.
CU_MEM_DECOMPRESS_ALGORITHM_SNAPPY = 2,
/// LZ4 is supported.
CU_MEM_DECOMPRESS_ALGORITHM_LZ4 = 4,
}
pub use self::CUmemDecompressAlgorithm_enum as CUmemDecompressAlgorithm;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUmemDecompressParams_st {
pub srcNumBytes: size_t,
pub dstNumBytes: size_t,
pub dstActBytes: *mut cuuint32_t,
pub src: *const ::core::ffi::c_void,
pub dst: *mut ::core::ffi::c_void,
pub algo: CUmemDecompressAlgorithm,
pub padding: [::core::ffi::c_uchar; 20usize],
}
impl Default for CUmemDecompressParams_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Structure describing the parameters that compose a single decompression operation.
pub type CUmemDecompressParams = CUmemDecompressParams_st;
unsafe extern "C" {
/// Submit a batch of count independent decompression operations.
///
/// Each of the count decompression operations is described by a single entry in the paramsArray array. Once the batch has been submitted, the function will return, and decompression will happen asynchronously with respect to the
/// CPU. To the work completion tracking mechanisms in the CUDA driver, the batch will be considered a single unit of work and
/// processed according to stream semantics, i.e., it is not possible to query the completion of individual decompression operations
/// within a batch.
///
/// The memory pointed to by each of [CUmemDecompressParams.src](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemDecompressParams.html#structCUmemDecompressParams_14d390c15ec5ed068f0912e42077ae0e0), [CUmemDecompressParams.dst](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemDecompressParams.html#structCUmemDecompressParams_139077e823122cfcfab6aeca53093c88c), and [CUmemDecompressParams.dstActBytes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemDecompressParams.html#structCUmemDecompressParams_1df7e9b52dd81aa6c0ed689eeab86d1a7), must be capable of usage with the hardware decompress feature. That is, for each of said pointers, the pointer attribute
/// [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE`] should give a non-zero value. To ensure this, the memory backing the pointers should have been allocated using one of the
/// following CUDA memory allocators: \* [`cuMemAlloc_v2`] \* [`cuMemCreate`] with the usage flag [`CU_MEM_CREATE_USAGE_HW_DECOMPRESS`] \* [`cuMemAllocFromPoolAsync`] from a pool that was created with the usage flag [`CU_MEM_POOL_CREATE_USAGE_HW_DECOMPRESS`] Additionally, [CUmemDecompressParams.src](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemDecompressParams.html#structCUmemDecompressParams_14d390c15ec5ed068f0912e42077ae0e0), [CUmemDecompressParams.dst](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemDecompressParams.html#structCUmemDecompressParams_139077e823122cfcfab6aeca53093c88c), and [CUmemDecompressParams.dstActBytes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemDecompressParams.html#structCUmemDecompressParams_1df7e9b52dd81aa6c0ed689eeab86d1a7), must all be accessible from the device associated with the context where stream was created. For information on how to ensure this, see the documentation for the allocator of interest.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuMemAlloc_v2`], [`cuMemPoolCreate`], [`cuMemAllocFromPoolAsync`].
///
/// # Parameters
///
/// - `paramsArray`: The array of structures describing the independent decompression operations.
/// - `count`: The number of entries in paramsArray array.
/// - `flags`: Must be 0.
/// - `errorIndex`: The index into paramsArray of the decompression operation for which the error returned by this function pertains to. If index is SIZE_MAX and the value returned is not [`cudaError_enum::CUDA_SUCCESS`], then the error returned by this function should be considered a general error that does not pertain to a particular decompression
/// operation. May be NULL, in which case, no index will be recorded in the event of error.
/// - `stream`: The stream where the work will be enqueued.
pub fn cuMemBatchDecompressAsync(
paramsArray: *mut CUmemDecompressParams,
count: size_t,
flags: ::core::ffi::c_uint,
errorIndex: *mut size_t,
stream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Allocate an address range reservation.
///
/// Reserves a virtual address range based on the given parameters, giving the starting address of the range in ptr. This API requires a system that supports UVA. The size and address parameters must be a multiple of the host page size and
/// the alignment must be a power of two or zero for default alignment. If addr is 0, then the driver chooses the address at which to place the start of the reservation whereas when it is non-zero then
/// the driver treats it as a hint about where to place the reservation.
///
/// **See also:**
///
/// [`cuMemAddressFree`].
///
/// # Parameters
///
/// - `ptr`: Resulting pointer to start of virtual address range allocated.
/// - `size`: Size of the reserved virtual address range requested.
/// - `alignment`: Alignment of the reserved virtual address range requested.
/// - `addr`: Hint address for the start of the address range.
/// - `flags`: Currently unused, must be zero.
pub fn cuMemAddressReserve(
ptr: *mut CUdeviceptr,
size: size_t,
alignment: size_t,
addr: CUdeviceptr,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Free an address range reservation.
///
/// Frees a virtual address range reserved by cuMemAddressReserve. The size must match what was given to memAddressReserve and
/// the ptr given must match what was returned from memAddressReserve.
///
/// **See also:**
///
/// [`cuMemAddressReserve`].
///
/// # Parameters
///
/// - `ptr`: Starting address of the virtual address range to free.
/// - `size`: Size of the virtual address region to free.
pub fn cuMemAddressFree(ptr: CUdeviceptr, size: size_t) -> CUresult;
}
unsafe extern "C" {
/// Create a CUDA memory handle representing a memory allocation of a given size described by the given properties.
///
/// This creates a memory allocation on the target device specified through the prop structure. The created allocation will not have any device or host mappings. The generic memory handle for the allocation can be mapped to the address space of calling process via [`cuMemMap`]. This handle cannot be transmitted directly to other processes (see [`cuMemExportToShareableHandle`]). On Windows, the caller must also pass an LPSECURITYATTRIBUTE in prop to be associated with this handle which limits or allows access to this handle for a recipient process (see [CUmemAllocationProp::win32HandleMetaData](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemAllocationProp__v1.html#structCUmemAllocationProp__v1_1542262ad88e1d00f02b306c641270168) for more). The size of this allocation must be a multiple of the value given via [`cuMemGetAllocationGranularity`] with the [`CUmemAllocationGranularity_flags_enum::CU_MEM_ALLOC_GRANULARITY_MINIMUM`] flag. To create a CPU allocation that doesn't target any specific NUMA nodes, applications must set CUmemAllocationProp::CUmemLocation::type
/// to [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`]. CUmemAllocationProp::CUmemLocation::id is ignored for HOST allocations. HOST allocations are not IPC capable and [CUmemAllocationProp::requestedHandleTypes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemAllocationProp__v1.html#structCUmemAllocationProp__v1_1e2e852e72e5d2053b771fbac49495efd) must be 0, any other value will result in [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]. To create a CPU allocation targeting a specific host NUMA node, applications must set CUmemAllocationProp::CUmemLocation::type
/// to [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`] and CUmemAllocationProp::CUmemLocation::id must specify the NUMA ID of the CPU. On systems where NUMA is not available CUmemAllocationProp::CUmemLocation::id
/// must be set to 0. Specifying [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT`] as the [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) will result in [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// Applications that intend to use [`CUmemAllocationHandleType_enum::CU_MEM_HANDLE_TYPE_FABRIC`] based memory sharing must ensure: (1) `nvidia-caps-imex-channels` character device is created by the driver and is listed
/// under /proc/devices (2) have at least one IMEX channel file accessible by the user launching the application.
///
/// When exporter and importer CUDA processes have been granted access to the same IMEX channel, they can securely share memory.
///
/// The IMEX channel security model works on a per user basis. Which means all processes under a user can share memory if the
/// user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX channel is required for each
/// user.
///
/// These channel files exist in /dev/nvidia-caps-imex-channels/channel\* and can be created using standard OS native calls like
/// mknod on Linux. For example: To create channel0 with the major number from /proc/devices users can execute the following command:
/// `mknod /dev/nvidia-caps-imex-channels/channel0 c <major number>=""> 0`
///
/// If CUmemAllocationProp::allocFlags::usage contains [`CU_MEM_CREATE_USAGE_TILE_POOL`] flag then the memory allocation is intended only to be used as backing tile pool for sparse CUDA arrays and sparse CUDA mipmapped
/// arrays. (see [`cuMemMapArrayAsync`]).
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMemRelease`], [`cuMemExportToShareableHandle`], [`cuMemImportFromShareableHandle`].
///
/// # Parameters
///
/// - `handle`: Value of handle returned. All operations on this allocation are to be performed using this handle.
/// - `size`: Size of the allocation requested.
/// - `prop`: Properties of the allocation to create.
/// - `flags`: flags for future use, must be zero now.
pub fn cuMemCreate(
handle: *mut CUmemGenericAllocationHandle,
size: size_t,
prop: *const CUmemAllocationProp,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Release a memory handle representing a memory allocation which was previously allocated through cuMemCreate.
///
/// Frees the memory that was allocated on a device through cuMemCreate.
///
/// The memory allocation will be freed when all outstanding mappings to the memory are unmapped and when all outstanding references
/// to the handle (including it's shareable counterparts) are also released. The generic memory handle can be freed when there
/// are still outstanding mappings made with this handle. Each time a recipient process imports a shareable handle, it needs to
/// pair it with [`cuMemRelease`] for the handle to be freed. If handle is not a valid handle the behavior is undefined.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMemCreate`].
///
/// # Parameters
///
/// - `handle`: Value of handle which was returned previously by cuMemCreate.
pub fn cuMemRelease(handle: CUmemGenericAllocationHandle) -> CUresult;
}
unsafe extern "C" {
/// Maps an allocation handle to a reserved virtual address range.
///
/// Maps bytes of memory represented by handle starting from byte offset to size to address range \[addr, addr + size\]. This range must be an address reservation previously reserved with [`cuMemAddressReserve`], and offset + size must be less than the size of the memory allocation. Both ptr, size, and offset must be a multiple of the value given via [`cuMemGetAllocationGranularity`] with the [`CUmemAllocationGranularity_flags_enum::CU_MEM_ALLOC_GRANULARITY_MINIMUM`] flag. If handle represents a multicast object, ptr, size and offset must be aligned to the value returned by [`cuMulticastGetGranularity`] with the flag CU_MULTICAST_MINIMUM_GRANULARITY. For best performance however, it is recommended that ptr, size and offset be aligned to the value returned by [`cuMulticastGetGranularity`] with the flag CU_MULTICAST_RECOMMENDED_GRANULARITY.
///
/// When handle represents a multicast object, this call may return [`CUresult::CUDA_ERROR_ILLEGAL_STATE`] if the system configuration is in an illegal
/// state. In such cases, to continue using multicast, verify that the system configuration is in a valid state and all required
/// driver daemons are running properly.
///
/// Please note calling [`cuMemMap`] does not make the address accessible, the caller needs to update accessibility of a contiguous mapped VA range by calling
/// [`cuMemSetAccess`].
///
/// Once a recipient process obtains a shareable memory handle from [`cuMemImportFromShareableHandle`], the process must use [`cuMemMap`] to map the memory into its address ranges before setting accessibility with [`cuMemSetAccess`].
///
/// [`cuMemMap`] can only create mappings on VA range reservations that are not currently mapped.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMemUnmap`], [`cuMemSetAccess`], [`cuMemCreate`], [`cuMemAddressReserve`], [`cuMemImportFromShareableHandle`].
///
/// # Parameters
///
/// - `ptr`: Address where memory will be mapped.
/// - `size`: Size of the memory mapping.
/// - `offset`: Offset into the memory represented by
///
/// * handle from which to start mapping
/// * Note: currently must be zero.
/// - `handle`: Handle to a shareable memory.
/// - `flags`: flags for future use, must be zero now.
pub fn cuMemMap(
ptr: CUdeviceptr,
size: size_t,
offset: size_t,
handle: CUmemGenericAllocationHandle,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Maps or unmaps subregions of sparse CUDA arrays and sparse CUDA mipmapped arrays.
///
/// Performs map or unmap operations on subregions of sparse CUDA arrays and sparse CUDA mipmapped arrays. Each operation is specified
/// by a CUarrayMapInfo entry in the mapInfoList array of size count. The structure CUarrayMapInfo is defined as follow:
///
/// ```text
/// typedef struct CUarrayMapInfo_st {
/// CUresourcetype resourceType;
/// union {
/// CUmipmappedArray mipmap;
/// CUarray array;
/// } resource;
///
/// CUarraySparseSubresourceType subresourceType;
/// union {
/// struct {
/// unsigned int level;
/// unsigned int layer;
/// unsigned int offsetX;
/// unsigned int offsetY;
/// unsigned int offsetZ;
/// unsigned int extentWidth;
/// unsigned int extentHeight;
/// unsigned int extentDepth;
/// } sparseLevel;
/// struct {
/// unsigned int layer;
/// unsigned long long offset;
/// unsigned long long size;
/// } miptail;
/// } subresource;
///
/// CUmemOperationType memOperationType;
///
/// CUmemHandleType memHandleType;
/// union {
/// CUmemGenericAllocationHandle memHandle;
/// } memHandle;
///
/// unsigned long long offset;
/// unsigned int deviceBitMask;
/// unsigned int flags;
/// unsigned int reserved\[2\];
/// } CUarrayMapInfo;
/// ```
///
/// where [CUarrayMapInfo::resourceType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_18cf3c7ba97c834ab8b0fcfb50fec578c) specifies the type of resource to be operated on. If [CUarrayMapInfo::resourceType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_18cf3c7ba97c834ab8b0fcfb50fec578c) is set to [`CUresourcetype::CU_RESOURCE_TYPE_ARRAY`] then CUarrayMapInfo::resource::array must be set to a valid sparse CUDA array handle. The CUDA array must be either a 2D,
/// 2D layered or 3D CUDA array and must have been allocated using [`cuArrayCreate_v2`] or [`cuArray3DCreate_v2`] with the flag [`CUDA_ARRAY3D_SPARSE`] or [`CUDA_ARRAY3D_DEFERRED_MAPPING`]. For CUDA arrays obtained using [`cuMipmappedArrayGetLevel`], [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] will be returned. If [CUarrayMapInfo::resourceType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_18cf3c7ba97c834ab8b0fcfb50fec578c) is set to [`CUresourcetype::CU_RESOURCE_TYPE_MIPMAPPED_ARRAY`] then CUarrayMapInfo::resource::mipmap must be set to a valid sparse CUDA mipmapped array handle. The CUDA mipmapped array
/// must be either a 2D, 2D layered or 3D CUDA mipmapped array and must have been allocated using [`cuMipmappedArrayCreate`] with the flag [`CUDA_ARRAY3D_SPARSE`] or [`CUDA_ARRAY3D_DEFERRED_MAPPING`].
///
/// [CUarrayMapInfo::subresourceType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_17a2fe272bd8e44af2386f1c20c3d3c68) specifies the type of subresource within the resource. CUarraySparseSubresourceType_enum is defined as:
///
/// ```text
/// typedef enum CUarraySparseSubresourceType_enum {
/// CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_SPARSE_LEVEL = 0,
/// CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_MIPTAIL = 1
/// } CUarraySparseSubresourceType;
/// ```
///
/// where CUarraySparseSubresourceType::CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_SPARSE_LEVEL indicates a sparse-miplevel which spans
/// at least one tile in every dimension. The remaining miplevels which are too small to span at least one tile in any dimension
/// constitute the mip tail region as indicated by CUarraySparseSubresourceType::CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_MIPTAIL subresource
/// type.
///
/// If [CUarrayMapInfo::subresourceType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_17a2fe272bd8e44af2386f1c20c3d3c68) is set to CUarraySparseSubresourceType::CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_SPARSE_LEVEL then CUarrayMapInfo::subresource::sparseLevel
/// struct must contain valid array subregion offsets and extents. The CUarrayMapInfo::subresource::sparseLevel::offsetX, CUarrayMapInfo::subresource::sparseLevel::offsetY
/// and CUarrayMapInfo::subresource::sparseLevel::offsetZ must specify valid X, Y and Z offsets respectively. The CUarrayMapInfo::subresource::sparseLevel::extentWidth,
/// CUarrayMapInfo::subresource::sparseLevel::extentHeight and CUarrayMapInfo::subresource::sparseLevel::extentDepth must specify
/// valid width, height and depth extents respectively. These offsets and extents must be aligned to the corresponding tile dimension.
/// For CUDA mipmapped arrays CUarrayMapInfo::subresource::sparseLevel::level must specify a valid mip level index. Otherwise,
/// must be zero. For layered CUDA arrays and layered CUDA mipmapped arrays CUarrayMapInfo::subresource::sparseLevel::layer must
/// specify a valid layer index. Otherwise, must be zero. CUarrayMapInfo::subresource::sparseLevel::offsetZ must be zero and CUarrayMapInfo::subresource::sparseLevel::extentDepth
/// must be set to 1 for 2D and 2D layered CUDA arrays and CUDA mipmapped arrays. Tile extents can be obtained by calling [`cuArrayGetSparseProperties`] and [`cuMipmappedArrayGetSparseProperties`]
///
/// If [CUarrayMapInfo::subresourceType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_17a2fe272bd8e44af2386f1c20c3d3c68) is set to CUarraySparseSubresourceType::CU_ARRAY_SPARSE_SUBRESOURCE_TYPE_MIPTAIL then CUarrayMapInfo::subresource::miptail
/// struct must contain valid mip tail offset in CUarrayMapInfo::subresource::miptail::offset and size in CUarrayMapInfo::subresource::miptail::size.
/// Both, mip tail offset and mip tail size must be aligned to the tile size. For layered CUDA mipmapped arrays which don't have
/// the flag [`CU_ARRAY_SPARSE_PROPERTIES_SINGLE_MIPTAIL`] set in [CUDA_ARRAY_SPARSE_PROPERTIES::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__ARRAY__SPARSE__PROPERTIES__v1.html#structCUDA__ARRAY__SPARSE__PROPERTIES__v1_10e842bb64091fa47809112c700cb5f0a) as returned by [`cuMipmappedArrayGetSparseProperties`], CUarrayMapInfo::subresource::miptail::layer must specify a valid layer index. Otherwise, must be zero.
///
/// If CUarrayMapInfo::resource::array or CUarrayMapInfo::resource::mipmap was created with [`CUDA_ARRAY3D_DEFERRED_MAPPING`] flag set the [CUarrayMapInfo::subresourceType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_17a2fe272bd8e44af2386f1c20c3d3c68) and the contents of CUarrayMapInfo::subresource will be ignored.
///
/// [CUarrayMapInfo::memOperationType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_1dd139e9655407264f2aeb812cec0f19e) specifies the type of operation. `CUmemOperationType` is defined as:
///
/// ```text
/// typedef enum CUmemOperationType_enum {
/// CU_MEM_OPERATION_TYPE_MAP = 1,
/// CU_MEM_OPERATION_TYPE_UNMAP = 2
/// } CUmemOperationType;
/// ```
///
/// [CUarrayMapInfo::memOperationType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_1dd139e9655407264f2aeb812cec0f19e)
///
/// [CUarrayMapInfo::offset](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_14aee5e358272af897aeaf8b44fd15bdb)
///
/// [`CU_MEM_CREATE_USAGE_TILE_POOL`]
///
/// [`cuMemCreate`]
///
/// [CUarrayMapInfo::memHandleType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_1ed15e0aa10304948c68946fe8a5da161)
///
/// If [CUarrayMapInfo::memOperationType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_1dd139e9655407264f2aeb812cec0f19e) is set to CUmemOperationType::CU_MEM_OPERATION_TYPE_UNMAP then an unmapping operation is performed. CUarrayMapInfo::memHandle
/// must be NULL.
///
/// [CUarrayMapInfo::deviceBitMask](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_1f2d14f719018cc1daa786f7fd0652c2c) specifies the list of devices that must map or unmap physical memory. Currently, this mask must have exactly one bit set,
/// and the corresponding device must match the device associated with the stream. If [CUarrayMapInfo::memOperationType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_1dd139e9655407264f2aeb812cec0f19e) is set to CUmemOperationType::CU_MEM_OPERATION_TYPE_MAP, the device must also match the device associated with the tile pool
/// memory allocation as specified by CUarrayMapInfo::memHandle.
///
/// [CUarrayMapInfo::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_12e36982c16390693a56807d0b8e6380f) and [CUarrayMapInfo::reserved](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUarrayMapInfo__v1.html#structCUarrayMapInfo__v1_1cf7014dc4a157928de12563d0181ceba)[] are unused and must be set to zero.
///
/// **See also:**
///
/// [`cuMipmappedArrayCreate`], [`cuArrayCreate_v2`], [`cuArray3DCreate_v2`], [`cuMemCreate`], [`cuArrayGetSparseProperties`], [`cuMipmappedArrayGetSparseProperties`].
///
/// # Parameters
///
/// - `mapInfoList`: List of CUarrayMapInfo.
/// - `count`: Count of CUarrayMapInfo in mapInfoList.
/// - `hStream`: Stream identifier for the stream to use for map or unmap operations.
pub fn cuMemMapArrayAsync(
mapInfoList: *mut CUarrayMapInfo,
count: ::core::ffi::c_uint,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Unmap the backing memory of a given address range.
///
/// The range must be the entire contiguous address range that was mapped to. In other words, [`cuMemUnmap`] cannot unmap a sub-range of an address range mapped by [`cuMemCreate`] / [`cuMemMap`]. Any backing memory allocations will be freed if there are no existing mappings and there are no unreleased memory handles.
///
/// When [`cuMemUnmap`] returns successfully the address range is converted to an address reservation and can be used for a future calls to [`cuMemMap`]. Any new mapping to this virtual address will need to have access granted through [`cuMemSetAccess`], as all mappings start with no accessibility setup.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuMemCreate`], [`cuMemAddressReserve`].
///
/// # Parameters
///
/// - `ptr`: Starting address for the virtual address range to unmap.
/// - `size`: Size of the virtual address range to unmap.
pub fn cuMemUnmap(ptr: CUdeviceptr, size: size_t) -> CUresult;
}
unsafe extern "C" {
/// Set the access flags for each location specified in desc for the given virtual address range.
///
/// Given the virtual address range via ptr and size, and the locations in the array given by desc and count, set the access flags for the target locations. The range must be a fully mapped address range containing all allocations
/// created by [`cuMemMap`] / [`cuMemCreate`]. Users cannot specify [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`] accessibility for allocations created on with other location types. Note: When CUmemAccessDesc::CUmemLocation::type is [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`], CUmemAccessDesc::CUmemLocation::id is ignored. When setting the access flags for a virtual address range mapping a multicast
/// object, ptr and size must be aligned to the value returned by [`cuMulticastGetGranularity`] with the flag CU_MULTICAST_MINIMUM_GRANULARITY. For best performance however, it is recommended that ptr and size be aligned to the value returned by [`cuMulticastGetGranularity`] with the flag CU_MULTICAST_RECOMMENDED_GRANULARITY.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
///
/// **See also:**
///
/// [`cuMemSetAccess`], [`cuMemCreate`], :[`cuMemMap`].
///
/// # Parameters
///
/// - `ptr`: Starting address for the virtual address range.
/// - `size`: Length of the virtual address range.
/// - `desc`: Array of CUmemAccessDesc that describe how to change the
///
/// * mapping for each location specified.
/// - `count`: Number of CUmemAccessDesc in desc.
pub fn cuMemSetAccess(
ptr: CUdeviceptr,
size: size_t,
desc: *const CUmemAccessDesc,
count: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Get the access flags set for the given location and ptr.
///
/// **See also:**
///
/// [`cuMemSetAccess`].
///
/// # Parameters
///
/// - `flags`: Flags set for this location.
/// - `location`: Location in which to check the flags for.
/// - `ptr`: Address in which to check the access flags for.
pub fn cuMemGetAccess(
flags: *mut ::core::ffi::c_ulonglong,
location: *const CUmemLocation,
ptr: CUdeviceptr,
) -> CUresult;
}
unsafe extern "C" {
/// Exports an allocation to a requested shareable handle type.
///
/// Given a CUDA memory handle, create a shareable memory allocation handle that can be used to share the memory with other processes.
/// The recipient process can convert the shareable handle back into a CUDA memory handle using [`cuMemImportFromShareableHandle`] and map it with [`cuMemMap`]. The implementation of what this handle is and how it can be transferred is defined by the requested handle type in handleType
///
/// Once all shareable handles are closed and the allocation is released, the allocated memory referenced will be released back
/// to the OS and uses of the CUDA handle afterward will lead to undefined behavior.
///
/// This API can also be used in conjunction with other APIs (e.g. Vulkan, OpenGL) that support importing memory from the shareable
/// type
///
/// **See also:**
///
/// [`cuMemImportFromShareableHandle`].
///
/// # Parameters
///
/// - `shareableHandle`: Pointer to the location in which to store the requested handle type.
/// - `handle`: CUDA handle for the memory allocation.
/// - `handleType`: Type of shareable handle requested (defines type and size of the shareableHandle output parameter).
/// - `flags`: Reserved, must be zero.
pub fn cuMemExportToShareableHandle(
shareableHandle: *mut ::core::ffi::c_void,
handle: CUmemGenericAllocationHandle,
handleType: CUmemAllocationHandleType,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Imports an allocation from a requested shareable handle type.
///
/// If the current process cannot support the memory described by this shareable handle, this API will error as [`cudaError_enum::CUDA_ERROR_NOT_SUPPORTED`].
///
/// If shHandleType is [`CUmemAllocationHandleType_enum::CU_MEM_HANDLE_TYPE_FABRIC`] and the importer process has not been granted access to the same IMEX channel as the exporter process, this API will error
/// as [`cudaError_enum::CUDA_ERROR_NOT_PERMITTED`].
///
/// Note:
///
/// Importing shareable handles exported from some graphics APIs(VUlkan, OpenGL, etc) created on devices under an SLI group may
/// not be supported, and thus this API will return [`CUresult::CUDA_ERROR_NOT_SUPPORTED`]. There is no guarantee that the contents of handle will be the same CUDA memory handle for the same given OS shareable handle, or the same underlying allocation.
///
/// **See also:**
///
/// [`cuMemExportToShareableHandle`], [`cuMemMap`], [`cuMemRelease`].
///
/// # Parameters
///
/// - `handle`: CUDA Memory handle for the memory allocation.
/// - `osHandle`: Shareable Handle representing the memory allocation that is to be imported.
/// - `shHandleType`: handle type of the exported handle `CUmemAllocationHandleType`.
pub fn cuMemImportFromShareableHandle(
handle: *mut CUmemGenericAllocationHandle,
osHandle: *mut ::core::ffi::c_void,
shHandleType: CUmemAllocationHandleType,
) -> CUresult;
}
unsafe extern "C" {
/// Calculates either the minimal or recommended granularity.
///
/// Calculates either the minimal or recommended granularity for a given allocation specification and returns it in granularity.
/// This granularity can be used as a multiple for alignment, size, or address mapping.
///
/// **See also:**
///
/// [`cuMemCreate`], [`cuMemMap`].
///
/// # Parameters
///
/// - `granularity`: Returned granularity.
/// - `prop`: Property for which to determine the granularity for.
/// - `option`: Determines which granularity to return.
pub fn cuMemGetAllocationGranularity(
granularity: *mut size_t,
prop: *const CUmemAllocationProp,
option: CUmemAllocationGranularity_flags,
) -> CUresult;
}
unsafe extern "C" {
/// Retrieve the contents of the property structure defining properties for this handle.
///
/// **See also:**
///
/// [`cuMemCreate`], [`cuMemImportFromShareableHandle`].
///
/// # Parameters
///
/// - `prop`: Pointer to a properties structure which will hold the information about this handle.
/// - `handle`: Handle which to perform the query on.
pub fn cuMemGetAllocationPropertiesFromHandle(
prop: *mut CUmemAllocationProp,
handle: CUmemGenericAllocationHandle,
) -> CUresult;
}
unsafe extern "C" {
/// Given an address addr, returns the allocation handle of the backing memory allocation.
///
/// The handle is guaranteed to be the same handle value used to map the memory. If the address requested is not mapped, the function
/// will fail. The returned handle must be released with corresponding number of calls to [`cuMemRelease`].
///
/// Note:
///
/// The address addr, can be any address in a range previously mapped by [`cuMemMap`], and not necessarily the start address.
///
/// **See also:**
///
/// [`cuMemCreate`], [`cuMemRelease`], [`cuMemMap`].
///
/// # Parameters
///
/// - `handle`: CUDA Memory handle for the backing memory allocation.
/// - `addr`: Memory address to query, that has been mapped previously.
pub fn cuMemRetainAllocationHandle(
handle: *mut CUmemGenericAllocationHandle,
addr: *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Frees memory with stream ordered semantics.
///
/// Inserts a free operation into hStream. The allocation must not be accessed after stream execution reaches the free. After this API returns, accessing the memory
/// from any subsequent work launched on the GPU or querying its pointer attributes results in undefined behavior.
///
/// Note:
///
/// During stream capture, this function results in the creation of a free node and must therefore be passed the address of a
/// graph allocation.
///
/// # Parameters
///
/// - `dptr`: memory to free.
/// - `hStream`: The stream establishing the stream ordering contract.
pub fn cuMemFreeAsync(dptr: CUdeviceptr, hStream: CUstream) -> CUresult;
}
unsafe extern "C" {
/// Allocates memory with stream ordered semantics.
///
/// Inserts an allocation operation into hStream. A pointer to the allocated memory is returned immediately in \*dptr. The allocation must not be accessed until the allocation
/// operation completes. The allocation comes from the memory pool current to the stream's device.
///
/// Note:
///
/// * The default memory pool of a device contains device memory from that device.
/// * Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize,
/// and CUDA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream
/// runs.
/// * During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned
/// by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters.
///
/// **See also:**
///
/// [`cuMemAllocFromPoolAsync`], [`cuMemFreeAsync`], [`cuDeviceSetMemPool`], [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`], [`cuMemPoolSetAccess`], [`cuMemPoolSetAttribute`].
///
/// # Parameters
///
/// - `dptr`: Returned device pointer.
/// - `bytesize`: Number of bytes to allocate.
/// - `hStream`: The stream establishing the stream ordering contract and the memory pool to allocate from.
pub fn cuMemAllocAsync(
dptr: *mut CUdeviceptr,
bytesize: size_t,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Tries to release memory back to the OS.
///
/// Releases memory back to the OS until the pool contains fewer than minBytesToKeep reserved bytes, or there is no more memory
/// that the allocator can safely release. The allocator cannot release OS allocations that back outstanding asynchronous allocations.
/// The OS allocations may happen at different granularity from the user allocations.
///
/// Note:
///
/// * : Allocations that have not been freed count as outstanding.
/// * : Allocations that have been asynchronously freed but whose completion has not been observed on the host (eg. by a synchronize)
/// can count as outstanding.
///
/// **See also:**
///
/// [`cuMemAllocAsync`], [`cuMemFreeAsync`], [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`].
///
/// # Parameters
///
/// - `pool`: The memory pool to trim.
/// - `minBytesToKeep`: If the pool has less than minBytesToKeep reserved, the TrimTo operation is a no-op. Otherwise the pool will be guaranteed
/// to have at least minBytesToKeep bytes reserved after the operation.
pub fn cuMemPoolTrimTo(pool: CUmemoryPool, minBytesToKeep: size_t) -> CUresult;
}
unsafe extern "C" {
/// Sets attributes of a memory pool.
///
/// Supported attributes are:
///
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_RELEASE_THRESHOLD`]: (value type = cuuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS.
/// When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory
/// back to the OS on the next call to stream, event or context synchronize. (default 0)
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES`]: (value type = int) Allow [`cuMemAllocAsync`] to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on
/// the free action exists. CUDA events and null stream interactions can create the required stream ordered dependencies. (default
/// enabled)
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC`]: (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default
/// enabled)
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES`]: (value type = int) Allow [`cuMemAllocAsync`] to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released
/// by [`cuMemFreeAsync`] (default enabled).
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH`]: (value type = cuuint64_t) Reset the high watermark that tracks the amount of backing memory that was allocated for the memory
/// pool. It is illegal to set this attribute to a non-zero value.
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_USED_MEM_HIGH`]: (value type = cuuint64_t) Reset the high watermark that tracks the amount of used memory that was allocated for the memory
/// pool.
///
/// **See also:**
///
/// [`cuMemAllocAsync`], [`cuMemFreeAsync`], [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`].
///
/// # Parameters
///
/// - `pool`: The memory pool to modify.
/// - `attr`: The attribute to modify.
/// - `value`: Pointer to the value to assign.
pub fn cuMemPoolSetAttribute(
pool: CUmemoryPool,
attr: CUmemPool_attribute,
value: *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Gets attributes of a memory pool.
///
/// Supported attributes are:
///
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_RELEASE_THRESHOLD`]: (value type = cuuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS.
/// When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory
/// back to the OS on the next call to stream, event or context synchronize. (default 0)
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES`]: (value type = int) Allow [`cuMemAllocAsync`] to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on
/// the free action exists. CUDA events and null stream interactions can create the required stream ordered dependencies. (default
/// enabled)
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC`]: (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default
/// enabled)
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES`]: (value type = int) Allow [`cuMemAllocAsync`] to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released
/// by [`cuMemFreeAsync`] (default enabled).
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_RESERVED_MEM_CURRENT`]: (value type = cuuint64_t) Amount of backing memory currently allocated for the mempool
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH`]: (value type = cuuint64_t) High watermark of backing memory allocated for the mempool since the last time it was reset.
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_USED_MEM_CURRENT`]: (value type = cuuint64_t) Amount of memory from the pool that is currently in use by the application.
/// * [`CUmemPool_attribute_enum::CU_MEMPOOL_ATTR_USED_MEM_HIGH`]: (value type = cuuint64_t) High watermark of the amount of memory from the pool that was in use by the application.
///
/// **See also:**
///
/// [`cuMemAllocAsync`], [`cuMemFreeAsync`], [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`].
///
/// # Parameters
///
/// - `pool`: The memory pool to get attributes of.
/// - `attr`: The attribute to get.
/// - `value`: Retrieved value.
pub fn cuMemPoolGetAttribute(
pool: CUmemoryPool,
attr: CUmemPool_attribute,
value: *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Controls visibility of pools between devices.
///
/// **See also:**
///
/// [`cuMemAllocAsync`], [`cuMemFreeAsync`], [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`].
///
/// # Parameters
///
/// - `pool`: The pool being modified.
/// - `map`: Array of access descriptors. Each descriptor instructs the access to enable for a single gpu.
/// - `count`: Number of descriptors in the map array.
pub fn cuMemPoolSetAccess(
pool: CUmemoryPool,
map: *const CUmemAccessDesc,
count: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the accessibility of a pool from a device.
///
/// Returns the accessibility of the pool's memory from the specified location.
///
/// **See also:**
///
/// [`cuMemAllocAsync`], [`cuMemFreeAsync`], [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`].
///
/// # Parameters
///
/// - `flags`: the accessibility of the pool from the specified location.
/// - `memPool`: the pool being queried.
/// - `location`: the location accessing the pool.
pub fn cuMemPoolGetAccess(
flags: *mut CUmemAccess_flags,
memPool: CUmemoryPool,
location: *mut CUmemLocation,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a memory pool.
///
/// Creates a CUDA memory pool and returns the handle in pool. The poolProps determines the properties of the pool such as the backing device and IPC capabilities.
///
/// To create a memory pool for HOST memory not targeting a specific NUMA node, applications must set set CUmemPoolProps::CUmemLocation::type
/// to [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`]. CUmemPoolProps::CUmemLocation::id is ignored for such pools. Pools created with the type [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`] are not IPC capable and [CUmemPoolProps::handleTypes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemPoolProps__v1.html#structCUmemPoolProps__v1_169e75d604b122dbd39a8e3e3eacbe660) must be 0, any other values will result in [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]. To create a memory pool targeting a specific host NUMA node, applications must set CUmemPoolProps::CUmemLocation::type to
/// [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`] and CUmemPoolProps::CUmemLocation::id must specify the NUMA ID of the host memory node. Specifying [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT`] as the CUmemPoolProps::CUmemLocation::type will result in [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]. By default, the pool's memory will be accessible from the device it is allocated on. In the case of pools created with [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`] or [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`], their default accessibility will be from the host CPU. Applications can control the maximum size of the pool by specifying
/// a non-zero value for [CUmemPoolProps::maxSize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemPoolProps__v1.html#structCUmemPoolProps__v1_10f9278cc88653f1eee70ab6a7a2ad7f3). If set to 0, the maximum size of the pool will default to a system dependent value.
///
/// Applications that intend to use [`CUmemAllocationHandleType_enum::CU_MEM_HANDLE_TYPE_FABRIC`] based memory sharing must ensure: (1) `nvidia-caps-imex-channels` character device is created by the driver and is listed
/// under /proc/devices (2) have at least one IMEX channel file accessible by the user launching the application.
///
/// When exporter and importer CUDA processes have been granted access to the same IMEX channel, they can securely share memory.
///
/// The IMEX channel security model works on a per user basis. Which means all processes under a user can share memory if the
/// user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX channel is required for each
/// user.
///
/// These channel files exist in /dev/nvidia-caps-imex-channels/channel\* and can be created using standard OS native calls like
/// mknod on Linux. For example: To create channel0 with the major number from /proc/devices users can execute the following command:
/// `mknod /dev/nvidia-caps-imex-channels/channel0 c <major number>=""> 0`
///
/// To create a managed memory pool, applications must set `CUmemAllocationType` to [`CUmemAllocationType::CU_MEM_ALLOCATION_TYPE_MANAGED`]. `CUmemAllocationHandleType` must also be set to [`CUmemAllocationHandleType::CU_MEM_HANDLE_TYPE_NONE`] since IPC is not supported. For managed memory pools, CUmemPoolProps::CUmemLocation
/// will be treated as the preferred location for all allocations created from the pool. An application can also set [`CUmemLocationType::CU_MEM_LOCATION_TYPE_NONE`]
/// to indicate no preferred location. [CUmemPoolProps::maxSize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemPoolProps__v1.html#structCUmemPoolProps__v1_10f9278cc88653f1eee70ab6a7a2ad7f3) must be set to zero for managed memory pools. [CUmemPoolProps::usage](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemPoolProps__v1.html#structCUmemPoolProps__v1_181dcd809a228c4346f8e732bb8e9070b) should be zero as decompress for managed memory is not supported. For managed memory pools, all devices on the system must
/// have non-zero concurrentManagedAccess. If not, this call returns [`CUresult::CUDA_ERROR_NOT_SUPPORTED`]
///
/// Note:
///
/// Specifying [`CUmemAllocationHandleType::CU_MEM_HANDLE_TYPE_NONE`] creates a memory pool that will not support IPC.
///
/// **See also:**
///
/// [`cuDeviceSetMemPool`], [`cuDeviceGetMemPool`], [`cuDeviceGetDefaultMemPool`], [`cuMemAllocFromPoolAsync`], [`cuMemPoolExportToShareableHandle`].
pub fn cuMemPoolCreate(
pool: *mut CUmemoryPool,
poolProps: *const CUmemPoolProps,
) -> CUresult;
}
unsafe extern "C" {
/// Destroys the specified memory pool.
///
/// If any pointers obtained from this pool haven't been freed or the pool has free operations that haven't completed when [`cuMemPoolDestroy`] is invoked, the function will return immediately and the resources associated with the pool will be released automatically
/// once there are no more outstanding allocations.
///
/// Destroying the current mempool of a device sets the default mempool of that device as the current mempool for that device.
///
/// Note:
///
/// A device's default memory pool cannot be destroyed.
///
/// **See also:**
///
/// [`cuMemFreeAsync`], [`cuDeviceSetMemPool`], [`cuDeviceGetMemPool`], [`cuDeviceGetDefaultMemPool`], [`cuMemPoolCreate`].
pub fn cuMemPoolDestroy(pool: CUmemoryPool) -> CUresult;
}
unsafe extern "C" {
/// Returns the default memory pool for a given location and allocation type.
///
/// The memory location can be of one of [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`], [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`] or [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`]. The allocation type can be one of [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_PINNED`] or [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_MANAGED`]. When the allocation type is [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_MANAGED`], the location type can also be [CU_MEM_LOCATION_TYPE_NONE](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/types.html#group__CUDA__TYPES_1gg75cfd5b9fa5c1c6ee2be2547bfbe882ecfc8f2ab14e813f7afe8019052526fa4) to indicate no preferred location for the managed memory pool. In all other cases, the call returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMemAllocAsync`], [`cuMemPoolTrimTo`], [`cuMemPoolGetAttribute`], [`cuMemPoolSetAttribute`], [`cuMemPoolSetAccess`], [`cuMemGetMemPool`], [`cuMemPoolCreate`].
pub fn cuMemGetDefaultMemPool(
pool_out: *mut CUmemoryPool,
location: *mut CUmemLocation,
type_: CUmemAllocationType,
) -> CUresult;
}
unsafe extern "C" {
/// Gets the current memory pool for a memory location and of a particular allocation type.
///
/// The memory location can be of one of [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`], [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`] or [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`]. The allocation type can be one of [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_PINNED`] or [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_MANAGED`]. When the allocation type is [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_MANAGED`], the location type can also be [CU_MEM_LOCATION_TYPE_NONE](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/types.html#group__CUDA__TYPES_1gg75cfd5b9fa5c1c6ee2be2547bfbe882ecfc8f2ab14e813f7afe8019052526fa4) to indicate no preferred location for the managed memory pool. In all other cases, the call returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]
///
/// Returns the last pool provided to [`cuMemSetMemPool`] or [`cuDeviceSetMemPool`] for this location and allocation type or the location's default memory pool if [`cuMemSetMemPool`] or [`cuDeviceSetMemPool`] for that allocType and location has never been called. By default the current mempool of a location is the default mempool
/// for a device. Otherwise the returned pool must have been set with [`cuDeviceSetMemPool`].
///
/// **See also:**
///
/// [`cuDeviceGetDefaultMemPool`], [`cuMemPoolCreate`], [`cuDeviceSetMemPool`], [`cuMemSetMemPool`].
pub fn cuMemGetMemPool(
pool: *mut CUmemoryPool,
location: *mut CUmemLocation,
type_: CUmemAllocationType,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the current memory pool for a memory location and allocation type.
///
/// The memory location can be of one of [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`], [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`] or [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`]. The allocation type can be one of [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_PINNED`] or [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_MANAGED`]. When the allocation type is [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_MANAGED`], the location type can also be [CU_MEM_LOCATION_TYPE_NONE](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/types.html#group__CUDA__TYPES_1gg75cfd5b9fa5c1c6ee2be2547bfbe882ecfc8f2ab14e813f7afe8019052526fa4) to indicate no preferred location for the managed memory pool. In all other cases, the call returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// When a memory pool is set as the current memory pool, the location parameter should be the same as the location of the pool.
/// The location and allocation type specified must match those of the pool otherwise [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned. By default, a memory location's current memory pool is its default memory pool that can be obtained via [`cuMemGetDefaultMemPool`]. If the location type is [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`] and the allocation type is [`CUmemAllocationType_enum::CU_MEM_ALLOCATION_TYPE_PINNED`], then this API is the equivalent of calling [`cuDeviceSetMemPool`] with the location id as the device. For further details on the implications, please refer to the documentation for [`cuDeviceSetMemPool`].
///
/// Note:
///
/// Use [`cuMemAllocFromPoolAsync`] to specify asynchronous allocations from a device different than the one the stream runs on.
///
/// **See also:**
///
/// [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemGetMemPool`], [`cuMemPoolCreate`], [`cuMemPoolDestroy`], [`cuMemAllocFromPoolAsync`].
pub fn cuMemSetMemPool(
location: *mut CUmemLocation,
type_: CUmemAllocationType,
pool: CUmemoryPool,
) -> CUresult;
}
unsafe extern "C" {
/// Allocates memory from a specified pool with stream ordered semantics.
///
/// Inserts an allocation operation into hStream. A pointer to the allocated memory is returned immediately in \*dptr. The allocation must not be accessed until the allocation
/// operation completes. The allocation comes from the specified memory pool.
///
/// Note:
///
/// * The specified memory pool may be from a device different than that of the specified hStream.
///
/// * Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize,
/// and CUDA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream
/// runs.
///
/// Note:
///
/// During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned
/// by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters.
///
/// **See also:**
///
/// [`cuMemAllocAsync`], [`cuMemFreeAsync`], [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`], [`cuMemPoolSetAccess`], [`cuMemPoolSetAttribute`].
///
/// # Parameters
///
/// - `dptr`: Returned device pointer.
/// - `bytesize`: Number of bytes to allocate.
/// - `pool`: The pool to allocate from.
/// - `hStream`: The stream establishing the stream ordering semantic.
pub fn cuMemAllocFromPoolAsync(
dptr: *mut CUdeviceptr,
bytesize: size_t,
pool: CUmemoryPool,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Exports a memory pool to the requested handle type.
///
/// Given an IPC capable mempool, create an OS handle to share the pool with another process. A recipient process can convert
/// the shareable handle into a mempool with [`cuMemPoolImportFromShareableHandle`]. Individual pointers can then be shared with the [`cuMemPoolExportPointer`] and [`cuMemPoolImportPointer`] APIs. The implementation of what the shareable handle is and how it can be transferred is defined by the requested handle
/// type.
///
/// Note:
///
/// : To create an IPC capable mempool, create a mempool with a CUmemAllocationHandleType other than [`CUmemAllocationHandleType::CU_MEM_HANDLE_TYPE_NONE`].
///
/// **See also:**
///
/// [`cuMemPoolImportFromShareableHandle`], [`cuMemPoolExportPointer`], [`cuMemPoolImportPointer`], [`cuMemAllocAsync`], [`cuMemFreeAsync`], [`cuDeviceGetDefaultMemPool`], [`cuDeviceGetMemPool`], [`cuMemPoolCreate`], [`cuMemPoolSetAccess`], [`cuMemPoolSetAttribute`].
///
/// # Parameters
///
/// - `handle_out`: Returned OS handle.
/// - `pool`: pool to export.
/// - `handleType`: the type of handle to create.
/// - `flags`: must be 0.
pub fn cuMemPoolExportToShareableHandle(
handle_out: *mut ::core::ffi::c_void,
pool: CUmemoryPool,
handleType: CUmemAllocationHandleType,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// imports a memory pool from a shared handle.
///
/// Specific allocations can be imported from the imported pool with cuMemPoolImportPointer.
///
/// If handleType is [`CUmemAllocationHandleType_enum::CU_MEM_HANDLE_TYPE_FABRIC`] and the importer process has not been granted access to the same IMEX channel as the exporter process, this API will error
/// as [`cudaError_enum::CUDA_ERROR_NOT_PERMITTED`].
///
/// Note:
///
/// Imported memory pools do not support creating new allocations. As such imported memory pools may not be used in cuDeviceSetMemPool
/// or [`cuMemAllocFromPoolAsync`] calls.
///
/// **See also:**
///
/// [`cuMemPoolExportToShareableHandle`], [`cuMemPoolExportPointer`], [`cuMemPoolImportPointer`].
///
/// # Parameters
///
/// - `pool_out`: Returned memory pool.
/// - `handle`: OS handle of the pool to open.
/// - `handleType`: The type of handle being imported.
/// - `flags`: must be 0.
pub fn cuMemPoolImportFromShareableHandle(
pool_out: *mut CUmemoryPool,
handle: *mut ::core::ffi::c_void,
handleType: CUmemAllocationHandleType,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Export data to share a memory pool allocation between processes.
///
/// Constructs shareData_out for sharing a specific allocation from an already shared memory pool. The recipient process can import the allocation with
/// the [`cuMemPoolImportPointer`] api. The data is not a handle and may be shared through any IPC mechanism.
///
/// **See also:**
///
/// [`cuMemPoolExportToShareableHandle`], [`cuMemPoolImportFromShareableHandle`], [`cuMemPoolImportPointer`].
///
/// # Parameters
///
/// - `shareData_out`: Returned export data.
/// - `ptr`: pointer to memory being exported.
pub fn cuMemPoolExportPointer(
shareData_out: *mut CUmemPoolPtrExportData,
ptr: CUdeviceptr,
) -> CUresult;
}
unsafe extern "C" {
/// Import a memory pool allocation from another process.
///
/// Returns in ptr_out a pointer to the imported memory. The imported memory must not be accessed before the allocation operation completes in the
/// exporting process. The imported memory must be freed from all importing processes before being freed in the exporting process.
/// The pointer may be freed with cuMemFree or cuMemFreeAsync. If cuMemFreeAsync is used, the free must be completed on the importing
/// process before the free operation on the exporting process.
///
/// Note:
///
/// The cuMemFreeAsync api may be used in the exporting process before the cuMemFreeAsync operation completes in its stream as
/// long as the cuMemFreeAsync in the exporting process specifies a stream with a stream dependency on the importing process's
/// cuMemFreeAsync.
///
/// **See also:**
///
/// [`cuMemPoolExportToShareableHandle`], [`cuMemPoolImportFromShareableHandle`], [`cuMemPoolExportPointer`].
///
/// # Parameters
///
/// - `ptr_out`: pointer to imported memory.
/// - `pool`: pool from which to import.
/// - `shareData`: data specifying the memory to import.
pub fn cuMemPoolImportPointer(
ptr_out: *mut CUdeviceptr,
pool: CUmemoryPool,
shareData: *mut CUmemPoolPtrExportData,
) -> CUresult;
}
unsafe extern "C" {
/// Create a generic allocation handle representing a multicast object described by the given properties.
///
/// This creates a multicast object as described by prop. The number of participating devices is specified by [CUmulticastObjectProp::numDevices](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmulticastObjectProp__v1.html#structCUmulticastObjectProp__v1_1e5d44c9262847a6c74e4ae37acdc7478). Devices can be added to the multicast object via [`cuMulticastAddDevice`]. All participating devices must be added to the multicast object before memory can be bound to it. Memory is bound to the
/// multicast object via [`cuMulticastBindMem`], [`cuMulticastBindMem_v2`], [`cuMulticastBindAddr`], or [`cuMulticastBindAddr_v2`]. and can be unbound via [`cuMulticastUnbind`]. The total amount of memory that can be bound per device is specified by :[CUmulticastObjectProp::size](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmulticastObjectProp__v1.html#structCUmulticastObjectProp__v1_1a45dfd715e2e442fcc7e43f5ce2f8a46). This size must be a multiple of the value returned by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_MINIMUM`]. For best performance however, the size should be aligned to the value returned by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_RECOMMENDED`].
///
/// After all participating devices have been added, multicast objects can also be mapped to a device's virtual address space
/// using the virtual memory management APIs (see [`cuMemMap`] and [`cuMemSetAccess`]). Multicast objects can also be shared with other processes by requesting a shareable handle via [`cuMemExportToShareableHandle`]. Note that the desired types of shareable handles must be specified in the bitmask [CUmulticastObjectProp::handleTypes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmulticastObjectProp__v1.html#structCUmulticastObjectProp__v1_1705cc17eda91d960e96982f2fda52d55). Multicast objects can be released using the virtual memory management API [`cuMemRelease`].
///
/// **See also:**
///
/// [`cuMulticastAddDevice`], [`cuMulticastBindMem`], [`cuMulticastBindAddr`], [`cuMulticastUnbind`]
///
/// [`cuMemCreate`], [`cuMemRelease`], [`cuMemExportToShareableHandle`], [`cuMemImportFromShareableHandle`]
///
/// [`cuMulticastBindAddr_v2`], [`cuMulticastBindMem_v2`].
///
/// # Parameters
///
/// - `mcHandle`: Value of handle returned.
/// - `prop`: Properties of the multicast object to create.
pub fn cuMulticastCreate(
mcHandle: *mut CUmemGenericAllocationHandle,
prop: *const CUmulticastObjectProp,
) -> CUresult;
}
unsafe extern "C" {
/// Associate a device to a multicast object.
///
/// Associates a device to a multicast object. The added device will be a part of the multicast team of size specified by [CUmulticastObjectProp::numDevices](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmulticastObjectProp__v1.html#structCUmulticastObjectProp__v1_1e5d44c9262847a6c74e4ae37acdc7478) during [`cuMulticastCreate`]. The association of the device to the multicast object is permanent during the life time of the multicast object. All devices
/// must be added to the multicast team before any memory can be bound to any device in the team. Any calls to [`cuMulticastBindMem`], [`cuMulticastBindMem_v2`], [`cuMulticastBindAddr`], or [`cuMulticastBindAddr_v2`] will block until all devices have been added. Similarly all devices must be added to the multicast team before a virtual
/// address range can be mapped to the multicast object. A call to [`cuMemMap`] will block until all devices have been added.
///
/// **See also:**
///
/// [`cuMulticastCreate`], [`cuMulticastBindMem`], [`cuMulticastBindAddr`].
///
/// # Parameters
///
/// - `mcHandle`: Handle representing a multicast object.
/// - `dev`: Device that will be associated to the multicast object.
pub fn cuMulticastAddDevice(
mcHandle: CUmemGenericAllocationHandle,
dev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Bind a memory allocation represented by a handle to a multicast object.
///
/// Binds a memory allocation specified by memHandle and created via [`cuMemCreate`] to a multicast object represented by mcHandle and created via [`cuMulticastCreate`]. The intended size of the bind, the offset in the multicast range mcOffset as well as the offset in the memory memOffset must be a multiple of the value returned by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_MINIMUM`]. For best performance however, size, mcOffset and memOffset should be aligned to the granularity of the memory allocation(see ::cuMemGetAllocationGranularity) or to the value returned
/// by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_RECOMMENDED`].
///
/// The size + memOffset cannot be larger than the size of the allocated memory. Similarly the size + mcOffset cannot be larger than the size of the multicast object.
///
/// The memory allocation must have beeen created on one of the devices that was added to the multicast team via [`cuMulticastAddDevice`]. Externally shareable as well as imported multicast objects can be bound only to externally shareable memory. Note that this
/// call will return [`CUresult::CUDA_ERROR_OUT_OF_MEMORY`] if there are insufficient resources required to perform the bind. This call may
/// also return [`CUresult::CUDA_ERROR_SYSTEM_NOT_READY`] if the necessary system software is not initialized or running.
///
/// This call may return [`CUresult::CUDA_ERROR_ILLEGAL_STATE`] if the system configuration is in an illegal state. In such cases, to continue
/// using multicast, verify that the system configuration is in a valid state and all required driver daemons are running properly.
///
/// **See also:**
///
/// [`cuMulticastCreate`], [`cuMulticastAddDevice`], [`cuMemCreate`]
///
/// [`cuMulticastBindMem_v2`].
///
/// # Parameters
///
/// - `mcHandle`: Handle representing a multicast object.
/// - `mcOffset`: Offset into the multicast object for attachment.
/// - `memHandle`: Handle representing a memory allocation.
/// - `memOffset`: Offset into the memory for attachment.
/// - `size`: Size of the memory that will be bound to the multicast object.
/// - `flags`: Flags for future use, must be zero for now.
pub fn cuMulticastBindMem(
mcHandle: CUmemGenericAllocationHandle,
mcOffset: size_t,
memHandle: CUmemGenericAllocationHandle,
memOffset: size_t,
size: size_t,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Bind a memory allocation represented by a handle to a multicast object.
///
/// Binds a memory allocation specified by memHandle and created via [`cuMemCreate`] to a multicast object represented by mcHandle and created via [`cuMulticastCreate`]. The binding will be applicable for the device dev. The intended size of the bind, the offset in the multicast range mcOffset as well as the offset in the memory memOffset must be a multiple of the value returned by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_MINIMUM`]. For best performance however, size, mcOffset and memOffset should be aligned to the granularity of the memory allocation(see ::cuMemGetAllocationGranularity) or to the value returned
/// by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_RECOMMENDED`].
///
/// The size + memOffset cannot be larger than the size of the allocated memory. Similarly the size + mcOffset cannot be larger than the size of the multicast object.
///
/// The memory allocation must have beeen created on one of the devices that was added to the multicast team via [`cuMulticastAddDevice`]. For device memory, i.e., type [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`], the memory allocation must have been created on the device specified by dev. For host NUMA memory, i.e., type [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`], the memory allocation must have been created on the CPU NUMA node closest to dev. That is, the value returned when querying [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_HOST_NUMA_ID`] for dev, must be the CPU NUMA node where the memory was allocated. In both cases, the device named by dev must have been added to the multicast team via [`cuMulticastAddDevice`]. Externally shareable as well as imported multicast objects can be bound only to externally shareable memory. Note that this
/// call will return [`CUresult::CUDA_ERROR_OUT_OF_MEMORY`] if there are insufficient resources required to perform the bind. This call may
/// also return [`CUresult::CUDA_ERROR_SYSTEM_NOT_READY`] if the necessary system software is not initialized or running.
///
/// This call may return [`CUresult::CUDA_ERROR_ILLEGAL_STATE`] if the system configuration is in an illegal state. In such cases, to continue
/// using multicast, verify that the system configuration is in a valid state and all required driver daemons are running properly.
///
/// **See also:**
///
/// [`cuMulticastCreate`], [`cuMulticastAddDevice`], [`cuMemCreate`].
///
/// # Parameters
///
/// - `mcHandle`: Handle representing a multicast object.
/// - `dev`: The device that for which the multicast memory binding will be applicable.
/// - `mcOffset`: Offset into the multicast object for attachment.
/// - `memHandle`: Handle representing a memory allocation.
/// - `memOffset`: Offset into the memory for attachment.
/// - `size`: Size of the memory that will be bound to the multicast object.
/// - `flags`: Flags for future use, must be zero for now.
pub fn cuMulticastBindMem_v2(
mcHandle: CUmemGenericAllocationHandle,
dev: CUdevice,
mcOffset: size_t,
memHandle: CUmemGenericAllocationHandle,
memOffset: size_t,
size: size_t,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Bind a memory allocation represented by a virtual address to a multicast object.
///
/// Binds a memory allocation specified by its mapped address memptr to a multicast object represented by mcHandle. The memory must have been allocated via [`cuMemCreate`] or [cudaMallocAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb). The intended size of the bind, the offset in the multicast range mcOffset and memptr must be a multiple of the value returned by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_MINIMUM`]. For best performance however, size, mcOffset and memptr should be aligned to the value returned by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_RECOMMENDED`].
///
/// The size cannot be larger than the size of the allocated memory. Similarly the size + mcOffset cannot be larger than the total size of the multicast object.
///
/// The memory allocation must have beeen created on one of the devices that was added to the multicast team via [`cuMulticastAddDevice`]. Externally shareable as well as imported multicast objects can be bound only to externally shareable memory. Note that this
/// call will return [`CUresult::CUDA_ERROR_OUT_OF_MEMORY`] if there are insufficient resources required to perform the bind. This call may
/// also return [`CUresult::CUDA_ERROR_SYSTEM_NOT_READY`] if the necessary system software is not initialized or running.
///
/// This call may return [`CUresult::CUDA_ERROR_ILLEGAL_STATE`] if the system configuration is in an illegal state. In such cases, to continue
/// using multicast, verify that the system configuration is in a valid state and all required driver daemons are running properly.
///
/// **See also:**
///
/// [`cuMulticastCreate`], [`cuMulticastAddDevice`], [`cuMemCreate`]
///
/// [`cuMulticastBindAddr_v2`].
///
/// # Parameters
///
/// - `mcHandle`: Handle representing a multicast object.
/// - `mcOffset`: Offset into multicast va range for attachment.
/// - `memptr`: Virtual address of the memory allocation.
/// - `size`: Size of memory that will be bound to the multicast object.
/// - `flags`: Flags for future use, must be zero now.
pub fn cuMulticastBindAddr(
mcHandle: CUmemGenericAllocationHandle,
mcOffset: size_t,
memptr: CUdeviceptr,
size: size_t,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Bind a memory allocation represented by a virtual address to a multicast object.
///
/// Binds a memory allocation specified by its mapped address memptr to a multicast object represented by mcHandle. The binding will be applicable for the device dev. The memory must have been allocated via [`cuMemCreate`] or [cudaMallocAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb). The intended size of the bind, the offset in the multicast range mcOffset and memptr must be a multiple of the value returned by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_MINIMUM`]. For best performance however, size, mcOffset and memptr should be aligned to the value returned by [`cuMulticastGetGranularity`] with the flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_RECOMMENDED`].
///
/// The size cannot be larger than the size of the allocated memory. Similarly the size + mcOffset cannot be larger than the total size of the multicast object.
///
/// For device memory, i.e., type [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`], the memory allocation must have been created on the device specified by dev. For host NUMA memory, i.e., type [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`], the memory allocation must have been created on the CPU NUMA node closest to dev. That is, the value returned when querying [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_HOST_NUMA_ID`] for dev, must be the CPU NUMA node where the memory was allocated. In both cases, the device named by dev must have been added to the multicast team via [`cuMulticastAddDevice`]. Externally shareable as well as imported multicast objects can be bound only to externally shareable memory. Note that this
/// call will return [`CUresult::CUDA_ERROR_OUT_OF_MEMORY`] if there are insufficient resources required to perform the bind. This call may
/// also return [`CUresult::CUDA_ERROR_SYSTEM_NOT_READY`] if the necessary system software is not initialized or running.
///
/// This call may return [`CUresult::CUDA_ERROR_ILLEGAL_STATE`] if the system configuration is in an illegal state. In such cases, to continue
/// using multicast, verify that the system configuration is in a valid state and all required driver daemons are running properly.
///
/// **See also:**
///
/// [`cuMulticastCreate`], [`cuMulticastAddDevice`], [`cuMemCreate`].
///
/// # Parameters
///
/// - `mcHandle`: Handle representing a multicast object.
/// - `dev`: The device that for which the multicast memory binding will be applicable.
/// - `mcOffset`: Offset into multicast va range for attachment.
/// - `memptr`: Virtual address of the memory allocation.
/// - `size`: Size of memory that will be bound to the multicast object.
/// - `flags`: Flags for future use, must be zero now.
pub fn cuMulticastBindAddr_v2(
mcHandle: CUmemGenericAllocationHandle,
dev: CUdevice,
mcOffset: size_t,
memptr: CUdeviceptr,
size: size_t,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Unbind any memory allocations bound to a multicast object at a given offset and upto a given size.
///
/// Unbinds any memory allocations hosted on dev and bound to a multicast object at mcOffset and upto a given size. The intended size of the unbind and the offset in the multicast range ( mcOffset ) must be a multiple of the value returned by [`cuMulticastGetGranularity`] flag [`CUmulticastGranularity_flags_enum::CU_MULTICAST_GRANULARITY_MINIMUM`]. The size + mcOffset cannot be larger than the total size of the multicast object.
///
/// Note:
///
/// Warning: The mcOffset and the size must match the corresponding values specified during the bind call. Any other values may result in undefined behavior.
///
/// **See also:**
///
/// [`cuMulticastBindMem`], [`cuMulticastBindAddr`]
///
/// [`cuMulticastBindMem_v2`], [`cuMulticastBindAddr_v2`].
///
/// # Parameters
///
/// - `mcHandle`: Handle representing a multicast object.
/// - `dev`: Device that hosts the memory allocation.
/// - `mcOffset`: Offset into the multicast object.
/// - `size`: Desired size to unbind.
pub fn cuMulticastUnbind(
mcHandle: CUmemGenericAllocationHandle,
dev: CUdevice,
mcOffset: size_t,
size: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Calculates either the minimal or recommended granularity for multicast object.
///
/// Calculates either the minimal or recommended granularity for a given set of multicast object properties and returns it in
/// granularity. This granularity can be used as a multiple for size, bind offsets and address mappings of the multicast object.
///
/// **See also:**
///
/// [`cuMulticastCreate`], [`cuMulticastBindMem`], [`cuMulticastBindAddr`], [`cuMulticastUnbind`]
///
/// [`cuMulticastBindMem_v2`], [`cuMulticastBindAddr_v2`].
///
/// # Parameters
///
/// - `granularity`: Returned granularity.
/// - `prop`: Properties of the multicast object.
/// - `option`: Determines which granularity to return.
pub fn cuMulticastGetGranularity(
granularity: *mut size_t,
prop: *const CUmulticastObjectProp,
option: CUmulticastGranularity_flags,
) -> CUresult;
}
unsafe extern "C" {
/// Returns information about a pointer.
///
/// The supported attributes are:
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_CONTEXT`]:
///
/// Returns in \*data the [`CUcontext`] in which ptr was allocated or registered. The type of data must be [`CUcontext`] \*.
///
/// If ptr was not allocated by, mapped by, or registered with a [`CUcontext`] which uses unified virtual addressing then [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MEMORY_TYPE`]:
///
/// Returns in \*data the physical memory type of the memory that ptr addresses as a `CUmemorytype` enumerated value. The type of data must be unsigned int.
///
/// If ptr addresses device memory then \*data is set to [`CUmemorytype_enum::CU_MEMORYTYPE_DEVICE`]. The particular [`CUdevice`] on which the memory resides is the [`CUdevice`] of the [`CUcontext`] returned by the [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_CONTEXT`] attribute of ptr.
///
/// If ptr addresses host memory then \*data is set to [`CUmemorytype_enum::CU_MEMORYTYPE_HOST`].
///
/// If ptr was not allocated by, mapped by, or registered with a [`CUcontext`] which uses unified virtual addressing then [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// If the current [`CUcontext`] does not support unified virtual addressing then [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`] is returned.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_DEVICE_POINTER`]:
///
/// Returns in \*data the device pointer value through which ptr may be accessed by kernels running in the current [`CUcontext`]. The type of data must be CUdeviceptr \*.
///
/// If there exists no device pointer value through which kernels running in the current [`CUcontext`] may access ptr then [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// If there is no current [`CUcontext`] then [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`] is returned.
///
/// Except in the exceptional disjoint addressing cases discussed below, the value returned in \*data will equal the input value ptr.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_HOST_POINTER`]:
///
/// Returns in \*data the host pointer value through which ptr may be accessed by by the host program. The type of data must be void \*\*. If there exists no host pointer value through which the host program may directly access ptr then [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Except in the exceptional disjoint addressing cases discussed below, the value returned in \*data will equal the input value ptr.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_P2P_TOKENS`]:
///
/// Returns in \*data two tokens for use with the nv-p2p.h Linux kernel interface. data must be a struct of type CUDA_POINTER_ATTRIBUTE_P2P_TOKENS.
///
/// ptr must be a pointer to memory obtained from :[`cuMemAlloc_v2`]. Note that p2pToken and vaSpaceToken are only valid for the lifetime of the source allocation. A subsequent allocation at
/// the same address may return completely different tokens. Querying this attribute has a side effect of setting the attribute
/// [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_SYNC_MEMOPS`] for the region of memory that ptr points to.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_SYNC_MEMOPS`]:
///
/// A boolean attribute which when set, ensures that synchronous memory operations initiated on the region of memory that ptr points to will always synchronize. See further documentation in the section titled "API synchronization behavior" to learn
/// more about cases when synchronous memory operations can exhibit asynchronous behavior.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_BUFFER_ID`]:
///
/// Returns in \*data a buffer ID which is guaranteed to be unique within the process. data must point to an unsigned long long.
///
/// ptr must be a pointer to memory obtained from a CUDA memory allocation API. Every memory allocation from any of the CUDA memory
/// allocation APIs will have a unique ID over a process lifetime. Subsequent allocations do not reuse IDs from previous freed
/// allocations. IDs are only unique within a single process.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_MANAGED`]:
///
/// Returns in \*data a boolean that indicates whether the pointer points to managed memory or not.
///
/// If ptr is not a valid CUDA pointer then [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL`]:
///
/// Returns in \*data an integer representing a device ordinal of a device against which the memory was allocated or registered.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE`]:
///
/// Returns in \*data a boolean that indicates if this pointer maps to an allocation that is suitable for [cudaIpcGetMemHandle](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g8a37f7dfafaca652391d0758b3667539).
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_RANGE_START_ADDR`]:
///
/// Returns in \*data the starting address for the allocation referenced by the device pointer ptr. Note that this is not necessarily the address of the mapped region, but the address of the mappable address range ptr references (e.g. from [`cuMemAddressReserve`]).
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_RANGE_SIZE`]:
///
/// Returns in \*data the size for the allocation referenced by the device pointer ptr. Note that this is not necessarily the size of the mapped region, but the size of the mappable address range ptr references (e.g. from [`cuMemAddressReserve`]). To retrieve the size of the mapped region, see [`cuMemGetAddressRange_v2`]
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MAPPED`]:
///
/// Returns in \*data a boolean that indicates if this pointer is in a valid address range that is mapped to a backing allocation.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES`]:
///
/// Returns a bitmask of the allowed handle types for an allocation that may be passed to [`cuMemExportToShareableHandle`].
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MEMPOOL_HANDLE`]:
///
/// Returns in \*data the handle to the mempool that the allocation was obtained from.
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE`]:
///
/// Returns in \*data a boolean that indicates whether the pointer points to memory that is capable to be used for hardware accelerated decompression.
///
/// Note that for most allocations in the unified virtual address space the host and device pointer for accessing the allocation
/// will be the same. The exceptions to this are
///
/// * user memory registered using [`cuMemHostRegister_v2`]
/// * host memory allocated using [`cuMemHostAlloc`] with the [`CU_MEMHOSTALLOC_WRITECOMBINED`] flag For these types of allocation there will exist separate, disjoint host and device addresses for accessing the allocation.
/// In particular
/// * The host address will correspond to an invalid unmapped device address (which will result in an exception if accessed from
/// the device)
/// * The device address will correspond to an invalid unmapped host address (which will result in an exception if accessed from
/// the host). For these types of allocations, querying [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_HOST_POINTER`] and [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_DEVICE_POINTER`] may be used to retrieve the host and device addresses from either address.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuPointerSetAttribute`], [`cuMemAlloc_v2`], [`cuMemFree_v2`], [`cuMemAllocHost_v2`], [`cuMemFreeHost`], [`cuMemHostAlloc`], [`cuMemHostRegister_v2`], [`cuMemHostUnregister`], [cudaPointerGetAttributes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__UNIFIED.html#group__CUDART__UNIFIED_1gd89830e17d399c064a2f3c3fa8bb4390).
///
/// # Parameters
///
/// - `data`: Returned pointer attribute value.
/// - `attribute`: Pointer attribute to query.
/// - `ptr`: Pointer.
pub fn cuPointerGetAttribute(
data: *mut ::core::ffi::c_void,
attribute: CUpointer_attribute,
ptr: CUdeviceptr,
) -> CUresult;
}
unsafe extern "C" {
/// Prefetches memory to the specified destination location.
///
/// Prefetches memory to the specified destination location. devPtr is the base device pointer of the memory to be prefetched and location specifies the destination location. count specifies the number of bytes to copy. hStream is the stream in which the operation is enqueued. The memory range must refer to managed memory allocated via [`cuMemAllocManaged`], via cuMemAllocFromPool from a managed memory pool or declared via __managed__ variables.
///
/// Specifying [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`] for [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) will prefetch memory to GPU specified by device ordinal CUmemLocation::id which must have non-zero value for the device attribute
/// [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. Additionally, hStream must be associated with a device that has a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. Specifying [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`] as [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) will prefetch data to host memory. Applications can request prefetching memory to a specific host NUMA node by specifying
/// [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`] for [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) and a valid host NUMA node id in CUmemLocation::id Users can also request prefetching memory to the host NUMA node closest
/// to the current thread's CPU by specifying [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT`] for [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b). Note when [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) is etiher [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`] OR [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT`], CUmemLocation::id will be ignored.
///
/// The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU
/// page size before the prefetch operation is enqueued in the stream.
///
/// If no physical memory has been allocated for this region, then this memory region will be populated and mapped on the destination
/// device. If there's insufficient memory to prefetch the desired region, the Unified Memory driver may evict pages from other
/// [`cuMemAllocManaged`] allocations to host memory in order to make room. Device memory allocated using [`cuMemAlloc_v2`] or [`cuArrayCreate_v2`] will not be evicted.
///
/// By default, any mappings to the previous location of the migrated pages are removed and mappings for the new location are
/// only setup on the destination location. The exact behavior however also depends on the settings applied to this memory range
/// via [`cuMemAdvise_v2`] as described below:
///
/// If [`CUmem_advise_enum::CU_MEM_ADVISE_SET_READ_MOSTLY`] was set on any subset of this memory range, then that subset will create a read-only copy of the pages on destination location.
/// If however the destination location is a host NUMA node, then any pages of that subset that are already in another host NUMA
/// node will be transferred to the destination.
///
/// If [`CUmem_advise_enum::CU_MEM_ADVISE_SET_PREFERRED_LOCATION`] was called on any subset of this memory range, then the pages will be migrated to location even if location is not the preferred location of any pages in the memory range.
///
/// If [`CUmem_advise_enum::CU_MEM_ADVISE_SET_ACCESSED_BY`] was called on any subset of this memory range, then mappings to those pages from all the appropriate processors are updated
/// to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared.
///
/// Note that this API is not required for functionality and only serves to improve performance by allowing the application to
/// migrate data to a suitable location before it is accessed. Memory accesses to this range are always coherent and are allowed
/// even when the data is actively being migrated.
///
/// Note that this function is asynchronous with respect to the host and all work on other devices.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuMemcpy`], [`cuMemcpyPeer`], [`cuMemcpyAsync`], [`cuMemcpy3DPeerAsync`], [`cuMemAdvise_v2`], [cudaMemPrefetchAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g856fa41c8c0d28655e37b778cb9ffc65).
///
/// # Parameters
///
/// - `devPtr`: Pointer to be prefetched.
/// - `count`: Size in bytes.
/// - `location`: Location to prefetch to.
/// - `flags`: flags for future use, must be zero now.
/// - `hStream`: Stream to enqueue prefetch operation.
pub fn cuMemPrefetchAsync_v2(
devPtr: CUdeviceptr,
count: size_t,
location: CUmemLocation,
flags: ::core::ffi::c_uint,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Advise about the usage of a given memory range.
///
/// Advise the Unified Memory subsystem about the usage pattern for the memory range starting at devPtr with a size of count bytes. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned
/// to CPU page size before the advice is applied. The memory range must refer to managed memory allocated via [`cuMemAllocManaged`] or declared via __managed__ variables. The memory range could also refer to system-allocated pageable memory provided it
/// represents a valid, host-accessible region of memory and all additional constraints imposed by advice as outlined below are also satisfied. Specifying an invalid system-allocated pageable memory range results in an error being
/// returned.
///
/// The advice parameter can take the following values:
///
/// * [`CUmem_advise_enum::CU_MEM_ADVISE_SET_READ_MOSTLY`]: This implies that the data is mostly going to be read from and only occasionally written to. Any read accesses from any
/// processor to this region will create a read-only copy of at least the accessed pages in that processor's memory. Additionally,
/// if [`cuMemPrefetchAsync_v2`] is called on this region, it will create a read-only copy of the data on the destination processor. If the target location
/// for [`cuMemPrefetchAsync_v2`] is a host NUMA node and a read-only copy already exists on another host NUMA node, that copy will be migrated to the targeted
/// host NUMA node. If any processor writes to this region, all copies of the corresponding page will be invalidated except for
/// the one where the write occurred. If the writing processor is the CPU and the preferred location of the page is a host NUMA
/// node, then the page will also be migrated to that host NUMA node. The location argument is ignored for this advice. Note that for a page to be read-duplicated, the accessing processor must either be the
/// CPU or a GPU that has a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. Also, if a context is created on a device that does not have the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] set, then read-duplication will not occur until all such contexts are destroyed. If the memory region refers to valid system-allocated
/// pageable memory, then the accessing device must have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`] for a read-only copy to be created on that device. Note however that if the accessing device also has a non-zero value for
/// the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`], then setting this advice will not create a read-only copy when that device accesses this memory region.
///
/// * [`CUmem_advise_enum::CU_MEM_ADVISE_UNSET_READ_MOSTLY`]: Undoes the effect of [`CUmem_advise_enum::CU_MEM_ADVISE_SET_READ_MOSTLY`] and also prevents the Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated
/// copies of the data will be collapsed into a single copy. The location for the collapsed copy will be the preferred location
/// if the page has a preferred location and one of the read-duplicated copies was resident at that location. Otherwise, the location
/// chosen is arbitrary. Note: The location argument is ignored for this advice.
///
/// * [`CUmem_advise_enum::CU_MEM_ADVISE_SET_PREFERRED_LOCATION`]: This advice sets the preferred location for the data to be the memory belonging to location. When [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) is [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`], CUmemLocation::id is ignored and the preferred location is set to be host memory. To set the preferred location to a specific
/// host NUMA node, applications must set [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) to [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`] and CUmemLocation::id must specify the NUMA ID of the host NUMA node. If [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) is set to [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT`], CUmemLocation::id will be ignored and the host NUMA node closest to the calling thread's CPU will be used as the preferred
/// location. If [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) is a [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`], then CUmemLocation::id must be a valid device ordinal and the device must have a non-zero value for the device attribute
/// [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. Setting the preferred location does not cause data to migrate to that location immediately. Instead, it guides the migration
/// policy when a fault occurs on that memory region. If the data is already in its preferred location and the faulting processor
/// can establish a mapping without requiring the data to be migrated, then data migration will be avoided. On the other hand,
/// if the data is not in its preferred location or if a direct mapping cannot be established, then it will be migrated to the
/// processor accessing it. It is important to note that setting the preferred location does not prevent data prefetching done
/// using [`cuMemPrefetchAsync_v2`]. Having a preferred location can override the page thrash detection and resolution logic in the Unified Memory driver. Normally,
/// if a page is detected to be constantly thrashing between for example host and device memory, the page may eventually be pinned
/// to host memory by the Unified Memory driver. But if the preferred location is set as device memory, then the page will continue
/// to thrash indefinitely. If [`CUmem_advise_enum::CU_MEM_ADVISE_SET_READ_MOSTLY`] is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies
/// of this advice, unless read accesses from location will not result in a read-only copy being created on that procesor as outlined in description for the advice [`CUmem_advise_enum::CU_MEM_ADVISE_SET_READ_MOSTLY`]. If the memory region refers to valid system-allocated pageable memory, and [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) is [`CUmemLocationType::CU_MEM_LOCATION_TYPE_DEVICE`] then CUmemLocation::id must be a valid device that has a non-zero alue for the device attribute
/// [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`].
///
/// * [`CUmem_advise_enum::CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION`]: Undoes the effect of [`CUmem_advise_enum::CU_MEM_ADVISE_SET_PREFERRED_LOCATION`] and changes the preferred location to none. The location argument is ignored for this advice.
///
/// * [`CUmem_advise_enum::CU_MEM_ADVISE_SET_ACCESSED_BY`]: This advice implies that the data will be accessed by processor location. The [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) must be either [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`] with CUmemLocation::id representing a valid device ordinal or [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`] and CUmemLocation::id will be ignored. All other location types are invalid. If CUmemLocation::id is a GPU, then the device
/// attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] must be non-zero. This advice does not cause data migration and has no impact on the location of the data per se. Instead,
/// it causes the data to always be mapped in the specified processor's page tables, as long as the location of the data permits
/// a mapping to be established. If the data gets migrated for any reason, the mappings are updated accordingly. This advice is
/// recommended in scenarios where data locality is not important, but avoiding faults is. Consider for example a system containing
/// multiple GPUs with peer-to-peer access enabled, where the data located on one GPU is occasionally accessed by peer GPUs. In
/// such scenarios, migrating data over to the other GPUs is not as important because the accesses are infrequent and the overhead
/// of migration may be too high. But preventing faults can still help improve performance, and so having a mapping set up in
/// advance is useful. Note that on CPU access of this data, the data may be migrated to host memory because the CPU typically
/// cannot access device memory directly. Any GPU that had the [`CUmem_advise_enum::CU_MEM_ADVISE_SET_ACCESSED_BY`] flag set for this data will now have its mapping updated to point to the page in host memory. If [`CUmem_advise_enum::CU_MEM_ADVISE_SET_READ_MOSTLY`] is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies
/// of this advice. Additionally, if the preferred location of this memory region or any subset of it is also location, then the policies associated with [`CUmem_advise_enum::CU_MEM_ADVISE_SET_PREFERRED_LOCATION`] will override the policies of this advice. If the memory region refers to valid system-allocated pageable memory, and [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) is [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`] then device in CUmemLocation::id must have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`]. Additionally, if CUmemLocation::id has a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`], then this call has no effect.
///
/// * [`CUmem_advise_enum::CU_MEM_ADVISE_UNSET_ACCESSED_BY`]: Undoes the effect of [`CUmem_advise_enum::CU_MEM_ADVISE_SET_ACCESSED_BY`]. Any mappings to the data from location may be removed at any time causing accesses to result in non-fatal page faults. If the memory region refers to valid system-allocated
/// pageable memory, and [CUmemLocation::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUmemLocation__v1.html#structCUmemLocation__v1_1a34fc29f2a55d501f00f912d92152d1b) is [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`] then device in CUmemLocation::id must have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`]. Additionally, if CUmemLocation::id has a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`], then this call has no effect.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuMemcpy`], [`cuMemcpyPeer`], [`cuMemcpyAsync`], [`cuMemcpy3DPeerAsync`], [`cuMemPrefetchAsync_v2`], [cudaMemAdvise](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g5584e2dac446bebc695da3bb1c162607).
///
/// # Parameters
///
/// - `devPtr`: Pointer to memory to set the advice for.
/// - `count`: Size in bytes of the memory range.
/// - `advice`: Advice to be applied for the specified memory range.
/// - `location`: location to apply the advice for.
pub fn cuMemAdvise_v2(
devPtr: CUdeviceptr,
count: size_t,
advice: CUmem_advise,
location: CUmemLocation,
) -> CUresult;
}
unsafe extern "C" {
/// Performs a batch of memory prefetches asynchronously.
///
/// Performs a batch of memory prefetches. The batch as a whole executes in stream order but operations within a batch are not
/// guaranteed to execute in any specific order. All devices in the system must have a non-zero value for the device attribute
/// [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] otherwise the API will return an error.
///
/// The semantics of the individual prefetch operations are as described in [`cuMemPrefetchAsync_v2`].
///
/// Performs memory prefetch on address ranges specified in dptrs and sizes. Both arrays must be of the same length as specified by count. Each memory range specified must refer to managed memory allocated via [`cuMemAllocManaged`] or declared via __managed__ variables or it may also refer to system-allocated memory when all devices have a non-zero value
/// for [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`]. The prefetch location for every operation in the batch is specified in the prefetchLocs array. Each entry in this array can apply to more than one operation. This can be done by specifying in the prefetchLocIdxs array, the index of the first prefetch operation that the corresponding entry in the prefetchLocs array applies to. Both prefetchLocs and prefetchLocIdxs must be of the same length as specified by numPrefetchLocs. For example, if a batch has 10 prefetches listed in dptrs/sizes, the first 4 of which are to be prefetched to one location
/// and the remaining 6 are to be prefetched to another, then numPrefetchLocs will be 2, prefetchLocIdxs will be {0, 4} and prefetchLocs will contain the two locations. Note the first entry in prefetchLocIdxs must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than count. Furthermore, numPrefetchLocs must be lesser than or equal to count.
///
/// # Parameters
///
/// - `dptrs`: Array of pointers to be prefetched.
/// - `sizes`: Array of sizes for memory prefetch operations.
/// - `count`: Size of dptrs and sizes arrays.
/// - `prefetchLocs`: Array of locations to prefetch to.
/// - `prefetchLocIdxs`: Array of indices to specify which operands each entry in the prefetchLocs array applies to. The locations specified in prefetchLocs\[k\] will be applied to copies starting from prefetchLocIdxs\[k\] through
/// prefetchLocIdxs\[k+1\] - 1. Also prefetchLocs\[numPrefetchLocs - 1\] will apply to prefetches starting from prefetchLocIdxs\[numPrefetchLocs
/// - 1\] through count - 1.
/// - `numPrefetchLocs`: Size of prefetchLocs and prefetchLocIdxs arrays.
/// - `flags`: Flags reserved for future use. Must be zero.
/// - `hStream`: The stream to enqueue the operations in. Must not be legacy NULL stream.
pub fn cuMemPrefetchBatchAsync(
dptrs: *mut CUdeviceptr,
sizes: *mut size_t,
count: size_t,
prefetchLocs: *mut CUmemLocation,
prefetchLocIdxs: *mut size_t,
numPrefetchLocs: size_t,
flags: ::core::ffi::c_ulonglong,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Performs a batch of memory discards asynchronously.
///
/// Performs a batch of memory discards. The batch as a whole executes in stream order but operations within a batch are not guaranteed
/// to execute in any specific order. All devices in the system must have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] otherwise the API will return an error.
///
/// Discarding a memory range informs the driver that the contents of that range are no longer useful. Discarding memory ranges
/// allows the driver to optimize certain data migrations and can also help reduce memory pressure. This operation can be undone
/// on any part of the range by either writing to it or prefetching it via [`cuMemPrefetchAsync_v2`] or [`cuMemPrefetchBatchAsync`]. Reading from a discarded range, without a subsequent write or prefetch to that part of the range, will return an indeterminate
/// value. Note that any reads, writes or prefetches to any part of the memory range that occur simultaneously with the discard
/// operation result in undefined behavior.
///
/// Performs memory discard on address ranges specified in dptrs and sizes. Both arrays must be of the same length as specified by count. Each memory range specified must refer to managed memory allocated via [`cuMemAllocManaged`] or declared via __managed__ variables or it may also refer to system-allocated memory when all devices have a non-zero value
/// for [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`].
///
/// # Parameters
///
/// - `dptrs`: Array of pointers to be discarded.
/// - `sizes`: Array of sizes for memory discard operations.
/// - `count`: Size of dptrs and sizes arrays.
/// - `flags`: Flags reserved for future use. Must be zero.
/// - `hStream`: The stream to enqueue the operations in. Must not be legacy NULL stream.
pub fn cuMemDiscardBatchAsync(
dptrs: *mut CUdeviceptr,
sizes: *mut size_t,
count: size_t,
flags: ::core::ffi::c_ulonglong,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Performs a batch of memory discards and prefetches asynchronously.
///
/// Performs a batch of memory discards followed by prefetches. The batch as a whole executes in stream order but operations within
/// a batch are not guaranteed to execute in any specific order. All devices in the system must have a non-zero value for the
/// device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] otherwise the API will return an error.
///
/// Calling [`cuMemDiscardAndPrefetchBatchAsync`] is semantically equivalent to calling [`cuMemDiscardBatchAsync`] followed by [`cuMemPrefetchBatchAsync`], but is more optimal. For more details on what discarding and prefetching imply, please refer to [`cuMemDiscardBatchAsync`] and [`cuMemPrefetchBatchAsync`] respectively. Note that any reads, writes or prefetches to any part of the memory range that occur simultaneously with this
/// combined discard+prefetch operation result in undefined behavior.
///
/// Performs memory discard and prefetch on address ranges specified in dptrs and sizes. Both arrays must be of the same length as specified by count. Each memory range specified must refer to managed memory allocated via [`cuMemAllocManaged`] or declared via __managed__ variables or it may also refer to system-allocated memory when all devices have a non-zero value
/// for [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`]. Every operation in the batch has to be associated with a valid location to prefetch the address range to and specified in
/// the prefetchLocs array. Each entry in this array can apply to more than one operation. This can be done by specifying in the prefetchLocIdxs array, the index of the first operation that the corresponding entry in the prefetchLocs array applies to. Both prefetchLocs and prefetchLocIdxs must be of the same length as specified by numPrefetchLocs. For example, if a batch has 10 operations listed in dptrs/sizes, the first 6 of which are to be prefetched to one location
/// and the remaining 4 are to be prefetched to another, then numPrefetchLocs will be 2, prefetchLocIdxs will be {0, 6} and prefetchLocs will contain the two set of locations. Note the first entry in prefetchLocIdxs must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than count. Furthermore, numPrefetchLocs must be lesser than or equal to count.
///
/// # Parameters
///
/// - `dptrs`: Array of pointers to be discarded.
/// - `sizes`: Array of sizes for memory discard operations.
/// - `count`: Size of dptrs and sizes arrays.
/// - `prefetchLocs`: Array of locations to prefetch to.
/// - `prefetchLocIdxs`: Array of indices to specify which operands each entry in the prefetchLocs array applies to. The locations specified in prefetchLocs\[k\] will be applied to operations starting from prefetchLocIdxs\[k\]
/// through prefetchLocIdxs\[k+1\] - 1. Also prefetchLocs\[numPrefetchLocs - 1\] will apply to copies starting from prefetchLocIdxs\[numPrefetchLocs
/// - 1\] through count - 1.
/// - `numPrefetchLocs`: Size of prefetchLocs and prefetchLocIdxs arrays.
/// - `flags`: Flags reserved for future use. Must be zero.
/// - `hStream`: The stream to enqueue the operations in. Must not be legacy NULL stream.
pub fn cuMemDiscardAndPrefetchBatchAsync(
dptrs: *mut CUdeviceptr,
sizes: *mut size_t,
count: size_t,
prefetchLocs: *mut CUmemLocation,
prefetchLocIdxs: *mut size_t,
numPrefetchLocs: size_t,
flags: ::core::ffi::c_ulonglong,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Query an attribute of a given memory range.
///
/// Query an attribute about the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via [`cuMemAllocManaged`] or declared via __managed__ variables.
///
/// The attribute parameter can take the following values:
///
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY`]: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. The result returned will be 1 if all pages in the given memory range have read-duplication enabled, or 0 otherwise.
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION`]: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. The result returned will be a GPU device id if all pages in the memory range have that GPU as their preferred
/// location, or it will be CU_DEVICE_CPU if all pages in the memory range have the CPU as their preferred location, or it will
/// be CU_DEVICE_INVALID if either all the pages don't have the same preferred location or some of the pages don't have a preferred
/// location at all. Note that the actual location of the pages in the memory range at the time of the query may be different
/// from the preferred location.
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY`]: If this attribute is specified, data will be interpreted as an array of 32-bit integers, and dataSize must be a non-zero multiple of 4. The result returned will be a list of device ids that had [`CUmem_advise_enum::CU_MEM_ADVISE_SET_ACCESSED_BY`] set for that entire memory range. If any device does not have that advice set for the entire memory range, that device will
/// not be included. If data is larger than the number of devices that have that advice set for that memory range, CU_DEVICE_INVALID will be returned
/// in all the extra space provided. For ex., if dataSize is 12 (i.e. data has 3 elements) and only device 0 has the advice set, then the result returned will be { 0, CU_DEVICE_INVALID, CU_DEVICE_INVALID
/// }. If data is smaller than the number of devices that have that advice set, then only as many devices will be returned as can fit in
/// the array. There is no guarantee on which specific devices will be returned, however.
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION`]: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. The result returned will be the last location to which all pages in the memory range were prefetched explicitly
/// via [`cuMemPrefetchAsync_v2`]. This will either be a GPU id or CU_DEVICE_CPU depending on whether the last location for prefetch was a GPU or the CPU respectively.
/// If any page in the memory range was never explicitly prefetched or if all pages were not prefetched to the same location,
/// CU_DEVICE_INVALID will be returned. Note that this simply returns the last location that the application requested to prefetch
/// the memory range to. It gives no indication as to whether the prefetch operation to that location has completed or even begun.
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE`]: If this attribute is specified, data will be interpreted as a `CUmemLocationType`, and dataSize must be sizeof(CUmemLocationType). The `CUmemLocationType` returned will be [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`] if all pages in the memory range have the same GPU as their preferred location, or `CUmemLocationType` will be [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`] if all pages in the memory range have the CPU as their preferred location, or it will be [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`] if all the pages in the memory range have the same host NUMA node ID as their preferred location or it will be [`CUmemLocationType::CU_MEM_LOCATION_TYPE_INVALID`]
/// if either all the pages don't have the same preferred location or some of the pages don't have a preferred location at all.
/// Note that the actual location type of the pages in the memory range at the time of the query may be different from the preferred
/// location type.
/// + [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_ID`]: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. If the [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE`] query for the same address range returns [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`], it will be a valid device ordinal or if it returns [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`], it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored.
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE`]: If this attribute is specified, data will be interpreted as a `CUmemLocationType`, and dataSize must be sizeof(CUmemLocationType). The result returned will be the last location to which all pages in the memory range were
/// prefetched explicitly via [`cuMemPrefetchAsync_v2`]. The `CUmemLocationType` returned will be [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`] if the last prefetch location was a GPU or [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST`] if it was the CPU or [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`] if the last prefetch location was a specific host NUMA node. If any page in the memory range was never explicitly prefetched
/// or if all pages were not prefetched to the same location, `CUmemLocationType` will be [`CUmemLocationType::CU_MEM_LOCATION_TYPE_INVALID`]. Note that this simply returns the last location type that the application requested
/// to prefetch the memory range to. It gives no indication as to whether the prefetch operation to that location has completed
/// or even begun.
/// + [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_ID`]: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. If the [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE`] query for the same address range returns [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_DEVICE`], it will be a valid device ordinal or if it returns [`CUmemLocationType_enum::CU_MEM_LOCATION_TYPE_HOST_NUMA`], it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
///
/// **See also:**
///
/// [`cuMemRangeGetAttributes`], [`cuMemPrefetchAsync_v2`], [`cuMemAdvise_v2`], [cudaMemRangeGetAttribute](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g8048f6ea5ad77917444567656c140c5a).
///
/// # Parameters
///
/// - `data`: A pointers to a memory location where the result of each attribute query will be written to.
/// - `dataSize`: Array containing the size of data.
/// - `attribute`: The attribute to query.
/// - `devPtr`: Start of the range to query.
/// - `count`: Size of the range to query.
pub fn cuMemRangeGetAttribute(
data: *mut ::core::ffi::c_void,
dataSize: size_t,
attribute: CUmem_range_attribute,
devPtr: CUdeviceptr,
count: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Query attributes of a given memory range.
///
/// Query attributes of the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via [`cuMemAllocManaged`] or declared via __managed__ variables. The attributes array will be interpreted to have numAttributes entries. The dataSizes array will also be interpreted to have numAttributes entries. The results of the query will be stored in data.
///
/// The list of supported attributes are given below. Please refer to [`cuMemRangeGetAttribute`] for attribute descriptions and restrictions.
///
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY`]
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION`]
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY`]
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION`]
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE`]
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_ID`]
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE`]
/// * [`CUmem_range_attribute_enum::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_ID`]
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuMemRangeGetAttribute`], [`cuMemAdvise_v2`], [`cuMemPrefetchAsync_v2`], [cudaMemRangeGetAttributes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g1a9199e7709c7817d1c715cfbe174d05).
///
/// # Parameters
///
/// - `data`: A two-dimensional array containing pointers to memory locations where the result of each attribute query will be written
/// ```text
/// to.
/// ```
/// - `dataSizes`: Array containing the sizes of each result.
/// - `attributes`: An array of attributes to query (numAttributes and the number of attributes in this array should match).
/// - `numAttributes`: Number of attributes to query.
/// - `devPtr`: Start of the range to query.
/// - `count`: Size of the range to query.
pub fn cuMemRangeGetAttributes(
data: *mut *mut ::core::ffi::c_void,
dataSizes: *mut size_t,
attributes: *mut CUmem_range_attribute,
numAttributes: size_t,
devPtr: CUdeviceptr,
count: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Set attributes on a previously allocated memory region.
///
/// The supported attributes are:
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_SYNC_MEMOPS`]:
///
/// A boolean attribute that can either be set (1) or unset (0). When set, the region of memory that ptr points to is guaranteed to always synchronize memory operations that are synchronous. If there are some previously initiated
/// synchronous memory operations that are pending when this attribute is set, the function does not return until those memory
/// operations are complete. See further documentation in the section titled "API synchronization behavior" to learn more about
/// cases when synchronous memory operations can exhibit asynchronous behavior. value will be considered as a pointer to an unsigned integer to which this attribute is to be set.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuPointerGetAttribute`], [`cuPointerGetAttributes`], [`cuMemAlloc_v2`], [`cuMemFree_v2`], [`cuMemAllocHost_v2`], [`cuMemFreeHost`], [`cuMemHostAlloc`], [`cuMemHostRegister_v2`], [`cuMemHostUnregister`].
///
/// # Parameters
///
/// - `value`: Pointer to memory containing the value to be set.
/// - `attribute`: Pointer attribute to set.
/// - `ptr`: Pointer to a memory region allocated using CUDA memory allocation APIs.
pub fn cuPointerSetAttribute(
value: *const ::core::ffi::c_void,
attribute: CUpointer_attribute,
ptr: CUdeviceptr,
) -> CUresult;
}
unsafe extern "C" {
/// Returns information about a pointer.
///
/// The supported attributes are (refer to [`cuPointerGetAttribute`] for attribute descriptions and restrictions):
///
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_CONTEXT`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MEMORY_TYPE`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_DEVICE_POINTER`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_HOST_POINTER`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_SYNC_MEMOPS`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_BUFFER_ID`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_MANAGED`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_RANGE_START_ADDR`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_RANGE_SIZE`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MAPPED`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_MEMPOOL_HANDLE`]
/// * [`CUpointer_attribute_enum::CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE`]
///
/// Unlike [`cuPointerGetAttribute`], this function will not return an error when the ptr encountered is not a valid CUDA pointer. Instead, the attributes are assigned default NULL values and [`CUresult::CUDA_SUCCESS`] is returned.
///
/// If ptr was not allocated by, mapped by, or registered with a [`CUcontext`] which uses UVA (Unified Virtual Addressing), [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuPointerGetAttribute`], [`cuPointerSetAttribute`], [cudaPointerGetAttributes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__UNIFIED.html#group__CUDART__UNIFIED_1gd89830e17d399c064a2f3c3fa8bb4390).
///
/// # Parameters
///
/// - `numAttributes`: Number of attributes to query.
/// - `attributes`: An array of attributes to query (numAttributes and the number of attributes in this array should match).
/// - `data`: A two-dimensional array containing pointers to memory locations where the result of each attribute query will be written
/// ```text
/// to.
/// ```
/// - `ptr`: Pointer to query.
pub fn cuPointerGetAttributes(
numAttributes: ::core::ffi::c_uint,
attributes: *mut CUpointer_attribute,
data: *mut *mut ::core::ffi::c_void,
ptr: CUdeviceptr,
) -> CUresult;
}
unsafe extern "C" {
/// Create a stream.
///
/// Creates a stream and returns a handle in phStream. The Flags argument determines behaviors of the stream.
///
/// Valid values for Flags are:
///
/// * [`CUstream_flags_enum::CU_STREAM_DEFAULT`]: Default stream creation flag.
/// * [`CUstream_flags_enum::CU_STREAM_NON_BLOCKING`]: Specifies that work running in the created stream may run concurrently with work in stream 0 (the NULL stream), and that
/// the created stream should perform no implicit synchronization with stream 0.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuStreamCreateWithPriority`], [`cuGreenCtxStreamCreate`], [`cuStreamGetPriority`], [`cuStreamGetFlags`], [`cuStreamGetDevice`], [cudaStreamCreateWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1gb1e32aff9f59119e4d0a9858991c4ad3).
///
/// # Parameters
///
/// - `phStream`: Returned newly created stream.
/// - `Flags`: Parameters for stream creation.
pub fn cuStreamCreate(
phStream: *mut CUstream,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Create a stream with the given priority.
///
/// Creates a stream with the specified priority and returns a handle in phStream. This affects the scheduling priority of work in the stream. Priorities provide a hint to preferentially run work with higher
/// priority when possible, but do not preempt already-running work or provide any other functional guarantee on execution order.
///
/// priority follows a convention where lower numbers represent higher priorities. '0' represents default priority. The range of meaningful
/// numerical priorities can be queried using [`cuCtxGetStreamPriorityRange`]. If the specified priority is outside the numerical range returned by [`cuCtxGetStreamPriorityRange`], it will automatically be clamped to the lowest or the highest number in the range.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Stream priorities are supported only on GPUs with compute capability 3.5 or higher.
/// * In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream
/// priorities have no effect on host-to-device and device-to-host memory operations.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuStreamCreate`], [`cuGreenCtxStreamCreate`], [`cuStreamGetPriority`], [`cuCtxGetStreamPriorityRange`], [`cuStreamGetFlags`], [`cuStreamGetDevice`], [`cuStreamWaitEvent`], [`cuStreamQuery`], [`cuStreamSynchronize`], [`cuStreamAddCallback`], [cudaStreamCreateWithPriority](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1ge2be9e9858849bf62ba4a8b66d1c3540).
///
/// # Parameters
///
/// - `phStream`: Returned newly created stream.
/// - `flags`: Flags for stream creation. See [`cuStreamCreate`] for a list of valid flags.
/// - `priority`: Stream priority. Lower numbers represent higher priorities. See [`cuCtxGetStreamPriorityRange`] for more information about meaningful stream priorities that can be passed.
pub fn cuStreamCreateWithPriority(
phStream: *mut CUstream,
flags: ::core::ffi::c_uint,
priority: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Begins capture to CIG on a stream.
///
/// Begin CIG (CUDA in Graphics) capture on hStream for the graphics API as provided in streamCigCaptureParams. When a stream is in CIG capture mode, all operations pushed into the stream will not be executed, but will instead be captured
/// into a graphics API command list/command buffer. All kernel launches and memory copy/memory set operations on the CIG stream
/// will be recorded. When the command list is executed by the graphics API, all the stream's operations will execute in order
/// along with other graphics API commands in the command list.
///
/// CIG stream capture may not be initiated if stream is CU_STREAM_LEGACY. Capture must be ended on the same stream in which it was initiated, and it may only be initiated if
/// the stream is not already in CIG capture mode.
///
/// The context must be also created in CIG mode previously, otherwise this operation will fail and [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`] will be returned.
///
/// Data from the graphics client can be shared with CUDA via the streamSharedData in streamCigCaptureParams. The format of streamSharedData is dependent on the type of the graphics client. For D3D12, streamSharedData is an ID3D12CommandList object pointer. The command list must be in ready state for recording commands whenever kernels are
/// launched on the stream. The command list provided must belong to the graphics API device that the CIG context was created
/// with, otherwise the behavior will be undefined.
///
/// The stream object may not be destroyed until its associated command list has finished executing on the GPU. The command list/command
/// buffer used for capture may not be submitted for execution before a call to [`cuStreamEndCaptureToCig`] is made on the associated stream.
///
/// Graphics resources to be accessed by work recorded on the CIG stream must use UAV barriers on the command list prior to recording
/// work that accesses them on the stream.
///
/// Resubmission of the same recorded command list is not allowed. Further more, care must be taken for the order of execution
/// of the recorded CUDA work with regards to other CUDA work submitted under the same CIG context. Out-of-order execution can
/// lead to device hangs or exceptions.
///
/// CIG capture mode operates similarly to cuStreamBeginCapture with the [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`] option. There are additional limitations to streams in CIG capture mode. The following functions are not allowed for CIG
/// streams whether directly or indirectly via a recorded graph launch: [`cuLaunchHostFunc`]cuStreamAddCallback [`cuStreamSynchronize`]cuStreamWaitValue32 [`cuStreamWaitValue64_v2`]cuStreamBatchMemOp [`cuStreamBeginCapture_v2`]cuStreamBeginCaptureToGraph [`cuMemAllocAsync`][`cuMemFreeAsync`]
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamEndCaptureToCig`], [`cuStreamBeginCapture_v2`], [`cuStreamWaitEvent`], [`cuStreamQuery`], [`cuStreamSynchronize`], [`cuStreamAddCallback`].
///
/// # Parameters
///
/// - `hStream`: Stream in which to initiate capture to CIG.
/// - `streamCigCaptureParams`: CIG capture parameters.
pub fn cuStreamBeginCaptureToCig(
hStream: CUstream,
streamCigCaptureParams: *mut CUstreamCigCaptureParams,
) -> CUresult;
}
unsafe extern "C" {
/// Ends CIG capture on a stream.
///
/// End CIG capture on hStream. Capture must have been initiated on hStream via a call to [`cuStreamBeginCaptureToCig`]. Once this function is called, hStream will exit CIG capture mode and return to its original state, thus removing all CIG stream restrictions. Also, the command
/// list/command buffer that was associated with hStream in the previous call to [`cuStreamBeginCaptureToCig`] is now allowed to be submitted for execution on the graphics API. However, the stream may not be destroyed until execution
/// of the command list is fully done on the GPU. This requirements extends also to all streams dependent on the CIG stream (e.g.
/// via event waits).
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamBeginCaptureToCig`].
///
/// # Parameters
///
/// - `hStream`: Stream to end CIG capture.
pub fn cuStreamEndCaptureToCig(hStream: CUstream) -> CUresult;
}
unsafe extern "C" {
/// Query the priority of a given stream.
///
/// Query the priority of a stream created using [`cuStreamCreate`], [`cuStreamCreateWithPriority`] or [`cuGreenCtxStreamCreate`] and return the priority in priority. Note that if the stream was created with a priority outside the numerical range returned by [`cuCtxGetStreamPriorityRange`], this function returns the clamped priority. See [`cuStreamCreateWithPriority`] for details about priority clamping.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuStreamCreate`], [`cuStreamCreateWithPriority`], [`cuGreenCtxStreamCreate`], [`cuCtxGetStreamPriorityRange`], [`cuStreamGetFlags`], [`cuStreamGetDevice`], [cudaStreamGetPriority](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g192bb727d15c4407c119747de7d198a6).
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `priority`: Pointer to a signed integer in which the stream's priority is returned.
pub fn cuStreamGetPriority(
hStream: CUstream,
priority: *mut ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the device handle of the stream.
///
/// Returns in \*device the device handle of the stream
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuStreamCreate`], [`cuGreenCtxStreamCreate`], [`cuStreamGetFlags`].
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `device`: Returns the device to which a stream belongs.
pub fn cuStreamGetDevice(hStream: CUstream, device: *mut CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Query the flags of a given stream.
///
/// Query the flags of a stream created using [`cuStreamCreate`], [`cuStreamCreateWithPriority`] or [`cuGreenCtxStreamCreate`] and return the flags in flags.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuStreamCreate`], [`cuGreenCtxStreamCreate`], [`cuStreamGetPriority`], [cudaStreamGetFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1ga7f311f88126d751b9a7d3302ad6d0f8), [`cuStreamGetDevice`].
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `flags`: Pointer to an unsigned integer in which the stream's flags are returned The value returned in flags is a logical 'OR' of all flags that were used while creating this stream. See [`cuStreamCreate`] for the list of valid flags.
pub fn cuStreamGetFlags(
hStream: CUstream,
flags: *mut ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the unique Id associated with the stream handle supplied.
///
/// Returns in streamId the unique Id which is associated with the given stream handle. The Id is unique for the life of the program.
///
/// The stream handle hStream can refer to any of the following:
///
/// * a stream created via any of the CUDA driver APIs such as [`cuStreamCreate`] and [`cuStreamCreateWithPriority`], or their runtime API equivalents such as [cudaStreamCreate](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g6a3c4b819e6a994c26d0c4824a4c80da), [cudaStreamCreateWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1gb1e32aff9f59119e4d0a9858991c4ad3) and [cudaStreamCreateWithPriority](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1ge2be9e9858849bf62ba4a8b66d1c3540). Passing an invalid handle will result in undefined behavior.
/// * any of the special streams such as the NULL stream, `CU_STREAM_LEGACY` and `CU_STREAM_PER_THREAD`. The runtime API equivalents of these are also accepted, which are NULL, [cudaStreamLegacy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g4e62d09dde16ba457b0a97f3a5262246) and [cudaStreamPerThread](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g7b7129befd6f52708309acafd1c46197) respectively.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuStreamCreate`], [`cuStreamGetPriority`], [cudaStreamGetId](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g5799ae8dd744e561dfdeda02c53e82df).
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `streamId`: Pointer to store the Id of the stream.
pub fn cuStreamGetId(
hStream: CUstream,
streamId: *mut ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Query the context associated with a stream.
///
/// Returns the CUDA context that the stream is associated with.
///
/// If the stream was created via the API [`cuGreenCtxStreamCreate`], the returned context is equivalent to the one returned by [`cuCtxFromGreenCtx`] on the green context associated with the stream at creation time.
///
/// The stream handle hStream can refer to any of the following:
///
/// * a stream created via any of the CUDA driver APIs such as [`cuStreamCreate`] and [`cuStreamCreateWithPriority`], or their runtime API equivalents such as [cudaStreamCreate](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g6a3c4b819e6a994c26d0c4824a4c80da), [cudaStreamCreateWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1gb1e32aff9f59119e4d0a9858991c4ad3) and [cudaStreamCreateWithPriority](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1ge2be9e9858849bf62ba4a8b66d1c3540). The returned context is the context that was active in the calling thread when the stream was created. Passing an invalid
/// handle will result in undefined behavior.
/// * any of the special streams such as the NULL stream, `CU_STREAM_LEGACY` and `CU_STREAM_PER_THREAD`. The runtime API equivalents of these are also accepted, which are NULL, [cudaStreamLegacy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g4e62d09dde16ba457b0a97f3a5262246) and [cudaStreamPerThread](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g7b7129befd6f52708309acafd1c46197) respectively. Specifying any of the special handles will return the context current to the calling thread. If no context
/// is current to the calling thread, [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuStreamCreateWithPriority`], [`cuStreamGetPriority`], [`cuStreamGetFlags`], [`cuStreamGetDevice`], [cudaStreamCreateWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1gb1e32aff9f59119e4d0a9858991c4ad3).
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `pctx`: Returned context associated with the stream.
pub fn cuStreamGetCtx(hStream: CUstream, pctx: *mut CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Query the contexts associated with a stream.
///
/// Returns the contexts that the stream is associated with.
///
/// If the stream is associated with a green context, the API returns the green context in pGreenCtx and the primary context of the associated device in pCtx.
///
/// If the stream is associated with a regular context, the API returns the regular context in pCtx and NULL in pGreenCtx.
///
/// The stream handle hStream can refer to any of the following:
///
/// * a stream created via any of the CUDA driver APIs such as [`cuStreamCreate`], [`cuStreamCreateWithPriority`] and [`cuGreenCtxStreamCreate`], or their runtime API equivalents such as [cudaStreamCreate](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g6a3c4b819e6a994c26d0c4824a4c80da), [cudaStreamCreateWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1gb1e32aff9f59119e4d0a9858991c4ad3) and [cudaStreamCreateWithPriority](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1ge2be9e9858849bf62ba4a8b66d1c3540). Passing an invalid handle will result in undefined behavior.
/// * any of the special streams such as the NULL stream, `CU_STREAM_LEGACY` and `CU_STREAM_PER_THREAD`. The runtime API equivalents of these are also accepted, which are NULL, [cudaStreamLegacy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g4e62d09dde16ba457b0a97f3a5262246) and [cudaStreamPerThread](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g7b7129befd6f52708309acafd1c46197) respectively. If any of the special handles are specified, the API will operate on the context current to the calling thread.
/// If a green context (that was converted via [`cuCtxFromGreenCtx`] before setting it current) is current to the calling thread, the API will return the green context in pGreenCtx and the primary context of the associated device in pCtx. If a regular context is current, the API returns the regular context in pCtx and NULL in pGreenCtx. Note that specifying `CU_STREAM_PER_THREAD` or [cudaStreamPerThread](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g7b7129befd6f52708309acafd1c46197) will return [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`] if a green context is current to the calling thread. If no context is current to the calling thread, [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuStreamCreate`], [cudaStreamCreateWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1gb1e32aff9f59119e4d0a9858991c4ad3),.
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `pCtx`: Returned regular context associated with the stream.
/// - `pGreenCtx`: Returned green context if the stream is associated with a green context or NULL if not.
pub fn cuStreamGetCtx_v2(
hStream: CUstream,
pCtx: *mut CUcontext,
pGreenCtx: *mut CUgreenCtx,
) -> CUresult;
}
unsafe extern "C" {
/// Make a compute stream wait on an event.
///
/// Makes all future work submitted to hStream wait for all work captured in hEvent. See [`cuEventRecord`] for details on what is captured by an event. The synchronization will be performed efficiently on the device when applicable.
/// hEvent may be from a different context or device than hStream.
///
/// flags include:
///
/// * [`CUevent_wait_flags_enum::CU_EVENT_WAIT_DEFAULT`]: Default event creation flag.
/// * [`CUevent_wait_flags_enum::CU_EVENT_WAIT_EXTERNAL`]: Event is captured in the graph as an external event node when performing stream capture. This flag is invalid outside of
/// stream capture.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuEventRecord`], [`cuStreamQuery`], [`cuStreamSynchronize`], [`cuStreamAddCallback`], [`cuStreamDestroy_v2`], [cudaStreamWaitEvent](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g7840e3984799941a61839de40413d1d9).
///
/// # Parameters
///
/// - `hStream`: Stream to wait.
/// - `hEvent`: Event to wait on (may not be NULL).
/// - `Flags`: See CUevent_capture_flags.
pub fn cuStreamWaitEvent(
hStream: CUstream,
hEvent: CUevent,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Add a callback to a compute stream.
///
/// Note:
///
/// This function is slated for eventual deprecation and removal. If you do not require the callback to execute in case of a device
/// error, consider using [`cuLaunchHostFunc`]. Additionally, this function is not supported with [`cuStreamBeginCapture_v2`] and [`cuStreamEndCapture`], unlike [`cuLaunchHostFunc`].
///
/// Adds a callback to be called on the host after all currently enqueued items in the stream have completed. For each cuStreamAddCallback
/// call, the callback will be executed exactly once. The callback will block later work in the stream until it is finished.
///
/// The callback may be passed [`cudaError_enum::CUDA_SUCCESS`] or an error code. In the event of a device error, all subsequently executed callbacks will receive an appropriate `CUresult`.
///
/// Callbacks must not make any CUDA API calls. Attempting to use a CUDA API will result in [`cudaError_enum::CUDA_ERROR_NOT_PERMITTED`]. Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not
/// mandated to run earlier. Callbacks without a mandated order (in independent streams) execute in undefined order and may be
/// serialized.
///
/// For the purposes of Unified Memory, callback execution makes a number of guarantees:
///
/// * The callback stream is considered idle for the duration of the callback. Thus, for example, a callback may always use memory
/// attached to the callback stream.
/// * The start of execution of a callback has the same effect as synchronizing an event recorded in the same stream immediately
/// prior to the callback. It thus synchronizes streams which have been "joined" prior to the callback.
/// * Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and
/// stream callbacks have executed. Thus, for example, a callback might use global attached memory even if work has been added
/// to another stream, if the work has been ordered behind the callback with an event.
/// * Completion of a callback does not cause a stream to become active except as described above. The callback stream will remain
/// idle if no device work follows the callback, and will remain idle across consecutive callbacks without device work in between.
/// Thus, for example, stream synchronization can be done by signaling from a callback at the end of the stream.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamQuery`], [`cuStreamSynchronize`], [`cuStreamWaitEvent`], [`cuStreamDestroy_v2`], [`cuMemAllocManaged`], [`cuStreamAttachMemAsync`], [`cuLaunchHostFunc`], [cudaStreamAddCallback](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g74aa9f4b1c2f12d994bf13876a5a2498).
///
/// # Parameters
///
/// - `hStream`: Stream to add callback to.
/// - `callback`: The function to call once preceding stream operations are complete.
/// - `userData`: User specified data to be passed to the callback function.
/// - `flags`: Reserved for future use, must be 0.
pub fn cuStreamAddCallback(
hStream: CUstream,
callback: CUstreamCallback,
userData: *mut ::core::ffi::c_void,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Begins graph capture on a stream.
///
/// Begin graph capture on hStream. When a stream is in capture mode, all operations pushed into the stream will not be executed, but will instead be captured
/// into a graph, which will be returned via [`cuStreamEndCapture`]. Capture may not be initiated if stream is CU_STREAM_LEGACY. Capture must be ended on the same stream in which it was initiated, and it may only be initiated if
/// the stream is not already in capture mode. The capture mode may be queried via [`cuStreamIsCapturing`]. A unique id representing the capture sequence may be queried via [`cuStreamGetCaptureInfo_v3`].
///
/// If mode is not [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`], [`cuStreamEndCapture`] must be called on this stream from the same thread.
///
/// Note:
///
/// Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface
/// reference is undefined behavior. This restriction does not apply to texture and surface objects.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamIsCapturing`], [`cuStreamEndCapture`], [`cuThreadExchangeStreamCaptureMode`].
///
/// # Parameters
///
/// - `hStream`: Stream in which to initiate capture.
/// - `mode`: Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see
/// [`cuThreadExchangeStreamCaptureMode`].
pub fn cuStreamBeginCapture_v2(
hStream: CUstream,
mode: CUstreamCaptureMode,
) -> CUresult;
}
unsafe extern "C" {
/// Begins graph capture on a stream to an existing graph.
///
/// Begin graph capture on hStream, placing new nodes into an existing graph. When a stream is in capture mode, all operations pushed into the stream will not
/// be executed, but will instead be captured into hGraph. The graph will not be instantiable until the user calls [`cuStreamEndCapture`].
///
/// Capture may not be initiated if stream is CU_STREAM_LEGACY. Capture must be ended on the same stream in which it was initiated, and it may only be initiated if
/// the stream is not already in capture mode. The capture mode may be queried via [`cuStreamIsCapturing`]. A unique id representing the capture sequence may be queried via [`cuStreamGetCaptureInfo_v3`].
///
/// If mode is not [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`], [`cuStreamEndCapture`] must be called on this stream from the same thread.
///
/// Note:
///
/// Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface
/// reference is undefined behavior. This restriction does not apply to texture and surface objects.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamBeginCapture_v2`], [`cuStreamCreate`], [`cuStreamIsCapturing`], [`cuStreamEndCapture`], [`cuThreadExchangeStreamCaptureMode`], [`cuGraphAddNode_v2`].
///
/// # Parameters
///
/// - `hStream`: Stream in which to initiate capture.
/// - `hGraph`: Graph to capture into.
/// - `dependencies`: Dependencies of the first node captured in the stream. Can be NULL if numDependencies is 0.
/// - `dependencyData`: Optional array of data associated with each dependency.
/// - `numDependencies`: Number of dependencies.
/// - `mode`: Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see
/// [`cuThreadExchangeStreamCaptureMode`].
pub fn cuStreamBeginCaptureToGraph(
hStream: CUstream,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
dependencyData: *const CUgraphEdgeData,
numDependencies: size_t,
mode: CUstreamCaptureMode,
) -> CUresult;
}
unsafe extern "C" {
/// Swaps the stream capture interaction mode for a thread.
///
/// Sets the calling thread's stream capture interaction mode to the value contained in \*mode, and overwrites \*mode with the previous mode for the thread. To facilitate deterministic behavior across function or module boundaries, callers
/// are encouraged to use this API in a push-pop fashion:
///
/// ```text
/// CUstreamCaptureMode mode = desiredMode;
/// cuThreadExchangeStreamCaptureMode(&mode);
/// ...
/// cuThreadExchangeStreamCaptureMode(&mode); // restore previous mode
/// ```
///
/// During stream capture (see [`cuStreamBeginCapture_v2`]), some actions, such as a call to [cudaMalloc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g37d37965bfb4803b6d4e59ff26856356), may be unsafe. In the case of [cudaMalloc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g37d37965bfb4803b6d4e59ff26856356), the operation is not enqueued asynchronously to a stream, and is not observed by stream capture. Therefore, if the sequence
/// of operations captured via [`cuStreamBeginCapture_v2`] depended on the allocation being replayed whenever the graph is launched, the captured graph would be invalid.
///
/// Therefore, stream capture places restrictions on API calls that can be made within or concurrently to a [`cuStreamBeginCapture_v2`]-[`cuStreamEndCapture`] sequence. This behavior can be controlled via this API and flags to [`cuStreamBeginCapture_v2`].
///
/// A thread's mode is one of the following:
///
/// * [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_GLOBAL`]: This is the default mode. If the local thread has an ongoing capture sequence that was not initiated with [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`] at cuStreamBeginCapture, or if any other thread has a concurrent capture sequence initiated with [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_GLOBAL`], this thread is prohibited from potentially unsafe API calls.
/// * [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_THREAD_LOCAL`]: If the local thread has an ongoing capture sequence not initiated with [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`], it is prohibited from potentially unsafe API calls. Concurrent capture sequences in other threads are ignored.
/// * [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`]: The local thread is not prohibited from potentially unsafe API calls. Note that the thread is still prohibited from API calls
/// which necessarily conflict with stream capture, for example, attempting [`cuEventQuery`] on an event that was last recorded inside a capture sequence.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamBeginCapture_v2`].
///
/// # Parameters
///
/// - `mode`: Pointer to mode value to swap with the current mode.
pub fn cuThreadExchangeStreamCaptureMode(mode: *mut CUstreamCaptureMode) -> CUresult;
}
unsafe extern "C" {
/// Ends capture on a stream, returning the captured graph.
///
/// End capture on hStream, returning the captured graph via phGraph. Capture must have been initiated on hStream via a call to [`cuStreamBeginCapture_v2`]. If capture was invalidated, due to a violation of the rules of stream capture, then a NULL graph will be returned.
///
/// If the mode argument to [`cuStreamBeginCapture_v2`] was not [`CUstreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`], this call must be from the same thread as [`cuStreamBeginCapture_v2`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamBeginCapture_v2`], [`cuStreamIsCapturing`], [`cuGraphDestroy`].
///
/// # Parameters
///
/// - `hStream`: Stream to query.
/// - `phGraph`: The captured graph.
pub fn cuStreamEndCapture(hStream: CUstream, phGraph: *mut CUgraph) -> CUresult;
}
unsafe extern "C" {
/// Returns a stream's capture status.
///
/// Return the capture status of hStream via captureStatus. After a successful call, \*captureStatus will contain one of the following:
///
/// * [`CUstreamCaptureStatus_enum::CU_STREAM_CAPTURE_STATUS_NONE`]: The stream is not capturing.
/// * [`CUstreamCaptureStatus_enum::CU_STREAM_CAPTURE_STATUS_ACTIVE`]: The stream is capturing.
/// * [`CUstreamCaptureStatus_enum::CU_STREAM_CAPTURE_STATUS_INVALIDATED`]: The stream was capturing but an error has invalidated the capture sequence. The capture sequence must be terminated with
/// [`cuStreamEndCapture`] on the stream where it was initiated in order to continue using hStream.
///
/// Note that, if this is called on `CU_STREAM_LEGACY` (the "null stream") while a blocking stream in the same context is capturing, it will return [`cudaError_enum::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT`] and \*captureStatus is unspecified after the call. The blocking stream capture is not invalidated.
///
/// When a blocking stream is capturing, the legacy stream is in an unusable state until the blocking stream capture is terminated.
/// The legacy stream is not supported for stream capture, but attempted use would have an implicit dependency on the capturing
/// stream(s).
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamBeginCapture_v2`], [`cuStreamEndCapture`].
///
/// # Parameters
///
/// - `hStream`: Stream to query.
/// - `captureStatus`: Returns the stream's capture status.
pub fn cuStreamIsCapturing(
hStream: CUstream,
captureStatus: *mut CUstreamCaptureStatus,
) -> CUresult;
}
unsafe extern "C" {
/// Query a stream's capture state.
///
/// Query stream state related to stream capture.
///
/// If called on `CU_STREAM_LEGACY` (the "null stream") while a stream not created with [`CUstream_flags_enum::CU_STREAM_NON_BLOCKING`] is capturing, returns [`cudaError_enum::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT`].
///
/// Valid data (other than capture status) is returned only if both of the following are true:
///
/// * the call returns [`CUresult::CUDA_SUCCESS`]
/// * the returned capture status is [`CUstreamCaptureStatus_enum::CU_STREAM_CAPTURE_STATUS_ACTIVE`]
///
/// If edgeData_out is non-NULL then dependencies_out must be as well. If dependencies_out is non-NULL and edgeData_out is NULL, but there is non-zero edge data for one or more of the current stream dependencies, the call will return [`cudaError_enum::CUDA_ERROR_LOSSY_QUERY`].
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamBeginCapture_v2`], [`cuStreamIsCapturing`], [`cuStreamUpdateCaptureDependencies_v2`].
///
/// # Parameters
///
/// - `hStream`: The stream to query.
/// - `captureStatus_out`: Location to return the capture status of the stream; required.
/// - `id_out`: Optional location to return an id for the capture sequence, which is unique over the lifetime of the process.
/// - `graph_out`: Optional location to return the graph being captured into. All operations other than destroy and node removal are permitted
/// on the graph while the capture sequence is in progress. This API does not transfer ownership of the graph, which is transferred
/// or destroyed at [`cuStreamEndCapture`]. Note that the graph handle may be invalidated before end of capture for certain errors. Nodes that are or become unreachable
/// from the original stream at [`cuStreamEndCapture`] due to direct actions on the graph do not trigger [`cudaError_enum::CUDA_ERROR_STREAM_CAPTURE_UNJOINED`].
/// - `dependencies_out`: Optional location to store a pointer to an array of nodes. The next node to be captured in the stream will depend on this
/// set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call
/// which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they
/// or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream)
/// without copying.
/// - `edgeData_out`: Optional location to store a pointer to an array of graph edge data. This array parallels dependencies_out; the next node to be added has an edge to dependencies_out\[i\] with annotation edgeData_out\[i\] for each i. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated.
/// - `numDependencies_out`: Optional location to store the size of the array returned in dependencies_out.
pub fn cuStreamGetCaptureInfo_v3(
hStream: CUstream,
captureStatus_out: *mut CUstreamCaptureStatus,
id_out: *mut cuuint64_t,
graph_out: *mut CUgraph,
dependencies_out: *mut *const CUgraphNode,
edgeData_out: *mut *const CUgraphEdgeData,
numDependencies_out: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Update the set of dependencies in a capturing stream.
///
/// Modifies the dependency set of a capturing stream. The dependency set is the set of nodes that the next captured node in the
/// stream will depend on along with the edge data for those dependencies.
///
/// Valid flags are [`CUstreamUpdateCaptureDependencies_flags_enum::CU_STREAM_ADD_CAPTURE_DEPENDENCIES`] and [`CUstreamUpdateCaptureDependencies_flags_enum::CU_STREAM_SET_CAPTURE_DEPENDENCIES`]. These control whether the set passed to the API is added to the existing set or replaces it. A flags value of 0 defaults
/// to [`CUstreamUpdateCaptureDependencies_flags_enum::CU_STREAM_ADD_CAPTURE_DEPENDENCIES`].
///
/// Nodes that are removed from the dependency set via this API do not result in [`cudaError_enum::CUDA_ERROR_STREAM_CAPTURE_UNJOINED`] if they are unreachable from the stream at [`cuStreamEndCapture`].
///
/// Returns [`cudaError_enum::CUDA_ERROR_ILLEGAL_STATE`] if the stream is not capturing.
///
/// **See also:**
///
/// [`cuStreamBeginCapture_v2`], [`cuStreamGetCaptureInfo_v3`].
///
/// # Parameters
///
/// - `hStream`: The stream to update.
/// - `dependencies`: The set of dependencies to add.
/// - `dependencyData`: Optional array of data associated with each dependency.
/// - `numDependencies`: The size of the dependencies array.
/// - `flags`: See above.
pub fn cuStreamUpdateCaptureDependencies_v2(
hStream: CUstream,
dependencies: *mut CUgraphNode,
dependencyData: *const CUgraphEdgeData,
numDependencies: size_t,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Attach memory to a stream asynchronously.
///
/// Enqueues an operation in hStream to specify stream association of length bytes of memory starting from dptr. This function is a stream-ordered operation, meaning that it is dependent on, and will only take effect when, previous work
/// in stream has completed. Any previous association is automatically replaced.
///
/// dptr must point to one of the following types of memories:
///
/// * managed memory declared using the __managed__ keyword or allocated with [`cuMemAllocManaged`].
/// * a valid host-accessible region of system-allocated pageable memory. This type of memory may only be specified if the device
/// associated with the stream reports a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`].
///
/// For managed allocations, length must be either zero or the entire allocation's size. Both indicate that the entire allocation's stream association is being
/// changed. Currently, it is not possible to change stream association for a portion of a managed allocation.
///
/// For pageable host allocations, length must be non-zero.
///
/// The stream association is specified using flags which must be one of `CUmemAttach_flags`. If the [`CUmemAttach_flags_enum::CU_MEM_ATTACH_GLOBAL`] flag is specified, the memory can be accessed by any stream on any device. If the [`CUmemAttach_flags_enum::CU_MEM_ATTACH_HOST`] flag is specified, the program makes a guarantee that it won't access the memory on the device from any stream on a device
/// that has a zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. If the [`CUmemAttach_flags_enum::CU_MEM_ATTACH_SINGLE`] flag is specified and hStream is associated with a device that has a zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`], the program makes a guarantee that it will only access the memory on the device from hStream. It is illegal to attach singly to the NULL stream, because the NULL stream is a virtual global stream and not a specific
/// stream. An error will be returned in this case.
///
/// When memory is associated with a single stream, the Unified Memory system will allow CPU access to this memory region so long
/// as all operations in hStream have completed, regardless of whether other streams are active. In effect, this constrains exclusive ownership of the managed
/// memory region by an active GPU to per-stream activity instead of whole-GPU activity.
///
/// Accessing memory on the device from streams that are not associated with it will produce undefined results. No error checking
/// is performed by the Unified Memory system to ensure that kernels launched into other streams do not access this region.
///
/// It is a program's responsibility to order calls to [`cuStreamAttachMemAsync`] via events, synchronization or other means to ensure legal access to memory at all times. Data visibility and coherency will
/// be changed appropriately for all kernels which follow a stream-association change.
///
/// If hStream is destroyed while data is associated with it, the association is removed and the association reverts to the default visibility
/// of the allocation as specified at [`cuMemAllocManaged`]. For __managed__ variables, the default association is always [`CUmemAttach_flags_enum::CU_MEM_ATTACH_GLOBAL`]. Note that destroying a stream is an asynchronous operation, and as a result, the change to default association won't happen
/// until all work in the stream has completed.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamQuery`], [`cuStreamSynchronize`], [`cuStreamWaitEvent`], [`cuStreamDestroy_v2`], [`cuMemAllocManaged`], [cudaStreamAttachMemAsync](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g496353d630c29c44a2e33f531a3944d1).
///
/// # Parameters
///
/// - `hStream`: Stream in which to enqueue the attach operation.
/// - `dptr`: Pointer to memory (must be a pointer to managed memory or to a valid host-accessible region of system-allocated pageable
/// ```text
/// memory)
/// ```
/// - `length`: Length of memory.
/// - `flags`: Must be one of `CUmemAttach_flags`.
pub fn cuStreamAttachMemAsync(
hStream: CUstream,
dptr: CUdeviceptr,
length: size_t,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Determine status of a compute stream.
///
/// Returns [`cudaError_enum::CUDA_SUCCESS`] if all operations in the stream specified by hStream have completed, or [`cudaError_enum::CUDA_ERROR_NOT_READY`] if not.
///
/// For the purposes of Unified Memory, a return value of [`cudaError_enum::CUDA_SUCCESS`] is equivalent to having called [`cuStreamSynchronize`].
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamWaitEvent`], [`cuStreamDestroy_v2`], [`cuStreamSynchronize`], [`cuStreamAddCallback`], [cudaStreamQuery](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g2021adeb17905c7ec2a3c1bf125c5435).
///
/// # Parameters
///
/// - `hStream`: Stream to query status of.
pub fn cuStreamQuery(hStream: CUstream) -> CUresult;
}
unsafe extern "C" {
/// Wait until a stream's tasks are completed.
///
/// Waits until the device has completed all operations in the stream specified by hStream. If the context was created with the [`CUctx_flags_enum::CU_CTX_SCHED_BLOCKING_SYNC`] flag, the CPU thread will block until the stream is finished with all of its tasks.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamDestroy_v2`], [`cuStreamWaitEvent`], [`cuStreamQuery`], [`cuStreamAddCallback`], [cudaStreamSynchronize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g82b5784f674c17c6df64affe618bf45e).
///
/// # Parameters
///
/// - `hStream`: Stream to wait for.
pub fn cuStreamSynchronize(hStream: CUstream) -> CUresult;
}
unsafe extern "C" {
/// Destroys a stream.
///
/// Destroys the stream specified by hStream.
///
/// In case the device is still doing work in the stream hStream when [`cuStreamDestroy_v2`] is called, the function will return immediately and the resources associated with hStream will be released automatically once the device has completed all work in hStream.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamWaitEvent`], [`cuStreamQuery`], [`cuStreamSynchronize`], [`cuStreamAddCallback`], [cudaStreamDestroy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1gfda584f1788ca983cb21c5f4d2033a62).
///
/// # Parameters
///
/// - `hStream`: Stream to destroy.
pub fn cuStreamDestroy_v2(hStream: CUstream) -> CUresult;
}
unsafe extern "C" {
/// Copies attributes from source stream to destination stream.
///
/// Copies attributes from source stream src to destination stream dst. Both streams must have the same context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`CUaccessPolicyWindow`].
///
/// # Parameters
///
/// - `dst`: Destination stream.
/// - `src`: Source stream For list of attributes see CUstreamAttrID.
pub fn cuStreamCopyAttributes(dst: CUstream, src: CUstream) -> CUresult;
}
unsafe extern "C" {
/// Queries stream attribute.
///
/// Queries attribute attr from hStream and stores it in corresponding member of value_out.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`CUaccessPolicyWindow`].
pub fn cuStreamGetAttribute(
hStream: CUstream,
attr: CUstreamAttrID,
value_out: *mut CUstreamAttrValue,
) -> CUresult;
}
unsafe extern "C" {
/// Sets stream attribute.
///
/// Sets attribute attr on hStream from corresponding attribute of value. The updated attribute will be applied to subsequent work submitted to the stream. It will not affect previously submitted
/// work.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`CUaccessPolicyWindow`].
pub fn cuStreamSetAttribute(
hStream: CUstream,
attr: CUstreamAttrID,
value: *const CUstreamAttrValue,
) -> CUresult;
}
unsafe extern "C" {
/// Creates an event.
///
/// Creates an event \*phEvent for the current context with the flags specified via Flags. Valid flags include:
///
/// * [`CUevent_flags_enum::CU_EVENT_DEFAULT`]: Default event creation flag.
/// * [`CUevent_flags_enum::CU_EVENT_BLOCKING_SYNC`]: Specifies that the created event should use blocking synchronization. A CPU thread that uses [`cuEventSynchronize`] to wait on an event created with this flag will block until the event has actually been recorded.
/// * [`CUevent_flags_enum::CU_EVENT_DISABLE_TIMING`]: Specifies that the created event does not need to record timing data. Events created with this flag specified and the [`CUevent_flags_enum::CU_EVENT_BLOCKING_SYNC`] flag not specified will provide the best performance when used with [`cuStreamWaitEvent`] and [`cuEventQuery`].
/// * [`CUevent_flags_enum::CU_EVENT_INTERPROCESS`]: Specifies that the created event may be used as an interprocess event by [`cuIpcGetEventHandle`]. [`CUevent_flags_enum::CU_EVENT_INTERPROCESS`] must be specified along with [`CUevent_flags_enum::CU_EVENT_DISABLE_TIMING`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuEventRecord`], [`cuEventQuery`], [`cuEventSynchronize`], [`cuEventDestroy_v2`], [`cuEventElapsedTime_v2`], [cudaEventCreate](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g4b5fdb19d7fb5f6f8862559f9279f6c3), [cudaEventCreateWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EVENT.html#group__CUDART__EVENT_1g7b317e07ff385d85aa656204b971a042).
///
/// # Parameters
///
/// - `phEvent`: Returns newly created event.
/// - `Flags`: Event creation flags.
pub fn cuEventCreate(phEvent: *mut CUevent, Flags: ::core::ffi::c_uint) -> CUresult;
}
unsafe extern "C" {
/// Records an event.
///
/// Captures in hEvent the contents of hStream at the time of this call. hEvent and hStream must be from the same context otherwise [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`] is returned. Calls such as [`cuEventQuery`] or [`cuStreamWaitEvent`] will then examine or wait for completion of the work that was captured. Uses of hStream after this call do not modify hEvent. See note on default stream behavior for what is captured in the default case.
///
/// [`cuEventRecord`] can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as [`cuStreamWaitEvent`] use the most recently captured state at the time of the API call, and are not affected by later calls to [`cuEventRecord`]. Before the first call to [`cuEventRecord`], an event represents an empty set of work, so for example [`cuEventQuery`] would return [`cudaError_enum::CUDA_SUCCESS`].
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuEventCreate`], [`cuEventQuery`], [`cuEventSynchronize`], [`cuStreamWaitEvent`], [`cuEventDestroy_v2`], [`cuEventElapsedTime_v2`], [cudaEventRecord](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EVENT.html#group__CUDART__EVENT_1gf4fcb74343aa689f4159791967868446), [`cuEventRecordWithFlags`].
///
/// # Parameters
///
/// - `hEvent`: Event to record.
/// - `hStream`: Stream to record event for.
pub fn cuEventRecord(hEvent: CUevent, hStream: CUstream) -> CUresult;
}
unsafe extern "C" {
/// Records an event.
///
/// Captures in hEvent the contents of hStream at the time of this call. hEvent and hStream must be from the same context otherwise [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`] is returned. Calls such as [`cuEventQuery`] or [`cuStreamWaitEvent`] will then examine or wait for completion of the work that was captured. Uses of hStream after this call do not modify hEvent. See note on default stream behavior for what is captured in the default case.
///
/// [`cuEventRecordWithFlags`] can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as [`cuStreamWaitEvent`] use the most recently captured state at the time of the API call, and are not affected by later calls to [`cuEventRecordWithFlags`]. Before the first call to [`cuEventRecordWithFlags`], an event represents an empty set of work, so for example [`cuEventQuery`] would return [`cudaError_enum::CUDA_SUCCESS`].
///
/// flags include:
///
/// * [`CUevent_record_flags_enum::CU_EVENT_RECORD_DEFAULT`]: Default event creation flag.
/// * [`CUevent_record_flags_enum::CU_EVENT_RECORD_EXTERNAL`]: Event is captured in the graph as an external event node when performing stream capture. This flag is invalid outside of
/// stream capture.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuEventCreate`], [`cuEventQuery`], [`cuEventSynchronize`], [`cuStreamWaitEvent`], [`cuEventDestroy_v2`], [`cuEventElapsedTime_v2`], [`cuEventRecord`], [cudaEventRecord](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EVENT.html#group__CUDART__EVENT_1gf4fcb74343aa689f4159791967868446).
///
/// # Parameters
///
/// - `hEvent`: Event to record.
/// - `hStream`: Stream to record event for.
/// - `flags`: See CUevent_capture_flags.
pub fn cuEventRecordWithFlags(
hEvent: CUevent,
hStream: CUstream,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Queries an event's status.
///
/// Queries the status of all work currently captured by hEvent. See [`cuEventRecord`] for details on what is captured by an event.
///
/// Returns [`cudaError_enum::CUDA_SUCCESS`] if all captured work has been completed, or [`cudaError_enum::CUDA_ERROR_NOT_READY`] if any captured work is incomplete.
///
/// For the purposes of Unified Memory, a return value of [`cudaError_enum::CUDA_SUCCESS`] is equivalent to having called [`cuEventSynchronize`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuEventCreate`], [`cuEventRecord`], [`cuEventSynchronize`], [`cuEventDestroy_v2`], [`cuEventElapsedTime_v2`], [cudaEventQuery](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EVENT.html#group__CUDART__EVENT_1g2bf738909b4a059023537eaa29d8a5b7).
///
/// # Parameters
///
/// - `hEvent`: Event to query.
pub fn cuEventQuery(hEvent: CUevent) -> CUresult;
}
unsafe extern "C" {
/// Waits for an event to complete.
///
/// Waits until the completion of all work currently captured in hEvent. See [`cuEventRecord`] for details on what is captured by an event.
///
/// Waiting for an event that was created with the [`CUevent_flags_enum::CU_EVENT_BLOCKING_SYNC`] flag will cause the calling CPU thread to block until the event has been completed by the device. If the [`CUevent_flags_enum::CU_EVENT_BLOCKING_SYNC`] flag has not been set, then the CPU thread will busy-wait until the event has been completed by the device.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuEventCreate`], [`cuEventRecord`], [`cuEventQuery`], [`cuEventDestroy_v2`], [`cuEventElapsedTime_v2`], [cudaEventSynchronize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EVENT.html#group__CUDART__EVENT_1g949aa42b30ae9e622f6ba0787129ff22).
///
/// # Parameters
///
/// - `hEvent`: Event to wait for.
pub fn cuEventSynchronize(hEvent: CUevent) -> CUresult;
}
unsafe extern "C" {
/// Destroys an event.
///
/// Destroys the event specified by hEvent.
///
/// An event may be destroyed before it is complete (i.e., while [`cuEventQuery`] would return [`cudaError_enum::CUDA_ERROR_NOT_READY`]). In this case, the call does not block on completion of the event, and any associated resources will automatically be released
/// asynchronously at completion.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuEventCreate`], [`cuEventRecord`], [`cuEventQuery`], [`cuEventSynchronize`], [`cuEventElapsedTime_v2`], [cudaEventDestroy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EVENT.html#group__CUDART__EVENT_1g2cb6baa0830a1cd0bd957bfd8705045b).
///
/// # Parameters
///
/// - `hEvent`: Event to destroy.
pub fn cuEventDestroy_v2(hEvent: CUevent) -> CUresult;
}
unsafe extern "C" {
/// Computes the elapsed time between two events.
///
/// Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). Note this API
/// is not guaranteed to return the latest errors for pending work. As such this API is intended to serve as an elapsed time calculation
/// only and any polling for completion on the events to be compared should be done with [`cuEventQuery`] instead.
///
/// If either event was last recorded in a non-NULL stream, the resulting time may be greater than expected (even if both used
/// the same stream handle). This happens because the [`cuEventRecord`] operation takes place asynchronously and there is no guarantee that the measured latency is actually just between the two
/// events. Any number of other different stream operations could execute in between the two measured events, thus altering the
/// timing in a significant way.
///
/// If [`cuEventRecord`] has not been called on either event then [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`] is returned. If [`cuEventRecord`] has been called on both events but one or both of them has not yet been completed (that is, [`cuEventQuery`] would return [`cudaError_enum::CUDA_ERROR_NOT_READY`] on at least one of the events), [`cudaError_enum::CUDA_ERROR_NOT_READY`] is returned. If either event was created with the [`CUevent_flags_enum::CU_EVENT_DISABLE_TIMING`] flag, then this function will return [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuEventCreate`], [`cuEventRecord`], [`cuEventQuery`], [`cuEventSynchronize`], [`cuEventDestroy_v2`], [cudaEventElapsedTime](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EVENT.html#group__CUDART__EVENT_1g40159125411db92c835edb46a0989cd6).
///
/// # Parameters
///
/// - `pMilliseconds`: Time between hStart and hEnd in ms.
/// - `hStart`: Starting event.
/// - `hEnd`: Ending event.
pub fn cuEventElapsedTime_v2(
pMilliseconds: *mut f32,
hStart: CUevent,
hEnd: CUevent,
) -> CUresult;
}
unsafe extern "C" {
/// Imports an external memory object.
///
/// Imports an externally allocated memory object and returns a handle to that in extMem_out.
///
/// The properties of the handle being imported must be described in memHandleDesc. The CUDA_EXTERNAL_MEMORY_HANDLE_DESC structure is defined as follows:
///
/// ```text
/// typedef struct CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st {
/// CUexternalMemoryHandleType type;
/// union {
/// int fd;
/// struct {
/// void *handle;
/// const void *name;
/// } win32;
/// const void *nvSciBufObject;
/// } handle;
/// unsigned long long size;
/// unsigned int flags;
/// } CUDA_EXTERNAL_MEMORY_HANDLE_DESC;
/// ```
///
/// where [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) specifies the type of handle being imported. `CUexternalMemoryHandleType` is defined as:
///
/// ```text
/// typedef enum CUexternalMemoryHandleType_enum {
/// CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD = 1,
/// CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32 = 2,
/// CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
/// CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP = 4,
/// CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE = 5,
/// CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE = 6,
/// CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT = 7,
/// CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF = 8,
/// CU_EXTERNAL_MEMORY_HANDLE_TYPE_DMABUF_FD = 9
/// } CUexternalMemoryHandleType;
/// ```
///
/// If [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD`], then CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::fd must be a valid file descriptor referencing a memory object. Ownership
/// of the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any operations
/// on the file descriptor after it is imported results in undefined behavior.
///
/// If [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32`], then exactly one of CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle and CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
/// must not be NULL. If CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle is not NULL, then it must represent a valid shared
/// NT handle that references a memory object. Ownership of this handle is not transferred to CUDA after the import operation,
/// so the application must release the handle using the appropriate system call. If CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
/// is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a memory object.
///
/// If [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT`], then CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle must be non-NULL and CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
/// must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying
/// object, and thus will be invalid when all references to the memory object are destroyed.
///
/// If [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP`], then exactly one of CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle and CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
/// must not be NULL. If CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle is not NULL, then it must represent a valid shared
/// NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Heap object. This handle holds a
/// reference to the underlying object. If CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name is not NULL, then it must point
/// to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Heap object.
///
/// If [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE`], then exactly one of CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle and CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
/// must not be NULL. If CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle is not NULL, then it must represent a valid shared
/// NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Resource object. This handle holds
/// a reference to the underlying object. If CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name is not NULL, then it must point
/// to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Resource object.
///
/// If [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE`], then CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle must represent a valid shared NT handle that is returned by
/// IDXGIResource1::CreateSharedHandle when referring to a ID3D11Resource object. If CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
/// is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D11Resource object.
///
/// If [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT`], then CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::handle must represent a valid shared KMT handle that is returned by
/// IDXGIResource::GetSharedHandle when referring to a ID3D11Resource object and CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::win32::name
/// must be NULL.
///
/// If [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF`], then CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::nvSciBufObject must be non-NULL and reference a valid NvSciBuf object. If
/// the NvSciBuf object imported into CUDA is also mapped by other drivers, then the application must use [`cuWaitExternalSemaphoresAsync`] or [`cuSignalExternalSemaphoresAsync`] as appropriate barriers to maintain coherence between CUDA and the other drivers. See [`CUDA_EXTERNAL_SEMAPHORE_SIGNAL_SKIP_NVSCIBUF_MEMSYNC`] and [`CUDA_EXTERNAL_SEMAPHORE_WAIT_SKIP_NVSCIBUF_MEMSYNC`] for memory synchronization.
///
/// If [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_DMABUF_FD`], then CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::fd must be a valid file descriptor referencing a dma_buf object and [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_144d7c253f6b6f34e46b8726496e425c9) must be zero. Importing a dma_buf object is supported only on Tegra Jetson platform starting with Thor series. Mapping an
/// imported dma_buf object as CUDA mipmapped array using [`cuExternalMemoryGetMappedMipmappedArray`] is not supported.
///
/// The size of the memory object must be specified in [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::size](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_136570cee9bbfa12b3f34d0d1d98029ce).
///
/// Specifying the flag [`CUDA_EXTERNAL_MEMORY_DEDICATED`] in [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_144d7c253f6b6f34e46b8726496e425c9) indicates that the resource is a dedicated resource. The definition of what a dedicated resource is outside the scope of
/// this extension. This flag must be set if [CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__HANDLE__DESC__v1_1d4e3663348d28278d066980b422ab70e) is one of the following: [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE`][`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE`][`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT`]
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * If the Vulkan memory imported into CUDA is mapped on the CPU then the application must use vkInvalidateMappedMemoryRanges/vkFlushMappedMemoryRanges
/// as well as appropriate Vulkan pipeline barriers to maintain coherence between CPU and GPU. For more information on these APIs,
/// please refer to "Synchronization and Cache Control" chapter from Vulkan specification.
///
/// **See also:**
///
/// [`cuDestroyExternalMemory`], [`cuExternalMemoryGetMappedBuffer`], [`cuExternalMemoryGetMappedMipmappedArray`].
///
/// # Parameters
///
/// - `extMem_out`: Returned handle to an external memory object.
/// - `memHandleDesc`: Memory import handle descriptor.
pub fn cuImportExternalMemory(
extMem_out: *mut CUexternalMemory,
memHandleDesc: *const CUDA_EXTERNAL_MEMORY_HANDLE_DESC,
) -> CUresult;
}
unsafe extern "C" {
/// Maps a buffer onto an imported memory object.
///
/// Maps a buffer onto an imported memory object and returns a device pointer in devPtr.
///
/// The properties of the buffer being mapped must be described in bufferDesc. The CUDA_EXTERNAL_MEMORY_BUFFER_DESC structure is defined as follows:
///
/// ```text
/// typedef struct CUDA_EXTERNAL_MEMORY_BUFFER_DESC_st {
/// unsigned long long offset;
/// unsigned long long size;
/// unsigned int flags;
/// } CUDA_EXTERNAL_MEMORY_BUFFER_DESC;
/// ```
///
/// where [CUDA_EXTERNAL_MEMORY_BUFFER_DESC::offset](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__BUFFER__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__BUFFER__DESC__v1_1734130661fb389658d29d10ed6cf41cd) is the offset in the memory object where the buffer's base address is. [CUDA_EXTERNAL_MEMORY_BUFFER_DESC::size](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__BUFFER__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__BUFFER__DESC__v1_1b736c75bec5e1461f565e95500c8227f) is the size of the buffer. [CUDA_EXTERNAL_MEMORY_BUFFER_DESC::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__BUFFER__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__BUFFER__DESC__v1_186aad4fc1ddac67d953daddec0a5c94a) must be zero.
///
/// The offset and size have to be suitably aligned to match the requirements of the external API. Mapping two buffers whose ranges
/// overlap may or may not result in the same virtual address being returned for the overlapped portion. In such cases, the application
/// must ensure that all accesses to that region from the GPU are volatile. Otherwise writes made via one address are not guaranteed
/// to be visible via the other address, even if they're issued by the same thread. It is recommended that applications map the
/// combined range instead of mapping separate buffers and then apply the appropriate offsets to the returned pointer to derive
/// the individual buffers.
///
/// The returned pointer devPtr must be freed using [`cuMemFree_v2`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuImportExternalMemory`], [`cuDestroyExternalMemory`], [`cuExternalMemoryGetMappedMipmappedArray`].
///
/// # Parameters
///
/// - `devPtr`: Returned device pointer to buffer.
/// - `extMem`: Handle to external memory object.
/// - `bufferDesc`: Buffer descriptor.
pub fn cuExternalMemoryGetMappedBuffer(
devPtr: *mut CUdeviceptr,
extMem: CUexternalMemory,
bufferDesc: *const CUDA_EXTERNAL_MEMORY_BUFFER_DESC,
) -> CUresult;
}
unsafe extern "C" {
/// Maps a CUDA mipmapped array onto an external memory object.
///
/// Maps a CUDA mipmapped array onto an external object and returns a handle to it in mipmap.
///
/// The properties of the CUDA mipmapped array being mapped must be described in mipmapDesc. The structure CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC is defined as follows:
///
/// ```text
/// typedef struct CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_st {
/// unsigned long long offset;
/// CUDA_ARRAY3D_DESCRIPTOR arrayDesc;
/// unsigned int numLevels;
/// } CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC;
/// ```
///
/// where [CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::offset](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__MIPMAPPED__ARRAY__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__MIPMAPPED__ARRAY__DESC__v1_1c4a2c246eab269279434d8153d6e15aa) is the offset in the memory object where the base level of the mipmap chain is. [CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::arrayDesc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__MIPMAPPED__ARRAY__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__MIPMAPPED__ARRAY__DESC__v1_17c3e0998380d9922a9fcddadeecd186d) describes the format, dimensions and type of the base level of the mipmap chain. For further details on these parameters,
/// please refer to the documentation for [`cuMipmappedArrayCreate`]. Note that if the mipmapped array is bound as a color target in the graphics API, then the flag [`CUDA_ARRAY3D_COLOR_ATTACHMENT`] must be specified in CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::arrayDesc::Flags. [CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::numLevels](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__MIPMAPPED__ARRAY__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__MIPMAPPED__ARRAY__DESC__v1_1938185e3178ee0fb5920ac104035b321) specifies the total number of levels in the mipmap chain.
///
/// If extMem was imported from a handle of type [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF`], then [CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC::numLevels](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__MEMORY__MIPMAPPED__ARRAY__DESC__v1.html#structCUDA__EXTERNAL__MEMORY__MIPMAPPED__ARRAY__DESC__v1_1938185e3178ee0fb5920ac104035b321) must be equal to 1.
///
/// Mapping extMem imported from a handle of type [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_DMABUF_FD`], is not supported.
///
/// The returned CUDA mipmapped array must be freed using [`cuMipmappedArrayDestroy`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuImportExternalMemory`], [`cuDestroyExternalMemory`], [`cuExternalMemoryGetMappedBuffer`].
///
/// # Parameters
///
/// - `mipmap`: Returned CUDA mipmapped array.
/// - `extMem`: Handle to external memory object.
/// - `mipmapDesc`: CUDA array descriptor.
pub fn cuExternalMemoryGetMappedMipmappedArray(
mipmap: *mut CUmipmappedArray,
extMem: CUexternalMemory,
mipmapDesc: *const CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC,
) -> CUresult;
}
unsafe extern "C" {
/// Destroys an external memory object.
///
/// Destroys the specified external memory object. Any existing buffers and CUDA mipmapped arrays mapped onto this object must
/// no longer be used and must be explicitly freed using [`cuMemFree_v2`] and [`cuMipmappedArrayDestroy`] respectively.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuImportExternalMemory`], [`cuExternalMemoryGetMappedBuffer`], [`cuExternalMemoryGetMappedMipmappedArray`].
///
/// # Parameters
///
/// - `extMem`: External memory object to be destroyed.
pub fn cuDestroyExternalMemory(extMem: CUexternalMemory) -> CUresult;
}
unsafe extern "C" {
/// Imports an external semaphore.
///
/// Imports an externally allocated synchronization object and returns a handle to that in extSem_out.
///
/// The properties of the handle being imported must be described in semHandleDesc. The CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC is defined as follows:
///
/// ```text
/// typedef struct CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st {
/// CUexternalSemaphoreHandleType type;
/// union {
/// int fd;
/// struct {
/// void *handle;
/// const void *name;
/// } win32;
/// const void* NvSciSyncObj;
/// } handle;
/// unsigned int flags;
/// } CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC;
/// ```
///
/// where [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) specifies the type of handle being imported. `CUexternalSemaphoreHandleType` is defined as:
///
/// ```text
/// typedef enum CUexternalSemaphoreHandleType_enum {
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD = 1,
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32 = 2,
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE = 4,
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE = 5,
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC = 6,
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX = 7,
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT = 8,
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD = 9,
/// CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32 = 10
/// } CUexternalSemaphoreHandleType;
/// ```
///
/// If [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) is [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD`], then CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::fd must be a valid file descriptor referencing a synchronization object.
/// Ownership of the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any
/// operations on the file descriptor after it is imported results in undefined behavior.
///
/// If [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) is [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32`], then exactly one of CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle and CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
/// must not be NULL. If CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle is not NULL, then it must represent a valid
/// shared NT handle that references a synchronization object. Ownership of this handle is not transferred to CUDA after the import
/// operation, so the application must release the handle using the appropriate system call. If CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
/// is not NULL, then it must name a valid synchronization object.
///
/// If [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) is [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT`], then CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle must be non-NULL and CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
/// must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying
/// object, and thus will be invalid when all references to the synchronization object are destroyed.
///
/// If [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) is [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE`], then exactly one of CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle and CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
/// must not be NULL. If CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle is not NULL, then it must represent a valid
/// shared NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Fence object. This handle
/// holds a reference to the underlying object. If CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name is not NULL, then
/// it must name a valid synchronization object that refers to a valid ID3D12Fence object.
///
/// If [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) is [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE`], then CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle represents a valid shared NT handle that is returned by
/// ID3D11Fence::CreateSharedHandle. If CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name is not NULL, then it must name
/// a valid synchronization object that refers to a valid ID3D11Fence object.
///
/// If [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) is [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC`], then CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::nvSciSyncObj represents a valid NvSciSyncObj.
///
/// [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX`], then CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle represents a valid shared NT handle that is returned by
/// IDXGIResource1::CreateSharedHandle when referring to a IDXGIKeyedMutex object. If CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
/// is not NULL, then it must name a valid synchronization object that refers to a valid IDXGIKeyedMutex object.
///
/// If [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) is [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT`], then CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle represents a valid shared KMT handle that is returned by
/// IDXGIResource::GetSharedHandle when referring to a IDXGIKeyedMutex object and CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
/// must be NULL.
///
/// If [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) is [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD`], then CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::fd must be a valid file descriptor referencing a synchronization object.
/// Ownership of the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any
/// operations on the file descriptor after it is imported results in undefined behavior.
///
/// If [CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::type](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1.html#structCUDA__EXTERNAL__SEMAPHORE__HANDLE__DESC__v1_1cf32b96f55beec6f904b2455effed87d) is [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32`], then exactly one of CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle and CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
/// must not be NULL. If CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::handle is not NULL, then it must represent a valid
/// shared NT handle that references a synchronization object. Ownership of this handle is not transferred to CUDA after the import
/// operation, so the application must release the handle using the appropriate system call. If CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC::handle::win32::name
/// is not NULL, then it must name a valid synchronization object.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDestroyExternalSemaphore`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`].
///
/// # Parameters
///
/// - `extSem_out`: Returned handle to an external semaphore.
/// - `semHandleDesc`: Semaphore import handle descriptor.
pub fn cuImportExternalSemaphore(
extSem_out: *mut CUexternalSemaphore,
semHandleDesc: *const CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC,
) -> CUresult;
}
unsafe extern "C" {
/// Signals a set of external semaphore objects.
///
/// Enqueues a signal operation on a set of externally allocated semaphore object in the specified stream. The operations will
/// be executed when all prior operations in the stream complete.
///
/// The exact semantics of signaling a semaphore depends on the type of the object.
///
/// If the semaphore object is any one of the following types: [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT`] then signaling the semaphore will set it to the signaled state.
///
/// If the semaphore object is any one of the following types: [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32`] then the semaphore will be set to the value specified in CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS::params::fence::value.
///
/// If the semaphore object is of the type [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC`] this API sets CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS::params::nvSciSync::fence to a value that can be used by subsequent waiters
/// of the same NvSciSync object to order operations with those currently submitted in stream. Such an update will overwrite previous contents of CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS::params::nvSciSync::fence. By default,
/// signaling such an external semaphore object causes appropriate memory synchronization operations to be performed over all
/// external memory objects that are imported as [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF`]. This ensures that any subsequent accesses made by other importers of the same set of NvSciBuf memory object(s) are coherent.
/// These operations can be skipped by specifying the flag [`CUDA_EXTERNAL_SEMAPHORE_SIGNAL_SKIP_NVSCIBUF_MEMSYNC`], which can be used as a performance optimization when data coherency is not required. But specifying this flag in scenarios
/// where data coherency is required results in undefined behavior. Also, for semaphore object of the type [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC`], if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in [`cuDeviceGetNvSciSyncAttributes`] to CUDA_NVSCISYNC_ATTR_SIGNAL, this API will return [`CUresult::CUDA_ERROR_NOT_SUPPORTED`]. NvSciSyncFence associated with semaphore object
/// of the type [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC`] can be deterministic. For this the NvSciSyncAttrList used to create the semaphore object must have value of NvSciSyncAttrKey_RequireDeterministicFences
/// key set to true. Deterministic fences allow users to enqueue a wait over the semaphore object even before corresponding signal
/// is enqueued. For such a semaphore object, CUDA guarantees that each signal operation will increment the fence value by '1'.
/// Users are expected to track count of signals enqueued on the semaphore object and insert waits accordingly. When such a semaphore
/// object is signaled from multiple streams, due to concurrent stream execution, it is possible that the order in which the semaphore
/// gets signaled is indeterministic. This could lead to waiters of the semaphore getting unblocked incorrectly. Users are expected
/// to handle such situations, either by not using the same semaphore object with deterministic fence support enabled in different
/// streams or by adding explicit dependency amongst such streams so that the semaphore is signaled in order. NvSciSyncFence associated
/// with semaphore object of the type [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC`] can be timestamp enabled. For this the NvSciSyncAttrList used to create the object must have the value of NvSciSyncAttrKey_WaiterRequireTimestamps
/// key set to true. Timestamps are emitted asynchronously by the GPU and CUDA saves the GPU timestamp in the corresponding NvSciSyncFence
/// at the time of signal on GPU. Users are expected to convert GPU clocks to CPU clocks using appropriate scaling functions.
/// Users are expected to wait for the completion of the fence before extracting timestamp using appropriate NvSciSync APIs. Users
/// are expected to ensure that there is only one outstanding timestamp enabled fence per CUDA-NvSciSync object at any point of
/// time, failing which leads to undefined behavior. Extracting the timestamp before the corresponding fence is signalled could
/// lead to undefined behavior. Timestamp extracted via appropriate NvSciSync API would be in microseconds.
///
/// If the semaphore object is any one of the following types: [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT`] then the keyed mutex will be released with the key specified in CUDA_EXTERNAL_SEMAPHORE_PARAMS::params::keyedmutex::key.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuImportExternalSemaphore`], [`cuDestroyExternalSemaphore`], [`cuWaitExternalSemaphoresAsync`].
///
/// # Parameters
///
/// - `extSemArray`: Set of external semaphores to be signaled.
/// - `paramsArray`: Array of semaphore parameters.
/// - `numExtSems`: Number of semaphores to signal.
/// - `stream`: Stream to enqueue the signal operations in.
pub fn cuSignalExternalSemaphoresAsync(
extSemArray: *const CUexternalSemaphore,
paramsArray: *const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS,
numExtSems: ::core::ffi::c_uint,
stream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Waits on a set of external semaphore objects.
///
/// Enqueues a wait operation on a set of externally allocated semaphore object in the specified stream. The operations will be
/// executed when all prior operations in the stream complete.
///
/// The exact semantics of waiting on a semaphore depends on the type of the object.
///
/// If the semaphore object is any one of the following types: [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT`] then waiting on the semaphore will wait until the semaphore reaches the signaled state. The semaphore will then be reset
/// to the unsignaled state. Therefore for every signal operation, there can only be one wait operation.
///
/// If the semaphore object is any one of the following types: [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32`] then waiting on the semaphore will wait until the value of the semaphore is greater than or equal to CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS::params::fence::value.
///
/// If the semaphore object is of the type [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC`] then, waiting on the semaphore will wait until the CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS::params::nvSciSync::fence is signaled
/// by the signaler of the NvSciSyncObj that was associated with this semaphore object. By default, waiting on such an external
/// semaphore object causes appropriate memory synchronization operations to be performed over all external memory objects that
/// are imported as [`CUexternalMemoryHandleType_enum::CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF`]. This ensures that any subsequent accesses made by other importers of the same set of NvSciBuf memory object(s) are coherent.
/// These operations can be skipped by specifying the flag [`CUDA_EXTERNAL_SEMAPHORE_WAIT_SKIP_NVSCIBUF_MEMSYNC`], which can be used as a performance optimization when data coherency is not required. But specifying this flag in scenarios
/// where data coherency is required results in undefined behavior. Also, for semaphore object of the type [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC`], if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in [`cuDeviceGetNvSciSyncAttributes`] to CUDA_NVSCISYNC_ATTR_WAIT, this API will return [`CUresult::CUDA_ERROR_NOT_SUPPORTED`].
///
/// If the semaphore object is any one of the following types: [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX`], [`CUexternalSemaphoreHandleType_enum::CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT`] then the keyed mutex will be acquired when it is released with the key specified in CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS::params::keyedmutex::key
/// or until the timeout specified by CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS::params::keyedmutex::timeoutMs has lapsed. The timeout
/// interval can either be a finite value specified in milliseconds or an infinite value. In case an infinite value is specified
/// the timeout never elapses. The windows INFINITE macro must be used to specify infinite timeout.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuImportExternalSemaphore`], [`cuDestroyExternalSemaphore`], [`cuSignalExternalSemaphoresAsync`].
///
/// # Parameters
///
/// - `extSemArray`: External semaphores to be waited on.
/// - `paramsArray`: Array of semaphore parameters.
/// - `numExtSems`: Number of semaphores to wait on.
/// - `stream`: Stream to enqueue the wait operations in.
pub fn cuWaitExternalSemaphoresAsync(
extSemArray: *const CUexternalSemaphore,
paramsArray: *const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS,
numExtSems: ::core::ffi::c_uint,
stream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Destroys an external semaphore.
///
/// Destroys an external semaphore object and releases any references to the underlying resource. Any outstanding signals or waits
/// must have completed before the semaphore is destroyed.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuImportExternalSemaphore`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`].
///
/// # Parameters
///
/// - `extSem`: External semaphore to be destroyed.
pub fn cuDestroyExternalSemaphore(extSem: CUexternalSemaphore) -> CUresult;
}
unsafe extern "C" {
/// Wait on a memory location.
///
/// Enqueues a synchronization of the stream on the given memory location. Work ordered after the operation will block until the
/// given condition on the memory is satisfied. By default, the condition is to wait for (int32_t)(\*addr - value) >= 0, a cyclic
/// greater-or-equal. Other condition types can be specified via flags.
///
/// If the memory was registered via [`cuMemHostRegister_v2`], the device pointer should be obtained with [`cuMemHostGetDevicePointer_v2`]. This function cannot be used with managed memory ([`cuMemAllocManaged`]).
///
/// Support for [`CUstreamWaitValue_flags::CU_STREAM_WAIT_VALUE_NOR`] can be queried with [`cuDeviceGetAttribute`] and CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_WAIT_VALUE_NOR_V2.
///
/// Note:
///
/// Warning: Improper use of this API may deadlock the application. Synchronization ordering established through this API is not
/// visible to CUDA. CUDA tasks that are (even indirectly) ordered by this API should also have that order expressed with CUDA-visible
/// dependencies such as events. This ensures that the scheduler does not serialize them in an improper order.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamWaitValue64_v2`], [`cuStreamWriteValue32_v2`], [`cuStreamWriteValue64_v2`], [`cuStreamBatchMemOp_v2`], [`cuMemHostRegister_v2`], [`cuStreamWaitEvent`].
///
/// # Parameters
///
/// - `stream`: The stream to synchronize on the memory location.
/// - `addr`: The memory location to wait on.
/// - `value`: The value to compare with the memory location.
/// - `flags`: See `CUstreamWaitValue_flags`.
pub fn cuStreamWaitValue32_v2(
stream: CUstream,
addr: CUdeviceptr,
value: cuuint32_t,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Wait on a memory location.
///
/// Enqueues a synchronization of the stream on the given memory location. Work ordered after the operation will block until the
/// given condition on the memory is satisfied. By default, the condition is to wait for (int64_t)(\*addr - value) >= 0, a cyclic
/// greater-or-equal. Other condition types can be specified via flags.
///
/// If the memory was registered via [`cuMemHostRegister_v2`], the device pointer should be obtained with [`cuMemHostGetDevicePointer_v2`].
///
/// Support for this can be queried with [`cuDeviceGetAttribute`] and [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS`].
///
/// Note:
///
/// Warning: Improper use of this API may deadlock the application. Synchronization ordering established through this API is not
/// visible to CUDA. CUDA tasks that are (even indirectly) ordered by this API should also have that order expressed with CUDA-visible
/// dependencies such as events. This ensures that the scheduler does not serialize them in an improper order.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamWaitValue32_v2`], [`cuStreamWriteValue32_v2`], [`cuStreamWriteValue64_v2`], [`cuStreamBatchMemOp_v2`], [`cuMemHostRegister_v2`], [`cuStreamWaitEvent`].
///
/// # Parameters
///
/// - `stream`: The stream to synchronize on the memory location.
/// - `addr`: The memory location to wait on.
/// - `value`: The value to compare with the memory location.
/// - `flags`: See `CUstreamWaitValue_flags`.
pub fn cuStreamWaitValue64_v2(
stream: CUstream,
addr: CUdeviceptr,
value: cuuint64_t,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Write a value to memory.
///
/// Write a value to memory.
///
/// If the memory was registered via [`cuMemHostRegister_v2`], the device pointer should be obtained with [`cuMemHostGetDevicePointer_v2`]. This function cannot be used with managed memory ([`cuMemAllocManaged`]).
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamWriteValue64_v2`], [`cuStreamWaitValue32_v2`], [`cuStreamWaitValue64_v2`], [`cuStreamBatchMemOp_v2`], [`cuMemHostRegister_v2`], [`cuEventRecord`].
///
/// # Parameters
///
/// - `stream`: The stream to do the write in.
/// - `addr`: The device address to write to.
/// - `value`: The value to write.
/// - `flags`: See `CUstreamWriteValue_flags`.
pub fn cuStreamWriteValue32_v2(
stream: CUstream,
addr: CUdeviceptr,
value: cuuint32_t,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Write a value to memory.
///
/// Write a value to memory.
///
/// If the memory was registered via [`cuMemHostRegister_v2`], the device pointer should be obtained with [`cuMemHostGetDevicePointer_v2`].
///
/// Support for this can be queried with [`cuDeviceGetAttribute`] and [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamWriteValue32_v2`], [`cuStreamWaitValue32_v2`], [`cuStreamWaitValue64_v2`], [`cuStreamBatchMemOp_v2`], [`cuMemHostRegister_v2`], [`cuEventRecord`].
///
/// # Parameters
///
/// - `stream`: The stream to do the write in.
/// - `addr`: The device address to write to.
/// - `value`: The value to write.
/// - `flags`: See `CUstreamWriteValue_flags`.
pub fn cuStreamWriteValue64_v2(
stream: CUstream,
addr: CUdeviceptr,
value: cuuint64_t,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Batch operations to synchronize the stream via memory operations.
///
/// This is a batch version of [`cuStreamWaitValue32_v2`] and [`cuStreamWriteValue32_v2`]. Batching operations may avoid some performance overhead in both the API call and the device execution versus adding them
/// to the stream in separate API calls. The operations are enqueued in the order they appear in the array.
///
/// See `CUstreamBatchMemOpType` for the full set of supported operations, and [`cuStreamWaitValue32_v2`], [`cuStreamWaitValue64_v2`], [`cuStreamWriteValue32_v2`], and [`cuStreamWriteValue64_v2`] for details of specific operations.
///
/// See related APIs for details on querying support for specific operations.
///
/// Note:
///
/// Warning: Improper use of this API may deadlock the application. Synchronization ordering established through this API is not
/// visible to CUDA. CUDA tasks that are (even indirectly) ordered by this API should also have that order expressed with CUDA-visible
/// dependencies such as events. This ensures that the scheduler does not serialize them in an improper order.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamWaitValue32_v2`], [`cuStreamWaitValue64_v2`], [`cuStreamWriteValue32_v2`], [`cuStreamWriteValue64_v2`], [`cuMemHostRegister_v2`].
///
/// # Parameters
///
/// - `stream`: The stream to enqueue the operations in.
/// - `count`: The number of operations in the array. Must be less than 256.
/// - `paramArray`: The types and parameters of the individual operations.
/// - `flags`: Reserved for future expansion; must be 0.
pub fn cuStreamBatchMemOp_v2(
stream: CUstream,
count: ::core::ffi::c_uint,
paramArray: *mut CUstreamBatchMemOpParams,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Returns information about a function.
///
/// Returns in \*pi the integer value of the attribute attrib on the kernel given by hfunc. The supported attributes are:
///
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK`]: The maximum number of threads per block, beyond which a launch of the function would fail. This number depends on both the
/// function and the device on which the function is currently loaded.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES`]: The size in bytes of statically-allocated shared memory per block required by this function. This does not include dynamically-allocated
/// shared memory requested by the user at runtime.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES`]: The size in bytes of user-allocated constant memory required by this function.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES`]: The size in bytes of local memory used by each thread of this function.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_NUM_REGS`]: The number of registers used by each thread of this function.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_PTX_VERSION`]: The PTX virtual architecture version for which the function was compiled. This value is the major PTX version \* 10 + the
/// minor PTX version, so a PTX version 1.3 function would return the value 13. Note that this may return the undefined value
/// of 0 for cubins compiled prior to CUDA 3.0.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_BINARY_VERSION`]: The binary architecture version for which the function was compiled. This value is the major binary version \* 10 + the minor
/// binary version, so a binary version 1.3 function would return the value 13. Note that this will return a value of 10 for legacy
/// cubins that do not have a properly-encoded binary architecture version.
/// * CU_FUNC_CACHE_MODE_CA: The attribute to indicate whether the function has been compiled with user specified option "-Xptxas
/// --dlcm=ca" set .
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES`]: The maximum size in bytes of dynamically-allocated shared memory.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT`]: Preferred shared memory-L1 cache split ratio in percent of total shared memory.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CLUSTER_SIZE_MUST_BE_SET`]: If this attribute is set, the kernel must launch with a valid cluster size specified.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH`]: The required cluster width in blocks.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT`]: The required cluster height in blocks.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH`]: The required cluster depth in blocks.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED`]: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. A non-portable
/// cluster size may only function on the specific SKUs the program is tested on. The launch might fail if the program is run
/// on a different hardware platform. CUDA API provides cudaOccupancyMaxActiveClusters to assist with checking whether the desired
/// size can be launched on the current device. A portable cluster size is guaranteed to be functional on all compute capabilities
/// higher than the target compute capability. The portable cluster size for sm_90 is 8 blocks per cluster. This value may increase
/// for future compute capabilities. The specific hardware unit may support higher cluster sizes that’s not guaranteed to be portable.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE`]: The block scheduling policy of a function. The value type is CUclusterSchedulingPolicy.
///
/// With a few execeptions, function attributes may also be queried on unloaded function handles returned from [`cuModuleEnumerateFunctions`]. [`cudaError_enum::CUDA_ERROR_FUNCTION_NOT_LOADED`] is returned if the attribute requires a fully loaded function but the function is not loaded. The loading state of a function
/// may be queried using cuFuncIsloaded. [`cuFuncLoad`] may be called to explicitly load a function before querying the following attributes that require the function to be loaded:
///
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK`]
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES`]
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES`]
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCacheConfig`], [`cuCtxSetCacheConfig`], [`cuFuncSetCacheConfig`], [`cuLaunchKernel`], [cudaFuncGetAttributes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g0e78e02c6d12ebddd4577ac6ebadf494), [cudaFuncSetAttribute](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g61085e9f04656b92573af16072bbc78d), [`cuFuncIsLoaded`], [`cuFuncLoad`], [`cuKernelGetAttribute`].
///
/// # Parameters
///
/// - `pi`: Returned attribute value.
/// - `attrib`: Attribute requested.
/// - `hfunc`: Function to query attribute of.
pub fn cuFuncGetAttribute(
pi: *mut ::core::ffi::c_int,
attrib: CUfunction_attribute,
hfunc: CUfunction,
) -> CUresult;
}
unsafe extern "C" {
/// Sets information about a function.
///
/// This call sets the value of a specified attribute attrib on the kernel given by hfunc to an integer value specified by val This function returns [`CUresult::CUDA_SUCCESS`] if the new value of the attribute could be successfully set. If the set fails, this call
/// will return an error. Not all attributes can have values set. Attempting to set a value on a read-only attribute will result
/// in an error ([`CUresult::CUDA_ERROR_INVALID_VALUE`])
///
/// Supported attributes for the cuFuncSetAttribute call are:
///
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES`]: This maximum size in bytes of dynamically-allocated shared memory. The value should contain the requested maximum size of
/// dynamically-allocated shared memory. The sum of this value and the function attribute [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES`] cannot exceed the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN`]. The maximal size of requestable dynamic shared memory may differ by GPU architecture.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT`]: On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference,
/// in percent of the total shared memory. See [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR`] This is only a hint, and the driver can choose a different ratio if required to execute the function.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH`]: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity
/// of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime.
/// Setting it at runtime will return [`CUresult::CUDA_ERROR_NOT_PERMITTED`].
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT`]: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The
/// validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at
/// runtime. Setting it at runtime will return [`CUresult::CUDA_ERROR_NOT_PERMITTED`].
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH`]: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity
/// of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime.
/// Setting it at runtime will return [`CUresult::CUDA_ERROR_NOT_PERMITTED`].
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED`]: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed.
/// * [`CUfunction_attribute_enum::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE`]: The block scheduling policy of a function. The value type is CUclusterSchedulingPolicy.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCacheConfig`], [`cuCtxSetCacheConfig`], [`cuFuncSetCacheConfig`], [`cuLaunchKernel`], [cudaFuncGetAttributes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g0e78e02c6d12ebddd4577ac6ebadf494), [cudaFuncSetAttribute](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g61085e9f04656b92573af16072bbc78d), [`cuKernelSetAttribute`].
///
/// # Parameters
///
/// - `hfunc`: Function to query attribute of.
/// - `attrib`: Attribute requested.
/// - `value`: The value to set.
pub fn cuFuncSetAttribute(
hfunc: CUfunction,
attrib: CUfunction_attribute,
value: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the preferred cache configuration for a device function.
///
/// On devices where the L1 cache and shared memory use the same hardware resources, this sets through config the preferred cache configuration for the device function hfunc. This is only a preference. The driver will use the requested configuration if possible, but it is free to choose a different
/// configuration if required to execute hfunc. Any context-wide preference set via [`cuCtxSetCacheConfig`] will be overridden by this per-function setting unless the per-function setting is [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_NONE`]. In that case, the current context-wide setting will be used.
///
/// This setting does nothing on devices where the size of the L1 cache and shared memory are fixed.
///
/// Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization
/// point.
///
/// The supported cache configurations are:
///
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_NONE`]: no preference for shared memory or L1 (default)
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_SHARED`]: prefer larger shared memory and smaller L1 cache
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_L1`]: prefer larger L1 cache and smaller shared memory
/// * [`CUfunc_cache_enum::CU_FUNC_CACHE_PREFER_EQUAL`]: prefer equal sized L1 cache and shared memory
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCacheConfig`], [`cuCtxSetCacheConfig`], [`cuFuncGetAttribute`], [`cuLaunchKernel`], [cudaFuncSetCacheConfig](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g7d9cc996fe45b6260ebb086caff1c685), [`cuKernelSetCacheConfig`].
///
/// # Parameters
///
/// - `hfunc`: Kernel to configure cache for.
/// - `config`: Requested cache configuration.
pub fn cuFuncSetCacheConfig(hfunc: CUfunction, config: CUfunc_cache) -> CUresult;
}
unsafe extern "C" {
/// Returns a module handle.
///
/// Returns in \*hmod the handle of the module that function hfunc is located in. The lifetime of the module corresponds to the lifetime of the context it was loaded in or until the module
/// is explicitly unloaded.
///
/// The CUDA runtime manages its own modules loaded into the primary context. If the handle returned by this API refers to a module
/// loaded by the CUDA runtime, calling [`cuModuleUnload`] on that module will result in undefined behavior.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `hmod`: Returned module handle.
/// - `hfunc`: Function to retrieve module for.
pub fn cuFuncGetModule(hmod: *mut CUmodule, hfunc: CUfunction) -> CUresult;
}
unsafe extern "C" {
/// Returns the function name for a CUfunction handle.
///
/// Returns in \*\*name the function name associated with the function handle hfunc . The function name is returned as a null-terminated string. The returned name is only valid when the function handle is
/// valid. If the module is unloaded or reloaded, one must call the API again to get the updated name. This API may return a mangled
/// name if the function is not declared as having C linkage. If either \*\*name or hfunc is NULL, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `name`: The returned name of the function.
/// - `hfunc`: The function handle to retrieve the name for.
pub fn cuFuncGetName(
name: *mut *const ::core::ffi::c_char,
hfunc: CUfunction,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the offset and size of a kernel parameter in the device-side parameter layout.
///
/// Queries the kernel parameter at paramIndex into func's list of parameters, and returns in paramOffset and paramSize the offset and size, respectively, where the parameter will reside in the device-side parameter layout. This information
/// can be used to update kernel node parameters from the device via [cudaGraphKernelNodeSetParam()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g0c2bd161eff1e47531eedce282e66d21) and [cudaGraphKernelNodeUpdatesApply()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g2d558cf37c9616365c67447e61ac0d6a). paramIndex must be less than the number of parameters that func takes. paramSize can be set to NULL if only the parameter offset is desired.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuKernelGetParamInfo`].
///
/// # Parameters
///
/// - `func`: The function to query.
/// - `paramIndex`: The parameter index to query.
/// - `paramOffset`: Returns the offset into the device-side parameter layout at which the parameter resides.
/// - `paramSize`: Optionally returns the size of the parameter in the device-side parameter layout.
pub fn cuFuncGetParamInfo(
func: CUfunction,
paramIndex: size_t,
paramOffset: *mut size_t,
paramSize: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the number of parameters used by the function.
///
/// Queries the number of kernel parameters used by func and returns it in paramCount.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncGetParamInfo`].
///
/// # Parameters
///
/// - `func`: The function to query.
/// - `paramCount`: Returns the number of parameters used by the function.
pub fn cuFuncGetParamCount(func: CUfunction, paramCount: *mut size_t) -> CUresult;
}
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUfunctionLoadingState_enum {
CU_FUNCTION_LOADING_STATE_UNLOADED = 0,
CU_FUNCTION_LOADING_STATE_LOADED = 1,
CU_FUNCTION_LOADING_STATE_MAX = 2,
}
pub use self::CUfunctionLoadingState_enum as CUfunctionLoadingState;
unsafe extern "C" {
/// Returns if the function is loaded.
///
/// Returns in state the loading state of function.
///
/// **See also:**
///
/// [`cuFuncLoad`], [`cuModuleEnumerateFunctions`].
///
/// # Parameters
///
/// - `state`: returned loading state.
/// - `function`: the function to check.
pub fn cuFuncIsLoaded(
state: *mut CUfunctionLoadingState,
function: CUfunction,
) -> CUresult;
}
unsafe extern "C" {
/// Loads a function.
///
/// Finalizes function loading for function. Calling this API with a fully loaded function has no effect.
///
/// **See also:**
///
/// [`cuModuleEnumerateFunctions`], [`cuFuncIsLoaded`].
///
/// # Parameters
///
/// - `function`: the function to load.
pub fn cuFuncLoad(function: CUfunction) -> CUresult;
}
unsafe extern "C" {
/// Launches a CUDA function CUfunction or a CUDA kernel CUkernel.
///
/// Invokes the function [`CUfunction`] or the kernel [`CUkernel`]f on a gridDimX x gridDimY x gridDimZ grid of blocks. Each block contains blockDimX x blockDimY x blockDimZ threads.
///
/// sharedMemBytes sets the amount of dynamic shared memory that will be available to each thread block.
///
/// Kernel parameters to f can be specified in one of two ways:
///
/// 1) Kernel parameters can be specified via kernelParams. If f has N parameters, then kernelParams needs to be an array of N pointers. Each of kernelParams\[0\] through kernelParams\[N-1\] must point to a region of memory from which the actual kernel parameter will be copied. The number of kernel parameters
/// and their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel's image.
///
/// 2) Kernel parameters can also be packaged by the application into a single buffer that is passed in via the extra parameter. This places the burden on the application of knowing each kernel parameter's size and alignment/padding within
/// the buffer. Here is an example of using the extra parameter in this manner:
///
/// ```text
/// size_t argBufferSize;
/// char argBuffer\[256\];
///
/// // populate argBuffer and argBufferSize
///
/// void *config[] = {
/// CU_LAUNCH_PARAM_BUFFER_POINTER, argBuffer,
/// CU_LAUNCH_PARAM_BUFFER_SIZE, &argBufferSize,
/// CU_LAUNCH_PARAM_END
/// };
/// status = cuLaunchKernel(f, gx, gy, gz, bx, by, bz, sh, s, NULL, config);
/// ```
///
/// The extra parameter exists to allow [`cuLaunchKernel`] to take additional less commonly used arguments. extra specifies a list of names of extra settings and their corresponding values. Each extra setting name is immediately followed
/// by the corresponding value. The list must be terminated with either NULL or `CU_LAUNCH_PARAM_END`.
///
/// * `CU_LAUNCH_PARAM_END`, which indicates the end of the extra array;
/// * `CU_LAUNCH_PARAM_BUFFER_POINTER`, which specifies that the next value in extra will be a pointer to a buffer containing all the kernel parameters for launching kernel f;
/// * `CU_LAUNCH_PARAM_BUFFER_SIZE`, which specifies that the next value in extra will be a pointer to a size_t containing the size of the buffer specified with `CU_LAUNCH_PARAM_BUFFER_POINTER`;
///
/// The error [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] will be returned if kernel parameters are specified with both kernelParams and extra (i.e. both kernelParams and extra are non-NULL).
///
/// Calling [`cuLaunchKernel`] invalidates the persistent function state set through the following deprecated APIs: [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuParamSetSize`], [`cuParamSeti`], [`cuParamSetf`], [`cuParamSetv`].
///
/// Note that to use [`cuLaunchKernel`], the kernel f must either have been compiled with toolchain version 3.2 or later so that it will contain kernel parameter information,
/// or have no kernel parameters. If either of these conditions is not met, then [`cuLaunchKernel`] will return [`cudaError_enum::CUDA_ERROR_INVALID_IMAGE`].
///
/// Note that the API can also be used to launch context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to launch the kernel on will either be taken from the specified stream hStream or the current context in case of NULL stream.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCacheConfig`], [`cuCtxSetCacheConfig`], [`cuFuncSetCacheConfig`], [`cuFuncGetAttribute`], [cudaLaunchKernel](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g2c91bfe5e072fcd28de6606dd43cd64b), [`cuLibraryGetKernel`], [`cuKernelSetCacheConfig`], [`cuKernelGetAttribute`], [`cuKernelSetAttribute`].
///
/// # Parameters
///
/// - `f`: Function [`CUfunction`] or Kernel [`CUkernel`] to launch.
/// - `gridDimX`: Width of grid in blocks.
/// - `gridDimY`: Height of grid in blocks.
/// - `gridDimZ`: Depth of grid in blocks.
/// - `blockDimX`: X dimension of each thread block.
/// - `blockDimY`: Y dimension of each thread block.
/// - `blockDimZ`: Z dimension of each thread block.
/// - `sharedMemBytes`: Dynamic shared-memory size per thread block in bytes.
/// - `hStream`: Stream identifier.
/// - `kernelParams`: Array of pointers to kernel parameters.
/// - `extra`: Extra options.
pub fn cuLaunchKernel(
f: CUfunction,
gridDimX: ::core::ffi::c_uint,
gridDimY: ::core::ffi::c_uint,
gridDimZ: ::core::ffi::c_uint,
blockDimX: ::core::ffi::c_uint,
blockDimY: ::core::ffi::c_uint,
blockDimZ: ::core::ffi::c_uint,
sharedMemBytes: ::core::ffi::c_uint,
hStream: CUstream,
kernelParams: *mut *mut ::core::ffi::c_void,
extra: *mut *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Launches a CUDA function CUfunction or a CUDA kernel CUkernel with launch-time configuration.
///
/// Invokes the function [`CUfunction`] or the kernel [`CUkernel`]f with the specified launch-time configuration config.
///
/// The [`CUlaunchConfig`] structure is defined as:
///
/// ```text
/// typedef struct CUlaunchConfig_st {
/// unsigned int gridDimX;
/// unsigned int gridDimY;
/// unsigned int gridDimZ;
/// unsigned int blockDimX;
/// unsigned int blockDimY;
/// unsigned int blockDimZ;
/// unsigned int sharedMemBytes;
/// CUstream hStream;
/// CUlaunchAttribute *attrs;
/// unsigned int numAttrs;
/// } CUlaunchConfig;
/// ```
///
/// where:
///
/// * [CUlaunchConfig::gridDimX](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_1689d9cc16fd423b080ec828b5bc9d885) is the width of the grid in blocks.
/// * [CUlaunchConfig::gridDimY](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_18c2c6a003a635f55703d3e00873c1a04) is the height of the grid in blocks.
/// * [CUlaunchConfig::gridDimZ](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_12ee1e4c17d2976638d5c1def7aab2173) is the depth of the grid in blocks.
/// * [CUlaunchConfig::blockDimX](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_1c6348b2aec5d4cbe883351f0a4ca2404) is the X dimension of each thread block.
/// * [CUlaunchConfig::blockDimX](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_1c6348b2aec5d4cbe883351f0a4ca2404) is the Y dimension of each thread block.
/// * [CUlaunchConfig::blockDimZ](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_114969c04364799742f22a4eb97501f75) is the Z dimension of each thread block.
/// * [CUlaunchConfig::sharedMemBytes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_139281cdd7b80edb790b0fa85b2bca38f) is the dynamic shared-memory size per thread block in bytes.
/// * [CUlaunchConfig::hStream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_18bbdd01ea0d4d380fad9e8be14fb928b) is the handle to the stream to perform the launch in. The CUDA context associated with this stream must match that associated
/// with function f.
/// * [CUlaunchConfig::attrs](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_189bd86e2a9d67c421d5ad9650e57f375) is an array of [CUlaunchConfig::numAttrs](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_1c64a4dd37ff79255de128a5868658e06) continguous [`CUlaunchAttribute`] elements. The value of this pointer is not considered if [CUlaunchConfig::numAttrs](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_1c64a4dd37ff79255de128a5868658e06) is zero. However, in that case, it is recommended to set the pointer to NULL.
/// * [CUlaunchConfig::numAttrs](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_1c64a4dd37ff79255de128a5868658e06) is the number of attributes populating the first [CUlaunchConfig::numAttrs](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_1c64a4dd37ff79255de128a5868658e06) positions of the [CUlaunchConfig::attrs](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_189bd86e2a9d67c421d5ad9650e57f375) array.
///
/// Launch-time configuration is specified by adding entries to [CUlaunchConfig::attrs](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_189bd86e2a9d67c421d5ad9650e57f375). Each entry is an attribute ID and a corresponding attribute value.
///
/// The [`CUlaunchAttribute`] structure is defined as:
///
/// ```text
/// typedef struct CUlaunchAttribute_st {
/// CUlaunchAttributeID id;
/// CUlaunchAttributeValue value;
/// } CUlaunchAttribute;
/// ```
///
/// * [CUlaunchAttribute::id](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchAttribute.html#structCUlaunchAttribute_132aed095f6c0ffe51ea05d61ee83a5df) is a unique enum identifying the attribute.
/// * [CUlaunchAttribute::value](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchAttribute.html#structCUlaunchAttribute_1924768cf94d6cf1d94691d30e491fc55) is a union that hold the attribute value.
///
/// An example of using the config parameter:
///
/// ```text
/// CUlaunchAttribute coopAttr = {.id = CU_LAUNCH_ATTRIBUTE_COOPERATIVE,
/// .value = 1};
/// CUlaunchConfig config = {... // set block and grid dimensions
/// .attrs = &coopAttr,
/// .numAttrs = 1};
///
/// cuLaunchKernelEx(&config, kernel, NULL, NULL);
/// ```
///
/// The `CUlaunchAttributeID` enum is defined as:
///
/// ```text
/// typedef enum CUlaunchAttributeID_enum {
/// CU_LAUNCH_ATTRIBUTE_IGNORE = 0,
/// CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW = 1,
/// CU_LAUNCH_ATTRIBUTE_COOPERATIVE = 2,
/// CU_LAUNCH_ATTRIBUTE_SYNCHRONIZATION_POLICY = 3,
/// CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION = 4,
/// CU_LAUNCH_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE = 5,
/// CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION = 6,
/// CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT = 7,
/// CU_LAUNCH_ATTRIBUTE_PRIORITY = 8,
/// CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP = 9,
/// CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN = 10,
/// CU_LAUNCH_ATTRIBUTE_PREFERRED_CLUSTER_DIMENSION = 11,
/// CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT = 12,
/// CU_LAUNCH_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE = 13,
/// } CUlaunchAttributeID;
/// ```
///
/// and the corresponding [`CUlaunchAttributeValue`] union as :
///
/// ```text
/// typedef union CUlaunchAttributeValue_union {
/// CUaccessPolicyWindow accessPolicyWindow;
/// int cooperative;
/// CUsynchronizationPolicy syncPolicy;
/// struct {
/// unsigned int x;
/// unsigned int y;
/// unsigned int z;
/// } clusterDim;
/// CUclusterSchedulingPolicy clusterSchedulingPolicyPreference;
/// int programmaticStreamSerializationAllowed;
/// struct {
/// CUevent event;
/// int flags;
/// int triggerAtBlockStart;
/// } programmaticEvent;
/// int priority;
/// CUlaunchMemSyncDomainMap memSyncDomainMap;
/// CUlaunchMemSyncDomain memSyncDomain;
/// struct {
/// unsigned int x;
/// unsigned int y;
/// unsigned int z;
/// } preferredClusterDim;
/// struct {
/// CUevent event;
/// int flags;
/// } launchCompletionEvent;
/// struct {
/// int deviceUpdatable;
/// CUgraphDeviceNode devNode;
/// } deviceUpdatableKernelNode;
/// } CUlaunchAttributeValue;
/// ```
///
/// Setting [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_COOPERATIVE`] to a non-zero value causes the kernel launch to be a cooperative launch, with exactly the same usage and semantics of [`cuLaunchCooperativeKernel`].
///
/// Setting [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION`] to a non-zero values causes the kernel to use programmatic means to resolve its stream dependency -- enabling the CUDA runtime
/// to opportunistically allow the grid's execution to overlap with the previous kernel in the stream, if that kernel requests
/// the overlap.
///
/// [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT`] records an event along with the kernel launch. Event recorded through this launch attribute is guaranteed to only trigger
/// after all block in the associated kernel trigger the event. A block can trigger the event through PTX launchdep.release or
/// CUDA builtin function [cudaTriggerProgrammaticLaunchCompletion()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EXECUTION.html#group__CUDART__EXECUTION_1ge194af462d927583bed3acf60d450218). A trigger can also be inserted at the beginning of each block's execution if triggerAtBlockStart is set to non-0. Note that
/// dependents (including the CPU thread calling [`cuEventSynchronize`]) are not guaranteed to observe the release precisely when it is released. For example, [`cuEventSynchronize`] may only observe the event trigger long after the associated kernel has completed. This recording type is primarily meant
/// for establishing programmatic dependency between device tasks. The event supplied must not be an interprocess or interop event.
/// The event must disable timing (i.e. created with [`CUevent_flags_enum::CU_EVENT_DISABLE_TIMING`] flag set).
///
/// [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT`] records an event along with the kernel launch. Nominally, the event is triggered once all blocks of the kernel have begun
/// execution. Currently this is a best effort. If a kernel B has a launch completion dependency on a kernel A, B may wait until
/// A is complete. Alternatively, blocks of B may begin before all blocks of A have begun, for example:
///
/// * If B can claim execution resources unavailable to A, for example if they run on different GPUs.
/// * If B is a higher priority than A.
///
/// Exercise caution if such an ordering inversion could lead to deadlock. The event supplied must not be an interprocess or interop
/// event. The event must disable timing (i.e. must be created with the [`CUevent_flags_enum::CU_EVENT_DISABLE_TIMING`] flag set).
///
/// Setting [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE`] to 1 on a captured launch causes the resulting kernel node to be device-updatable. This attribute is specific to graphs,
/// and passing it to a launch in a non-capturing stream results in an error. Passing a value other than 0 or 1 is not allowed.
///
/// On success, a handle will be returned via CUlaunchAttributeValue::deviceUpdatableKernelNode::devNode which can be passed to
/// the various device-side update functions to update the node's kernel parameters from within another kernel. For more information
/// on the types of device updates that can be made, as well as the relevant limitations thereof, see [cudaGraphKernelNodeUpdatesApply](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g2d558cf37c9616365c67447e61ac0d6a).
///
/// Kernel nodes which are device-updatable have additional restrictions compared to regular kernel nodes. Firstly, device-updatable
/// nodes cannot be removed from their graph via [`cuGraphDestroyNode`]. Additionally, once opted-in to this functionality, a node cannot opt out, and any attempt to set the attribute to 0 will
/// result in an error. Graphs containing one or more device-updatable node also do not allow multiple instantiation.
///
/// [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_PREFERRED_CLUSTER_DIMENSION`] allows the kernel launch to specify a preferred substitute cluster dimension. Blocks may be grouped according to either the
/// dimensions specified with this attribute (grouped into a "preferred substitute cluster"), or the one specified with [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION`] attribute (grouped into a "regular cluster"). The cluster dimensions of a "preferred substitute cluster" shall be an integer
/// multiple greater than zero of the regular cluster dimensions. The device will attempt - on a best-effort basis - to group
/// thread blocks into preferred clusters over grouping them into regular clusters. When it deems necessary (primarily when the
/// device temporarily runs out of physical resources to launch the larger preferred clusters), the device may switch to launch
/// the regular clusters instead to attempt to utilize as much of the physical device resources as possible.
///
/// Each type of cluster will have its enumeration / coordinate setup as if the grid consists solely of its type of cluster. For
/// example, if the preferred substitute cluster dimensions double the regular cluster dimensions, there might be simultaneously
/// a regular cluster indexed at (1,0,0), and a preferred cluster indexed at (1,0,0). In this example, the preferred substitute
/// cluster (1,0,0) replaces regular clusters (2,0,0) and (3,0,0) and groups their blocks.
///
/// This attribute will only take effect when a regular cluster dimension has been specified. The preferred substitute The preferred
/// substitute cluster dimension must be an integer multiple greater than zero of the regular cluster dimension and must divide
/// the grid. It must also be no more than `maxBlocksPerCluster`, if it is set in the kernel's `__launch_bounds__`. Otherwise
/// it must be less than the maximum value the driver can support. Otherwise, setting this attribute to a value physically unable
/// to fit on any particular device is permitted.
///
/// The effect of other attributes is consistent with their effect when set via persistent APIs.
///
/// See [`cuStreamSetAttribute`] for
///
/// * [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW`]
/// * [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_SYNCHRONIZATION_POLICY`]
///
/// See [`cuFuncSetAttribute`] for
///
/// * [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION`]
/// * [`CUlaunchAttributeID_enum::CU_LAUNCH_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE`]
///
/// Kernel parameters to f can be specified in the same ways that they can be using [`cuLaunchKernel`].
///
/// Note that the API can also be used to launch context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to launch the kernel on will either be taken from the specified stream [CUlaunchConfig::hStream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUlaunchConfig.html#structCUlaunchConfig_18bbdd01ea0d4d380fad9e8be14fb928b) or the current context in case of NULL stream.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCacheConfig`], [`cuCtxSetCacheConfig`], [`cuFuncSetCacheConfig`], [`cuFuncGetAttribute`], [cudaLaunchKernel](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g2c91bfe5e072fcd28de6606dd43cd64b), [cudaLaunchKernelEx](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g98d60efe48c3400a1c17a1edb698e530), [`cuLibraryGetKernel`], [`cuKernelSetCacheConfig`], [`cuKernelGetAttribute`], [`cuKernelSetAttribute`].
///
/// # Parameters
///
/// - `config`: Config to launch.
/// - `f`: Function [`CUfunction`] or Kernel [`CUkernel`] to launch.
/// - `kernelParams`: Array of pointers to kernel parameters.
/// - `extra`: Extra options.
pub fn cuLaunchKernelEx(
config: *const CUlaunchConfig,
f: CUfunction,
kernelParams: *mut *mut ::core::ffi::c_void,
extra: *mut *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Launches a CUDA function CUfunction or a CUDA kernel CUkernel where thread blocks can cooperate and synchronize as they execute.
///
/// Invokes the function [`CUfunction`] or the kernel [`CUkernel`]f on a gridDimX x gridDimY x gridDimZ grid of blocks. Each block contains blockDimX x blockDimY x blockDimZ threads.
///
/// sharedMemBytes sets the amount of dynamic shared memory that will be available to each thread block.
///
/// The device on which this kernel is invoked must have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_COOPERATIVE_LAUNCH`].
///
/// The total number of blocks launched cannot exceed the maximum number of blocks per multiprocessor as returned by [`cuOccupancyMaxActiveBlocksPerMultiprocessor`] (or [`cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags`]) times the number of multiprocessors as specified by the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT`].
///
/// The kernel cannot make use of CUDA dynamic parallelism.
///
/// Kernel parameters must be specified via kernelParams. If f has N parameters, then kernelParams needs to be an array of N pointers. Each of kernelParams\[0\] through kernelParams\[N-1\] must point to a region of memory from which the actual kernel parameter will be copied. The number of kernel parameters
/// and their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel's image.
///
/// Calling [`cuLaunchCooperativeKernel`] sets persistent function state that is the same as function state set through [`cuLaunchKernel`] API
///
/// When the kernel f is launched via [`cuLaunchCooperativeKernel`], the previous block shape, shared size and parameter info associated with f is overwritten.
///
/// Note that to use [`cuLaunchCooperativeKernel`], the kernel f must either have been compiled with toolchain version 3.2 or later so that it will contain kernel parameter information,
/// or have no kernel parameters. If either of these conditions is not met, then [`cuLaunchCooperativeKernel`] will return [`cudaError_enum::CUDA_ERROR_INVALID_IMAGE`].
///
/// Note that the API can also be used to launch context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to launch the kernel on will either be taken from the specified stream hStream or the current context in case of NULL stream.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCacheConfig`], [`cuCtxSetCacheConfig`], [`cuFuncSetCacheConfig`], [`cuFuncGetAttribute`], [`cuLaunchCooperativeKernelMultiDevice`], [cudaLaunchCooperativeKernel](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g7c4cb6c44a6c4608da36c44374499b31), [`cuLibraryGetKernel`], [`cuKernelSetCacheConfig`], [`cuKernelGetAttribute`], [`cuKernelSetAttribute`].
///
/// # Parameters
///
/// - `f`: Function [`CUfunction`] or Kernel [`CUkernel`] to launch.
/// - `gridDimX`: Width of grid in blocks.
/// - `gridDimY`: Height of grid in blocks.
/// - `gridDimZ`: Depth of grid in blocks.
/// - `blockDimX`: X dimension of each thread block.
/// - `blockDimY`: Y dimension of each thread block.
/// - `blockDimZ`: Z dimension of each thread block.
/// - `sharedMemBytes`: Dynamic shared-memory size per thread block in bytes.
/// - `hStream`: Stream identifier.
/// - `kernelParams`: Array of pointers to kernel parameters.
pub fn cuLaunchCooperativeKernel(
f: CUfunction,
gridDimX: ::core::ffi::c_uint,
gridDimY: ::core::ffi::c_uint,
gridDimZ: ::core::ffi::c_uint,
blockDimX: ::core::ffi::c_uint,
blockDimY: ::core::ffi::c_uint,
blockDimZ: ::core::ffi::c_uint,
sharedMemBytes: ::core::ffi::c_uint,
hStream: CUstream,
kernelParams: *mut *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Launches CUDA functions on multiple devices where thread blocks can cooperate and synchronize as they execute.
///
/// Invokes kernels as specified in the launchParamsList array where each element of the array specifies all the parameters required to perform a single kernel launch. These kernels
/// can cooperate and synchronize as they execute. The size of the array is specified by numDevices.
///
/// No two kernels can be launched on the same device. All the devices targeted by this multi-device launch must be identical.
/// All devices must have a non-zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_COOPERATIVE_MULTI_DEVICE_LAUNCH`].
///
/// All kernels launched must be identical with respect to the compiled code. Note that any __device__, __constant__ or __managed__
/// variables present in the module that owns the kernel launched on each device, are independently instantiated on every device.
/// It is the application's responsibility to ensure these variables are initialized and used appropriately.
///
/// The size of the grids as specified in blocks, the size of the blocks themselves and the amount of shared memory used by each
/// thread block must also match across all launched kernels.
///
/// The streams used to launch these kernels must have been created via either [`cuStreamCreate`] or [`cuStreamCreateWithPriority`]. The NULL stream or `CU_STREAM_LEGACY` or `CU_STREAM_PER_THREAD` cannot be used.
///
/// The total number of blocks launched per kernel cannot exceed the maximum number of blocks per multiprocessor as returned by
/// [`cuOccupancyMaxActiveBlocksPerMultiprocessor`] (or [`cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags`]) times the number of multiprocessors as specified by the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT`]. Since the total number of blocks launched per device has to match across all devices, the maximum number of blocks that
/// can be launched per device will be limited by the device with the least number of multiprocessors.
///
/// The kernels cannot make use of CUDA dynamic parallelism.
///
/// The CUDA_LAUNCH_PARAMS structure is defined as:
///
/// ```text
/// typedef struct CUDA_LAUNCH_PARAMS_st
/// {
/// CUfunction function;
/// unsigned int gridDimX;
/// unsigned int gridDimY;
/// unsigned int gridDimZ;
/// unsigned int blockDimX;
/// unsigned int blockDimY;
/// unsigned int blockDimZ;
/// unsigned int sharedMemBytes;
/// CUstream hStream;
/// void **kernelParams;
/// } CUDA_LAUNCH_PARAMS;
/// ```
///
/// * [CUDA_LAUNCH_PARAMS::function](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_1ad25005328ba7debf0f5bd2d39a5363c) specifies the kernel to be launched. All functions must be identical with respect to the compiled code. Note that you can
/// also specify context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then casting to [`CUfunction`]. In this case, the context to launch the kernel on be taken from the specified stream [CUDA_LAUNCH_PARAMS::hStream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_1d7b7a742ef397fe918c18bf1f5e63576).
/// * [CUDA_LAUNCH_PARAMS::gridDimX](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_14328c3a1123bed3c08894d66ae9f0e8f) is the width of the grid in blocks. This must match across all kernels launched.
/// * [CUDA_LAUNCH_PARAMS::gridDimY](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_175e5d98e55ad9c877acf3511f9e4c6bc) is the height of the grid in blocks. This must match across all kernels launched.
/// * [CUDA_LAUNCH_PARAMS::gridDimZ](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_16e34c343c3dc355e93f3c47d5c3e3fbe) is the depth of the grid in blocks. This must match across all kernels launched.
/// * [CUDA_LAUNCH_PARAMS::blockDimX](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_1a31d64be7210f4f21404e89ed3c8bc09) is the X dimension of each thread block. This must match across all kernels launched.
/// * [CUDA_LAUNCH_PARAMS::blockDimX](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_1a31d64be7210f4f21404e89ed3c8bc09) is the Y dimension of each thread block. This must match across all kernels launched.
/// * [CUDA_LAUNCH_PARAMS::blockDimZ](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_1e35cc15ae81f10e20fc4c91dbc7356ea) is the Z dimension of each thread block. This must match across all kernels launched.
/// * [CUDA_LAUNCH_PARAMS::sharedMemBytes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_113811a872234e77c9903dd977f7c7ac3) is the dynamic shared-memory size per thread block in bytes. This must match across all kernels launched.
/// * [CUDA_LAUNCH_PARAMS::hStream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_1d7b7a742ef397fe918c18bf1f5e63576) is the handle to the stream to perform the launch in. This cannot be the NULL stream or `CU_STREAM_LEGACY` or `CU_STREAM_PER_THREAD`. The CUDA context associated with this stream must match that associated with [CUDA_LAUNCH_PARAMS::function](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_1ad25005328ba7debf0f5bd2d39a5363c).
/// * [CUDA_LAUNCH_PARAMS::kernelParams](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_16788671fda12351d95398142aa4c3bcd) is an array of pointers to kernel parameters. If [CUDA_LAUNCH_PARAMS::function](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_1ad25005328ba7debf0f5bd2d39a5363c) has N parameters, then [CUDA_LAUNCH_PARAMS::kernelParams](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_16788671fda12351d95398142aa4c3bcd) needs to be an array of N pointers. Each of [CUDA_LAUNCH_PARAMS::kernelParams](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_16788671fda12351d95398142aa4c3bcd)\[0\] through [CUDA_LAUNCH_PARAMS::kernelParams](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_16788671fda12351d95398142aa4c3bcd)\[N-1\] must point to a region of memory from which the actual kernel parameter will be copied. The number of kernel parameters
/// and their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel's image.
///
/// By default, the kernel won't begin execution on any GPU until all prior work in all the specified streams has completed. This
/// behavior can be overridden by specifying the flag [`CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_PRE_LAUNCH_SYNC`]. When this flag is specified, each kernel will only wait for prior work in the stream corresponding to that GPU to complete
/// before it begins execution.
///
/// Similarly, by default, any subsequent work pushed in any of the specified streams will not begin execution until the kernels
/// on all GPUs have completed. This behavior can be overridden by specifying the flag [`CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_POST_LAUNCH_SYNC`]. When this flag is specified, any subsequent work pushed in any of the specified streams will only wait for the kernel launched
/// on the GPU corresponding to that stream to complete before it begins execution.
///
/// Calling [`cuLaunchCooperativeKernelMultiDevice`] sets persistent function state that is the same as function state set through [`cuLaunchKernel`] API when called individually for each element in launchParamsList.
///
/// When kernels are launched via [`cuLaunchCooperativeKernelMultiDevice`], the previous block shape, shared size and parameter info associated with each [CUDA_LAUNCH_PARAMS::function](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__LAUNCH__PARAMS__v1.html#structCUDA__LAUNCH__PARAMS__v1_1ad25005328ba7debf0f5bd2d39a5363c) in launchParamsList is overwritten.
///
/// Note that to use [`cuLaunchCooperativeKernelMultiDevice`], the kernels must either have been compiled with toolchain version 3.2 or later so that it will contain kernel parameter
/// information, or have no kernel parameters. If either of these conditions is not met, then [`cuLaunchCooperativeKernelMultiDevice`] will return [`cudaError_enum::CUDA_ERROR_INVALID_IMAGE`].
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCacheConfig`], [`cuCtxSetCacheConfig`], [`cuFuncSetCacheConfig`], [`cuFuncGetAttribute`], [`cuLaunchCooperativeKernel`], cudaLaunchCooperativeKernelMultiDevice.
///
/// # Parameters
///
/// - `launchParamsList`: List of launch parameters, one per device.
/// - `numDevices`: Size of the launchParamsList array.
/// - `flags`: Flags to control launch behavior.
#[deprecated]
pub fn cuLaunchCooperativeKernelMultiDevice(
launchParamsList: *mut CUDA_LAUNCH_PARAMS,
numDevices: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Enqueues a host function call in a stream.
///
/// Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work
/// added after it.
///
/// The host function must not make any CUDA API calls. Attempting to use a CUDA API may result in [`cudaError_enum::CUDA_ERROR_NOT_PERMITTED`], but this is not required. The host function must not perform any synchronization that may depend on outstanding CUDA work
/// not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined
/// order and may be serialized.
///
/// For the purposes of Unified Memory, execution makes a number of guarantees:
///
/// * The stream is considered idle for the duration of the function's execution. Thus, for example, the function may always use
/// memory attached to the stream it was enqueued in.
/// * The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately
/// prior to the function. It thus synchronizes streams which have been "joined" prior to the function.
/// * Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and
/// stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added
/// to another stream, if the work has been ordered behind the function call with an event.
/// * Completion of the function does not cause a stream to become active except as described above. The stream will remain idle
/// if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without
/// device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end
/// of the stream.
///
/// Note that, in contrast to [`cuStreamAddCallback`], the function will not be called in the event of an error in the CUDA context.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamQuery`], [`cuStreamSynchronize`], [`cuStreamWaitEvent`], [`cuStreamDestroy_v2`], [`cuMemAllocManaged`], [`cuStreamAttachMemAsync`], [`cuStreamAddCallback`].
///
/// # Parameters
///
/// - `hStream`: Stream to enqueue function call in.
/// - `userData`: User-specified data to be passed to the function.
pub fn cuLaunchHostFunc(
hStream: CUstream,
fn_: CUhostFn,
userData: *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Enqueues a host function call in a stream.
///
/// Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work
/// added after it.
///
/// The host function must not make any CUDA API calls. Attempting to use a CUDA API may result in [`cudaError_enum::CUDA_ERROR_NOT_PERMITTED`], but this is not required. The host function must not perform any synchronization that may depend on outstanding CUDA work
/// not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined
/// order and may be serialized.
///
/// For the purposes of Unified Memory, execution makes a number of guarantees:
///
/// * The stream is considered idle for the duration of the function's execution. Thus, for example, the function may always use
/// memory attached to the stream it was enqueued in.
/// * The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately
/// prior to the function. It thus synchronizes streams which have been "joined" prior to the function.
/// * Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and
/// stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added
/// to another stream, if the work has been ordered behind the function call with an event.
/// * Completion of the function does not cause a stream to become active except as described above. The stream will remain idle
/// if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without
/// device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end
/// of the stream.
///
/// Note that, in contrast to [`cuStreamAddCallback`], the function will not be called in the event of an error in the CUDA context.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamCreate`], [`cuStreamQuery`], [`cuStreamSynchronize`], [`cuStreamWaitEvent`], [`cuStreamDestroy_v2`], [`cuMemAllocManaged`], [`cuStreamAttachMemAsync`], [`cuStreamAddCallback`].
///
/// # Parameters
///
/// - `hStream`: Stream to enqueue function call in.
/// - `userData`: User-specified data to be passed to the function.
/// - `syncMode`: Synchronization mode for the host function.
pub fn cuLaunchHostFunc_v2(
hStream: CUstream,
fn_: CUhostFn,
userData: *mut ::core::ffi::c_void,
syncMode: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the block-dimensions for the function.
///
/// x
///
/// y
///
/// z
///
/// hfunc
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncSetSharedSize`], [`cuFuncSetCacheConfig`], [`cuFuncGetAttribute`], [`cuParamSetSize`], [`cuParamSeti`], [`cuParamSetf`], [`cuParamSetv`], [`cuLaunch`], [`cuLaunchGrid`], [`cuLaunchGridAsync`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `hfunc`: Kernel to specify dimensions of.
/// - `x`: X dimension.
/// - `y`: Y dimension.
/// - `z`: Z dimension.
#[deprecated]
pub fn cuFuncSetBlockShape(
hfunc: CUfunction,
x: ::core::ffi::c_int,
y: ::core::ffi::c_int,
z: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the dynamic shared-memory size for the function.
///
/// bytes
///
/// hfunc
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncSetBlockShape`], [`cuFuncSetCacheConfig`], [`cuFuncGetAttribute`], [`cuParamSetSize`], [`cuParamSeti`], [`cuParamSetf`], [`cuParamSetv`], [`cuLaunch`], [`cuLaunchGrid`], [`cuLaunchGridAsync`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `hfunc`: Kernel to specify dynamic shared-memory size for.
/// - `bytes`: Dynamic shared-memory size per thread in bytes.
#[deprecated]
pub fn cuFuncSetSharedSize(
hfunc: CUfunction,
bytes: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the parameter size for the function.
///
/// numbytes
///
/// hfunc
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuFuncGetAttribute`], [`cuParamSetf`], [`cuParamSeti`], [`cuParamSetv`], [`cuLaunch`], [`cuLaunchGrid`], [`cuLaunchGridAsync`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `hfunc`: Kernel to set parameter size for.
/// - `numbytes`: Size of parameter list in bytes.
#[deprecated]
pub fn cuParamSetSize(hfunc: CUfunction, numbytes: ::core::ffi::c_uint) -> CUresult;
}
unsafe extern "C" {
/// Adds an integer parameter to the function's argument list.
///
/// hfunc
///
/// offset
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuFuncGetAttribute`], [`cuParamSetSize`], [`cuParamSetf`], [`cuParamSetv`], [`cuLaunch`], [`cuLaunchGrid`], [`cuLaunchGridAsync`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `hfunc`: Kernel to add parameter to.
/// - `offset`: Offset to add parameter to argument list.
/// - `value`: Value of parameter.
#[deprecated]
pub fn cuParamSeti(
hfunc: CUfunction,
offset: ::core::ffi::c_int,
value: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Adds a floating-point parameter to the function's argument list.
///
/// hfunc
///
/// offset
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuFuncGetAttribute`], [`cuParamSetSize`], [`cuParamSeti`], [`cuParamSetv`], [`cuLaunch`], [`cuLaunchGrid`], [`cuLaunchGridAsync`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `hfunc`: Kernel to add parameter to.
/// - `offset`: Offset to add parameter to argument list.
/// - `value`: Value of parameter.
#[deprecated]
pub fn cuParamSetf(
hfunc: CUfunction,
offset: ::core::ffi::c_int,
value: f32,
) -> CUresult;
}
unsafe extern "C" {
/// Adds arbitrary data to the function's argument list.
///
/// numbytes
///
/// ptr
///
/// hfunc
///
/// offset
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuFuncGetAttribute`], [`cuParamSetSize`], [`cuParamSetf`], [`cuParamSeti`], [`cuLaunch`], [`cuLaunchGrid`], [`cuLaunchGridAsync`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `hfunc`: Kernel to add data to.
/// - `offset`: Offset to add data to argument list.
/// - `ptr`: Pointer to arbitrary data.
/// - `numbytes`: Size of data to copy in bytes.
#[deprecated]
pub fn cuParamSetv(
hfunc: CUfunction,
offset: ::core::ffi::c_int,
ptr: *mut ::core::ffi::c_void,
numbytes: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Launches a CUDA function.
///
/// f
///
/// [`cuFuncSetBlockShape`]
///
/// The block shape, dynamic shared memory size, and parameter information must be set using [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuParamSetSize`], [`cuParamSeti`], [`cuParamSetf`], and [`cuParamSetv`] prior to calling this function.
///
/// Launching a function via [`cuLaunchKernel`] invalidates the function's block shape, dynamic shared memory size, and parameter information. After launching via cuLaunchKernel,
/// this state must be re-initialized prior to calling this function. Failure to do so results in undefined behavior.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuFuncGetAttribute`], [`cuParamSetSize`], [`cuParamSetf`], [`cuParamSeti`], [`cuParamSetv`], [`cuLaunchGrid`], [`cuLaunchGridAsync`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `f`: Kernel to launch.
#[deprecated]
pub fn cuLaunch(f: CUfunction) -> CUresult;
}
unsafe extern "C" {
/// Launches a CUDA function.
///
/// f
///
/// grid_width
///
/// grid_height
///
/// [`cuFuncSetBlockShape`]
///
/// The block shape, dynamic shared memory size, and parameter information must be set using [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuParamSetSize`], [`cuParamSeti`], [`cuParamSetf`], and [`cuParamSetv`] prior to calling this function.
///
/// Launching a function via [`cuLaunchKernel`] invalidates the function's block shape, dynamic shared memory size, and parameter information. After launching via cuLaunchKernel,
/// this state must be re-initialized prior to calling this function. Failure to do so results in undefined behavior.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuFuncGetAttribute`], [`cuParamSetSize`], [`cuParamSetf`], [`cuParamSeti`], [`cuParamSetv`], [`cuLaunch`], [`cuLaunchGridAsync`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `f`: Kernel to launch.
/// - `grid_width`: Width of grid in blocks.
/// - `grid_height`: Height of grid in blocks.
#[deprecated]
pub fn cuLaunchGrid(
f: CUfunction,
grid_width: ::core::ffi::c_int,
grid_height: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Launches a CUDA function.
///
/// f
///
/// grid_width
///
/// grid_height
///
/// [`cuFuncSetBlockShape`]
///
/// The block shape, dynamic shared memory size, and parameter information must be set using [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuParamSetSize`], [`cuParamSeti`], [`cuParamSetf`], and [`cuParamSetv`] prior to calling this function.
///
/// Launching a function via [`cuLaunchKernel`] invalidates the function's block shape, dynamic shared memory size, and parameter information. After launching via cuLaunchKernel,
/// this state must be re-initialized prior to calling this function. Failure to do so results in undefined behavior.
///
/// Note:
///
/// * In certain cases where cubins are created with no ABI (i.e., using ptxas--abi-compileno), this function may serialize kernel launches. The CUDA driver retains asynchronous behavior by growing the per-thread stack
/// as needed per launch and not shrinking it afterwards.
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuFuncSetBlockShape`], [`cuFuncSetSharedSize`], [`cuFuncGetAttribute`], [`cuParamSetSize`], [`cuParamSetf`], [`cuParamSeti`], [`cuParamSetv`], [`cuLaunch`], [`cuLaunchGrid`], [`cuLaunchKernel`].
///
/// # Parameters
///
/// - `f`: Kernel to launch.
/// - `grid_width`: Width of grid in blocks.
/// - `grid_height`: Height of grid in blocks.
/// - `hStream`: Stream identifier.
#[deprecated]
pub fn cuLaunchGridAsync(
f: CUfunction,
grid_width: ::core::ffi::c_int,
grid_height: ::core::ffi::c_int,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Adds a texture-reference to the function's argument list.
///
/// hTexRef
///
/// [`cuModuleGetTexRef`]
///
/// texunit
///
/// [`CU_PARAM_TR_DEFAULT`]
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `hfunc`: Kernel to add texture-reference to.
/// - `texunit`: Texture unit (must be [`CU_PARAM_TR_DEFAULT`]).
/// - `hTexRef`: Texture-reference to add to argument list.
#[deprecated]
pub fn cuParamSetTexRef(
hfunc: CUfunction,
texunit: ::core::ffi::c_int,
hTexRef: CUtexref,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the shared memory configuration for a device function.
///
/// Any per-function setting of shared memory bank size set via [`cuFuncSetSharedMemConfig`] will override the context wide setting set with [`cuCtxSetSharedMemConfig`].
///
/// Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major
/// effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what
/// kinds of accesses to shared memory will result in bank conflicts.
///
/// This function will do nothing on devices with fixed shared memory bank size.
///
/// The supported bank configurations are:
///
/// * [`CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE`]: use the context's shared memory configuration when launching this function.
/// * [`CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE`]: set shared memory bank width to be natively four bytes when launching this function.
/// * [`CUsharedconfig_enum::CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE`]: set shared memory bank width to be natively eight bytes when launching this function.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxGetCacheConfig`], [`cuCtxSetCacheConfig`], [`cuCtxGetSharedMemConfig`], [`cuCtxSetSharedMemConfig`], [`cuFuncGetAttribute`], [`cuLaunchKernel`], [cudaFuncSetSharedMemConfig](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EXECUTION__DEPRECATED.html#group__CUDART__EXECUTION__DEPRECATED_1gbd189716def6fdb5f819dae77452d30b).
///
/// # Parameters
///
/// - `hfunc`: kernel to be given a shared memory config.
/// - `config`: requested shared memory configuration.
#[deprecated]
pub fn cuFuncSetSharedMemConfig(
hfunc: CUfunction,
config: CUsharedconfig,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a graph.
///
/// Creates an empty graph, which is returned via phGraph.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddHostNode`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`], `cuGraphInstantiate`, [`cuGraphDestroy`], [`cuGraphGetNodes`], [`cuGraphGetRootNodes`], [`cuGraphGetEdges_v2`], [`cuGraphClone`].
///
/// # Parameters
///
/// - `phGraph`: Returns newly created graph.
/// - `flags`: Graph creation flags, must be 0.
pub fn cuGraphCreate(phGraph: *mut CUgraph, flags: ::core::ffi::c_uint) -> CUresult;
}
unsafe extern "C" {
/// Creates a kernel execution node and adds it to a graph.
///
/// Creates a new kernel execution node and adds it to hGraph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// The CUDA_KERNEL_NODE_PARAMS structure is defined as:
///
/// ```text
/// typedef struct CUDA_KERNEL_NODE_PARAMS_st {
/// CUfunction func;
/// unsigned int gridDimX;
/// unsigned int gridDimY;
/// unsigned int gridDimZ;
/// unsigned int blockDimX;
/// unsigned int blockDimY;
/// unsigned int blockDimZ;
/// unsigned int sharedMemBytes;
/// void **kernelParams;
/// void **extra;
/// CUkernel kern;
/// CUcontext ctx;
/// } CUDA_KERNEL_NODE_PARAMS;
/// ```
///
/// When the graph is launched, the node will invoke kernel func on a (gridDimX x gridDimY x gridDimZ) grid of blocks. Each block contains (blockDimX x blockDimY x blockDimZ) threads.
///
/// sharedMemBytes sets the amount of dynamic shared memory that will be available to each thread block.
///
/// Kernel parameters to func can be specified in one of two ways:
///
/// 1) Kernel parameters can be specified via kernelParams. If the kernel has N parameters, then kernelParams needs to be an array of N pointers. Each pointer, from kernelParams\[0\] to kernelParams\[N-1\], points to the region of memory from which the actual parameter will be copied. The number of kernel parameters and
/// their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel's image.
///
/// 2) Kernel parameters for non-cooperative kernels can also be packaged by the application into a single buffer that is passed
/// in via extra. This places the burden on the application of knowing each kernel parameter's size and alignment/padding within the buffer.
/// The extra parameter exists to allow this function to take additional less commonly used arguments. extra specifies a list of names of extra settings and their corresponding values. Each extra setting name is immediately followed
/// by the corresponding value. The list must be terminated with either NULL or CU_LAUNCH_PARAM_END.
///
/// * `CU_LAUNCH_PARAM_END`, which indicates the end of the extra array;
/// * `CU_LAUNCH_PARAM_BUFFER_POINTER`, which specifies that the next value in extra will be a pointer to a buffer containing all the kernel parameters for launching kernel func;
/// * `CU_LAUNCH_PARAM_BUFFER_SIZE`, which specifies that the next value in extra will be a pointer to a size_t containing the size of the buffer specified with `CU_LAUNCH_PARAM_BUFFER_POINTER`;
///
/// The error [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] will be returned if kernel parameters are specified with both kernelParams and extra (i.e. both kernelParams and extra are non-NULL). [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] will be returned if extra is used for a cooperative kernel.
///
/// The kernelParams or extra array, as well as the argument values it points to, are copied during this call.
///
/// Note:
///
/// Kernels launched using graphs must not use texture and surface references. Reading or writing through any texture or surface
/// reference is undefined behavior. This restriction does not apply to texture and surface objects.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuLaunchKernel`], [`cuLaunchCooperativeKernel`], [`cuGraphKernelNodeGetParams_v2`], [`cuGraphKernelNodeSetParams_v2`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddHostNode`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the GPU execution node.
pub fn cuGraphAddKernelNode_v2(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
nodeParams: *const CUDA_KERNEL_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a kernel node's parameters.
///
/// Returns the parameters of kernel node hNode in nodeParams. The kernelParams or extra array returned in nodeParams, as well as the argument values it points to, are owned by the node. This memory remains valid until the node is destroyed
/// or its parameters are modified, and should not be modified directly. Use [`cuGraphKernelNodeSetParams_v2`] to update the parameters of this node.
///
/// The params will contain either kernelParams or extra, according to which of these was most recently set on the node.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetParams`], [`cuLaunchKernel`], [`cuGraphAddKernelNode_v2`], [`cuGraphKernelNodeSetParams_v2`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `nodeParams`: Pointer to return the parameters.
pub fn cuGraphKernelNodeGetParams_v2(
hNode: CUgraphNode,
nodeParams: *mut CUDA_KERNEL_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Sets a kernel node's parameters.
///
/// Sets the parameters of kernel node hNode to nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuLaunchKernel`], [`cuGraphAddKernelNode_v2`], [`cuGraphKernelNodeGetParams_v2`].
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cuGraphKernelNodeSetParams_v2(
hNode: CUgraphNode,
nodeParams: *const CUDA_KERNEL_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a memcpy node and adds it to a graph.
///
/// Creates a new memcpy node and adds it to hGraph with numDependencies dependencies specified via dependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// When the graph is launched, the node will perform the memcpy described by copyParams. See [`cuMemcpy3D_v2`] for a description of the structure and its restrictions.
///
/// Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device
/// which has a zero value for the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. If one or more of the operands refer to managed memory, then using the memory type [`CUmemorytype_enum::CU_MEMORYTYPE_UNIFIED`] is disallowed for those operand(s). The managed memory will be treated as residing on either the host or the device, depending
/// on which memory type is specified.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuMemcpy3D_v2`], [`cuGraphMemcpyNodeGetParams`], [`cuGraphMemcpyNodeSetParams`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddHostNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `copyParams`: Parameters for the memory copy.
/// - `ctx`: Context on which to run the node.
pub fn cuGraphAddMemcpyNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
copyParams: *const CUDA_MEMCPY3D,
ctx: CUcontext,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a memcpy node's parameters.
///
/// Returns the parameters of memcpy node hNode in nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetParams`], [`cuMemcpy3D_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphMemcpyNodeSetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `nodeParams`: Pointer to return the parameters.
pub fn cuGraphMemcpyNodeGetParams(
hNode: CUgraphNode,
nodeParams: *mut CUDA_MEMCPY3D,
) -> CUresult;
}
unsafe extern "C" {
/// Sets a memcpy node's parameters.
///
/// Sets the parameters of memcpy node hNode to nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuMemcpy3D_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphMemcpyNodeGetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cuGraphMemcpyNodeSetParams(
hNode: CUgraphNode,
nodeParams: *const CUDA_MEMCPY3D,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a memset node and adds it to a graph.
///
/// Creates a new memset node and adds it to hGraph with numDependencies dependencies specified via dependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// The element size must be 1, 2, or 4 bytes. When the graph is launched, the node will perform the memset described by memsetParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuMemsetD2D32_v2`], [`cuGraphMemsetNodeGetParams`], [`cuGraphMemsetNodeSetParams`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddHostNode`], [`cuGraphAddMemcpyNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `memsetParams`: Parameters for the memory set.
/// - `ctx`: Context on which to run the node.
pub fn cuGraphAddMemsetNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
memsetParams: *const CUDA_MEMSET_NODE_PARAMS,
ctx: CUcontext,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a memset node's parameters.
///
/// Returns the parameters of memset node hNode in nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetParams`], [`cuMemsetD2D32_v2`], [`cuGraphAddMemsetNode`], [`cuGraphMemsetNodeSetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `nodeParams`: Pointer to return the parameters.
pub fn cuGraphMemsetNodeGetParams(
hNode: CUgraphNode,
nodeParams: *mut CUDA_MEMSET_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Sets a memset node's parameters.
///
/// Sets the parameters of memset node hNode to nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuMemsetD2D32_v2`], [`cuGraphAddMemsetNode`], [`cuGraphMemsetNodeGetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cuGraphMemsetNodeSetParams(
hNode: CUgraphNode,
nodeParams: *const CUDA_MEMSET_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a host execution node and adds it to a graph.
///
/// Creates a new CPU execution node and adds it to hGraph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// When the graph is launched, the node will invoke the specified CPU function. Host nodes are not supported under MPS with pre-Volta
/// GPUs.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuLaunchHostFunc`], [`cuGraphHostNodeGetParams`], [`cuGraphHostNodeSetParams`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the host node.
pub fn cuGraphAddHostNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
nodeParams: *const CUDA_HOST_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a host node's parameters.
///
/// Returns the parameters of host node hNode in nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetParams`], [`cuLaunchHostFunc`], [`cuGraphAddHostNode`], [`cuGraphHostNodeSetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `nodeParams`: Pointer to return the parameters.
pub fn cuGraphHostNodeGetParams(
hNode: CUgraphNode,
nodeParams: *mut CUDA_HOST_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Sets a host node's parameters.
///
/// Sets the parameters of host node hNode to nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuLaunchHostFunc`], [`cuGraphAddHostNode`], [`cuGraphHostNodeGetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cuGraphHostNodeSetParams(
hNode: CUgraphNode,
nodeParams: *const CUDA_HOST_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a child graph node and adds it to a graph.
///
/// Creates a new node which executes an embedded graph, and adds it to hGraph with numDependencies dependencies specified via dependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// If childGraph contains allocation nodes, free nodes, or conditional nodes, this call will return an error.
///
/// The node executes an embedded child graph. The child graph is cloned in this call.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphChildGraphNodeGetGraph`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddHostNode`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`], [`cuGraphClone`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `childGraph`: The graph to clone into this node.
pub fn cuGraphAddChildGraphNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
childGraph: CUgraph,
) -> CUresult;
}
unsafe extern "C" {
/// Gets a handle to the embedded graph of a child graph node.
///
/// Gets a handle to the embedded graph in a child graph node. This call does not clone the graph. Changes to the graph will be
/// reflected in the node, and the node retains ownership of the graph.
///
/// Allocation and free nodes cannot be added to the returned graph. Attempting to do so will return an error.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddChildGraphNode`], [`cuGraphNodeFindInClone`].
///
/// # Parameters
///
/// - `hNode`: Node to get the embedded graph for.
/// - `phGraph`: Location to store a handle to the graph.
pub fn cuGraphChildGraphNodeGetGraph(
hNode: CUgraphNode,
phGraph: *mut CUgraph,
) -> CUresult;
}
unsafe extern "C" {
/// Creates an empty node and adds it to a graph.
///
/// Creates a new node which performs no operation, and adds it to hGraph with numDependencies dependencies specified via dependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// An empty node performs no operation during execution, but can be used for transitive ordering. For example, a phased execution
/// graph with 2 groups of n nodes with a barrier between them can be represented using an empty node and 2\*n dependency edges,
/// rather than no empty node and n^2 dependency edges.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddHostNode`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
pub fn cuGraphAddEmptyNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Creates an event record node and adds it to a graph.
///
/// Creates a new event record node and adds it to hGraph with numDependencies dependencies specified via dependencies and event specified in event. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// Each launch of the graph will record event to capture execution of the node's dependencies.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphAddEventWaitNode`], [`cuEventRecordWithFlags`], [`cuStreamWaitEvent`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `event`: Event for the node.
pub fn cuGraphAddEventRecordNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
event: CUevent,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the event associated with an event record node.
///
/// Returns the event of event record node hNode in event_out.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddEventRecordNode`], [`cuGraphEventRecordNodeSetEvent`], [`cuGraphEventWaitNodeGetEvent`], [`cuEventRecordWithFlags`], [`cuStreamWaitEvent`].
///
/// # Parameters
///
/// - `hNode`: Node to get the event for.
/// - `event_out`: Pointer to return the event.
pub fn cuGraphEventRecordNodeGetEvent(
hNode: CUgraphNode,
event_out: *mut CUevent,
) -> CUresult;
}
unsafe extern "C" {
/// Sets an event record node's event.
///
/// Sets the event of event record node hNode to event.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuGraphAddEventRecordNode`], [`cuGraphEventRecordNodeGetEvent`], [`cuGraphEventWaitNodeSetEvent`], [`cuEventRecordWithFlags`], [`cuStreamWaitEvent`].
///
/// # Parameters
///
/// - `hNode`: Node to set the event for.
/// - `event`: Event to use.
pub fn cuGraphEventRecordNodeSetEvent(
hNode: CUgraphNode,
event: CUevent,
) -> CUresult;
}
unsafe extern "C" {
/// Creates an event wait node and adds it to a graph.
///
/// Creates a new event wait node and adds it to hGraph with numDependencies dependencies specified via dependencies and event specified in event. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// The graph node will wait for all work captured in event. See [`cuEventRecord`] for details on what is captured by an event. event may be from a different context or device than the launch stream.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphAddEventRecordNode`], [`cuEventRecordWithFlags`], [`cuStreamWaitEvent`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `event`: Event for the node.
pub fn cuGraphAddEventWaitNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
event: CUevent,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the event associated with an event wait node.
///
/// Returns the event of event wait node hNode in event_out.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddEventWaitNode`], [`cuGraphEventWaitNodeSetEvent`], [`cuGraphEventRecordNodeGetEvent`], [`cuEventRecordWithFlags`], [`cuStreamWaitEvent`].
///
/// # Parameters
///
/// - `hNode`: Node to get the event for.
/// - `event_out`: Pointer to return the event.
pub fn cuGraphEventWaitNodeGetEvent(
hNode: CUgraphNode,
event_out: *mut CUevent,
) -> CUresult;
}
unsafe extern "C" {
/// Sets an event wait node's event.
///
/// Sets the event of event wait node hNode to event.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuGraphAddEventWaitNode`], [`cuGraphEventWaitNodeGetEvent`], [`cuGraphEventRecordNodeSetEvent`], [`cuEventRecordWithFlags`], [`cuStreamWaitEvent`].
///
/// # Parameters
///
/// - `hNode`: Node to set the event for.
/// - `event`: Event to use.
pub fn cuGraphEventWaitNodeSetEvent(hNode: CUgraphNode, event: CUevent) -> CUresult;
}
unsafe extern "C" {
/// Creates an external semaphore signal node and adds it to a graph.
///
/// Creates a new external semaphore signal node and adds it to hGraph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// Performs a signal operation on a set of externally allocated semaphore objects when the node is launched. The operation(s)
/// will occur after all of the node's dependencies have completed.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphExternalSemaphoresSignalNodeGetParams`], [`cuGraphExternalSemaphoresSignalNodeSetParams`], [`cuGraphExecExternalSemaphoresSignalNodeSetParams`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuImportExternalSemaphore`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddEventRecordNode`], [`cuGraphAddEventWaitNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cuGraphAddExternalSemaphoresSignalNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
nodeParams: *const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Returns an external semaphore signal node's parameters.
///
/// Returns the parameters of an external semaphore signal node hNode in params_out. The extSemArray and paramsArray returned in params_out, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should
/// not be modified directly. Use [`cuGraphExternalSemaphoresSignalNodeSetParams`] to update the parameters of this node.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetParams`], [`cuLaunchKernel`], [`cuGraphAddExternalSemaphoresSignalNode`], [`cuGraphExternalSemaphoresSignalNodeSetParams`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
pub fn cuGraphExternalSemaphoresSignalNodeGetParams(
hNode: CUgraphNode,
params_out: *mut CUDA_EXT_SEM_SIGNAL_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Sets an external semaphore signal node's parameters.
///
/// Sets the parameters of an external semaphore signal node hNode to nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuGraphAddExternalSemaphoresSignalNode`], [`cuGraphExternalSemaphoresSignalNodeSetParams`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`].
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cuGraphExternalSemaphoresSignalNodeSetParams(
hNode: CUgraphNode,
nodeParams: *const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Creates an external semaphore wait node and adds it to a graph.
///
/// Creates a new external semaphore wait node and adds it to hGraph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// Performs a wait operation on a set of externally allocated semaphore objects when the node is launched. The node's dependencies
/// will not be launched until the wait operation has completed.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphExternalSemaphoresWaitNodeGetParams`], [`cuGraphExternalSemaphoresWaitNodeSetParams`], [`cuGraphExecExternalSemaphoresWaitNodeSetParams`], [`cuGraphAddExternalSemaphoresSignalNode`], [`cuImportExternalSemaphore`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddEventRecordNode`], [`cuGraphAddEventWaitNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cuGraphAddExternalSemaphoresWaitNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
nodeParams: *const CUDA_EXT_SEM_WAIT_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Returns an external semaphore wait node's parameters.
///
/// Returns the parameters of an external semaphore wait node hNode in params_out. The extSemArray and paramsArray returned in params_out, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should
/// not be modified directly. Use [`cuGraphExternalSemaphoresSignalNodeSetParams`] to update the parameters of this node.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetParams`], [`cuLaunchKernel`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuGraphExternalSemaphoresWaitNodeSetParams`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
pub fn cuGraphExternalSemaphoresWaitNodeGetParams(
hNode: CUgraphNode,
params_out: *mut CUDA_EXT_SEM_WAIT_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Sets an external semaphore wait node's parameters.
///
/// Sets the parameters of an external semaphore wait node hNode to nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuGraphExternalSemaphoresWaitNodeSetParams`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`].
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cuGraphExternalSemaphoresWaitNodeSetParams(
hNode: CUgraphNode,
nodeParams: *const CUDA_EXT_SEM_WAIT_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a batch memory operation node and adds it to a graph.
///
/// Creates a new batch memory operation node and adds it to hGraph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// When the node is added, the paramArray inside nodeParams is copied and therefore it can be freed after the call returns.
///
/// Note:
///
/// Warning: Improper use of this API may deadlock the application. Synchronization ordering established through this API is not
/// visible to CUDA. CUDA tasks that are (even indirectly) ordered by this API should also have that order expressed with CUDA-visible
/// dependencies such as events. This ensures that the scheduler does not serialize them in an improper order.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuStreamBatchMemOp_v2`], [`cuStreamWaitValue32_v2`], [`cuStreamWriteValue32_v2`], [`cuStreamWaitValue64_v2`], [`cuStreamWriteValue64_v2`], [`cuGraphBatchMemOpNodeGetParams`], [`cuGraphBatchMemOpNodeSetParams`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cuGraphAddBatchMemOpNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
nodeParams: *const CUDA_BATCH_MEM_OP_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a batch mem op node's parameters.
///
/// Returns the parameters of batch mem op node hNode in nodeParams_out. The paramArray returned in nodeParams_out is owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not
/// be modified directly. Use [`cuGraphBatchMemOpNodeSetParams`] to update the parameters of this node.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetParams`], [`cuStreamBatchMemOp_v2`], [`cuGraphAddBatchMemOpNode`], [`cuGraphBatchMemOpNodeSetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `nodeParams_out`: Pointer to return the parameters.
pub fn cuGraphBatchMemOpNodeGetParams(
hNode: CUgraphNode,
nodeParams_out: *mut CUDA_BATCH_MEM_OP_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Sets a batch mem op node's parameters.
///
/// Sets the parameters of batch mem op node hNode to nodeParams.
///
/// The paramArray inside nodeParams is copied and therefore it can be freed after the call returns.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuStreamBatchMemOp_v2`], [`cuGraphAddBatchMemOpNode`], [`cuGraphBatchMemOpNodeGetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cuGraphBatchMemOpNodeSetParams(
hNode: CUgraphNode,
nodeParams: *const CUDA_BATCH_MEM_OP_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the parameters for a batch mem op node in the given graphExec.
///
/// Sets the parameters of a batch mem op node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// The following fields on operations may be modified on an executable graph:
///
/// op.waitValue.address op.waitValue.value\[64\] op.waitValue.flags bits corresponding to wait type (i.e. [`CUstreamWaitValue_flags::CU_STREAM_WAIT_VALUE_FLUSH`]
/// bit cannot be modified) op.writeValue.address op.writeValue.value\[64\]
///
/// Other fields, such as the context, count or type of operations, and other types of operations such as membars, may not be
/// modified.
///
/// hNode must not have been removed from the original graph.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// The paramArray inside nodeParams is copied and therefore it can be freed after the call returns.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuStreamBatchMemOp_v2`], [`cuGraphAddBatchMemOpNode`], [`cuGraphBatchMemOpNodeGetParams`], [`cuGraphBatchMemOpNodeSetParams`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Batch mem op node from the graph from which graphExec was instantiated.
/// - `nodeParams`: Updated Parameters to set.
pub fn cuGraphExecBatchMemOpNodeSetParams(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
nodeParams: *const CUDA_BATCH_MEM_OP_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Creates an allocation node and adds it to a graph.
///
/// Creates a new allocation node and adds it to hGraph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// When [`cuGraphAddMemAllocNode`] creates an allocation node, it returns the address of the allocation in nodeParams.dptr. The allocation's address remains fixed across instantiations and launches.
///
/// If the allocation is freed in the same graph, by creating a free node using [`cuGraphAddMemFreeNode`], the allocation can be accessed by nodes ordered after the allocation node but before the free node. These allocations cannot
/// be freed outside the owning graph, and they can only be freed once in the owning graph.
///
/// If the allocation is not freed in the same graph, then it can be accessed not only by nodes in the graph which are ordered
/// after the allocation node, but also by stream operations ordered after the graph's execution but before the allocation is
/// freed.
///
/// Allocations which are not freed in the same graph can be freed by:
///
/// * passing the allocation to [`cuMemFreeAsync`] or [`cuMemFree_v2`];
/// * launching a graph with a free node for that allocation; or
/// * specifying [`CUgraphInstantiate_flags_enum::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH`] during instantiation, which makes each launch behave as though it called [`cuMemFreeAsync`] for every unfreed allocation.
///
/// It is not possible to free an allocation in both the owning graph and another graph. If the allocation is freed in the same
/// graph, a free node cannot be added to another graph. If the allocation is freed in another graph, a free node can no longer
/// be added to the owning graph.
///
/// The following restrictions apply to graphs which contain allocation and/or memory free nodes:
///
/// * Nodes and edges of the graph cannot be deleted.
/// * The graph can only be used in a child node if the ownership is moved to the parent.
/// * Only one instantiation of the graph may exist at any point in time.
/// * The graph cannot be cloned.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphAddMemFreeNode`], [`cuGraphMemAllocNodeGetParams`], [`cuDeviceGraphMemTrim`], [`cuDeviceGetGraphMemAttribute`], [`cuDeviceSetGraphMemAttribute`], [`cuMemAllocAsync`], [`cuMemFreeAsync`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddEventRecordNode`], [`cuGraphAddEventWaitNode`], [`cuGraphAddExternalSemaphoresSignalNode`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cuGraphAddMemAllocNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
nodeParams: *mut CUDA_MEM_ALLOC_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a memory alloc node's parameters.
///
/// Returns the parameters of a memory alloc node hNode in params_out. The poolProps and accessDescs returned in params_out, are owned by the node. This memory remains valid until the node is destroyed. The returned parameters must not be modified.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetParams`], [`cuGraphAddMemAllocNode`], [`cuGraphMemFreeNodeGetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
pub fn cuGraphMemAllocNodeGetParams(
hNode: CUgraphNode,
params_out: *mut CUDA_MEM_ALLOC_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a memory free node and adds it to a graph.
///
/// Creates a new memory free node and adds it to hGraph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// [`cuGraphAddMemFreeNode`] will return [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] if the user attempts to free:
///
/// * an allocation twice in the same graph.
/// * an address that was not returned by an allocation node.
/// * an invalid address.
///
/// The following restrictions apply to graphs which contain allocation and/or memory free nodes:
///
/// * Nodes and edges of the graph cannot be deleted.
/// * The graph can only be used in a child node if the ownership is moved to the parent.
/// * Only one instantiation of the graph may exist at any point in time.
/// * The graph cannot be cloned.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphAddMemAllocNode`], [`cuGraphMemFreeNodeGetParams`], [`cuDeviceGraphMemTrim`], [`cuDeviceGetGraphMemAttribute`], [`cuDeviceSetGraphMemAttribute`], [`cuMemAllocAsync`], [`cuMemFreeAsync`], [`cuGraphCreate`], [`cuGraphDestroyNode`], [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddEventRecordNode`], [`cuGraphAddEventWaitNode`], [`cuGraphAddExternalSemaphoresSignalNode`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `dptr`: Address of memory to free.
pub fn cuGraphAddMemFreeNode(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
numDependencies: size_t,
dptr: CUdeviceptr,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a memory free node's parameters.
///
/// Returns the address of a memory free node hNode in dptr_out.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetParams`], [`cuGraphAddMemFreeNode`], [`cuGraphMemAllocNodeGetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `dptr_out`: Pointer to return the device address.
pub fn cuGraphMemFreeNodeGetParams(
hNode: CUgraphNode,
dptr_out: *mut CUdeviceptr,
) -> CUresult;
}
unsafe extern "C" {
/// Free unused memory that was cached on the specified device for use with graphs back to the OS.
///
/// Blocks which are not in use by a graph that is either currently executing or scheduled to execute are freed back to the operating
/// system.
///
/// **See also:**
///
/// [`cuGraphAddMemAllocNode`], [`cuGraphAddMemFreeNode`], [`cuDeviceSetGraphMemAttribute`], [`cuDeviceGetGraphMemAttribute`].
///
/// # Parameters
///
/// - `device`: The device for which cached memory should be freed.
pub fn cuDeviceGraphMemTrim(device: CUdevice) -> CUresult;
}
unsafe extern "C" {
/// Query asynchronous allocation attributes related to graphs.
///
/// Valid attributes are:
///
/// * [`CUgraphMem_attribute_enum::CU_GRAPH_MEM_ATTR_USED_MEM_CURRENT`]: Amount of memory, in bytes, currently associated with graphs
/// * [`CUgraphMem_attribute_enum::CU_GRAPH_MEM_ATTR_USED_MEM_HIGH`]: High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be
/// reset to zero.
/// * [`CUgraphMem_attribute_enum::CU_GRAPH_MEM_ATTR_RESERVED_MEM_CURRENT`]: Amount of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
/// * [`CUgraphMem_attribute_enum::CU_GRAPH_MEM_ATTR_RESERVED_MEM_HIGH`]: High watermark of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
///
/// **See also:**
///
/// [`cuDeviceSetGraphMemAttribute`], [`cuGraphAddMemAllocNode`], [`cuGraphAddMemFreeNode`].
///
/// # Parameters
///
/// - `device`: Specifies the scope of the query.
/// - `attr`: attribute to get.
/// - `value`: retrieved value.
pub fn cuDeviceGetGraphMemAttribute(
device: CUdevice,
attr: CUgraphMem_attribute,
value: *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Set asynchronous allocation attributes related to graphs.
///
/// Valid attributes are:
///
/// * [`CUgraphMem_attribute_enum::CU_GRAPH_MEM_ATTR_USED_MEM_HIGH`]: High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be
/// reset to zero.
/// * [`CUgraphMem_attribute_enum::CU_GRAPH_MEM_ATTR_RESERVED_MEM_HIGH`]: High watermark of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
///
/// **See also:**
///
/// [`cuDeviceGetGraphMemAttribute`], [`cuGraphAddMemAllocNode`], [`cuGraphAddMemFreeNode`].
///
/// # Parameters
///
/// - `device`: Specifies the scope of the query.
/// - `attr`: attribute to get.
/// - `value`: pointer to value to set.
pub fn cuDeviceSetGraphMemAttribute(
device: CUdevice,
attr: CUgraphMem_attribute,
value: *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Clones a graph.
///
/// This function creates a copy of originalGraph and returns it in phGraphClone. All parameters are copied into the cloned graph. The original graph may be modified after this call without affecting the
/// clone.
///
/// Child graph nodes in the original graph are recursively copied into the clone.
///
/// Note:
///
/// : Cloning is not supported for graphs which contain memory allocation nodes, memory free nodes, or conditional nodes.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphCreate`], [`cuGraphNodeFindInClone`].
///
/// # Parameters
///
/// - `phGraphClone`: Returns newly created cloned graph.
/// - `originalGraph`: Graph to clone.
pub fn cuGraphClone(phGraphClone: *mut CUgraph, originalGraph: CUgraph) -> CUresult;
}
unsafe extern "C" {
/// Finds a cloned version of a node.
///
/// This function returns the node in hClonedGraph corresponding to hOriginalNode in the original graph.
///
/// hClonedGraph must have been cloned from hOriginalGraph via [`cuGraphClone`]. hOriginalNode must have been in hOriginalGraph at the time of the call to [`cuGraphClone`], and the corresponding cloned node in hClonedGraph must not have been removed. The cloned node is then returned via phClonedNode.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphClone`].
///
/// # Parameters
///
/// - `phNode`: Returns handle to the cloned node.
/// - `hOriginalNode`: Handle to the original node.
/// - `hClonedGraph`: Cloned graph to query.
pub fn cuGraphNodeFindInClone(
phNode: *mut CUgraphNode,
hOriginalNode: CUgraphNode,
hClonedGraph: CUgraph,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a node's type.
///
/// Returns the node type of hNode in type.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphGetNodes`], [`cuGraphGetRootNodes`], [`cuGraphChildGraphNodeGetGraph`], [`cuGraphKernelNodeGetParams_v2`], [`cuGraphKernelNodeSetParams_v2`], [`cuGraphHostNodeGetParams`], [`cuGraphHostNodeSetParams`], [`cuGraphMemcpyNodeGetParams`], [`cuGraphMemcpyNodeSetParams`], [`cuGraphMemsetNodeGetParams`], [`cuGraphMemsetNodeSetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to query.
pub fn cuGraphNodeGetType(
hNode: CUgraphNode,
type_: *mut CUgraphNodeType,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the graph that contains a given graph node.
///
/// Returns the graph that contains hNode in \*phGraph. If hNode is in a child graph, the child graph it is in is returned.
///
/// **See also:**
///
/// [`cuGraphGetNodes`], [`cuGraphDebugDotPrint`]cuGraphNodeGetLocalId [`cuGraphNodeGetToolsId`]cuGraphGetId [`cuGraphExecGetId`].
///
/// # Parameters
///
/// - `hNode`: Node to query.
pub fn cuGraphNodeGetContainingGraph(
hNode: CUgraphNode,
phGraph: *mut CUgraph,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the local node id of a given graph node.
///
/// Returns the node id of hNode in \*nodeId. The nodeId matches that referenced by [`cuGraphDebugDotPrint`]. The local nodeId and graphId together can uniquely identify the node.
///
/// **See also:**
///
/// [`cuGraphGetNodes`], [`cuGraphDebugDotPrint`]cuGraphNodeGetContainingGraph [`cuGraphNodeGetToolsId`]cuGraphGetId [`cuGraphExecGetId`].
///
/// # Parameters
///
/// - `hNode`: Node to query.
/// - `nodeId`: Pointer to return the nodeId.
pub fn cuGraphNodeGetLocalId(
hNode: CUgraphNode,
nodeId: *mut ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Returns an id used by tools to identify a given node.
///
/// **See also:**
///
/// [`cuGraphGetNodes`], [`cuGraphDebugDotPrint`]cuGraphNodeGetContainingGraph [`cuGraphNodeGetLocalId`]cuGraphGetId [`cuGraphExecGetId`].
///
/// # Parameters
///
/// - `hNode`: Node to query.
pub fn cuGraphNodeGetToolsId(
hNode: CUgraphNode,
toolsNodeId: *mut ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the id of a given graph.
///
/// Returns the id of hGraph in \*graphId. The value in \*graphId will match that referenced by [`cuGraphDebugDotPrint`].
///
/// **See also:**
///
/// [`cuGraphGetNodes`], [`cuGraphDebugDotPrint`]cuGraphNodeGetContainingGraph [`cuGraphNodeGetLocalId`]cuGraphNodeGetToolsId [`cuGraphExecGetId`].
///
/// # Parameters
///
/// - `hGraph`: Graph to query.
pub fn cuGraphGetId(hGraph: CUgraph, graphId: *mut ::core::ffi::c_uint) -> CUresult;
}
unsafe extern "C" {
/// Returns the id of a given graph exec.
///
/// Returns the id of hGraphExec in \*graphId. The value in \*graphId will match that referenced by [`cuGraphDebugDotPrint`].
///
/// **See also:**
///
/// [`cuGraphGetNodes`], [`cuGraphDebugDotPrint`]cuGraphNodeGetContainingGraph [`cuGraphNodeGetLocalId`]cuGraphNodeGetToolsId [`cuGraphGetId`].
///
/// # Parameters
///
/// - `hGraphExec`: Graph to query.
pub fn cuGraphExecGetId(
hGraphExec: CUgraphExec,
graphId: *mut ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a graph's nodes.
///
/// Returns a list of hGraph's nodes. nodes may be NULL, in which case this function will return the number of nodes in numNodes. Otherwise, numNodes entries will be filled in. If numNodes is higher than the actual number of nodes, the remaining entries in nodes will be set to NULL, and the number of nodes actually obtained will be returned in numNodes.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphCreate`], [`cuGraphGetRootNodes`], [`cuGraphGetEdges_v2`], [`cuGraphNodeGetType`], [`cuGraphNodeGetDependencies_v2`], [`cuGraphNodeGetDependentNodes_v2`].
///
/// # Parameters
///
/// - `hGraph`: Graph to query.
/// - `nodes`: Pointer to return the nodes.
/// - `numNodes`: See description.
pub fn cuGraphGetNodes(
hGraph: CUgraph,
nodes: *mut CUgraphNode,
numNodes: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a graph's root nodes.
///
/// Returns a list of hGraph's root nodes. rootNodes may be NULL, in which case this function will return the number of root nodes in numRootNodes. Otherwise, numRootNodes entries will be filled in. If numRootNodes is higher than the actual number of root nodes, the remaining entries in rootNodes will be set to NULL, and the number of nodes actually obtained will be returned in numRootNodes.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphCreate`], [`cuGraphGetNodes`], [`cuGraphGetEdges_v2`], [`cuGraphNodeGetType`], [`cuGraphNodeGetDependencies_v2`], [`cuGraphNodeGetDependentNodes_v2`].
///
/// # Parameters
///
/// - `hGraph`: Graph to query.
/// - `rootNodes`: Pointer to return the root nodes.
/// - `numRootNodes`: See description.
pub fn cuGraphGetRootNodes(
hGraph: CUgraph,
rootNodes: *mut CUgraphNode,
numRootNodes: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a graph's dependency edges.
///
/// Returns a list of hGraph's dependency edges. Edges are returned via corresponding indices in from, to and edgeData; that is, the node in to\[i\] has a dependency on the node in from\[i\] with data edgeData\[i\]. from and to may both be NULL, in which case this function only returns the number of edges in numEdges. Otherwise, numEdges entries will be filled in. If numEdges is higher than the actual number of edges, the remaining entries in from and to will be set to NULL, and the number of edges actually returned will be written to numEdges. edgeData may alone be NULL, in which case the edges must all have default (zeroed) edge data. Attempting a lossy query via NULL edgeData will result in [`cudaError_enum::CUDA_ERROR_LOSSY_QUERY`]. If edgeData is non-NULL then from and to must be as well.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphGetNodes`], [`cuGraphGetRootNodes`], [`cuGraphAddDependencies_v2`], [`cuGraphRemoveDependencies_v2`], [`cuGraphNodeGetDependencies_v2`], [`cuGraphNodeGetDependentNodes_v2`].
///
/// # Parameters
///
/// - `hGraph`: Graph to get the edges from.
/// - `from`: Location to return edge endpoints.
/// - `to`: Location to return edge endpoints.
/// - `edgeData`: Optional location to return edge data.
/// - `numEdges`: See description.
pub fn cuGraphGetEdges_v2(
hGraph: CUgraph,
from: *mut CUgraphNode,
to: *mut CUgraphNode,
edgeData: *mut CUgraphEdgeData,
numEdges: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a node's dependencies.
///
/// Returns a list of node's dependencies. dependencies may be NULL, in which case this function will return the number of dependencies in numDependencies. Otherwise, numDependencies entries will be filled in. If numDependencies is higher than the actual number of dependencies, the remaining entries in dependencies will be set to NULL, and the number of nodes actually obtained will be returned in numDependencies.
///
/// Note that if an edge has non-zero (non-default) edge data and edgeData is NULL, this API will return [`cudaError_enum::CUDA_ERROR_LOSSY_QUERY`]. If edgeData is non-NULL, then dependencies must be as well.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetDependentNodes_v2`], [`cuGraphGetNodes`], [`cuGraphGetRootNodes`], [`cuGraphGetEdges_v2`], [`cuGraphAddDependencies_v2`], [`cuGraphRemoveDependencies_v2`].
///
/// # Parameters
///
/// - `hNode`: Node to query.
/// - `dependencies`: Pointer to return the dependencies.
/// - `edgeData`: Optional array to return edge data for each dependency.
/// - `numDependencies`: See description.
pub fn cuGraphNodeGetDependencies_v2(
hNode: CUgraphNode,
dependencies: *mut CUgraphNode,
edgeData: *mut CUgraphEdgeData,
numDependencies: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a node's dependent nodes.
///
/// Returns a list of node's dependent nodes. dependentNodes may be NULL, in which case this function will return the number of dependent nodes in numDependentNodes. Otherwise, numDependentNodes entries will be filled in. If numDependentNodes is higher than the actual number of dependent nodes, the remaining entries in dependentNodes will be set to NULL, and the number of nodes actually obtained will be returned in numDependentNodes.
///
/// Note that if an edge has non-zero (non-default) edge data and edgeData is NULL, this API will return [`cudaError_enum::CUDA_ERROR_LOSSY_QUERY`]. If edgeData is non-NULL, then dependentNodes must be as well.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetDependencies_v2`], [`cuGraphGetNodes`], [`cuGraphGetRootNodes`], [`cuGraphGetEdges_v2`], [`cuGraphAddDependencies_v2`], [`cuGraphRemoveDependencies_v2`].
///
/// # Parameters
///
/// - `hNode`: Node to query.
/// - `dependentNodes`: Pointer to return the dependent nodes.
/// - `edgeData`: Optional pointer to return edge data for dependent nodes.
/// - `numDependentNodes`: See description.
pub fn cuGraphNodeGetDependentNodes_v2(
hNode: CUgraphNode,
dependentNodes: *mut CUgraphNode,
edgeData: *mut CUgraphEdgeData,
numDependentNodes: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Adds dependency edges to a graph.
///
/// The number of dependencies to be added is defined by numDependencies Elements in from and to at corresponding indices define a dependency. Each node in from and to must belong to hGraph.
///
/// If numDependencies is 0, elements in from and to will be ignored. Specifying an existing dependency will return an error.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphRemoveDependencies_v2`], [`cuGraphGetEdges_v2`], [`cuGraphNodeGetDependencies_v2`], [`cuGraphNodeGetDependentNodes_v2`].
///
/// # Parameters
///
/// - `hGraph`: Graph to which dependencies are added.
/// - `from`: Array of nodes that provide the dependencies.
/// - `to`: Array of dependent nodes.
/// - `edgeData`: Optional array of edge data. If NULL, default (zeroed) edge data is assumed.
/// - `numDependencies`: Number of dependencies to be added.
pub fn cuGraphAddDependencies_v2(
hGraph: CUgraph,
from: *const CUgraphNode,
to: *const CUgraphNode,
edgeData: *const CUgraphEdgeData,
numDependencies: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Removes dependency edges from a graph.
///
/// The number of dependencies to be removed is defined by numDependencies. Elements in from and to at corresponding indices define a dependency. Each node in from and to must belong to hGraph.
///
/// If numDependencies is 0, elements in from and to will be ignored. Specifying an edge that does not exist in the graph, with data matching edgeData, results in an error. edgeData is nullable, which is equivalent to passing default (zeroed) data for each edge.
///
/// Dependencies cannot be removed from graphs which contain allocation or free nodes. Any attempt to do so will return an error.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddDependencies_v2`], [`cuGraphGetEdges_v2`], [`cuGraphNodeGetDependencies_v2`], [`cuGraphNodeGetDependentNodes_v2`].
///
/// # Parameters
///
/// - `hGraph`: Graph from which to remove dependencies.
/// - `from`: Array of nodes that provide the dependencies.
/// - `to`: Array of dependent nodes.
/// - `edgeData`: Optional array of edge data. If NULL, edge data is assumed to be default (zeroed).
/// - `numDependencies`: Number of dependencies to be removed.
pub fn cuGraphRemoveDependencies_v2(
hGraph: CUgraph,
from: *const CUgraphNode,
to: *const CUgraphNode,
edgeData: *const CUgraphEdgeData,
numDependencies: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Remove a node from the graph.
///
/// Removes hNode from its graph. This operation also severs any dependencies of other nodes on hNode and vice versa.
///
/// Nodes which belong to a graph which contains allocation or free nodes cannot be destroyed. Any attempt to do so will return
/// an error.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddChildGraphNode`], [`cuGraphAddEmptyNode`], [`cuGraphAddKernelNode_v2`], [`cuGraphAddHostNode`], [`cuGraphAddMemcpyNode`], [`cuGraphAddMemsetNode`].
///
/// # Parameters
///
/// - `hNode`: Node to remove.
pub fn cuGraphDestroyNode(hNode: CUgraphNode) -> CUresult;
}
unsafe extern "C" {
pub fn cuGraphInstantiateWithFlags(
phGraphExec: *mut CUgraphExec,
hGraph: CUgraph,
flags: ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Creates an executable graph from a graph.
///
/// Instantiates hGraph as an executable graph according to the instantiateParams structure. The graph is validated for any structural constraints or intra-node constraints which were not previously validated.
/// If instantiation is successful, a handle to the instantiated graph is returned in phGraphExec.
///
/// instantiateParams controls the behavior of instantiation and subsequent graph launches, as well as returning more detailed information in the
/// event of an error. [`CUDA_GRAPH_INSTANTIATE_PARAMS`] is defined as:
///
/// ```text
/// typedef struct {
/// cuuint64_t flags;
/// CUstream hUploadStream;
/// CUgraphNode hErrNode_out;
/// CUgraphInstantiateResult result_out;
/// } CUDA_GRAPH_INSTANTIATE_PARAMS;
/// ```
///
/// The flags field controls the behavior of instantiation and subsequent graph launches. Valid flags are:
///
/// * [`CUgraphInstantiate_flags_enum::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH`], which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before
/// the graph is relaunched.
///
/// * [`CUgraphInstantiate_flags_enum::CUDA_GRAPH_INSTANTIATE_FLAG_UPLOAD`], which will perform an upload of the graph into hUploadStream once the graph has been instantiated.
///
/// * [`CUgraphInstantiate_flags_enum::CUDA_GRAPH_INSTANTIATE_FLAG_DEVICE_LAUNCH`], which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can
/// be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing.
/// This flag cannot be used in conjunction with [`CUgraphInstantiate_flags_enum::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH`].
///
/// * [`CUgraphInstantiate_flags_enum::CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY`], which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream
/// during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream
/// capture.
///
/// If hGraph contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An
/// attempt to instantiate a second executable graph before destroying the first with [`cuGraphExecDestroy`] will result in an error. The same also applies if hGraph contains any device-updatable kernel nodes.
///
/// If hGraph contains kernels which call device-side [cudaGraphLaunch()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g1920584881db959c8c74130d79019b73) from multiple contexts, this will result in an error.
///
/// Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:
///
/// * The graph's nodes must reside on a single context.
/// * The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes.
/// * The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are
/// outlined below.
/// * Kernel nodes:
/// + Use of CUDA Dynamic Parallelism is not permitted.
/// + Cooperative launches are permitted as long as MPS is not in use.
/// * Memcpy nodes:
/// + Only copies involving device memory and/or pinned device-mapped host memory are permitted.
/// + Copies involving CUDA arrays are not permitted.
/// + Both operands must be accessible from the current context, and the current context must match the context of other nodes in
/// the graph.
///
/// In the event of an error, the result_out and hErrNode_out fields will contain more information about the nature of the error. Possible error reporting includes:
///
/// * [`CUgraphInstantiateResult_enum::CUDA_GRAPH_INSTANTIATE_ERROR`], if passed an invalid value or if an unexpected error occurred which is described by the return value of the function. hErrNode_out will be set to NULL.
/// * [`CUgraphInstantiateResult_enum::CUDA_GRAPH_INSTANTIATE_INVALID_STRUCTURE`], if the graph structure is invalid. hErrNode_out will be set to one of the offending nodes.
/// * [`CUgraphInstantiateResult_enum::CUDA_GRAPH_INSTANTIATE_NODE_OPERATION_NOT_SUPPORTED`], if the graph is instantiated for device launch but contains a node of an unsupported node type, or a node which performs
/// unsupported operations, such as use of CUDA dynamic parallelism within a kernel node. hErrNode_out will be set to this node.
/// * [`CUgraphInstantiateResult_enum::CUDA_GRAPH_INSTANTIATE_MULTIPLE_CTXS_NOT_SUPPORTED`], if the graph is instantiated for device launch but a node’s context differs from that of another node. This error can also
/// be returned if a graph is not instantiated for device launch and it contains kernels which call device-side [cudaGraphLaunch()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g1920584881db959c8c74130d79019b73) from multiple contexts. hErrNode_out will be set to this node.
///
/// If instantiation is successful, result_out will be set to [`CUgraphInstantiateResult_enum::CUDA_GRAPH_INSTANTIATE_SUCCESS`], and hErrNode_out will be set to NULL.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphCreate`], `cuGraphInstantiate`, [`cuGraphExecDestroy`].
///
/// # Parameters
///
/// - `phGraphExec`: Returns instantiated graph.
/// - `hGraph`: Graph to instantiate.
/// - `instantiateParams`: Instantiation parameters.
pub fn cuGraphInstantiateWithParams(
phGraphExec: *mut CUgraphExec,
hGraph: CUgraph,
instantiateParams: *mut CUDA_GRAPH_INSTANTIATE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Query the instantiation flags of an executable graph.
///
/// Returns the flags that were passed to instantiation for the given executable graph. [`CUgraphInstantiate_flags_enum::CUDA_GRAPH_INSTANTIATE_FLAG_UPLOAD`] will not be returned by this API as it does not affect the resulting executable graph.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// `cuGraphInstantiate`, [`cuGraphInstantiateWithParams`].
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph to query.
/// - `flags`: Returns the instantiation flags.
pub fn cuGraphExecGetFlags(
hGraphExec: CUgraphExec,
flags: *mut cuuint64_t,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the parameters for a kernel node in the given graphExec.
///
/// Sets the parameters of a kernel node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// hNode must not have been removed from the original graph. All nodeParams fields may change, but the following restrictions apply to func updates:
///
/// * The owning context of the function cannot change.
/// * A node whose function originally did not use CUDA dynamic parallelism cannot be updated to a function which uses CDP
/// * A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side
/// update calls.
/// * If hGraphExec was not instantiated for device launch, a node whose function originally did not use device-side [cudaGraphLaunch()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g1920584881db959c8c74130d79019b73) cannot be updated to a function which uses device-side [cudaGraphLaunch()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g1920584881db959c8c74130d79019b73) unless the node resides on the same context as nodes which contained such calls at instantiate-time. If no such calls were
/// present at instantiation, these updates cannot be performed at all.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// If hNode is a device-updatable kernel node, the next upload/launch of hGraphExec will overwrite any previous device-side updates. Additionally, applying host updates to a device-updatable kernel node while
/// it is being updated from the device will result in undefined behavior.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuGraphAddKernelNode_v2`], [`cuGraphKernelNodeSetParams_v2`], [`cuGraphExecMemcpyNodeSetParams`], [`cuGraphExecMemsetNodeSetParams`], [`cuGraphExecHostNodeSetParams`], [`cuGraphExecChildGraphNodeSetParams`], [`cuGraphExecEventRecordNodeSetEvent`], [`cuGraphExecEventWaitNodeSetEvent`], [`cuGraphExecExternalSemaphoresSignalNodeSetParams`], [`cuGraphExecExternalSemaphoresWaitNodeSetParams`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: kernel node from the graph from which graphExec was instantiated.
/// - `nodeParams`: Updated Parameters to set.
pub fn cuGraphExecKernelNodeSetParams_v2(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
nodeParams: *const CUDA_KERNEL_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the parameters for a memcpy node in the given graphExec.
///
/// Updates the work represented by hNode in hGraphExec as though hNode had contained copyParams at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored.
///
/// The source and destination memory in copyParams must be allocated from the same contexts as the original source and destination memory. Both the instantiation-time memory
/// operands and the memory operands in copyParams must be 1-dimensional. Zero-length operations are not supported.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Returns [`CUresult::CUDA_ERROR_INVALID_VALUE`] if the memory operands' mappings changed or either the original or new memory operands are
/// multidimensional.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuGraphAddMemcpyNode`], [`cuGraphMemcpyNodeSetParams`], [`cuGraphExecKernelNodeSetParams_v2`], [`cuGraphExecMemsetNodeSetParams`], [`cuGraphExecHostNodeSetParams`], [`cuGraphExecChildGraphNodeSetParams`], [`cuGraphExecEventRecordNodeSetEvent`], [`cuGraphExecEventWaitNodeSetEvent`], [`cuGraphExecExternalSemaphoresSignalNodeSetParams`], [`cuGraphExecExternalSemaphoresWaitNodeSetParams`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Memcpy node from the graph which was used to instantiate graphExec.
/// - `copyParams`: The updated parameters to set.
/// - `ctx`: Context on which to run the node.
pub fn cuGraphExecMemcpyNodeSetParams(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
copyParams: *const CUDA_MEMCPY3D,
ctx: CUcontext,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the parameters for a memset node in the given graphExec.
///
/// Updates the work represented by hNode in hGraphExec as though hNode had contained memsetParams at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored.
///
/// Zero sized operations are not supported.
///
/// The new destination pointer in memsetParams must be to the same kind of allocation as the original destination pointer and
/// have the same context association and device mapping as the original destination pointer.
///
/// Both the value and pointer address may be updated. Changing other aspects of the memset (width, height, element size or pitch)
/// may cause the update to be rejected. Specifically, for 2d memsets, all dimension changes are rejected. For 1d memsets, changes
/// in height are explicitly rejected and other changes are opportunistically allowed if the resulting work maps onto the work
/// resources already allocated for the node.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuGraphAddMemsetNode`], [`cuGraphMemsetNodeSetParams`], [`cuGraphExecKernelNodeSetParams_v2`], [`cuGraphExecMemcpyNodeSetParams`], [`cuGraphExecHostNodeSetParams`], [`cuGraphExecChildGraphNodeSetParams`], [`cuGraphExecEventRecordNodeSetEvent`], [`cuGraphExecEventWaitNodeSetEvent`], [`cuGraphExecExternalSemaphoresSignalNodeSetParams`], [`cuGraphExecExternalSemaphoresWaitNodeSetParams`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Memset node from the graph which was used to instantiate graphExec.
/// - `memsetParams`: The updated parameters to set.
/// - `ctx`: Context on which to run the node.
pub fn cuGraphExecMemsetNodeSetParams(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
memsetParams: *const CUDA_MEMSET_NODE_PARAMS,
ctx: CUcontext,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the parameters for a host node in the given graphExec.
///
/// Updates the work represented by hNode in hGraphExec as though hNode had contained nodeParams at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuGraphAddHostNode`], [`cuGraphHostNodeSetParams`], [`cuGraphExecKernelNodeSetParams_v2`], [`cuGraphExecMemcpyNodeSetParams`], [`cuGraphExecMemsetNodeSetParams`], [`cuGraphExecChildGraphNodeSetParams`], [`cuGraphExecEventRecordNodeSetEvent`], [`cuGraphExecEventWaitNodeSetEvent`], [`cuGraphExecExternalSemaphoresSignalNodeSetParams`], [`cuGraphExecExternalSemaphoresWaitNodeSetParams`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Host node from the graph which was used to instantiate graphExec.
/// - `nodeParams`: The updated parameters to set.
pub fn cuGraphExecHostNodeSetParams(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
nodeParams: *const CUDA_HOST_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Updates node parameters in the child graph node in the given graphExec.
///
/// Updates the work represented by hNode in hGraphExec as though the nodes contained in hNode's graph had the parameters contained in childGraph's nodes at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// The topology of childGraph, as well as the node insertion order, must match that of the graph contained in hNode. See [`cuGraphExecUpdate_v2`] for a list of restrictions on what can be updated in an instantiated graph. The update is recursive, so child graph nodes
/// contained within the top level child graph will also be updated.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuGraphAddChildGraphNode`], [`cuGraphChildGraphNodeGetGraph`], [`cuGraphExecKernelNodeSetParams_v2`], [`cuGraphExecMemcpyNodeSetParams`], [`cuGraphExecMemsetNodeSetParams`], [`cuGraphExecHostNodeSetParams`], [`cuGraphExecEventRecordNodeSetEvent`], [`cuGraphExecEventWaitNodeSetEvent`], [`cuGraphExecExternalSemaphoresSignalNodeSetParams`], [`cuGraphExecExternalSemaphoresWaitNodeSetParams`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Host node from the graph which was used to instantiate graphExec.
/// - `childGraph`: The graph supplying the updated parameters.
pub fn cuGraphExecChildGraphNodeSetParams(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
childGraph: CUgraph,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the event for an event record node in the given graphExec.
///
/// Sets the event of an event record node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuGraphAddEventRecordNode`], [`cuGraphEventRecordNodeGetEvent`], [`cuGraphEventWaitNodeSetEvent`], [`cuEventRecordWithFlags`], [`cuStreamWaitEvent`], [`cuGraphExecKernelNodeSetParams_v2`], [`cuGraphExecMemcpyNodeSetParams`], [`cuGraphExecMemsetNodeSetParams`], [`cuGraphExecHostNodeSetParams`], [`cuGraphExecChildGraphNodeSetParams`], [`cuGraphExecEventWaitNodeSetEvent`], [`cuGraphExecExternalSemaphoresSignalNodeSetParams`], [`cuGraphExecExternalSemaphoresWaitNodeSetParams`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: event record node from the graph from which graphExec was instantiated.
/// - `event`: Updated event to use.
pub fn cuGraphExecEventRecordNodeSetEvent(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
event: CUevent,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the event for an event wait node in the given graphExec.
///
/// Sets the event of an event wait node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuGraphAddEventWaitNode`], [`cuGraphEventWaitNodeGetEvent`], [`cuGraphEventRecordNodeSetEvent`], [`cuEventRecordWithFlags`], [`cuStreamWaitEvent`], [`cuGraphExecKernelNodeSetParams_v2`], [`cuGraphExecMemcpyNodeSetParams`], [`cuGraphExecMemsetNodeSetParams`], [`cuGraphExecHostNodeSetParams`], [`cuGraphExecChildGraphNodeSetParams`], [`cuGraphExecEventRecordNodeSetEvent`], [`cuGraphExecExternalSemaphoresSignalNodeSetParams`], [`cuGraphExecExternalSemaphoresWaitNodeSetParams`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: event wait node from the graph from which graphExec was instantiated.
/// - `event`: Updated event to use.
pub fn cuGraphExecEventWaitNodeSetEvent(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
event: CUevent,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the parameters for an external semaphore signal node in the given graphExec.
///
/// Sets the parameters of an external semaphore signal node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// hNode must not have been removed from the original graph.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Changing nodeParams->numExtSems is not supported.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuGraphAddExternalSemaphoresSignalNode`], [`cuImportExternalSemaphore`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`], [`cuGraphExecKernelNodeSetParams_v2`], [`cuGraphExecMemcpyNodeSetParams`], [`cuGraphExecMemsetNodeSetParams`], [`cuGraphExecHostNodeSetParams`], [`cuGraphExecChildGraphNodeSetParams`], [`cuGraphExecEventRecordNodeSetEvent`], [`cuGraphExecEventWaitNodeSetEvent`], [`cuGraphExecExternalSemaphoresWaitNodeSetParams`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: semaphore signal node from the graph from which graphExec was instantiated.
/// - `nodeParams`: Updated Parameters to set.
pub fn cuGraphExecExternalSemaphoresSignalNodeSetParams(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
nodeParams: *const CUDA_EXT_SEM_SIGNAL_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the parameters for an external semaphore wait node in the given graphExec.
///
/// Sets the parameters of an external semaphore wait node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// hNode must not have been removed from the original graph.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Changing nodeParams->numExtSems is not supported.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphExecNodeSetParams`], [`cuGraphAddExternalSemaphoresWaitNode`], [`cuImportExternalSemaphore`], [`cuSignalExternalSemaphoresAsync`], [`cuWaitExternalSemaphoresAsync`], [`cuGraphExecKernelNodeSetParams_v2`], [`cuGraphExecMemcpyNodeSetParams`], [`cuGraphExecMemsetNodeSetParams`], [`cuGraphExecHostNodeSetParams`], [`cuGraphExecChildGraphNodeSetParams`], [`cuGraphExecEventRecordNodeSetEvent`], [`cuGraphExecEventWaitNodeSetEvent`], [`cuGraphExecExternalSemaphoresSignalNodeSetParams`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: semaphore wait node from the graph from which graphExec was instantiated.
/// - `nodeParams`: Updated Parameters to set.
pub fn cuGraphExecExternalSemaphoresWaitNodeSetParams(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
nodeParams: *const CUDA_EXT_SEM_WAIT_NODE_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Enables or disables the specified node in the given graphExec.
///
/// Sets hNode to be either enabled or disabled. Disabled nodes are functionally equivalent to empty nodes until they are reenabled. Existing
/// node parameters are not affected by disabling/enabling the node.
///
/// The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// hNode must not have been removed from the original graph.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// If hNode is a device-updatable kernel node, the next upload/launch of hGraphExec will overwrite any previous device-side updates. Additionally, applying host updates to a device-updatable kernel node while
/// it is being updated from the device will result in undefined behavior.
///
/// Note:
///
/// Currently only kernel, memset and memcpy nodes are supported.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeGetEnabled`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate `[`cuGraphLaunch`].
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Node from the graph from which graphExec was instantiated.
/// - `isEnabled`: Node is enabled if != 0, otherwise the node is disabled.
pub fn cuGraphNodeSetEnabled(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
isEnabled: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Query whether a node in the given graphExec is enabled.
///
/// Sets isEnabled to 1 if hNode is enabled, or 0 if hNode is disabled.
///
/// The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// hNode must not have been removed from the original graph.
///
/// Note:
///
/// * Currently only kernel, memset and memcpy nodes are supported.
/// * This function will not reflect device-side updates for device-updatable kernel nodes.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetEnabled`], [`cuGraphExecUpdate_v2`], `cuGraphInstantiate `[`cuGraphLaunch`].
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Node from the graph from which graphExec was instantiated.
/// - `isEnabled`: Location to return the enabled status of the node.
pub fn cuGraphNodeGetEnabled(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
isEnabled: *mut ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Uploads an executable graph in a stream.
///
/// Uploads hGraphExec to the device in hStream without executing it. Uploads of the same hGraphExec will be serialized. Each upload is ordered behind both any previous work in hStream and any previous launches of hGraphExec. Uses memory cached by stream to back the allocations owned by hGraphExec.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// `cuGraphInstantiate`, [`cuGraphLaunch`], [`cuGraphExecDestroy`].
///
/// # Parameters
///
/// - `hGraphExec`: Executable graph to upload.
/// - `hStream`: Stream in which to upload the graph.
pub fn cuGraphUpload(hGraphExec: CUgraphExec, hStream: CUstream) -> CUresult;
}
unsafe extern "C" {
/// Launches an executable graph in a stream.
///
/// Executes hGraphExec in hStream. Only one instance of hGraphExec may be executing at a time. Each launch is ordered behind both any previous work in hStream and any previous launches of hGraphExec. To execute a graph concurrently, it must be instantiated multiple times into multiple executable graphs.
///
/// If any allocations created by hGraphExec remain unfreed (from a previous launch) and hGraphExec was not instantiated with [`CUgraphInstantiate_flags_enum::CUDA_GRAPH_INSTANTIATE_FLAG_AUTO_FREE_ON_LAUNCH`], the launch will fail with [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// `cuGraphInstantiate`, [`cuGraphUpload`], [`cuGraphExecDestroy`].
///
/// # Parameters
///
/// - `hGraphExec`: Executable graph to launch.
/// - `hStream`: Stream in which to launch the graph.
pub fn cuGraphLaunch(hGraphExec: CUgraphExec, hStream: CUstream) -> CUresult;
}
unsafe extern "C" {
/// Destroys an executable graph.
///
/// Destroys the executable graph specified by hGraphExec, as well as all of its executable nodes. If the executable graph is in-flight, it will not be terminated, but rather freed
/// asynchronously on completion.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// `cuGraphInstantiate`, [`cuGraphUpload`], [`cuGraphLaunch`].
///
/// # Parameters
///
/// - `hGraphExec`: Executable graph to destroy.
pub fn cuGraphExecDestroy(hGraphExec: CUgraphExec) -> CUresult;
}
unsafe extern "C" {
/// Destroys a graph.
///
/// Destroys the graph specified by hGraph, as well as all of its nodes.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphCreate`].
///
/// # Parameters
///
/// - `hGraph`: Graph to destroy.
pub fn cuGraphDestroy(hGraph: CUgraph) -> CUresult;
}
unsafe extern "C" {
/// Check whether an executable graph can be updated with a graph and perform the update if possible.
///
/// Updates the node parameters in the instantiated graph specified by hGraphExec with the node parameters in a topologically identical graph specified by hGraph.
///
/// Limitations:
///
/// * Kernel nodes:
/// + The owning context of the function cannot change.
/// + A node whose function originally did not use CUDA dynamic parallelism cannot be updated to a function which uses CDP.
/// + A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side
/// update calls.
/// + A cooperative node cannot be updated to a non-cooperative node, and vice-versa.
/// + If the graph was instantiated with [`CUgraphInstantiate_flags::CUDA_GRAPH_INSTANTIATE_FLAG_USE_NODE_PRIORITY`], the priority attribute cannot change. Equality
/// is checked on the originally requested priority values, before they are clamped to the device's supported range.
/// + If hGraphExec was not instantiated for device launch, a node whose function originally did not use device-side [cudaGraphLaunch()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g1920584881db959c8c74130d79019b73) cannot be updated to a function which uses device-side [cudaGraphLaunch()](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__GRAPH.html#group__CUDART__GRAPH_1g1920584881db959c8c74130d79019b73) unless the node resides on the same context as nodes which contained such calls at instantiate-time. If no such calls were
/// present at instantiation, these updates cannot be performed at all.
/// + Neither hGraph nor hGraphExec may contain device-updatable kernel nodes.
/// * Memset and memcpy nodes:
/// + The CUDA device(s) to which the operand(s) was allocated/mapped cannot change.
/// + The source/destination memory must be allocated from the same contexts as the original source/destination memory.
/// + For 2d memsets, only address and assigned value may be updated.
/// + For 1d memsets, updating dimensions is also allowed, but may fail if the resulting operation doesn't map onto the work resources
/// already allocated for the node.
/// * Additional memcpy node restrictions:
/// + Changing either the source or destination memory type(i.e. [`CUmemorytype::CU_MEMORYTYPE_DEVICE`], [`CUmemorytype::CU_MEMORYTYPE_ARRAY`], etc.) is not supported.
/// * External semaphore wait nodes and record nodes:
/// + Changing the number of semaphores is not supported.
/// * Conditional nodes:
/// + Changing node parameters is not supported.
/// + Changing parameters of nodes within the conditional body graph is subject to the rules above.
/// + Conditional handle flags and default values are updated as part of the graph update.
///
/// Note: The API may add further restrictions in future releases. The return code should always be checked.
///
/// cuGraphExecUpdate sets the result member of resultInfo to [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_ERROR_TOPOLOGY_CHANGED`] under the following conditions:
///
/// * The count of nodes directly in hGraphExec and hGraph differ, in which case resultInfo->errorNode is set to NULL.
/// * hGraph has more exit nodes than hGraph, in which case resultInfo->errorNode is set to one of the exit nodes in hGraph.
/// * A node in hGraph has a different number of dependencies than the node from hGraphExec it is paired with, in which case resultInfo->errorNode is set to the node from hGraph.
/// * A node in hGraph has a dependency that does not match with the corresponding dependency of the paired node from hGraphExec. resultInfo->errorNode will be set to the node from hGraph. resultInfo->errorFromNode will be set to the mismatched dependency. The dependencies are paired based on edge order and
/// a dependency does not match when the nodes are already paired based on other edges examined in the graph.
///
/// cuGraphExecUpdate sets the result member of resultInfo to:
///
/// * [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_ERROR`] if passed an invalid value.
/// * [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_ERROR_TOPOLOGY_CHANGED`] if the graph topology changed
/// * [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_ERROR_NODE_TYPE_CHANGED`] if the type of a node changed, in which case hErrorNode_out is set to the node from hGraph.
/// * [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_ERROR_UNSUPPORTED_FUNCTION_CHANGE`] if the function changed in an unsupported way(see note above), in which
/// case hErrorNode_out is set to the node from hGraph
/// * [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_ERROR_PARAMETERS_CHANGED`] if any parameters to a node changed in a way that is not supported, in which
/// case hErrorNode_out is set to the node from hGraph.
/// * [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_ERROR_ATTRIBUTES_CHANGED`] if any attributes of a node changed in a way that is not supported, in which
/// case hErrorNode_out is set to the node from hGraph.
/// * [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_ERROR_NOT_SUPPORTED`] if something about a node is unsupported, like the node's type or configuration,
/// in which case hErrorNode_out is set to the node from hGraph
///
/// If the update fails for a reason not listed above, the result member of resultInfo will be set to [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_ERROR`]. If the update succeeds, the result member will be set to [`CUgraphExecUpdateResult::CU_GRAPH_EXEC_UPDATE_SUCCESS`].
///
/// cuGraphExecUpdate returns [`CUresult::CUDA_SUCCESS`] when the updated was performed successfully. It returns [`CUresult::CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE`]
/// if the graph update was not performed because it included changes which violated constraints specific to instantiated graph
/// update.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The instantiated graph to be updated.
/// - `hGraph`: The graph containing the updated parameters.
/// - `resultInfo`: the error info structure.
pub fn cuGraphExecUpdate_v2(
hGraphExec: CUgraphExec,
hGraph: CUgraph,
resultInfo: *mut CUgraphExecUpdateResultInfo,
) -> CUresult;
}
unsafe extern "C" {
/// Copies attributes from source node to destination node.
///
/// Copies attributes from source node src to destination node dst. Both node must have the same context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`CUaccessPolicyWindow`].
///
/// # Parameters
///
/// - `dst`: Destination node.
/// - `src`: Source node For list of attributes see CUkernelNodeAttrID.
pub fn cuGraphKernelNodeCopyAttributes(
dst: CUgraphNode,
src: CUgraphNode,
) -> CUresult;
}
unsafe extern "C" {
/// Queries node attribute.
///
/// Queries attribute attr from node hNode and stores it in corresponding member of value_out.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`CUaccessPolicyWindow`].
pub fn cuGraphKernelNodeGetAttribute(
hNode: CUgraphNode,
attr: CUkernelNodeAttrID,
value_out: *mut CUkernelNodeAttrValue,
) -> CUresult;
}
unsafe extern "C" {
/// Sets node attribute.
///
/// Sets attribute attr on node hNode from corresponding attribute of value.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`CUaccessPolicyWindow`].
pub fn cuGraphKernelNodeSetAttribute(
hNode: CUgraphNode,
attr: CUkernelNodeAttrID,
value: *const CUkernelNodeAttrValue,
) -> CUresult;
}
unsafe extern "C" {
/// Write a DOT file describing graph structure.
///
/// Using the provided hGraph, write to path a DOT formatted description of the graph. By default this includes the graph topology, node types, node id, kernel names
/// and memcpy direction. flags can be specified to write more detailed information about each node type such as parameter values, kernel attributes, node
/// and function handles.
///
/// # Parameters
///
/// - `hGraph`: The graph to create a DOT file from.
/// - `path`: The path to write the DOT file to.
/// - `flags`: Flags from CUgraphDebugDot_flags for specifying which additional node information to write.
pub fn cuGraphDebugDotPrint(
hGraph: CUgraph,
path: *const ::core::ffi::c_char,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Create a user object.
///
/// Create a user object with the specified destructor callback and initial reference count. The initial references are owned
/// by the caller.
///
/// Destructor callbacks cannot make CUDA API calls and should avoid blocking behavior, as they are executed by a shared internal
/// thread. Another thread may be signaled to perform such actions, if it does not block forward progress of tasks scheduled through
/// CUDA.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cuUserObjectRetain`], [`cuUserObjectRelease`], [`cuGraphRetainUserObject`], [`cuGraphReleaseUserObject`], [`cuGraphCreate`].
///
/// # Parameters
///
/// - `object_out`: Location to return the user object handle.
/// - `ptr`: The pointer to pass to the destroy function.
/// - `destroy`: Callback to free the user object when it is no longer in use.
/// - `initialRefcount`: The initial refcount to create the object with, typically 1. The initial references are owned by the calling thread.
/// - `flags`: Currently it is required to pass [`CUuserObject_flags_enum::CU_USER_OBJECT_NO_DESTRUCTOR_SYNC`], which is the only defined flag. This indicates that the destroy callback cannot be waited on by any CUDA API. Users requiring
/// synchronization of the callback should signal its completion manually.
pub fn cuUserObjectCreate(
object_out: *mut CUuserObject,
ptr: *mut ::core::ffi::c_void,
destroy: CUhostFn,
initialRefcount: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Retain a reference to a user object.
///
/// Retains new references to a user object. The new references are owned by the caller.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cuUserObjectCreate`], [`cuUserObjectRelease`], [`cuGraphRetainUserObject`], [`cuGraphReleaseUserObject`], [`cuGraphCreate`].
///
/// # Parameters
///
/// - `object`: The object to retain.
/// - `count`: The number of references to retain, typically 1. Must be nonzero and not larger than INT_MAX.
pub fn cuUserObjectRetain(
object: CUuserObject,
count: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Release a reference to a user object.
///
/// Releases user object references owned by the caller. The object's destructor is invoked if the reference count reaches zero.
///
/// It is undefined behavior to release references not owned by the caller, or to use a user object handle after all references
/// are released.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cuUserObjectCreate`], [`cuUserObjectRetain`], [`cuGraphRetainUserObject`], [`cuGraphReleaseUserObject`], [`cuGraphCreate`].
///
/// # Parameters
///
/// - `object`: The object to release.
/// - `count`: The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.
pub fn cuUserObjectRelease(
object: CUuserObject,
count: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Retain a reference to a user object from a graph.
///
/// Creates or moves user object references that will be owned by a CUDA graph.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cuUserObjectCreate`], [`cuUserObjectRetain`], [`cuUserObjectRelease`], [`cuGraphReleaseUserObject`], [`cuGraphCreate`].
///
/// # Parameters
///
/// - `graph`: The graph to associate the reference with.
/// - `object`: The user object to retain a reference for.
/// - `count`: The number of references to add to the graph, typically 1. Must be nonzero and not larger than INT_MAX.
/// - `flags`: The optional flag [`CUuserObjectRetain_flags_enum::CU_GRAPH_USER_OBJECT_MOVE`] transfers references from the calling thread, rather than create new references. Pass 0 to create new references.
pub fn cuGraphRetainUserObject(
graph: CUgraph,
object: CUuserObject,
count: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Release a user object reference from a graph.
///
/// Releases user object references owned by a graph.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cuUserObjectCreate`], [`cuUserObjectRetain`], [`cuUserObjectRelease`], [`cuGraphRetainUserObject`], [`cuGraphCreate`].
///
/// # Parameters
///
/// - `graph`: The graph that will release the reference.
/// - `object`: The user object to release a reference for.
/// - `count`: The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.
pub fn cuGraphReleaseUserObject(
graph: CUgraph,
object: CUuserObject,
count: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Adds a node of arbitrary type to a graph.
///
/// Creates a new node in hGraph described by nodeParams with numDependencies dependencies specified via dependencies. numDependencies may be 0. dependencies may be null if numDependencies is 0. dependencies may not have any duplicate entries.
///
/// nodeParams is a tagged union. The node type should be specified in the type field, and type-specific parameters in the corresponding union member. All unused bytes - that is, reserved0 and all bytes past the utilized union member - must be set to zero. It is recommended to use brace initialization or memset
/// to ensure all bytes are initialized.
///
/// Note that for some node types, nodeParams may contain "out parameters" which are modified during the call, such as nodeParams->alloc.dptr.
///
/// A handle to the new node will be returned in phGraphNode.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphCreate`], [`cuGraphNodeSetParams`], [`cuGraphExecNodeSetParams`].
///
/// # Parameters
///
/// - `phGraphNode`: Returns newly created node.
/// - `hGraph`: Graph to which to add the node.
/// - `dependencies`: Dependencies of the node.
/// - `dependencyData`: Optional edge data for the dependencies. If NULL, the data is assumed to be default (zeroed) for all dependencies.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Specification of the node.
pub fn cuGraphAddNode_v2(
phGraphNode: *mut CUgraphNode,
hGraph: CUgraph,
dependencies: *const CUgraphNode,
dependencyData: *const CUgraphEdgeData,
numDependencies: size_t,
nodeParams: *mut CUgraphNodeParams,
) -> CUresult;
}
unsafe extern "C" {
/// Update a graph node's parameters.
///
/// Sets the parameters of graph node hNode to nodeParams. The node type specified by nodeParams->type must match the type of hNode. nodeParams must be fully initialized and all unused bytes (reserved, padding) zeroed.
///
/// Modifying parameters is not supported for node types [`CUgraphNodeType::CU_GRAPH_NODE_TYPE_MEM_ALLOC`] and [`CUgraphNodeType::CU_GRAPH_NODE_TYPE_MEM_FREE`].
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphNodeGetParams`], [`cuGraphExecNodeSetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cuGraphNodeSetParams(
hNode: CUgraphNode,
nodeParams: *mut CUgraphNodeParams,
) -> CUresult;
}
unsafe extern "C" {
/// Return a graph node's parameters.
///
/// Returns the parameters of graph node hNode in \*nodeParams.
///
/// Any pointers returned in \*nodeParams point to driver-owned memory associated with the node. This memory remains valid until the node is destroyed. Any memory
/// pointed to from \*nodeParams must not be modified.
///
/// The returned parameters are a description of the node, but may not be identical to the struct provided at creation and may
/// not be suitable for direct creation of identical nodes. This is because parameters may be partially unspecified and filled
/// in by the driver at creation, may reference non-copyable handles, or may describe ownership semantics or other parameters
/// that govern behavior of node creation but are not part of the final functional descriptor.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphNodeSetParams`], [`cuGraphAddNode_v2`], [`cuGraphExecNodeSetParams`].
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `nodeParams`: Pointer to return the parameters.
pub fn cuGraphNodeGetParams(
hNode: CUgraphNode,
nodeParams: *mut CUgraphNodeParams,
) -> CUresult;
}
unsafe extern "C" {
/// Update a graph node's parameters in an instantiated graph.
///
/// Sets the parameters of a node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph from which the executable graph was instantiated. hNode must not have been removed from the original graph.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Allowed changes to parameters on executable graphs are as follows:
///
/// | Node type | Allowed changes |
/// | --- | --- |
/// | kernel | See [`cuGraphExecKernelNodeSetParams_v2`] |
/// | memcpy | Addresses for 1-dimensional copies if allocated in same context; see [`cuGraphExecMemcpyNodeSetParams`] |
/// | memset | Addresses for 1-dimensional memsets if allocated in same context; see [`cuGraphExecMemsetNodeSetParams`] |
/// | host | Unrestricted |
/// | child graph | Topology must match and restrictions apply recursively; see [`cuGraphExecUpdate_v2`] |
/// | event wait | Unrestricted |
/// | event record | Unrestricted |
/// | external semaphore signal | Number of semaphore operations cannot change |
/// | external semaphore wait | Number of semaphore operations cannot change |
/// | memory allocation | API unsupported |
/// | memory free | API unsupported |
/// | batch memops | Addresses, values, and operation type for wait operations; see [`cuGraphExecBatchMemOpNodeSetParams`] |
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`], [`cuGraphNodeSetParams`][`cuGraphExecUpdate_v2`], `cuGraphInstantiate`.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to update the specified node.
/// - `hNode`: Corresponding node from the graph from which graphExec was instantiated.
/// - `nodeParams`: Updated Parameters to set.
pub fn cuGraphExecNodeSetParams(
hGraphExec: CUgraphExec,
hNode: CUgraphNode,
nodeParams: *mut CUgraphNodeParams,
) -> CUresult;
}
unsafe extern "C" {
/// Create a conditional handle.
///
/// Creates a conditional handle associated with hGraph.
///
/// The conditional handle must be associated with a conditional node in this graph or one of its children.
///
/// Handles not associated with a conditional node may cause graph instantiation to fail.
///
/// Handles can only be set from the context with which they are associated.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphAddNode_v2`].
///
/// # Parameters
///
/// - `pHandle_out`: Pointer used to return the handle to the caller.
/// - `hGraph`: Graph which will contain the conditional node using this handle.
/// - `ctx`: Context for the handle and associated conditional node.
/// - `defaultLaunchValue`: Optional initial value for the conditional variable. Applied at the beginning of each graph execution if CU_GRAPH_COND_ASSIGN_DEFAULT
/// is set in flags.
/// - `flags`: Currently must be CU_GRAPH_COND_ASSIGN_DEFAULT or 0.
pub fn cuGraphConditionalHandleCreate(
pHandle_out: *mut CUgraphConditionalHandle,
hGraph: CUgraph,
ctx: CUcontext,
defaultLaunchValue: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Returns occupancy of a function.
///
/// Returns in \*numBlocks the number of the maximum active blocks per streaming multiprocessor.
///
/// Note that the API can also be used with context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to use for calculations will be the current context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaOccupancyMaxActiveBlocksPerMultiprocessor](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g5a5d67a3c907371559ba692195e8a38c).
///
/// # Parameters
///
/// - `numBlocks`: Returned occupancy.
/// - `func`: Kernel for which occupancy is calculated.
/// - `blockSize`: Block size the kernel is intended to be launched with.
/// - `dynamicSMemSize`: Per-block dynamic shared memory usage intended, in bytes.
pub fn cuOccupancyMaxActiveBlocksPerMultiprocessor(
numBlocks: *mut ::core::ffi::c_int,
func: CUfunction,
blockSize: ::core::ffi::c_int,
dynamicSMemSize: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Returns occupancy of a function.
///
/// Returns in \*numBlocks the number of the maximum active blocks per streaming multiprocessor.
///
/// The Flags parameter controls how special cases are handled. The valid flags are:
///
/// * [`CUoccupancy_flags_enum::CU_OCCUPANCY_DEFAULT`], which maintains the default behavior as [`cuOccupancyMaxActiveBlocksPerMultiprocessor`];
///
/// * [`CUoccupancy_flags_enum::CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE`], which suppresses the default behavior on platform where global caching affects occupancy. On such platforms, if caching
/// is enabled, but per-block SM resource usage would result in zero occupancy, the occupancy calculator will calculate the occupancy
/// as if caching is disabled. Setting [`CUoccupancy_flags_enum::CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE`] makes the occupancy calculator to return 0 in such cases. More information can be found about this feature in the "Unified
/// L1/Texture Cache" section of the Maxwell tuning guide.
///
/// Note that the API can also be with launch context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to use for calculations will be the current context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g603b86b20b37823253ff89fe8688ba83).
///
/// # Parameters
///
/// - `numBlocks`: Returned occupancy.
/// - `func`: Kernel for which occupancy is calculated.
/// - `blockSize`: Block size the kernel is intended to be launched with.
/// - `dynamicSMemSize`: Per-block dynamic shared memory usage intended, in bytes.
/// - `flags`: Requested behavior for the occupancy calculator.
pub fn cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
numBlocks: *mut ::core::ffi::c_int,
func: CUfunction,
blockSize: ::core::ffi::c_int,
dynamicSMemSize: size_t,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Suggest a launch configuration with reasonable occupancy.
///
/// Returns in \*blockSize a reasonable block size that can achieve the maximum occupancy (or, the maximum number of active warps with the fewest blocks
/// per multiprocessor), and in \*minGridSize the minimum grid size to achieve the maximum occupancy.
///
/// If blockSizeLimit is 0, the configurator will use the maximum block size permitted by the device / function instead.
///
/// If per-block dynamic shared memory allocation is not needed, the user should leave both blockSizeToDynamicSMemSize and dynamicSMemSize as 0.
///
/// If per-block dynamic shared memory allocation is needed, then if the dynamic shared memory size is constant regardless of
/// block size, the size should be passed through dynamicSMemSize, and blockSizeToDynamicSMemSize should be NULL.
///
/// Otherwise, if the per-block dynamic shared memory size varies with different block sizes, the user needs to provide a unary
/// function through blockSizeToDynamicSMemSize that computes the dynamic shared memory needed by func for any given block size. dynamicSMemSize is ignored. An example signature is:
///
/// ```text
/// // Take block size, returns dynamic shared memory needed
/// size_t blockToSmem(int blockSize);
/// ```
///
/// Note that the API can also be used with context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to use for calculations will be the current context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaOccupancyMaxPotentialBlockSize](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1gee5334618ed4bb0871e4559a77643fc1).
///
/// # Parameters
///
/// - `minGridSize`: Returned minimum grid size needed to achieve the maximum occupancy.
/// - `blockSize`: Returned maximum block size that can achieve the maximum occupancy.
/// - `func`: Kernel for which launch configuration is calculated.
/// - `blockSizeToDynamicSMemSize`: A function that calculates how much per-block dynamic shared memory func uses based on the block size.
/// - `dynamicSMemSize`: Dynamic shared memory usage intended, in bytes.
/// - `blockSizeLimit`: The maximum block size func is designed to handle.
pub fn cuOccupancyMaxPotentialBlockSize(
minGridSize: *mut ::core::ffi::c_int,
blockSize: *mut ::core::ffi::c_int,
func: CUfunction,
blockSizeToDynamicSMemSize: CUoccupancyB2DSize,
dynamicSMemSize: size_t,
blockSizeLimit: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Suggest a launch configuration with reasonable occupancy.
///
/// An extended version of [`cuOccupancyMaxPotentialBlockSize`]. In addition to arguments passed to [`cuOccupancyMaxPotentialBlockSize`], [`cuOccupancyMaxPotentialBlockSizeWithFlags`] also takes a Flags parameter.
///
/// The Flags parameter controls how special cases are handled. The valid flags are:
///
/// * [`CUoccupancy_flags_enum::CU_OCCUPANCY_DEFAULT`], which maintains the default behavior as [`cuOccupancyMaxPotentialBlockSize`];
///
/// * [`CUoccupancy_flags_enum::CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE`], which suppresses the default behavior on platform where global caching affects occupancy. On such platforms, the launch
/// configurations that produces maximal occupancy might not support global caching. Setting [`CUoccupancy_flags_enum::CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE`] guarantees that the produced launch configuration is global caching compatible at a potential cost of occupancy. More
/// information can be found about this feature in the "Unified L1/Texture Cache" section of the Maxwell tuning guide.
///
/// Note that the API can also be used with context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to use for calculations will be the current context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaOccupancyMaxPotentialBlockSizeWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1gd0524825c5c01bbc9a5e29e890745800).
///
/// # Parameters
///
/// - `minGridSize`: Returned minimum grid size needed to achieve the maximum occupancy.
/// - `blockSize`: Returned maximum block size that can achieve the maximum occupancy.
/// - `func`: Kernel for which launch configuration is calculated.
/// - `blockSizeToDynamicSMemSize`: A function that calculates how much per-block dynamic shared memory func uses based on the block size.
/// - `dynamicSMemSize`: Dynamic shared memory usage intended, in bytes.
/// - `blockSizeLimit`: The maximum block size func is designed to handle.
/// - `flags`: Options.
pub fn cuOccupancyMaxPotentialBlockSizeWithFlags(
minGridSize: *mut ::core::ffi::c_int,
blockSize: *mut ::core::ffi::c_int,
func: CUfunction,
blockSizeToDynamicSMemSize: CUoccupancyB2DSize,
dynamicSMemSize: size_t,
blockSizeLimit: ::core::ffi::c_int,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Returns dynamic shared memory available per block when launching numBlocks blocks on SM.
///
/// Returns in \*dynamicSmemSize the maximum size of dynamic shared memory to allow numBlocks blocks per SM.
///
/// Note that the API can also be used with context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to use for calculations will be the current context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `dynamicSmemSize`: Returned maximum dynamic shared memory.
/// - `func`: Kernel function for which occupancy is calculated.
/// - `numBlocks`: Number of blocks to fit on SM.
/// - `blockSize`: Size of the blocks.
pub fn cuOccupancyAvailableDynamicSMemPerBlock(
dynamicSmemSize: *mut size_t,
func: CUfunction,
numBlocks: ::core::ffi::c_int,
blockSize: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Given the kernel function (func) and launch configuration (config), return the maximum cluster size in \*clusterSize.
///
/// The cluster dimensions in config are ignored. If func has a required cluster size set (see [cudaFuncGetAttributes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g0e78e02c6d12ebddd4577ac6ebadf494) / [`cuFuncGetAttribute`]),\*clusterSize will reflect the required cluster size.
///
/// By default this function will always return a value that's portable on future hardware. A higher value may be returned if
/// the kernel function allows non-portable cluster sizes.
///
/// This function will respect the compile time launch bounds.
///
/// Note that the API can also be used with context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to use for calculations will either be taken from the specified stream config->hStream or the current context in case of NULL stream.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaFuncGetAttributes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g0e78e02c6d12ebddd4577ac6ebadf494), [`cuFuncGetAttribute`].
///
/// # Parameters
///
/// - `clusterSize`: Returned maximum cluster size that can be launched for the given kernel function and launch configuration.
/// - `func`: Kernel function for which maximum cluster size is calculated.
/// - `config`: Launch configuration for the given kernel function.
pub fn cuOccupancyMaxPotentialClusterSize(
clusterSize: *mut ::core::ffi::c_int,
func: CUfunction,
config: *const CUlaunchConfig,
) -> CUresult;
}
unsafe extern "C" {
/// Given the kernel function (func) and launch configuration (config), return the maximum number of clusters that could co-exist on the target device in \*numClusters.
///
/// If the function has required cluster size already set (see [cudaFuncGetAttributes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g0e78e02c6d12ebddd4577ac6ebadf494) / [`cuFuncGetAttribute`]), the cluster size from config must either be unspecified or match the required size. Without required sizes, the cluster
/// size must be specified in config, else the function will return an error.
///
/// Note that various attributes of the kernel function may affect occupancy calculation. Runtime environment may affect how the
/// hardware schedules the clusters, so the calculated occupancy is not guaranteed to be achievable.
///
/// Note that the API can also be used with context-less kernel [`CUkernel`] by querying the handle using [`cuLibraryGetKernel`] and then passing it to the API by casting to [`CUfunction`]. Here, the context to use for calculations will either be taken from the specified stream config->hStream or the current context in case of NULL stream.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaFuncGetAttributes](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g0e78e02c6d12ebddd4577ac6ebadf494), [`cuFuncGetAttribute`].
///
/// # Parameters
///
/// - `numClusters`: Returned maximum number of clusters that could co-exist on the target device.
/// - `func`: Kernel function for which maximum number of clusters are calculated.
/// - `config`: Launch configuration for the given kernel function.
pub fn cuOccupancyMaxActiveClusters(
numClusters: *mut ::core::ffi::c_int,
func: CUfunction,
config: *const CUlaunchConfig,
) -> CUresult;
}
unsafe extern "C" {
/// Binds an array as a texture reference.
///
/// hArray
///
/// hTexRef
///
/// Flags
///
/// [`CU_TRSA_OVERRIDE_FORMAT`]
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference to bind.
/// - `hArray`: Array to bind.
/// - `Flags`: Options (must be [`CU_TRSA_OVERRIDE_FORMAT`]).
#[deprecated]
pub fn cuTexRefSetArray(
hTexRef: CUtexref,
hArray: CUarray,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Binds a mipmapped array to a texture reference.
///
/// hMipmappedArray
///
/// hTexRef
///
/// Flags
///
/// [`CU_TRSA_OVERRIDE_FORMAT`]
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference to bind.
/// - `hMipmappedArray`: Mipmapped array to bind.
/// - `Flags`: Options (must be [`CU_TRSA_OVERRIDE_FORMAT`]).
#[deprecated]
pub fn cuTexRefSetMipmappedArray(
hTexRef: CUtexref,
hMipmappedArray: CUmipmappedArray,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Binds an address as a texture reference.
///
/// hTexRef
///
/// hTexRef
///
/// Since the hardware enforces an alignment requirement on texture base addresses, [`cuTexRefSetAddress_v2`] passes back a byte offset in \*ByteOffset that must be applied to texture fetches in order to read from the desired memory. This offset must be divided by the texel
/// size and passed to kernels that read from the texture so they can be applied to the tex1Dfetch() function.
///
/// If the device memory pointer was returned from [`cuMemAlloc_v2`], the offset is guaranteed to be 0 and NULL may be passed as the ByteOffset parameter.
///
/// The total number of elements (or texels) in the linear address range cannot exceed [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH`]. The number of elements is computed as (bytes / bytesPerElement), where bytesPerElement is determined from the data format and number of components set using [`cuTexRefSetFormat`].
///
/// **See also:**
///
/// [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `ByteOffset`: Returned byte offset.
/// - `hTexRef`: Texture reference to bind.
/// - `dptr`: Device pointer to bind.
/// - `bytes`: Size of memory to bind in bytes.
#[deprecated]
pub fn cuTexRefSetAddress_v2(
ByteOffset: *mut size_t,
hTexRef: CUtexref,
dptr: CUdeviceptr,
bytes: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Binds an address as a 2D texture reference.
///
/// hTexRef
///
/// hTexRef
///
/// Using a tex2D() function inside a kernel requires a call to either [`cuTexRefSetArray`] to bind the corresponding texture reference to an array, or [`cuTexRefSetAddress2D_v3`] to bind the texture reference to linear memory.
///
/// Function calls to [`cuTexRefSetFormat`] cannot follow calls to [`cuTexRefSetAddress2D_v3`] for the same texture reference.
///
/// It is required that dptr be aligned to the appropriate hardware-specific texture alignment. You can query this value using the device attribute [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT`]. If an unaligned dptr is supplied, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Pitch has to be aligned to the hardware-specific texture pitch alignment. This value can be queried using the device attribute
/// [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT`]. If an unaligned Pitch is supplied, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Width and Height, which are specified in elements (or texels), cannot exceed [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH`] and [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT`] respectively. Pitch, which is specified in bytes, cannot exceed [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH`].
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference to bind.
/// - `desc`: Descriptor of CUDA array.
/// - `dptr`: Device pointer to bind.
/// - `Pitch`: Line pitch in bytes.
#[deprecated]
pub fn cuTexRefSetAddress2D_v3(
hTexRef: CUtexref,
desc: *const CUDA_ARRAY_DESCRIPTOR,
dptr: CUdeviceptr,
Pitch: size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the format for a texture reference.
///
/// hTexRef
///
/// fmt
///
/// NumPackedComponents
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`], [cudaCreateChannelDesc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__HIGHLEVEL.html#group__CUDART__HIGHLEVEL_1g655725c27d8ffe75accb9b531ecf2d15).
///
/// # Parameters
///
/// - `hTexRef`: Texture reference.
/// - `fmt`: Format to set.
/// - `NumPackedComponents`: Number of components per array element.
#[deprecated]
pub fn cuTexRefSetFormat(
hTexRef: CUtexref,
fmt: CUarray_format,
NumPackedComponents: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the addressing mode for a texture reference.
///
/// am
///
/// dim
///
/// hTexRef
///
/// dim
///
/// dim
///
/// `CUaddress_mode`
///
/// ```text
/// typedef enum CUaddress_mode_enum {
/// CU_TR_ADDRESS_MODE_WRAP = 0,
/// CU_TR_ADDRESS_MODE_CLAMP = 1,
/// CU_TR_ADDRESS_MODE_MIRROR = 2,
/// CU_TR_ADDRESS_MODE_BORDER = 3
/// } CUaddress_mode;
/// ```
///
/// Note that this call has no effect if hTexRef is bound to linear memory. Also, if the flag, [`CU_TRSF_NORMALIZED_COORDINATES`], is not set, the only supported address mode is [`CUaddress_mode_enum::CU_TR_ADDRESS_MODE_CLAMP`].
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference.
/// - `dim`: Dimension.
/// - `am`: Addressing mode to set.
#[deprecated]
pub fn cuTexRefSetAddressMode(
hTexRef: CUtexref,
dim: ::core::ffi::c_int,
am: CUaddress_mode,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the filtering mode for a texture reference.
///
/// fm
///
/// hTexRef
///
/// ```text
/// typedef enum CUfilter_mode_enum {
/// CU_TR_FILTER_MODE_POINT = 0,
/// CU_TR_FILTER_MODE_LINEAR = 1
/// } CUfilter_mode;
/// ```
///
/// Note that this call has no effect if hTexRef is bound to linear memory.
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference.
/// - `fm`: Filtering mode to set.
#[deprecated]
pub fn cuTexRefSetFilterMode(hTexRef: CUtexref, fm: CUfilter_mode) -> CUresult;
}
unsafe extern "C" {
/// Sets the mipmap filtering mode for a texture reference.
///
/// fm
///
/// hTexRef
///
/// ```text
/// typedef enum CUfilter_mode_enum {
/// CU_TR_FILTER_MODE_POINT = 0,
/// CU_TR_FILTER_MODE_LINEAR = 1
/// } CUfilter_mode;
/// ```
///
/// Note that this call has no effect if hTexRef is not bound to a mipmapped array.
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference.
/// - `fm`: Filtering mode to set.
#[deprecated]
pub fn cuTexRefSetMipmapFilterMode(hTexRef: CUtexref, fm: CUfilter_mode) -> CUresult;
}
unsafe extern "C" {
/// Sets the mipmap level bias for a texture reference.
///
/// bias
///
/// hTexRef
///
/// Note that this call has no effect if hTexRef is not bound to a mipmapped array.
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference.
/// - `bias`: Mipmap level bias.
#[deprecated]
pub fn cuTexRefSetMipmapLevelBias(hTexRef: CUtexref, bias: f32) -> CUresult;
}
unsafe extern "C" {
/// Sets the mipmap min/max mipmap level clamps for a texture reference.
///
/// minMipmapLevelClamp
///
/// maxMipmapLevelClamp
///
/// hTexRef
///
/// Note that this call has no effect if hTexRef is not bound to a mipmapped array.
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference.
/// - `minMipmapLevelClamp`: Mipmap min level clamp.
/// - `maxMipmapLevelClamp`: Mipmap max level clamp.
#[deprecated]
pub fn cuTexRefSetMipmapLevelClamp(
hTexRef: CUtexref,
minMipmapLevelClamp: f32,
maxMipmapLevelClamp: f32,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the maximum anisotropy for a texture reference.
///
/// maxAniso
///
/// hTexRef
///
/// Note that this call has no effect if hTexRef is bound to linear memory.
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference.
/// - `maxAniso`: Maximum anisotropy.
#[deprecated]
pub fn cuTexRefSetMaxAnisotropy(
hTexRef: CUtexref,
maxAniso: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Sets the border color for a texture reference.
///
/// pBorderColor
///
/// hTexRef
///
/// Note that the color values can be set only when the Address mode is set to [`CUaddress_mode::CU_TR_ADDRESS_MODE_BORDER`] using [`cuTexRefSetAddressMode`]. Applications using integer border color values have to "reinterpret_cast" their values to float.
///
/// **See also:**
///
/// [`cuTexRefSetAddressMode`], [`cuTexRefGetAddressMode`], [`cuTexRefGetBorderColor`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference.
/// - `pBorderColor`: RGBA color.
#[deprecated]
pub fn cuTexRefSetBorderColor(hTexRef: CUtexref, pBorderColor: *mut f32) -> CUresult;
}
unsafe extern "C" {
/// Sets the flags for a texture reference.
///
/// Flags
///
/// hTexRef
///
/// * [`CU_TRSF_READ_AS_INTEGER`], which suppresses the default behavior of having the texture promote integer data to floating point data in the range \[0,
/// 1\]. Note that texture with 32-bit integer format would not be promoted, regardless of whether or not this flag is specified;
/// * [`CU_TRSF_NORMALIZED_COORDINATES`], which suppresses the default behavior of having the texture coordinates range from 0, Dim) where Dim is the width or height
/// of the CUDA array. Instead, the texture coordinates [0, 1.0) reference the entire breadth of the array dimension;
/// * [CU_TRSF_DISABLE_TRILINEAR_OPTIMIZATION, which disables any trilinear filtering optimizations. Trilinear optimizations improve texture filtering performance by allowing
/// bilinear filtering on textures in scenarios where it can closely approximate the expected results.
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference.
/// - `Flags`: Optional flags to set.
#[deprecated]
pub fn cuTexRefSetFlags(hTexRef: CUtexref, Flags: ::core::ffi::c_uint) -> CUresult;
}
unsafe extern "C" {
/// Gets the address associated with a texture reference.
///
/// \*pdptr
///
/// hTexRef
///
/// [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `pdptr`: Returned device address.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetAddress_v2(pdptr: *mut CUdeviceptr, hTexRef: CUtexref) -> CUresult;
}
unsafe extern "C" {
/// Gets the array bound to a texture reference.
///
/// \*phArray
///
/// hTexRef
///
/// [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `phArray`: Returned array.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetArray(phArray: *mut CUarray, hTexRef: CUtexref) -> CUresult;
}
unsafe extern "C" {
/// Gets the mipmapped array bound to a texture reference.
///
/// \*phMipmappedArray
///
/// hTexRef
///
/// [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `phMipmappedArray`: Returned mipmapped array.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetMipmappedArray(
phMipmappedArray: *mut CUmipmappedArray,
hTexRef: CUtexref,
) -> CUresult;
}
unsafe extern "C" {
/// Gets the addressing mode used by a texture reference.
///
/// \*pam
///
/// dim
///
/// hTexRef
///
/// dim
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `pam`: Returned addressing mode.
/// - `hTexRef`: Texture reference.
/// - `dim`: Dimension.
#[deprecated]
pub fn cuTexRefGetAddressMode(
pam: *mut CUaddress_mode,
hTexRef: CUtexref,
dim: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Gets the filter-mode used by a texture reference.
///
/// \*pfm
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `pfm`: Returned filtering mode.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetFilterMode(pfm: *mut CUfilter_mode, hTexRef: CUtexref) -> CUresult;
}
unsafe extern "C" {
/// Gets the format used by a texture reference.
///
/// \*pFormat
///
/// \*pNumChannels
///
/// hTexRef
///
/// pFormat
///
/// pNumChannels
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`].
///
/// # Parameters
///
/// - `pFormat`: Returned format.
/// - `pNumChannels`: Returned number of components.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetFormat(
pFormat: *mut CUarray_format,
pNumChannels: *mut ::core::ffi::c_int,
hTexRef: CUtexref,
) -> CUresult;
}
unsafe extern "C" {
/// Gets the mipmap filtering mode for a texture reference.
///
/// pfm
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `pfm`: Returned mipmap filtering mode.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetMipmapFilterMode(
pfm: *mut CUfilter_mode,
hTexRef: CUtexref,
) -> CUresult;
}
unsafe extern "C" {
/// Gets the mipmap level bias for a texture reference.
///
/// pBias
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `pbias`: Returned mipmap level bias.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetMipmapLevelBias(pbias: *mut f32, hTexRef: CUtexref) -> CUresult;
}
unsafe extern "C" {
/// Gets the min/max mipmap level clamps for a texture reference.
///
/// pminMipmapLevelClamp
///
/// pmaxMipmapLevelClamp
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `pminMipmapLevelClamp`: Returned mipmap min level clamp.
/// - `pmaxMipmapLevelClamp`: Returned mipmap max level clamp.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetMipmapLevelClamp(
pminMipmapLevelClamp: *mut f32,
pmaxMipmapLevelClamp: *mut f32,
hTexRef: CUtexref,
) -> CUresult;
}
unsafe extern "C" {
/// Gets the maximum anisotropy for a texture reference.
///
/// pmaxAniso
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFlags`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `pmaxAniso`: Returned maximum anisotropy.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetMaxAnisotropy(
pmaxAniso: *mut ::core::ffi::c_int,
hTexRef: CUtexref,
) -> CUresult;
}
unsafe extern "C" {
/// Gets the border color used by a texture reference.
///
/// pBorderColor
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefSetAddressMode`], [`cuTexRefSetAddressMode`], [`cuTexRefSetBorderColor`].
///
/// # Parameters
///
/// - `pBorderColor`: Returned Type and Value of RGBA color.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetBorderColor(pBorderColor: *mut f32, hTexRef: CUtexref) -> CUresult;
}
unsafe extern "C" {
/// Gets the flags used by a texture reference.
///
/// \*pFlags
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefSetAddress_v2`], [`cuTexRefSetAddress2D_v3`], [`cuTexRefSetAddressMode`], [`cuTexRefSetArray`], [`cuTexRefSetFilterMode`], [`cuTexRefSetFlags`], [`cuTexRefSetFormat`], [`cuTexRefGetAddress_v2`], [`cuTexRefGetAddressMode`], [`cuTexRefGetArray`], [`cuTexRefGetFilterMode`], [`cuTexRefGetFormat`].
///
/// # Parameters
///
/// - `pFlags`: Returned flags.
/// - `hTexRef`: Texture reference.
#[deprecated]
pub fn cuTexRefGetFlags(
pFlags: *mut ::core::ffi::c_uint,
hTexRef: CUtexref,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a texture reference.
///
/// \*pTexRef
///
/// [`cuTexRefSetArray`]
///
/// [`cuTexRefSetAddress_v2`]
///
/// **See also:**
///
/// [`cuTexRefDestroy`].
///
/// # Parameters
///
/// - `pTexRef`: Returned texture reference.
#[deprecated]
pub fn cuTexRefCreate(pTexRef: *mut CUtexref) -> CUresult;
}
unsafe extern "C" {
/// Destroys a texture reference.
///
/// hTexRef
///
/// **See also:**
///
/// [`cuTexRefCreate`].
///
/// # Parameters
///
/// - `hTexRef`: Texture reference to destroy.
#[deprecated]
pub fn cuTexRefDestroy(hTexRef: CUtexref) -> CUresult;
}
unsafe extern "C" {
/// Sets the CUDA array for a surface reference.
///
/// hArray
///
/// hSurfRef
///
/// Flags
///
/// [`CUDA_ARRAY3D_SURFACE_LDST`]
///
/// hSurfRef
///
/// **See also:**
///
/// [`cuModuleGetSurfRef`], [`cuSurfRefGetArray`].
///
/// # Parameters
///
/// - `hSurfRef`: Surface reference handle.
/// - `hArray`: CUDA array handle.
/// - `Flags`: set to 0.
#[deprecated]
pub fn cuSurfRefSetArray(
hSurfRef: CUsurfref,
hArray: CUarray,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Passes back the CUDA array bound to a surface reference.
///
/// \*phArray
///
/// hSurfRef
///
/// [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`]
///
/// **See also:**
///
/// [`cuModuleGetSurfRef`], [`cuSurfRefSetArray`].
///
/// # Parameters
///
/// - `phArray`: Surface reference handle.
/// - `hSurfRef`: Surface reference handle.
#[deprecated]
pub fn cuSurfRefGetArray(phArray: *mut CUarray, hSurfRef: CUsurfref) -> CUresult;
}
unsafe extern "C" {
/// Creates a texture object.
///
/// Creates a texture object and returns it in pTexObject. pResDesc describes the data to texture from. pTexDesc describes how the data should be sampled. pResViewDesc is an optional argument that specifies an alternate format for the data described by pResDesc, and also describes the subresource region to restrict access to when texturing. pResViewDesc can only be specified if the type of resource is a CUDA array or a CUDA mipmapped array not in a block compressed format.
///
/// Texture objects are only supported on devices of compute capability 3.0 or higher. Additionally, a texture object is an opaque
/// value, and, as such, should only be accessed through CUDA API calls.
///
/// The CUDA_RESOURCE_DESC structure is defined as:
///
/// ```text
/// typedef struct CUDA_RESOURCE_DESC_st
/// {
/// CUresourcetype resType;
///
/// union {
/// struct {
/// CUarray hArray;
/// } array;
/// struct {
/// CUmipmappedArray hMipmappedArray;
/// } mipmap;
/// struct {
/// CUdeviceptr devPtr;
/// CUarray_format format;
/// unsigned int numChannels;
/// size_t sizeInBytes;
/// } linear;
/// struct {
/// CUdeviceptr devPtr;
/// CUarray_format format;
/// unsigned int numChannels;
/// size_t width;
/// size_t height;
/// size_t pitchInBytes;
/// } pitch2D;
/// } res;
///
/// unsigned int flags;
/// } CUDA_RESOURCE_DESC;
/// ```
///
/// * [CUDA_RESOURCE_DESC::resType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__DESC__v1.html#structCUDA__RESOURCE__DESC__v1_1fe341889f4a57165e7acc0efcfc38b64) specifies the type of resource to texture from. CUresourceType is defined as:
///
/// ```text
/// typedef enum CUresourcetype_enum {
/// CU_RESOURCE_TYPE_ARRAY = 0x00,
/// CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01,
/// CU_RESOURCE_TYPE_LINEAR = 0x02,
/// CU_RESOURCE_TYPE_PITCH2D = 0x03
/// } CUresourcetype;
/// ```
///
/// If [CUDA_RESOURCE_DESC::resType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__DESC__v1.html#structCUDA__RESOURCE__DESC__v1_1fe341889f4a57165e7acc0efcfc38b64) is set to [`CUresourcetype_enum::CU_RESOURCE_TYPE_ARRAY`], CUDA_RESOURCE_DESC::res::array::hArray must be set to a valid CUDA array handle.
///
/// If [CUDA_RESOURCE_DESC::resType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__DESC__v1.html#structCUDA__RESOURCE__DESC__v1_1fe341889f4a57165e7acc0efcfc38b64) is set to [`CUresourcetype_enum::CU_RESOURCE_TYPE_MIPMAPPED_ARRAY`], CUDA_RESOURCE_DESC::res::mipmap::hMipmappedArray must be set to a valid CUDA mipmapped array handle.
///
/// If [CUDA_RESOURCE_DESC::resType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__DESC__v1.html#structCUDA__RESOURCE__DESC__v1_1fe341889f4a57165e7acc0efcfc38b64) is set to [`CUresourcetype_enum::CU_RESOURCE_TYPE_LINEAR`], CUDA_RESOURCE_DESC::res::linear::devPtr must be set to a valid device pointer, that is aligned to [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT`]. CUDA_RESOURCE_DESC::res::linear::format and CUDA_RESOURCE_DESC::res::linear::numChannels describe the format of each component
/// and the number of components per array element. CUDA_RESOURCE_DESC::res::linear::sizeInBytes specifies the size of the array
/// in bytes. The total number of elements in the linear address range cannot exceed [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH`]. The number of elements is computed as (sizeInBytes / (sizeof(format) \* numChannels)).
///
/// If [CUDA_RESOURCE_DESC::resType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__DESC__v1.html#structCUDA__RESOURCE__DESC__v1_1fe341889f4a57165e7acc0efcfc38b64) is set to [`CUresourcetype_enum::CU_RESOURCE_TYPE_PITCH2D`], CUDA_RESOURCE_DESC::res::pitch2D::devPtr must be set to a valid device pointer, that is aligned to [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT`]. CUDA_RESOURCE_DESC::res::pitch2D::format and CUDA_RESOURCE_DESC::res::pitch2D::numChannels describe the format of each component
/// and the number of components per array element. CUDA_RESOURCE_DESC::res::pitch2D::width and CUDA_RESOURCE_DESC::res::pitch2D::height
/// specify the width and height of the array in elements, and cannot exceed [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH`] and [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT`] respectively. CUDA_RESOURCE_DESC::res::pitch2D::pitchInBytes specifies the pitch between two rows in bytes and has to be
/// aligned to [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT`]. Pitch cannot exceed [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH`].
///
/// * flags must be set to zero.
///
/// The CUDA_TEXTURE_DESC struct is defined as
///
/// ```text
/// typedef struct CUDA_TEXTURE_DESC_st {
/// CUaddress_mode addressMode\[3\];
/// CUfilter_mode filterMode;
/// unsigned int flags;
/// unsigned int maxAnisotropy;
/// CUfilter_mode mipmapFilterMode;
/// float mipmapLevelBias;
/// float minMipmapLevelClamp;
/// float maxMipmapLevelClamp;
/// } CUDA_TEXTURE_DESC;
/// ```
///
/// * [CUDA_TEXTURE_DESC::addressMode](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_1aeb3f6fa73835433a7700b80eea8d49b) specifies the addressing mode for each dimension of the texture data. `CUaddress_mode` is defined as:
///
/// ```text
/// typedef enum CUaddress_mode_enum {
/// CU_TR_ADDRESS_MODE_WRAP = 0,
/// CU_TR_ADDRESS_MODE_CLAMP = 1,
/// CU_TR_ADDRESS_MODE_MIRROR = 2,
/// CU_TR_ADDRESS_MODE_BORDER = 3
/// } CUaddress_mode;
/// ```
///
/// This is ignored if [CUDA_RESOURCE_DESC::resType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__DESC__v1.html#structCUDA__RESOURCE__DESC__v1_1fe341889f4a57165e7acc0efcfc38b64) is [`CUresourcetype_enum::CU_RESOURCE_TYPE_LINEAR`]. Also, if the flag, [`CU_TRSF_NORMALIZED_COORDINATES`] is not set, the only supported address mode is [`CUaddress_mode_enum::CU_TR_ADDRESS_MODE_CLAMP`].
///
/// * [CUDA_TEXTURE_DESC::filterMode](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_182e92599f2f13422d8cc6cfe947e6b17) specifies the filtering mode to be used when fetching from the texture. CUfilter_mode is defined as:
///
/// ```text
/// typedef enum CUfilter_mode_enum {
/// CU_TR_FILTER_MODE_POINT = 0,
/// CU_TR_FILTER_MODE_LINEAR = 1
/// } CUfilter_mode;
/// ```
///
/// This is ignored if [CUDA_RESOURCE_DESC::resType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__DESC__v1.html#structCUDA__RESOURCE__DESC__v1_1fe341889f4a57165e7acc0efcfc38b64) is [`CUresourcetype_enum::CU_RESOURCE_TYPE_LINEAR`].
///
/// * [CUDA_TEXTURE_DESC::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_1f50575c45ea8767561db54f4e785cabd) can be any combination of the following:
/// + [`CU_TRSF_READ_AS_INTEGER`], which suppresses the default behavior of having the texture promote integer data to floating point data in the range [0,
/// ```text
/// 1]. Note that texture with 32-bit integer format would not be promoted, regardless of whether or not this flag is specified.
/// ```
/// + [`CU_TRSF_NORMALIZED_COORDINATES`], which suppresses the default behavior of having the texture coordinates range from 0, Dim) where Dim is the width or height
/// ```text
/// of the CUDA array. Instead, the texture coordinates [0, 1.0) reference the entire breadth of the array dimension; Note that
/// for CUDA mipmapped arrays, this flag has to be set.
/// ```
/// + [CU_TRSF_DISABLE_TRILINEAR_OPTIMIZATION, which disables any trilinear filtering optimizations. Trilinear optimizations improve texture filtering performance by allowing
/// bilinear filtering on textures in scenarios where it can closely approximate the expected results.
/// + [`CU_TRSF_SEAMLESS_CUBEMAP`], which enables seamless cube map filtering. This flag can only be specified if the underlying resource is a CUDA array or
/// a CUDA mipmapped array that was created with the flag [`CUDA_ARRAY3D_CUBEMAP`]. When seamless cube map filtering is enabled, texture address modes specified by [CUDA_TEXTURE_DESC::addressMode](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_1aeb3f6fa73835433a7700b80eea8d49b) are ignored. Instead, if the [CUDA_TEXTURE_DESC::filterMode](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_182e92599f2f13422d8cc6cfe947e6b17) is set to [`CUfilter_mode_enum::CU_TR_FILTER_MODE_POINT`] the address mode [`CUaddress_mode_enum::CU_TR_ADDRESS_MODE_CLAMP`] will be applied for all dimensions. If the [CUDA_TEXTURE_DESC::filterMode](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_182e92599f2f13422d8cc6cfe947e6b17) is set to [`CUfilter_mode_enum::CU_TR_FILTER_MODE_LINEAR`] seamless cube map filtering will be performed when sampling along the cube face borders.
///
/// * [CUDA_TEXTURE_DESC::maxAnisotropy](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_139035372a07e031d233445673427f34a) specifies the maximum anisotropy ratio to be used when doing anisotropic filtering. This value will be clamped to the range
/// \[1,16\].
///
/// * [CUDA_TEXTURE_DESC::mipmapFilterMode](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_117333d832def1d97420ddd0bce8c73ce) specifies the filter mode when the calculated mipmap level lies between two defined mipmap levels.
///
/// * [CUDA_TEXTURE_DESC::mipmapLevelBias](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_10b1c10e7f1eedc4a8ab547da5741ce2d) specifies the offset to be applied to the calculated mipmap level.
///
/// * [CUDA_TEXTURE_DESC::minMipmapLevelClamp](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_1bf7da8359ccf52ba8afcd28c31b48be8) specifies the lower end of the mipmap level range to clamp access to.
///
/// * [CUDA_TEXTURE_DESC::maxMipmapLevelClamp](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_1149eca11ac6059979a1754bffcc6c210) specifies the upper end of the mipmap level range to clamp access to.
///
/// The CUDA_RESOURCE_VIEW_DESC struct is defined as
///
/// ```text
/// typedef struct CUDA_RESOURCE_VIEW_DESC_st
/// {
/// CUresourceViewFormat format;
/// size_t width;
/// size_t height;
/// size_t depth;
/// unsigned int firstMipmapLevel;
/// unsigned int lastMipmapLevel;
/// unsigned int firstLayer;
/// unsigned int lastLayer;
/// } CUDA_RESOURCE_VIEW_DESC;
/// ```
///
/// * [CUDA_RESOURCE_VIEW_DESC::format](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__VIEW__DESC__v1.html#structCUDA__RESOURCE__VIEW__DESC__v1_17ee307ae64bba468ea89bb502d3f8386) specifies how the data contained in the CUDA array or CUDA mipmapped array should be interpreted. Note that this can incur
/// a change in size of the texture data. If the resource view format is a block compressed format, then the underlying CUDA array
/// or CUDA mipmapped array has to have a base of format [`CUarray_format_enum::CU_AD_FORMAT_UNSIGNED_INT32`]. with 2 or 4 channels, depending on the block compressed format. For ex., BC1 and BC4 require the underlying CUDA array to
/// have a format of [`CUarray_format_enum::CU_AD_FORMAT_UNSIGNED_INT32`] with 2 channels. The other BC formats require the underlying resource to have the same base format but with 4 channels.
///
/// * [CUDA_RESOURCE_VIEW_DESC::width](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__VIEW__DESC__v1.html#structCUDA__RESOURCE__VIEW__DESC__v1_17a74f483b2af8a73d2a1876688926e63) specifies the new width of the texture data. If the resource view format is a block compressed format, this value has to
/// be 4 times the original width of the resource. For non block compressed formats, this value has to be equal to that of the
/// original resource.
///
/// * [CUDA_RESOURCE_VIEW_DESC::height](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__VIEW__DESC__v1.html#structCUDA__RESOURCE__VIEW__DESC__v1_1a2737a7f88568199ab94d7c3f696bed3) specifies the new height of the texture data. If the resource view format is a block compressed format, this value has to
/// be 4 times the original height of the resource. For non block compressed formats, this value has to be equal to that of the
/// original resource.
///
/// * [CUDA_RESOURCE_VIEW_DESC::depth](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__VIEW__DESC__v1.html#structCUDA__RESOURCE__VIEW__DESC__v1_164ca74e2623b821d8dfbbabbc5c839f6) specifies the new depth of the texture data. This value has to be equal to that of the original resource.
///
/// * [CUDA_RESOURCE_VIEW_DESC::firstMipmapLevel](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__VIEW__DESC__v1.html#structCUDA__RESOURCE__VIEW__DESC__v1_134105380b4498ef2a7b6f9898f983df3) specifies the most detailed mipmap level. This will be the new mipmap level zero. For non-mipmapped resources, this value
/// has to be zero.[CUDA_TEXTURE_DESC::minMipmapLevelClamp](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_1bf7da8359ccf52ba8afcd28c31b48be8) and [CUDA_TEXTURE_DESC::maxMipmapLevelClamp](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__TEXTURE__DESC__v1.html#structCUDA__TEXTURE__DESC__v1_1149eca11ac6059979a1754bffcc6c210) will be relative to this value. For ex., if the firstMipmapLevel is set to 2, and a minMipmapLevelClamp of 1.2 is specified,
/// then the actual minimum mipmap level clamp will be 3.2.
///
/// * [CUDA_RESOURCE_VIEW_DESC::lastMipmapLevel](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__VIEW__DESC__v1.html#structCUDA__RESOURCE__VIEW__DESC__v1_16e0dc4da9bcf7518fc66aee8f0dd928e) specifies the least detailed mipmap level. For non-mipmapped resources, this value has to be zero.
///
/// * [CUDA_RESOURCE_VIEW_DESC::firstLayer](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__VIEW__DESC__v1.html#structCUDA__RESOURCE__VIEW__DESC__v1_154262bb560a5c52aa73dfe97077334f9) specifies the first layer index for layered textures. This will be the new layer zero. For non-layered resources, this value
/// has to be zero.
///
/// * [CUDA_RESOURCE_VIEW_DESC::lastLayer](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__VIEW__DESC__v1.html#structCUDA__RESOURCE__VIEW__DESC__v1_14f2845ad9438911320a33e3fb1017964) specifies the last layer index for layered textures. For non-layered resources, this value has to be zero.
///
/// **See also:**
///
/// [`cuTexObjectDestroy`], [cudaCreateTextureObject](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TEXTURE__OBJECT.html#group__CUDART__TEXTURE__OBJECT_1g16ac75814780c3a16e4c63869feb9ad3).
///
/// # Parameters
///
/// - `pTexObject`: Texture object to create.
/// - `pResDesc`: Resource descriptor.
/// - `pTexDesc`: Texture descriptor.
/// - `pResViewDesc`: Resource view descriptor.
pub fn cuTexObjectCreate(
pTexObject: *mut CUtexObject,
pResDesc: *const CUDA_RESOURCE_DESC,
pTexDesc: *const CUDA_TEXTURE_DESC,
pResViewDesc: *const CUDA_RESOURCE_VIEW_DESC,
) -> CUresult;
}
unsafe extern "C" {
/// Destroys a texture object.
///
/// Destroys the texture object specified by texObject.
///
/// **See also:**
///
/// [`cuTexObjectCreate`], [cudaDestroyTextureObject](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TEXTURE__OBJECT.html#group__CUDART__TEXTURE__OBJECT_1g27be12e215f162cc877be94390da75bb).
///
/// # Parameters
///
/// - `texObject`: Texture object to destroy.
pub fn cuTexObjectDestroy(texObject: CUtexObject) -> CUresult;
}
unsafe extern "C" {
/// Returns a texture object's resource descriptor.
///
/// Returns the resource descriptor for the texture object specified by texObject.
///
/// **See also:**
///
/// [`cuTexObjectCreate`], [cudaGetTextureObjectResourceDesc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TEXTURE__OBJECT.html#group__CUDART__TEXTURE__OBJECT_1g4ac6e3f033c356ecc4ab6fb85154f066),.
///
/// # Parameters
///
/// - `pResDesc`: Resource descriptor.
/// - `texObject`: Texture object.
pub fn cuTexObjectGetResourceDesc(
pResDesc: *mut CUDA_RESOURCE_DESC,
texObject: CUtexObject,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a texture object's texture descriptor.
///
/// Returns the texture descriptor for the texture object specified by texObject.
///
/// **See also:**
///
/// [`cuTexObjectCreate`], [cudaGetTextureObjectTextureDesc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TEXTURE__OBJECT.html#group__CUDART__TEXTURE__OBJECT_1g152565714ff9dce6867b6099afc05e50).
///
/// # Parameters
///
/// - `pTexDesc`: Texture descriptor.
/// - `texObject`: Texture object.
pub fn cuTexObjectGetTextureDesc(
pTexDesc: *mut CUDA_TEXTURE_DESC,
texObject: CUtexObject,
) -> CUresult;
}
unsafe extern "C" {
/// Returns a texture object's resource view descriptor.
///
/// Returns the resource view descriptor for the texture object specified by texObject. If no resource view was set for texObject, the [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// **See also:**
///
/// [`cuTexObjectCreate`], [cudaGetTextureObjectResourceViewDesc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__TEXTURE__OBJECT.html#group__CUDART__TEXTURE__OBJECT_1g0332bef8105771003c64d7f09d6163fe).
///
/// # Parameters
///
/// - `pResViewDesc`: Resource view descriptor.
/// - `texObject`: Texture object.
pub fn cuTexObjectGetResourceViewDesc(
pResViewDesc: *mut CUDA_RESOURCE_VIEW_DESC,
texObject: CUtexObject,
) -> CUresult;
}
unsafe extern "C" {
/// Creates a surface object.
///
/// Creates a surface object and returns it in pSurfObject. pResDesc describes the data to perform surface load/stores on. [CUDA_RESOURCE_DESC::resType](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__DESC__v1.html#structCUDA__RESOURCE__DESC__v1_1fe341889f4a57165e7acc0efcfc38b64) must be [`CUresourcetype_enum::CU_RESOURCE_TYPE_ARRAY`] and CUDA_RESOURCE_DESC::res::array::hArray must be set to a valid CUDA array handle. [CUDA_RESOURCE_DESC::flags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/structCUDA__RESOURCE__DESC__v1.html#structCUDA__RESOURCE__DESC__v1_1857d9251dec54700bd8cd071accc3bdf) must be set to zero.
///
/// Surface objects are only supported on devices of compute capability 3.0 or higher. Additionally, a surface object is an opaque
/// value, and, as such, should only be accessed through CUDA API calls.
///
/// **See also:**
///
/// [`cuSurfObjectDestroy`], [cudaCreateSurfaceObject](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__SURFACE__OBJECT.html#group__CUDART__SURFACE__OBJECT_1g958899474ab2c5f40d233b524d6c5a01).
///
/// # Parameters
///
/// - `pSurfObject`: Surface object to create.
/// - `pResDesc`: Resource descriptor.
pub fn cuSurfObjectCreate(
pSurfObject: *mut CUsurfObject,
pResDesc: *const CUDA_RESOURCE_DESC,
) -> CUresult;
}
unsafe extern "C" {
/// Destroys a surface object.
///
/// Destroys the surface object specified by surfObject.
///
/// **See also:**
///
/// [`cuSurfObjectCreate`], [cudaDestroySurfaceObject](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__SURFACE__OBJECT.html#group__CUDART__SURFACE__OBJECT_1g9fab66c3a39b9f8f52b718eea794ad60).
///
/// # Parameters
///
/// - `surfObject`: Surface object to destroy.
pub fn cuSurfObjectDestroy(surfObject: CUsurfObject) -> CUresult;
}
unsafe extern "C" {
/// Returns a surface object's resource descriptor.
///
/// Returns the resource descriptor for the surface object specified by surfObject.
///
/// **See also:**
///
/// [`cuSurfObjectCreate`], [cudaGetSurfaceObjectResourceDesc](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__SURFACE__OBJECT.html#group__CUDART__SURFACE__OBJECT_1gd7087318f73ae605645d6721d51486bd).
///
/// # Parameters
///
/// - `pResDesc`: Resource descriptor.
/// - `surfObject`: Surface object.
pub fn cuSurfObjectGetResourceDesc(
pResDesc: *mut CUDA_RESOURCE_DESC,
surfObject: CUsurfObject,
) -> CUresult;
}
unsafe extern "C" {
/// Create a tensor map descriptor object representing tiled memory region.
///
/// Creates a descriptor for Tensor Memory Access (TMA) object specified by the parameters describing a tiled region and returns
/// it in tensorMap.
///
/// Tensor map objects are only supported on devices of compute capability 9.0 or higher. Additionally, a tensor map object is
/// an opaque value, and, as such, should only be accessed through CUDA APIs and PTX.
///
/// The parameters passed are bound to the following requirements:
///
/// * tensorMap address must be aligned to 64 bytes.
///
/// * tensorDataType has to be an enum from `CUtensorMapDataType` which is defined as:
///
/// ```text
/// typedef enum CUtensorMapDataType_enum {
/// CU_TENSOR_MAP_DATA_TYPE_UINT8 = 0, // 1 byte
/// CU_TENSOR_MAP_DATA_TYPE_UINT16, // 2 bytes
/// CU_TENSOR_MAP_DATA_TYPE_UINT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_INT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_UINT64, // 8 bytes
/// CU_TENSOR_MAP_DATA_TYPE_INT64, // 8 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT16, // 2 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT64, // 8 bytes
/// CU_TENSOR_MAP_DATA_TYPE_BFLOAT16, // 2 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_TFLOAT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, // 4 bits
/// CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, // 4 bits
/// CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B // 6 bits
/// } CUtensorMapDataType;
/// ```
///
/// [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B`] copies '16 x U4' packed values to memory aligned as 8 bytes. There are no gaps between
/// packed values. [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`] copies '16 x U4' packed values to memory aligned as 16 bytes. There are
/// 8 byte gaps between every 8 byte chunk of packed values. [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] copies '16 x U6' packed values
/// to memory aligned as 16 bytes. There are 4 byte gaps between every 12 byte chunk of packed values.
///
/// * tensorRank must be non-zero and less than or equal to the maximum supported dimensionality of 5. If interleave is not [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`], then tensorRank must additionally be greater than or equal to 3.
///
/// * globalAddress, which specifies the starting address of the memory region described, must be 16 byte aligned. The following requirements
/// need to also be met:
/// + When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_32B`], globalAddress must be 32 byte aligned.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], globalAddress must be 32 byte aligned.
///
/// * globalDim array, which specifies tensor size of each of the tensorRank dimensions, must be non-zero and less than or equal to 2^32. Additionally, the following requirements need to be met for
/// the packed data types:
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], globalDim\[0\] must be a multiple of 128.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B`], globalDim\[0\] must be a multiple of 2.
/// + Dimension for the packed data types must reflect the number of individual U# values.
///
/// * globalStrides array, which specifies tensor stride of each of the lower tensorRank - 1 dimensions in bytes, must be a multiple of 16 and less than 2^40. Additionally, the following requirements need to be
/// met:
/// + When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_32B`], the strides must be a multiple of 32.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], the strides must be a multiple of 32.
/// Each following dimension specified includes previous dimension stride:
///
/// ```text
/// globalStrides\[0\] = globalDim\[0\] * elementSizeInBytes(tensorDataType) + padding\[0\];
/// for (i = 1; i < tensorRank - 1; i++)
/// globalStrides\[i\] = globalStrides\[i – 1\] * (globalDim\[i\] + padding\[i\]);
/// assert(globalStrides\[i\] >= globalDim\[i\]);
/// ```
///
/// * boxDim array, which specifies number of elements to be traversed along each of the tensorRank dimensions, must be non-zero and less than or equal to 256. Additionally, the following requirements need to be met:
/// + When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`], { boxDim\[0\] \* elementSizeInBytes( tensorDataType ) } must be a multiple of 16 bytes.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], boxDim\[0\] must be 128.
///
/// * elementStrides array, which specifies the iteration step along each of the tensorRank dimensions, must be non-zero and less than or equal to 8. Note that when interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`], the first element of this array is ignored since TMA doesn’t support the stride for dimension
/// zero. When all elements of elementStrides array is one, boxDim specifies the number of elements to load. However, if the elementStrides\[i\] is not equal to one, then TMA loads ceil( boxDim\[i\] / elementStrides\[i\]) number of elements along i-th dimension. To load N elements along i-th dimension, boxDim\[i\] must be set to N \* elementStrides\[i\].
///
/// * interleave specifies the interleaved layout of type `CUtensorMapInterleave`, which is defined as:
///
/// ```text
/// typedef enum CUtensorMapInterleave_enum {
/// CU_TENSOR_MAP_INTERLEAVE_NONE = 0,
/// CU_TENSOR_MAP_INTERLEAVE_16B,
/// CU_TENSOR_MAP_INTERLEAVE_32B
/// } CUtensorMapInterleave;
/// ```
///
/// TMA supports interleaved layouts like NC/8HWC8 where C8 utilizes 16 bytes in memory assuming 2 byte per channel or NC/16HWC16
/// where C16 uses 32 bytes. When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`] and swizzle is not [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_NONE`], the bounding box inner dimension (computed as boxDim\[0\] multiplied by element size derived from tensorDataType) must be less than or equal to the swizzle size.
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_32B`] requires the bounding box inner dimension to be <= 32.
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_64B`] requires the bounding box inner dimension to be <= 64.
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B`]\* require the bounding box inner dimension to be <= 128. Additionally, tensorDataType of [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] requires interleave to be [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`].
///
/// * swizzle, which specifies the shared memory bank swizzling pattern, has to be of type `CUtensorMapSwizzle` which is defined as:
///
/// ```text
/// typedef enum CUtensorMapSwizzle_enum {
/// CU_TENSOR_MAP_SWIZZLE_NONE = 0,
/// CU_TENSOR_MAP_SWIZZLE_32B, // Swizzle 16B chunks within 32B span
/// CU_TENSOR_MAP_SWIZZLE_64B, // Swizzle 16B chunks within 64B span
/// CU_TENSOR_MAP_SWIZZLE_128B, // Swizzle 16B chunks within 128B span
/// CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B, // Swizzle 32B chunks within 128B span
/// CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B_FLIP_8B, // Swizzle 32B chunks within 128B span, additionally swap lower 8B with upper 8B within each 16B for every alternate row
/// CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B, // Swizzle 64B chunks within 128B span
/// } CUtensorMapSwizzle;
/// ```
///
/// Data are organized in a specific order in global memory; however, this may not match the order in which the application accesses
/// data in shared memory. This difference in data organization may cause bank conflicts when shared memory is accessed. In order
/// to avoid this problem, data can be loaded to shared memory with shuffling across shared memory banks. When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_32B`], swizzle must be [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_32B`]. Other interleave modes can have any swizzling pattern. When the tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`], only the following swizzle modes are supported:
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_NONE`] (Load & Store)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B`] (Load & Store)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B`] (Load & Store)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B`] (Store only) When the tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], only the following swizzle modes are supported:
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_NONE`] (Load only)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B`] (Load only)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B`] (Load only)
///
/// * l2Promotion specifies L2 fetch size which indicates the byte granurality at which L2 requests is filled from DRAM. It must be of type
/// `CUtensorMapL2promotion`, which is defined as:
///
/// ```text
/// typedef enum CUtensorMapL2promotion_enum {
/// CU_TENSOR_MAP_L2_PROMOTION_NONE = 0,
/// CU_TENSOR_MAP_L2_PROMOTION_L2_64B,
/// CU_TENSOR_MAP_L2_PROMOTION_L2_128B,
/// CU_TENSOR_MAP_L2_PROMOTION_L2_256B
/// } CUtensorMapL2promotion;
/// ```
///
/// * oobFill, which indicates whether zero or a special NaN constant should be used to fill out-of-bound elements, must be of type `CUtensorMapFloatOOBfill` which is defined as:
///
/// ```text
/// typedef enum CUtensorMapFloatOOBfill_enum {
/// CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE = 0,
/// CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA
/// } CUtensorMapFloatOOBfill;
/// ```
///
/// Note that [`CUtensorMapFloatOOBfill::CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA`] can only be used when tensorDataType represents a floating-point data type, and when tensorDataType is not [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B`], [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], and [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`].
///
/// **See also:**
///
/// [`cuTensorMapEncodeIm2col`], [`cuTensorMapEncodeIm2colWide`], [`cuTensorMapReplaceAddress`].
///
/// # Parameters
///
/// - `tensorMap`: Tensor map object to create.
/// - `tensorDataType`: Tensor data type.
/// - `tensorRank`: Dimensionality of tensor.
/// - `globalAddress`: Starting address of memory region described by tensor.
/// - `globalDim`: Array containing tensor size (number of elements) along each of the tensorRank dimensions.
/// - `globalStrides`: Array containing stride size (in bytes) along each of the tensorRank - 1 dimensions.
/// - `boxDim`: Array containing traversal box size (number of elments) along each of the tensorRank dimensions. Specifies how many elements to be traversed along each tensor dimension.
/// - `elementStrides`: Array containing traversal stride in each of the tensorRank dimensions.
/// - `interleave`: Type of interleaved layout the tensor addresses.
/// - `swizzle`: Bank swizzling pattern inside shared memory.
/// - `l2Promotion`: L2 promotion size.
/// - `oobFill`: Indicate whether zero or special NaN constant must be used to fill out-of-bound elements.
pub fn cuTensorMapEncodeTiled(
tensorMap: *mut CUtensorMap,
tensorDataType: CUtensorMapDataType,
tensorRank: cuuint32_t,
globalAddress: *mut ::core::ffi::c_void,
globalDim: *const cuuint64_t,
globalStrides: *const cuuint64_t,
boxDim: *const cuuint32_t,
elementStrides: *const cuuint32_t,
interleave: CUtensorMapInterleave,
swizzle: CUtensorMapSwizzle,
l2Promotion: CUtensorMapL2promotion,
oobFill: CUtensorMapFloatOOBfill,
) -> CUresult;
}
unsafe extern "C" {
/// Create a tensor map descriptor object representing im2col memory region.
///
/// Creates a descriptor for Tensor Memory Access (TMA) object specified by the parameters describing a im2col memory layout and
/// returns it in tensorMap.
///
/// Tensor map objects are only supported on devices of compute capability 9.0 or higher. Additionally, a tensor map object is
/// an opaque value, and, as such, should only be accessed through CUDA APIs and PTX.
///
/// The parameters passed are bound to the following requirements:
///
/// * tensorMap address must be aligned to 64 bytes.
///
/// * tensorDataType has to be an enum from `CUtensorMapDataType` which is defined as:
///
/// ```text
/// typedef enum CUtensorMapDataType_enum {
/// CU_TENSOR_MAP_DATA_TYPE_UINT8 = 0, // 1 byte
/// CU_TENSOR_MAP_DATA_TYPE_UINT16, // 2 bytes
/// CU_TENSOR_MAP_DATA_TYPE_UINT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_INT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_UINT64, // 8 bytes
/// CU_TENSOR_MAP_DATA_TYPE_INT64, // 8 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT16, // 2 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT64, // 8 bytes
/// CU_TENSOR_MAP_DATA_TYPE_BFLOAT16, // 2 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_TFLOAT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, // 4 bits
/// CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, // 4 bits
/// CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B // 6 bits
/// } CUtensorMapDataType;
/// ```
///
/// [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B`] copies '16 x U4' packed values to memory aligned as 8 bytes. There are no gaps between
/// packed values. [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`] copies '16 x U4' packed values to memory aligned as 16 bytes. There are
/// 8 byte gaps between every 8 byte chunk of packed values. [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] copies '16 x U6' packed values
/// to memory aligned as 16 bytes. There are 4 byte gaps between every 12 byte chunk of packed values.
///
/// * tensorRank, which specifies the number of tensor dimensions, must be 3, 4, or 5.
///
/// * globalAddress, which specifies the starting address of the memory region described, must be 16 byte aligned. The following requirements
/// need to also be met:
/// + When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_32B`], globalAddress must be 32 byte aligned.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], globalAddress must be 32 byte aligned.
///
/// * globalDim array, which specifies tensor size of each of the tensorRank dimensions, must be non-zero and less than or equal to 2^32. Additionally, the following requirements need to be met for
/// the packed data types:
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], globalDim\[0\] must be a multiple of 128.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B`], globalDim\[0\] must be a multiple of 2.
/// + Dimension for the packed data types must reflect the number of individual U# values.
///
/// * globalStrides array, which specifies tensor stride of each of the lower tensorRank - 1 dimensions in bytes, must be a multiple of 16 and less than 2^40. Additionally, the following requirements need to be
/// met:
/// + When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_32B`], the strides must be a multiple of 32.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], the strides must be a multiple of 32.
/// Each following dimension specified includes previous dimension stride:
///
/// ```text
/// globalStrides\[0\] = globalDim\[0\] * elementSizeInBytes(tensorDataType) + padding\[0\];
/// for (i = 1; i < tensorRank - 1; i++)
/// globalStrides\[i\] = globalStrides\[i – 1\] * (globalDim\[i\] + padding\[i\]);
/// assert(globalStrides\[i\] >= globalDim\[i\]);
/// ```
///
/// * pixelBoxLowerCorner array specifies the coordinate offsets {D, H, W} of the bounding box from top/left/front corner. The number of offsets and
/// their precision depend on the tensor dimensionality:
/// + When tensorRank is 3, one signed offset within range \[-32768, 32767\] is supported.
/// + When tensorRank is 4, two signed offsets each within range \[-128, 127\] are supported.
/// + When tensorRank is 5, three offsets each within range \[-16, 15\] are supported.
///
/// * pixelBoxUpperCorner array specifies the coordinate offsets {D, H, W} of the bounding box from bottom/right/back corner. The number of offsets
/// and their precision depend on the tensor dimensionality:
/// + When tensorRank is 3, one signed offset within range \[-32768, 32767\] is supported.
/// + When tensorRank is 4, two signed offsets each within range \[-128, 127\] are supported.
/// + When tensorRank is 5, three offsets each within range \[-16, 15\] are supported. The bounding box specified by pixelBoxLowerCorner and pixelBoxUpperCorner must have non-zero area.
///
/// * channelsPerPixel, which specifies the number of elements which must be accessed along C dimension, must be less than or equal to 256. Additionally,
/// when tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], channelsPerPixel must be 128.
///
/// * pixelsPerColumn, which specifies the number of elements that must be accessed along the {N, D, H, W} dimensions, must be less than or equal
/// to 1024.
///
/// * elementStrides array, which specifies the iteration step along each of the tensorRank dimensions, must be non-zero and less than or equal to 8. Note that when interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`], the first element of this array is ignored since TMA doesn’t support the stride for dimension
/// zero. When all elements of the elementStrides array are one, boxDim specifies the number of elements to load. However, if elementStrides\[i\] is not equal to one for some i, then TMA loads ceil( boxDim\[i\] / elementStrides\[i\]) number of elements along i-th dimension. To load N elements along i-th dimension, boxDim\[i\] must be set to N \* elementStrides\[i\].
///
/// * interleave specifies the interleaved layout of type `CUtensorMapInterleave`, which is defined as:
///
/// ```text
/// typedef enum CUtensorMapInterleave_enum {
/// CU_TENSOR_MAP_INTERLEAVE_NONE = 0,
/// CU_TENSOR_MAP_INTERLEAVE_16B,
/// CU_TENSOR_MAP_INTERLEAVE_32B
/// } CUtensorMapInterleave;
/// ```
///
/// TMA supports interleaved layouts like NC/8HWC8 where C8 utilizes 16 bytes in memory assuming 2 byte per channel or NC/16HWC16
/// where C16 uses 32 bytes. When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`] and swizzle is not [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_NONE`], the bounding box inner dimension (computed as channelsPerPixel multiplied by element size in bytes derived from tensorDataType) must be less than or equal to the swizzle size.
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_32B`] requires the bounding box inner dimension to be <= 32.
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_64B`] requires the bounding box inner dimension to be <= 64.
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B`]\* require the bounding box inner dimension to be <= 128. Additionally, tensorDataType of [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] requires interleave to be [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`].
///
/// * swizzle, which specifies the shared memory bank swizzling pattern, has to be of type `CUtensorMapSwizzle` which is defined as:
///
/// ```text
/// typedef enum CUtensorMapSwizzle_enum {
/// CU_TENSOR_MAP_SWIZZLE_NONE = 0,
/// CU_TENSOR_MAP_SWIZZLE_32B, // Swizzle 16B chunks within 32B span
/// CU_TENSOR_MAP_SWIZZLE_64B, // Swizzle 16B chunks within 64B span
/// CU_TENSOR_MAP_SWIZZLE_128B, // Swizzle 16B chunks within 128B span
/// CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B, // Swizzle 32B chunks within 128B span
/// CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B_FLIP_8B, // Swizzle 32B chunks within 128B span, additionally swap lower 8B with upper 8B within each 16B for every alternate row
/// CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B, // Swizzle 64B chunks within 128B span
/// } CUtensorMapSwizzle;
/// ```
///
/// Data are organized in a specific order in global memory; however, this may not match the order in which the application accesses
/// data in shared memory. This difference in data organization may cause bank conflicts when shared memory is accessed. In order
/// to avoid this problem, data can be loaded to shared memory with shuffling across shared memory banks. When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_32B`], swizzle must be [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_32B`]. Other interleave modes can have any swizzling pattern. When the tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`], only the following swizzle modes are supported:
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_NONE`] (Load & Store)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B`] (Load & Store)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B`] (Load & Store)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B_ATOM_64B`] (Store only) When the tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], only the following swizzle modes are supported:
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_NONE`] (Load only)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B`] (Load only)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B`] (Load only)
///
/// * l2Promotion specifies L2 fetch size which indicates the byte granularity at which L2 requests are filled from DRAM. It must be of type
/// `CUtensorMapL2promotion`, which is defined as:
///
/// ```text
/// typedef enum CUtensorMapL2promotion_enum {
/// CU_TENSOR_MAP_L2_PROMOTION_NONE = 0,
/// CU_TENSOR_MAP_L2_PROMOTION_L2_64B,
/// CU_TENSOR_MAP_L2_PROMOTION_L2_128B,
/// CU_TENSOR_MAP_L2_PROMOTION_L2_256B
/// } CUtensorMapL2promotion;
/// ```
///
/// * oobFill, which indicates whether zero or a special NaN constant should be used to fill out-of-bound elements, must be of type `CUtensorMapFloatOOBfill` which is defined as:
///
/// ```text
/// typedef enum CUtensorMapFloatOOBfill_enum {
/// CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE = 0,
/// CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA
/// } CUtensorMapFloatOOBfill;
/// ```
///
/// Note that [`CUtensorMapFloatOOBfill::CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA`] can only be used when tensorDataType represents a floating-point data type, and when tensorDataType is not [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B`], [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], and [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`].
///
/// **See also:**
///
/// [`cuTensorMapEncodeTiled`], [`cuTensorMapEncodeIm2colWide`], [`cuTensorMapReplaceAddress`].
///
/// # Parameters
///
/// - `tensorMap`: Tensor map object to create.
/// - `tensorDataType`: Tensor data type.
/// - `tensorRank`: Dimensionality of tensor; must be at least 3.
/// - `globalAddress`: Starting address of memory region described by tensor.
/// - `globalDim`: Array containing tensor size (number of elements) along each of the tensorRank dimensions.
/// - `globalStrides`: Array containing stride size (in bytes) along each of the tensorRank - 1 dimensions.
/// - `pixelBoxLowerCorner`: Array containing DHW dimensions of lower box corner.
/// - `pixelBoxUpperCorner`: Array containing DHW dimensions of upper box corner.
/// - `channelsPerPixel`: Number of channels per pixel.
/// - `pixelsPerColumn`: Number of pixels per column.
/// - `elementStrides`: Array containing traversal stride in each of the tensorRank dimensions.
/// - `interleave`: Type of interleaved layout the tensor addresses.
/// - `swizzle`: Bank swizzling pattern inside shared memory.
/// - `l2Promotion`: L2 promotion size.
/// - `oobFill`: Indicate whether zero or special NaN constant will be used to fill out-of-bound elements.
pub fn cuTensorMapEncodeIm2col(
tensorMap: *mut CUtensorMap,
tensorDataType: CUtensorMapDataType,
tensorRank: cuuint32_t,
globalAddress: *mut ::core::ffi::c_void,
globalDim: *const cuuint64_t,
globalStrides: *const cuuint64_t,
pixelBoxLowerCorner: *const ::core::ffi::c_int,
pixelBoxUpperCorner: *const ::core::ffi::c_int,
channelsPerPixel: cuuint32_t,
pixelsPerColumn: cuuint32_t,
elementStrides: *const cuuint32_t,
interleave: CUtensorMapInterleave,
swizzle: CUtensorMapSwizzle,
l2Promotion: CUtensorMapL2promotion,
oobFill: CUtensorMapFloatOOBfill,
) -> CUresult;
}
unsafe extern "C" {
/// Create a tensor map descriptor object representing im2col memory region, but where the elements are exclusively loaded along
/// the W dimension.
///
/// Creates a descriptor for Tensor Memory Access (TMA) object specified by the parameters describing a im2col memory layout and
/// where the row is always loaded along the W dimensuin and returns it in tensorMap. This assumes the tensor layout in memory is either NDHWC, NHWC, or NWC.
///
/// This API is only supported on devices of compute capability 10.0 or higher. Additionally, a tensor map object is an opaque
/// value, and, as such, should only be accessed through CUDA APIs and PTX.
///
/// The parameters passed are bound to the following requirements:
///
/// * tensorMap address must be aligned to 64 bytes.
///
/// * tensorDataType has to be an enum from `CUtensorMapDataType` which is defined as:
///
/// ```text
/// typedef enum CUtensorMapDataType_enum {
/// CU_TENSOR_MAP_DATA_TYPE_UINT8 = 0, // 1 byte
/// CU_TENSOR_MAP_DATA_TYPE_UINT16, // 2 bytes
/// CU_TENSOR_MAP_DATA_TYPE_UINT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_INT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_UINT64, // 8 bytes
/// CU_TENSOR_MAP_DATA_TYPE_INT64, // 8 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT16, // 2 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT64, // 8 bytes
/// CU_TENSOR_MAP_DATA_TYPE_BFLOAT16, // 2 bytes
/// CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_TFLOAT32, // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ // 4 bytes
/// CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B, // 4 bits
/// CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B, // 4 bits
/// CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B // 6 bits
/// } CUtensorMapDataType;
/// ```
///
/// [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B`] copies '16 x U4' packed values to memory aligned as 8 bytes. There are no gaps between
/// packed values. [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`] copies '16 x U4' packed values to memory aligned as 16 bytes. There are
/// 8 byte gaps between every 8 byte chunk of packed values. [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] copies '16 x U6' packed values
/// to memory aligned as 16 bytes. There are 4 byte gaps between every 12 byte chunk of packed values.
///
/// * tensorRank, which specifies the number of tensor dimensions, must be 3, 4, or 5.
///
/// * globalAddress, which specifies the starting address of the memory region described, must be 16 byte aligned. The following requirements
/// need to also be met:
/// + When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_32B`], globalAddress must be 32 byte aligned.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], globalAddress must be 32 byte aligned.
///
/// * globalDim array, which specifies tensor size of each of the tensorRank dimensions, must be non-zero and less than or equal to 2^32. Additionally, the following requirements need to be met for
/// the packed data types:
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], globalDim\[0\] must be a multiple of 128.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B`], globalDim\[0\] must be a multiple of 2.
/// + Dimension for the packed data types must reflect the number of individual U# values.
///
/// * globalStrides array, which specifies tensor stride of each of the lower tensorRank - 1 dimensions in bytes, must be a multiple of 16 and less than 2^40. Additionally, the following requirements need to be
/// met:
/// + When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_32B`], the strides must be a multiple of 32.
/// + When tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], the strides must be a multiple of 32.
/// Each following dimension specified includes previous dimension stride:
///
/// ```text
/// globalStrides\[0\] = globalDim\[0\] * elementSizeInBytes(tensorDataType) + padding\[0\];
/// for (i = 1; i < tensorRank - 1; i++)
/// globalStrides\[i\] = globalStrides\[i – 1\] * (globalDim\[i\] + padding\[i\]);
/// assert(globalStrides\[i\] >= globalDim\[i\]);
/// ```
///
/// * pixelBoxLowerCornerWidth specifies the coordinate offset W of the bounding box from left corner. The offset must be within range \[-32768, 32767\].
///
/// * pixelBoxUpperCornerWidth specifies the coordinate offset W of the bounding box from right corner. The offset must be within range \[-32768, 32767\].
///
/// The bounding box specified by pixelBoxLowerCornerWidth and pixelBoxUpperCornerWidth must have non-zero area. Note that the size of the box along D and H dimensions is always equal to one.
///
/// * channelsPerPixel, which specifies the number of elements which must be accessed along C dimension, must be less than or equal to 256. Additionally,
/// when tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] or [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], channelsPerPixel must be 128.
///
/// * pixelsPerColumn, which specifies the number of elements that must be accessed along the W dimension, must be less than or equal to 1024.
/// This field is ignored when mode is [`CUtensorMapIm2ColWideMode::CU_TENSOR_MAP_IM2COL_WIDE_MODE_W128`].
///
/// * elementStrides array, which specifies the iteration step along each of the tensorRank dimensions, must be non-zero and less than or equal to 8. Note that when interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`], the first element of this array is ignored since TMA doesn’t support the stride for dimension
/// zero. When all elements of the elementStrides array are one, boxDim specifies the number of elements to load. However, if elementStrides\[i\] is not equal to one for some i, then TMA loads ceil( boxDim\[i\] / elementStrides\[i\]) number of elements along i-th dimension. To load N elements along i-th dimension, boxDim\[i\] must be set to N \* elementStrides\[i\].
///
/// * interleave specifies the interleaved layout of type `CUtensorMapInterleave`, which is defined as:
///
/// ```text
/// typedef enum CUtensorMapInterleave_enum {
/// CU_TENSOR_MAP_INTERLEAVE_NONE = 0,
/// CU_TENSOR_MAP_INTERLEAVE_16B,
/// CU_TENSOR_MAP_INTERLEAVE_32B
/// } CUtensorMapInterleave;
/// ```
///
/// TMA supports interleaved layouts like NC/8HWC8 where C8 utilizes 16 bytes in memory assuming 2 byte per channel or NC/16HWC16
/// where C16 uses 32 bytes. When interleave is [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`], the bounding box inner dimension (computed as channelsPerPixel multiplied by element size in bytes derived from tensorDataType) must be less than or equal to the swizzle size.
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_64B`] requires the bounding box inner dimension to be <= 64.
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B`]\* require the bounding box inner dimension to be <= 128. Additionally, tensorDataType of [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`] requires interleave to be [`CUtensorMapInterleave::CU_TENSOR_MAP_INTERLEAVE_NONE`].
///
/// * mode, which describes loading of elements loaded along the W dimension, has to be one of the following `CUtensorMapIm2ColWideMode` types:
///
/// ```text
/// CU_TENSOR_MAP_IM2COL_WIDE_MODE_W,
/// CU_TENSOR_MAP_IM2COL_WIDE_MODE_W128
/// ```
///
/// [`CUtensorMapIm2ColWideMode::CU_TENSOR_MAP_IM2COL_WIDE_MODE_W`] allows the number of elements loaded along the W dimension to be specified via the pixelsPerColumn field.
///
/// * swizzle, which specifies the shared memory bank swizzling pattern, must be one of the following `CUtensorMapSwizzle` modes (other swizzle modes are not supported):
///
/// ```text
/// typedef enum CUtensorMapSwizzle_enum {
/// CU_TENSOR_MAP_SWIZZLE_64B, // Swizzle 16B chunks within 64B span
/// CU_TENSOR_MAP_SWIZZLE_128B, // Swizzle 16B chunks within 128B span
/// CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B, // Swizzle 32B chunks within 128B span
/// } CUtensorMapSwizzle;
/// ```
///
/// Data are organized in a specific order in global memory; however, this may not match the order in which the application accesses
/// data in shared memory. This difference in data organization may cause bank conflicts when shared memory is accessed. In order
/// to avoid this problem, data can be loaded to shared memory with shuffling across shared memory banks. When the tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`], only the following swizzle modes are supported:
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_64B`] (Store only)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B`] (Load & Store)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B`] (Load & Store) When the tensorDataType is [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], only the following swizzle modes are supported:
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B`] (Load only)
/// + [`CUtensorMapSwizzle::CU_TENSOR_MAP_SWIZZLE_128B_ATOM_32B`] (Load only)
///
/// Additionally, CU_TENSOR_MAP_SWIZZLE_96B is supported only when mode is [`CUtensorMapIm2ColWideMode::CU_TENSOR_MAP_IM2COL_WIDE_MODE_W`].
///
/// * l2Promotion specifies L2 fetch size which indicates the byte granularity at which L2 requests are filled from DRAM. It must be of type
/// `CUtensorMapL2promotion`, which is defined as:
///
/// ```text
/// typedef enum CUtensorMapL2promotion_enum {
/// CU_TENSOR_MAP_L2_PROMOTION_NONE = 0,
/// CU_TENSOR_MAP_L2_PROMOTION_L2_64B,
/// CU_TENSOR_MAP_L2_PROMOTION_L2_128B,
/// CU_TENSOR_MAP_L2_PROMOTION_L2_256B
/// } CUtensorMapL2promotion;
/// ```
///
/// * oobFill, which indicates whether zero or a special NaN constant should be used to fill out-of-bound elements, must be of type `CUtensorMapFloatOOBfill` which is defined as:
///
/// ```text
/// typedef enum CUtensorMapFloatOOBfill_enum {
/// CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE = 0,
/// CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA
/// } CUtensorMapFloatOOBfill;
/// ```
///
/// Note that [`CUtensorMapFloatOOBfill::CU_TENSOR_MAP_FLOAT_OOB_FILL_NAN_REQUEST_ZERO_FMA`] can only be used when tensorDataType represents a floating-point data type, and when tensorDataType is not [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B`], [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN16B`], and [`CUtensorMapDataType::CU_TENSOR_MAP_DATA_TYPE_16U6_ALIGN16B`].
///
/// **See also:**
///
/// [`cuTensorMapEncodeTiled`], [`cuTensorMapEncodeIm2col`], [`cuTensorMapReplaceAddress`].
///
/// # Parameters
///
/// - `tensorMap`: Tensor map object to create.
/// - `tensorDataType`: Tensor data type.
/// - `tensorRank`: Dimensionality of tensor; must be at least 3.
/// - `globalAddress`: Starting address of memory region described by tensor.
/// - `globalDim`: Array containing tensor size (number of elements) along each of the tensorRank dimensions.
/// - `globalStrides`: Array containing stride size (in bytes) along each of the tensorRank - 1 dimensions.
/// - `pixelBoxLowerCornerWidth`: Width offset of left box corner.
/// - `pixelBoxUpperCornerWidth`: Width offset of right box corner.
/// - `channelsPerPixel`: Number of channels per pixel.
/// - `pixelsPerColumn`: Number of pixels per column.
/// - `elementStrides`: Array containing traversal stride in each of the tensorRank dimensions.
/// - `interleave`: Type of interleaved layout the tensor addresses.
/// - `mode`: W or W128 mode.
/// - `swizzle`: Bank swizzling pattern inside shared memory.
/// - `l2Promotion`: L2 promotion size.
/// - `oobFill`: Indicate whether zero or special NaN constant will be used to fill out-of-bound elements.
pub fn cuTensorMapEncodeIm2colWide(
tensorMap: *mut CUtensorMap,
tensorDataType: CUtensorMapDataType,
tensorRank: cuuint32_t,
globalAddress: *mut ::core::ffi::c_void,
globalDim: *const cuuint64_t,
globalStrides: *const cuuint64_t,
pixelBoxLowerCornerWidth: ::core::ffi::c_int,
pixelBoxUpperCornerWidth: ::core::ffi::c_int,
channelsPerPixel: cuuint32_t,
pixelsPerColumn: cuuint32_t,
elementStrides: *const cuuint32_t,
interleave: CUtensorMapInterleave,
mode: CUtensorMapIm2ColWideMode,
swizzle: CUtensorMapSwizzle,
l2Promotion: CUtensorMapL2promotion,
oobFill: CUtensorMapFloatOOBfill,
) -> CUresult;
}
unsafe extern "C" {
/// Modify an existing tensor map descriptor with an updated global address.
///
/// Modifies the descriptor for Tensor Memory Access (TMA) object passed in tensorMap with an updated globalAddress.
///
/// Tensor map objects are only supported on devices of compute capability 9.0 or higher. Additionally, a tensor map object is
/// an opaque value, and, as such, should only be accessed through CUDA API calls.
///
/// **See also:**
///
/// [`cuTensorMapEncodeTiled`], [`cuTensorMapEncodeIm2col`], [`cuTensorMapEncodeIm2colWide`].
///
/// # Parameters
///
/// - `tensorMap`: Tensor map object to modify.
/// - `globalAddress`: Starting address of memory region described by tensor, must follow previous alignment requirements.
pub fn cuTensorMapReplaceAddress(
tensorMap: *mut CUtensorMap,
globalAddress: *mut ::core::ffi::c_void,
) -> CUresult;
}
unsafe extern "C" {
/// Queries if a device may directly access a peer device's memory.
///
/// Returns in \*canAccessPeer a value of 1 if contexts on dev are capable of directly accessing memory from contexts on peerDev and 0 otherwise. If direct access of peerDev from dev is possible, then access may be enabled on two specific contexts by calling [`cuCtxEnablePeerAccess`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxEnablePeerAccess`], [`cuCtxDisablePeerAccess`], [cudaDeviceCanAccessPeer](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__PEER.html#group__CUDART__PEER_1g4db0d04e44995d5c1c34be4ecc863f22).
///
/// # Parameters
///
/// - `canAccessPeer`: Returned access capability.
/// - `dev`: Device from which allocations on peerDev are to be directly accessed.
/// - `peerDev`: Device on which the allocations to be directly accessed by dev reside.
pub fn cuDeviceCanAccessPeer(
canAccessPeer: *mut ::core::ffi::c_int,
dev: CUdevice,
peerDev: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Enables direct access to memory allocations in a peer context.
///
/// If both the current context and peerContext are on devices which support unified addressing (as may be queried using [`CUdevice_attribute_enum::CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING`]) and same major compute capability, then on success all allocations from peerContext will immediately be accessible by the current context. See [Unified Addressing](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/unified-addressing.html#group__CUDA__UNIFIED) for additional details.
///
/// Note that access granted by this call is unidirectional and that in order to access memory from the current context in peerContext, a separate symmetric call to [`cuCtxEnablePeerAccess`] is required.
///
/// Note that there are both device-wide and system-wide limitations per system configuration, as noted in the CUDA Programming
/// Guide under the section "Peer-to-Peer Memory Access".
///
/// Returns [`cudaError_enum::CUDA_ERROR_PEER_ACCESS_UNSUPPORTED`] if [`cuDeviceCanAccessPeer`] indicates that the [`CUdevice`] of the current context cannot directly access memory from the [`CUdevice`] of peerContext.
///
/// Returns [`cudaError_enum::CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED`] if direct access of peerContext from the current context has already been enabled.
///
/// Returns [`cudaError_enum::CUDA_ERROR_TOO_MANY_PEERS`] if direct peer access is not possible because hardware resources required for peer access have been exhausted.
///
/// Returns [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`] if there is no current context, peerContext is not a valid context, or if the current context is peerContext.
///
/// Returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] if Flags is not 0.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceCanAccessPeer`], [`cuCtxDisablePeerAccess`], [cudaDeviceEnablePeerAccess](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__PEER.html#group__CUDART__PEER_1g2b0adabf90db37e5cfddc92cbb2589f3).
///
/// # Parameters
///
/// - `peerContext`: Peer context to enable direct access to from the current context.
/// - `Flags`: Reserved for future use and must be set to 0.
pub fn cuCtxEnablePeerAccess(
peerContext: CUcontext,
Flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Disables direct access to memory allocations in a peer context and unregisters any registered allocations.
///
/// Returns [`cudaError_enum::CUDA_ERROR_PEER_ACCESS_NOT_ENABLED`] if direct peer access has not yet been enabled from peerContext to the current context.
///
/// Returns [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`] if there is no current context, or if peerContext is not a valid context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceCanAccessPeer`], [`cuCtxEnablePeerAccess`], [cudaDeviceDisablePeerAccess](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__PEER.html#group__CUDART__PEER_1g9663734ad02653207ad6836053bf572e).
///
/// # Parameters
///
/// - `peerContext`: Peer context to disable direct access to.
pub fn cuCtxDisablePeerAccess(peerContext: CUcontext) -> CUresult;
}
unsafe extern "C" {
/// Queries attributes of the link between two devices.
///
/// Returns in \*value the value of the requested attribute attrib of the link between srcDevice and dstDevice. The supported attributes are:
///
/// * [`CUdevice_P2PAttribute_enum::CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK`]: A relative value indicating the performance of the link between two devices.
/// * [`CUdevice_P2PAttribute_enum::CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED`] P2P: 1 if P2P Access is enable.
/// * [`CUdevice_P2PAttribute_enum::CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED`]: 1 if all CUDA-valid atomic operations over the link are supported.
/// * [CU_DEVICE_P2P_ATTRIBUTE_CUDA_ARRAY_ACCESS_SUPPORTED](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/types.html#group__CUDA__TYPES_1gg578d7cf687ce20f7e99468e8c14e22de83a83eb1e8d535b6b8ecf00f509f4097): 1 if cudaArray can be accessed over the link.
/// * [`CUdevice_P2PAttribute_enum::CU_DEVICE_P2P_ATTRIBUTE_ONLY_PARTIAL_NATIVE_ATOMIC_SUPPORTED`]: 1 if some CUDA-valid atomic operations over the link are supported. Information about specific operations can be retrieved
/// with [`cuDeviceGetP2PAtomicCapabilities`].
///
/// Returns [`cudaError_enum::CUDA_ERROR_INVALID_DEVICE`] if srcDevice or dstDevice are not valid or if they represent the same device.
///
/// Returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] if attrib is not valid or if value is a null pointer.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuCtxEnablePeerAccess`], [`cuCtxDisablePeerAccess`], [`cuDeviceCanAccessPeer`], [`cuDeviceGetP2PAtomicCapabilities`], [cudaDeviceGetP2PAttribute](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gc63e5bf168e53b2daf71904eab048fa9).
///
/// # Parameters
///
/// - `value`: Returned value of the requested attribute.
/// - `attrib`: The requested attribute of the link between srcDevice and dstDevice.
/// - `srcDevice`: The source device of the target link.
/// - `dstDevice`: The destination device of the target link.
pub fn cuDeviceGetP2PAttribute(
value: *mut ::core::ffi::c_int,
attrib: CUdevice_P2PAttribute,
srcDevice: CUdevice,
dstDevice: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Queries details about atomic operations supported between two devices.
///
/// Returns in \*capabilities the details about requested atomic \*operations over the link between srcDevice and dstDevice. The allocated size of \*operations and \*capabilities must be count.
///
/// For each `CUatomicOperation` in \*operations, the corresponding result in \*capabilities will be a bitmask indicating which of `CUatomicOperationCapability` the link supports natively.
///
/// Returns [`cudaError_enum::CUDA_ERROR_INVALID_DEVICE`] if srcDevice or dstDevice are not valid or if they represent the same device.
///
/// Returns [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] if \*capabilities or \*operations is NULL, if count is 0, or if any of \*operations is not valid.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuDeviceGetP2PAttribute`], [cudaDeviceGetP2PAttribute](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1gc63e5bf168e53b2daf71904eab048fa9), [cudaDeviceGetP2PAtomicCapabilities](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1ga608cadee2598ca942b362db73267c2b).
///
/// # Parameters
///
/// - `capabilities`: Returned capability details of each requested operation.
/// - `operations`: Requested operations.
/// - `count`: Count of requested operations and size of capabilities.
/// - `srcDevice`: The source device of the target link.
/// - `dstDevice`: The destination device of the target link.
pub fn cuDeviceGetP2PAtomicCapabilities(
capabilities: *mut ::core::ffi::c_uint,
operations: *const CUatomicOperation,
count: ::core::ffi::c_uint,
srcDevice: CUdevice,
dstDevice: CUdevice,
) -> CUresult;
}
unsafe extern "C" {
/// Unregisters a graphics resource for access by CUDA.
///
/// Unregisters the graphics resource resource so it is not accessible by CUDA unless registered again.
///
/// If resource is invalid then [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// `cuGraphicsD3D9RegisterResource`, `cuGraphicsD3D10RegisterResource`, `cuGraphicsD3D11RegisterResource`, `cuGraphicsGLRegisterBuffer`, `cuGraphicsGLRegisterImage`, [cudaGraphicsUnregisterResource](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__INTEROP.html#group__CUDART__INTEROP_1gc65d1f2900086747de1e57301d709940).
///
/// # Parameters
///
/// - `resource`: Resource to unregister.
pub fn cuGraphicsUnregisterResource(resource: CUgraphicsResource) -> CUresult;
}
unsafe extern "C" {
/// Get an array through which to access a subresource of a mapped graphics resource.
///
/// Returns in \*pArray an array through which the subresource of the mapped graphics resource resource which corresponds to array index arrayIndex and mipmap level mipLevel may be accessed. The value set in \*pArray may change every time that resource is mapped.
///
/// If resource is not a texture then it cannot be accessed via an array and [`cudaError_enum::CUDA_ERROR_NOT_MAPPED_AS_ARRAY`] is returned. If arrayIndex is not a valid array index for resource then [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned. If mipLevel is not a valid mipmap level for resource then [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned. If resource is not mapped then [`cudaError_enum::CUDA_ERROR_NOT_MAPPED`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphicsResourceGetMappedPointer_v2`], [cudaGraphicsSubResourceGetMappedArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__INTEROP.html#group__CUDART__INTEROP_1g0dd6b5f024dfdcff5c28a08ef9958031).
///
/// # Parameters
///
/// - `pArray`: Returned array through which a subresource of resource may be accessed.
/// - `resource`: Mapped resource to access.
/// - `arrayIndex`: Array index for array textures or cubemap face index as defined by `CUarray_cubemap_face` for cubemap textures for the subresource to access.
/// - `mipLevel`: Mipmap level for the subresource to access.
pub fn cuGraphicsSubResourceGetMappedArray(
pArray: *mut CUarray,
resource: CUgraphicsResource,
arrayIndex: ::core::ffi::c_uint,
mipLevel: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Get a mipmapped array through which to access a mapped graphics resource.
///
/// Returns in \*pMipmappedArray a mipmapped array through which the mapped graphics resource resource. The value set in \*pMipmappedArray may change every time that resource is mapped.
///
/// If resource is not a texture then it cannot be accessed via a mipmapped array and [`cudaError_enum::CUDA_ERROR_NOT_MAPPED_AS_ARRAY`] is returned. If resource is not mapped then [`cudaError_enum::CUDA_ERROR_NOT_MAPPED`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphicsResourceGetMappedPointer_v2`], [cudaGraphicsResourceGetMappedMipmappedArray](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__INTEROP.html#group__CUDART__INTEROP_1g84c3772d2ed06cda8c92bc43cdc893d0).
///
/// # Parameters
///
/// - `pMipmappedArray`: Returned mipmapped array through which resource may be accessed.
/// - `resource`: Mapped resource to access.
pub fn cuGraphicsResourceGetMappedMipmappedArray(
pMipmappedArray: *mut CUmipmappedArray,
resource: CUgraphicsResource,
) -> CUresult;
}
unsafe extern "C" {
/// Get a device pointer through which to access a mapped graphics resource.
///
/// Returns in \*pDevPtr a pointer through which the mapped graphics resource resource may be accessed. Returns in pSize the size of the memory in bytes which may be accessed from that pointer. The value set in pPointer may change every time that resource is mapped.
///
/// If resource is not a buffer then it cannot be accessed via a pointer and [`cudaError_enum::CUDA_ERROR_NOT_MAPPED_AS_POINTER`] is returned. If resource is not mapped then [`cudaError_enum::CUDA_ERROR_NOT_MAPPED`] is returned. \*
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphicsMapResources`], [`cuGraphicsSubResourceGetMappedArray`], [cudaGraphicsResourceGetMappedPointer](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__INTEROP.html#group__CUDART__INTEROP_1ga36881081c8deb4df25c256158e1ac99).
///
/// # Parameters
///
/// - `pDevPtr`: Returned pointer through which resource may be accessed.
/// - `pSize`: Returned size of the buffer accessible starting at \*pPointer.
/// - `resource`: Mapped resource to access.
pub fn cuGraphicsResourceGetMappedPointer_v2(
pDevPtr: *mut CUdeviceptr,
pSize: *mut size_t,
resource: CUgraphicsResource,
) -> CUresult;
}
unsafe extern "C" {
/// Set usage flags for mapping a graphics resource.
///
/// Set flags for mapping the graphics resource resource.
///
/// Changes to flags will take effect the next time resource is mapped. The flags argument may be any of the following:
///
/// * [`CUgraphicsMapResourceFlags::CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE`]: Specifies no hints about how this resource will be used. It is therefore assumed that
/// this resource will be read from and written to by CUDA kernels. This is the default value.
/// * CU_GRAPHICS_MAP_RESOURCE_FLAGS_READONLY: Specifies that CUDA kernels which access this resource will not write to this resource.
/// * CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITEDISCARD: Specifies that CUDA kernels which access this resource will not read from this
/// resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will
/// be preserved.
///
/// If resource is presently mapped for access by CUDA then [`cudaError_enum::CUDA_ERROR_ALREADY_MAPPED`] is returned. If flags is not one of the above values then [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphicsMapResources`], [cudaGraphicsResourceSetMapFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__INTEROP.html#group__CUDART__INTEROP_1g5f94a0043909fddc100ab5f0c2476b9f).
///
/// # Parameters
///
/// - `resource`: Registered resource to set flags for.
/// - `flags`: Parameters for resource mapping.
pub fn cuGraphicsResourceSetMapFlags_v2(
resource: CUgraphicsResource,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Map graphics resources for access by CUDA.
///
/// Maps the count graphics resources in resources for access by CUDA.
///
/// The resources in resources may be accessed by CUDA until they are unmapped. The graphics API from which resources were registered should not access any resources while they are mapped by CUDA. If an application does so, the results are
/// undefined.
///
/// This function provides the synchronization guarantee that any graphics calls issued before [`cuGraphicsMapResources`] will complete before any subsequent CUDA work issued in stream begins.
///
/// If resources includes any duplicate entries then [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`] is returned. If any of resources are presently mapped for access by CUDA then [`cudaError_enum::CUDA_ERROR_ALREADY_MAPPED`] is returned.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphicsResourceGetMappedPointer_v2`], [`cuGraphicsSubResourceGetMappedArray`], [`cuGraphicsUnmapResources`], [cudaGraphicsMapResources](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__INTEROP.html#group__CUDART__INTEROP_1gad8fbe74d02adefb8e7efb4971ee6322).
///
/// # Parameters
///
/// - `count`: Number of resources to map.
/// - `resources`: Resources to map for CUDA usage.
/// - `hStream`: Stream with which to synchronize.
pub fn cuGraphicsMapResources(
count: ::core::ffi::c_uint,
resources: *mut CUgraphicsResource,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Unmap graphics resources.
///
/// Unmaps the count graphics resources in resources.
///
/// Once unmapped, the resources in resources may not be accessed by CUDA until they are mapped again.
///
/// This function provides the synchronization guarantee that any CUDA work issued in stream before [`cuGraphicsUnmapResources`] will complete before any subsequently issued graphics work begins.
///
/// If resources includes any duplicate entries then [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`] is returned. If any of resources are not presently mapped for access by CUDA then [`cudaError_enum::CUDA_ERROR_NOT_MAPPED`] is returned.
///
/// Note:
///
/// * This function uses standard [default stream](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGraphicsMapResources`], [cudaGraphicsUnmapResources](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__INTEROP.html#group__CUDART__INTEROP_1g11988ab4431b11ddb7cbde7aedb60491).
///
/// # Parameters
///
/// - `count`: Number of resources to unmap.
/// - `resources`: Resources to unmap.
/// - `hStream`: Stream with which to synchronize.
pub fn cuGraphicsUnmapResources(
count: ::core::ffi::c_uint,
resources: *mut CUgraphicsResource,
hStream: CUstream,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the requested driver API function pointer.
///
/// Returns in \*\*pfn the address of the CUDA driver function for the requested CUDA version and flags.
///
/// The CUDA version is specified as (1000 \* major + 10 \* minor), so CUDA 11.2 should be specified as 11020. For a requested driver
/// symbol, if the specified CUDA version is greater than or equal to the CUDA version in which the driver symbol was introduced,
/// this API will return the function pointer to the corresponding versioned function. If the specified CUDA version is greater
/// than the driver version, the API will return [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in
/// the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example,
/// cudaTypedefs.h consists of function pointer typedefs for driver APIs defined in cuda.h.
///
/// The API will return [`cudaError_enum::CUDA_SUCCESS`] and set the returned pfn to NULL if the requested driver function is not supported on the platform, no ABI compatible driver function exists for the
/// specified cudaVersion or if the driver symbol is invalid.
///
/// It will also set the optional symbolStatus to one of the values in `CUdriverProcAddressQueryResult` with the following meanings:
///
/// * [`CUdriverProcAddressQueryResult_enum::CU_GET_PROC_ADDRESS_SUCCESS`] - The requested symbol was succesfully found based on input arguments and pfn is valid
/// * [`CUdriverProcAddressQueryResult_enum::CU_GET_PROC_ADDRESS_SYMBOL_NOT_FOUND`] - The requested symbol was not found
/// * [`CUdriverProcAddressQueryResult_enum::CU_GET_PROC_ADDRESS_VERSION_NOT_SUFFICIENT`] - The requested symbol was found but is not supported by cudaVersion specified
///
/// The requested flags can be:
///
/// * [`CUdriverProcAddress_flags_enum::CU_GET_PROC_ADDRESS_DEFAULT`]: This is the default mode. This is equivalent to [`CUdriverProcAddress_flags_enum::CU_GET_PROC_ADDRESS_PER_THREAD_DEFAULT_STREAM`] if the code is compiled with --default-stream per-thread compilation flag or the macro CUDA_API_PER_THREAD_DEFAULT_STREAM
/// is defined; [`CUdriverProcAddress_flags_enum::CU_GET_PROC_ADDRESS_LEGACY_STREAM`] otherwise.
/// * [`CUdriverProcAddress_flags_enum::CU_GET_PROC_ADDRESS_LEGACY_STREAM`]: This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding
/// per-thread versions.
/// * [`CUdriverProcAddress_flags_enum::CU_GET_PROC_ADDRESS_PER_THREAD_DEFAULT_STREAM`]: This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread
/// versions. If a per-thread version is not found, the API will return the legacy version of the driver function.
///
/// Note:
///
/// Version mixing among CUDA-defined types and driver API versions is strongly discouraged and doing so can result in an undefined
/// behavior. [More here](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-driver-api/version-mixing-rules.html#version-mixing-rules).
///
/// **See also:**
///
/// [cudaGetDriverEntryPointByVersion](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__DRIVER__ENTRY__POINT.html#group__CUDART__DRIVER__ENTRY__POINT_1gda6c90a43afbe8043128285afbaf8c04).
///
/// # Parameters
///
/// - `symbol`: The base name of the driver API function to look for. As an example, for the driver API cuMemAlloc_v2, symbol would be cuMemAlloc and cudaVersion would be the ABI compatible CUDA version for the _v2 variant.
/// - `pfn`: Location to return the function pointer to the requested driver function.
/// - `cudaVersion`: The CUDA version to look for the requested driver symbol.
/// - `flags`: Flags to specify search options.
/// - `symbolStatus`: Optional location to store the status of the search for symbol based on cudaVersion. See `CUdriverProcAddressQueryResult` for possible values.
pub fn cuGetProcAddress_v2(
symbol: *const ::core::ffi::c_char,
pfn: *mut *mut ::core::ffi::c_void,
cudaVersion: ::core::ffi::c_int,
flags: cuuint64_t,
symbolStatus: *mut CUdriverProcAddressQueryResult,
) -> CUresult;
}
/// Flags for choosing a coredump attribute to get/set.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUcoredumpSettings_enum {
CU_COREDUMP_ENABLE_ON_EXCEPTION = 1,
CU_COREDUMP_TRIGGER_HOST = 2,
CU_COREDUMP_LIGHTWEIGHT = 3,
CU_COREDUMP_ENABLE_USER_TRIGGER = 4,
CU_COREDUMP_FILE = 5,
CU_COREDUMP_PIPE = 6,
CU_COREDUMP_GENERATION_FLAGS = 7,
CU_COREDUMP_MAX = 8,
}
pub use self::CUcoredumpSettings_enum as CUcoredumpSettings;
/// Flags for controlling coredump contents.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUCoredumpGenerationFlags {
CU_COREDUMP_DEFAULT_FLAGS = 0,
CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES = 1,
CU_COREDUMP_SKIP_GLOBAL_MEMORY = 2,
CU_COREDUMP_SKIP_SHARED_MEMORY = 4,
CU_COREDUMP_SKIP_LOCAL_MEMORY = 8,
CU_COREDUMP_SKIP_ABORT = 16,
CU_COREDUMP_SKIP_CONSTBANK_MEMORY = 32,
CU_COREDUMP_GZIP_COMPRESS = 64,
CU_COREDUMP_LIGHTWEIGHT_FLAGS = 47,
}
unsafe extern "C" {
/// Allows caller to fetch a coredump attribute value for the current context.
///
/// Returns in \*value the requested value specified by attrib. It is up to the caller to ensure that the data type and size of \*value matches the request.
///
/// If the caller calls this function with \*value equal to NULL, the size of the memory region (in bytes) expected for attrib will be placed in size.
///
/// The supported attributes are:
///
/// * [`CUcoredumpSettings::CU_COREDUMP_ENABLE_ON_EXCEPTION`]: Bool where true means that GPU exceptions from this context will create a coredump at the
/// location specified by [`CUcoredumpSettings::CU_COREDUMP_FILE`]. The default value is false unless set to true globally or locally, or the [`CUctx_flags::CU_CTX_USER_COREDUMP_ENABLE`]
/// flag was set during context creation.
/// * [`CUcoredumpSettings::CU_COREDUMP_TRIGGER_HOST`]: Bool where true means that the host CPU will also create a coredump. The default value is true unless
/// set to false globally or or locally. This value is deprecated as of CUDA 12.5 - raise the [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_ABORT`] flag to disable
/// host device abort() if needed.
/// * [`CUcoredumpSettings::CU_COREDUMP_LIGHTWEIGHT`]: Bool where true means that any resulting coredumps will not have a dump of GPU memory or non-reloc
/// ELF images. The default value is false unless set to true globally or locally. This attribute is deprecated as of CUDA 12.5,
/// please use [`CUcoredumpSettings::CU_COREDUMP_GENERATION_FLAGS`] instead.
/// * [`CUcoredumpSettings::CU_COREDUMP_ENABLE_USER_TRIGGER`]: Bool where true means that a coredump can be created by writing to the system pipe specified
/// by [`CUcoredumpSettings::CU_COREDUMP_PIPE`]. The default value is false unless set to true globally or locally.
/// * [`CUcoredumpSettings::CU_COREDUMP_FILE`]: String of up to 1023 characters that defines the location where any coredumps generated by this context
/// will be written. The default value is core.cuda.HOSTNAME.PID where HOSTNAME is the host name of the machine running the CUDA
/// applications and PID is the process ID of the CUDA application.
/// * [`CUcoredumpSettings::CU_COREDUMP_PIPE`]: String of up to 1023 characters that defines the name of the pipe that will be monitored if user-triggered
/// coredumps are enabled. The default value is corepipe.cuda.HOSTNAME.PID where HOSTNAME is the host name of the machine running
/// the CUDA application and PID is the process ID of the CUDA application.
/// * [`CUcoredumpSettings::CU_COREDUMP_GENERATION_FLAGS`]: An integer with values to allow granular control the data contained in a coredump specified
/// as a bitwise OR combination of the following values: + [`CUCoredumpGenerationFlags::CU_COREDUMP_DEFAULT_FLAGS`] - if set by itself, coredump generation returns
/// to its default settings of including all memory regions that it is able to access + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES`]
/// - Coredump will not include the data from CUDA source modules that are not relocated at runtime. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_GLOBAL_MEMORY`]
/// - Coredump will not include device-side global data that does not belong to any context. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_SHARED_MEMORY`]
/// - Coredump will not include grid-scale shared memory for the warp that the dumped kernel belonged to. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_LOCAL_MEMORY`]
/// - Coredump will not include local memory from the kernel. + [`CUCoredumpGenerationFlags::CU_COREDUMP_LIGHTWEIGHT_FLAGS`] - Enables all of the above options.
/// Equiavlent to setting the [`CUcoredumpSettings::CU_COREDUMP_LIGHTWEIGHT`] attribute to true. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_ABORT`] - If set, GPU exceptions will
/// not raise an abort() in the host CPU process. Same functional goal as [`CUcoredumpSettings::CU_COREDUMP_TRIGGER_HOST`] but better reflects the default
/// behavior.
///
/// **See also:**
///
/// [`cuCoredumpGetAttributeGlobal`], [`cuCoredumpSetAttribute`], [`cuCoredumpSetAttributeGlobal`].
///
/// # Parameters
///
/// - `attrib`: The enum defining which value to fetch.
/// - `value`: void\* containing the requested data.
/// - `size`: The size of the memory region value points to.
pub fn cuCoredumpGetAttribute(
attrib: CUcoredumpSettings,
value: *mut ::core::ffi::c_void,
size: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Allows caller to fetch a coredump attribute value for the entire application.
///
/// Returns in \*value the requested value specified by attrib. It is up to the caller to ensure that the data type and size of \*value matches the request.
///
/// If the caller calls this function with \*value equal to NULL, the size of the memory region (in bytes) expected for attrib will be placed in size.
///
/// The supported attributes are:
///
/// * [`CUcoredumpSettings::CU_COREDUMP_ENABLE_ON_EXCEPTION`]: Bool where true means that GPU exceptions from this context will create a coredump at the
/// location specified by [`CUcoredumpSettings::CU_COREDUMP_FILE`]. The default value is false.
/// * [`CUcoredumpSettings::CU_COREDUMP_TRIGGER_HOST`]: Bool where true means that the host CPU will also create a coredump. The default value is true unless
/// set to false globally or or locally. This value is deprecated as of CUDA 12.5 - raise the [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_ABORT`] flag to disable
/// host device abort() if needed.
/// * [`CUcoredumpSettings::CU_COREDUMP_LIGHTWEIGHT`]: Bool where true means that any resulting coredumps will not have a dump of GPU memory or non-reloc
/// ELF images. The default value is false. This attribute is deprecated as of CUDA 12.5, please use [`CUcoredumpSettings::CU_COREDUMP_GENERATION_FLAGS`]
/// instead.
/// * [`CUcoredumpSettings::CU_COREDUMP_ENABLE_USER_TRIGGER`]: Bool where true means that a coredump can be created by writing to the system pipe specified
/// by [`CUcoredumpSettings::CU_COREDUMP_PIPE`]. The default value is false.
/// * [`CUcoredumpSettings::CU_COREDUMP_FILE`]: String of up to 1023 characters that defines the location where any coredumps generated by this context
/// will be written. The default value is core.cuda.HOSTNAME.PID where HOSTNAME is the host name of the machine running the CUDA
/// applications and PID is the process ID of the CUDA application.
/// * [`CUcoredumpSettings::CU_COREDUMP_PIPE`]: String of up to 1023 characters that defines the name of the pipe that will be monitored if user-triggered
/// coredumps are enabled. The default value is corepipe.cuda.HOSTNAME.PID where HOSTNAME is the host name of the machine running
/// the CUDA application and PID is the process ID of the CUDA application.
/// * [`CUcoredumpSettings::CU_COREDUMP_GENERATION_FLAGS`]: An integer with values to allow granular control the data contained in a coredump specified
/// as a bitwise OR combination of the following values: + [`CUCoredumpGenerationFlags::CU_COREDUMP_DEFAULT_FLAGS`] - if set by itself, coredump generation returns
/// to its default settings of including all memory regions that it is able to access + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES`]
/// - Coredump will not include the data from CUDA source modules that are not relocated at runtime. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_GLOBAL_MEMORY`]
/// - Coredump will not include device-side global data that does not belong to any context. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_SHARED_MEMORY`]
/// - Coredump will not include grid-scale shared memory for the warp that the dumped kernel belonged to. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_LOCAL_MEMORY`]
/// - Coredump will not include local memory from the kernel. + [`CUCoredumpGenerationFlags::CU_COREDUMP_LIGHTWEIGHT_FLAGS`] - Enables all of the above options.
/// Equiavlent to setting the [`CUcoredumpSettings::CU_COREDUMP_LIGHTWEIGHT`] attribute to true. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_ABORT`] - If set, GPU exceptions will
/// not raise an abort() in the host CPU process. Same functional goal as [`CUcoredumpSettings::CU_COREDUMP_TRIGGER_HOST`] but better reflects the default
/// behavior.
///
/// **See also:**
///
/// [`cuCoredumpGetAttribute`], [`cuCoredumpSetAttribute`], [`cuCoredumpSetAttributeGlobal`].
///
/// # Parameters
///
/// - `attrib`: The enum defining which value to fetch.
/// - `value`: void\* containing the requested data.
/// - `size`: The size of the memory region value points to.
pub fn cuCoredumpGetAttributeGlobal(
attrib: CUcoredumpSettings,
value: *mut ::core::ffi::c_void,
size: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Allows caller to set a coredump attribute value for the current context.
///
/// This function should be considered an alternate interface to the CUDA-GDB environment variables defined in this document:
/// <https://docs.nvidia.com/cuda/cuda-gdb/index.html#gpu-coredump>
///
/// An important design decision to note is that any coredump environment variable values set before CUDA initializes will take
/// permanent precedence over any values set with this function. This decision was made to ensure no change in behavior for any
/// users that may be currently using these variables to get coredumps.
///
/// \*value shall contain the requested value specified by set. It is up to the caller to ensure that the data type and size of \*value matches the request.
///
/// If the caller calls this function with \*value equal to NULL, the size of the memory region (in bytes) expected for set will be placed in size.
///
/// /note This function will return [`cudaError_enum::CUDA_ERROR_NOT_SUPPORTED`] if the caller attempts to set [`CUcoredumpSettings::CU_COREDUMP_ENABLE_ON_EXCEPTION`] on a GPU of with Compute Capability < 6.0. [`cuCoredumpSetAttributeGlobal`] works on those platforms as an alternative.
///
/// /note [`CUcoredumpSettings::CU_COREDUMP_ENABLE_USER_TRIGGER`] and [`CUcoredumpSettings::CU_COREDUMP_PIPE`] cannot be set on a per-context basis.
///
/// The supported attributes are:
///
/// * [`CUcoredumpSettings::CU_COREDUMP_ENABLE_ON_EXCEPTION`]: Bool where true means that GPU exceptions from this context will create a coredump at the
/// location specified by [`CUcoredumpSettings::CU_COREDUMP_FILE`]. The default value is false.
/// * [`CUcoredumpSettings::CU_COREDUMP_TRIGGER_HOST`]: Bool where true means that the host CPU will also create a coredump. The default value is true unless
/// set to false globally or or locally. This value is deprecated as of CUDA 12.5 - raise the [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_ABORT`] flag to disable
/// host device abort() if needed.
/// * [`CUcoredumpSettings::CU_COREDUMP_LIGHTWEIGHT`]: Bool where true means that any resulting coredumps will not have a dump of GPU memory or non-reloc
/// ELF images. The default value is false. This attribute is deprecated as of CUDA 12.5, please use [`CUcoredumpSettings::CU_COREDUMP_GENERATION_FLAGS`]
/// instead.
/// * [`CUcoredumpSettings::CU_COREDUMP_FILE`]: String of up to 1023 characters that defines the location where any coredumps generated by this context
/// will be written. The default value is core.cuda.HOSTNAME.PID where HOSTNAME is the host name of the machine running the CUDA
/// applications and PID is the process ID of the CUDA application.
/// * [`CUcoredumpSettings::CU_COREDUMP_GENERATION_FLAGS`]: An integer with values to allow granular control the data contained in a coredump specified
/// as a bitwise OR combination of the following values: + [`CUCoredumpGenerationFlags::CU_COREDUMP_DEFAULT_FLAGS`] - if set by itself, coredump generation returns
/// to its default settings of including all memory regions that it is able to access + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES`]
/// - Coredump will not include the data from CUDA source modules that are not relocated at runtime. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_GLOBAL_MEMORY`]
/// - Coredump will not include device-side global data that does not belong to any context. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_SHARED_MEMORY`]
/// - Coredump will not include grid-scale shared memory for the warp that the dumped kernel belonged to. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_LOCAL_MEMORY`]
/// - Coredump will not include local memory from the kernel. + [`CUCoredumpGenerationFlags::CU_COREDUMP_LIGHTWEIGHT_FLAGS`] - Enables all of the above options.
/// Equiavlent to setting the [`CUcoredumpSettings::CU_COREDUMP_LIGHTWEIGHT`] attribute to true. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_ABORT`] - If set, GPU exceptions will
/// not raise an abort() in the host CPU process. Same functional goal as [`CUcoredumpSettings::CU_COREDUMP_TRIGGER_HOST`] but better reflects the default
/// behavior.
///
/// **See also:**
///
/// [`cuCoredumpGetAttributeGlobal`], [`cuCoredumpGetAttribute`], [`cuCoredumpSetAttributeGlobal`].
///
/// # Parameters
///
/// - `attrib`: The enum defining which value to set.
/// - `value`: void\* containing the requested data.
/// - `size`: The size of the memory region value points to.
pub fn cuCoredumpSetAttribute(
attrib: CUcoredumpSettings,
value: *mut ::core::ffi::c_void,
size: *mut size_t,
) -> CUresult;
}
unsafe extern "C" {
/// Allows caller to set a coredump attribute value globally.
///
/// This function should be considered an alternate interface to the CUDA-GDB environment variables defined in this document:
/// <https://docs.nvidia.com/cuda/cuda-gdb/index.html#gpu-coredump>
///
/// An important design decision to note is that any coredump environment variable values set before CUDA initializes will take
/// permanent precedence over any values set with this function. This decision was made to ensure no change in behavior for any
/// users that may be currently using these variables to get coredumps.
///
/// \*value shall contain the requested value specified by set. It is up to the caller to ensure that the data type and size of \*value matches the request.
///
/// If the caller calls this function with \*value equal to NULL, the size of the memory region (in bytes) expected for set will be placed in size.
///
/// The supported attributes are:
///
/// * [`CUcoredumpSettings::CU_COREDUMP_ENABLE_ON_EXCEPTION`]: Bool where true means that GPU exceptions from this context will create a coredump at the
/// location specified by [`CUcoredumpSettings::CU_COREDUMP_FILE`]. The default value is false.
/// * [`CUcoredumpSettings::CU_COREDUMP_TRIGGER_HOST`]: Bool where true means that the host CPU will also create a coredump. The default value is true unless
/// set to false globally or or locally. This value is deprecated as of CUDA 12.5 - raise the [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_ABORT`] flag to disable
/// host device abort() if needed.
/// * [`CUcoredumpSettings::CU_COREDUMP_LIGHTWEIGHT`]: Bool where true means that any resulting coredumps will not have a dump of GPU memory or non-reloc
/// ELF images. The default value is false. This attribute is deprecated as of CUDA 12.5, please use [`CUcoredumpSettings::CU_COREDUMP_GENERATION_FLAGS`]
/// instead.
/// * [`CUcoredumpSettings::CU_COREDUMP_ENABLE_USER_TRIGGER`]: Bool where true means that a coredump can be created by writing to the system pipe specified
/// by [`CUcoredumpSettings::CU_COREDUMP_PIPE`]. The default value is false.
/// * [`CUcoredumpSettings::CU_COREDUMP_FILE`]: String of up to 1023 characters that defines the location where any coredumps generated by this context
/// will be written. The default value is core.cuda.HOSTNAME.PID where HOSTNAME is the host name of the machine running the CUDA
/// applications and PID is the process ID of the CUDA application.
/// * [`CUcoredumpSettings::CU_COREDUMP_PIPE`]: String of up to 1023 characters that defines the name of the pipe that will be monitored if user-triggered
/// coredumps are enabled. This value may not be changed after [`CUcoredumpSettings::CU_COREDUMP_ENABLE_USER_TRIGGER`] is set to true. The default value
/// is corepipe.cuda.HOSTNAME.PID where HOSTNAME is the host name of the machine running the CUDA application and PID is the process
/// ID of the CUDA application.
/// * [`CUcoredumpSettings::CU_COREDUMP_GENERATION_FLAGS`]: An integer with values to allow granular control the data contained in a coredump specified
/// as a bitwise OR combination of the following values: + [`CUCoredumpGenerationFlags::CU_COREDUMP_DEFAULT_FLAGS`] - if set by itself, coredump generation returns
/// to its default settings of including all memory regions that it is able to access + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_NONRELOCATED_ELF_IMAGES`]
/// - Coredump will not include the data from CUDA source modules that are not relocated at runtime. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_GLOBAL_MEMORY`]
/// - Coredump will not include device-side global data that does not belong to any context. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_SHARED_MEMORY`]
/// - Coredump will not include grid-scale shared memory for the warp that the dumped kernel belonged to. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_LOCAL_MEMORY`]
/// - Coredump will not include local memory from the kernel. + [`CUCoredumpGenerationFlags::CU_COREDUMP_LIGHTWEIGHT_FLAGS`] - Enables all of the above options.
/// Equiavlent to setting the [`CUcoredumpSettings::CU_COREDUMP_LIGHTWEIGHT`] attribute to true. + [`CUCoredumpGenerationFlags::CU_COREDUMP_SKIP_ABORT`] - If set, GPU exceptions will
/// not raise an abort() in the host CPU process. Same functional goal as [`CUcoredumpSettings::CU_COREDUMP_TRIGGER_HOST`] but better reflects the default
/// behavior.
///
/// **See also:**
///
/// [`cuCoredumpGetAttribute`], [`cuCoredumpGetAttributeGlobal`], [`cuCoredumpSetAttribute`].
///
/// # Parameters
///
/// - `attrib`: The enum defining which value to set.
/// - `value`: void\* containing the requested data.
/// - `size`: The size of the memory region value points to.
pub fn cuCoredumpSetAttributeGlobal(
attrib: CUcoredumpSettings,
value: *mut ::core::ffi::c_void,
size: *mut size_t,
) -> CUresult;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUcoredumpCallbackEntry_st {
_unused: [u8; 0],
}
/// Opaque handle representing a registered coredump status callback. This handle is returned when registering a callback and
/// must be provided when deregistering the callback.
pub type CUcoredumpCallbackHandle = *mut CUcoredumpCallbackEntry_st;
/// Callback function prototype for GPU coredump status notifications. This callback will be invoked when a GPU coredump begins
/// or completes, depending on which registration function was used. The callback executes synchronously during the coredump process.
pub type CUcoredumpStatusCallback = ::core::option::Option<
unsafe extern "C" fn(
userData: *mut ::core::ffi::c_void,
pid: ::core::ffi::c_int,
dev: CUdevice,
),
>;
unsafe extern "C" {
/// Register a callback to be invoked when a GPU coredump begins.
///
/// This function registers a callback that will be called when a GPU coredump is initiated, before any coredump data is collected.
/// Callbacks are executed in the order they were registered. The same callback function can be registered multiple times with
/// different userData, and each registration will receive a unique handle.
///
/// Note:
///
/// Callbacks execute synchronously during the coredump process and will block coredump progress while running.
///
/// **See also:**
///
/// [`cuCoredumpDeregisterStartCallback`], [`cuCoredumpRegisterCompleteCallback`].
///
/// # Parameters
///
/// - `callback`: The callback function to register.
/// - `userData`: User data pointer to pass to the callback.
/// - `callbackOut`: Location to store the callback handle (optional, may be NULL).
pub fn cuCoredumpRegisterStartCallback(
callback: CUcoredumpStatusCallback,
userData: *mut ::core::ffi::c_void,
callbackOut: *mut CUcoredumpCallbackHandle,
) -> CUresult;
}
unsafe extern "C" {
/// Register a callback to be invoked when a GPU coredump completes.
///
/// This function registers a callback that will be called when a GPU coredump has been fully collected and written to disk. Callbacks
/// are executed in the order they were registered. The same callback function can be registered multiple times with different
/// userData, and each registration will receive a unique handle.
///
/// Note:
///
/// Callbacks execute synchronously during the coredump process and will block coredump progress while running.
///
/// **See also:**
///
/// [`cuCoredumpDeregisterCompleteCallback`], [`cuCoredumpRegisterStartCallback`].
///
/// # Parameters
///
/// - `callback`: The callback function to register.
/// - `userData`: User data pointer to pass to the callback.
/// - `callbackOut`: Location to store the callback handle (optional, may be NULL).
pub fn cuCoredumpRegisterCompleteCallback(
callback: CUcoredumpStatusCallback,
userData: *mut ::core::ffi::c_void,
callbackOut: *mut CUcoredumpCallbackHandle,
) -> CUresult;
}
unsafe extern "C" {
/// Deregister a previously registered coredump start callback.
///
/// This function removes a callback that was registered with [`cuCoredumpRegisterStartCallback`]. The callback handle becomes invalid after this call.
///
/// Note:
///
/// It is the caller's responsibility to deregister callbacks before they go out of scope.
///
/// **See also:**
///
/// [`cuCoredumpRegisterStartCallback`].
///
/// # Parameters
///
/// - `callback`: The callback handle to deregister.
pub fn cuCoredumpDeregisterStartCallback(
callback: CUcoredumpCallbackHandle,
) -> CUresult;
}
unsafe extern "C" {
/// Deregister a previously registered coredump complete callback.
///
/// This function removes a callback that was registered with [`cuCoredumpRegisterCompleteCallback`]. The callback handle becomes invalid after this call.
///
/// Note:
///
/// It is the caller's responsibility to deregister callbacks before they go out of scope.
///
/// **See also:**
///
/// [`cuCoredumpRegisterCompleteCallback`].
///
/// # Parameters
///
/// - `callback`: The callback handle to deregister.
pub fn cuCoredumpDeregisterCompleteCallback(
callback: CUcoredumpCallbackHandle,
) -> CUresult;
}
unsafe extern "C" {
pub fn cuGetExportTable(
ppExportTable: *mut *const ::core::ffi::c_void,
pExportTableId: *const CUuuid,
) -> CUresult;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUdevResourceDesc_st {
_unused: [u8; 0],
}
/// An opaque descriptor handle. The descriptor encapsulates multiple created and configured resources. Created via [`cuDevResourceGenerateDesc`].
pub type CUdevResourceDesc = *mut CUdevResourceDesc_st;
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUgreenCtxCreate_flags {
CU_GREEN_CTX_DEFAULT_STREAM = 1,
}
/// Flags for a [`CUdevSmResource`] group.
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUdevSmResourceGroup_flags {
CU_DEV_SM_RESOURCE_GROUP_DEFAULT = 0,
CU_DEV_SM_RESOURCE_GROUP_BACKFILL = 1,
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUdevSmResourceSplitByCount_flags {
CU_DEV_SM_RESOURCE_SPLIT_IGNORE_SM_COSCHEDULING = 1,
CU_DEV_SM_RESOURCE_SPLIT_MAX_POTENTIAL_CLUSTER_SIZE = 2,
}
/// Type of resource.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum CUdevResourceType {
CU_DEV_RESOURCE_TYPE_INVALID = 0,
/// Streaming multiprocessors related information.
CU_DEV_RESOURCE_TYPE_SM = 1,
/// Workqueue configuration related information.
CU_DEV_RESOURCE_TYPE_WORKQUEUE_CONFIG = 1000,
/// Pre-existing workqueue related information.
CU_DEV_RESOURCE_TYPE_WORKQUEUE = 10000,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUdevSmResource_st {
pub smCount: ::core::ffi::c_uint,
pub minSmPartitionSize: ::core::ffi::c_uint,
pub smCoscheduledAlignment: ::core::ffi::c_uint,
pub flags: ::core::ffi::c_uint,
}
/// Data for SM-related resources All parameters in this structure are OUTPUT only. Do not write to any of the fields in this
/// structure.
pub type CUdevSmResource = CUdevSmResource_st;
/// Sharing scope for workqueues.
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUdevWorkqueueConfigScope {
/// Use all shared workqueue resources across all contexts. Default driver behavior.
CU_WORKQUEUE_SCOPE_DEVICE_CTX = 0,
/// When possible, use non-overlapping workqueue resources with other balanced green contexts.
CU_WORKQUEUE_SCOPE_GREEN_CTX_BALANCED = 1,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUdevWorkqueueConfigResource_st {
pub device: CUdevice,
pub wqConcurrencyLimit: ::core::ffi::c_uint,
pub sharingScope: CUdevWorkqueueConfigScope,
}
impl Default for CUdevWorkqueueConfigResource_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Data for workqueue configuration related resources.
pub type CUdevWorkqueueConfigResource = CUdevWorkqueueConfigResource_st;
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CUdevWorkqueueResource_st {
pub reserved: [::core::ffi::c_uchar; 40usize],
}
impl Default for CUdevWorkqueueResource_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
/// Handle to a pre-existing workqueue related resource.
pub type CUdevWorkqueueResource = CUdevWorkqueueResource_st;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct CU_DEV_SM_RESOURCE_GROUP_PARAMS_st {
pub smCount: ::core::ffi::c_uint,
pub coscheduledSmCount: ::core::ffi::c_uint,
pub preferredCoscheduledSmCount: ::core::ffi::c_uint,
pub flags: ::core::ffi::c_uint,
pub reserved: [::core::ffi::c_uint; 12usize],
}
/// Input data for splitting SMs.
pub type CU_DEV_SM_RESOURCE_GROUP_PARAMS = CU_DEV_SM_RESOURCE_GROUP_PARAMS_st;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CUdevResource_st {
pub type_: CUdevResourceType,
pub _internal_padding: [::core::ffi::c_uchar; 92usize],
pub __bindgen_anon_1: CUdevResource_st__bindgen_ty_1,
pub nextResource: *mut CUdevResource_st,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union CUdevResource_st__bindgen_ty_1 {
pub sm: CUdevSmResource,
pub wqConfig: CUdevWorkqueueConfigResource,
pub wq: CUdevWorkqueueResource,
pub _oversize: [::core::ffi::c_uchar; 40usize],
}
impl Default for CUdevResource_st__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl Default for CUdevResource_st {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub type CUdevResource_v1 = CUdevResource_st;
/// A tagged union describing different resources identified by the type field. This structure should not be directly modified
/// outside of the API that created it.
///
/// ```text
/// struct {
/// CUdevResourceType type;
/// union {
/// CUdevSmResource sm;
/// CUdevWorkqueueConfigResource wqConfig;
/// CUdevWorkqueueResource wq;
/// };
/// };
/// ```
///
/// * If type is [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_INVALID`], this resource is not valid and cannot be further accessed.
/// * If type is [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_SM`], the [`CUdevSmResource`] structure sm is filled in. For example, sm.smCount will reflect the amount of streaming multiprocessors available in this resource.
/// * If type is [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_WORKQUEUE_CONFIG`], the [`CUdevWorkqueueConfigResource`] structure wqConfig is filled in.
/// * If type is [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_WORKQUEUE`], the [`CUdevWorkqueueResource`] structure wq is filled in.
pub type CUdevResource = CUdevResource_v1;
unsafe extern "C" {
/// Creates a green context with a specified set of resources.
///
/// This API creates a green context with the resources specified in the descriptor desc and returns it in the handle represented by phCtx. This API will retain the primary context on device dev, which will is released when the green context is destroyed. It is advised to have the primary context active before calling
/// this API to avoid the heavy cost of triggering primary context initialization and deinitialization multiple times.
///
/// The API does not set the green context current. In order to set it current, you need to explicitly set it current by first
/// converting the green context to a CUcontext using [`cuCtxFromGreenCtx`] and subsequently calling [`cuCtxSetCurrent`] / [`cuCtxPushCurrent_v2`]. It should be noted that a green context can be current to only one thread at a time. There is no internal synchronization
/// to make API calls accessing the same green context from multiple threads work.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// The supported flags are:
///
/// * CU_GREEN_CTX_DEFAULT_STREAM : Creates a default stream to use inside the green context. Required.
///
/// **See also:**
///
/// [`cuGreenCtxDestroy`], [`cuCtxFromGreenCtx`], [`cuCtxSetCurrent`], [`cuCtxPushCurrent_v2`], [`cuDevResourceGenerateDesc`], [`cuDevicePrimaryCtxRetain`], [`cuCtxCreate_v4`].
///
/// # Parameters
///
/// - `phCtx`: Pointer for the output handle to the green context.
/// - `desc`: Descriptor generated via [`cuDevResourceGenerateDesc`] which contains the set of resources to be used.
/// - `dev`: Device on which to create the green context.
/// - `flags`: One of the supported green context creation flags. CU_GREEN_CTX_DEFAULT_STREAM is required.
pub fn cuGreenCtxCreate(
phCtx: *mut CUgreenCtx,
desc: CUdevResourceDesc,
dev: CUdevice,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Destroys a green context.
///
/// Destroys the green context, releasing the primary context of the device that this green context was created for. Any resources
/// provisioned for this green context (that were initially available via the resource descriptor) are released as well. The API
/// does not destroy streams created via [`cuGreenCtxStreamCreate`], [`cuStreamCreate`], or [`cuStreamCreateWithPriority`]. Users are expected to destroy these streams explicitly using [`cuStreamDestroy_v2`] to avoid resource leaks. Once the green context is destroyed, any subsequent API calls involving these streams will return
/// [`cudaError_enum::CUDA_ERROR_STREAM_DETACHED`] with the exception of the following APIs:
///
/// * [`cuStreamDestroy_v2`].
///
/// Additionally, the API will invalidate all active captures on these streams.
///
/// **See also:**
///
/// [`cuGreenCtxCreate`], [`cuCtxDestroy_v2`].
///
/// # Parameters
///
/// - `hCtx`: Green context to be destroyed.
pub fn cuGreenCtxDestroy(hCtx: CUgreenCtx) -> CUresult;
}
unsafe extern "C" {
/// Converts a green context into the primary context.
///
/// The API converts a green context into the primary context returned in pContext. It is important to note that the converted context pContext is a normal primary context but with the resources of the specified green context hCtx. Once converted, it can then be used to set the context current with [`cuCtxSetCurrent`] or with any of the CUDA APIs that accept a CUcontext parameter.
///
/// Users are expected to call this API before calling any CUDA APIs that accept a CUcontext. Failing to do so will result in
/// the APIs returning [`cudaError_enum::CUDA_ERROR_INVALID_CONTEXT`].
///
/// **See also:**
///
/// [`cuGreenCtxCreate`].
///
/// # Parameters
///
/// - `pContext`: Returned primary context with green context resources.
/// - `hCtx`: Green context to convert.
pub fn cuCtxFromGreenCtx(pContext: *mut CUcontext, hCtx: CUgreenCtx) -> CUresult;
}
unsafe extern "C" {
/// Get device resources.
///
/// Get the type resources available to the device. This may often be the starting point for further partitioning or configuring of resources.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// **See also:**
///
/// [`cuDevResourceGenerateDesc`].
///
/// # Parameters
///
/// - `device`: Device to get resource for.
/// - `resource`: Output pointer to a [`CUdevResource`] structure.
pub fn cuDeviceGetDevResource(
device: CUdevice,
resource: *mut CUdevResource,
type_: CUdevResourceType,
) -> CUresult;
}
unsafe extern "C" {
/// Get context resources.
///
/// Get the type resources available to the context represented by hCtx
/// Note: The API is not supported on 32-bit platforms.
///
/// **See also:**
///
/// [`cuDevResourceGenerateDesc`].
///
/// # Parameters
///
/// - `hCtx`: Context to get resource for.
/// - `resource`: Output pointer to a [`CUdevResource`] structure.
pub fn cuCtxGetDevResource(
hCtx: CUcontext,
resource: *mut CUdevResource,
type_: CUdevResourceType,
) -> CUresult;
}
unsafe extern "C" {
/// Get green context resources.
///
/// Get the type resources available to the green context represented by hCtx
///
/// **See also:**
///
/// [`cuDevResourceGenerateDesc`].
///
/// # Parameters
///
/// - `hCtx`: Green context to get resource for.
/// - `resource`: Output pointer to a [`CUdevResource`] structure.
pub fn cuGreenCtxGetDevResource(
hCtx: CUgreenCtx,
resource: *mut CUdevResource,
type_: CUdevResourceType,
) -> CUresult;
}
unsafe extern "C" {
/// Splits [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_SM`] resources.
///
/// Splits [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_SM`] resources into nbGroups, adhering to the minimum SM count specified in minCount and the usage flags in flags. If result is NULL, the API simulates a split and provides the amount of groups that would be created in nbGroups. Otherwise, nbGroups must point to the amount of elements in result and on return, the API will overwrite nbGroups with the amount actually created. The groups are written to the array in result. nbGroups can be less than the total amount if a smaller number of groups is needed.
///
/// This API is used to spatially partition the input resource. The input resource needs to come from one of [`cuDeviceGetDevResource`], [`cuCtxGetDevResource`], or [`cuGreenCtxGetDevResource`]. A limitation of the API is that the output results cannot be split again without first creating a descriptor and a green
/// context with that descriptor.
///
/// When creating the groups, the API will take into account the performance and functional characteristics of the input resource,
/// and guarantee a split that will create a disjoint set of symmetrical partitions. This may lead to fewer groups created than
/// purely dividing the total SM count by the minCount due to cluster requirements or alignment and granularity requirements for the minCount. These requirements can be queried
/// with [`cuDeviceGetDevResource`], [`cuCtxGetDevResource`], and [`cuGreenCtxGetDevResource`] for CU_DEV_RESOURCE_TYPE_SM, using the minSmPartitionSize and smCoscheduledAlignment fields to determine minimum partition size and alignment granularity, respectively.
///
/// The remainder set does not have the same functional or performance guarantees as the groups in result. Its use should be carefully planned and future partitions of the remainder set are discouraged.
///
/// The following flags are supported:
///
/// * CU_DEV_SM_RESOURCE_SPLIT_IGNORE_SM_COSCHEDULING : Lower the minimum SM count and alignment, and treat each SM independent of its hierarchy. This allows more fine grained
/// partitions but at the cost of advanced features (such as large clusters on compute capability 9.0+).
/// * CU_DEV_SM_RESOURCE_SPLIT_MAX_POTENTIAL_CLUSTER_SIZE : Compute Capability 9.0+ only. Attempt to create groups that may allow for maximally sized thread clusters. This can be
/// queried post green context creation using [`cuOccupancyMaxPotentialClusterSize`] and launch configuration (config), return the maximum cluster size in *clusterSize.").
///
/// A successful API call must either have:
///
/// * A valid array of result pointers of size passed in nbGroups, with input of type [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_SM`]. Value of minCount must be between 0 and the SM count specified in input. remainder may be NULL.
/// * NULL passed in for result, with a valid integer pointer in nbGroups and input of type [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_SM`]. Value of minCount must be between 0 and the SM count specified in input. remainder may be NULL. This queries the number of groups that would be created by the API.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// **See also:**
///
/// [`cuGreenCtxGetDevResource`], [`cuCtxGetDevResource`], [`cuDeviceGetDevResource`].
///
/// # Parameters
///
/// - `result`: Output array of [`CUdevResource`] resources. Can be NULL to query the number of groups.
/// - `nbGroups`: This is a pointer, specifying the number of groups that would be or should be created as described below.
/// - `input`: Input SM resource to be split. Must be a valid [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_SM`] resource.
/// - `remainder`: If the input resource cannot be cleanly split among nbGroups, the remainder is placed in here. Can be ommitted (NULL) if the user does not need the remaining set.
/// - `flags`: Flags specifying how these partitions are used or which constraints to abide by when splitting the input. Zero is valid
/// for default behavior.
/// - `minCount`: Minimum number of SMs required.
pub fn cuDevSmResourceSplitByCount(
result: *mut CUdevResource,
nbGroups: *mut ::core::ffi::c_uint,
input: *const CUdevResource,
remainder: *mut CUdevResource,
flags: ::core::ffi::c_uint,
minCount: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Splits a [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_SM`] resource into structured groups.
///
/// This API will split a resource of CU_DEV_RESOURCE_TYPE_SM into nbGroups structured device resource groups (the result array), as well as an optional remainder, according to a set of requirements specified in the groupParams array. The term “structured” is a trait that specifies the result has SMs that are co-scheduled together. This co-scheduling can be specified via the coscheduledSmCount field of the groupParams structure, while the smCount will specify how many SMs are required in total for that result. The remainder is always “unstructured”, it does not have
/// any set guarantees with respect to co-scheduling and those properties will need to either be queried via the occupancy set
/// of APIs or further split into structured groups by this API.
///
/// The API has a discovery mode for use cases where it is difficult to know ahead of time what the SM count should be. Discovery
/// happens when the smCount field of a given groupParams array entry is set to 0 - the smCount will be filled in by the API with the derived SM count according to the provided groupParams fields and constraints. Discovery can be used with both a valid result array and with a NULL result pointer value. The latter is useful in situations where the smCount will end up being zero, which is an invalid value to
/// create a result entry with, but allowed for discovery purposes when the result is NULL.
///
/// The groupParams array is evaluated from index 0 to nbGroups - 1. For each index in the groupParams array, the API will evaluate which SMs may be a good fit based on constraints and assign those SMs to result. This evaluation order is important to consider when using discovery mode, as it helps discover the remaining SMs.
///
/// For a valid call:
///
/// * result should point to a [`CUdevResource`] array of size nbGroups, or alternatively, may be NULL, if the developer wishes for only the groupParams entries to be updated
///
/// * input should be a valid CU_DEV_RESOURCE_TYPE_SM resource that originates from querying the green context, device context, or device.
///
/// * The remainder group may be NULL.
///
/// * There are no API flags at this time, so the value passed in should be 0.
///
/// * A [`CU_DEV_SM_RESOURCE_GROUP_PARAMS`] array of size nbGroups. Each entry must be zero-initialized.
/// + smCount: must be either 0 or in the range of \[2,inputSmCount\] where inputSmCount is the amount of SMs the input resource has. smCount must be a multiple of 2, as well as a multiple of coscheduledSmCount. When assigning SMs to a group (and if results are expected by having the result parameter set), smCount cannot end up with 0 or a value less than coscheduledSmCount otherwise [`CUresult::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`] will be returned.
/// + coscheduledSmCount: allows grouping SMs together in order to be able to launch clusters on Compute Architecture 9.0+. The default value may be
/// queried from the device’s CU_DEV_RESOURCE_TYPE_SM resource (8 on Compute Architecture 9.0+ and 2 otherwise). The maximum is 32 on Compute Architecture 9.0+ and 2 otherwise.
/// + preferredCoscheduledSmCount: Attempts to merge coscheduledSmCount groups into larger groups, in order to make use of preferredClusterDimensions on Compute Architecture 10.0+. The default value is set to coscheduledSmCount.
/// + flags:
/// - [`CUdevSmResourceGroup_flags::CU_DEV_SM_RESOURCE_GROUP_BACKFILL`]: lets smCount be a non-multiple of coscheduledSmCount, filling the difference between SM count and already assigned co-scheduled groupings with other SMs. This lets any resulting
/// group behave similar to the remainder group for example.
///
/// **Example params and their effect:**
///
/// A groupParams array element is defined in the following order:
///
/// ```text
/// { .smCount, .coscheduledSmCount, .preferredCoscheduledSmCount, .flags, \/\* .reserved \*\/ }
/// ```
///
/// ```text
/// // Example 1
/// // Will discover how many SMs there are, that are co-scheduled in groups of smCoscheduledAlignment.
/// // The rest is placed in the optional remainder.
/// CU_DEV_SM_RESOURCE_GROUP_PARAMS params { 0, 0, 0, 0 };
/// ```
///
/// ```text
/// // Example 2
/// // Assuming the device has 10+ SMs, the result will have 10 SMs that are co-scheduled in groups of 2 SMs.
/// // The rest is placed in the optional remainder.
/// CU_DEV_SM_RESOURCE_GROUP_PARAMS params { 10, 2, 0, 0};
/// // Setting the coscheduledSmCount to 2 guarantees that we can always have a valid result
/// // as long as the SM count is less than or equal to the input resource SM count.
/// ```
///
/// ```text
/// // Example 3
/// // A single piece is split-off, but instead of assigning the rest to the remainder, a second group contains everything else
/// // This assumes the device has 10+ SMs (8 of which are coscheduled in groups of 4),
/// // otherwise the second group could end up with 0 SMs, which is not allowed.
/// CU_DEV_SM_RESOURCE_GROUP_PARAMS params { {8, 4, 0, 0}, {0, 2, 0, CU_DEV_SM_RESOURCE_GROUP_BACKFILL } }
/// ```
///
/// The difference between a catch-all param group as the last entry and the remainder is in two aspects:
///
/// * The remainder may be NULL / _TYPE_INVALID (if there are no SMs remaining), while a result group must always be valid.
/// * The remainder does not have a structure, while the result group will always need to adhere to a structure of coscheduledSmCount
/// (even if its just 2), and therefore must always have enough coscheduled SMs to cover that requirement (even with the [`CUdevSmResourceGroup_flags::CU_DEV_SM_RESOURCE_GROUP_BACKFILL`] flag enabled).
///
/// Splitting an input into N groups, can be accomplished by repeatedly splitting off 1 group and re-splitting the remainder (a
/// bisect operation). However, it's recommended to accomplish this with a single call wherever possible.
///
/// **See also:**
///
/// [`cuGreenCtxGetDevResource`], [`cuCtxGetDevResource`], [`cuDeviceGetDevResource`].
///
/// # Parameters
///
/// - `result`: Output array of [`CUdevResource`] resources. Can be NULL, alongside an smCount of 0, for discovery purpose.
/// - `nbGroups`: Specifies the number of groups in result and groupParams.
/// - `input`: Input SM resource to be split. Must be a valid [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_SM`] resource.
/// - `remainder`: If splitting the input resource leaves any SMs, the remainder is placed in here.
/// - `flags`: Flags specifying how the API should behave. The value should be 0 for now.
/// - `groupParams`: Description of how the SMs should be split and assigned to the corresponding result entry.
pub fn cuDevSmResourceSplit(
result: *mut CUdevResource,
nbGroups: ::core::ffi::c_uint,
input: *const CUdevResource,
remainder: *mut CUdevResource,
flags: ::core::ffi::c_uint,
groupParams: *mut CU_DEV_SM_RESOURCE_GROUP_PARAMS,
) -> CUresult;
}
unsafe extern "C" {
/// Generate a resource descriptor.
///
/// Generates a single resource descriptor with the set of resources specified in resources. The generated resource descriptor is necessary for the creation of green contexts via the [`cuGreenCtxCreate`] API. Resources of the same type can be passed in, provided they meet the requirements as noted below.
///
/// A successful API call must have:
///
/// * A valid output pointer for the phDesc descriptor as well as a valid array of resources pointers, with the array size passed in nbResources. If multiple resources are provided in resources, the device they came from must be the same, otherwise [`CUresult::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`] is returned. If multiple
/// resources are provided in resources and they are of type CU_DEV_RESOURCE_TYPE_SM, they must be outputs (whether result or remaining) from the same split API instance and have the same smCoscheduledAlignment values, otherwise [`CUresult::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`]
/// is returned.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// **See also:**
///
/// [`cuDevSmResourceSplitByCount`].
///
/// # Parameters
///
/// - `phDesc`: Output descriptor.
/// - `resources`: Array of resources to be included in the descriptor.
/// - `nbResources`: Number of resources passed in resources.
pub fn cuDevResourceGenerateDesc(
phDesc: *mut CUdevResourceDesc,
resources: *mut CUdevResource,
nbResources: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Records an event.
///
/// Captures in hEvent all the activities of the green context of hCtx at the time of this call. hEvent and hCtx must be from the same primary context otherwise [`cudaError_enum::CUDA_ERROR_INVALID_HANDLE`] is returned. Calls such as [`cuEventQuery`] or [`cuGreenCtxWaitEvent`] will then examine or wait for completion of the work that was captured. Uses of hCtx after this call do not modify hEvent.
///
/// Note:
///
/// The API will return [`cudaError_enum::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED`] if the specified green context hCtx has a stream in the capture mode. In such a case, the call will invalidate all the conflicting captures.
///
/// **See also:**
///
/// [`cuGreenCtxWaitEvent`], [`cuEventRecord`], [`cuCtxRecordEvent`], [`cuCtxWaitEvent`].
///
/// # Parameters
///
/// - `hCtx`: Green context to record event for.
/// - `hEvent`: Event to record.
pub fn cuGreenCtxRecordEvent(hCtx: CUgreenCtx, hEvent: CUevent) -> CUresult;
}
unsafe extern "C" {
/// Make a green context wait on an event.
///
/// Makes all future work submitted to green context hCtx wait for all work captured in hEvent. The synchronization will be performed on the device and will not block the calling CPU thread. See [`cuGreenCtxRecordEvent`] or [`cuEventRecord`], for details on what is captured by an event.
///
/// Note:
///
/// * hEvent may be from a different context or device than hCtx.
/// * The API will return [`cudaError_enum::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED`] and invalidate the capture if the specified event hEvent is part of an ongoing capture sequence or if the specified green context hCtx has a stream in the capture mode.
///
/// **See also:**
///
/// [`cuGreenCtxRecordEvent`], [`cuStreamWaitEvent`], [`cuCtxRecordEvent`], [`cuCtxWaitEvent`].
///
/// # Parameters
///
/// - `hCtx`: Green context to wait.
/// - `hEvent`: Event to wait on.
pub fn cuGreenCtxWaitEvent(hCtx: CUgreenCtx, hEvent: CUevent) -> CUresult;
}
unsafe extern "C" {
/// Query the green context associated with a stream.
///
/// Returns the CUDA green context that the stream is associated with, or NULL if the stream is not associated with any green
/// context.
///
/// The stream handle hStream can refer to any of the following:
///
/// * a stream created via any of the CUDA driver APIs such as [`cuStreamCreate`], [`cuStreamCreateWithPriority`] and [`cuGreenCtxStreamCreate`], or their runtime API equivalents such as [cudaStreamCreate](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g6a3c4b819e6a994c26d0c4824a4c80da), [cudaStreamCreateWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1gb1e32aff9f59119e4d0a9858991c4ad3) and [cudaStreamCreateWithPriority](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1ge2be9e9858849bf62ba4a8b66d1c3540). If during stream creation the context that was active in the calling thread was obtained with cuCtxFromGreenCtx, that green
/// context is returned in phCtx. Otherwise, \*phCtx is set to NULL instead.
/// * special stream such as the NULL stream or `CU_STREAM_LEGACY`. In that case if context that is active in the calling thread was obtained with cuCtxFromGreenCtx, that green context is
/// returned. Otherwise, \*phCtx is set to NULL instead.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuStreamCreate`], [`cuStreamCreateWithPriority`], [`cuStreamGetCtx`], [`cuGreenCtxStreamCreate`], [`cuStreamGetPriority`], [`cuStreamGetFlags`], [`cuStreamGetDevice`], [`cuStreamWaitEvent`], [`cuStreamQuery`], [`cuStreamSynchronize`], [`cuStreamAddCallback`], [cudaStreamCreate](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g6a3c4b819e6a994c26d0c4824a4c80da), [cudaStreamCreateWithFlags](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1gb1e32aff9f59119e4d0a9858991c4ad3).
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `phCtx`: Returned green context associated with the stream.
pub fn cuStreamGetGreenCtx(hStream: CUstream, phCtx: *mut CUgreenCtx) -> CUresult;
}
unsafe extern "C" {
/// Create a stream for use in the green context.
///
/// Creates a stream for use in the specified green context greenCtx and returns a handle in phStream. The stream can be destroyed by calling [`cuStreamDestroy_v2`]. Note that the API ignores the context that is current to the calling thread and creates a stream in the specified green
/// context greenCtx.
///
/// The supported values for flags are:
///
/// * [`CUstream_flags_enum::CU_STREAM_NON_BLOCKING`]: This must be specified. It indicates that work running in the created stream may run concurrently with work in the default
/// stream, and that the created stream should perform no implicit synchronization with the default stream.
///
/// Specifying priority affects the scheduling priority of work in the stream. Priorities provide a hint to preferentially run work with higher priority
/// when possible, but do not preempt already-running work or provide any other functional guarantee on execution order. priority follows a convention where lower numbers represent higher priorities. '0' represents default priority. The range of meaningful
/// numerical priorities can be queried using [`cuCtxGetStreamPriorityRange`]. If the specified priority is outside the numerical range returned by [`cuCtxGetStreamPriorityRange`], it will automatically be clamped to the lowest or the highest number in the range.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream
/// priorities have no effect on host-to-device and device-to-host memory operations.
///
/// **See also:**
///
/// [`cuStreamDestroy_v2`], [`cuGreenCtxCreate`].
///
/// # Parameters
///
/// - `phStream`: Returned newly created stream.
/// - `greenCtx`: Green context for which to create the stream for.
/// - `flags`: Flags for stream creation. [`CUstream_flags::CU_STREAM_NON_BLOCKING`] must be specified.
/// - `priority`: Stream priority. Lower numbers represent higher priorities. See [`cuCtxGetStreamPriorityRange`] for more information about meaningful stream priorities that can be passed.
pub fn cuGreenCtxStreamCreate(
phStream: *mut CUstream,
greenCtx: CUgreenCtx,
flags: ::core::ffi::c_uint,
priority: ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the unique Id associated with the green context supplied.
///
/// Returns in greenCtxId the unique Id which is associated with a given green context. The Id is unique for the life of the program for this instance
/// of CUDA. If green context is supplied as NULL and the current context is set to a green context, the Id of the current green
/// context is returned.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGreenCtxCreate`], [`cuGreenCtxDestroy`], [`cuCtxGetId`].
///
/// # Parameters
///
/// - `greenCtx`: Green context for which to obtain the Id.
/// - `greenCtxId`: Pointer to store the Id of the green context.
pub fn cuGreenCtxGetId(
greenCtx: CUgreenCtx,
greenCtxId: *mut ::core::ffi::c_ulonglong,
) -> CUresult;
}
unsafe extern "C" {
/// Get stream resources.
///
/// Get the type resources available to the hStream and store them in resource.
///
/// Note: The API will return [`cudaError_enum::CUDA_ERROR_INVALID_RESOURCE_TYPE`] is type is [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_WORKQUEUE_CONFIG`] or [`CUdevResourceType::CU_DEV_RESOURCE_TYPE_WORKQUEUE`].
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cuGreenCtxCreate`], [`cuGreenCtxStreamCreate`], [`cuStreamCreate`], [`cuDevSmResourceSplitByCount`], [`cuDevResourceGenerateDesc`], [cudaStreamGetDevResource](https://docs.nvidia.com/cuda/archive/13.2.0/cuda-runtime-api/group__CUDART__EXECUTION__CONTEXT.html#group__CUDART__EXECUTION__CONTEXT_1g55c60bf05fec3cf837d96520c91b8396).
///
/// # Parameters
///
/// - `hStream`: Stream to get resource for.
/// - `resource`: Output pointer to a [`CUdevResource`] structure.
pub fn cuStreamGetDevResource(
hStream: CUstream,
resource: *mut CUdevResource,
type_: CUdevResourceType,
) -> CUresult;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum CUlogLevel_enum {
CU_LOG_LEVEL_ERROR = 0,
CU_LOG_LEVEL_WARNING = 1,
}
pub use self::CUlogLevel_enum as CUlogLevel;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct CUlogsCallbackEntry_st {
_unused: [u8; 0],
}
pub type CUlogsCallbackHandle = *mut CUlogsCallbackEntry_st;
pub type CUlogsCallback = ::core::option::Option<
unsafe extern "C" fn(
data: *mut ::core::ffi::c_void,
logLevel: CUlogLevel,
message: *mut ::core::ffi::c_char,
length: size_t,
),
>;
pub type CUlogIterator = ::core::ffi::c_uint;
unsafe extern "C" {
/// Register a callback function to receive error log messages.
///
/// # Parameters
///
/// - `callbackFunc`: The function to register as a callback.
/// - `userData`: A generic pointer to user data. This is passed into the callback function.
/// - `callback_out`: Optional location to store the callback handle after it is registered.
pub fn cuLogsRegisterCallback(
callbackFunc: CUlogsCallback,
userData: *mut ::core::ffi::c_void,
callback_out: *mut CUlogsCallbackHandle,
) -> CUresult;
}
unsafe extern "C" {
/// Unregister a log message callback.
///
/// # Parameters
///
/// - `callback`: The callback instance to unregister from receiving log messages.
pub fn cuLogsUnregisterCallback(callback: CUlogsCallbackHandle) -> CUresult;
}
unsafe extern "C" {
/// Sets log iterator to point to the end of log buffer, where the next message would be written.
///
/// # Parameters
///
/// - `iterator_out`: Location to store an iterator to the current tail of the logs.
/// - `flags`: Reserved for future use, must be 0.
pub fn cuLogsCurrent(
iterator_out: *mut CUlogIterator,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Dump accumulated driver logs into a file.
///
/// Logs generated by the driver are stored in an internal buffer and can be copied out using this API. This API dumps all driver
/// logs starting from iterator into pathToFile provided.
///
/// Note:
///
/// * iterator is auto-advancing. Dumping logs will update the value of iterator to receive the next generated log.
/// * The driver reserves limited memory for storing logs. The oldest logs may be overwritten and become unrecoverable. An indication
/// will appear in the destination outupt if the logs have been truncated. Call dump after each failed API to mitigate this risk.
///
/// # Parameters
///
/// - `iterator`: Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
/// - `pathToFile`: Path to output file for dumping logs.
/// - `flags`: Reserved for future use, must be 0.
pub fn cuLogsDumpToFile(
iterator: *mut CUlogIterator,
pathToFile: *const ::core::ffi::c_char,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Dump accumulated driver logs into a buffer.
///
/// Logs generated by the driver are stored in an internal buffer and can be copied out using this API. This API dumps driver
/// logs from iterator into buffer up to the size specified in \*size. The driver will always null terminate the buffer but there will not be a null character between log entries, only a newline
/// \n. The driver will then return the actual number of bytes written in \*size, excluding the null terminator. If there are no messages to dump, \*size will be set to 0 and the function will return [`cudaError_enum::CUDA_SUCCESS`]. If the provided buffer is not large enough to hold any messages, \*size will be set to 0 and the function will return [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`].
///
/// Note:
///
/// * iterator is auto-advancing. Dumping logs will update the value of iterator to receive the next generated log.
/// * The driver reserves limited memory for storing logs. The maximum size of the buffer is 25600 bytes. The oldest logs may be
/// overwritten and become unrecoverable. An indication will appear in the destination outupt if the logs have been truncated.
/// Call dump after each failed API to mitigate this risk.
/// * If the provided value in \*size is not large enough to hold all buffered messages, a message will be added at the head of the buffer indicating this. The
/// driver then computes the number of messages it is able to store in buffer and writes it out. The final message in buffer will always be the most recent log message as of when the API is called.
///
/// # Parameters
///
/// - `iterator`: Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
/// - `buffer`: Pointer to dump logs.
/// - `size`: See description.
/// - `flags`: Reserved for future use, must be 0.
pub fn cuLogsDumpToMemory(
iterator: *mut CUlogIterator,
buffer: *mut ::core::ffi::c_char,
size: *mut size_t,
flags: ::core::ffi::c_uint,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the restore thread ID for a CUDA process.
///
/// Returns in \*tid the thread ID of the CUDA restore thread for the process specified by pid.
///
/// # Parameters
///
/// - `pid`: The process ID of the CUDA process.
/// - `tid`: Returned restore thread ID.
pub fn cuCheckpointProcessGetRestoreThreadId(
pid: ::core::ffi::c_int,
tid: *mut ::core::ffi::c_int,
) -> CUresult;
}
unsafe extern "C" {
/// Returns the process state of a CUDA process.
///
/// Returns in \*state the current state of the CUDA process specified by pid.
///
/// # Parameters
///
/// - `pid`: The process ID of the CUDA process.
/// - `state`: Returned CUDA process state.
pub fn cuCheckpointProcessGetState(
pid: ::core::ffi::c_int,
state: *mut CUprocessState,
) -> CUresult;
}
unsafe extern "C" {
/// Lock a running CUDA process.
///
/// Lock the CUDA process specified by pid which will block further CUDA API calls. Process must be in the RUNNING state in order to lock.
///
/// Upon successful return the process will be in the LOCKED state.
///
/// If timeoutMs is specified and the timeout is reached the process will be left in the RUNNING state upon return.
///
/// # Parameters
///
/// - `pid`: The process ID of the CUDA process.
/// - `args`: Optional lock operation arguments.
pub fn cuCheckpointProcessLock(
pid: ::core::ffi::c_int,
args: *mut CUcheckpointLockArgs,
) -> CUresult;
}
unsafe extern "C" {
/// Checkpoint a CUDA process's GPU memory contents.
///
/// Checkpoints a CUDA process specified by pid that is in the LOCKED state. The GPU memory contents will be brought into host memory and all underlying references will
/// be released. Process must be in the LOCKED state to checkpoint.
///
/// Upon successful return the process will be in the CHECKPOINTED state.
///
/// # Parameters
///
/// - `pid`: The process ID of the CUDA process.
/// - `args`: Optional checkpoint operation arguments.
pub fn cuCheckpointProcessCheckpoint(
pid: ::core::ffi::c_int,
args: *mut CUcheckpointCheckpointArgs,
) -> CUresult;
}
unsafe extern "C" {
/// Restore a CUDA process's GPU memory contents from its last checkpoint.
///
/// Restores a CUDA process specified by pid from its last checkpoint. Process must be in the CHECKPOINTED state to restore.
///
/// GPU UUID pairs can be specified in args to remap the process old GPUs onto new GPUs. The GPU to restore onto needs to have enough memory and be of the same chip
/// type as the old GPU. If an array of GPU UUID pairs is specified, it must contain every checkpointed GPU.
///
/// Upon successful return the process will be in the LOCKED state.
///
/// CUDA process restore requires persistence mode to be enabled or [`cuInit`] has not been called, any function from the driver API will return [`CUresult::CUDA_ERROR_NOT_INITIALIZED`].") to have been called before execution.
///
/// **See also:**
///
/// [`cuInit`] has not been called, any function from the driver API will return [`CUresult::CUDA_ERROR_NOT_INITIALIZED`].")
///
/// # Parameters
///
/// - `pid`: The process ID of the CUDA process.
/// - `args`: Optional restore operation arguments.
pub fn cuCheckpointProcessRestore(
pid: ::core::ffi::c_int,
args: *mut CUcheckpointRestoreArgs,
) -> CUresult;
}
unsafe extern "C" {
/// Unlock a CUDA process to allow CUDA API calls.
///
/// Unlocks a process specified by pid allowing it to resume making CUDA API calls. Process must be in the LOCKED state.
///
/// Upon successful return the process will be in the RUNNING state.
///
/// # Parameters
///
/// - `pid`: The process ID of the CUDA process.
/// - `args`: Optional unlock operation arguments.
pub fn cuCheckpointProcessUnlock(
pid: ::core::ffi::c_int,
args: *mut CUcheckpointUnlockArgs,
) -> CUresult;
}