/* automatically generated by rust-bindgen 0.72.1 */
/// Compile-time CUDA runtime API version code. This identifies the headers used to generate these bindings, which may differ from the loaded library.
pub const CUDART_VERSION: u32 = 13040;
/// Selects a one-dimensional surface resource.
pub const cudaSurfaceType1D: u32 = 1;
/// Selects a two-dimensional surface resource.
pub const cudaSurfaceType2D: u32 = 2;
/// Selects a three-dimensional surface resource.
pub const cudaSurfaceType3D: u32 = 3;
/// Selects a cube-map surface resource.
pub const cudaSurfaceTypeCubemap: u32 = 12;
/// Selects a layered one-dimensional surface resource.
pub const cudaSurfaceType1DLayered: u32 = 241;
/// Selects a layered two-dimensional surface resource.
pub const cudaSurfaceType2DLayered: u32 = 242;
/// Selects a layered cube-map surface resource.
pub const cudaSurfaceTypeCubemapLayered: u32 = 252;
/// Selects a one-dimensional texture resource.
pub const cudaTextureType1D: u32 = 1;
/// Selects a two-dimensional texture resource.
pub const cudaTextureType2D: u32 = 2;
/// Selects a three-dimensional texture resource.
pub const cudaTextureType3D: u32 = 3;
/// Selects a cube-map texture resource.
pub const cudaTextureTypeCubemap: u32 = 12;
/// Selects a layered one-dimensional texture resource.
pub const cudaTextureType1DLayered: u32 = 241;
/// Selects a layered two-dimensional texture resource.
pub const cudaTextureType2DLayered: u32 = 242;
/// Selects a layered cube-map texture resource.
pub const cudaTextureTypeCubemapLayered: u32 = 252;
impl cudaRoundMode {
/// Rounds to the nearest representable value.
pub const cudaRoundNearest: cudaRoundMode = cudaRoundMode(0);
/// Rounds toward zero.
pub const cudaRoundZero: cudaRoundMode = cudaRoundMode(1);
/// Rounds toward positive infinity.
pub const cudaRoundPosInf: cudaRoundMode = cudaRoundMode(2);
/// Rounds toward negative infinity.
pub const cudaRoundMinInf: cudaRoundMode = cudaRoundMode(3);
}
/// Floating-point rounding direction for CUDA conversion operations.
#[repr(transparent)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct cudaRoundMode(pub ::core::ffi::c_uint);
/// Unsigned C `size_t`, used for byte counts and object sizes in the native ABI.
pub type size_t = ::core::ffi::c_ulong;
impl cudaSurfaceBoundaryMode {
/// Zero boundary mode.
pub const cudaBoundaryModeZero: cudaSurfaceBoundaryMode = cudaSurfaceBoundaryMode(0);
/// Clamp boundary mode.
pub const cudaBoundaryModeClamp: cudaSurfaceBoundaryMode = cudaSurfaceBoundaryMode(
1,
);
/// Trap boundary mode.
pub const cudaBoundaryModeTrap: cudaSurfaceBoundaryMode = cudaSurfaceBoundaryMode(2);
}
/// CUDA Surface boundary modes.
#[repr(transparent)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct cudaSurfaceBoundaryMode(pub ::core::ffi::c_uint);
impl cudaSurfaceFormatMode {
/// Forced format mode.
pub const cudaFormatModeForced: cudaSurfaceFormatMode = cudaSurfaceFormatMode(0);
/// Auto format mode.
pub const cudaFormatModeAuto: cudaSurfaceFormatMode = cudaSurfaceFormatMode(1);
}
/// CUDA Surface format modes.
#[repr(transparent)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct cudaSurfaceFormatMode(pub ::core::ffi::c_uint);
/// An opaque value that represents a CUDA Surface object.
pub type cudaSurfaceObject_t = ::core::ffi::c_ulonglong;
impl cudaTextureAddressMode {
/// Wrapping address mode.
pub const cudaAddressModeWrap: cudaTextureAddressMode = cudaTextureAddressMode(0);
/// Clamp to edge address mode.
pub const cudaAddressModeClamp: cudaTextureAddressMode = cudaTextureAddressMode(1);
/// Mirror address mode.
pub const cudaAddressModeMirror: cudaTextureAddressMode = cudaTextureAddressMode(2);
/// Border address mode.
pub const cudaAddressModeBorder: cudaTextureAddressMode = cudaTextureAddressMode(3);
}
/// CUDA texture address modes.
#[repr(transparent)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct cudaTextureAddressMode(pub ::core::ffi::c_uint);
impl cudaTextureFilterMode {
/// Point filter mode.
pub const cudaFilterModePoint: cudaTextureFilterMode = cudaTextureFilterMode(0);
/// Linear filter mode.
pub const cudaFilterModeLinear: cudaTextureFilterMode = cudaTextureFilterMode(1);
}
/// CUDA texture filter modes.
#[repr(transparent)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct cudaTextureFilterMode(pub ::core::ffi::c_uint);
impl cudaTextureReadMode {
/// Read texture as specified element type.
pub const cudaReadModeElementType: cudaTextureReadMode = cudaTextureReadMode(0);
/// Read texture as normalized float.
pub const cudaReadModeNormalizedFloat: cudaTextureReadMode = cudaTextureReadMode(1);
}
/// CUDA texture read modes.
#[repr(transparent)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct cudaTextureReadMode(pub ::core::ffi::c_uint);
/// CUDA texture descriptor.
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
pub struct cudaTextureDesc {
/// Texture address mode for up to 3 dimensions.
pub addressMode: [cudaTextureAddressMode; 3usize],
/// Texture filter mode.
pub filterMode: cudaTextureFilterMode,
/// Texture read mode.
pub readMode: cudaTextureReadMode,
/// Perform sRGB->linear conversion during texture read.
pub sRGB: ::core::ffi::c_int,
/// Texture Border Color.
pub borderColor: [f32; 4usize],
/// Indicates whether texture reads are normalized or not.
pub normalizedCoords: ::core::ffi::c_int,
/// Limit to the anisotropy ratio.
pub maxAnisotropy: ::core::ffi::c_uint,
/// Mipmap filter mode.
pub mipmapFilterMode: cudaTextureFilterMode,
/// Offset applied to the supplied mipmap level.
pub mipmapLevelBias: f32,
/// Lower end of the mipmap level range to clamp access to.
pub minMipmapLevelClamp: f32,
/// Upper end of the mipmap level range to clamp access to.
pub maxMipmapLevelClamp: f32,
/// Disable any trilinear filtering optimizations.
pub disableTrilinearOptimization: ::core::ffi::c_int,
/// Enable seamless cube map filtering.
pub seamlessCubemap: ::core::ffi::c_int,
}
impl Default for cudaTextureDesc {
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()
}
}
}
/// An opaque value that represents a CUDA texture object.
pub type cudaTextureObject_t = ::core::ffi::c_ulonglong;
singe_loader::functions! { crate::RUNTIME;
/// Destroy all allocations and reset all state on the current device in the current process.
///
/// Explicitly destroys and cleans up all resources associated with the current device in the current process. It is the caller’s responsibility to ensure that the resources are not accessed or passed in subsequent API calls and doing so will result in undefined behavior. These resources include CUDA types [cudaStream_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gae15d9c8b7a240312b533d6122558085a), [cudaEvent_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaea2f543a9fc0e52fe4ae712920fd1247), [cudaArray_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaaf8b3ba752727d996074a71ee997ce68), [cudaMipmappedArray_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga1b03ad14fc0ab86f8b033837f5562d8a), [`cudaPitchedPtr`], [`cudaTextureObject_t`], [`cudaSurfaceObject_t`], ::textureReference, ::surfaceReference, [cudaExternalMemory_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga79a2bf6a3a2aa9011a96dc17d476faf7), [cudaExternalSemaphore_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaf8bc7ab93d638c5835e5289ac7d683c4) and [cudaGraphicsResource_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaf58dd8d3c7a65714ff7f5459adbf7e6f). These resources also include memory allocations by [`cudaMalloc`], [`cudaMallocHost`], [`cudaMallocManaged`] and [`cudaMallocPitch`]. Any subsequent API call to this device will reinitialize the device.
///
/// Note that this function will reset the device immediately. It is the caller’s responsibility to ensure that the device is not being accessed by any other host threads from the process when this function is called.
pub fn cudaDeviceReset() -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Wait for compute device to finish.
///
/// Blocks until the device has completed all preceding requested tasks. [`cudaDeviceSynchronize`] returns an error if one of the preceding tasks has failed. If the [cudaDeviceScheduleBlockingSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga057e6912c52708b6aa86e79dd83d007c) flag was set for this device, the host thread will block until the device has finished its work.
pub fn cudaDeviceSynchronize() -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Set resource limits.
///
/// Setting `limit` to `value` is a request by the application to update the current limit maintained by the device. 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 [`cudaDeviceGetLimit`] to find out exactly what the limit has been set to.
///
/// Setting each [`cudaLimit`] has its own specific restrictions, so each is discussed here.
///
/// # Parameters
///
/// - `limit`: Limit to set.
/// - `value`: Size of limit.
pub fn cudaDeviceSetLimit(limit: cudaLimit, value: size_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Return resource limits.
///
/// Returns in `*pValue` the current size of `limit`. The following [`cudaLimit`] values are supported.
///
/// # Parameters
///
/// - `pValue`: Returned size of the limit.
/// - `limit`: Limit to query.
pub fn cudaDeviceGetLimit(pValue: *mut size_t, limit: cudaLimit) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the maximum number of elements allocatable in a 1D linear texture for a given element size.
///
/// Returns in `maxWidthInElements` the maximum number of elements allocatable in a 1D linear texture for given format descriptor `fmtDesc`.
///
/// # Parameters
///
/// - `maxWidthInElements`: Returns maximum number of texture elements allocatable for given `fmtDesc`.
/// - `fmtDesc`: Texture format description.
pub fn cudaDeviceGetTexture1DLinearMaxWidth(
maxWidthInElements: *mut size_t,
fmtDesc: *const cudaChannelFormatDesc,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the preferred cache configuration for the current device.
///
/// On devices where the L1 cache and shared memory use the same hardware resources, this returns through `pCacheConfig` the preferred cache configuration for the current device. This is only a preference. The runtime 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 `pCacheConfig` of [cudaFuncCachePreferNone](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggab980f35ed69ee7991704de29a13de49ba3b4b8c65376ce1ca107be413e15981bc) on devices where the size of the L1 cache and shared memory are fixed.
///
/// The supported cache configurations are.
///
/// # Parameters
///
/// - `pCacheConfig`: - Returned cache configuration
pub fn cudaDeviceGetCacheConfig(pCacheConfig: *mut cudaFuncCache) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaStreamCreateWithPriority`] 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 [`cudaDeviceGetAttribute`]).
///
/// # 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 cudaDeviceGetStreamPriorityRange(
leastPriority: *mut ::core::ffi::c_int,
greatestPriority: *mut ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the preferred cache configuration for the current device.
///
/// On devices where the L1 cache and shared memory use the same hardware resources, this sets through `cacheConfig` the preferred cache configuration for the current device. This is only a preference. The runtime 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 [cudaFuncSetCacheConfig (C API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__EXECUTION.html#group__cudart__execution_1ga6699ca1943ac2655effa0d571b2f4f15) or [cudaFuncSetCacheConfig (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga981c8d74d33b21e7fd57609b7337653e) will be preferred over this device-wide setting. Setting the device-wide cache configuration to [cudaFuncCachePreferNone](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggab980f35ed69ee7991704de29a13de49ba3b4b8c65376ce1ca107be413e15981bc) 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.
///
/// # Parameters
///
/// - `cacheConfig`: - Requested cache configuration
pub fn cudaDeviceSetCacheConfig(cacheConfig: cudaFuncCache) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a handle to a compute device.
///
/// Returns in `*device` a device ordinal given a PCI bus ID string.
///
/// where `domain`, `bus`, `device`, and `function` are all hexadecimal values.
///
/// # Parameters
///
/// - `device`: Returned device ordinal.
/// - `pciBusId`: String in one of the following forms.
pub fn cudaDeviceGetByPCIBusId(
device: *mut ::core::ffi::c_int,
pciBusId: *const ::core::ffi::c_char,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// where `domain`, `bus`, `device`, and `function` are all hexadecimal values. pciBusId should be large enough to store 13 characters including the NULL-terminator.
///
/// # Parameters
///
/// - `pciBusId`: Returned identifier string for the device in the following format.
/// - `len`: Maximum length of string to store in `name`.
/// - `device`: Device to get identifier string for.
pub fn cudaDeviceGetPCIBusId(
pciBusId: *mut ::core::ffi::c_char,
len: ::core::ffi::c_int,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Gets an interprocess handle for a previously allocated event.
///
/// Takes as input a previously allocated event. This event must have been created with the [cudaEventInterprocess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga49ec9cd742f8a3f6fde4ee72a66326f6) and [cudaEventDisableTiming](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaa5d3eff7c3623e2be533968d9cc1ee7e) flags set. This opaque handle may be copied into other processes and opened with [`cudaIpcOpenEventHandle`] to allow efficient hardware synchronization between GPU work in different processes.
///
/// After the event has been been opened in the importing process, [`cudaEventRecord`], [`cudaEventSynchronize`], [`cudaStreamWaitEvent`] and [`cudaEventQuery`] may be used in either process. Performing operations on the imported event after the exported event has been freed with [`cudaEventDestroy`] 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 [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda0ab012a7c597ffbe86090ee2f9e1758c).
///
/// # Parameters
///
/// - `handle`: Pointer to a user allocated cudaIpcEventHandle in which to return the opaque event handle.
/// - `event`: Event allocated with [cudaEventInterprocess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga49ec9cd742f8a3f6fde4ee72a66326f6) and [cudaEventDisableTiming](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaa5d3eff7c3623e2be533968d9cc1ee7e) flags.
pub fn cudaIpcGetEventHandle(
handle: *mut cudaIpcEventHandle_t,
event: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Opens an interprocess event handle for use in the current process.
///
/// Opens an interprocess event handle exported from another process with [`cudaIpcGetEventHandle`]. This function returns a [cudaEvent_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaea2f543a9fc0e52fe4ae712920fd1247) that behaves like a locally created event with the [cudaEventDisableTiming](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaa5d3eff7c3623e2be533968d9cc1ee7e) flag specified. This event must be freed with [`cudaEventDestroy`].
///
/// Performing operations on the imported event after the exported event has been freed with [`cudaEventDestroy`] 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 [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda0ab012a7c597ffbe86090ee2f9e1758c).
///
/// # Parameters
///
/// - `event`: Returns the imported event.
/// - `handle`: Interprocess handle to open.
pub fn cudaIpcOpenEventHandle(
event: *mut cudaEvent_t,
handle: cudaIpcEventHandle_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaMalloc`] 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 [`cudaFree`] and a subsequent call to [`cudaMalloc`] returns memory with the same device address, [`cudaIpcGetMemHandle`] 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 [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda0ab012a7c597ffbe86090ee2f9e1758c).
///
/// # Parameters
///
/// - `handle`: Pointer to user allocated ::cudaIpcMemHandle to return the handle in.
/// - `devPtr`: Base pointer to previously allocated device memory.
pub fn cudaIpcGetMemHandle(
handle: *mut cudaIpcMemHandle_t,
devPtr: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaIpcGetMemHandle`] into the current device address space. For contexts on different devices [`cudaIpcOpenMemHandle`] can attempt to enable peer access between the devices as if the user called [`cudaDeviceEnablePeerAccess`]. This behavior is controlled by the [cudaIpcMemLazyEnablePeerAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga60f28a5142ee7ae0336dfa83fd54e006) flag. [`cudaDeviceCanAccessPeer`] can determine if a mapping is possible.
///
/// [`cudaIpcOpenMemHandle`] can open handles to devices that may not be visible in the process calling the API.
///
/// Contexts that may open ::cudaIpcMemHandles are restricted in the following way. ::cudaIpcMemHandles from each device in a given process may only be opened by one context per device 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 [`cudaIpcOpenMemHandle`] must be freed with [`cudaIpcCloseMemHandle`].
///
/// Calling [`cudaFree`] on an exported memory region before calling [`cudaIpcCloseMemHandle`] 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 [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda0ab012a7c597ffbe86090ee2f9e1758c).
///
/// # Parameters
///
/// - `devPtr`: Returned device pointer.
/// - `handle`: cudaIpcMemHandle to open.
/// - `flags`: Flags for this operation. Must be specified as [cudaIpcMemLazyEnablePeerAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga60f28a5142ee7ae0336dfa83fd54e006).
pub fn cudaIpcOpenMemHandle(
devPtr: *mut *mut ::core::ffi::c_void,
handle: cudaIpcMemHandle_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Attempts to close memory mapped with cudaIpcOpenMemHandle.
///
/// Decrements the reference count of the memory returnd by [`cudaIpcOpenMemHandle`] 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 [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda0ab012a7c597ffbe86090ee2f9e1758c).
///
/// # Parameters
///
/// - `devPtr`: - Device pointer returned by ::cudaIpcOpenMemHandle
pub fn cudaIpcCloseMemHandle(devPtr: *mut ::core::ffi::c_void) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Blocks until remote writes are visible to the specified scope.
///
/// Blocks until remote writes to the target context via mappings created through GPUDirect RDMA 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 [cudaDevAttrGPUDirectRDMAWritesOrdering](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda881d5b0c5bf7777e382920af4d743bde), 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.
///
/// Users may query support for this API via [cudaDevAttrGPUDirectRDMAFlushWritesOptions](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda7b3462e13705248606f39fb5381446ee).
///
/// # Parameters
///
/// - `target`: The target of the operation, see cudaFlushGPUDirectRDMAWritesTarget.
/// - `scope`: The scope of the operation, see cudaFlushGPUDirectRDMAWritesScope.
pub fn cudaDeviceFlushGPUDirectRDMAWrites(
target: cudaFlushGPUDirectRDMAWritesTarget,
scope: cudaFlushGPUDirectRDMAWritesScope,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 cudaDeviceRegisterAsyncNotification or cudaDeviceUnregisterAsyncNotification. Doing so will result in [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a67b6095ab719b21659a400b553963eb3). Async notification callbacks execute in an undefined order and may be serialized.
///
/// Returns in `*callback` a handle representing the registered callback instance.
///
/// # 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 cudaDeviceRegisterAsyncNotification(
device: ::core::ffi::c_int,
callbackFunc: cudaAsyncCallback,
userData: *mut ::core::ffi::c_void,
callback: *mut cudaAsyncCallbackHandle_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Unregisters an async notification callback.
///
/// Unregisters `callback` so that the corresponding callback function will stop receiving async notifications.
///
/// # Parameters
///
/// - `device`: The device from which to remove `callback`.
/// - `callback`: The callback instance to unregister from receiving async notifications.
pub fn cudaDeviceUnregisterAsyncNotification(
device: ::core::ffi::c_int,
callback: cudaAsyncCallbackHandle_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the shared memory configuration for the current device.
///
/// This function will return in `pConfig` the current size of shared memory banks on the current device. On devices with configurable shared memory banks, [`cudaDeviceSetSharedMemConfig`] can be used to change this setting, so that all subsequent kernel launches will by default use the new bank size. When [`cudaDeviceGetSharedMemConfig`] is called on devices without configurable shared memory, it will return the fixed bank size of the hardware.
///
/// The returned bank configurations can be either.
///
/// # Parameters
///
/// - `pConfig`: - Returned cache configuration
#[deprecated]
pub fn cudaDeviceGetSharedMemConfig(
pConfig: *mut cudaSharedMemConfig,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the shared memory configuration for the current device.
///
/// On devices with configurable shared memory banks, this function will set the shared memory bank size which is used for all subsequent kernel launches. Any per-function setting of shared memory set via [`cudaFuncSetSharedMemConfig`] will override the device wide setting.
///
/// Changing the shared memory configuration between launches may introduce a device side synchronization point.
///
/// 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.
///
/// # Parameters
///
/// - `config`: - Requested cache configuration
#[deprecated]
pub fn cudaDeviceSetSharedMemConfig(config: cudaSharedMemConfig) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the last error from a runtime call.
///
/// Returns the last error that has been produced by any of the runtime calls in the same instance of the CUDA Runtime library in the host thread and resets it to [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591).
///
/// Note: Multiple instances of the CUDA Runtime library can be present in an application when using a library that statically links the CUDA Runtime.
pub fn cudaGetLastError() -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the last error from a runtime call.
///
/// Returns the last error that has been produced by any of the runtime calls in the same instance of the CUDA Runtime library in the host thread. This call does not reset the error to [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) like [`cudaGetLastError`].
///
/// Note: Multiple instances of the CUDA Runtime library can be present in an application when using a library that statically links the CUDA Runtime.
pub fn cudaPeekAtLastError() -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the string representation of an error code enum name.
///
/// Returns a string containing the name of an error code in the enum. If the error code is not recognized, “unrecognized error code” is returned.
///
/// # Parameters
///
/// - `error`: - Error code to convert to string
pub fn cudaGetErrorName(error: cudaError_t) -> *const ::core::ffi::c_char;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the description string for an error code.
///
/// Returns the description string for an error code. If the error code is not recognized, “unrecognized error code” is returned.
///
/// # Parameters
///
/// - `error`: - Error code to convert to string
pub fn cudaGetErrorString(error: cudaError_t) -> *const ::core::ffi::c_char;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the number of compute-capable devices.
///
/// Returns in `*count` the number of devices with compute capability greater or equal to 2.0 that are available for execution.
///
/// # Parameters
///
/// - `count`: - Returns the number of devices with compute capability greater or equal to 2.0
pub fn cudaGetDeviceCount(count: *mut ::core::ffi::c_int) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns information about the compute-device.
///
/// Returns in `*prop` the properties of device `dev`.
///
/// # Parameters
///
/// - `prop`: Properties for the specified device.
/// - `device`: Device number to get properties for.
pub fn cudaGetDeviceProperties(
prop: *mut cudaDeviceProp,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns information about the device.
///
/// Returns in `*value` the integer value of the attribute `attr` on device `device`.
///
/// # Parameters
///
/// - `value`: Returned device attribute value.
/// - `attr`: Device attribute to query.
/// - `device`: Device number to query.
pub fn cudaDeviceGetAttribute(
value: *mut ::core::ffi::c_int,
attr: cudaDeviceAttr,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaAtomicOperation`] in `*operations`, the corresponding result in `*capabilities` will be a bitmask indicating which of [cudaAtomicOperationCapability](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3ded8497f09d41455ea64acb7a880868) the link supports natively.
///
/// Returns [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a938c6e8b96ecde62e3ab5137156f739a) if `dev` is not valid.
///
/// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if `*capabilities` or `*operations` is NULL, if `count` is 0, or if any of `*operations` is not valid.
///
/// # Parameters
///
/// - `capabilities`: Returned capability details of each requested operation.
/// - `operations`: Requested operations.
/// - `count`: Count of requested operations and size of capabilities.
pub fn cudaDeviceGetHostAtomicCapabilities(
capabilities: *mut ::core::ffi::c_uint,
operations: *const cudaAtomicOperation,
count: ::core::ffi::c_uint,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the default mempool of a device.
///
/// The default mempool of a device contains device memory from that device.
pub fn cudaDeviceGetDefaultMemPool(
memPool: *mut cudaMemPool_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the current memory pool of a device.
///
/// The memory pool must be local to the specified device. Unless a mempool is specified in the [`cudaMallocAsync`] call, [`cudaMallocAsync`] allocates from the current mempool of the provided stream’s device. By default, a device’s current memory pool is its default memory pool.
pub fn cudaDeviceSetMemPool(
device: ::core::ffi::c_int,
memPool: cudaMemPool_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Gets the current mempool for a device.
///
/// Returns the last pool provided to [`cudaDeviceSetMemPool`] for this device or the device’s default memory pool if [`cudaDeviceSetMemPool`] 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 or [`cudaDeviceSetMemPool`].
pub fn cudaDeviceGetMemPool(
memPool: *mut cudaMemPool_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 that matches this device’s capabilities.
///
/// If NvSciSyncAttrKey_RequiredPerm field in `nvSciSyncAttrList` is already set this API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c).
///
/// The applications should set `nvSciSyncAttrList` to a valid NvSciSyncAttrList failing which this API will return ::cudaErrorInvalidHandle.
///
/// The `flags` controls how applications intends to use the NvSciSync created from the `nvSciSyncAttrList`. The valid flags are:
///
/// At least one of these flags must be set, failing which the API returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c). 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
///
/// [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591), [cudaErrorDeviceUninitialized](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a9e95927732f0d5a68151c72296581504), [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c), ::cudaErrorInvalidHandle, [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a938c6e8b96ecde62e3ab5137156f739a), [cudaErrorNotSupported](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad846fd9f2e8ba5e2fb4f1695b7ab6164), [cudaErrorMemoryAllocation](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af210f50ae7f17f655e0504929606add9).
///
/// # Parameters
///
/// - `nvSciSyncAttrList`: Return NvSciSync attributes supported.
/// - `device`: Valid CUDA Device to get NvSciSync attributes for.
/// - `flags`: flags describing NvSciSync usage.
pub fn cudaDeviceGetNvSciSyncAttributes(
nvSciSyncAttrList: *mut ::core::ffi::c_void,
device: ::core::ffi::c_int,
flags: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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:
///
/// Returns [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a938c6e8b96ecde62e3ab5137156f739a) if `srcDevice` or `dstDevice` are not valid or if they represent the same device.
///
/// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if `attrib` is not valid or if `value` is a null pointer.
///
/// # Parameters
///
/// - `value`: Returned value of the requested attribute.
/// - `srcDevice`: The source device of the target link.
/// - `dstDevice`: The destination device of the target link.
pub fn cudaDeviceGetP2PAttribute(
value: *mut ::core::ffi::c_int,
attr: cudaDeviceP2PAttr,
srcDevice: ::core::ffi::c_int,
dstDevice: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaAtomicOperation`] in `*operations`, the corresponding result in `*capabilities` will be a bitmask indicating which of [cudaAtomicOperationCapability](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3ded8497f09d41455ea64acb7a880868) the link supports natively.
///
/// Returns [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a938c6e8b96ecde62e3ab5137156f739a) if `srcDevice` or `dstDevice` are not valid or if they represent the same device.
///
/// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if `*capabilities` or `*operations` is NULL, if `count` is 0, or if any of `*operations` is not valid.
///
/// # 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 cudaDeviceGetP2PAtomicCapabilities(
capabilities: *mut ::core::ffi::c_uint,
operations: *const cudaAtomicOperation,
count: ::core::ffi::c_uint,
srcDevice: ::core::ffi::c_int,
dstDevice: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Select compute-device which best matches criteria.
///
/// Returns in `*device` the device which has properties that best match `*prop`.
///
/// # Parameters
///
/// - `device`: Device with best match.
/// - `prop`: Desired device properties.
pub fn cudaChooseDevice(
device: *mut ::core::ffi::c_int,
prop: *const cudaDeviceProp,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Initialize device to be used for GPU executions.
///
/// This function will initialize the CUDA Runtime structures and primary context on `device` when called, but the context will not be made current to `device`.
///
/// When [cudaInitDeviceFlagsAreValid](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga2ff861a477ec064dcf01977194158e49) is set in `flags`, deviceFlags are applied to the requested device. The values of deviceFlags match those of the flags parameters in [`cudaSetDeviceFlags`]. The effect may be verified by [`cudaGetDeviceFlags`].
///
/// This function will return an error if the device is in [`cudaComputeMode::cudaComputeModeExclusiveProcess`] and is occupied by another process or if the device is in [`cudaComputeMode::cudaComputeModeProhibited`].
///
/// # Parameters
///
/// - `device`: Device on which the runtime will initialize itself.
/// - `deviceFlags`: Parameters for device operation.
/// - `flags`: Flags for controlling the device initialization.
pub fn cudaInitDevice(
device: ::core::ffi::c_int,
deviceFlags: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Set device to be used for GPU executions.
///
/// Sets `device` as the current device for the calling host thread. Valid device id’s are 0 to ([`cudaGetDeviceCount`] - 1).
///
/// Any device memory subsequently allocated from this host thread using [`cudaMalloc`], [`cudaMallocPitch`] or [`cudaMallocArray`] will be physically resident on `device`. Any host memory allocated from this host thread using [`cudaMallocHost`] or [`cudaHostAlloc`] or [`cudaHostRegister`] will have its lifetime associated with `device`. Any streams or events created from this host thread will be associated with `device`. Any kernels launched from this host thread using the <<<>>> operator or [`cudaLaunchKernel`] will be executed on `device`.
///
/// This call may be made from any host thread, to any device, and at any time. This function will do no synchronization with the previous or new device, and should only take significant time when it initializes the runtime’s context state. This call will bind the primary context of the specified device to the calling thread and all the subsequent memory allocations, stream and event creations, and kernel launches will be associated with the primary context. This function will also immediately initialize the runtime state on the primary context, and the context will be current on `device` immediately. This function will return an error if the device is in [`cudaComputeMode::cudaComputeModeExclusiveProcess`] and is occupied by another process or if the device is in [`cudaComputeMode::cudaComputeModeProhibited`].
///
/// It is not required to call [`cudaInitDevice`] before using this function.
///
/// # Parameters
///
/// - `device`: - Device on which the active host thread should execute the device code.
pub fn cudaSetDevice(device: ::core::ffi::c_int) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns which device is currently being used.
///
/// Returns in `*device` the current device for the calling host thread.
///
/// # Parameters
///
/// - `device`: - Returns the device on which the active host thread executes the device code.
pub fn cudaGetDevice(device: *mut ::core::ffi::c_int) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Set a list of devices that can be used for CUDA.
///
/// Sets a list of devices for CUDA execution in priority order using `device_arr`. The parameter `len` specifies the number of elements in the list. CUDA will try devices from the list sequentially until it finds one that works. If this function is not called, or if it is called with a `len` of 0, then CUDA will go back to its default behavior of trying devices sequentially from a default list containing all of the available CUDA devices in the system. If a specified device ID in the list does not exist, this function will return [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a938c6e8b96ecde62e3ab5137156f739a). If `len` is not 0 and `device_arr` is NULL or if `len` exceeds the number of devices in the system, then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// # Parameters
///
/// - `device_arr`: List of devices to try.
/// - `len`: Number of devices in specified list.
pub fn cudaSetValidDevices(
device_arr: *mut ::core::ffi::c_int,
len: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets flags to be used for device executions.
///
/// Records `flags` as the flags for the current device. If the current device has been set and that device has already been initialized, the previous flags are overwritten. If the current device has not been initialized, it is initialized with the provided flags. If no device has been made current to the calling thread, a default device is selected and initialized with the provided flags.
///
/// The three LSBs of the `flags` parameter can be used to control how the CPU thread interacts with the OS scheduler when waiting for results from the device.
///
/// # Parameters
///
/// - `flags`: - Parameters for device operation
pub fn cudaSetDeviceFlags(flags: ::core::ffi::c_uint) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Gets the flags for the current device.
///
/// Returns in `flags` the flags for the current device. If there is a current device for the calling thread, the flags for the device are returned. If there is no current device, the flags for the first device are returned, which may be the default flags. Compare to the behavior of [`cudaSetDeviceFlags`].
///
/// Typically, the flags returned should match the behavior that will be seen if the calling thread uses a device after this call, without any change to the flags or current device inbetween by this or another thread. Note that if the device is not initialized, it is possible for another thread to change the flags for the current device before it is initialized. Additionally, when using exclusive mode, if this thread has not requested a specific device, it may use a device other than the first device, contrary to the assumption made by this function.
///
/// If a context has been created via the driver API and is current to the calling thread, the flags for that context are always returned.
///
/// Flags returned by this function may specifically include [cudaDeviceMapHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3762be9cccdd809a4ca128354fd134b0) even though it is not accepted by [`cudaSetDeviceFlags`] because it is implicit in runtime API flags. The reason for this is that the current context may have been created via the driver API in which case the flag is not implicit and may be unset.
///
/// # Parameters
///
/// - `flags`: - Pointer to store the device flags
pub fn cudaGetDeviceFlags(flags: *mut ::core::ffi::c_uint) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Create an asynchronous stream.
///
/// Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it.
///
/// # Parameters
///
/// - `pStream`: - Pointer to new stream identifier
pub fn cudaStreamCreate(pStream: *mut cudaStream_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Create an asynchronous stream.
///
/// Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. The `flags` argument determines the behaviors of the stream. Valid values for `flags` are.
///
/// # Parameters
///
/// - `pStream`: Pointer to new stream identifier.
/// - `flags`: Parameters for stream creation.
pub fn cudaStreamCreateWithFlags(
pStream: *mut cudaStream_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Create an asynchronous stream with the specified priority.
///
/// Creates a stream with the specified priority and returns a handle in `pStream`. The stream is created on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. 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 [`cudaDeviceGetStreamPriorityRange`]. If the specified priority is outside the numerical range returned by [`cudaDeviceGetStreamPriorityRange`], it will automatically be clamped to the lowest or the highest number in the range.
///
/// # Parameters
///
/// - `pStream`: Pointer to new stream identifier.
/// - `flags`: Flags for stream creation. See [`cudaStreamCreateWithFlags`] for a list of valid flags that can be passed.
/// - `priority`: Priority of the stream. Lower numbers represent higher priorities. See [`cudaDeviceGetStreamPriorityRange`] for more information about the meaningful stream priorities that can be passed.
pub fn cudaStreamCreateWithPriority(
pStream: *mut cudaStream_t,
flags: ::core::ffi::c_uint,
priority: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Query the priority of a stream.
///
/// Query the priority of a stream. The priority is returned in in `priority`. Note that if the stream was created with a priority outside the meaningful numerical range returned by [`cudaDeviceGetStreamPriorityRange`], this function returns the clamped priority. See [`cudaStreamCreateWithPriority`] for details about priority clamping.
///
/// # 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 cudaStreamGetPriority(
hStream: cudaStream_t,
priority: *mut ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Query the flags of a stream.
///
/// Query the flags of a stream. The flags are returned in `flags`. See [`cudaStreamCreateWithFlags`] for a list of valid flags.
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `flags`: Pointer to an unsigned integer in which the stream’s flags are returned.
pub fn cudaStreamGetFlags(
hStream: cudaStream_t,
flags: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Query the Id of a stream.
///
/// Query the Id of a stream. The Id is returned in `streamId`. The Id is unique for the life of the program.
///
/// The stream handle `hStream` can refer to any of the following.
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `streamId`: Pointer to an unsigned long long in which the stream Id is returned.
pub fn cudaStreamGetId(
hStream: cudaStream_t,
streamId: *mut ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Query the device of a stream.
///
/// Returns in `*device` the device of the stream.
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `device`: Returns the device to which the stream belongs.
pub fn cudaStreamGetDevice(
hStream: cudaStream_t,
device: *mut ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Resets all persisting lines in cache to normal status.
///
/// Resets all persisting lines in cache to normal status. Takes effect on function return.
pub fn cudaCtxResetPersistingL2Cache() -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `dst`: Destination stream.
/// - `src`: Source stream For attributes see cudaStreamAttrID.
pub fn cudaStreamCopyAttributes(dst: cudaStream_t, src: cudaStream_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Queries stream attribute.
///
/// Queries attribute `attr` from `hStream` and stores it in corresponding member of `value_out`.
pub fn cudaStreamGetAttribute(
hStream: cudaStream_t,
attr: cudaLaunchAttributeID,
value_out: *mut cudaLaunchAttributeValue,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
pub fn cudaStreamSetAttribute(
hStream: cudaStream_t,
attr: cudaLaunchAttributeID,
value: *const cudaLaunchAttributeValue,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Destroys and cleans up an asynchronous stream.
///
/// Destroys and cleans up the asynchronous stream specified by `stream`.
///
/// In case the device is still doing work in the stream `stream` when [`cudaStreamDestroy`] is called, the function will return immediately and the resources associated with `stream` will be released automatically once the device has completed all work in `stream`.
///
/// # Parameters
///
/// - `stream`: - Stream identifier
pub fn cudaStreamDestroy(stream: cudaStream_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Make a compute stream wait on an event.
///
/// Makes all future work submitted to `stream` wait for all work captured in `event`. See [`cudaEventRecord`] for details on what is captured by an event. The synchronization will be performed efficiently on the device when applicable. `event` may be from a different device than `stream`.
///
/// flags include.
///
/// # Parameters
///
/// - `stream`: Stream to wait.
/// - `event`: Event to wait on.
/// - `flags`: Parameters for the operation(See above).
pub fn cudaStreamWaitEvent(
stream: cudaStream_t,
event: cudaEvent_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
/// Type of stream callback functions.
///
/// The stream as passed to ::cudaStreamAddCallback, may be NULL.
///
/// ::cudaSuccess or any persistent error on the stream.
///
/// User parameter provided at registration.
pub type cudaStreamCallback_t = ::core::option::Option<
unsafe extern "C" fn(
stream: cudaStream_t,
status: cudaError_t,
userData: *mut ::core::ffi::c_void,
),
>;
singe_loader::functions! { crate::RUNTIME;
/// Add a callback to a compute stream.
///
/// Adds a callback to be called on the host after all currently enqueued items in the stream have completed. For each cudaStreamAddCallback call, a callback will be executed exactly once. The callback will block later work in the stream until it is finished.
///
/// The callback may be passed [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) or an error code. In the event of a device error, all subsequently executed callbacks will receive an appropriate [cudaError_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaf599e5b8b829ce7db0f5216928f6ecb6).
///
/// Callbacks must not make any CUDA API calls. Attempting to use CUDA APIs may result in [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a67b6095ab719b21659a400b553963eb3). 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.
///
/// # Parameters
///
/// - `stream`: 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 cudaStreamAddCallback(
stream: cudaStream_t,
callback: cudaStreamCallback_t,
userData: *mut ::core::ffi::c_void,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Waits for stream tasks to complete.
///
/// Blocks until `stream` has completed all operations. If the [cudaDeviceScheduleBlockingSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga057e6912c52708b6aa86e79dd83d007c) flag was set for this device, the host thread will block until the stream is finished with all of its tasks.
///
/// # Parameters
///
/// - `stream`: - Stream identifier
pub fn cudaStreamSynchronize(stream: cudaStream_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Queries an asynchronous stream for completion status.
///
/// Returns [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) if all operations in `stream` have completed, or [cudaErrorNotReady](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a285d0c852ab65b8925505e1065563f6d) if not.
///
/// For the purposes of Unified Memory, a return value of [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) is equivalent to having called [`cudaStreamSynchronize`].
///
/// # Parameters
///
/// - `stream`: - Stream identifier
pub fn cudaStreamQuery(stream: cudaStream_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Attach memory to a stream asynchronously.
///
/// Enqueues an operation in `stream` to specify stream association of `length` bytes of memory starting from `devPtr`. 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.
///
/// `devPtr` must point to an one of the following types of memories:
///
/// 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 allocations, `length` must be non-zero.
///
/// The stream association is specified using `flags` which must be one of [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff), [cudaMemAttachHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4f9a428d18fdd89a99441d0dd27131c0) or [cudaMemAttachSingle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gadc191442d08fc3a9de4cf055edfd2dbe). The default value for `flags` is [cudaMemAttachSingle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gadc191442d08fc3a9de4cf055edfd2dbe) If the [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff) flag is specified, the memory can be accessed by any stream on any device. If the [cudaMemAttachHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4f9a428d18fdd89a99441d0dd27131c0) 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09). If the [cudaMemAttachSingle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gadc191442d08fc3a9de4cf055edfd2dbe) flag is specified and `stream` is associated with a device that has a zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09), the program makes a guarantee that it will only access the memory on the device from `stream`. 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 `stream` 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 [`cudaStreamAttachMemAsync`] 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 `stream` 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 [`cudaMallocManaged`]. For **managed** variables, the default association is always [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff). 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.
///
/// # Parameters
///
/// - `stream`: Stream in which to enqueue the attach operation.
/// - `devPtr`: Pointer to memory (must be a pointer to managed memory or to a valid host-accessible region of system-allocated memory).
/// - `length`: Length of memory (defaults to zero).
/// - `flags`: Must be one of [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff), [cudaMemAttachHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4f9a428d18fdd89a99441d0dd27131c0) or [cudaMemAttachSingle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gadc191442d08fc3a9de4cf055edfd2dbe) (defaults to [cudaMemAttachSingle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gadc191442d08fc3a9de4cf055edfd2dbe)).
pub fn cudaStreamAttachMemAsync(
stream: cudaStream_t,
devPtr: *mut ::core::ffi::c_void,
length: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Begins graph capture on a stream.
///
/// Begin graph capture on `stream`. 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 [`cudaStreamEndCapture`]. Capture may not be initiated if `stream` is [cudaStreamLegacy](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4e62d09dde16ba457b0a97f3a5262246). 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 [`cudaStreamIsCapturing`]. A unique id representing the capture sequence may be queried via [`cudaStreamGetCaptureInfo`].
///
/// If `mode` is not cudaStreamCaptureModeRelaxed, [`cudaStreamEndCapture`] must be called on this stream from the same thread.
///
/// # Parameters
///
/// - `stream`: 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 [`cudaThreadExchangeStreamCaptureMode`].
pub fn cudaStreamBeginCapture(
stream: cudaStream_t,
mode: cudaStreamCaptureMode,
) -> cudaError_t;
}
/// Callback function invoked when node parameter mismatches are detected while recapturing to an existing graph. Parameter struct pointers are only valid within the callback.
///
/// User parameter provided at beginning of recapture
///
/// Graph node with the parameter mismatch
///
/// The original node parameters from the graph
///
/// The node parameters received during the recapture
///
/// status Status code for the recapture of the node
///
///
///
/// # Return value
///
/// Error code for the callback. Anything other than cudaSuccess will cause the recapture to fail immediately.
pub type cudaGraphRecaptureCallback_t = ::core::option::Option<
unsafe extern "C" fn(
data: *mut ::core::ffi::c_void,
node: cudaGraphNode_t,
originalParams: *const cudaGraphNodeParams,
recaptureParams: *const cudaGraphNodeParams,
status: cudaGraphRecaptureStatus,
) -> cudaError_t,
>;
/// Struct of user callback data that is invoked when node parameter mismatches are detected while recapturing to an existing graph.
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct cudaGraphRecaptureCallbackData {
/// Callback function that will be invoked.
pub callbackFunc: cudaGraphRecaptureCallback_t,
/// Generic pointer that is passed to the callback function.
pub userData: *mut ::core::ffi::c_void,
}
impl Default for cudaGraphRecaptureCallbackData {
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()
}
}
}
singe_loader::functions! { crate::RUNTIME;
/// Begin graph capture on a stream to an existing graph.
///
/// Begin graph capture on `stream` to the existing `graph`. The node creation order while recapturing the graph must be identical to the original graph. The recapture will fail immediately for:
///
/// Any other node parameter mismatches during recapture can be configured to call the function provided in `callbackFunc`. The recapture will fail immediately if the callback returns anything other than cudaSuccess.
///
/// If the recapture fails for any reason, the `graph` will be in an undefined state and should be destroyed.
///
/// See cudaStreamBeginCapture for additional detail on beginning the capture.
///
/// # Parameters
///
/// - `stream`: 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 [`cudaThreadExchangeStreamCaptureMode`].
/// - `graph`: Existing CUDA graph to be captured into.
/// - `callbackData`: Optional struct of callback data that will be invoked for all parameter mismatches from the original graph.
pub fn cudaStreamBeginRecaptureToGraph(
stream: cudaStream_t,
mode: cudaStreamCaptureMode,
graph: cudaGraph_t,
callbackData: *mut cudaGraphRecaptureCallbackData,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Begins graph capture on a stream to an existing graph.
///
/// Begin graph capture on `stream`. When a stream is in capture mode, all operations pushed into the stream will not be executed, but will instead be captured into `graph`, which will be returned via [`cudaStreamEndCapture`].
///
/// Capture may not be initiated if `stream` is [cudaStreamLegacy](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4e62d09dde16ba457b0a97f3a5262246). 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 [`cudaStreamIsCapturing`]. A unique id representing the capture sequence may be queried via [`cudaStreamGetCaptureInfo`].
///
/// If `mode` is not cudaStreamCaptureModeRelaxed, [`cudaStreamEndCapture`] must be called on this stream from the same thread.
///
/// # Parameters
///
/// - `stream`: Stream in which to initiate capture.
/// - `graph`: 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 [`cudaThreadExchangeStreamCaptureMode`].
pub fn cudaStreamBeginCaptureToGraph(
stream: cudaStream_t,
graph: cudaGraph_t,
dependencies: *const cudaGraphNode_t,
dependencyData: *const cudaGraphEdgeData,
numDependencies: size_t,
mode: cudaStreamCaptureMode,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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:
///
/// During stream capture (see [`cudaStreamBeginCapture`]), some actions, such as a call to [`cudaMalloc`], may be unsafe. In the case of [`cudaMalloc`], the operation is not enqueued asynchronously to a stream, and is not observed by stream capture. Therefore, if the sequence of operations captured via [`cudaStreamBeginCapture`] 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 [`cudaStreamBeginCapture`]-[`cudaStreamEndCapture`] sequence. This behavior can be controlled via this API and flags to [`cudaStreamBeginCapture`].
///
/// A thread’s mode is one of the following.
///
/// # Parameters
///
/// - `mode`: - Pointer to mode value to swap with the current mode
pub fn cudaThreadExchangeStreamCaptureMode(
mode: *mut cudaStreamCaptureMode,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Ends capture on a stream, returning the captured graph.
///
/// End capture on `stream`, returning the captured graph via `pGraph`. Capture must have been initiated on `stream` via a call to [`cudaStreamBeginCapture`]. 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 [`cudaStreamBeginCapture`] was not cudaStreamCaptureModeRelaxed, this call must be from the same thread as [`cudaStreamBeginCapture`].
///
/// # Parameters
///
/// - `stream`: Stream to query.
/// - `pGraph`: The captured graph.
pub fn cudaStreamEndCapture(
stream: cudaStream_t,
pGraph: *mut cudaGraph_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a stream’s capture status.
///
/// Return the capture status of `stream` via `pCaptureStatus`. After a successful call, `*pCaptureStatus` will contain one of the following:
///
/// Note that, if this is called on [cudaStreamLegacy](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4e62d09dde16ba457b0a97f3a5262246) (the “null stream”) while a blocking stream on the same device is capturing, it will return [cudaErrorStreamCaptureImplicit](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038acf775033deb76dbde57b8df7bd9244e7) and `*pCaptureStatus` 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).
///
/// # Parameters
///
/// - `stream`: Stream to query.
/// - `pCaptureStatus`: Returns the stream’s capture status.
pub fn cudaStreamIsCapturing(
stream: cudaStream_t,
pCaptureStatus: *mut cudaStreamCaptureStatus,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Query a stream’s capture state.
///
/// Query stream state related to stream capture.
///
/// If called on [cudaStreamLegacy](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4e62d09dde16ba457b0a97f3a5262246) (the “null stream”) while a stream not created with [`cudaStreamNonBlocking`] is capturing, returns [cudaErrorStreamCaptureImplicit](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038acf775033deb76dbde57b8df7bd9244e7).
///
/// Valid data (other than capture status) is returned only if both of the following are true:
///
/// 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 [cudaErrorLossyQuery](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad484d9d8e8f269cf93d4c111b646f908).
///
/// # Parameters
///
/// - `stream`: 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 [`cudaStreamEndCapture`]. 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 [`cudaStreamEndCapture`] due to direct actions on the graph do not trigger [cudaErrorStreamCaptureUnjoined](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ace9e4b4b58c1abf9faa1ce8b1079076d).
/// - `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 cudaStreamGetCaptureInfo(
stream: cudaStream_t,
captureStatus_out: *mut cudaStreamCaptureStatus,
id_out: *mut ::core::ffi::c_ulonglong,
graph_out: *mut cudaGraph_t,
dependencies_out: *mut *const cudaGraphNode_t,
edgeData_out: *mut *const cudaGraphEdgeData,
numDependencies_out: *mut size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// Valid flags are [`cudaStreamUpdateCaptureDependenciesFlags::cudaStreamAddCaptureDependencies`] and [`cudaStreamUpdateCaptureDependenciesFlags::cudaStreamSetCaptureDependencies`]. 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 [`cudaStreamUpdateCaptureDependenciesFlags::cudaStreamAddCaptureDependencies`].
///
/// Nodes that are removed from the dependency set via this API do not result in [cudaErrorStreamCaptureUnjoined](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ace9e4b4b58c1abf9faa1ce8b1079076d) if they are unreachable from the stream at [`cudaStreamEndCapture`].
///
/// Returns [cudaErrorIllegalState](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a0604022302a2ed15d31bc33546b2e963) if the stream is not capturing.
///
/// # Parameters
///
/// - `stream`: 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 cudaStreamUpdateCaptureDependencies(
stream: cudaStream_t,
dependencies: *mut cudaGraphNode_t,
dependencyData: *const cudaGraphEdgeData,
numDependencies: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates an event object
///
/// Creates an event object for the current device using ::cudaEventDefault.
///
///
///
///
///
/// # Return value
///
/// ::cudaSuccess, ::cudaErrorInvalidValue, ::cudaErrorLaunchFailure, ::cudaErrorMemoryAllocation
///
/// Note: _init_rt
///
/// Note: _callback
///
///
///
/// See also: `::cudaEventCreate(cudaEvent_t*`, unsigned int) "cudaEventCreate (C++ API)", ::cudaEventCreateWithFlags, ::cudaEventRecord, ::cudaEventQuery, ::cudaEventSynchronize, ::cudaEventDestroy, ::cudaEventElapsedTime, ::cudaStreamWaitEvent, ::cuEventCreate
///
/// # Parameters
///
/// - `event`: - Newly created event
pub fn cudaEventCreate(event: *mut cudaEvent_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates an event object with the specified flags.
///
/// Creates an event object for the current device with the specified flags. Valid flags include.
///
/// # Parameters
///
/// - `event`: Newly created event.
/// - `flags`: Flags for new event.
pub fn cudaEventCreateWithFlags(
event: *mut cudaEvent_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Records an event.
///
/// Captures in `event` the contents of `stream` at the time of this call. `event` and `stream` must be on the same CUDA context. Calls such as [`cudaEventQuery`] or [`cudaStreamWaitEvent`] will then examine or wait for completion of the work that was captured. Uses of `stream` after this call do not modify `event`. See note on default stream behavior for what is captured in the default case.
///
/// [`cudaEventRecord`] can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as [`cudaStreamWaitEvent`] use the most recently captured state at the time of the API call, and are not affected by later calls to [`cudaEventRecord`]. Before the first call to [`cudaEventRecord`], an event represents an empty set of work, so for example [`cudaEventQuery`] would return [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591).
///
/// # Parameters
///
/// - `event`: Event to record.
/// - `stream`: Stream in which to record event.
pub fn cudaEventRecord(event: cudaEvent_t, stream: cudaStream_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Records an event.
///
/// Captures in `event` the contents of `stream` at the time of this call. `event` and `stream` must be on the same CUDA context. Calls such as [`cudaEventQuery`] or [`cudaStreamWaitEvent`] will then examine or wait for completion of the work that was captured. Uses of `stream` after this call do not modify `event`. See note on default stream behavior for what is captured in the default case.
///
/// [`cudaEventRecordWithFlags`] can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as [`cudaStreamWaitEvent`] use the most recently captured state at the time of the API call, and are not affected by later calls to [`cudaEventRecordWithFlags`]. Before the first call to [`cudaEventRecordWithFlags`], an event represents an empty set of work, so for example [`cudaEventQuery`] would return [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591).
///
/// flags include.
///
/// # Parameters
///
/// - `event`: Event to record.
/// - `stream`: Stream in which to record event.
/// - `flags`: Parameters for the operation(See above).
pub fn cudaEventRecordWithFlags(
event: cudaEvent_t,
stream: cudaStream_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Queries an event’s status.
///
/// Queries the status of all work currently captured by `event`. See [`cudaEventRecord`] for details on what is captured by an event.
///
/// Returns [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) if all captured work has been completed, or [cudaErrorNotReady](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a285d0c852ab65b8925505e1065563f6d) if any captured work is incomplete.
///
/// For the purposes of Unified Memory, a return value of [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) is equivalent to having called [`cudaEventSynchronize`].
///
/// # Parameters
///
/// - `event`: - Event to query
pub fn cudaEventQuery(event: cudaEvent_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Waits for an event to complete.
///
/// Waits until the completion of all work currently captured in `event`. See [`cudaEventRecord`] for details on what is captured by an event.
///
/// Waiting for an event that was created with the [cudaEventBlockingSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga26509a522be9d449aa7c8c279612452d) flag will cause the calling CPU thread to block until the event has been completed by the device. If the [cudaEventBlockingSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga26509a522be9d449aa7c8c279612452d) flag has not been set, then the CPU thread will busy-wait until the event has been completed by the device.
///
/// # Parameters
///
/// - `event`: - Event to wait for
pub fn cudaEventSynchronize(event: cudaEvent_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Destroys an event object.
///
/// Destroys the event specified by `event`.
///
/// An event may be destroyed before it is complete (i.e., while [`cudaEventQuery`] would return [cudaErrorNotReady](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a285d0c852ab65b8925505e1065563f6d)). In this case, the call does not block on completion of the event, and any associated resources will automatically be released asynchronously at completion.
///
/// # Parameters
///
/// - `event`: - Event to destroy
pub fn cudaEventDestroy(event: cudaEvent_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Computes the elapsed time between 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 a elapsed time calculation only and polling for completion on the events to be compared should be done with [`cudaEventQuery`] 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 [`cudaEventRecord`] 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 [`cudaEventRecord`] has not been called on either event, then [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ac4673247aee4d1ab8d07871f376e0273) is returned. If [`cudaEventRecord`] has been called on both events but one or both of them has not yet been completed (that is, [`cudaEventQuery`] would return [cudaErrorNotReady](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a285d0c852ab65b8925505e1065563f6d) on at least one of the events), [cudaErrorNotReady](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a285d0c852ab65b8925505e1065563f6d) is returned. If either event was created with the [cudaEventDisableTiming](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaa5d3eff7c3623e2be533968d9cc1ee7e) flag, then this function will return [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ac4673247aee4d1ab8d07871f376e0273).
///
/// # Parameters
///
/// - `ms`: Time between `start` and `end` in ms.
/// - `start`: Starting event.
/// - `end`: Ending event.
pub fn cudaEventElapsedTime(
ms: *mut f32,
start: cudaEvent_t,
end: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaExternalMemoryHandleDesc`] structure is defined as follows:
///
/// where [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) specifies the type of handle being imported. [`cudaExternalMemoryHandleType`] is defined as:
///
/// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeOpaqueFd`], then ::cudaExternalMemoryHandleDesc::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 [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeOpaqueWin32`], then exactly one of ::cudaExternalMemoryHandleDesc::handle::win32::handle and ::cudaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalMemoryHandleDesc::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 ::cudaExternalMemoryHandleDesc::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 [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeOpaqueWin32Kmt`], then ::cudaExternalMemoryHandleDesc::handle::win32::handle must be non-NULL and ::cudaExternalMemoryHandleDesc::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 [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D12Heap`], then exactly one of ::cudaExternalMemoryHandleDesc::handle::win32::handle and ::cudaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalMemoryHandleDesc::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 ::cudaExternalMemoryHandleDesc::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 [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D12Resource`], then exactly one of ::cudaExternalMemoryHandleDesc::handle::win32::handle and ::cudaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalMemoryHandleDesc::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 ::cudaExternalMemoryHandleDesc::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 [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11Resource`]
///
/// ,then exactly one of ::cudaExternalMemoryHandleDesc::handle::win32::handle and ::cudaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalMemoryHandleDesc::handle::win32::handle is
///
/// not NULL, then it must represent a valid shared NT handle that is
///
/// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11ResourceKmt`], then ::cudaExternalMemoryHandleDesc::handle::win32::handle must be non-NULL and ::cudaExternalMemoryHandleDesc::handle::win32::name must be NULL. The handle specified must be a valid shared KMT handle that is returned by IDXGIResource::GetSharedHandle when referring to a ID3D11Resource object.
///
/// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeNvSciBuf`], then ::cudaExternalMemoryHandleDesc::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 [`cudaWaitExternalSemaphoresAsync`] or [`cudaSignalExternalSemaphoresAsync`] as approprriate barriers to maintain coherence between CUDA and the other drivers. See [cudaExternalSemaphoreWaitSkipNvSciBufMemSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3643166ea40207f6a13f82ebd7b6c2c7) and [cudaExternalSemaphoreSignalSkipNvSciBufMemSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga39b71a7aa040658a7a280fcf31eb4a77) for memory synchronization.
///
/// The size of the memory object must be specified in [cudaExternalMemoryHandleDesc::size](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a362086a22da90ac8fba1ca294e65548e).
///
/// Specifying the flag [cudaExternalMemoryDedicated](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaea2031488a28bcdb7695e9bbaf25e149) in [cudaExternalMemoryHandleDesc::flags](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a74412d3d2777ebc856aea0b9158aaafa) 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 [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryHandleDesc.html#structcudaexternalmemoryhandledesc_1a8d2b65d3b597280eb9be66ee34c7ee52) is one of the following: [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D12Resource`] [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11Resource`] [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11ResourceKmt`].
///
/// # Parameters
///
/// - `extMem_out`: Returned handle to an external memory object.
/// - `memHandleDesc`: Memory import handle descriptor.
pub fn cudaImportExternalMemory(
extMem_out: *mut cudaExternalMemory_t,
memHandleDesc: *const cudaExternalMemoryHandleDesc,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaExternalMemoryBufferDesc`] structure is defined as follows:
///
/// where [cudaExternalMemoryBufferDesc::offset](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryBufferDesc.html#structcudaexternalmemorybufferdesc_1a034839893ecb4e103f82498888157ba6) is the offset in the memory object where the buffer’s base address is. [cudaExternalMemoryBufferDesc::size](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryBufferDesc.html#structcudaexternalmemorybufferdesc_1a56bdddff67c72329350ed4fa4f2cd746) is the size of the buffer. [cudaExternalMemoryBufferDesc::flags](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryBufferDesc.html#structcudaexternalmemorybufferdesc_1a0a7888cacfea49ab9b30ae7e9ab47d32) 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 [`cudaFree`].
///
/// # Parameters
///
/// - `devPtr`: Returned device pointer to buffer.
/// - `extMem`: Handle to external memory object.
/// - `bufferDesc`: Buffer descriptor.
pub fn cudaExternalMemoryGetMappedBuffer(
devPtr: *mut *mut ::core::ffi::c_void,
extMem: cudaExternalMemory_t,
bufferDesc: *const cudaExternalMemoryBufferDesc,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaExternalMemoryMipmappedArrayDesc`] is defined as follows:
///
/// where [cudaExternalMemoryMipmappedArrayDesc::offset](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaexternalmemorymipmappedarraydesc_1a2f9441c3c6e3100f1517ccaf668ffd83) is the offset in the memory object where the base level of the mipmap chain is. [cudaExternalMemoryMipmappedArrayDesc::formatDesc](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaexternalmemorymipmappedarraydesc_1a42333e3049cc4a40213b086be45927e1) describes the format of the data. [cudaExternalMemoryMipmappedArrayDesc::extent](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaexternalmemorymipmappedarraydesc_1acba41d5152a8458ac72a24e65ee0f3ac) specifies the dimensions of the base level of the mipmap chain. [cudaExternalMemoryMipmappedArrayDesc::flags](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaexternalmemorymipmappedarraydesc_1ade6d5579b7f13034ea82e06012c8758f) are flags associated with CUDA mipmapped arrays. For further details, please refer to the documentation for [`cudaMalloc3DArray`]. Note that if the mipmapped array is bound as a color target in the graphics API, then the flag [cudaArrayColorAttachment](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gafec2b519ab85854efaa40e12f4e34ad3) must be specified in [cudaExternalMemoryMipmappedArrayDesc::flags](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaexternalmemorymipmappedarraydesc_1ade6d5579b7f13034ea82e06012c8758f). [cudaExternalMemoryMipmappedArrayDesc::numLevels](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaexternalmemorymipmappedarraydesc_1a4a939b3d6c1fca916dd78679049f36eb) specifies the total number of levels in the mipmap chain.
///
/// The returned CUDA mipmapped array must be freed using [`cudaFreeMipmappedArray`].
///
/// # Parameters
///
/// - `mipmap`: Returned CUDA mipmapped array.
/// - `extMem`: Handle to external memory object.
/// - `mipmapDesc`: CUDA array descriptor.
pub fn cudaExternalMemoryGetMappedMipmappedArray(
mipmap: *mut cudaMipmappedArray_t,
extMem: cudaExternalMemory_t,
mipmapDesc: *const cudaExternalMemoryMipmappedArrayDesc,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaFree`] and [`cudaFreeMipmappedArray`] respectively.
///
/// # Parameters
///
/// - `extMem`: - External memory object to be destroyed
pub fn cudaDestroyExternalMemory(extMem: cudaExternalMemory_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaExternalSemaphoreHandleDesc`] is defined as follows:
///
/// where [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) specifies the type of handle being imported. [`cudaExternalSemaphoreHandleType`] is defined as:
///
/// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueFd`], then ::cudaExternalSemaphoreHandleDesc::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 [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32`], then exactly one of ::cudaExternalSemaphoreHandleDesc::handle::win32::handle and ::cudaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalSemaphoreHandleDesc::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 ::cudaExternalSemaphoreHandleDesc::handle::win32::name is not NULL, then it must name a valid synchronization object.
///
/// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt`], then ::cudaExternalSemaphoreHandleDesc::handle::win32::handle must be non-NULL and ::cudaExternalSemaphoreHandleDesc::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 [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D12Fence`], then exactly one of ::cudaExternalSemaphoreHandleDesc::handle::win32::handle and ::cudaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalSemaphoreHandleDesc::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 ::cudaExternalSemaphoreHandleDesc::handle::win32::name is not NULL, then it must name a valid synchronization object that refers to a valid ID3D12Fence object.
///
/// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D11Fence`], then exactly one of ::cudaExternalSemaphoreHandleDesc::handle::win32::handle and ::cudaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D11Fence::CreateSharedHandle. If ::cudaExternalSemaphoreHandleDesc::handle::win32::name is not NULL, then it must name a valid synchronization object that refers to a valid ID3D11Fence object.
///
/// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`], then ::cudaExternalSemaphoreHandleDesc::handle::nvSciSyncObj represents a valid NvSciSyncObj.
///
/// [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutex`], then exactly one of ::cudaExternalSemaphoreHandleDesc::handle::win32::handle and ::cudaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it represent a valid shared NT handle that is returned by IDXGIResource1::CreateSharedHandle when referring to a IDXGIKeyedMutex object.
///
/// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutexKmt`], then ::cudaExternalSemaphoreHandleDesc::handle::win32::handle must be non-NULL and ::cudaExternalSemaphoreHandleDesc::handle::win32::name must be NULL. The handle specified must represent a valid KMT handle that is returned by IDXGIResource::GetSharedHandle when referring to a IDXGIKeyedMutex object.
///
/// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd`], then ::cudaExternalSemaphoreHandleDesc::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 [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaExternalSemaphoreHandleDesc.html#structcudaexternalsemaphorehandledesc_1ae925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32`], then exactly one of ::cudaExternalSemaphoreHandleDesc::handle::win32::handle and ::cudaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalSemaphoreHandleDesc::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 ::cudaExternalSemaphoreHandleDesc::handle::win32::name is not NULL, then it must name a valid synchronization object.
///
/// # Parameters
///
/// - `extSem_out`: Returned handle to an external semaphore.
/// - `semHandleDesc`: Semaphore import handle descriptor.
pub fn cudaImportExternalSemaphore(
extSem_out: *mut cudaExternalSemaphore_t,
semHandleDesc: *const cudaExternalSemaphoreHandleDesc,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueFd`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt`] then signaling the semaphore will set it to the signaled state.
///
/// If the semaphore object is any one of the following types: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D12Fence`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D11Fence`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32`] then the semaphore will be set to the value specified in ::cudaExternalSemaphoreSignalParams::params::fence::value.
///
/// If the semaphore object is of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`] this API sets ::cudaExternalSemaphoreSignalParams::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 ::cudaExternalSemaphoreSignalParams::params::nvSciSync::fence. By default, signaling such an external semaphore object causes appropriate memory synchronization operations to be performed over all the external memory objects that are imported as [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeNvSciBuf`]. 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 [cudaExternalSemaphoreSignalSkipNvSciBufMemSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga39b71a7aa040658a7a280fcf31eb4a77), 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 [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`], if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in [`cudaDeviceGetNvSciSyncAttributes`] to cudaNvSciSyncAttrSignal, this API will return cudaErrorNotSupported.
///
/// ::cudaExternalSemaphoreSignalParams::params::nvSciSync::fence associated with semaphore object of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`] 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. ::cudaExternalSemaphoreSignalParams::params::nvSciSync::fence associated with semaphore object of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`] 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: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutex`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutexKmt`], then the keyed mutex will be released with the key specified in ::cudaExternalSemaphoreSignalParams::params::keyedmutex::key.
///
/// # 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 cudaSignalExternalSemaphoresAsync(
extSemArray: *const cudaExternalSemaphore_t,
paramsArray: *const cudaExternalSemaphoreSignalParams,
numExtSems: ::core::ffi::c_uint,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueFd`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt`] 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: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D12Fence`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D11Fence`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32`] then waiting on the semaphore will wait until the value of the semaphore is greater than or equal to ::cudaExternalSemaphoreWaitParams::params::fence::value.
///
/// If the semaphore object is of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`] then, waiting on the semaphore will wait until the ::cudaExternalSemaphoreSignalParams::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 [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeNvSciBuf`]. 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 [cudaExternalSemaphoreWaitSkipNvSciBufMemSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3643166ea40207f6a13f82ebd7b6c2c7), 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 [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`], if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in [`cudaDeviceGetNvSciSyncAttributes`] to cudaNvSciSyncAttrWait, this API will return cudaErrorNotSupported.
///
/// If the semaphore object is any one of the following types: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutex`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutexKmt`], then the keyed mutex will be acquired when it is released with the key specified in ::cudaExternalSemaphoreSignalParams::params::keyedmutex::key or until the timeout specified by ::cudaExternalSemaphoreSignalParams::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.
///
/// # 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 cudaWaitExternalSemaphoresAsync(
extSemArray: *const cudaExternalSemaphore_t,
paramsArray: *const cudaExternalSemaphoreWaitParams,
numExtSems: ::core::ffi::c_uint,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `extSem`: - External semaphore to be destroyed
pub fn cudaDestroyExternalSemaphore(extSem: cudaExternalSemaphore_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Launches a device function.
///
/// The function invokes kernel `func` on `gridDim` (`gridDim.x ``gridDim.y ``gridDim.z`) grid of blocks. Each block contains `blockDim` (`blockDim.x ``blockDim.y ``blockDim.z`) threads.
///
/// If the kernel has N parameters the `args` should point to array of N pointers. Each pointer, from `args\[0\]` to `args\[N - 1\]`, point to the region of memory from which the actual parameter will be copied.
///
/// For templated functions, pass the function symbol as follows: func_name<template_arg_0,…,template_arg_N>
///
/// `sharedMem` sets the amount of dynamic shared memory that will be available to each thread block.
///
/// `stream` specifies a stream the invocation is associated to.
///
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `gridDim`: Grid dimentions.
/// - `blockDim`: Block dimentions.
/// - `args`: Arguments.
/// - `sharedMem`: Shared memory.
/// - `stream`: Stream identifier.
pub fn cudaLaunchKernel(
func: *const ::core::ffi::c_void,
gridDim: dim3,
blockDim: dim3,
args: *mut *mut ::core::ffi::c_void,
sharedMem: size_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Launches a CUDA function with launch-time configuration.
///
/// Note that the functionally equivalent variadic template [cudaLaunchKernelEx](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga7d9168c86a4293639c75ea437465ed53) is available for C++11 and newer.
///
/// Invokes the kernel `func` on `config->gridDim` (`config->gridDim.x ``config->gridDim.y ``config->gridDim.z`) grid of blocks. Each block contains `config->blockDim` (`config->blockDim.x ``config->blockDim.y ``config->blockDim.z`) threads.
///
/// `config->dynamicSmemBytes` sets the amount of dynamic shared memory that will be available to each thread block.
///
/// `config->stream` specifies a stream the invocation is associated to.
///
/// Configuration beyond grid and block dimensions, dynamic shared memory size, and stream can be provided with the following two fields of `config:`
///
/// `config->attrs` is an array of `config->numAttrs` contiguous [cudaLaunchAttribute](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaLaunchAttribute.html#structcudalaunchattribute) elements. The value of this pointer is not considered if `config->numAttrs` is zero. However, in that case, it is recommended to set the pointer to NULL. `config->numAttrs` is the number of attributes populating the first `config->numAttrs` positions of the `config->attrs` array.
///
/// If the kernel has N parameters the `args` should point to array of N pointers. Each pointer, from `args\[0\]` to `args\[N - 1\]`, point to the region of memory from which the actual parameter will be copied.
///
/// N.B. This function is so named to avoid unintentionally invoking the templated version, `cudaLaunchKernelEx`, for kernels taking a single void\*\* or void\* parameter.
///
/// # Parameters
///
/// - `config`: Launch configuration.
/// - `func`: Kernel to launch.
/// - `args`: Array of pointers to kernel parameters.
pub fn cudaLaunchKernelExC(
config: *const cudaLaunchConfig_t,
func: *const ::core::ffi::c_void,
args: *mut *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Launches a device function where thread blocks can cooperate and synchronize as they execute.
///
/// The function invokes kernel `func` on `gridDim` (`gridDim.x ``gridDim.y ``gridDim.z`) grid of blocks. Each block contains `blockDim` (`blockDim.x ``blockDim.y ``blockDim.z`) threads.
///
/// The device on which this kernel is invoked must have a non-zero value for the device attribute [cudaDevAttrCooperativeLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda108260813c2eb395a60d4acf08c97595).
///
/// The total number of blocks launched cannot exceed the maximum number of blocks per multiprocessor as returned by [`cudaOccupancyMaxActiveBlocksPerMultiprocessor`] (or [`cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags`]) times the number of multiprocessors as specified by the device attribute [cudaDevAttrMultiProcessorCount](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda74de9ed281f917c8e4ef272da09f338a).
///
/// The kernel cannot make use of CUDA dynamic parallelism.
///
/// If the kernel has N parameters the `args` should point to array of N pointers. Each pointer, from `args\[0\]` to `args\[N - 1\]`, point to the region of memory from which the actual parameter will be copied.
///
/// For templated functions, pass the function symbol as follows: func_name<template_arg_0,…,template_arg_N>
///
/// `sharedMem` sets the amount of dynamic shared memory that will be available to each thread block.
///
/// `stream` specifies a stream the invocation is associated to.
///
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `gridDim`: Grid dimentions.
/// - `blockDim`: Block dimentions.
/// - `args`: Arguments.
/// - `sharedMem`: Shared memory.
/// - `stream`: Stream identifier.
pub fn cudaLaunchCooperativeKernel(
func: *const ::core::ffi::c_void,
gridDim: dim3,
blockDim: dim3,
args: *mut *mut ::core::ffi::c_void,
sharedMem: size_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 `cacheConfig` the preferred cache configuration for the function specified via `func`. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute `func`.
///
/// `func` is a device function symbol and must be declared as a `__global__` function. If the specified function does not exist, then [cudaErrorInvalidDeviceFunction](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e) is returned. For templated functions, pass the function symbol as follows: func_name<template_arg_0,…,template_arg_N>
///
/// 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.
///
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `cacheConfig`: Requested cache configuration.
pub fn cudaFuncSetCacheConfig(
func: *const ::core::ffi::c_void,
cacheConfig: cudaFuncCache,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Find out attributes for a given function.
///
/// This function obtains the attributes of a function specified via `func`. `func` is a device function symbol and must be declared as a `__global__` function. The fetched attributes are placed in `attr`. If the specified function does not exist, then it is assumed to be a [cudaKernel_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga0b33f204b307b3154aa4f005a3c8a46a) and used as is. For templated functions, pass the function symbol as follows: func_name<template_arg_0,…,template_arg_N>
///
/// Note that some function attributes such as [maxThreadsPerBlock](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaFuncAttributes.html#structcudafuncattributes_1ab8350f491105f159ff684f5c59167af0) may vary based on the device that is currently being used.
///
/// # Parameters
///
/// - `attr`: Return pointer to function’s attributes.
/// - `func`: Device function symbol.
pub fn cudaFuncGetAttributes(
attr: *mut cudaFuncAttributes,
func: *const ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Set attributes for a given function.
///
/// This function sets the attributes of a function specified via `func`. The parameter `func` must be a pointer to a function that executes on the device. The parameter specified by `func` must be declared as a `__global__` function. The enumeration defined by `attr` is set to the value defined by `value`. If the specified function does not exist, then it is assumed to be a [cudaKernel_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga0b33f204b307b3154aa4f005a3c8a46a) and used as is. If the specified attribute cannot be written, or if the value is incorrect, then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// Valid values for `attr` are:
///
/// cudaLaunchKernel (C++ API), [cudaFuncSetCacheConfig (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga981c8d74d33b21e7fd57609b7337653e), [cudaFuncGetAttributes (C API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__EXECUTION.html#group__cudart__execution_1gace91ab5ae929d84d16860e4d1a189754),.
///
/// # Parameters
///
/// - `func`: Function to get attributes of.
/// - `attr`: Attribute to set.
/// - `value`: Value to set.
pub fn cudaFuncSetAttribute(
func: *const ::core::ffi::c_void,
attr: cudaFuncAttribute,
value: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the function name for a device entry function pointer.
///
/// Returns in `**name` the function name associated with the symbol `func`. The function name is returned as a null-terminated string. This API may return a mangled name if the function is not declared as having C linkage. If `**name` is NULL, [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned. If `func` is not a device entry function, then it is assumed to be a [cudaKernel_t](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga0b33f204b307b3154aa4f005a3c8a46a) and used as is.
///
/// cudaFuncGetName (C++ API).
///
/// # Parameters
///
/// - `name`: The returned name of the function.
/// - `func`: The function pointer to retrieve name for.
pub fn cudaFuncGetName(
name: *mut *const ::core::ffi::c_char,
func: *const ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the offset and size of a kernel parameter in the device-side parameter layout.
///
/// Queries the kernel parameter at `paramIndex` in `func's` list of parameters and returns parameter information via `paramOffset` and `paramSize`. `paramOffset` returns the offset of the parameter in the device-side parameter layout. `paramSize` returns the size in bytes of the parameter. This information can be used to update kernel node parameters from the device via [cudaGraphKernelNodeSetParam()](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__GRAPH.html#group__cudart__graph_1ga9171bc40a4f9be650b3fe867e8bfb549) and [cudaGraphKernelNodeUpdatesApply()](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__GRAPH.html#group__cudart__graph_1ga2d558cf37c9616365c67447e61ac0d6a). `paramIndex` must be less than the number of parameters that `func` takes.
///
/// # Parameters
///
/// - `func`: The function to query.
/// - `paramIndex`: The parameter index to query.
/// - `paramOffset`: The offset into the device-side parameter layout at which the parameter resides.
/// - `paramSize`: The size of the parameter in the device-side parameter layout.
pub fn cudaFuncGetParamInfo(
func: *const ::core::ffi::c_void,
paramIndex: size_t,
paramOffset: *mut size_t,
paramSize: *mut size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the number of parameters used by the function.
///
/// Queries the number of kernel parameters used by `func` and returns it in `paramCount`.
///
/// # Parameters
///
/// - `func`: The function to query.
/// - `paramCount`: Returns the number of parameters used by the function.
pub fn cudaFuncGetParamCount(
func: *const ::core::ffi::c_void,
paramCount: *mut size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a67b6095ab719b21659a400b553963eb3), 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:
///
/// Note that, in constrast to ::cuStreamAddCallback, the function will not be called in the event of an error in the CUDA context.
///
/// # Parameters
///
/// - `stream`: Stream to enqueue function call in.
/// - `fn_`: The function to call once preceding stream operations are complete.
/// - `userData`: User-specified data to be passed to the function.
pub fn cudaLaunchHostFunc(
stream: cudaStream_t,
fn_: cudaHostFn_t,
userData: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a67b6095ab719b21659a400b553963eb3), 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:
///
/// Note that, in constrast to ::cuStreamAddCallback, the function will not be called in the event of an error in the CUDA context.
///
/// # Parameters
///
/// - `stream`: Stream to enqueue function call in.
/// - `fn_`: The function to call once preceding stream operations are complete.
/// - `userData`: User-specified data to be passed to the function.
/// - `syncMode`: Sync mode for the host function.
pub fn cudaLaunchHostFunc_v2(
stream: cudaStream_t,
fn_: cudaHostFn_t,
userData: *mut ::core::ffi::c_void,
syncMode: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the shared memory configuration for a device function.
///
/// On devices with configurable shared memory banks, this function will force all subsequent launches of the specified device function to have the given shared memory bank size configuration. On any given launch of the function, the shared memory configuration of the device will be temporarily changed if needed to suit the function’s preferred configuration. Changes in shared memory configuration between subsequent launches of functions, may introduce a device side synchronization point.
///
/// Any per-function setting of shared memory bank size set via [`cudaFuncSetSharedMemConfig`] will override the device wide setting set by [`cudaDeviceSetSharedMemConfig`].
///
/// 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.
///
/// For templated functions, pass the function symbol as follows: func_name<template_arg_0,…,template_arg_N>
///
/// The supported bank configurations are.
///
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `config`: Requested shared memory configuration.
#[deprecated]
pub fn cudaFuncSetSharedMemConfig(
func: *const ::core::ffi::c_void,
config: cudaSharedMemConfig,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns occupancy for a device function.
///
/// Returns in `*numBlocks` the maximum number of active blocks per streaming multiprocessor for the device function.
///
/// # Parameters
///
/// - `numBlocks`: Returned occupancy.
/// - `func`: Kernel function 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 cudaOccupancyMaxActiveBlocksPerMultiprocessor(
numBlocks: *mut ::core::ffi::c_int,
func: *const ::core::ffi::c_void,
blockSize: ::core::ffi::c_int,
dynamicSMemSize: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 block.
pub fn cudaOccupancyAvailableDynamicSMemPerBlock(
dynamicSmemSize: *mut size_t,
func: *const ::core::ffi::c_void,
numBlocks: ::core::ffi::c_int,
blockSize: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns occupancy for a device function with the specified flags.
///
/// Returns in `*numBlocks` the maximum number of active blocks per streaming multiprocessor for the device function.
///
/// The `flags` parameter controls how special cases are handled. Valid flags include.
///
/// # Parameters
///
/// - `numBlocks`: Returned occupancy.
/// - `func`: Kernel function 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 cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
numBlocks: *mut ::core::ffi::c_int,
func: *const ::core::ffi::c_void,
blockSize: ::core::ffi::c_int,
dynamicSMemSize: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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`]),`*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.
///
/// # 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.
pub fn cudaOccupancyMaxPotentialClusterSize(
clusterSize: *mut ::core::ffi::c_int,
func: *const ::core::ffi::c_void,
launchConfig: *const cudaLaunchConfig_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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`]), 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.
///
/// # 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.
pub fn cudaOccupancyMaxActiveClusters(
numClusters: *mut ::core::ffi::c_int,
func: *const ::core::ffi::c_void,
launchConfig: *const cudaLaunchConfig_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocates memory that will be automatically managed by the Unified Memory system.
///
/// Allocates `size` bytes of managed memory on the device and returns in `*devPtr` a pointer to the allocated memory. If the device doesn’t support allocating managed memory, [cudaErrorNotSupported](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad846fd9f2e8ba5e2fb4f1695b7ab6164) is returned. Support for managed memory can be queried using the device attribute [cudaDevAttrManagedMemory](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda5467985f87821a03625ab62e72195ff8). The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. If `size` is 0, [`cudaMallocManaged`] returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c). 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 [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff) or [cudaMemAttachHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4f9a428d18fdd89a99441d0dd27131c0). The default value for `flags` is [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff). If [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff) is specified, then this memory is accessible from any stream on any device. If [cudaMemAttachHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4f9a428d18fdd89a99441d0dd27131c0) is specified, then the allocation should not be accessed from devices that have a zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09); an explicit call to [`cudaStreamAttachMemAsync`] will be required to enable access on such devices.
///
/// If the association is later changed via [`cudaStreamAttachMemAsync`] to a single stream, the default association, as specifed during [`cudaMallocManaged`], is restored when that stream is destroyed. For **managed** variables, the default association is always [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff). 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 [`cudaMallocManaged`] should be released with [`cudaFree`].
///
/// Device memory oversubscription is possible for GPUs that have a non-zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09). 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09), 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 [`cudaMemAdvise`]. The application can also explicitly migrate memory to a desired processor’s memory via [`cudaMemPrefetchAsync`].
///
/// In a multi-GPU system where all of the GPUs have a zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09) 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 [`cudaMallocManaged`] 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09) is zero for at least one of those GPUs, the location chosen for physical storage of managed memory is system-dependent.
///
/// # Parameters
///
/// - `devPtr`: Pointer to allocated device memory.
/// - `size`: Requested allocation size in bytes.
/// - `flags`: Must be either [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff) or [cudaMemAttachHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4f9a428d18fdd89a99441d0dd27131c0) (defaults to [cudaMemAttachGlobal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4808e47eba73eb94622ec70a9f9b91ff)).
pub fn cudaMallocManaged(
devPtr: *mut *mut ::core::ffi::c_void,
size: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocate memory on the device.
///
/// Allocates `size` bytes of linear memory on the device and returns in `*devPtr` a pointer to the allocated memory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. [`cudaMalloc`] returns [cudaErrorMemoryAllocation](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af210f50ae7f17f655e0504929606add9) in case of failure.
///
/// The device version of [`cudaFree`] cannot be used with a `*devPtr` allocated using the host API, and vice versa.
///
/// # Parameters
///
/// - `devPtr`: Pointer to allocated device memory.
/// - `size`: Requested allocation size in bytes.
pub fn cudaMalloc(
devPtr: *mut *mut ::core::ffi::c_void,
size: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocates page-locked memory on the host
///
/// Allocates `size` 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 ::cudaMemcpy*(). 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 ::pageableMemoryAccessUsesHostPageTables is true, ::cudaMallocHost may not page-lock the allocated memory.
///
/// Page-locking excessive amounts of memory with ::cudaMallocHost() 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.
///
///
///
///
///
/// # Return value
///
/// ::cudaSuccess, ::cudaErrorInvalidValue, ::cudaErrorMemoryAllocation, ::cudaErrorExternalDevice
///
/// Note: _init_rt
///
/// Note: _callback
///
///
///
/// See also: ::cudaMalloc, ::cudaMallocPitch, ::cudaMallocArray, ::cudaMalloc3D, ::cudaMalloc3DArray, ::cudaHostAlloc, ::cudaFree, ::cudaFreeArray, `::cudaMallocHost(void**`, size_t, unsigned int) "cudaMallocHost (C++ API)", ::cudaFreeHost, ::cudaHostAlloc, ::cuMemAllocHost
///
/// # Parameters
///
/// - `ptr`: - Pointer to allocated host memory
/// - `size`: - Requested allocation size in bytes
pub fn cudaMallocHost(
ptr: *mut *mut ::core::ffi::c_void,
size: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocates pitched memory on the device.
///
/// Allocates at least `width` (in bytes) \* `height` bytes of linear memory on the device and returns in `*devPtr` 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. The pitch returned in `*pitch` by [`cudaMallocPitch`] 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:
///
/// For allocations of 2D arrays, it is recommended that programmers consider performing pitch allocations using [`cudaMallocPitch`]. Due to pitch 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).
///
/// # Parameters
///
/// - `devPtr`: Pointer to allocated pitched device memory.
/// - `pitch`: Pitch for allocation.
/// - `width`: Requested pitched allocation width (in bytes).
/// - `height`: Requested pitched allocation height.
pub fn cudaMallocPitch(
devPtr: *mut *mut ::core::ffi::c_void,
pitch: *mut size_t,
width: size_t,
height: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocate an array on the device.
///
/// Allocates a CUDA array according to the [`cudaChannelFormatDesc`] structure `desc` and returns a handle to the new CUDA array in `*array`.
///
/// The [`cudaChannelFormatDesc`] is defined as:
///
/// The `flags` parameter enables different options to be specified that affect the allocation, as follows.
///
/// `width` and `height` must meet certain size requirements. See [`cudaMalloc3DArray`] for more details.
///
/// # Parameters
///
/// - `array`: Pointer to allocated array in device memory.
/// - `desc`: Requested channel format.
/// - `width`: Requested array allocation width.
/// - `height`: Requested array allocation height.
/// - `flags`: Requested properties of allocated array.
pub fn cudaMallocArray(
array: *mut cudaArray_t,
desc: *const cudaChannelFormatDesc,
width: size_t,
height: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Frees memory on the device.
///
/// Frees the memory space pointed to by `devPtr`, which must have been returned by a previous call to one of the following memory allocation APIs - [`cudaMalloc`], [`cudaMallocPitch`], [`cudaMallocManaged`], [`cudaMallocAsync`], [`cudaMallocFromPoolAsync`].
///
/// Note - This API will not perform any implicit synchronization when the pointer was allocated with [`cudaMallocAsync`] or [`cudaMallocFromPoolAsync`]. Callers must ensure that all accesses to these pointer have completed before invoking [`cudaFree`]. For best performance and memory reuse, users should use [`cudaFreeAsync`] to free memory allocated via the stream ordered memory allocator. For all other pointers, this API may perform implicit synchronization.
///
/// If [`cudaFree`](`devPtr`) has already been called before, an error is returned. If `devPtr` is 0, no operation is performed. [`cudaFree`] returns ::cudaErrorValue in case of failure.
///
/// The device version of [`cudaFree`] cannot be used with a `*devPtr` allocated using the host API, and vice versa.
///
/// # Parameters
///
/// - `devPtr`: - Device pointer to memory to free
pub fn cudaFree(devPtr: *mut ::core::ffi::c_void) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Frees page-locked memory.
///
/// Frees the memory space pointed to by `hostPtr`, which must have been returned by a previous call to [`cudaMallocHost`] or [`cudaHostAlloc`].
///
/// # Parameters
///
/// - `ptr`: - Pointer to memory to free
pub fn cudaFreeHost(ptr: *mut ::core::ffi::c_void) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Frees an array on the device.
///
/// Frees the CUDA array `array`, which must have been returned by a previous call to [`cudaMallocArray`]. If `devPtr` is 0, no operation is performed.
///
/// # Parameters
///
/// - `array`: - Pointer to array to free
pub fn cudaFreeArray(array: cudaArray_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Frees a mipmapped array on the device.
///
/// Frees the CUDA mipmapped array `mipmappedArray`, which must have been returned by a previous call to [`cudaMallocMipmappedArray`]. If `devPtr` is 0, no operation is performed.
///
/// # Parameters
///
/// - `mipmappedArray`: - Pointer to mipmapped array to free
pub fn cudaFreeMipmappedArray(mipmappedArray: cudaMipmappedArray_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocates page-locked memory on the host.
///
/// Allocates `size` 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 [`cudaMemcpy`]. 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(). Allocating excessive amounts of pinned 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.
///
/// 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.
///
/// In order for the [`cudaHostAllocMapped`] flag to have any effect, the CUDA context must support the [cudaDeviceMapHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3762be9cccdd809a4ca128354fd134b0) flag, which can be checked via [`cudaGetDeviceFlags`]. The [cudaDeviceMapHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3762be9cccdd809a4ca128354fd134b0) flag is implicitly set for contexts created via the runtime API.
///
/// The [`cudaHostAllocMapped`] flag may be specified on CUDA contexts for devices that do not support mapped pinned memory. The failure is deferred to [`cudaHostGetDevicePointer`] because the memory may be mapped into other CUDA contexts via the [`cudaHostAllocPortable`] flag.
///
/// Memory allocated by this function must be freed with [`cudaFreeHost`].
///
/// # Parameters
///
/// - `pHost`: Device pointer to allocated memory.
/// - `size`: Requested allocation size in bytes.
/// - `flags`: Requested properties of allocated memory.
pub fn cudaHostAlloc(
pHost: *mut *mut ::core::ffi::c_void,
size: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Registers an existing host memory range for use by CUDA.
///
/// Page-locks the memory range specified by `ptr` and `size` and maps it for the device(s) as specified by `flags`. This memory range also is added to the same tracking mechanism as [`cudaHostAlloc`] to automatically accelerate calls to functions such as [`cudaMemcpy`]. 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 ::pageableMemoryAccessUsesHostPageTables is true, [`cudaHostRegister`] will not page-lock the memory range specified by `ptr` but only populate unpopulated pages.
///
/// [`cudaHostRegister`] is supported only on I/O coherent devices that have a non-zero value for the device attribute [cudaDevAttrHostRegisterSupported](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda6ea4a004a336c3c95b6ff06ec6269e29).
///
/// The `flags` parameter enables different options to be specified that affect the allocation, as follows.
///
/// All of these flags are orthogonal to one another: a developer may page-lock memory that is portable or mapped with no restrictions.
///
/// The CUDA context must have been created with the ::cudaMapHost flag in order for the [`cudaHostRegisterMapped`] flag to have any effect.
///
/// The [`cudaHostRegisterMapped`] flag may be specified on CUDA contexts for devices that do not support mapped pinned memory. The failure is deferred to [`cudaHostGetDevicePointer`] because the memory may be mapped into other CUDA contexts via the [`cudaHostRegisterPortable`] flag.
///
/// For devices that have a non-zero value for the device attribute [cudaDevAttrCanUseHostPointerForRegisteredMem](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdab08e379a7a038dc8134914702c223f69), the memory can also be accessed from the device using the host pointer `ptr`. The device pointer returned by [`cudaHostGetDevicePointer`] 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 [`cudaHostGetDevicePointer`] 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 [`cudaHostGetDevicePointer`] 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 [`cudaHostUnregister`].
///
/// # Parameters
///
/// - `ptr`: Host pointer to memory to page-lock.
/// - `size`: Size in bytes of the address range to page-lock in bytes.
/// - `flags`: Flags for allocation request.
pub fn cudaHostRegister(
ptr: *mut ::core::ffi::c_void,
size: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Unregisters a memory range that was registered with cudaHostRegister.
///
/// Unmaps the memory range whose base address is specified by `ptr`, and makes it pageable again.
///
/// The base address must be the same one specified to [`cudaHostRegister`].
///
/// # Parameters
///
/// - `ptr`: - Host pointer to memory to unregister
pub fn cudaHostUnregister(ptr: *mut ::core::ffi::c_void) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister.
///
/// Passes back the device pointer corresponding to the mapped, pinned host buffer allocated by [`cudaHostAlloc`] or registered by [`cudaHostRegister`].
///
/// [`cudaHostGetDevicePointer`] will fail if the [cudaDeviceMapHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3762be9cccdd809a4ca128354fd134b0) flag was not specified before deferred context creation occurred, or if called on a device that does not support mapped, pinned memory.
///
/// For devices that have a non-zero value for the device attribute [cudaDevAttrCanUseHostPointerForRegisteredMem](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdab08e379a7a038dc8134914702c223f69), the memory can also be accessed from the device using the host pointer `pHost`. The device pointer returned by [`cudaHostGetDevicePointer`] may or may not match the original host pointer `pHost` 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 [`cudaHostGetDevicePointer`] will match the original pointer `pHost`. If any device visible to the application has a zero value for the device attribute, the device pointer returned by [`cudaHostGetDevicePointer`] will not match the original host pointer `pHost`, 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.
///
/// `flags` provides for future releases. For now, it must be set to 0.
///
/// # Parameters
///
/// - `pDevice`: Returned device pointer for mapped memory.
/// - `pHost`: Requested host pointer mapping.
/// - `flags`: Flags for extensions (must be 0 for now).
pub fn cudaHostGetDevicePointer(
pDevice: *mut *mut ::core::ffi::c_void,
pHost: *mut ::core::ffi::c_void,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc.
///
/// [`cudaHostGetFlags`] will fail if the input pointer does not reside in an address range allocated by [`cudaHostAlloc`].
///
/// # Parameters
///
/// - `pFlags`: Returned flags word.
/// - `pHost`: Host pointer.
pub fn cudaHostGetFlags(
pFlags: *mut ::core::ffi::c_uint,
pHost: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocates logical 1D, 2D, or 3D memory objects on the device.
///
/// Allocates at least `width` \* `height` \* `depth` bytes of linear memory on the device and returns a [`cudaPitchedPtr`] in which `ptr` is a pointer to the allocated memory. The function may pad the allocation to ensure hardware alignment requirements are met. The pitch returned in the `pitch` field of `pitchedDevPtr` is the width in bytes of the allocation.
///
/// The returned [`cudaPitchedPtr`] contains additional fields `xsize` and `ysize`, the logical width and height of the allocation, which are equivalent to the `width` and `height` `extent` parameters provided by the programmer during allocation.
///
/// For allocations of 2D and 3D objects, it is highly recommended that programmers perform allocations using [`cudaMalloc3D`] or [`cudaMallocPitch`]. Due to alignment restrictions in the hardware, this is especially true if the application will be performing memory copies involving 2D or 3D objects (whether linear memory or CUDA arrays).
///
/// # Parameters
///
/// - `pitchedDevPtr`: Pointer to allocated pitched device memory.
/// - `extent`: Requested allocation size (`width` field in bytes).
pub fn cudaMalloc3D(
pitchedDevPtr: *mut cudaPitchedPtr,
extent: cudaExtent,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocate an array on the device.
///
/// Allocates a CUDA array according to the [`cudaChannelFormatDesc`] structure `desc` and returns a handle to the new CUDA array in `*array`.
///
/// The [`cudaChannelFormatDesc`] is defined as:
///
/// [`cudaMalloc3DArray`] can allocate the following:
///
/// The `flags` parameter enables different options to be specified that affect the allocation, as follows.
///
/// The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified in elements.
///
/// Note that 2D CUDA arrays have different size requirements if the [cudaArrayTextureGather](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga142b19a14d56a03b1e410430aa5202d1) flag is set. In that case, the valid range for (width, height, depth) is ((1,maxTexture2DGather\[0\]), (1,maxTexture2DGather\[1\]), 0).
///
/// # Parameters
///
/// - `array`: Pointer to allocated array in device memory.
/// - `desc`: Requested channel format.
/// - `extent`: Requested allocation size (`width` field in elements).
/// - `flags`: Flags for extensions.
pub fn cudaMalloc3DArray(
array: *mut cudaArray_t,
desc: *const cudaChannelFormatDesc,
extent: cudaExtent,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocate a mipmapped array on the device.
///
/// Allocates a CUDA mipmapped array according to the [`cudaChannelFormatDesc`] structure `desc` and returns a handle to the new CUDA mipmapped array in `*mipmappedArray`. `numLevels` 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 [`cudaChannelFormatDesc`] is defined as:
///
/// [`cudaMallocMipmappedArray`] can allocate the following:
///
/// The `flags` parameter enables different options to be specified that affect the allocation, as follows.
///
/// The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified in elements.
///
/// # Parameters
///
/// - `mipmappedArray`: Pointer to allocated mipmapped array in device memory.
/// - `desc`: Requested channel format.
/// - `extent`: Requested allocation size (`width` field in elements).
/// - `numLevels`: Number of mipmap levels to allocate.
/// - `flags`: Flags for extensions.
pub fn cudaMallocMipmappedArray(
mipmappedArray: *mut cudaMipmappedArray_t,
desc: *const cudaChannelFormatDesc,
extent: cudaExtent,
numLevels: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Gets a mipmap level of a CUDA mipmapped array.
///
/// Returns in `*levelArray` a CUDA array that represents a single mipmap level of the CUDA mipmapped array `mipmappedArray`.
///
/// If `level` is greater than the maximum number of levels in this mipmapped array, [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// If `mipmappedArray` is NULL, [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ac4673247aee4d1ab8d07871f376e0273) is returned.
///
/// # Parameters
///
/// - `levelArray`: Returned mipmap level CUDA array.
/// - `mipmappedArray`: CUDA mipmapped array.
/// - `level`: Mipmap level.
pub fn cudaGetMipmappedArrayLevel(
levelArray: *mut cudaArray_t,
mipmappedArray: cudaMipmappedArray_const_t,
level: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between 3D objects.
///
/// [`cudaMemcpy3D`] copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a CUDA array. The source, destination, extent, and kind of copy performed is specified by the [`cudaMemcpy3DParms`] struct which should be initialized to zero before use:
///
/// The struct passed to [`cudaMemcpy3D`] must specify one of `srcArray` or `srcPtr` and one of `dstArray` or `dstPtr`. Passing more than one non-zero source or destination will cause [`cudaMemcpy3D`] to return an error.
///
/// The `srcPos` and `dstPos` fields are optional offsets into the source and destination objects and are defined in units of each object’s elements. The element for a host or device pointer is assumed to be **unsigned char**.
///
/// The `extent` field defines the dimensions of the transferred area in elements. If a CUDA array is participating in the copy, the extent is defined in terms of that array’s elements. If no CUDA array is participating in the copy then the extents are defined in elements of **unsigned char**.
///
/// The `kind` field defines the direction of the copy. It must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. For [`cudaMemcpyKind::cudaMemcpyHostToHost`] or [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] passed as kind and cudaArray type passed as source or destination, if the kind implies cudaArray type to be present on the host, [`cudaMemcpy3D`] will disregard that implication and silently correct the kind based on the fact that cudaArray type can only be present on the device.
///
/// If the source and destination are both arrays, [`cudaMemcpy3D`] will return an error if they do not have the same element size.
///
/// The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined behavior will result.
///
/// The source object must entirely contain the region defined by `srcPos` and `extent`. The destination object must entirely contain the region defined by `dstPos` and `extent`.
///
/// [`cudaMemcpy3D`] returns an error if the pitch of `srcPtr` or `dstPtr` exceeds the maximum allowed. The pitch of a [`cudaPitchedPtr`] allocated with [`cudaMalloc3D`] will always be valid.
///
/// # Parameters
///
/// - `p`: - 3D memory copy parameters
pub fn cudaMemcpy3D(p: *const cudaMemcpy3DParms) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies memory between devices.
///
/// Perform a 3D memory copy according to the parameters specified in `p`. See the definition of the [`cudaMemcpy3DPeerParms`] structure for documentation of its parameters.
///
/// Note that this function is synchronous with respect to the host only if the source or destination of the transfer is host memory. Note also that this copy is serialized with respect to all pending and future asynchronous work in to the current device, the copy’s source device, and the copy’s destination device (use [`cudaMemcpy3DPeerAsync`] to avoid this synchronization).
///
/// # Parameters
///
/// - `p`: - Parameters for the memory copy
pub fn cudaMemcpy3DPeer(p: *const cudaMemcpy3DPeerParms) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between 3D objects.
///
/// [`cudaMemcpy3DAsync`] copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a CUDA array. The source, destination, extent, and kind of copy performed is specified by the [`cudaMemcpy3DParms`] struct which should be initialized to zero before use:
///
/// The struct passed to [`cudaMemcpy3DAsync`] must specify one of `srcArray` or `srcPtr` and one of `dstArray` or `dstPtr`. Passing more than one non-zero source or destination will cause [`cudaMemcpy3DAsync`] to return an error.
///
/// The `srcPos` and `dstPos` fields are optional offsets into the source and destination objects and are defined in units of each object’s elements. The element for a host or device pointer is assumed to be **unsigned char**. For CUDA arrays, positions must be in the range [0, 2048) for any dimension.
///
/// The `extent` field defines the dimensions of the transferred area in elements. If a CUDA array is participating in the copy, the extent is defined in terms of that array’s elements. If no CUDA array is participating in the copy then the extents are defined in elements of **unsigned char**.
///
/// The `kind` field defines the direction of the copy. It must be one of [cudaMemcpyHostToHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga18fa99055ee694244a270e4d5101e95badeec295de8a74ac2a74f98ffb6c5d7c7), [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. For [`cudaMemcpyKind::cudaMemcpyHostToHost`] or [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] passed as kind and cudaArray type passed as source or destination, if the kind implies cudaArray type to be present on the host, [`cudaMemcpy3DAsync`] will disregard that implication and silently correct the kind based on the fact that cudaArray type can only be present on the device.
///
/// If the source and destination are both arrays, [`cudaMemcpy3DAsync`] will return an error if they do not have the same element size.
///
/// The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined behavior will result.
///
/// The source object must lie entirely within the region defined by `srcPos` and `extent`. The destination object must lie entirely within the region defined by `dstPos` and `extent`.
///
/// [`cudaMemcpy3DAsync`] returns an error if the pitch of `srcPtr` or `dstPtr` exceeds the maximum allowed. The pitch of a [`cudaPitchedPtr`] allocated with [`cudaMalloc3D`] will always be valid.
///
/// [`cudaMemcpy3DAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero `stream` argument. If `kind` is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and `stream` is non-zero, the copy may overlap with operations in other streams.
///
/// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
///
/// # Parameters
///
/// - `p`: 3D memory copy parameters.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy3DAsync(
p: *const cudaMemcpy3DParms,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies memory between devices asynchronously.
///
/// Perform a 3D memory copy according to the parameters specified in `p`. See the definition of the [`cudaMemcpy3DPeerParms`] structure for documentation of its parameters.
///
/// # Parameters
///
/// - `p`: Parameters for the memory copy.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy3DPeerAsync(
p: *const cudaMemcpy3DPeerParms,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Gets free and total device 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.
///
/// # Parameters
///
/// - `free`: Returned free memory in bytes.
/// - `total`: Returned total memory in bytes.
pub fn cudaMemGetInfo(free: *mut size_t, total: *mut size_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Gets info about the specified cudaArray.
///
/// Returns in `*desc`, `*extent` and `*flags` respectively, the type, shape and flags of `array`.
///
/// Any of `*desc`, `*extent` and `*flags` may be specified as NULL.
///
/// # Parameters
///
/// - `desc`: Returned array type.
/// - `extent`: Returned array shape. 2D arrays will have depth of zero.
/// - `flags`: Returned array flags.
/// - `array`: The ::cudaArray to get info for.
pub fn cudaArrayGetInfo(
desc: *mut cudaChannelFormatDesc,
extent: *mut cudaExtent,
flags: *mut ::core::ffi::c_uint,
array: cudaArray_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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: [`cudaChannelFormatKind::cudaChannelFormatKindNV12`], then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// Note that if the `hArray` has format [`cudaChannelFormatKind::cudaChannelFormatKindNV12`], then passing in 0 for `planeIdx` returns a CUDA array of the same size as `hArray` but with one 8-bit channel and [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`] as its format kind. If 1 is passed for `planeIdx`, then the returned CUDA array has half the height and width of `hArray` with two 8-bit channels and [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`] as its format kind.
///
/// # Parameters
///
/// - `pPlaneArray`: Returned CUDA array referenced by the `planeIdx`.
/// - `hArray`: CUDA array.
/// - `planeIdx`: Plane index.
pub fn cudaArrayGetPlane(
pPlaneArray: *mut cudaArray_t,
hArray: cudaArray_t,
planeIdx: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaArrayDeferredMapping](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga91a50795515848406a89c2e6cef2fb02) [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// The returned value in [cudaArrayMemoryRequirements::size](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArrayMemoryRequirements.html#structcudaarraymemoryrequirements_1acff0bc12daa05c6c40892a2187befd87) represents the total size of the CUDA array. The returned value in [cudaArrayMemoryRequirements::alignment](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArrayMemoryRequirements.html#structcudaarraymemoryrequirements_1a37898b13b500d39e4a43d0ee04cf0ef3) represents the alignment necessary for mapping the CUDA array.
///
/// # Parameters
///
/// - `memoryRequirements`: Pointer to [cudaArrayMemoryRequirements](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArrayMemoryRequirements.html#structcudaarraymemoryrequirements).
/// - `array`: CUDA array to get the memory requirements of.
/// - `device`: Device to get the memory requirements for.
pub fn cudaArrayGetMemoryRequirements(
memoryRequirements: *mut cudaArrayMemoryRequirements,
array: cudaArray_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaArrayDeferredMapping](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga91a50795515848406a89c2e6cef2fb02) [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// The returned value in [cudaArrayMemoryRequirements::size](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArrayMemoryRequirements.html#structcudaarraymemoryrequirements_1acff0bc12daa05c6c40892a2187befd87) represents the total size of the CUDA mipmapped array. The returned value in [cudaArrayMemoryRequirements::alignment](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArrayMemoryRequirements.html#structcudaarraymemoryrequirements_1a37898b13b500d39e4a43d0ee04cf0ef3) represents the alignment necessary for mapping the CUDA mipmapped array.
///
/// # Parameters
///
/// - `memoryRequirements`: Pointer to [cudaArrayMemoryRequirements](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArrayMemoryRequirements.html#structcudaarraymemoryrequirements).
/// - `mipmap`: CUDA mipmapped array to get the memory requirements of.
/// - `device`: Device to get the memory requirements for.
pub fn cudaMipmappedArrayGetMemoryRequirements(
memoryRequirements: *mut cudaArrayMemoryRequirements,
mipmap: cudaMipmappedArray_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaArraySparse](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga42c353686a15da063dc7722594ae4bff) [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// If the returned value in [cudaArraySparseProperties::flags](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties_1a44c8728469d60e511aceb4ba7086c164) contains [cudaArraySparsePropertiesSingleMipTail](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga6820071ffa1300699897eab8d319e4d9), then [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties_1a22cfa4ad83195f0e9585303c988bb886) represents the total size of the array. Otherwise, it will be zero. Also, the returned value in [cudaArraySparseProperties::miptailFirstLevel](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties_1ab6909e5db55b866477b6cc16fb02f9d3) is always zero. Note that the `array` must have been allocated using [`cudaMallocArray`] or [`cudaMalloc3DArray`]. For CUDA arrays obtained using ::cudaMipmappedArrayGetLevel, [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) will be returned. Instead, [`cudaMipmappedArrayGetSparseProperties`] must be used to obtain the sparse properties of the entire CUDA mipmapped array to which `array` belongs to.
///
/// # Parameters
///
/// - `sparseProperties`: Pointer to return the [cudaArraySparseProperties](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties).
/// - `array`: The CUDA array to get the sparse properties of.
pub fn cudaArrayGetSparseProperties(
sparseProperties: *mut cudaArraySparseProperties,
array: cudaArray_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaArraySparse](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga42c353686a15da063dc7722594ae4bff) [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// For non-layered CUDA mipmapped arrays, [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties_1a22cfa4ad83195f0e9585303c988bb886) 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 [cudaArraySparseProperties::flags](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties_1a44c8728469d60e511aceb4ba7086c164) contains [cudaArraySparsePropertiesSingleMipTail](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga6820071ffa1300699897eab8d319e4d9), then [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties_1a22cfa4ad83195f0e9585303c988bb886) specifies the size of the mip tail of all layers combined. Otherwise, [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties_1a22cfa4ad83195f0e9585303c988bb886) specifies mip tail size per layer. The returned value of [cudaArraySparseProperties::miptailFirstLevel](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties_1ab6909e5db55b866477b6cc16fb02f9d3) is valid only if [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties_1a22cfa4ad83195f0e9585303c988bb886) is non-zero.
///
/// # Parameters
///
/// - `sparseProperties`: Pointer to return [cudaArraySparseProperties](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaArraySparseProperties.html#structcudaarraysparseproperties).
/// - `mipmap`: The CUDA mipmapped array to get the sparse properties of.
pub fn cudaMipmappedArrayGetSparseProperties(
sparseProperties: *mut cudaArraySparseProperties,
mipmap: cudaMipmappedArray_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies `count` bytes from the memory area pointed to by `src` to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. Calling [`cudaMemcpy`] with dst and src pointers that do not match the direction of the copy results in an undefined behavior.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
pub fn cudaMemcpy(
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies memory between two devices.
///
/// Copies memory from one device to memory on another device. `dst` is the base device pointer of the destination memory and `dstDevice` is the destination device. `src` is the base device pointer of the source memory and `srcDevice` is the source device. `count` specifies the number of bytes to copy.
///
/// Note that this function is asynchronous with respect to the host, but serialized with respect all pending and future asynchronous work in to the current device, `srcDevice`, and `dstDevice` (use [`cudaMemcpyPeerAsync`] to avoid this synchronization).
///
/// # Parameters
///
/// - `dst`: Destination device pointer.
/// - `dstDevice`: Destination device.
/// - `src`: Source device pointer.
/// - `srcDevice`: Source device.
/// - `count`: Size of memory copy in bytes.
pub fn cudaMemcpyPeer(
dst: *mut ::core::ffi::c_void,
dstDevice: ::core::ffi::c_int,
src: *const ::core::ffi::c_void,
srcDevice: ::core::ffi::c_int,
count: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies a matrix (`height` rows of `width` bytes each) from the memory area pointed to by `src` to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. `dpitch` and `spitch` are the widths in memory in bytes of the 2D arrays pointed to by `dst` and `src`, including any padding added to the end of each row. The memory areas may not overlap. `width` must not exceed either `dpitch` or `spitch`. Calling [`cudaMemcpy2D`] with `dst` and `src` pointers that do not match the direction of the copy results in an undefined behavior. [`cudaMemcpy2D`] returns an error if `dpitch` or `spitch` exceeds the maximum allowed.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `dpitch`: Pitch of destination memory.
/// - `src`: Source memory address.
/// - `spitch`: Pitch of source memory.
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
pub fn cudaMemcpy2D(
dst: *mut ::core::ffi::c_void,
dpitch: size_t,
src: *const ::core::ffi::c_void,
spitch: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies a matrix (`height` rows of `width` bytes each) from the memory area pointed to by `src` to the CUDA array `dst` starting at `hOffset` rows and `wOffset` bytes from the upper left corner, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. `spitch` is the width in memory in bytes of the 2D array pointed to by `src`, including any padding added to the end of each row. `wOffset` + `width` must not exceed the width of the CUDA array `dst`. `width` must not exceed `spitch`. [`cudaMemcpy2DToArray`] returns an error if `spitch` exceeds the maximum allowed.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffset`: Destination starting X offset (columns in bytes).
/// - `hOffset`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `spitch`: Pitch of source memory.
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
pub fn cudaMemcpy2DToArray(
dst: cudaArray_t,
wOffset: size_t,
hOffset: size_t,
src: *const ::core::ffi::c_void,
spitch: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies a matrix (`height` rows of `width` bytes each) from the CUDA array `src` starting at `hOffset` rows and `wOffset` bytes from the upper left corner to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. `dpitch` is the width in memory in bytes of the 2D array pointed to by `dst`, including any padding added to the end of each row. `wOffset` + `width` must not exceed the width of the CUDA array `src`. `width` must not exceed `dpitch`. [`cudaMemcpy2DFromArray`] returns an error if `dpitch` exceeds the maximum allowed.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `dpitch`: Pitch of destination memory.
/// - `src`: Source memory address.
/// - `wOffset`: Source starting X offset (columns in bytes).
/// - `hOffset`: Source starting Y offset (rows).
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
pub fn cudaMemcpy2DFromArray(
dst: *mut ::core::ffi::c_void,
dpitch: size_t,
src: cudaArray_const_t,
wOffset: size_t,
hOffset: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies a matrix (`height` rows of `width` bytes each) from the CUDA array `src` starting at `hOffsetSrc` rows and `wOffsetSrc` bytes from the upper left corner to the CUDA array `dst` starting at `hOffsetDst` rows and `wOffsetDst` bytes from the upper left corner, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. `wOffsetDst` + `width` must not exceed the width of the CUDA array `dst`. `wOffsetSrc` + `width` must not exceed the width of the CUDA array `src`.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffsetDst`: Destination starting X offset (columns in bytes).
/// - `hOffsetDst`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `wOffsetSrc`: Source starting X offset (columns in bytes).
/// - `hOffsetSrc`: Source starting Y offset (rows).
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
pub fn cudaMemcpy2DArrayToArray(
dst: cudaArray_t,
wOffsetDst: size_t,
hOffsetDst: size_t,
src: cudaArray_const_t,
wOffsetSrc: size_t,
hOffsetSrc: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data to the given symbol on the device.
///
/// Copies `count` bytes from the memory area pointed to by `src` to the memory area pointed to by `offset` bytes from the start of symbol `symbol`. The memory areas may not overlap. `symbol` is a variable that resides in global or constant memory space. `kind` can be either [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// # Parameters
///
/// - `symbol`: Device symbol address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaMemcpyToSymbol(
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data from the given symbol on the device.
///
/// Copies `count` bytes from the memory area pointed to by `offset` bytes from the start of symbol `symbol` to the memory area pointed to by `dst`. The memory areas may not overlap. `symbol` is a variable that resides in global or constant memory space. `kind` can be either [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaMemcpyFromSymbol(
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies `count` bytes from the memory area pointed to by `src` to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// The memory areas may not overlap. Calling [`cudaMemcpyAsync`] with `dst` and `src` pointers that do not match the direction of the copy results in an undefined behavior.
///
/// [`cudaMemcpyAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero `stream` argument. If `kind` is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and the `stream` is non-zero, the copy may overlap with operations in other streams.
///
/// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpyAsync(
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies memory between two devices asynchronously.
///
/// Copies memory from one device to memory on another device. `dst` is the base device pointer of the destination memory and `dstDevice` is the destination device. `src` is the base device pointer of the source memory and `srcDevice` is the source device. `count` specifies the number of bytes to copy.
///
/// Note that this function is asynchronous with respect to the host and all work on other devices.
///
/// # Parameters
///
/// - `dst`: Destination device pointer.
/// - `dstDevice`: Destination device.
/// - `src`: Source device pointer.
/// - `srcDevice`: Source device.
/// - `count`: Size of memory copy in bytes.
/// - `stream`: Stream identifier.
pub fn cudaMemcpyPeerAsync(
dst: *mut ::core::ffi::c_void,
dstDevice: ::core::ffi::c_int,
src: *const ::core::ffi::c_void,
srcDevice: ::core::ffi::c_int,
count: size_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaMemcpy3DBatchAsync`].
///
/// 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 [cudaMemcpyAttributes::srcAccessOrder](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpyAttributes.html#structcudamemcpyattributes_1a0d466b9b554cfd529fa0d0344c0c391a) indicates the source access ordering to be observed for copies associated with the attribute. If the source access order is set to [cudaMemcpySrcAccessOrderStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga1a0bf7e313a2ef3dcabacefcf8a013b5ab0c0860266a1fe9e640296317e8e32ae), then the source will be accessed in stream order. If the source access order is set to [cudaMemcpySrcAccessOrderDuringApiCall](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga1a0bf7e313a2ef3dcabacefcf8a013b5acf1101b874ba5ffe6ad6d89b7e807b29) 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 [cudaMemcpySrcAccessOrderAny](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga1a0bf7e313a2ef3dcabacefcf8a013b5a17b318d18bd58f8bfb6eb4b44a7d6949) 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 [cudaMemcpyAttributes](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpyAttributes.html#structcudamemcpyattributes) corresponding to it including the appropriate srcAccessOrder setting, otherwise the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c).
///
/// The [cudaMemcpyAttributes::srcLocHint](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpyAttributes.html#structcudamemcpyattributes_1a02741caad443491b1a0504c1fda2e495) and [cudaMemcpyAttributes::dstLocHint](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpyAttributes.html#structcudamemcpyattributes_1a1afc02fa1b53087f91d115ee8718dd65) 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09) is true or system-allocated pageable memory on devices where [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdadc80992427a92713e699953a6d249d6f) is true. For other cases, these hints are ignored.
///
/// The [cudaMemcpyAttributes::flags](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpyAttributes.html#structcudamemcpyattributes_1af18d7011fefaecb0fa72cbdbf8aad0fb) field can be used to specify certain flags for copies. Setting the [cudaMemcpyFlagPreferOverlapWithCompute](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggae21aa0690949b1d1e5360e4edcf75dcfafef0e1bac799cb33d1ee092124ced948) 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.
///
/// # 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.
/// - `stream`: The stream to enqueue the operations in. Must not be legacy NULL stream.
pub fn cudaMemcpyBatchAsync(
dsts: *const *mut ::core::ffi::c_void,
srcs: *const *const ::core::ffi::c_void,
sizes: *const size_t,
count: size_t,
attrs: *mut cudaMemcpyAttributes,
attrsIdxs: *mut size_t,
numAttrs: size_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaMemcpy3DBatchOp::src](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpy3DBatchOp.html#structcudamemcpy3dbatchop_1a8ffb48e0046cf9c16b1f4b7ad83baa31) and [cudaMemcpy3DBatchOp::dst](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpy3DBatchOp.html#structcudamemcpy3dbatchop_1a0295c551c9a400a93fa5304a864ccfea) 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 [cudaMemcpy3DBatchOp::extent](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpy3DBatchOp.html#structcudamemcpy3dbatchop_1a4368cd2ad50ccd13bef8e7a088e63e3f). 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 cudaMemcpy3DOperand::type is specified as [cudaMemcpyOperandTypePointer](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggada2d93832ded1a29fd7cb28a6261ee6ca395369a66615a9cacf1a734334859a67), then ::cudaMemcpy3DOperand::op::ptr will be used. The ::cudaMemcpy3DOperand::op::ptr::ptr field must contain the pointer where the copy should begin. The ::cudaMemcpy3DOperand::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 ::cudaMemcpy3DBatchOp::extent::width. The ::cudaMemcpy3DOperand::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 ::cudaMemcpy3DBatchOp::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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09) is true or system-allocated pageable memory on devices where [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdadc80992427a92713e699953a6d249d6f) is true, the ::cudaMemcpy3DOperand::op::ptr::locHint field can be used to hint the location of the operand.
///
/// If an operand’s type is specified as [cudaMemcpyOperandTypeArray](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggada2d93832ded1a29fd7cb28a6261ee6ca468b9e5daeac88a1cddc387310cb2952), then ::cudaMemcpy3DOperand::op::array will be used. The ::cudaMemcpy3DOperand::op::array::array field specifies the CUDA array and ::cudaMemcpy3DOperand::op::array::offset specifies the 3D offset into that array where the copy begins.
///
/// The [cudaMemcpyAttributes::srcAccessOrder](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpyAttributes.html#structcudamemcpyattributes_1a0d466b9b554cfd529fa0d0344c0c391a) indicates the source access ordering to be observed for copies associated with the attribute. If the source access order is set to [cudaMemcpySrcAccessOrderStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga1a0bf7e313a2ef3dcabacefcf8a013b5ab0c0860266a1fe9e640296317e8e32ae), then the source will be accessed in stream order. If the source access order is set to [cudaMemcpySrcAccessOrderDuringApiCall](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga1a0bf7e313a2ef3dcabacefcf8a013b5acf1101b874ba5ffe6ad6d89b7e807b29) 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 [cudaMemcpySrcAccessOrderAny](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga1a0bf7e313a2ef3dcabacefcf8a013b5a17b318d18bd58f8bfb6eb4b44a7d6949) 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 [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c).
///
/// The [cudaMemcpyAttributes::flags](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpyAttributes.html#structcudamemcpyattributes_1af18d7011fefaecb0fa72cbdbf8aad0fb) field can be used to specify certain flags for copies. Setting the [cudaMemcpyFlagPreferOverlapWithCompute](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggae21aa0690949b1d1e5360e4edcf75dcfafef0e1bac799cb33d1ee092124ced948) 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.
///
/// # 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.
/// - `stream`: The stream to enqueue the operations in. Must not be default NULL stream.
pub fn cudaMemcpy3DBatchAsync(
numOps: size_t,
opList: *mut cudaMemcpy3DBatchOp,
flags: ::core::ffi::c_ulonglong,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 `stream` specifies the stream to enqueue the operation in.
///
/// For more information regarding the attributes, please refer to [cudaMemcpyAttributes](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpyAttributes.html#structcudamemcpyattributes) and it’s usage desciption in::cudaMemcpyBatchAsync.
///
/// # Parameters
///
/// - `dst`: Destination device pointer.
/// - `src`: Source device pointer.
/// - `size`: Number of bytes to copy.
/// - `attr`: Attributes for the copy.
/// - `stream`: Stream to enqueue the operation in.
pub fn cudaMemcpyWithAttributesAsync(
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
size: size_t,
attr: *mut cudaMemcpyAttributes,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Performs 3D asynchronous memory copy with the specified attributes.
///
/// Performs the copy operation specified in `op`. `flags` specifies the flags for the copy and `stream` specifies the stream to enqueue the operation in.
///
/// For more information regarding the operation, please refer to [cudaMemcpy3DBatchOp](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemcpy3DBatchOp.html#structcudamemcpy3dbatchop) and it’s usage desciption in::cudaMemcpy3DBatchAsync.
///
/// # Parameters
///
/// - `op`: Operation to perform.
/// - `flags`: Flags for the copy, must be zero now.
/// - `stream`: Stream to enqueue the operation in.
pub fn cudaMemcpy3DWithAttributesAsync(
op: *mut cudaMemcpy3DBatchOp,
flags: ::core::ffi::c_ulonglong,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies a matrix (`height` rows of `width` bytes each) from the memory area pointed to by `src` to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. `dpitch` and `spitch` are the widths in memory in bytes of the 2D arrays pointed to by `dst` and `src`, including any padding added to the end of each row. The memory areas may not overlap. `width` must not exceed either `dpitch` or `spitch`.
///
/// Calling [`cudaMemcpy2DAsync`] with `dst` and `src` pointers that do not match the direction of the copy results in an undefined behavior. [`cudaMemcpy2DAsync`] returns an error if `dpitch` or `spitch` is greater than the maximum allowed.
///
/// [`cudaMemcpy2DAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero `stream` argument. If `kind` is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and `stream` is non-zero, the copy may overlap with operations in other streams.
///
/// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `dpitch`: Pitch of destination memory.
/// - `src`: Source memory address.
/// - `spitch`: Pitch of source memory.
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy2DAsync(
dst: *mut ::core::ffi::c_void,
dpitch: size_t,
src: *const ::core::ffi::c_void,
spitch: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies a matrix (`height` rows of `width` bytes each) from the memory area pointed to by `src` to the CUDA array `dst` starting at `hOffset` rows and `wOffset` bytes from the upper left corner, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. `spitch` is the width in memory in bytes of the 2D array pointed to by `src`, including any padding added to the end of each row. `wOffset` + `width` must not exceed the width of the CUDA array `dst`. `width` must not exceed `spitch`. [`cudaMemcpy2DToArrayAsync`] returns an error if `spitch` exceeds the maximum allowed.
///
/// [`cudaMemcpy2DToArrayAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero `stream` argument. If `kind` is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and `stream` is non-zero, the copy may overlap with operations in other streams.
///
/// [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], ::cuMemcpy2DAsync.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffset`: Destination starting X offset (columns in bytes).
/// - `hOffset`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `spitch`: Pitch of source memory.
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy2DToArrayAsync(
dst: cudaArray_t,
wOffset: size_t,
hOffset: size_t,
src: *const ::core::ffi::c_void,
spitch: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies a matrix (`height` rows of `width` bytes each) from the CUDA array `src` starting at `hOffset` rows and `wOffset` bytes from the upper left corner to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. `dpitch` is the width in memory in bytes of the 2D array pointed to by `dst`, including any padding added to the end of each row. `wOffset` + `width` must not exceed the width of the CUDA array `src`. `width` must not exceed `dpitch`. [`cudaMemcpy2DFromArrayAsync`] returns an error if `dpitch` exceeds the maximum allowed.
///
/// [`cudaMemcpy2DFromArrayAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero `stream` argument. If `kind` is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and `stream` is non-zero, the copy may overlap with operations in other streams.
///
/// [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], ::cuMemcpy2DAsync.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `dpitch`: Pitch of destination memory.
/// - `src`: Source memory address.
/// - `wOffset`: Source starting X offset (columns in bytes).
/// - `hOffset`: Source starting Y offset (rows).
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy2DFromArrayAsync(
dst: *mut ::core::ffi::c_void,
dpitch: size_t,
src: cudaArray_const_t,
wOffset: size_t,
hOffset: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data to the given symbol on the device.
///
/// Copies `count` bytes from the memory area pointed to by `src` to the memory area pointed to by `offset` bytes from the start of symbol `symbol`. The memory areas may not overlap. `symbol` is a variable that resides in global or constant memory space. `kind` can be either [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// [`cudaMemcpyToSymbolAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero `stream` argument. If `kind` is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] and `stream` is non-zero, the copy may overlap with operations in other streams.
///
/// # Parameters
///
/// - `symbol`: Device symbol address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpyToSymbolAsync(
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data from the given symbol on the device.
///
/// Copies `count` bytes from the memory area pointed to by `offset` bytes from the start of symbol `symbol` to the memory area pointed to by `dst`. The memory areas may not overlap. `symbol` is a variable that resides in global or constant memory space. `kind` can be either [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// [`cudaMemcpyFromSymbolAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero `stream` argument. If `kind` is [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and `stream` is non-zero, the copy may overlap with operations in other streams.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpyFromSymbolAsync(
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Initializes or sets device memory to a value.
///
/// Fills the first `count` bytes of the memory area pointed to by `devPtr` with the constant byte value `value`.
///
/// Note that this function is asynchronous with respect to the host unless `devPtr` refers to pinned host memory.
///
/// # Parameters
///
/// - `devPtr`: Pointer to device memory.
/// - `value`: Value to set for each byte of specified memory.
/// - `count`: Size in bytes to set.
pub fn cudaMemset(
devPtr: *mut ::core::ffi::c_void,
value: ::core::ffi::c_int,
count: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Initializes or sets device memory to a value.
///
/// Sets to the specified value `value` a matrix (`height` rows of `width` bytes each) pointed to by `dstPtr`. `pitch` is the width in bytes of the 2D array pointed to by `dstPtr`, including any padding added to the end of each row. This function performs fastest when the pitch is one that has been passed back by [`cudaMallocPitch`].
///
/// Note that this function is asynchronous with respect to the host unless `devPtr` refers to pinned host memory.
///
/// # Parameters
///
/// - `devPtr`: Pointer to 2D device memory.
/// - `pitch`: Pitch in bytes of 2D device memory(Unused if `height` is 1).
/// - `value`: Value to set for each byte of specified memory.
/// - `width`: Width of matrix set (columns in bytes).
/// - `height`: Height of matrix set (rows).
pub fn cudaMemset2D(
devPtr: *mut ::core::ffi::c_void,
pitch: size_t,
value: ::core::ffi::c_int,
width: size_t,
height: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Initializes or sets device memory to a value.
///
/// Initializes each element of a 3D array to the specified value `value`. The object to initialize is defined by `pitchedDevPtr`. The `pitch` field of `pitchedDevPtr` is the width in memory in bytes of the 3D array pointed to by `pitchedDevPtr`, including any padding added to the end of each row. The `xsize` field specifies the logical width of each row in bytes, while the `ysize` field specifies the height of each 2D slice in rows. The `pitch` field of `pitchedDevPtr` is ignored when `height` and `depth` are both equal to 1.
///
/// The extents of the initialized region are specified as a `width` in bytes, a `height` in rows, and a `depth` in slices.
///
/// Extents with `width` greater than or equal to the `xsize` of `pitchedDevPtr` may perform significantly faster than extents narrower than the `xsize`. Secondarily, extents with `height` equal to the `ysize` of `pitchedDevPtr` will perform faster than when the `height` is shorter than the `ysize`.
///
/// This function performs fastest when the `pitchedDevPtr` has been allocated by [`cudaMalloc3D`].
///
/// Note that this function is asynchronous with respect to the host unless `pitchedDevPtr` refers to pinned host memory.
///
/// # Parameters
///
/// - `pitchedDevPtr`: Pointer to pitched device memory.
/// - `value`: Value to set for each byte of specified memory.
/// - `extent`: Size parameters for where to set device memory (`width` field in bytes).
pub fn cudaMemset3D(
pitchedDevPtr: cudaPitchedPtr,
value: ::core::ffi::c_int,
extent: cudaExtent,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Initializes or sets device memory to a value.
///
/// Fills the first `count` bytes of the memory area pointed to by `devPtr` with the constant byte value `value`.
///
/// [`cudaMemsetAsync`] is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero `stream` argument. If `stream` is non-zero, the operation may overlap with operations in other streams.
///
/// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
///
/// # Parameters
///
/// - `devPtr`: Pointer to device memory.
/// - `value`: Value to set for each byte of specified memory.
/// - `count`: Size in bytes to set.
/// - `stream`: Stream identifier.
pub fn cudaMemsetAsync(
devPtr: *mut ::core::ffi::c_void,
value: ::core::ffi::c_int,
count: size_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Initializes or sets device memory to a value.
///
/// Sets to the specified value `value` a matrix (`height` rows of `width` bytes each) pointed to by `dstPtr`. `pitch` is the width in bytes of the 2D array pointed to by `dstPtr`, including any padding added to the end of each row. This function performs fastest when the pitch is one that has been passed back by [`cudaMallocPitch`].
///
/// [`cudaMemset2DAsync`] is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero `stream` argument. If `stream` is non-zero, the operation may overlap with operations in other streams.
///
/// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
///
/// # Parameters
///
/// - `devPtr`: Pointer to 2D device memory.
/// - `pitch`: Pitch in bytes of 2D device memory(Unused if `height` is 1).
/// - `value`: Value to set for each byte of specified memory.
/// - `width`: Width of matrix set (columns in bytes).
/// - `height`: Height of matrix set (rows).
/// - `stream`: Stream identifier.
pub fn cudaMemset2DAsync(
devPtr: *mut ::core::ffi::c_void,
pitch: size_t,
value: ::core::ffi::c_int,
width: size_t,
height: size_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Initializes or sets device memory to a value.
///
/// Initializes each element of a 3D array to the specified value `value`. The object to initialize is defined by `pitchedDevPtr`. The `pitch` field of `pitchedDevPtr` is the width in memory in bytes of the 3D array pointed to by `pitchedDevPtr`, including any padding added to the end of each row. The `xsize` field specifies the logical width of each row in bytes, while the `ysize` field specifies the height of each 2D slice in rows. The `pitch` field of `pitchedDevPtr` is ignored when `height` and `depth` are both equal to 1.
///
/// The extents of the initialized region are specified as a `width` in bytes, a `height` in rows, and a `depth` in slices.
///
/// Extents with `width` greater than or equal to the `xsize` of `pitchedDevPtr` may perform significantly faster than extents narrower than the `xsize`. Secondarily, extents with `height` equal to the `ysize` of `pitchedDevPtr` will perform faster than when the `height` is shorter than the `ysize`.
///
/// This function performs fastest when the `pitchedDevPtr` has been allocated by [`cudaMalloc3D`].
///
/// [`cudaMemset3DAsync`] is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero `stream` argument. If `stream` is non-zero, the operation may overlap with operations in other streams.
///
/// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
///
/// # Parameters
///
/// - `pitchedDevPtr`: Pointer to pitched device memory.
/// - `value`: Value to set for each byte of specified memory.
/// - `extent`: Size parameters for where to set device memory (`width` field in bytes).
/// - `stream`: Stream identifier.
pub fn cudaMemset3DAsync(
pitchedDevPtr: cudaPitchedPtr,
value: ::core::ffi::c_int,
extent: cudaExtent,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Finds the address associated with a CUDA symbol.
///
/// Returns in `*devPtr` the address of symbol `symbol` on the device. `symbol` is a variable that resides in global or constant memory space. If `symbol` cannot be found, or if `symbol` is not declared in the global or constant memory space, `*devPtr` is unchanged and the error [cudaErrorInvalidSymbol](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a) is returned.
///
/// # Parameters
///
/// - `devPtr`: Return device pointer associated with symbol.
/// - `symbol`: Device symbol address.
pub fn cudaGetSymbolAddress(
devPtr: *mut *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Finds the size of the object associated with a CUDA symbol.
///
/// Returns in `*size` the size of symbol `symbol`. `symbol` is a variable that resides in global or constant memory space. If `symbol` cannot be found, or if `symbol` is not declared in global or constant memory space, `*size` is unchanged and the error [cudaErrorInvalidSymbol](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a) is returned.
///
/// # Parameters
///
/// - `size`: Size of object associated with symbol.
/// - `symbol`: Device symbol address.
pub fn cudaGetSymbolSize(
size: *mut size_t,
symbol: *const ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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. `stream` is the stream in which the operation is enqueued. The memory range must refer to managed memory allocated via [`cudaMallocManaged`] or declared via **managed** variables, or it may also refer to memory allocated from a managed memory pool, or it may also refer to system-allocated memory on systems with non-zero cudaDevAttrPageableMemoryAccess.
///
/// Specifying [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4) for [cudaMemLocation::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a6df2243c9f48e48ad92306df676b2fe0) will prefetch memory to GPU specified by device ordinal [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) which must have non-zero value for the device attribute ::concurrentManagedAccess. Additionally, `stream` must be associated with a device that has a non-zero value for the device attribute ::concurrentManagedAccess. Specifying [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5) as [cudaMemLocation::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a6df2243c9f48e48ad92306df676b2fe0) will prefetch data to host memory. Applications can request prefetching memory to a specific host NUMA node by specifying [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0) for [cudaMemLocation::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a6df2243c9f48e48ad92306df676b2fe0) and a valid host NUMA node id in [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) Users can also request prefetching memory to the host NUMA node closest to the current thread’s CPU by specifying [cudaMemLocationTypeHostNumaCurrent](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0aa3925690e32332c940cb726ef56a4258) for [cudaMemLocation::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a6df2243c9f48e48ad92306df676b2fe0). Note when [cudaMemLocation::type](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a6df2243c9f48e48ad92306df676b2fe0) is etiher [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5) OR [cudaMemLocationTypeHostNumaCurrent](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0aa3925690e32332c940cb726ef56a4258), [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) will be ignored. Prefetching to [cudaMemLocationTypeDeviceLocalityDomain](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a88b5d659aa9d7501f0382836eebb125b) locations is not supported.
///
/// 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 [`cudaMallocManaged`] allocations to host memory in order to make room. Device memory allocated using [`cudaMalloc`] or [`cudaMallocArray`] 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 as described below:
///
/// If [cudaMemAdviseSetReadMostly](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggac314a8b14091f7e02a7ad15dcb36c857a441d911811beda174627f403142d5ff0) 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 [cudaMemAdviseSetPreferredLocation](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggac314a8b14091f7e02a7ad15dcb36c857aa4a2bc3c7d218dcd9a1b425b432759eb) 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 [cudaMemAdviseSetAccessedBy](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggac314a8b14091f7e02a7ad15dcb36c857a50a22279bce0dc29956ad4f257084623) 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.
///
/// # Parameters
///
/// - `devPtr`: Pointer to be prefetched.
/// - `count`: Size in bytes.
/// - `location`: location to prefetch to.
/// - `flags`: flags for future use, must be zero now.
/// - `stream`: Stream to enqueue prefetch operation.
pub fn cudaMemPrefetchAsync(
devPtr: *const ::core::ffi::c_void,
count: size_t,
location: cudaMemLocation,
flags: ::core::ffi::c_uint,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09) otherwise the API will return an error.
///
/// The semantics of the individual prefetch operations are as described in [`cudaMemPrefetchAsync`].
///
/// 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 [`cudaMallocManaged`] or declared via **managed** variables or it may also refer to system-allocated memory when all devices have a non-zero value for [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdadc80992427a92713e699953a6d249d6f). 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.
/// - `stream`: The stream to enqueue the operations in. Must not be legacy NULL stream.
pub fn cudaMemPrefetchBatchAsync(
dptrs: *mut *mut ::core::ffi::c_void,
sizes: *mut size_t,
count: size_t,
prefetchLocs: *mut cudaMemLocation,
prefetchLocIdxs: *mut size_t,
numPrefetchLocs: size_t,
flags: ::core::ffi::c_ulonglong,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09) 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 [`cudaMemPrefetchAsync`] or [`cudaMemPrefetchBatchAsync`]. 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 [`cudaMallocManaged`] or declared via **managed** variables or it may also refer to system-allocated memory when all devices have a non-zero value for [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdadc80992427a92713e699953a6d249d6f).
///
/// # 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.
/// - `stream`: The stream to enqueue the operations in. Must not be legacy NULL stream.
pub fn cudaMemDiscardBatchAsync(
dptrs: *mut *mut ::core::ffi::c_void,
sizes: *mut size_t,
count: size_t,
flags: ::core::ffi::c_ulonglong,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09) otherwise the API will return an error.
///
/// Calling [`cudaMemDiscardAndPrefetchBatchAsync`] is semantically equivalent to calling [`cudaMemDiscardBatchAsync`] followed by [`cudaMemPrefetchBatchAsync`], but is more optimal. For more details on what discarding and prefetching imply, please refer to [`cudaMemDiscardBatchAsync`] and [`cudaMemPrefetchBatchAsync`] 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 [`cudaMallocManaged`] or declared via **managed** variables or it may also refer to system-allocated memory when all devices have a non-zero value for [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdadc80992427a92713e699953a6d249d6f). 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.
/// - `stream`: The stream to enqueue the operations in. Must not be legacy NULL stream.
pub fn cudaMemDiscardAndPrefetchBatchAsync(
dptrs: *mut *mut ::core::ffi::c_void,
sizes: *mut size_t,
count: size_t,
prefetchLocs: *mut cudaMemLocation,
prefetchLocIdxs: *mut size_t,
numPrefetchLocs: size_t,
flags: ::core::ffi::c_ulonglong,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Gets location information for a memory address range.
///
/// Retrieves memory location information for the specified address range starting at `ptr` with size `size`. The API determines the most common location by sampling memory at intervals defined by `samplingGranularity` within the whole interval.
///
/// The location information is returned in the `location_out` array, with one entry per summary region. The total number of locations returned will be ceil(size/summaryGranularity). The user is expected to allocate the `location_out` array with sufficient memory.
///
/// For example, with an address range of 1GB, a `summaryGranularity` of 128MB, and a `samplingGranularity` of 2MB, the function will:
///
/// When the memory is not resident on any processor, the call returns [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) and the returned location type for that interval is [cudaMemLocationTypeNone](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a53b6266fa56e0b7efe6a0b78ed8e8f49).
///
/// The memory range must refer to one of the following:
///
/// All devices on the system must have non-zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09). If not, this call returns [cudaErrorNotSupported](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad846fd9f2e8ba5e2fb4f1695b7ab6164).
///
/// # Parameters
///
/// - `size`: Size in bytes of the memory range to query.
/// - `summaryGranularity`: Granularity in bytes at which to summarize location information.
/// - `samplingGranularity`: Granularity in bytes at which to sample memory within each summary region.
/// - `location_out`: Array to store location information, one entry per summary region.
pub fn cudaMemGetLocationInfo(
devPtr: *mut ::core::ffi::c_void,
size: size_t,
summaryGranularity: size_t,
samplingGranularity: size_t,
location_out: *mut cudaMemLocation,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaMallocManaged`] 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.
///
/// # 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 cudaMemAdvise(
devPtr: *const ::core::ffi::c_void,
count: size_t,
advice: cudaMemoryAdvise,
location: cudaMemLocation,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaMallocManaged`] or declared via **managed** variables.
///
/// The `attribute` parameter can take the following values.
///
/// # 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 cudaMemRangeGetAttribute(
data: *mut ::core::ffi::c_void,
dataSize: size_t,
attribute: cudaMemRangeAttribute,
devPtr: *const ::core::ffi::c_void,
count: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaMallocManaged`] 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 [`cudaMemRangeGetAttribute`] for attribute descriptions and restrictions.
///
/// # Parameters
///
/// - `data`: A two-dimensional array containing pointers to memory locations where the result of each attribute query will be written 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 cudaMemRangeGetAttributes(
data: *mut *mut ::core::ffi::c_void,
dataSizes: *mut size_t,
attributes: *mut cudaMemRangeAttribute,
numAttributes: size_t,
devPtr: *const ::core::ffi::c_void,
count: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies `count` bytes from the memory area pointed to by `src` to the CUDA array `dst` starting at `hOffset` rows and `wOffset` bytes from the upper left corner, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffset`: Destination starting X offset (columns in bytes).
/// - `hOffset`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
#[deprecated]
pub fn cudaMemcpyToArray(
dst: cudaArray_t,
wOffset: size_t,
hOffset: size_t,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies `count` bytes from the CUDA array `src` starting at `hOffset` rows and `wOffset` bytes from the upper left corner to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `wOffset`: Source starting X offset (columns in bytes).
/// - `hOffset`: Source starting Y offset (rows).
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
#[deprecated]
pub fn cudaMemcpyFromArray(
dst: *mut ::core::ffi::c_void,
src: cudaArray_const_t,
wOffset: size_t,
hOffset: size_t,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies `count` bytes from the CUDA array `src` starting at `hOffsetSrc` rows and `wOffsetSrc` bytes from the upper left corner to the CUDA array `dst` starting at `hOffsetDst` rows and `wOffsetDst` bytes from the upper left corner, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffsetDst`: Destination starting X offset (columns in bytes).
/// - `hOffsetDst`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `wOffsetSrc`: Source starting X offset (columns in bytes).
/// - `hOffsetSrc`: Source starting Y offset (rows).
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
#[deprecated]
pub fn cudaMemcpyArrayToArray(
dst: cudaArray_t,
wOffsetDst: size_t,
hOffsetDst: size_t,
src: cudaArray_const_t,
wOffsetSrc: size_t,
hOffsetSrc: size_t,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies `count` bytes from the memory area pointed to by `src` to the CUDA array `dst` starting at `hOffset` rows and `wOffset` bytes from the upper left corner, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// [`cudaMemcpyToArrayAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero `stream` argument. If `kind` is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and `stream` is non-zero, the copy may overlap with operations in other streams.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffset`: Destination starting X offset (columns in bytes).
/// - `hOffset`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
#[deprecated]
pub fn cudaMemcpyToArrayAsync(
dst: cudaArray_t,
wOffset: size_t,
hOffset: size_t,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between host and device.
///
/// Copies `count` bytes from the CUDA array `src` starting at `hOffset` rows and `wOffset` bytes from the upper left corner to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// [`cudaMemcpyFromArrayAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero `stream` argument. If `kind` is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and `stream` is non-zero, the copy may overlap with operations in other streams.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `wOffset`: Source starting X offset (columns in bytes).
/// - `hOffset`: Source starting Y offset (rows).
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
#[deprecated]
pub fn cudaMemcpyFromArrayAsync(
dst: *mut ::core::ffi::c_void,
src: cudaArray_const_t,
wOffset: size_t,
hOffset: size_t,
count: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 the allocation operation completes. The allocation comes from the memory pool associated with the stream's device.
///
///
///
/// Note: The default memory pool of a device contains device memory from that device.
///
/// Note: 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.
///
///
///
///
///
/// # Return value
///
/// ::cudaSuccess, ::cudaErrorInvalidValue, ::cudaErrorNotSupported, ::cudaErrorOutOfMemory,
///
/// Note: _null_stream
///
/// Note: _init_rt
///
/// Note: _callback
///
///
///
/// See also: ::cuMemAllocAsync, `::cudaMallocAsync(void**` ptr, size_t size, cudaMemPool_t memPool, cudaStream_t stream) "cudaMallocAsync (C++ API)", ::cudaMallocFromPoolAsync, ::cudaFreeAsync, ::cudaDeviceSetMemPool, ::cudaDeviceGetDefaultMemPool, ::cudaDeviceGetMemPool, ::cudaMemPoolSetAccess, ::cudaMemPoolSetAttribute, ::cudaMemPoolGetAttribute
///
/// # Parameters
///
/// - `devPtr`: - Returned device pointer
/// - `size`: - Number of bytes to allocate
/// - `hStream`: - The stream establishing the stream ordering contract and the memory pool to allocate from
pub fn cudaMallocAsync(
devPtr: *mut *mut ::core::ffi::c_void,
size: size_t,
hStream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `hStream`: The stream establishing the stream ordering promise.
pub fn cudaFreeAsync(
devPtr: *mut ::core::ffi::c_void,
hStream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `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 cudaMemPoolTrimTo(
memPool: cudaMemPool_t,
minBytesToKeep: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets attributes of a memory pool.
///
/// Supported attributes are.
///
/// # Parameters
///
/// - `attr`: The attribute to modify.
/// - `value`: Pointer to the value to assign.
pub fn cudaMemPoolSetAttribute(
memPool: cudaMemPool_t,
attr: cudaMemPoolAttr,
value: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Gets attributes of a memory pool.
///
/// Supported attributes are:
///
/// The following properties can be also be queried on imported and default pools.
///
/// # Parameters
///
/// - `attr`: The attribute to get.
/// - `value`: Retrieved value.
pub fn cudaMemPoolGetAttribute(
memPool: cudaMemPool_t,
attr: cudaMemPoolAttr,
value: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Controls visibility of pools between devices.
///
/// # Parameters
///
/// - `count`: Number of descriptors in the map array.
pub fn cudaMemPoolSetAccess(
memPool: cudaMemPool_t,
descList: *const cudaMemAccessDesc,
count: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the accessibility of a pool from a device.
///
/// Returns the accessibility of the pool’s memory from the specified location.
///
/// # Parameters
///
/// - `flags`: the accessibility of the pool from the specified location.
/// - `memPool`: the pool being queried.
/// - `location`: the location accessing the pool.
pub fn cudaMemPoolGetAccess(
flags: *mut cudaMemAccessFlags,
memPool: cudaMemPool_t,
location: *mut cudaMemLocation,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 ::cudaMemPoolProps::cudaMemLocation::type to [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5). ::cudaMemPoolProps::cudaMemLocation::id is ignored for such pools. Pools created with the type [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5) are not IPC capable and [cudaMemPoolProps::handleTypes](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemPoolProps.html#structcudamempoolprops_1a4cf896bffe71384e374c4d2decca9a53) must be 0, any other values will result in [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c). To create a memory pool targeting a specific host NUMA node, applications must set ::cudaMemPoolProps::cudaMemLocation::type to [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0) and ::cudaMemPoolProps::cudaMemLocation::id must specify the NUMA ID of the host memory node. Specifying [cudaMemLocationTypeHostNumaCurrent](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0aa3925690e32332c940cb726ef56a4258) as the ::cudaMemPoolProps::cudaMemLocation::type will result in [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c). To create a memory pool targeting a specific device locality domain, applications must set ::cudaMemPoolProps::cudaMemLocation::type to [cudaMemLocationTypeDeviceLocalityDomain](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a88b5d659aa9d7501f0382836eebb125b), ::cudaMemPoolProps::cudaMemLocation::localized.deviceId must specify the device ID, and ::cudaMemPoolProps::cudaMemLocation::localized.localityDomainId must specify the locality domain ID. The locality domain ID must be a valid locality domain ID for the specified device. See also [`cudaDeviceGetAttribute`] with the attribute [cudaDevAttrLocalityDomainCount](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cda53544b5a7a807fb2c96f15dda587500d). By default, the pool’s memory will be accessible from the device it is allocated on. In the case of pools created with [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0) or [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5), 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 [cudaMemPoolProps::maxSize](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemPoolProps.html#structcudamempoolprops_1a2d90e82afb8d577a2aee847d082e145d). If set to 0, the maximum size of the pool will default to a system dependent value.
///
/// Applications that intend to use ::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 [cudaMemPoolProps](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemPoolProps.html#structcudamempoolprops):cudaMemAllocationType to [`cudaMemAllocationType::cudaMemAllocationTypeManaged`]. ::cudaMemPoolProps::cudaMemAllocationHandleType must also be set to [cudaMemHandleTypeNone](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaabde707dfb8a602b917e0b177f77f365afed45251c1591431e1b9da28c1a04191) since IPC is not supported. For managed memory pools, ::cudaMemPoolProps::cudaMemLocation will be treated as the preferred location for all allocations created from the pool. An application can also set [cudaMemLocationTypeNone](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a53b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location. [cudaMemPoolProps::maxSize](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemPoolProps.html#structcudamempoolprops_1a2d90e82afb8d577a2aee847d082e145d) must be set to zero for managed memory pools. [cudaMemPoolProps::usage](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemPoolProps.html#structcudamempoolprops_1a377241affe79dd0a3c7b40453824bd6b) 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 [cudaErrorNotSupported](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad846fd9f2e8ba5e2fb4f1695b7ab6164).
pub fn cudaMemPoolCreate(
memPool: *mut cudaMemPool_t,
poolProps: *const cudaMemPoolProps,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaMemPoolDestroy`] 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.
pub fn cudaMemPoolDestroy(memPool: cudaMemPool_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the default memory pool for a given location and allocation type.
///
/// The memory location can be of one of [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4), [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5), [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0), or [cudaMemLocationTypeDeviceLocalityDomain](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a88b5d659aa9d7501f0382836eebb125b). The allocation type can be one of [`cudaMemAllocationType::cudaMemAllocationTypePinned`] or [`cudaMemAllocationType::cudaMemAllocationTypeManaged`]. When the allocation type is [`cudaMemAllocationType::cudaMemAllocationTypeManaged`], the location type can also be [cudaMemLocationTypeNone](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a53b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location for the managed memory pool. [`cudaMemAllocationType::cudaMemAllocationTypeManaged`] can not be used with [cudaMemLocationTypeDeviceLocalityDomain](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a88b5d659aa9d7501f0382836eebb125b). In all other cases, the call return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c).
pub fn cudaMemGetDefaultMemPool(
memPool: *mut cudaMemPool_t,
location: *mut cudaMemLocation,
type_: cudaMemAllocationType,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Gets the current memory pool for a given memory location and allocation type.
///
/// The memory location can be of one of [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4), [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5), [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0), or [cudaMemLocationTypeDeviceLocalityDomain](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a88b5d659aa9d7501f0382836eebb125b). The allocation type can be one of [`cudaMemAllocationType::cudaMemAllocationTypePinned`] or [`cudaMemAllocationType::cudaMemAllocationTypeManaged`]. When the allocation type is [`cudaMemAllocationType::cudaMemAllocationTypeManaged`], the location type can also be [cudaMemLocationTypeNone](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a53b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location for the managed memory pool. [`cudaMemAllocationType::cudaMemAllocationTypeManaged`] can not be used with [cudaMemLocationTypeDeviceLocalityDomain](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a88b5d659aa9d7501f0382836eebb125b). In all other cases, the call return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c)
///
/// Returns the last pool provided to [`cudaMemSetMemPool`] or [`cudaDeviceSetMemPool`] for this location and allocation type or the location’s default memory pool if [`cudaMemSetMemPool`] or [`cudaDeviceSetMemPool`] for that allocType and location has never been called. By default the current mempool of a location is the default mempool for a device that can be obtained via cudaMemGetDefaultMemPool Otherwise the returned pool must have been set with [`cudaDeviceSetMemPool`].
pub fn cudaMemGetMemPool(
memPool: *mut cudaMemPool_t,
location: *mut cudaMemLocation,
type_: cudaMemAllocationType,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the current memory pool for a memory location and allocation type.
///
/// The memory location can be of one of [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4), [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5) [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0), or [cudaMemLocationTypeDeviceLocalityDomain](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a88b5d659aa9d7501f0382836eebb125b). The allocation type can be one of [`cudaMemAllocationType::cudaMemAllocationTypePinned`] or [`cudaMemAllocationType::cudaMemAllocationTypeManaged`]. When the allocation type is [`cudaMemAllocationType::cudaMemAllocationTypeManaged`], the location type can also be [cudaMemLocationTypeNone](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a53b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location for the managed memory pool. [`cudaMemAllocationType::cudaMemAllocationTypeManaged`] can not be used with [cudaMemLocationTypeDeviceLocalityDomain](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a88b5d659aa9d7501f0382836eebb125b). In all other cases, the call return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c)
///
/// When a memory pool is set as the current memory pool, the location parameter should be the same as the location of the pool. If the location type or index don’t match, the call returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c). The type of memory pool should also match the parameter allocType. Else the call returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c)
///
/// .
///
/// By default, a memory location’s current memory pool is its default memory pool. If the location type is.
pub fn cudaMemSetMemPool(
location: *mut cudaMemLocation,
type_: cudaMemAllocationType,
memPool: cudaMemPool_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Allocates memory from a specified pool with stream ordered semantics.
///
/// Inserts an allocation operation into `stream`. 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.
///
/// # Parameters
///
/// - `ptr`: Returned device pointer.
/// - `memPool`: The pool to allocate from.
/// - `stream`: The stream establishing the stream ordering semantic.
pub fn cudaMallocFromPoolAsync(
ptr: *mut *mut ::core::ffi::c_void,
size: size_t,
memPool: cudaMemPool_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaMemPoolImportFromShareableHandle`]. Individual pointers can then be shared with the [`cudaMemPoolExportPointer`] and [`cudaMemPoolImportPointer`] APIs. The implementation of what the shareable handle is and how it can be transferred is defined by the requested handle type.
///
/// # Parameters
///
/// - `handleType`: the type of handle to create.
/// - `flags`: must be 0.
pub fn cudaMemPoolExportToShareableHandle(
shareableHandle: *mut ::core::ffi::c_void,
memPool: cudaMemPool_t,
handleType: cudaMemAllocationHandleType,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// imports a memory pool from a shared handle.
///
/// Specific allocations can be imported from the imported pool with [`cudaMemPoolImportPointer`].
///
/// # Parameters
///
/// - `handleType`: The type of handle being imported.
/// - `flags`: must be 0.
pub fn cudaMemPoolImportFromShareableHandle(
memPool: *mut cudaMemPool_t,
shareableHandle: *mut ::core::ffi::c_void,
handleType: cudaMemAllocationHandleType,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaMemPoolImportPointer`] api. The data is not a handle and may be shared through any IPC mechanism.
///
/// # Parameters
///
/// - `ptr`: pointer to memory being exported.
pub fn cudaMemPoolExportPointer(
exportData: *mut cudaMemPoolPtrExportData,
ptr: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 cudaFree or cudaFreeAsync. If [`cudaFreeAsync`] is used, the free must be completed on the importing process before the free operation on the exporting process.
pub fn cudaMemPoolImportPointer(
ptr: *mut *mut ::core::ffi::c_void,
memPool: cudaMemPool_t,
exportData: *mut cudaMemPoolPtrExportData,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns attributes about a specified pointer.
///
/// Returns in `*attributes` the attributes of the pointer `ptr`. If pointer was not allocated in, mapped by or registered with context supporting unified addressing [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// The [`cudaPointerAttributes`] structure is defined as.
///
/// # Parameters
///
/// - `attributes`: Attributes for the specified pointer.
/// - `ptr`: Pointer to get attributes for.
pub fn cudaPointerGetAttributes(
attributes: *mut cudaPointerAttributes,
ptr: *const ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Queries if a device may directly access a peer device’s memory.
///
/// Returns in `*canAccessPeer` a value of 1 if device `device` is capable of directly accessing memory from `peerDevice` and 0 otherwise. If direct access of `peerDevice` from `device` is possible, then access may be enabled by calling [`cudaDeviceEnablePeerAccess`].
///
/// # Parameters
///
/// - `canAccessPeer`: Returned access capability.
/// - `device`: Device from which allocations on `peerDevice` are to be directly accessed.
/// - `peerDevice`: Device on which the allocations to be directly accessed by `device` reside.
pub fn cudaDeviceCanAccessPeer(
canAccessPeer: *mut ::core::ffi::c_int,
device: ::core::ffi::c_int,
peerDevice: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Enables direct access to memory allocations on a peer device.
///
/// On success, all allocations from `peerDevice` will immediately be accessible by the current device. They will remain accessible until access is explicitly disabled using [`cudaDeviceDisablePeerAccess`] or either device is reset using [`cudaDeviceReset`].
///
/// Note that access granted by this call is unidirectional and that in order to access memory on the current device from `peerDevice`, a separate symmetric call to [`cudaDeviceEnablePeerAccess`] 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 [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a938c6e8b96ecde62e3ab5137156f739a) if [`cudaDeviceCanAccessPeer`] indicates that the current device cannot directly access memory from `peerDevice`.
///
/// Returns [cudaErrorPeerAccessAlreadyEnabled](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a0bc28e8217afa14b95f907631cb84f33) if direct access of `peerDevice` from the current device has already been enabled.
///
/// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if `flags` is not 0.
///
/// # Parameters
///
/// - `peerDevice`: Peer device to enable direct access to from the current device.
/// - `flags`: Reserved for future use and must be set to 0.
pub fn cudaDeviceEnablePeerAccess(
peerDevice: ::core::ffi::c_int,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Disables direct access to memory allocations on a peer device.
///
/// Returns [cudaErrorPeerAccessNotEnabled](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a821b54bce59b87db6efc2ea59a867bf7) if direct access to memory on `peerDevice` has not yet been enabled from the current device.
///
/// # Parameters
///
/// - `peerDevice`: - Peer device to disable direct access to
pub fn cudaDeviceDisablePeerAccess(peerDevice: ::core::ffi::c_int) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ac4673247aee4d1ab8d07871f376e0273) is returned.
///
/// # Parameters
///
/// - `resource`: - Resource to unregister
pub fn cudaGraphicsUnregisterResource(
resource: cudaGraphicsResource_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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:
///
/// If `resource` is presently mapped for access by CUDA then [cudaErrorUnknown](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e491daacef266c7b3e3c1e140a6133c) is returned. If `flags` is not one of the above values then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// # Parameters
///
/// - `resource`: Registered resource to set flags for.
/// - `flags`: Parameters for resource mapping.
pub fn cudaGraphicsResourceSetMapFlags(
resource: cudaGraphicsResource_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaGraphicsMapResources`] will complete before any subsequent CUDA work issued in `stream` begins.
///
/// If `resources` contains any duplicate entries then [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ac4673247aee4d1ab8d07871f376e0273) is returned. If any of `resources` are presently mapped for access by CUDA then [cudaErrorUnknown](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e491daacef266c7b3e3c1e140a6133c) is returned.
///
/// # Parameters
///
/// - `count`: Number of resources to map.
/// - `resources`: Resources to map for CUDA.
/// - `stream`: Stream for synchronization.
pub fn cudaGraphicsMapResources(
count: ::core::ffi::c_int,
resources: *mut cudaGraphicsResource_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaGraphicsUnmapResources`] will complete before any subsequently issued graphics work begins.
///
/// If `resources` contains any duplicate entries then [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ac4673247aee4d1ab8d07871f376e0273) is returned. If any of `resources` are not presently mapped for access by CUDA then [cudaErrorUnknown](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e491daacef266c7b3e3c1e140a6133c) is returned.
///
/// # Parameters
///
/// - `count`: Number of resources to unmap.
/// - `resources`: Resources to unmap.
/// - `stream`: Stream for synchronization.
pub fn cudaGraphicsUnmapResources(
count: ::core::ffi::c_int,
resources: *mut cudaGraphicsResource_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Get an device pointer through which to access a mapped graphics resource.
///
/// Returns in `*devPtr` a pointer through which the mapped graphics resource `resource` may be accessed. Returns in `*size` the size of the memory in bytes which may be accessed from that pointer. The value set in `devPtr` may change every time that `resource` is mapped.
///
/// If `resource` is not a buffer then it cannot be accessed via a pointer and [cudaErrorUnknown](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e491daacef266c7b3e3c1e140a6133c) is returned. If `resource` is not mapped then [cudaErrorUnknown](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e491daacef266c7b3e3c1e140a6133c) is returned.
///
/// # Parameters
///
/// - `devPtr`: Returned pointer through which `resource` may be accessed.
/// - `size`: Returned size of the buffer accessible starting at `*devPtr`.
/// - `resource`: Mapped resource to access.
pub fn cudaGraphicsResourceGetMappedPointer(
devPtr: *mut *mut ::core::ffi::c_void,
size: *mut size_t,
resource: cudaGraphicsResource_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Get an array through which to access a subresource of a mapped graphics resource.
///
/// Returns in `*array` 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 `array` may change every time that `resource` is mapped.
///
/// If `resource` is not a texture then it cannot be accessed via an array and [cudaErrorUnknown](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e491daacef266c7b3e3c1e140a6133c) is returned. If `arrayIndex` is not a valid array index for `resource` then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned. If `mipLevel` is not a valid mipmap level for `resource` then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned. If `resource` is not mapped then [cudaErrorUnknown](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e491daacef266c7b3e3c1e140a6133c) is returned.
///
/// # Parameters
///
/// - `array`: 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 [cudaGraphicsCubeFace](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gabf3ce16a621826a09263b8a58902fee8) for cubemap textures for the subresource to access.
/// - `mipLevel`: Mipmap level for the subresource to access.
pub fn cudaGraphicsSubResourceGetMappedArray(
array: *mut cudaArray_t,
resource: cudaGraphicsResource_t,
arrayIndex: ::core::ffi::c_uint,
mipLevel: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Get a mipmapped array through which to access a mapped graphics resource.
///
/// Returns in `*mipmappedArray` a mipmapped array through which the mapped graphics resource `resource` may be accessed. The value set in `mipmappedArray` may change every time that `resource` is mapped.
///
/// If `resource` is not a texture then it cannot be accessed via an array and [cudaErrorUnknown](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e491daacef266c7b3e3c1e140a6133c) is returned. If `resource` is not mapped then [cudaErrorUnknown](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e491daacef266c7b3e3c1e140a6133c) is returned.
///
/// # Parameters
///
/// - `mipmappedArray`: Returned mipmapped array through which `resource` may be accessed.
/// - `resource`: Mapped resource to access.
pub fn cudaGraphicsResourceGetMappedMipmappedArray(
mipmappedArray: *mut cudaMipmappedArray_t,
resource: cudaGraphicsResource_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Get the channel descriptor of an array.
///
/// Returns in `*desc` the channel descriptor of the CUDA array `array`.
///
/// # Parameters
///
/// - `desc`: Channel format.
/// - `array`: Memory array on device.
pub fn cudaGetChannelDesc(
desc: *mut cudaChannelFormatDesc,
array: cudaArray_const_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a channel descriptor using the specified format
///
/// Returns a channel descriptor with format `f` and number of bits of each component `x`, `y`, `z`, and `w`. The ::cudaChannelFormatDesc is defined as:
///
///
///
/// ```text
/// struct cudaChannelFormatDesc {
/// int x, y, z, w;
/// enum cudaChannelFormatKind f;
/// };
/// ```
///
/// where ::cudaChannelFormatKind is one of ::cudaChannelFormatKindSigned, ::cudaChannelFormatKindUnsigned, or ::cudaChannelFormatKindFloat.
///
///
///
///
///
/// # Return value
///
/// Channel descriptor with format `f`
///
///
///
/// See also: `::cudaCreateChannelDesc(void)` "cudaCreateChannelDesc (C++ API)", ::cudaGetChannelDesc, ::cudaCreateTextureObject, ::cudaCreateSurfaceObject
///
/// # Parameters
///
/// - `x`: - X component
/// - `y`: - Y component
/// - `z`: - Z component
/// - `w`: - W component
/// - `f`: - Channel format
pub fn cudaCreateChannelDesc(
x: ::core::ffi::c_int,
y: ::core::ffi::c_int,
z: ::core::ffi::c_int,
w: ::core::ffi::c_int,
f: cudaChannelFormatKind,
) -> cudaChannelFormatDesc;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaResourceDesc`] structure is defined as:
///
/// The [`cudaTextureDesc`] struct is defined as
///
/// The [`cudaResourceViewDesc`] struct is defined as.
///
/// # Parameters
///
/// - `pTexObject`: Texture object to create.
/// - `pResDesc`: Resource descriptor.
/// - `pTexDesc`: Texture descriptor.
/// - `pResViewDesc`: Resource view descriptor.
pub fn cudaCreateTextureObject(
pTexObject: *mut cudaTextureObject_t,
pResDesc: *const cudaResourceDesc,
pTexDesc: *const cudaTextureDesc,
pResViewDesc: *const cudaResourceViewDesc,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Destroys a texture object.
///
/// Destroys the texture object specified by `texObject`.
///
/// # Parameters
///
/// - `texObject`: - Texture object to destroy
pub fn cudaDestroyTextureObject(texObject: cudaTextureObject_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a texture object’s resource descriptor.
///
/// Returns the resource descriptor for the texture object specified by `texObject`.
///
/// # Parameters
///
/// - `pResDesc`: Resource descriptor.
/// - `texObject`: Texture object.
pub fn cudaGetTextureObjectResourceDesc(
pResDesc: *mut cudaResourceDesc,
texObject: cudaTextureObject_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a texture object’s texture descriptor.
///
/// Returns the texture descriptor for the texture object specified by `texObject`.
///
/// # Parameters
///
/// - `pTexDesc`: Texture descriptor.
/// - `texObject`: Texture object.
pub fn cudaGetTextureObjectTextureDesc(
pTexDesc: *mut cudaTextureDesc,
texObject: cudaTextureObject_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 specified, [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// # Parameters
///
/// - `pResViewDesc`: Resource view descriptor.
/// - `texObject`: Texture object.
pub fn cudaGetTextureObjectResourceViewDesc(
pResViewDesc: *mut cudaResourceViewDesc,
texObject: cudaTextureObject_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a surface object.
///
/// Creates a surface object and returns it in `pSurfObject`. `pResDesc` describes the data to perform surface load/stores on. [cudaResourceDesc::resType](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaResourceDesc.html#structcudaresourcedesc_1aaac8b3bb1d63bd25d8e9af7ee0b9a580) must be [`cudaResourceType::cudaResourceTypeArray`] and ::cudaResourceDesc::res::array::array must be set to a valid CUDA array handle.
///
/// 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.
///
/// # Parameters
///
/// - `pSurfObject`: Surface object to create.
/// - `pResDesc`: Resource descriptor.
pub fn cudaCreateSurfaceObject(
pSurfObject: *mut cudaSurfaceObject_t,
pResDesc: *const cudaResourceDesc,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Destroys a surface object.
///
/// Destroys the surface object specified by `surfObject`.
///
/// # Parameters
///
/// - `surfObject`: - Surface object to destroy
pub fn cudaDestroySurfaceObject(surfObject: cudaSurfaceObject_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a surface object’s resource descriptor Returns the resource descriptor for the surface object specified by `surfObject`.
///
/// # Parameters
///
/// - `pResDesc`: Resource descriptor.
/// - `surfObject`: Surface object.
pub fn cudaGetSurfaceObjectResourceDesc(
pResDesc: *mut cudaResourceDesc,
surfObject: cudaSurfaceObject_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the latest version of CUDA supported by the driver.
///
/// Returns in `*driverVersion` the latest 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. If no driver is installed, then 0 is returned as the driver version.
///
/// This function automatically returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if `driverVersion` is NULL.
///
/// # Parameters
///
/// - `driverVersion`: - Returns the CUDA driver version.
pub fn cudaDriverGetVersion(driverVersion: *mut ::core::ffi::c_int) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the CUDA Runtime version.
///
/// Returns in `*runtimeVersion` the version number of the current CUDA Runtime instance. The version is returned as (1000 major + 10 minor). For example, CUDA 9.2 would be represented by 9020.
///
/// As of CUDA 12.0, this function no longer initializes CUDA. The purpose of this API is solely to return a compile-time constant stating the CUDA Toolkit version in the above format.
///
/// As of CUDA 13.0, on Windows, the `runtimeVersion` may not be the same as the CUDA Toolkit version the app was built with. Windows will use the CUDA Runtime packaged with the display driver, and that version will be reported.
///
/// This function automatically returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if the `runtimeVersion` argument is NULL.
///
/// # Parameters
///
/// - `runtimeVersion`: - Returns the CUDA Runtime version.
pub fn cudaRuntimeGetVersion(runtimeVersion: *mut ::core::ffi::c_int) -> cudaError_t;
}
/// Type of public error reporting callback functions.
///
/// User parameter provided at registration
///
/// Severity level of the log message
///
/// Error log message being reported
///
/// Length of the message in bytes
pub type cudaLogsCallback_t = ::core::option::Option<
unsafe extern "C" fn(
data: *mut ::core::ffi::c_void,
logLevel: cudaLogLevel,
message: *mut ::core::ffi::c_char,
length: size_t,
),
>;
singe_loader::functions! { crate::RUNTIME;
/// 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 cudaLogsRegisterCallback(
callbackFunc: cudaLogsCallback_t,
userData: *mut ::core::ffi::c_void,
callback_out: *mut cudaLogsCallbackHandle,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Unregister a log message callback.
///
/// # Parameters
///
/// - `callback`: - The callback instance to unregister from receiving log messages
pub fn cudaLogsUnregisterCallback(callback: cudaLogsCallbackHandle) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 cudaLogsCurrent(
iterator_out: *mut cudaLogIterator,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaLogsDumpToFile(
iterator: *mut cudaLogIterator,
pathToFile: *const ::core::ffi::c_char,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 ::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 ::CUDA_ERROR_INVALID_VALUE.
///
/// # 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 cudaLogsDumpToMemory(
iterator: *mut cudaLogIterator,
buffer: *mut ::core::ffi::c_char,
size: *mut size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a graph.
///
/// Creates an empty graph, which is returned via `pGraph`.
///
/// # Parameters
///
/// - `pGraph`: Returns newly created graph.
/// - `flags`: Graph creation flags, must be 0.
pub fn cudaGraphCreate(
pGraph: *mut cudaGraph_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a kernel execution node and adds it to a graph.
///
/// Creates a new kernel execution node and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies` and arguments specified in `pNodeParams`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// The [`cudaKernelNodeParams`] structure is defined as:
///
/// When the graph is launched, the node will invoke kernel `func` on a (`gridDim.x` x `gridDim.y` x `gridDim.z`) grid of blocks. Each block contains (`blockDim.x` x `blockDim.y` x `blockDim.z`) threads.
///
/// `sharedMem` 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 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.
///
/// The error [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) will be returned if kernel parameters are specified with both `kernelParams` and `extra` (i.e. both `kernelParams` and `extra` are non-NULL).
///
/// The `kernelParams` or `extra` array, as well as the argument values it points to, are copied during this call.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `pNodeParams`: Parameters for the GPU execution node.
pub fn cudaGraphAddKernelNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
pNodeParams: *const cudaKernelNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a kernel node’s parameters.
///
/// Returns the parameters of kernel node `node` in `pNodeParams`. The `kernelParams` or `extra` array returned in `pNodeParams`, 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 [`cudaGraphKernelNodeSetParams`] 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.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
pub fn cudaGraphKernelNodeGetParams(
node: cudaGraphNode_t,
pNodeParams: *mut cudaKernelNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets a kernel node’s parameters.
///
/// Sets the parameters of kernel node `node` to `pNodeParams`.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
pub fn cudaGraphKernelNodeSetParams(
node: cudaGraphNode_t,
pNodeParams: *const cudaKernelNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies attributes from source node to destination node.
///
/// Copies attributes from source node `hSrc` to destination node `hDst`. Both node must have the same context.
///
/// # Parameters
///
/// - `hDst`: Destination node.
/// - `hSrc`: Source node For list of attributes see cudaKernelNodeAttrID.
pub fn cudaGraphKernelNodeCopyAttributes(
hDst: cudaGraphNode_t,
hSrc: cudaGraphNode_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Queries node attribute.
///
/// Queries attribute `attr` from node `hNode` and stores it in corresponding member of `value_out`.
pub fn cudaGraphKernelNodeGetAttribute(
hNode: cudaGraphNode_t,
attr: cudaLaunchAttributeID,
value_out: *mut cudaLaunchAttributeValue,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets node attribute.
///
/// Sets attribute `attr` on node `hNode` from corresponding attribute of `value`.
pub fn cudaGraphKernelNodeSetAttribute(
hNode: cudaGraphNode_t,
attr: cudaLaunchAttributeID,
value: *const cudaLaunchAttributeValue,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a memcpy node and adds it to a graph.
///
/// Creates a new memcpy node and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// When the graph is launched, the node will perform the memcpy described by `pCopyParams`. See [`cudaMemcpy3D`] 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09).
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `pCopyParams`: Parameters for the memory copy.
pub fn cudaGraphAddMemcpyNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
pCopyParams: *const cudaMemcpy3DParms,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a memcpy node to copy to a symbol on the device and adds it to a graph.
///
/// Creates a new memcpy node to copy to `symbol` and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// When the graph is launched, the node will copy `count` bytes from the memory area pointed to by `src` to the memory area pointed to by `offset` bytes from the start of symbol `symbol`. The memory areas may not overlap. `symbol` is a variable that resides in global or constant memory space. `kind` can be either [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09).
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `symbol`: Device symbol address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphAddMemcpyNodeToSymbol(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a memcpy node to copy from a symbol on the device and adds it to a graph.
///
/// Creates a new memcpy node to copy from `symbol` and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// When the graph is launched, the node will copy `count` bytes from the memory area pointed to by `offset` bytes from the start of symbol `symbol` to the memory area pointed to by `dst`. The memory areas may not overlap. `symbol` is a variable that resides in global or constant memory space. `kind` can be either [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09).
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphAddMemcpyNodeFromSymbol(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a 1D memcpy node and adds it to a graph.
///
/// Creates a new 1D memcpy node and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// When the graph is launched, the node will copy `count` bytes from the memory area pointed to by `src` to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that do not match the direction of the copy results in an undefined behavior.
///
/// 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 [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga49e2f8c2c0bd6fe264f2fc970912e5cdac88178f29891f2c18fe67361cc80de09).
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
pub fn cudaGraphAddMemcpyNode1D(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a memcpy node’s parameters.
///
/// Returns the parameters of memcpy node `node` in `pNodeParams`.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
pub fn cudaGraphMemcpyNodeGetParams(
node: cudaGraphNode_t,
pNodeParams: *mut cudaMemcpy3DParms,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets a memcpy node’s parameters.
///
/// Sets the parameters of memcpy node `node` to `pNodeParams`.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
pub fn cudaGraphMemcpyNodeSetParams(
node: cudaGraphNode_t,
pNodeParams: *const cudaMemcpy3DParms,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets a memcpy node’s parameters to copy to a symbol on the device.
///
/// Sets the parameters of memcpy node `node` to the copy described by the provided parameters.
///
/// When the graph is launched, the node will copy `count` bytes from the memory area pointed to by `src` to the memory area pointed to by `offset` bytes from the start of symbol `symbol`. The memory areas may not overlap. `symbol` is a variable that resides in global or constant memory space. `kind` can be either [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `symbol`: Device symbol address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphMemcpyNodeSetParamsToSymbol(
node: cudaGraphNode_t,
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets a memcpy node’s parameters to copy from a symbol on the device.
///
/// Sets the parameters of memcpy node `node` to the copy described by the provided parameters.
///
/// When the graph is launched, the node will copy `count` bytes from the memory area pointed to by `offset` bytes from the start of symbol `symbol` to the memory area pointed to by `dst`. The memory areas may not overlap. `symbol` is a variable that resides in global or constant memory space. `kind` can be either [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphMemcpyNodeSetParamsFromSymbol(
node: cudaGraphNode_t,
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets a memcpy node’s parameters to perform a 1-dimensional copy.
///
/// Sets the parameters of memcpy node `node` to the copy described by the provided parameters.
///
/// When the graph is launched, the node will copy `count` bytes from the memory area pointed to by `src` to the memory area pointed to by `dst`, where `kind` specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that do not match the direction of the copy results in an undefined behavior.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
pub fn cudaGraphMemcpyNodeSetParams1D(
node: cudaGraphNode_t,
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a memset node and adds it to a graph.
///
/// Creates a new memset node and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// The element size must be 1, 2, or 4 bytes. When the graph is launched, the node will perform the memset described by `pMemsetParams`.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `pMemsetParams`: Parameters for the memory set.
pub fn cudaGraphAddMemsetNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
pMemsetParams: *const cudaMemsetParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a memset node’s parameters.
///
/// Returns the parameters of memset node `node` in `pNodeParams`.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
pub fn cudaGraphMemsetNodeGetParams(
node: cudaGraphNode_t,
pNodeParams: *mut cudaMemsetParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets a memset node’s parameters.
///
/// Sets the parameters of memset node `node` to `pNodeParams`.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
pub fn cudaGraphMemsetNodeSetParams(
node: cudaGraphNode_t,
pNodeParams: *const cudaMemsetParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a host execution node and adds it to a graph.
///
/// Creates a new CPU execution node and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies` and arguments specified in `pNodeParams`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// When the graph is launched, the node will invoke the specified CPU function. Host nodes are not supported under MPS with pre-Volta GPUs.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `pNodeParams`: Parameters for the host node.
pub fn cudaGraphAddHostNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
pNodeParams: *const cudaHostNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a host node’s parameters.
///
/// Returns the parameters of host node `node` in `pNodeParams`.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
pub fn cudaGraphHostNodeGetParams(
node: cudaGraphNode_t,
pNodeParams: *mut cudaHostNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets a host node’s parameters.
///
/// Sets the parameters of host node `node` to `nodeParams`.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
pub fn cudaGraphHostNodeSetParams(
node: cudaGraphNode_t,
pNodeParams: *const cudaHostNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a child graph node and adds it to a graph.
///
/// Creates a new node which executes an embedded graph, and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// 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.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `childGraph`: The graph to clone into this node.
pub fn cudaGraphAddChildGraphNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
childGraph: cudaGraph_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `node`: Node to get the embedded graph for.
/// - `pGraph`: Location to store a handle to the graph.
pub fn cudaGraphChildGraphNodeGetGraph(
node: cudaGraphNode_t,
pGraph: *mut cudaGraph_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates an empty node and adds it to a graph.
///
/// Creates a new node which performs no operation, and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// 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.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
pub fn cudaGraphAddEmptyNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// These nodes may not be used in loops or conditionals.
///
/// # Parameters
///
/// - `numDependencies`: Number of dependencies.
/// - `event`: Event for the node.
pub fn cudaGraphAddEventRecordNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
event: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the event associated with an event record node.
///
/// Returns the event of event record node `hNode` in `event_out`.
///
/// # Parameters
///
/// - `event_out`: Pointer to return the event.
pub fn cudaGraphEventRecordNodeGetEvent(
node: cudaGraphNode_t,
event_out: *mut cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets an event record node’s event.
///
/// Sets the event of event record node `hNode` to `event`.
///
/// # Parameters
///
/// - `event`: Event to use.
pub fn cudaGraphEventRecordNodeSetEvent(
node: cudaGraphNode_t,
event: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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. The synchronization will be performed efficiently on the device when applicable. `event` may be from a different context or device than the launch stream.
///
/// These nodes may not be used in loops or conditionals.
///
/// # Parameters
///
/// - `numDependencies`: Number of dependencies.
/// - `event`: Event for the node.
pub fn cudaGraphAddEventWaitNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
event: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the event associated with an event wait node.
///
/// Returns the event of event wait node `hNode` in `event_out`.
///
/// # Parameters
///
/// - `event_out`: Pointer to return the event.
pub fn cudaGraphEventWaitNodeGetEvent(
node: cudaGraphNode_t,
event_out: *mut cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets an event wait node’s event.
///
/// Sets the event of event wait node `hNode` to `event`.
///
/// # Parameters
///
/// - `event`: Event to use.
pub fn cudaGraphEventWaitNodeSetEvent(
node: cudaGraphNode_t,
event: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates an external semaphore signal node and adds it to a graph.
///
/// Creates a new external semaphore signal node and adds it to `graph` 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 `pGraphNode`.
///
/// 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.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cudaGraphAddExternalSemaphoresSignalNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
nodeParams: *const cudaExternalSemaphoreSignalNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaGraphExternalSemaphoresSignalNodeSetParams`] to update the parameters of this node.
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
pub fn cudaGraphExternalSemaphoresSignalNodeGetParams(
hNode: cudaGraphNode_t,
params_out: *mut cudaExternalSemaphoreSignalNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets an external semaphore signal node’s parameters.
///
/// Sets the parameters of an external semaphore signal node `hNode` to `nodeParams`.
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cudaGraphExternalSemaphoresSignalNodeSetParams(
hNode: cudaGraphNode_t,
nodeParams: *const cudaExternalSemaphoreSignalNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates an external semaphore wait node and adds it to a graph.
///
/// Creates a new external semaphore wait node and adds it to `graph` 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 `pGraphNode`.
///
/// 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.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cudaGraphAddExternalSemaphoresWaitNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
nodeParams: *const cudaExternalSemaphoreWaitNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaGraphExternalSemaphoresSignalNodeSetParams`] to update the parameters of this node.
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
pub fn cudaGraphExternalSemaphoresWaitNodeGetParams(
hNode: cudaGraphNode_t,
params_out: *mut cudaExternalSemaphoreWaitNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets an external semaphore wait node’s parameters.
///
/// Sets the parameters of an external semaphore wait node `hNode` to `nodeParams`.
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cudaGraphExternalSemaphoresWaitNodeSetParams(
hNode: cudaGraphNode_t,
nodeParams: *const cudaExternalSemaphoreWaitNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates an allocation node and adds it to a graph.
///
/// Creates a new allocation node and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies` 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. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// When [`cudaGraphAddMemAllocNode`] 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 [`cudaGraphAddMemFreeNode`], 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:
///
/// 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.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cudaGraphAddMemAllocNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
nodeParams: *mut cudaMemAllocNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
pub fn cudaGraphMemAllocNodeGetParams(
node: cudaGraphNode_t,
params_out: *mut cudaMemAllocNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a memory free node and adds it to a graph.
///
/// Creates a new memory free node and adds it to `graph` with `numDependencies` dependencies specified via `pDependencies` and address specified in `dptr`. It is possible for `numDependencies` to be 0, in which case the node will be placed at the root of the graph. `pDependencies` may not have any duplicate entries. A handle to the new node will be returned in `pGraphNode`.
///
/// [`cudaGraphAddMemFreeNode`] will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if the user attempts to free:
///
/// The following restrictions apply to graphs which contain allocation and/or memory free nodes.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `dptr`: Address of memory to free.
pub fn cudaGraphAddMemFreeNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
dptr: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a memory free node’s parameters.
///
/// Returns the address of a memory free node `hNode` in `dptr_out`.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `dptr_out`: Pointer to return the device address.
pub fn cudaGraphMemFreeNodeGetParams(
node: cudaGraphNode_t,
dptr_out: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `device`: - The device for which cached memory should be freed.
pub fn cudaDeviceGraphMemTrim(device: ::core::ffi::c_int) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Query asynchronous allocation attributes related to graphs.
///
/// Valid attributes are.
///
/// # Parameters
///
/// - `device`: Specifies the scope of the query.
/// - `attr`: attribute to get.
/// - `value`: retrieved value.
pub fn cudaDeviceGetGraphMemAttribute(
device: ::core::ffi::c_int,
attr: cudaGraphMemAttributeType,
value: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Set asynchronous allocation attributes related to graphs.
///
/// Valid attributes are.
///
/// # Parameters
///
/// - `device`: Specifies the scope of the query.
/// - `attr`: attribute to get.
/// - `value`: pointer to value to set.
pub fn cudaDeviceSetGraphMemAttribute(
device: ::core::ffi::c_int,
attr: cudaGraphMemAttributeType,
value: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Clones a graph.
///
/// This function creates a copy of `originalGraph` and returns it in `pGraphClone`. 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.
///
/// # Parameters
///
/// - `pGraphClone`: Returns newly created cloned graph.
/// - `originalGraph`: Graph to clone.
pub fn cudaGraphClone(
pGraphClone: *mut cudaGraph_t,
originalGraph: cudaGraph_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Finds a cloned version of a node.
///
/// This function returns the node in `clonedGraph` corresponding to `originalNode` in the original graph.
///
/// `clonedGraph` must have been cloned from `originalGraph` via [`cudaGraphClone`]. `originalNode` must have been in `originalGraph` at the time of the call to [`cudaGraphClone`], and the corresponding cloned node in `clonedGraph` must not have been removed. The cloned node is then returned via `pClonedNode`.
///
/// # Parameters
///
/// - `pNode`: Returns handle to the cloned node.
/// - `originalNode`: Handle to the original node.
/// - `clonedGraph`: Cloned graph to query.
pub fn cudaGraphNodeFindInClone(
pNode: *mut cudaGraphNode_t,
originalNode: cudaGraphNode_t,
clonedGraph: cudaGraph_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a node’s type.
///
/// Returns the node type of `node` in `pType`.
///
/// # Parameters
///
/// - `node`: Node to query.
/// - `pType`: Pointer to return the node type.
pub fn cudaGraphNodeGetType(
node: cudaGraphNode_t,
pType: *mut cudaGraphNodeType,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `hNode`: Node to query.
/// - `phGraph`: Pointer to return the containing graph.
pub fn cudaGraphNodeGetContainingGraph(
hNode: cudaGraphNode_t,
phGraph: *mut cudaGraph_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the node id of a given graph node.
///
/// Returns the node id of `hNode` in `*nodeId`. The nodeId matches that referenced by [`cudaGraphDebugDotPrint`]. The local nodeId and graphId together can uniquely identify the node.
///
/// # Parameters
///
/// - `hNode`: Node to query.
/// - `nodeId`: Pointer to return the nodeId.
pub fn cudaGraphNodeGetLocalId(
hNode: cudaGraphNode_t,
nodeId: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns an id used by tools to identify a given node.
///
/// # Parameters
///
/// - `hNode`: Node to query.
pub fn cudaGraphNodeGetToolsId(
hNode: cudaGraphNode_t,
toolsNodeId: *mut ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the id of a given graph.
///
/// Returns the id of `hGraph` in `*graphId`. The value in `*graphId` matches that referenced by [`cudaGraphDebugDotPrint`].
///
/// # Parameters
///
/// - `hGraph`: Graph to query.
pub fn cudaGraphGetId(
hGraph: cudaGraph_t,
graphID: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the id of a given graph exec.
///
/// Returns the id of `hGraphExec` in `*graphId`. The value in `*graphId` matches that referenced by [`cudaGraphDebugDotPrint`].
///
/// # Parameters
///
/// - `hGraphExec`: Graph to query.
pub fn cudaGraphExecGetId(
hGraphExec: cudaGraphExec_t,
graphID: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a graph’s nodes.
///
/// Returns a list of `graph'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`.
///
/// # Parameters
///
/// - `graph`: Graph to query.
/// - `nodes`: Pointer to return the nodes.
/// - `numNodes`: See description.
pub fn cudaGraphGetNodes(
graph: cudaGraph_t,
nodes: *mut cudaGraphNode_t,
numNodes: *mut size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a graph’s root nodes.
///
/// Returns a list of `graph's` root nodes. `pRootNodes` may be NULL, in which case this function will return the number of root nodes in `pNumRootNodes`. Otherwise, `pNumRootNodes` entries will be filled in. If `pNumRootNodes` is higher than the actual number of root nodes, the remaining entries in `pRootNodes` will be set to NULL, and the number of nodes actually obtained will be returned in `pNumRootNodes`.
///
/// # Parameters
///
/// - `graph`: Graph to query.
/// - `pRootNodes`: Pointer to return the root nodes.
/// - `pNumRootNodes`: See description.
pub fn cudaGraphGetRootNodes(
graph: cudaGraph_t,
pRootNodes: *mut cudaGraphNode_t,
pNumRootNodes: *mut size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a graph’s dependency edges.
///
/// Returns a list of `graph'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 losst query via NULL `edgeData` will result in [cudaErrorLossyQuery](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad484d9d8e8f269cf93d4c111b646f908). If `edgeData` is non-NULL then `from` and `to` must be as well.
///
/// # Parameters
///
/// - `graph`: 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 cudaGraphGetEdges(
graph: cudaGraph_t,
from: *mut cudaGraphNode_t,
to: *mut cudaGraphNode_t,
edgeData: *mut cudaGraphEdgeData,
numEdges: *mut size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a node’s dependencies.
///
/// Returns a list of `node's` dependencies. `pDependencies` may be NULL, in which case this function will return the number of dependencies in `pNumDependencies`. Otherwise, `pNumDependencies` entries will be filled in. If `pNumDependencies` is higher than the actual number of dependencies, the remaining entries in `pDependencies` will be set to NULL, and the number of nodes actually obtained will be returned in `pNumDependencies`.
///
/// Note that if an edge has non-zero (non-default) edge data and `edgeData` is NULL, this API will return [cudaErrorLossyQuery](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad484d9d8e8f269cf93d4c111b646f908). If `edgeData` is non-NULL, then `pDependencies` must be as well.
///
/// # Parameters
///
/// - `node`: Node to query.
/// - `pDependencies`: Pointer to return the dependencies.
/// - `edgeData`: Optional array to return edge data for each dependency.
/// - `pNumDependencies`: See description.
pub fn cudaGraphNodeGetDependencies(
node: cudaGraphNode_t,
pDependencies: *mut cudaGraphNode_t,
edgeData: *mut cudaGraphEdgeData,
pNumDependencies: *mut size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a node’s dependent nodes.
///
/// Returns a list of `node's` dependent nodes. `pDependentNodes` may be NULL, in which case this function will return the number of dependent nodes in `pNumDependentNodes`. Otherwise, `pNumDependentNodes` entries will be filled in. If `pNumDependentNodes` is higher than the actual number of dependent nodes, the remaining entries in `pDependentNodes` will be set to NULL, and the number of nodes actually obtained will be returned in `pNumDependentNodes`.
///
/// Note that if an edge has non-zero (non-default) edge data and `edgeData` is NULL, this API will return [cudaErrorLossyQuery](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad484d9d8e8f269cf93d4c111b646f908). If `edgeData` is non-NULL, then `pDependentNodes` must be as well.
///
/// # Parameters
///
/// - `node`: Node to query.
/// - `pDependentNodes`: Pointer to return the dependent nodes.
/// - `edgeData`: Optional pointer to return edge data for dependent nodes.
/// - `pNumDependentNodes`: See description.
pub fn cudaGraphNodeGetDependentNodes(
node: cudaGraphNode_t,
pDependentNodes: *mut cudaGraphNode_t,
edgeData: *mut cudaGraphEdgeData,
pNumDependentNodes: *mut size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Adds dependency edges to a graph.
///
/// The number of dependencies to be added is defined by `numDependencies` Elements in `pFrom` and `pTo` at corresponding indices define a dependency. Each node in `pFrom` and `pTo` must belong to `graph`.
///
/// If `numDependencies` is 0, elements in `pFrom` and `pTo` will be ignored. Specifying an existing dependency will return an error.
///
/// # Parameters
///
/// - `graph`: 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 cudaGraphAddDependencies(
graph: cudaGraph_t,
from: *const cudaGraphNode_t,
to: *const cudaGraphNode_t,
edgeData: *const cudaGraphEdgeData,
numDependencies: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Removes dependency edges from a graph.
///
/// The number of `pDependencies` to be removed is defined by `numDependencies`. Elements in `pFrom` and `pTo` at corresponding indices define a dependency. Each node in `pFrom` and `pTo` must belong to `graph`.
///
/// If `numDependencies` is 0, elements in `pFrom` and `pTo` 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.
///
/// # Parameters
///
/// - `graph`: 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 cudaGraphRemoveDependencies(
graph: cudaGraph_t,
from: *const cudaGraphNode_t,
to: *const cudaGraphNode_t,
edgeData: *const cudaGraphEdgeData,
numDependencies: size_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Remove a node from the graph.
///
/// Removes `node` from its graph. This operation also severs any dependencies of other nodes on `node` and vice versa.
///
/// Dependencies cannot be removed from graphs which contain allocation or free nodes. Any attempt to do so will return an error.
///
/// # Parameters
///
/// - `node`: - Node to remove
pub fn cudaGraphDestroyNode(node: cudaGraphNode_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates an executable graph from a graph
///
/// Instantiates `graph` as an executable graph. 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 `pGraphExec`.
///
/// The `flags` parameter controls the behavior of instantiation and subsequent graph launches. Valid flags are:
///
/// - ::cudaGraphInstantiateFlagAutoFreeOnLaunch, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched.
///
/// - ::cudaGraphInstantiateFlagDeviceLaunch, 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 cannot be used in conjunction with ::cudaGraphInstantiateFlagAutoFreeOnLaunch.
///
/// - ::cudaGraphInstantiateFlagUseNodePriority, 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 `graph` 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 ::cudaGraphExecDestroy will result in an error. The same also applies if `graph` contains any device-updatable kernel nodes.
///
/// 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 device.
/// - 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 device, and the current device must match the device of other nodes in the graph.
///
/// If `graph` is not instantiated for launch on the device but contains kernels which call device-side cudaGraphLaunch() from multiple devices, this will result in an error.
///
///
///
///
///
/// # Return value
///
/// ::cudaSuccess, ::cudaErrorInvalidValue
///
/// Note: _graph_thread_safety
///
/// Note: _init_rt
///
/// Note: _callback
///
///
///
/// See also: ::cudaGraphInstantiateWithFlags, ::cudaGraphCreate, ::cudaGraphUpload, ::cudaGraphLaunch, ::cudaGraphExecDestroy
///
/// # Parameters
///
/// - `pGraphExec`: - Returns instantiated graph
/// - `graph`: - Graph to instantiate
/// - `flags`: - Flags to control instantiation. See ::CUgraphInstantiate_flags.
pub fn cudaGraphInstantiate(
pGraphExec: *mut cudaGraphExec_t,
graph: cudaGraph_t,
flags: ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates an executable graph from a graph.
///
/// Instantiates `graph` as an executable graph. 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 `pGraphExec`.
///
/// The `flags` parameter controls the behavior of instantiation and subsequent graph launches. Valid flags are:
///
/// If `graph` 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 [`cudaGraphExecDestroy`] will result in an error. The same also applies if `graph` contains any device-updatable kernel nodes.
///
/// If `graph` contains kernels which call device-side [`cudaGraphLaunch`] from multiple devices, this will result in an error.
///
/// Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs.
///
/// # Parameters
///
/// - `pGraphExec`: Returns instantiated graph.
/// - `graph`: Graph to instantiate.
/// - `flags`: Flags to control instantiation. See ::CUgraphInstantiate_flags.
pub fn cudaGraphInstantiateWithFlags(
pGraphExec: *mut cudaGraphExec_t,
graph: cudaGraph_t,
flags: ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates an executable graph from a graph.
///
/// Instantiates `graph` 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 `pGraphExec`.
///
/// `instantiateParams` controls the behavior of instantiation and subsequent graph launches, as well as returning more detailed information in the event of an error. [cudaGraphInstantiateParams](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaGraphInstantiateParams.html#structcudagraphinstantiateparams) is defined as:
///
/// The `flags` field controls the behavior of instantiation and subsequent graph launches. Valid flags are:
///
/// If `graph` 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 [`cudaGraphExecDestroy`] will result in an error. The same also applies if `graph` contains any device-updatable kernel nodes.
///
/// If `graph` contains kernels which call device-side [`cudaGraphLaunch`] from multiple devices, this will result in an error.
///
/// Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:
///
/// In the event of an error, the `result_out` and `errNode_out` fields will contain more information about the nature of the error. Possible error reporting includes:
///
/// If instantiation is successful, `result_out` will be set to [cudaGraphInstantiateSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3faefd09000966e3b9d6ca5bcf7b2b9da6b92d94f90110623dafb5fe8081f6f45), and `hErrNode_out` will be set to NULL.
///
/// # Parameters
///
/// - `pGraphExec`: Returns instantiated graph.
/// - `graph`: Graph to instantiate.
/// - `instantiateParams`: Instantiation parameters.
pub fn cudaGraphInstantiateWithParams(
pGraphExec: *mut cudaGraphExec_t,
graph: cudaGraph_t,
instantiateParams: *mut cudaGraphInstantiateParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Query the instantiation flags of an executable graph.
///
/// Returns the flags that were passed to instantiation for the given executable graph. [cudaGraphInstantiateFlagUpload](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a565872dd74cc9d97125bf43740345238) will not be returned by this API as it does not affect the resulting executable graph.
///
/// # Parameters
///
/// - `graphExec`: The executable graph to query.
/// - `flags`: Returns the instantiation flags.
pub fn cudaGraphExecGetFlags(
graphExec: cudaGraphExec_t,
flags: *mut ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 `node` in the non-executable graph, from which the executable graph was instantiated.
///
/// `node` must not have been removed from the original graph. All `nodeParams` fields may change, but the following restrictions apply to `func` updates:
///
/// The modifications only affect future launches of `hGraphExec`. Already enqueued or running launches of `hGraphExec` are not affected by this call. `node` is also not modified by this call.
///
/// If `node` 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.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: kernel node from the graph from which graphExec was instantiated.
/// - `pNodeParams`: Updated Parameters to set.
pub fn cudaGraphExecKernelNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
pNodeParams: *const cudaKernelNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the parameters for a memcpy node in the given graphExec.
///
/// Updates the work represented by `node` in `hGraphExec` as though `node` had contained `pNodeParams` at instantiation. `node` must remain in the graph which was used to instantiate `hGraphExec`. Changed edges to and from `node` are ignored.
///
/// The source and destination memory in `pNodeParams` 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 `pNodeParams` 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. `node` is also not modified by this call.
///
/// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if the memory operands’ mappings changed or either the original or new memory operands are multidimensional.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
/// - `pNodeParams`: Updated Parameters to set.
pub fn cudaGraphExecMemcpyNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
pNodeParams: *const cudaMemcpy3DParms,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the parameters for a memcpy node in the given graphExec to copy to a symbol on the device.
///
/// Updates the work represented by `node` in `hGraphExec` as though `node` had contained the given params at instantiation. `node` must remain in the graph which was used to instantiate `hGraphExec`. Changed edges to and from `node` are ignored.
///
/// `src` and `symbol` must be allocated from the same contexts as the original source and destination memory. The instantiation-time memory operands 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. `node` is also not modified by this call.
///
/// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if the memory operands’ mappings changed or the original memory operands are multidimensional.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
/// - `symbol`: Device symbol address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphExecMemcpyNodeSetParamsToSymbol(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the parameters for a memcpy node in the given graphExec to copy from a symbol on the device.
///
/// Updates the work represented by `node` in `hGraphExec` as though `node` had contained the given params at instantiation. `node` must remain in the graph which was used to instantiate `hGraphExec`. Changed edges to and from `node` are ignored.
///
/// `symbol` and `dst` must be allocated from the same contexts as the original source and destination memory. The instantiation-time memory operands 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. `node` is also not modified by this call.
///
/// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if the memory operands’ mappings changed or the original memory operands are multidimensional.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphExecMemcpyNodeSetParamsFromSymbol(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the parameters for a memcpy node in the given graphExec to perform a 1-dimensional copy.
///
/// Updates the work represented by `node` in `hGraphExec` as though `node` had contained the given params at instantiation. `node` must remain in the graph which was used to instantiate `hGraphExec`. Changed edges to and from `node` are ignored.
///
/// `src` and `dst` must be allocated from the same contexts as the original source and destination memory. The instantiation-time memory operands 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. `node` is also not modified by this call.
///
/// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c) if the memory operands’ mappings changed or the original memory operands are multidimensional.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
pub fn cudaGraphExecMemcpyNodeSetParams1D(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the parameters for a memset node in the given graphExec.
///
/// Updates the work represented by `node` in `hGraphExec` as though `node` had contained `pNodeParams` at instantiation. `node` must remain in the graph which was used to instantiate `hGraphExec`. Changed edges to and from `node` are ignored.
///
/// Zero sized operations are not supported.
///
/// The new destination pointer in `pNodeParams` 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. `node` is also not modified by this call.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memset node from the graph which was used to instantiate graphExec.
/// - `pNodeParams`: Updated Parameters to set.
pub fn cudaGraphExecMemsetNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
pNodeParams: *const cudaMemsetParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets the parameters for a host node in the given graphExec.
///
/// Updates the work represented by `node` in `hGraphExec` as though `node` had contained `pNodeParams` at instantiation. `node` must remain in the graph which was used to instantiate `hGraphExec`. Changed edges to and from `node` are ignored.
///
/// The modifications only affect future launches of `hGraphExec`. Already enqueued or running launches of `hGraphExec` are not affected by this call. `node` is also not modified by this call.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Host node from the graph which was used to instantiate graphExec.
/// - `pNodeParams`: Updated Parameters to set.
pub fn cudaGraphExecHostNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
pNodeParams: *const cudaHostNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Updates node parameters in the child graph node in the given graphExec.
///
/// Updates the work represented by `node` in `hGraphExec` as though the nodes contained in `node's` graph had the parameters contained in `childGraph's` nodes at instantiation. `node` must remain in the graph which was used to instantiate `hGraphExec`. Changed edges to and from `node` are ignored.
///
/// The modifications only affect future launches of `hGraphExec`. Already enqueued or running launches of `hGraphExec` are not affected by this call. `node` 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 `node`. See [`cudaGraphExecUpdate`] 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.
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Host node from the graph which was used to instantiate graphExec.
/// - `childGraph`: The graph supplying the updated parameters.
pub fn cudaGraphExecChildGraphNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
childGraph: cudaGraph_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaGraphExecEventRecordNodeSetEvent(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
event: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaGraphExecEventWaitNodeSetEvent(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
event: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaGraphExecExternalSemaphoresSignalNodeSetParams(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
nodeParams: *const cudaExternalSemaphoreSignalNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaGraphExecExternalSemaphoresWaitNodeSetParams(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
nodeParams: *const cudaExternalSemaphoreWaitNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaGraphNodeSetEnabled(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
isEnabled: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaGraphNodeGetEnabled(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
isEnabled: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 cudaGraphInstantiateFlagUseNodePriority, 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() cannot be updated to a function which uses device-side cudaGraphLaunch() unless the node resides on the same device 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. CU_MEMORYTYPE_DEVICE, CU_MEMORYTYPE_ARRAY, etc.) 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.
///
/// cudaGraphExecUpdate sets the result member of `resultInfo` to cudaGraphExecUpdateErrorTopologyChanged 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.
///
/// cudaGraphExecUpdate sets `the` result member of `resultInfo` to:
/// - cudaGraphExecUpdateError if passed an invalid value.
/// - cudaGraphExecUpdateErrorTopologyChanged if the graph topology changed
/// - cudaGraphExecUpdateErrorNodeTypeChanged if the type of a node changed, in which case `hErrorNode_out` is set to the node from `hGraph`.
/// - cudaGraphExecUpdateErrorFunctionChanged if the function of a kernel node changed (CUDA driver < 11.2)
/// - cudaGraphExecUpdateErrorUnsupportedFunctionChange if the func field of a kernel changed in an unsupported way(see note above), in which case `hErrorNode_out` is set to the node from `hGraph`
/// - cudaGraphExecUpdateErrorParametersChanged 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`
/// - cudaGraphExecUpdateErrorAttributesChanged 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`
/// - cudaGraphExecUpdateErrorNotSupported 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 cudaGraphExecUpdateError. If the update succeeds, the result member will be set to cudaGraphExecUpdateSuccess.
///
/// cudaGraphExecUpdate returns cudaSuccess when the updated was performed successfully. It returns cudaErrorGraphExecUpdateFailure if the graph update was not performed because it included changes which violated constraints specific to instantiated graph update.
///
///
///
///
///
/// # Return value
///
/// ::cudaSuccess, ::cudaErrorGraphExecUpdateFailure,
///
/// Note: _graph_thread_safety
///
/// Note: _init_rt
///
/// Note: _callback
///
///
///
/// See also: ::cudaGraphInstantiate
///
/// # Parameters
///
/// - `hGraphExec`: The instantiated graph to be updated
/// - `hGraph`: The graph containing the updated parameters
/// - `resultInfo`: the error info structure
pub fn cudaGraphExecUpdate(
hGraphExec: cudaGraphExec_t,
hGraph: cudaGraph_t,
resultInfo: *mut cudaGraphExecUpdateResultInfo,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Uploads an executable graph in a stream.
///
/// Uploads `graphExec` to the device in `stream` without executing it. Uploads of the same `graphExec` will be serialized. Each upload is ordered behind both any previous work in `stream` and any previous launches of `graphExec`. Uses memory cached by `stream` to back the allocations owned by `graphExec`.
///
/// # Parameters
///
/// - `graphExec`: Executable graph to upload.
/// - `stream`: Stream in which to upload the graph.
pub fn cudaGraphUpload(
graphExec: cudaGraphExec_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Launches an executable graph in a stream.
///
/// Executes `graphExec` in `stream`. Only one instance of `graphExec` may be executing at a time. Each launch is ordered behind both any previous work in `stream` and any previous launches of `graphExec`. To execute a graph concurrently, it must be instantiated multiple times into multiple executable graphs.
///
/// If any allocations created by `graphExec` remain unfreed (from a previous launch) and `graphExec` was not instantiated with [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a4258c8d3adc203f97e73e92810e1785f), the launch will fail with [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c).
///
/// # Parameters
///
/// - `graphExec`: Executable graph to launch.
/// - `stream`: Stream in which to launch the graph.
pub fn cudaGraphLaunch(
graphExec: cudaGraphExec_t,
stream: cudaStream_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Destroys an executable graph.
///
/// Destroys the executable graph specified by `graphExec`.
///
/// # Parameters
///
/// - `graphExec`: - Executable graph to destroy
pub fn cudaGraphExecDestroy(graphExec: cudaGraphExec_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Destroys a graph.
///
/// Destroys the graph specified by `graph`, as well as all of its nodes.
///
/// # Parameters
///
/// - `graph`: - Graph to destroy
pub fn cudaGraphDestroy(graph: cudaGraph_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Write a DOT file describing graph structure.
///
/// Using the provided `graph`, 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
///
/// - `graph`: The graph to create a DOT file from.
/// - `path`: The path to write the DOT file to.
/// - `flags`: Flags from cudaGraphDebugDotFlags for specifying which additional node information to write.
pub fn cudaGraphDebugDotPrint(
graph: cudaGraph_t,
path: *const ::core::ffi::c_char,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 [cudaUserObjectNoDestructorSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf4748f36762263564ca8a7a47fd902bbaca181af9d994c9a5290b509175ea99fe), 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 cudaUserObjectCreate(
object_out: *mut cudaUserObject_t,
ptr: *mut ::core::ffi::c_void,
destroy: cudaHostFn_t,
initialRefcount: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaUserObjectRetain(
object: cudaUserObject_t,
count: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaUserObjectRelease(
object: cudaUserObject_t,
count: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 [cudaGraphUserObjectMove](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggae53f516fc65103fccb14c83184188157a96b13064f28cdb8932c782b94ab5802f) transfers references from the calling thread, rather than create new references. Pass 0 to create new references.
pub fn cudaGraphRetainUserObject(
graph: cudaGraph_t,
object: cudaUserObject_t,
count: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaGraphReleaseUserObject(
graph: cudaGraph_t,
object: cudaUserObject_t,
count: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Adds a node of arbitrary type to a graph.
///
/// Creates a new node in `graph` described by `nodeParams` with `numDependencies` dependencies specified via `pDependencies`. `numDependencies` may be 0. `pDependencies` may be null if `numDependencies` is 0. `pDependencies` 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`.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: 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 cudaGraphAddNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
dependencyData: *const cudaGraphEdgeData,
numDependencies: size_t,
nodeParams: *mut cudaGraphNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Update a graph node’s parameters.
///
/// Sets the parameters of graph node `node` to `nodeParams`. The node type specified by `nodeParams->type` must match the type of `node`. `nodeParams` must be fully initialized and all unused bytes (reserved, padding) zeroed.
///
/// Modifying parameters is not supported for node types cudaGraphNodeTypeMemAlloc and cudaGraphNodeTypeMemFree.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cudaGraphNodeSetParams(
node: cudaGraphNode_t,
nodeParams: *mut cudaGraphNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns a graph node’s parameters.
///
/// Returns the parameters of graph node `node` 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.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `nodeParams`: Pointer to return the parameters.
pub fn cudaGraphNodeGetParams(
node: cudaGraphNode_t,
nodeParams: *mut cudaGraphNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Update a graph node’s parameters in an instantiated graph.
///
/// Sets the parameters of a node in an executable graph `graphExec`. The node is identified by the corresponding node `node` in the non-executable graph from which the executable graph was instantiated. `node` must not have been removed from the original graph.
///
/// The modifications only affect future launches of `graphExec`. Already enqueued or running launches of `graphExec` are not affected by this call. `node` is also not modified by this call.
///
/// Allowed changes to parameters on executable graphs are as follows.
///
/// # Parameters
///
/// - `graphExec`: The executable graph in which to update the specified node.
/// - `node`: Corresponding node from the graph from which graphExec was instantiated.
/// - `nodeParams`: Updated Parameters to set.
pub fn cudaGraphExecNodeSetParams(
graphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
nodeParams: *mut cudaGraphNodeParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `pHandle_out`: Pointer used to return the handle to the caller.
/// - `graph`: Graph which will contain the conditional node using this handle.
/// - `defaultLaunchValue`: Optional initial value for the conditional variable. Applied at the beginning of each graph execution if cudaGraphCondAssignDefault is set in `flags`.
/// - `flags`: Currently must be cudaGraphCondAssignDefault or 0.
pub fn cudaGraphConditionalHandleCreate(
pHandle_out: *mut cudaGraphConditionalHandle,
graph: cudaGraph_t,
defaultLaunchValue: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `pHandle_out`: Pointer used to return the handle to the caller.
/// - `graph`: Graph which will contain the conditional node using this handle.
/// - `ctx`: Execution context for the handle and associated conditional node. If NULL, current context will be used.
/// - `defaultLaunchValue`: Optional initial value for the conditional variable. Applied at the beginning of each graph execution if cudaGraphCondAssignDefault is set in `flags`.
/// - `flags`: Currently must be cudaGraphCondAssignDefault or 0.
pub fn cudaGraphConditionalHandleCreate_v2(
pHandle_out: *mut cudaGraphConditionalHandle,
graph: cudaGraph_t,
ctx: cudaExecutionContext_t,
defaultLaunchValue: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the requested driver API function pointer.
///
/// Returns in `**funcPtr` the address of the CUDA driver function for the requested flags.
///
/// For a requested driver symbol, if the CUDA version in which the driver symbol was introduced is less than or equal to the CUDA runtime version, the API will return the function pointer to the corresponding versioned driver function.
///
/// 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 [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) and set the returned `funcPtr` if the requested driver function is valid and supported on the platform.
///
/// The API will return [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) and set the returned `funcPtr` to NULL if the requested driver function is not supported on the platform, no ABI compatible driver function exists for the CUDA runtime version or if the driver symbol is invalid.
///
/// It will also set the optional `driverStatus` to one of the values in [cudaDriverEntryPointQueryResult](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaeb22957eedf779d624069585c25f1d1f) with the following meanings:
///
/// The requested flags can be.
///
/// # 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. Note that the API will use the CUDA runtime version to return the address to the most recent ABI compatible driver symbol, ::cuMemAlloc or ::cuMemAlloc_v2.
/// - `funcPtr`: Location to return the function pointer to the requested driver function.
/// - `flags`: Flags to specify search options.
/// - `driverStatus`: Optional location to store the status of finding the symbol from the driver. See [cudaDriverEntryPointQueryResult](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaeb22957eedf779d624069585c25f1d1f) for possible values.
pub fn cudaGetDriverEntryPoint(
symbol: *const ::core::ffi::c_char,
funcPtr: *mut *mut ::core::ffi::c_void,
flags: ::core::ffi::c_ulonglong,
driverStatus: *mut cudaDriverEntryPointQueryResult,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the requested driver API function pointer by CUDA version.
///
/// Returns in `**funcPtr` the address of the CUDA driver function for the requested flags and CUDA driver version.
///
/// 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 [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c).
///
/// 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.
///
/// For the case where the CUDA version requested is greater than the CUDA Toolkit installed, there may not be an appropriate function pointer typedef in the corresponding header file and may need a custom typedef to match the driver function signature returned. This can be done by getting the typedefs from a later toolkit or creating appropriately matching custom function typedefs.
///
/// The API will return [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) and set the returned `funcPtr` if the requested driver function is valid and supported on the platform.
///
/// The API will return [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) and set the returned `funcPtr` to NULL if the requested driver function is not supported on the platform, no ABI compatible driver function exists for the requested version or if the driver symbol is invalid.
///
/// It will also set the optional `driverStatus` to one of the values in [cudaDriverEntryPointQueryResult](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaeb22957eedf779d624069585c25f1d1f) with the following meanings:
///
/// The requested flags can be.
///
/// # 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.
/// - `funcPtr`: 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.
/// - `driverStatus`: Optional location to store the status of finding the symbol from the driver. See [cudaDriverEntryPointQueryResult](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaeb22957eedf779d624069585c25f1d1f) for possible values.
pub fn cudaGetDriverEntryPointByVersion(
symbol: *const ::core::ffi::c_char,
funcPtr: *mut *mut ::core::ffi::c_void,
cudaVersion: ::core::ffi::c_uint,
flags: ::core::ffi::c_ulonglong,
driverStatus: *mut cudaDriverEntryPointQueryResult,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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:
///
/// 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. Please also see the documentation for nvrtc (<https://docs.nvidia.com/cuda/nvrtc/index.html>), nvjitlink (<https://docs.nvidia.com/cuda/nvjitlink/index.html>), and nvfatbin (<https://docs.nvidia.com/cuda/nvfatbin/index.html>) for more information on generating loadable code at runtime.
///
/// 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`.
///
/// # 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 cudaLibraryLoadData(
library: *mut cudaLibrary_t,
code: *const ::core::ffi::c_void,
jitOptions: *mut cudaJitOption,
jitOptionsValues: *mut *mut ::core::ffi::c_void,
numJitOptions: ::core::ffi::c_uint,
libraryOptions: *mut cudaLibraryOption,
libraryOptionValues: *mut *mut ::core::ffi::c_void,
numLibraryOptions: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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:
///
/// 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. Please also see the documentation for nvrtc (<https://docs.nvidia.com/cuda/nvrtc/index.html>), nvjitlink (<https://docs.nvidia.com/cuda/nvjitlink/index.html>), and nvfatbin (<https://docs.nvidia.com/cuda/nvfatbin/index.html>) for more information on generating loadable code at runtime.
///
/// 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`.
///
/// # 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 cudaLibraryLoadFromFile(
library: *mut cudaLibrary_t,
fileName: *const ::core::ffi::c_char,
jitOptions: *mut cudaJitOption,
jitOptionsValues: *mut *mut ::core::ffi::c_void,
numJitOptions: ::core::ffi::c_uint,
libraryOptions: *mut cudaLibraryOption,
libraryOptionValues: *mut *mut ::core::ffi::c_void,
numLibraryOptions: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Unloads a library.
///
/// Unloads the library specified with `library`.
///
/// # Parameters
///
/// - `library`: - Library to unload
pub fn cudaLibraryUnload(library: cudaLibrary_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaErrorSymbolNotFound](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a9d51ecb21a3081d01e078d136c137593).
///
/// # Parameters
///
/// - `pKernel`: Returned kernel handle.
/// - `library`: Library to retrieve kernel from.
/// - `name`: Name of kernel to retrieve.
pub fn cudaLibraryGetKernel(
pKernel: *mut cudaKernel_t,
library: cudaLibrary_t,
name: *const ::core::ffi::c_char,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 device. If no global for the requested name `name` exists, the call returns [cudaErrorSymbolNotFound](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a9d51ecb21a3081d01e078d136c137593). One of the parameters `dptr` or `bytes` (not both) can be NULL in which case it is ignored. The returned `dptr` cannot be passed to the Symbol APIs such as [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaGetSymbolAddress`], or [`cudaGetSymbolSize`].
///
/// # Parameters
///
/// - `dptr`: Returned global device pointer for the requested library.
/// - `bytes`: Returned global size in bytes.
/// - `library`: Library to retrieve global from.
/// - `name`: Name of global to retrieve.
pub fn cudaLibraryGetGlobal(
dptr: *mut *mut ::core::ffi::c_void,
bytes: *mut size_t,
library: cudaLibrary_t,
name: *const ::core::ffi::c_char,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaErrorSymbolNotFound](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a9d51ecb21a3081d01e078d136c137593). 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. The returned `dptr` cannot be passed to the Symbol APIs such as [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaGetSymbolAddress`], or [`cudaGetSymbolSize`].
///
/// # 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 cudaLibraryGetManaged(
dptr: *mut *mut ::core::ffi::c_void,
bytes: *mut size_t,
library: cudaLibrary_t,
name: *const ::core::ffi::c_char,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [cudaErrorSymbolNotFound](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a9d51ecb21a3081d01e078d136c137593). If there is no device with attribute [cudaDeviceProp::unifiedFunctionPointers](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaDeviceProp.html#structcudadeviceprop_1a9f94309e6d30a640821cc9de9591e565) present in the system, the call may return [cudaErrorSymbolNotFound](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a9d51ecb21a3081d01e078d136c137593).
///
/// # 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 cudaLibraryGetUnifiedFunction(
fptr: *mut *mut ::core::ffi::c_void,
library: cudaLibrary_t,
symbol: *const ::core::ffi::c_char,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 cudaLibraryGetKernelCount(
count: *mut ::core::ffi::c_uint,
lib: cudaLibrary_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # 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 cudaLibraryEnumerateKernels(
kernels: *mut cudaKernel_t,
numKernels: ::core::ffi::c_uint,
lib: cudaLibrary_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Sets information about a kernel.
///
/// This call sets the value of a specified attribute `attr` on the kernel `kernel` for the requested device `device` to an integer value specified by `value`. This function returns [cudaSuccess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae355f04607d824883b4a50662830d591) 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 ([cudaErrorInvalidValue](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a3e8aef5398ee38e28ed41e357b48917c))
///
/// Note that attributes set using [`cudaFuncSetAttribute`] will override the attribute set by this API irrespective of whether the call to [`cudaFuncSetAttribute`] is made before or after this API call. Because of this and the stricter locking requirements mentioned below it is suggested that this call be used during the initialization path and not on each thread accessing `kernel` such as on kernel launches or on the critical path.
///
/// Valid values for `attr` are.
///
/// # Parameters
///
/// - `kernel`: Kernel to set attribute of.
/// - `attr`: Attribute requested.
/// - `value`: Value to set.
/// - `device`: Device to set attribute of.
pub fn cudaKernelSetAttributeForDevice(
kernel: cudaKernel_t,
attr: cudaFuncAttribute,
value: ::core::ffi::c_int,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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.
///
/// # Parameters
///
/// - `device`: Device to get resource for.
/// - `resource`: Output pointer to a [cudaDevResource](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaDevResource.html#structcudadevresource) structure.
/// - `type_`: Type of resource to retrieve.
pub fn cudaDeviceGetDevResource(
device: ::core::ffi::c_int,
resource: *mut cudaDevResource,
type_: cudaDevResourceType,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Splits [`cudaDevResourceType::cudaDevResourceTypeSm`] resources.
///
/// Splits [`cudaDevResourceType::cudaDevResourceTypeSm`] 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 [`cudaDeviceGetDevResource`], or [`cudaExecutionCtxGetDevResource`]. 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 [`cudaDeviceGetDevResource`], or [`cudaExecutionCtxGetDevResource`] for [`cudaDevResourceType::cudaDevResourceTypeSm`], 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:
///
/// A successful API call must either have:
///
/// Note: The API is not supported on 32-bit platforms.
///
/// # Parameters
///
/// - `result`: Output array of `cudaDevResource` 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 [`cudaDevSmResource`] resource.
/// - `remaining`: If the input resource cannot be cleanly split among `nbGroups`, the remaining 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 cudaDevSmResourceSplitByCount(
result: *mut cudaDevResource,
nbGroups: *mut ::core::ffi::c_uint,
input: *const cudaDevResource,
remaining: *mut cudaDevResource,
flags: ::core::ffi::c_uint,
minCount: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Splits a [`cudaDevResourceType::cudaDevResourceTypeSm`] resource into structured groups.
///
/// This API will split a resource of [`cudaDevResourceType::cudaDevResourceTypeSm`] 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:
///
/// **Example params and their effect:**
///
/// A groupParams array element is defined in the following order:
///
/// The difference between a catch-all param group as the last entry and the remainder is in two aspects:
///
/// 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.
///
/// # Parameters
///
/// - `result`: Output array of `cudaDevResource` 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 [`cudaDevResourceType::cudaDevResourceTypeSm`] 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 cudaDevSmResourceSplit(
result: *mut cudaDevResource,
nbGroups: ::core::ffi::c_uint,
input: *const cudaDevResource,
remainder: *mut cudaDevResource,
flags: ::core::ffi::c_uint,
groupParams: *mut cudaDevSmResourceGroupParams,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 [`cudaGreenCtxCreate`] API. Resources of the same type can be passed in, provided they meet the requirements as noted below.
///
/// A successful API call must have:
///
/// Note: The API is not supported on 32-bit platforms.
///
/// # Parameters
///
/// - `phDesc`: Output descriptor.
/// - `resources`: Array of resources to be included in the descriptor.
/// - `nbResources`: Number of resources passed in `resources`.
pub fn cudaDevResourceGenerateDesc(
phDesc: *mut cudaDevResourceDesc_t,
resources: *mut cudaDevResource,
nbResources: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// 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 retains the device’s primary context for the lifetime of the green context. The primary context will be released when the green context is destroyed. To avoid the overhead of repeated initialization and teardown, it is recommended to explicitly initialize the device’s primary context ahead of time using [`cudaInitDevice`]. This ensures that the primary context remains initialized throughout the program’s lifetime, minimizing overhead during green context creation and destruction.
///
/// The API does not create a default stream for the green context. Developers are expected to create streams explicitly using [`cudaExecutionCtxStreamCreate`] to submit work to the green context.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// # Parameters
///
/// - `phCtx`: Pointer for the output handle to the green context.
/// - `desc`: Descriptor generated via [`cudaDevResourceGenerateDesc`] which contains the set of resources to be used.
/// - `device`: Device on which to create the green context.
/// - `flags`: Green context creation flags. Must be 0, currently reserved for future use.
pub fn cudaGreenCtxCreate(
phCtx: *mut cudaExecutionContext_t,
desc: cudaDevResourceDesc_t,
device: ::core::ffi::c_int,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Destroy a execution context.
///
/// Destroys the specified execution context `ctx`. It is the responsibility of the caller to ensure that no API call issues using `ctx` while [`cudaExecutionCtxDestroy`] is executing or subsequently.
///
/// If `ctx` is a green context, any resources provisioned for it (that were initially available via the resource descriptor) are released as well.
///
/// The API does not destroy streams created via [`cudaExecutionCtxStreamCreate`]. Users are expected to destroy these streams explicitly using [`cudaStreamDestroy`] to avoid resource leaks. Once the execution context is destroyed, any subsequent API calls involving these streams will return [cudaErrorStreamDetached](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038adac625035f38851dbb8e21a4b556c141) with the exception of the following APIs:
///
/// Additionally, the API will invalidate all active captures on these streams.
///
/// Passing in a `ctx` that was not explicitly created via CUDA Runtime APIs is not allowed and will result in undefined behavior.
///
/// # Parameters
///
/// - `ctx`: - Execution context to destroy (required parameter, see note below)
pub fn cudaExecutionCtxDestroy(ctx: cudaExecutionContext_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Get context resources.
///
/// Get the `type` resources available to context represented by `ctx`.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// # Parameters
///
/// - `ctx`: Execution context to get resource for (required parameter, see note below).
/// - `resource`: Output pointer to a [cudaDevResource](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaDevResource.html#structcudadevresource) structure.
/// - `type_`: Type of resource to retrieve.
pub fn cudaExecutionCtxGetDevResource(
ctx: cudaExecutionContext_t,
resource: *mut cudaDevResource,
type_: cudaDevResourceType,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the device handle for the execution context.
///
/// Returns in `*device` the handle of the specified execution context’s device. The execution context should not be NULL.
///
/// # Parameters
///
/// - `device`: Returned device handle for the specified execution context.
/// - `ctx`: Execution context for which to obtain the device (required parameter, see note below).
pub fn cudaExecutionCtxGetDevice(
device: *mut ::core::ffi::c_int,
ctx: cudaExecutionContext_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the unique Id associated with the execution 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. The execution context should not be NULL.
///
/// # Parameters
///
/// - `ctx`: Context for which to obtain the Id (required parameter, see note below).
/// - `ctxId`: Pointer to store the Id of the context.
pub fn cudaExecutionCtxGetId(
ctx: cudaExecutionContext_t,
ctxId: *mut ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Creates a stream and initializes it for the given execution context.
///
/// The API creates a CUDA stream with the specified `flags` and `priority`, initializing it with resources as defined at the time of creating the specified `ctx`. Additionally, the API also enables work submitted to to the stream to be tracked under `ctx`.
///
/// The supported values for `flags` are:
///
/// 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 [`cudaDeviceGetStreamPriorityRange`]. If the specified priority is outside the numerical range returned by [`cudaDeviceGetStreamPriorityRange`], it will automatically be clamped to the lowest or the highest number in the range.
///
/// # Parameters
///
/// - `phStream`: Returned stream handle.
/// - `ctx`: Execution context to initialize the stream with (required parameter, see note below).
/// - `flags`: Flags for stream creation.
/// - `priority`: Stream priority.
pub fn cudaExecutionCtxStreamCreate(
phStream: *mut cudaStream_t,
ctx: cudaExecutionContext_t,
flags: ::core::ffi::c_uint,
priority: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Block for the specified execution context’s tasks to complete.
///
/// Blocks until the specified execution context has completed all preceding requested tasks. If the specified execution context is the device (primary) context obtained via [`cudaDeviceGetExecutionCtx`], green contexts that have been created on the device will also be synchronized.
///
/// The API returns an error if one of the preceding tasks failed.
///
/// # Parameters
///
/// - `ctx`: - Execution context to synchronize (required parameter, see note below)
pub fn cudaExecutionCtxSynchronize(ctx: cudaExecutionContext_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Get stream resources.
///
/// Get the `type` resources available to the `hStream` and store them in `resource`.
///
/// Note: The API will return [cudaErrorInvalidResourceType](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a4954cdb4893fda9f1a30251a018c32fe) is `type` is [`cudaDevResourceType::cudaDevResourceTypeWorkqueueConfig`] or [`cudaDevResourceType::cudaDevResourceTypeWorkqueue`].
///
/// # Parameters
///
/// - `hStream`: Stream to get resource for.
/// - `resource`: Output pointer to a [cudaDevResource](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaDevResource.html#structcudadevresource) structure.
/// - `type_`: Type of resource to retrieve.
pub fn cudaStreamGetDevResource(
hStream: cudaStream_t,
resource: *mut cudaDevResource,
type_: cudaDevResourceType,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Records an event for the specified execution context.
///
/// Captures in `event` all the activities of the execution context `ctx` at the time of this call. `event` and `ctx` must be from the same CUDA device, otherwise ::cudaErrorInvalidHandle will be returned. Calls such as [`cudaEventQuery`] or [`cudaExecutionCtxWaitEvent`] will then examine or wait for completion of the work that was captured. Uses of `ctx` after this call do not modify `event`. If the execution context passed to `ctx` is the device (primary) context obtained via [`cudaDeviceGetExecutionCtx`], `event` will capture all the activities of the green contexts created on the device as well.
///
/// # Parameters
///
/// - `ctx`: Execution context to record event for (required parameter, see note below).
/// - `event`: Event to record.
pub fn cudaExecutionCtxRecordEvent(
ctx: cudaExecutionContext_t,
event: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Make an execution context wait on an event.
///
/// Makes all future work submitted to execution context `ctx` wait for all work captured in `event`. The synchronization will be performed on the device and will not block the calling CPU thread. See [`cudaExecutionCtxRecordEvent`] for details on what is captured by an event. If the execution context passed to `ctx` is the device (primary) context obtained via [`cudaDeviceGetExecutionCtx`], all green contexts created on the device will wait for `event` as well.
///
/// # Parameters
///
/// - `ctx`: Execution context to wait for (required parameter, see note below).
/// - `event`: Event to wait on.
pub fn cudaExecutionCtxWaitEvent(
ctx: cudaExecutionContext_t,
event: cudaEvent_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Returns the execution context for a device.
///
/// Returns in `ctx` the execution context for the specified device. This is the device’s primary context. The returned context can then be passed to APIs that take in a cudaExecutionContext_t enabling explicit context-based programming without relying on thread-local state.
///
/// Passing the returned execution context to [`cudaExecutionCtxDestroy`] is not allowed and will result in undefined behavior.
///
/// # Parameters
///
/// - `ctx`: Returns the device execution context.
/// - `device`: Device to get the execution context for.
pub fn cudaDeviceGetExecutionCtx(
ctx: *mut cudaExecutionContext_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// impl_private
pub fn cudaGetExportTable(
ppExportTable: *mut *const ::core::ffi::c_void,
pExportTableId: *const cudaUUID_t,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Get pointer to device entry function that matches entry function `symbolPtr`.
///
/// Returns in `functionPtr` the device entry function corresponding to the symbol `symbolPtr`.
///
/// # Parameters
///
/// - `functionPtr`: Returns the device entry function.
/// - `symbolPtr`: Pointer to device entry function to search for.
pub fn cudaGetFuncBySymbol(
functionPtr: *mut cudaFunction_t,
symbolPtr: *const ::core::ffi::c_void,
) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Get pointer to device kernel that matches entry function `entryFuncAddr`.
///
/// Returns in `kernelPtr` the device kernel corresponding to the entry function `entryFuncAddr`.
///
/// Note that it is possible that there are multiple symbols belonging to different translation units with the same `entryFuncAddr` registered with this CUDA Runtime and so the order which the translation units are loaded and registered with the CUDA Runtime can lead to differing return pointers in `kernelPtr`. Suggested methods of ensuring uniqueness are to limit visibility of **global** device functions by using static or hidden visibility attribute in the respective translation units.
///
/// # Parameters
///
/// - `kernelPtr`: Returns the device kernel.
/// - `entryFuncAddr`: Address of device entry function to search kernel for.
pub fn cudaGetKernel(
kernelPtr: *mut cudaKernel_t,
entryFuncAddr: *const ::core::ffi::c_void,
) -> cudaError_t;
}