/* 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`], [`cudaEvent_t`], [`cudaArray_t`], [`cudaMipmappedArray_t`], [`cudaPitchedPtr`], [`cudaTextureObject_t`], [`cudaSurfaceObject_t`], `textureReference`, `surfaceReference`, [`cudaExternalMemory_t`], [`cudaExternalSemaphore_t`] and [`cudaGraphicsResource_t`]. 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.
///
/// Note: [`cudaDeviceReset`] will not destroy memory allocations by [`cudaMallocAsync`] and [`cudaMallocFromPoolAsync`]. These memory allocations need to be destroyed explicitly.
///
/// Note: If a non-primary [`CUcontext`](crate::driver::CUcontext) is current to the thread, [`cudaDeviceReset`] will destroy only the internal CUDA RT state for that [`CUcontext`](crate::driver::CUcontext).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
///
/// See also: [`cudaDeviceSynchronize`].
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.
///
/// Note: Use of cudaDeviceSynchronize in device code was deprecated in CUDA 11.6 and removed for compute_90+ compilation. For compute capability < 9.0, compile-time opt-in by specifying -D CUDA_FORCE_CDP1_IF_SUPPORTED is required to continue using [`cudaDeviceSynchronize`] in device code for now. Note that this is different from host-side cudaDeviceSynchronize, which is still supported.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED`]
///
/// See also: [`cudaDeviceReset`], [`cuCtxSynchronize`](crate::driver::cuCtxSynchronize).
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.
///
/// * [`cudaLimit::cudaLimitStackSize`] controls the stack size in bytes of each GPU thread.
/// * [`cudaLimit::cudaLimitPrintfFifoSize`] controls the size in bytes of the shared FIFO used by the `printf()` device system call. Setting [`cudaLimit::cudaLimitPrintfFifoSize`] must not be performed after launching any kernel that uses the `printf()` device system call - in such case [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] will be returned.
/// * [`cudaLimit::cudaLimitMallocHeapSize`] controls the size in bytes of the heap used by the `malloc()` and `free()` device system calls. Setting [`cudaLimit::cudaLimitMallocHeapSize`] must not be performed after launching any kernel that uses the `malloc()` or `free()` device system calls - in such case [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] will be returned.
/// * [`cudaLimit::cudaLimitDevRuntimeSyncDepth`] controls the maximum nesting depth of a grid at which a thread can safely call [`cudaDeviceSynchronize`]. Setting this limit must be performed before any launch of a kernel that uses the device runtime and calls [`cudaDeviceSynchronize`] above the default sync depth, two levels of grids. Calls to [`cudaDeviceSynchronize`] will fail with error code [cudaErrorSyncDepthExceeded](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a265dbf94c45903cd582cfc40f93a176a) if the limitation is violated. This limit can be set smaller than the default or up the maximum launch depth of 24. When setting this limit, keep in mind that additional levels of sync depth require the runtime to reserve large amounts of device memory which can no longer be used for user allocations. If these reservations of device memory fail, [`cudaDeviceSetLimit`] will return [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`], and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability < 9.0. Attempting to set this limit on devices of other compute capability will results in error [`cudaError_t::CUDA_ERROR_UNSUPPORTED_LIMIT`] being returned.
/// * [`cudaLimit::cudaLimitDevRuntimePendingLaunchCount`] controls the maximum number of outstanding device runtime launches that can be made from the current device. A grid is outstanding from the point of launch up until the grid is known to have been completed. Device runtime launches which violate this limitation fail and return [cudaErrorLaunchPendingCountExceeded](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2372902b9ffd65825d138e16125b1376) when [`cudaGetLastError`] is called after launch. If more pending launches than the default (2048 launches) are needed for a module using the device runtime, this limit can be increased. Keep in mind that being able to sustain additional pending launches will require the runtime to reserve larger amounts of device memory upfront which can no longer be used for allocations. If these reservations fail, [`cudaDeviceSetLimit`] will return [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`], and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability 3.5 and higher. Attempting to set this limit on devices of compute capability less than 3.5 will result in the error [`cudaError_t::CUDA_ERROR_UNSUPPORTED_LIMIT`] being returned.
/// * [`cudaLimit::cudaLimitMaxL2FetchGranularity`] controls the L2 cache fetch granularity. Values can range from 0B to 128B. This is purely a performance hint and it can be ignored or clamped depending on the platform.
/// * [`cudaLimit::cudaLimitPersistingL2CacheSize`] controls size in bytes available for persisting L2 cache. This is purely a performance hint and it can be ignored or clamped depending on the platform.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `limit`: Limit to set.
/// - `value`: Size of limit.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_UNSUPPORTED_LIMIT`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaDeviceGetLimit`], [`cuCtxSetLimit`](crate::driver::cuCtxSetLimit).
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.
///
/// * [`cudaLimit::cudaLimitStackSize`] is the stack size in bytes of each GPU thread.
/// * [`cudaLimit::cudaLimitPrintfFifoSize`] is the size in bytes of the shared FIFO used by the `printf()` device system call.
/// * [`cudaLimit::cudaLimitMallocHeapSize`] is the size in bytes of the heap used by the `malloc()` and `free()` device system calls.
/// * [`cudaLimit::cudaLimitDevRuntimeSyncDepth`] is the maximum grid depth at which a thread can isssue the device runtime call [`cudaDeviceSynchronize`] to wait on child grid launches to complete. This functionality is removed for devices of compute capability >= 9.0, and hence will return error [`cudaError_t::CUDA_ERROR_UNSUPPORTED_LIMIT`] on such devices.
/// * [`cudaLimit::cudaLimitDevRuntimePendingLaunchCount`] is the maximum number of outstanding device runtime launches.
/// * [`cudaLimit::cudaLimitMaxL2FetchGranularity`] is the L2 cache fetch granularity.
/// * [`cudaLimit::cudaLimitPersistingL2CacheSize`] is the persisting L2 cache size in bytes.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pValue`: Returned size of the limit.
/// - `limit`: Limit to query.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_UNSUPPORTED_LIMIT`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDeviceSetLimit`], [`cuCtxGetLimit`](crate::driver::cuCtxGetLimit).
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `maxWidthInElements`: Returns maximum number of texture elements allocatable for given `fmtDesc`.
/// - `fmtDesc`: Texture format description.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_UNSUPPORTED_LIMIT`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cuDeviceGetTexture1DLinearMaxWidth`](crate::driver::cuDeviceGetTexture1DLinearMaxWidth).
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 [`cudaFuncCache::CU_FUNC_CACHE_PREFER_NONE`] on devices where the size of the L1 cache and shared memory are fixed.
///
/// The supported cache configurations are:
///
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_NONE`]: no preference for shared memory or L1 (default)
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_SHARED`]: prefer larger shared memory and smaller L1 cache
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_L1`]: prefer larger L1 cache and smaller shared memory
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_EQUAL`]: prefer equal size L1 cache and shared memory.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pCacheConfig`: Returned cache configuration
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
///
/// See also: [`cudaDeviceSetCacheConfig`], [`cudaFuncSetCacheConfig`] (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), [`cuCtxGetCacheConfig`](crate::driver::cuCtxGetCacheConfig).
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`]).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
///
/// See also: [`cudaStreamCreateWithPriority`], [`cudaStreamGetPriority`], [`cuCtxGetStreamPriorityRange`](crate::driver::cuCtxGetStreamPriorityRange).
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 [`cudaFuncCache::CU_FUNC_CACHE_PREFER_NONE`] will cause subsequent kernel launches to prefer to not change the cache configuration unless required to launch the kernel.
///
/// This setting does nothing on devices where the size of the L1 cache and shared memory are fixed.
///
/// Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization point.
///
/// The supported cache configurations are:
///
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_NONE`]: no preference for shared memory or L1 (default)
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_SHARED`]: prefer larger shared memory and smaller L1 cache
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_L1`]: prefer larger L1 cache and smaller shared memory
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_EQUAL`]: prefer equal size L1 cache and shared memory.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `cacheConfig`: Requested cache configuration
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
///
/// See also: [`cudaDeviceGetCacheConfig`], [`cudaFuncSetCacheConfig`] (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), [`cuCtxSetCacheConfig`](crate::driver::cuCtxSetCacheConfig).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device`: Returned device ordinal.
/// - `pciBusId`: String in one of the following forms.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaDeviceGetPCIBusId`], [`cuDeviceGetByPCIBusId`](crate::driver::cuDeviceGetByPCIBusId).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaDeviceGetByPCIBusId`], [`cuDeviceGetPCIBusId`](crate::driver::cuDeviceGetPCIBusId).
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`].
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_MAP_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaEventCreate`], [`cudaEventDestroy`], [`cudaEventSynchronize`], [`cudaEventQuery`], [`cudaStreamWaitEvent`], [`cudaIpcOpenEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcOpenMemHandle`], [`cudaIpcCloseMemHandle`], [`cuIpcGetEventHandle`](crate::driver::cuIpcGetEventHandle).
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`] 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`].
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `event`: Returns the imported event.
/// - `handle`: Interprocess handle to open.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_MAP_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_CONTEXT`]
///
/// See also: [`cudaEventCreate`], [`cudaEventDestroy`], [`cudaEventSynchronize`], [`cudaEventQuery`], [`cudaStreamWaitEvent`], [`cudaIpcGetEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcOpenMemHandle`], [`cudaIpcCloseMemHandle`], [`cuIpcOpenEventHandle`](crate::driver::cuIpcOpenEventHandle).
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`].
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `handle`: Pointer to user allocated `cudaIpcMemHandle` to return the handle in.
/// - `devPtr`: Base pointer to previously allocated device memory.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_MAP_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMalloc`], [`cudaFree`], [`cudaIpcGetEventHandle`], [`cudaIpcOpenEventHandle`], [`cudaIpcOpenMemHandle`], [`cudaIpcCloseMemHandle`], [`cuIpcGetMemHandle`](crate::driver::cuIpcGetMemHandle).
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`].
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: No guarantees are made about the address returned in `*devPtr`.
///
/// In particular, multiple processes may not receive the same address for the same
///
/// `handle`.
///
/// # 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).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_MAP_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_CONTEXT`]
/// - [`cudaError_t::CUDA_ERROR_TOO_MANY_PEERS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMalloc`], [`cudaFree`], [`cudaIpcGetEventHandle`], [`cudaIpcOpenEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcCloseMemHandle`], [`cudaDeviceEnablePeerAccess`], [`cudaDeviceCanAccessPeer`], [`cuIpcOpenMemHandle`](crate::driver::cuIpcOpenMemHandle).
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_IPC_EVENT_SUPPORTED`].
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `devPtr`: Device pointer returned by [`cudaIpcOpenMemHandle`]
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_MAP_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMalloc`], [`cudaFree`], [`cudaIpcGetEventHandle`], [`cudaIpcOpenEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcOpenMemHandle`], [`cuIpcCloseMemHandle`](crate::driver::cuIpcCloseMemHandle).
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WRITES_ORDERING`], the call will be a no-op and can be safely omitted for performance. This can be determined by comparing the numerical values between the two enums, with smaller scopes having smaller values.
///
/// Users may query support for this API via [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_FLUSH_WRITES_OPTIONS`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `target`: The target of the operation, see cudaFlushGPUDirectRDMAWritesTarget.
/// - `scope`: The scope of the operation, see cudaFlushGPUDirectRDMAWritesScope.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuFlushGPUDirectRDMAWrites`](crate::driver::cuFlushGPUDirectRDMAWrites).
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 [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]. Async notification callbacks execute in an undefined order and may be serialized.
///
/// Returns in `*callback` a handle representing the registered callback instance.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaDeviceUnregisterAsyncNotification`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `device`: The device from which to remove `callback`.
/// - `callback`: The callback instance to unregister from receiving async notifications.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaDeviceRegisterAsyncNotification`].
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:
///
/// * cudaSharedMemBankSizeFourByte - shared memory bank width is four bytes.
/// * cudaSharedMemBankSizeEightByte - shared memory bank width is eight bytes.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pConfig`: Returned cache configuration
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDeviceSetCacheConfig`], [`cudaDeviceGetCacheConfig`], [`cudaDeviceSetSharedMemConfig`], [`cudaFuncSetCacheConfig`], [`cuCtxGetSharedMemConfig`](crate::driver::cuCtxGetSharedMemConfig).
#[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:
///
/// * cudaSharedMemBankSizeDefault: set bank width the device default (currently, four bytes)
/// * cudaSharedMemBankSizeFourByte: set shared memory bank width to be four bytes natively.
/// * cudaSharedMemBankSizeEightByte: set shared memory bank width to be eight bytes natively.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `config`: Requested cache configuration
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDeviceSetCacheConfig`], [`cudaDeviceGetCacheConfig`], [`cudaDeviceGetSharedMemConfig`], [`cudaFuncSetCacheConfig`], [`cuCtxSetSharedMemConfig`](crate::driver::cuCtxSetSharedMemConfig).
#[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 [`cudaError_t::CUDA_SUCCESS`].
///
/// Note: Multiple instances of the CUDA Runtime library can be present in an application when using a library that statically links the CUDA Runtime.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorMissingConfiguration`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a7697c0ee1bf14e2545f1272ac03ee3a2)
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_TIMEOUT`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaErrorInvalidConfiguration`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad3934977826b2e1488dfeb7e0614e776)
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidSymbol`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a)
/// - [`cudaError_t::CUDA_ERROR_UNMAP_FAILED`]
/// - [`cudaErrorInvalidDevicePointer`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a5fa2f00ab72ab5cf649a0a32351a20bf)
/// - [`cudaErrorInvalidTexture`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae4312b7621ebad05ce494249474a7e11)
/// - [`cudaErrorInvalidTextureBinding`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e73e27da21d74d0de9eaa8bcd61b527)
/// - [`cudaErrorInvalidChannelDescriptor`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a5abd0c4b36ef85f853c51bc18c516e0b)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
/// - [`cudaErrorInvalidFilterSetting`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038aa4dc8c42993939bd4d3b0399dce9236b)
/// - [`cudaErrorInvalidNormSetting`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a7a9f85073ed9240040e505cb48db68ef)
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaErrorInsufficientDriver`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067)
/// - [`cudaError_t::CUDA_ERROR_NO_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE`]
/// - [`cudaErrorStartupFailure`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a1c7fe018f3f2d9ede149e96d7379c9c5)
/// - [`cudaError_t::CUDA_ERROR_INVALID_PTX`]
/// - [`cudaError_t::CUDA_ERROR_UNSUPPORTED_PTX_VERSION`]
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILER_NOT_FOUND`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILATION_DISABLED`]
///
/// See also: [`cudaPeekAtLastError`], [`cudaGetErrorName`], [`cudaGetErrorString`], [`cudaError`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3f51e3575c2178246db0a94a430e0038).
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 [`cudaError_t::CUDA_SUCCESS`] 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorMissingConfiguration`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a7697c0ee1bf14e2545f1272ac03ee3a2)
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_TIMEOUT`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaErrorInvalidConfiguration`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad3934977826b2e1488dfeb7e0614e776)
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidSymbol`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a)
/// - [`cudaError_t::CUDA_ERROR_UNMAP_FAILED`]
/// - [`cudaErrorInvalidDevicePointer`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a5fa2f00ab72ab5cf649a0a32351a20bf)
/// - [`cudaErrorInvalidTexture`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ae4312b7621ebad05ce494249474a7e11)
/// - [`cudaErrorInvalidTextureBinding`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a2e73e27da21d74d0de9eaa8bcd61b527)
/// - [`cudaErrorInvalidChannelDescriptor`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a5abd0c4b36ef85f853c51bc18c516e0b)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
/// - [`cudaErrorInvalidFilterSetting`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038aa4dc8c42993939bd4d3b0399dce9236b)
/// - [`cudaErrorInvalidNormSetting`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a7a9f85073ed9240040e505cb48db68ef)
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaErrorInsufficientDriver`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067)
/// - [`cudaError_t::CUDA_ERROR_NO_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE`]
/// - [`cudaErrorStartupFailure`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a1c7fe018f3f2d9ede149e96d7379c9c5)
/// - [`cudaError_t::CUDA_ERROR_INVALID_PTX`]
/// - [`cudaError_t::CUDA_ERROR_UNSUPPORTED_PTX_VERSION`]
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILER_NOT_FOUND`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILATION_DISABLED`]
///
/// See also: [`cudaGetLastError`], [`cudaGetErrorName`], [`cudaGetErrorString`], [`cudaError`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3f51e3575c2178246db0a94a430e0038).
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
///
/// # Return value
///
/// `char*` pointer to a NULL-terminated string.
///
/// See also: [`cudaGetErrorString`], [`cudaGetLastError`], [`cudaPeekAtLastError`], [`cudaError`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3f51e3575c2178246db0a94a430e0038), [`cuGetErrorName`](crate::driver::cuGetErrorName).
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
///
/// # Return value
///
/// `char*` pointer to a NULL-terminated string.
///
/// See also: [`cudaGetErrorName`], [`cudaGetLastError`], [`cudaPeekAtLastError`], [`cudaError`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3f51e3575c2178246db0a94a430e0038), [`cuGetErrorString`](crate::driver::cuGetErrorString).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `count`: Returns the number of devices with compute capability greater or equal to 2.0
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
///
/// See also: [`cudaGetDevice`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cudaInitDevice`], [`cuDeviceGetCount`](crate::driver::cuDeviceGetCount).
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `prop`: Properties for the specified device.
/// - `device`: Device number to get properties for.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaChooseDevice`], [`cudaDeviceGetAttribute`], [`cudaInitDevice`], [`cuDeviceGetAttribute`](crate::driver::cuDeviceGetAttribute), [`cuDeviceGetName`](crate::driver::cuDeviceGetName).
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `value`: Returned device attribute value.
/// - `attr`: Device attribute to query.
/// - `device`: Device number to query.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaChooseDevice`], [`cudaGetDeviceProperties`], [`cudaInitDevice`], [`cuDeviceGetAttribute`](crate::driver::cuDeviceGetAttribute).
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 [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`] if `dev` is not valid.
///
/// Returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if `*capabilities` or `*operations` is NULL, if `count` is 0, or if any of `*operations` is not valid.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `capabilities`: Returned capability details of each requested operation.
/// - `operations`: Requested operations.
/// - `count`: Count of requested operations and size of capabilities.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDeviceGetAttribute`], [`cudaDeviceGetP2PAtomicCapabilities`], `cuDeviceGeHostAtomicCapabilities`.
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuDeviceGetDefaultMemPool`](crate::driver::cuDeviceGetDefaultMemPool), [`cudaMallocAsync`], [`cudaMemPoolTrimTo`], [`cudaMemPoolGetAttribute`], [`cudaDeviceSetMemPool`], [`cudaMemPoolSetAttribute`], [`cudaMemPoolSetAccess`].
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.
///
/// Note: Use [`cudaMallocFromPoolAsync`] to specify asynchronous allocations from a device different than the one the stream runs on.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuDeviceSetMemPool`](crate::driver::cuDeviceSetMemPool), [`cudaDeviceGetMemPool`], [`cudaDeviceGetDefaultMemPool`], [`cudaMemPoolCreate`], [`cudaMemPoolDestroy`], [`cudaMallocFromPoolAsync`].
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`](crate::driver::cuDeviceSetMemPool) or [`cudaDeviceSetMemPool`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuDeviceGetMemPool`](crate::driver::cuDeviceGetMemPool), [`cudaDeviceGetDefaultMemPool`], [`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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// 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:
///
/// * [cudaNvSciSyncAttrSignal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga8157cb1b3c077ba222a56779a37d3bd1), specifies that the applications intends to signal an NvSciSync on this CUDA device.
/// * [cudaNvSciSyncAttrWait](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga407f1fe03a9f560b23220faa306e70cf), specifies that the applications intends to wait on an NvSciSync on this CUDA device.
///
/// At least one of these flags must be set, failing which the API returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]. Both the flags are orthogonal to one another: a developer may set both these flags that allows to set both wait and signal specific attributes in the same `nvSciSyncAttrList`.
///
/// Note that this API updates the input `nvSciSyncAttrList` with values equivalent to the following public attribute key-values: NvSciSyncAttrKey_RequiredPerm is set to
///
/// * NvSciSyncAccessPerm_SignalOnly if [cudaNvSciSyncAttrSignal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga8157cb1b3c077ba222a56779a37d3bd1) is set in `flags`.
/// * NvSciSyncAccessPerm_WaitOnly if [cudaNvSciSyncAttrWait](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga407f1fe03a9f560b23220faa306e70cf) is set in `flags`.
/// * NvSciSyncAccessPerm_WaitSignal if both [cudaNvSciSyncAttrWait](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga407f1fe03a9f560b23220faa306e70cf) and [cudaNvSciSyncAttrSignal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga8157cb1b3c077ba222a56779a37d3bd1) are set in `flags`. NvSciSyncAttrKey_PrimitiveInfo is set to
/// * NvSciSyncAttrValPrimitiveType_SysmemSemaphore on any valid `device`.
/// * NvSciSyncAttrValPrimitiveType_Syncpoint if `device` is a Tegra device.
/// * NvSciSyncAttrValPrimitiveType_SysmemSemaphorePayload64b if `device` is GA10X+. NvSciSyncAttrKey_GpuId is set to the same UUID that is returned in `cudaDeviceProp.uuid` from `cudaDeviceGetProperties` for this `device`.
///
/// [`cudaError_t::CUDA_SUCCESS`], [`cudaError_t::CUDA_ERROR_INVALID_CONTEXT`], [`cudaError_t::CUDA_ERROR_INVALID_VALUE`], `cudaErrorInvalidHandle`, [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`], [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`], [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`].
///
/// # Parameters
///
/// - `nvSciSyncAttrList`: Return NvSciSync attributes supported.
/// - `device`: Valid CUDA Device to get NvSciSync attributes for.
/// - `flags`: flags describing NvSciSync usage.
///
/// See also: [`cudaImportExternalSemaphore`], [`cudaDestroyExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
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:
///
/// * [`cudaDeviceP2PAttr::CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK`]: A relative value indicating the performance of the link between two devices. Lower value means better performance (0 being the value used for most performant link).
/// * [`cudaDeviceP2PAttr::CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED`]: 1 if peer access is enabled.
/// * [`cudaDeviceP2PAttr::CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED`]: 1 if all native atomic operations over the link are supported.
/// * [`cudaDeviceP2PAttr::CU_DEVICE_P2P_ATTRIBUTE_ACCESS_ACCESS_SUPPORTED`]: 1 if accessing CUDA arrays over the link is supported.
/// * [`cudaDeviceP2PAttr::CU_DEVICE_P2P_ATTRIBUTE_ONLY_PARTIAL_NATIVE_ATOMIC_SUPPORTED`]: 1 if some CUDA-valid atomic operations over the link are supported. Information about specific operations can be retrieved with [`cudaDeviceGetP2PAtomicCapabilities`].
///
/// Returns [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`] if `srcDevice` or `dstDevice` are not valid or if they represent the same device.
///
/// Returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if `attrib` is not valid or if `value` is a null pointer.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `value`: Returned value of the requested attribute.
/// - `srcDevice`: The source device of the target link.
/// - `dstDevice`: The destination device of the target link.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDeviceEnablePeerAccess`], [`cudaDeviceDisablePeerAccess`], [`cudaDeviceCanAccessPeer`], [`cuDeviceGetP2PAttribute`](crate::driver::cuDeviceGetP2PAttribute), [`cudaDeviceGetP2PAtomicCapabilities`].
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 [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`] if `srcDevice` or `dstDevice` are not valid or if they represent the same device.
///
/// Returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if `*capabilities` or `*operations` is NULL, if `count` is 0, or if any of `*operations` is not valid.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDeviceGetP2PAttribute`], [`cuDeviceGetP2PAttribute`](crate::driver::cuDeviceGetP2PAttribute), [`cuDeviceGetP2PAtomicCapabilities`](crate::driver::cuDeviceGetP2PAtomicCapabilities).
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device`: Device with best match.
/// - `prop`: Desired device properties.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaInitDevice`].
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`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device`: Device on which the runtime will initialize itself.
/// - `deviceFlags`: Parameters for device operation.
/// - `flags`: Flags for controlling the device initialization.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cudaSetDevice`], [`cuCtxSetCurrent`](crate::driver::cuCtxSetCurrent).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device`: Device on which the active host thread should execute the device code.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]: cudaErrorDeviceUnavailable.
///
/// See also: [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cudaInitDevice`], [`cuCtxSetCurrent`](crate::driver::cuCtxSetCurrent).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device`: Returns the device on which the active host thread executes the device code.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]: cudaErrorDeviceUnavailable.
///
/// See also: [`cudaGetDeviceCount`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cuCtxGetCurrent`](crate::driver::cuCtxGetCurrent).
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 [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]. If `len` is not 0 and `device_arr` is NULL or if `len` exceeds the number of devices in the system, then [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device_arr`: List of devices to try.
/// - `len`: Number of devices in specified list.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaGetDeviceCount`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaSetDeviceFlags`], [`cudaChooseDevice`].
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.
///
/// * [cudaDeviceScheduleAuto](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3ade1dbaf4b222b22733cdfdcc026075): The default value if the `flags` parameter is zero, uses a heuristic based on the number of active CUDA contexts in the process `C` and the number of logical processors in the system `P`. If `C` > `P`, then CUDA will yield to other OS threads when waiting for the device, otherwise CUDA will not yield while waiting for results and actively spin on the processor. Additionally, on Tegra devices, [cudaDeviceScheduleAuto](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3ade1dbaf4b222b22733cdfdcc026075) uses a heuristic based on the power profile of the platform and may choose [cudaDeviceScheduleBlockingSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga057e6912c52708b6aa86e79dd83d007c) for low-powered devices.
/// * [cudaDeviceScheduleSpin](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaf01347c3dafebf07e1a0b4321a030a63): Instruct CUDA to actively spin when waiting for results from the device. This can decrease latency when waiting for the device, but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread.
/// * [cudaDeviceScheduleYield](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gabc13c52d342c67ebf0f1f7af937735a8): Instruct CUDA to yield its thread when waiting for results from the device. This can increase latency when waiting for the device, but can increase the performance of CPU threads performing work in parallel with the device.
/// * [cudaDeviceScheduleBlockingSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga057e6912c52708b6aa86e79dd83d007c): Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the device to finish work.
/// * [cudaDeviceBlockingSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga130ddae663f1873258fee5a6e0808b71): Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the device to finish work. [Deprecated:](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/deprecated.html#deprecated) This flag was deprecated as of CUDA 4.0 and replaced with [cudaDeviceScheduleBlockingSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga057e6912c52708b6aa86e79dd83d007c).
/// * [cudaDeviceMapHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga3762be9cccdd809a4ca128354fd134b0): This flag enables allocating pinned host memory that is accessible to the device. It is implicit for the runtime but may be absent if a context is created using the driver API. If this flag is not set, [`cudaHostGetDevicePointer`] will always return a failure code.
/// * [cudaDeviceLmemResizeToMax](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gada5f97298bf704dd3b04cbac4819e6e3): Instruct CUDA to not reduce local memory after resizing local memory for a kernel. This can prevent thrashing by local memory allocations when launching many kernels with high local memory usage at the cost of potentially increased memory usage. [Deprecated:](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/deprecated.html#deprecated) This flag is deprecated and the behavior enabled by this flag is now the default and cannot be disabled.
/// * [cudaDeviceSyncMemops](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gab5cbd9be7931e6c68d11e1175aa14c23): Ensures that synchronous memory operations initiated on this context will always synchronize. See further documentation in the section titled “API Synchronization behavior” to learn more about cases when synchronous memory operations can exhibit asynchronous behavior.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `flags`: Parameters for device operation
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGetDeviceFlags`], [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaSetDevice`], [`cudaSetValidDevices`], [`cudaInitDevice`], [`cudaChooseDevice`], [`cuDevicePrimaryCtxSetFlags`](crate::driver::cuDevicePrimaryCtxSetFlags).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `flags`: Pointer to store the device flags
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaSetDevice`], [`cudaSetDeviceFlags`], [`cudaInitDevice`], [`cuCtxGetFlags`](crate::driver::cuCtxGetFlags), [`cuDevicePrimaryCtxGetState`](crate::driver::cuDevicePrimaryCtxGetState).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pStream`: Pointer to new stream identifier
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_EXTERNAL_DEVICE`]
///
/// See also: [`cudaStreamCreateWithPriority`], [`cudaStreamCreateWithFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetFlags`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaSetDevice`], [`cudaStreamDestroy`], [`cuStreamCreate`](crate::driver::cuStreamCreate).
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
///
/// * [`cudaStreamDefault`]: Default stream creation flag.
/// * [`cudaStreamNonBlocking`]: Specifies that work running in the created stream may run concurrently with work in stream 0 (the NULL stream), and that the created stream should perform no implicit synchronization with stream 0.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pStream`: Pointer to new stream identifier.
/// - `flags`: Parameters for stream creation.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_EXTERNAL_DEVICE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamCreateWithPriority`], [`cudaStreamGetFlags`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaSetDevice`], [`cudaStreamDestroy`], [`cuStreamCreate`](crate::driver::cuStreamCreate).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Stream priorities are supported only on GPUs with compute capability 3.5 or higher.
///
/// Note: In the current implementation, only compute kernels launched in priority streams are affected by the stream’s priority. Stream priorities have no effect on host-to-device and device-to-host memory operations.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_EXTERNAL_DEVICE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaDeviceGetStreamPriorityRange`], [`cudaStreamGetPriority`], [`cudaStreamQuery`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaStreamSynchronize`], [`cudaSetDevice`], [`cudaStreamDestroy`], [`cuStreamCreateWithPriority`](crate::driver::cuStreamCreateWithPriority).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `priority`: Pointer to a signed integer in which the stream’s priority is returned.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaStreamCreateWithPriority`], [`cudaDeviceGetStreamPriorityRange`], [`cudaStreamGetFlags`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [`cuStreamGetPriority`](crate::driver::cuStreamGetPriority).
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.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `flags`: Pointer to an unsigned integer in which the stream’s flags are returned.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaStreamCreateWithPriority`], [`cudaStreamCreateWithFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetDevice`], [`cuStreamGetFlags`](crate::driver::cuStreamGetFlags).
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:
///
/// * a stream created via any of the CUDA runtime APIs such as [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`] and [`cudaStreamCreateWithPriority`], or their driver API equivalents such as [`cuStreamCreate`](crate::driver::cuStreamCreate) or [`cuStreamCreateWithPriority`](crate::driver::cuStreamCreateWithPriority). Passing an invalid handle will result in undefined behavior.
/// * any of the special streams such as the NULL stream, [cudaStreamLegacy](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga4e62d09dde16ba457b0a97f3a5262246) and [cudaStreamPerThread](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga7b7129befd6f52708309acafd1c46197) respectively. The driver API equivalents of these are also accepted which are NULL, `CU_STREAM_LEGACY` and `CU_STREAM_PER_THREAD`.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `streamId`: Pointer to an unsigned long long in which the stream Id is returned.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaStreamCreateWithPriority`], [`cudaStreamCreateWithFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetFlags`], [`cuStreamGetId`](crate::driver::cuStreamGetId).
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.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `device`: Returns the device to which the stream belongs.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]: cudaErrorDeviceUnavailable.
///
/// See also: [`cudaSetDevice`], [`cudaGetDevice`], [`cudaStreamCreate`], [`cudaStreamGetPriority`], [`cudaStreamGetFlags`], [`cuStreamGetId`](crate::driver::cuStreamGetId).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
///
/// See also: [`cudaAccessPolicyWindow`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `dst`: Destination stream.
/// - `src`: Source stream For attributes see cudaStreamAttrID.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaAccessPolicyWindow`].
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaAccessPolicyWindow`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaAccessPolicyWindow`].
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`.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// # Parameters
///
/// - `stream`: Stream identifier
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_EXTERNAL_DEVICE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamWaitEvent`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [`cuStreamDestroy`](crate::driver::cuStreamDestroy).
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:
///
/// * [cudaEventWaitDefault](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaf8f19058a7cc2c3994c8f71590b8747e): Default event creation flag.
/// * [cudaEventWaitExternal](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga0c23426b7252eaa9cef695859991304e): Event is captured in the graph as an external event node when performing stream capture.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `stream`: Stream to wait.
/// - `event`: Event to wait on.
/// - `flags`: Parameters for the operation(See above).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [`cuStreamWaitEvent`](crate::driver::cuStreamWaitEvent).
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.
///
/// [`cudaError_t::CUDA_SUCCESS`] 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 [`cudaError_t::CUDA_SUCCESS`] or an error code. In the event of a device error, all subsequently executed callbacks will receive an appropriate [`cudaError_t`].
///
/// Callbacks must not make any CUDA API calls. Attempting to use CUDA APIs may result in [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]. Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not mandated to run earlier. Callbacks without a mandated order (in independent streams) execute in undefined order and may be serialized.
///
/// For the purposes of Unified Memory, callback execution makes a number of guarantees:
///
/// * The callback stream is considered idle for the duration of the callback. Thus, for example, a callback may always use memory attached to the callback stream.
/// * The start of execution of a callback has the same effect as synchronizing an event recorded in the same stream immediately prior to the callback. It thus synchronizes streams which have been “joined” prior to the callback.
/// * Adding device work to any stream does not have the effect of making the stream active until all preceding callbacks have executed. Thus, for example, a callback might use global attached memory even if work has been added to another stream, if it has been properly ordered with an event.
/// * Completion of a callback does not cause a stream to become active except as described above. The callback stream will remain idle if no device work follows the callback, and will remain idle across consecutive callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a callback at the end of the stream.
///
/// Note: This function is slated for eventual deprecation and removal. If you do not require the callback to execute in case of a device error, consider using [`cudaLaunchHostFunc`]. Additionally, this function is not supported with [`cudaStreamBeginCapture`] and [`cudaStreamEndCapture`], unlike [`cudaLaunchHostFunc`].
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamDestroy`], [`cudaMallocManaged`], [`cudaStreamAttachMemAsync`], [`cudaLaunchHostFunc`], [`cuStreamAddCallback`](crate::driver::cuStreamAddCallback).
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.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `stream`: Stream identifier
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [`cuStreamSynchronize`](crate::driver::cuStreamSynchronize).
pub fn cudaStreamSynchronize(stream: cudaStream_t) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Queries an asynchronous stream for completion status.
///
/// Returns [`cudaError_t::CUDA_SUCCESS`] if all operations in `stream` have completed, or [`cudaError_t::CUDA_ERROR_NOT_READY`] if not.
///
/// For the purposes of Unified Memory, a return value of [`cudaError_t::CUDA_SUCCESS`] is equivalent to having called [`cudaStreamSynchronize`].
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `stream`: Stream identifier
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_READY`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamWaitEvent`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [`cuStreamQuery`](crate::driver::cuStreamQuery).
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:
///
/// * managed memory declared using the **managed** keyword or allocated with [`cudaMallocManaged`].
/// * a valid host-accessible region of system-allocated pageable memory. This type of memory may only be specified if the device associated with the stream reports a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`].
///
/// For managed allocations, `length` must be either zero or the entire allocation’s size. Both indicate that the entire allocation’s stream association is being changed. Currently, it is not possible to change stream association for a portion of a managed allocation.
///
/// For pageable 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`], 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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)).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_READY`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamWaitEvent`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [`cudaMallocManaged`], [`cuStreamAttachMemAsync`](crate::driver::cuStreamAttachMemAsync).
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.
///
/// Note: Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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`].
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamIsCapturing`], [`cudaStreamEndCapture`], [`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
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:
///
/// * Topology mismatches between the existing graph and the recaptured graph
/// * Parameter mismatches for memory allocation or free nodes
///
/// 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.
///
/// Note: Any user objects associated with `graph` will be released prior to the recapture.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]: cudaErrorDeinitialized, `cudaErrorNotInitialized`.
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamBeginCapture`], [`cudaStreamIsCapturing`], [`cudaStreamEndCapture`], [`cudaThreadExchangeStreamCaptureMode`].
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.
///
/// Note: Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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`].
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamIsCapturing`], [`cudaStreamEndCapture`], [`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:
///
/// ```text
/// cudaStreamCaptureMode mode = desiredMode;
/// cudaThreadExchangeStreamCaptureMode(&mode);
/// ...
/// cudaThreadExchangeStreamCaptureMode(&mode); // restore previous mode
/// ```
///
/// 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:
///
/// * `cudaStreamCaptureModeGlobal:` This is the default mode. If the local thread has an ongoing capture sequence that was not initiated with [`cudaStreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`] at [`cuStreamBeginCapture`](crate::driver::cuStreamBeginCapture), or if any other thread has a concurrent capture sequence initiated with [`cudaStreamCaptureMode::CU_STREAM_CAPTURE_MODE_GLOBAL`], this thread is prohibited from potentially unsafe API calls.
/// * `cudaStreamCaptureModeThreadLocal:` If the local thread has an ongoing capture sequence not initiated with [`cudaStreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED`], it is prohibited from potentially unsafe API calls. Concurrent capture sequences in other threads are ignored.
/// * `cudaStreamCaptureModeRelaxed:` The local thread is not prohibited from potentially unsafe API calls. Note that the thread is still prohibited from API calls which necessarily conflict with stream capture, for example, attempting [`cudaEventQuery`] on an event that was last recorded inside a capture sequence.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `mode`: Pointer to mode value to swap with the current mode
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaStreamBeginCapture`].
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`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `stream`: Stream to query.
/// - `pGraph`: The captured graph.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamBeginCapture`], [`cudaStreamIsCapturing`], [`cudaGraphDestroy`].
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:
///
/// * [`cudaStreamCaptureStatus::CU_STREAM_CAPTURE_STATUS_NONE`]: The stream is not capturing.
/// * [`cudaStreamCaptureStatus::CU_STREAM_CAPTURE_STATUS_ACTIVE`]: The stream is capturing.
/// * [`cudaStreamCaptureStatus::CU_STREAM_CAPTURE_STATUS_INVALIDATED`]: The stream was capturing but an error has invalidated the capture sequence. The capture sequence must be terminated with [`cudaStreamEndCapture`] on the stream where it was initiated in order to continue using `stream`.
///
/// 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 [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT`] 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).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `stream`: Stream to query.
/// - `pCaptureStatus`: Returns the stream’s capture status.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamBeginCapture`], [`cudaStreamEndCapture`].
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 [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT`].
///
/// Valid data (other than capture status) is returned only if both of the following are true:
///
/// * the call returns cudaSuccess
/// * the returned capture status is [`cudaStreamCaptureStatus::CU_STREAM_CAPTURE_STATUS_ACTIVE`]
///
/// If `edgeData_out` is non-NULL then `dependencies_out` must be as well. If `dependencies_out` is non-NULL and `edgeData_out` is NULL, but there is non-zero edge data for one or more of the current stream dependencies, the call will return [`cudaError_t::CUDA_ERROR_LOSSY_QUERY`].
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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 [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_UNJOINED`].
/// - `dependencies_out`: Optional location to store a pointer to an array of nodes. The next node to be captured in the stream will depend on this set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream) without copying.
/// - `edgeData_out`: Optional location to store a pointer to an array of graph edge data. This array parallels `dependencies_out`; the next node to be added has an edge to `dependencies_out`\[i\] with annotation `edgeData_out`\[i\] for each `i`. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated.
/// - `numDependencies_out`: Optional location to store the size of the array returned in dependencies_out.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_IMPLICIT`]
/// - [`cudaError_t::CUDA_ERROR_LOSSY_QUERY`]
///
/// See also: [`cudaStreamBeginCapture`], [`cudaStreamIsCapturing`], [`cudaStreamUpdateCaptureDependencies`].
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 [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_UNJOINED`] if they are unreachable from the stream at [`cudaStreamEndCapture`].
///
/// Returns [`cudaError_t::CUDA_ERROR_ILLEGAL_STATE`] if the stream is not capturing.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_ILLEGAL_STATE`]
///
/// See also: [`cudaStreamBeginCapture`], [`cudaStreamGetCaptureInfo`].
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](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga6f8811acffcc133b5e4a50de6646d18e).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `event`: Newly created event
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [cudaEventCreate (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga4b5fdb19d7fb5f6f8862559f9279f6c3), [`cudaEventCreateWithFlags`], [`cudaEventRecord`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [`cuEventCreate`](crate::driver::cuEventCreate).
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:
///
/// * [cudaEventDefault](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga6f8811acffcc133b5e4a50de6646d18e): Default event creation flag.
/// * [cudaEventBlockingSync](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga26509a522be9d449aa7c8c279612452d): Specifies that event should use blocking synchronization. A host thread that uses [`cudaEventSynchronize`] to wait on an event created with this flag will block until the event actually completes.
/// * [cudaEventDisableTiming](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaa5d3eff7c3623e2be533968d9cc1ee7e): Specifies that the created event does not need to record timing data. Events created with this flag specified and 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 not specified will provide the best performance when used with [`cudaStreamWaitEvent`] and [`cudaEventQuery`].
/// * [cudaEventInterprocess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga49ec9cd742f8a3f6fde4ee72a66326f6): Specifies that the created event may be used as an interprocess event by [`cudaIpcGetEventHandle`]. [cudaEventInterprocess](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga49ec9cd742f8a3f6fde4ee72a66326f6) must be specified along with [cudaEventDisableTiming](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gaa5d3eff7c3623e2be533968d9cc1ee7e).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `event`: Newly created event.
/// - `flags`: Flags for new event.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaEventCreate`] (C API), [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [`cuEventCreate`](crate::driver::cuEventCreate).
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 [`cudaError_t::CUDA_SUCCESS`].
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Returns [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] in the event of being passed NULL as the input event.
///
/// # Parameters
///
/// - `event`: Event to record.
/// - `stream`: Stream in which to record event.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
///
/// See also: [`cudaEventCreate`] (C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [`cudaEventRecordWithFlags`], [`cuEventRecord`](crate::driver::cuEventRecord).
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 [`cudaError_t::CUDA_SUCCESS`].
///
/// flags include:
///
/// * [`cudaEventRecordDefault`]: Default event creation flag.
/// * [`cudaEventRecordExternal`]: Event is captured in the graph as an external event node when performing stream capture.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Returns [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] in the event of being passed NULL as the input event.
///
/// # Parameters
///
/// - `event`: Event to record.
/// - `stream`: Stream in which to record event.
/// - `flags`: Parameters for the operation(See above).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
///
/// See also: [`cudaEventCreate`] (C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [`cudaEventRecord`], [`cuEventRecord`](crate::driver::cuEventRecord).
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 [`cudaError_t::CUDA_SUCCESS`] if all captured work has been completed, or [`cudaError_t::CUDA_ERROR_NOT_READY`] if any captured work is incomplete.
///
/// For the purposes of Unified Memory, a return value of [`cudaError_t::CUDA_SUCCESS`] is equivalent to having called [`cudaEventSynchronize`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Returns [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] in the event of being passed NULL as the input event.
///
/// # Parameters
///
/// - `event`: Event to query
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_READY`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
///
/// See also: [`cudaEventCreate`] (C API), [`cudaEventCreateWithFlags`], [`cudaEventRecord`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cuEventQuery`](crate::driver::cuEventQuery).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Returns [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] in the event of being passed NULL as the input event.
///
/// # Parameters
///
/// - `event`: Event to wait for
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
///
/// See also: [`cudaEventCreate`] (C API), [`cudaEventCreateWithFlags`], [`cudaEventRecord`], [`cudaEventQuery`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cuEventSynchronize`](crate::driver::cuEventSynchronize).
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 [`cudaError_t::CUDA_ERROR_NOT_READY`]). In this case, the call does not block on completion of the event, and any associated resources will automatically be released asynchronously at completion.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// Note: Returns [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] in the event of being passed NULL as the input event.
///
/// # Parameters
///
/// - `event`: Event to destroy
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
///
/// See also: [`cudaEventCreate`] (C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventRecord`], [`cudaEventElapsedTime`], [`cuEventDestroy`](crate::driver::cuEventDestroy).
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 [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] 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 [`cudaError_t::CUDA_ERROR_NOT_READY`] on at least one of the events), [`cudaError_t::CUDA_ERROR_NOT_READY`] 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 [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Returns [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] in the event of being passed NULL as the input event.
///
/// # Parameters
///
/// - `ms`: Time between `start` and `end` in ms.
/// - `start`: Starting event.
/// - `end`: Ending event.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_READY`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaEventCreate`] (C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventRecord`], [`cuEventElapsedTime`](crate::driver::cuEventElapsedTime).
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:
///
/// ```text
/// typedef struct cudaExternalMemoryHandleDesc_st {
/// cudaExternalMemoryHandleType type;
/// union {
/// int fd;
/// struct {
/// void *handle;
/// const void *name;
/// } win32;
/// const void *nvSciBufObject;
/// } handle;
/// unsigned long long size;
/// unsigned int flags;
/// } cudaExternalMemoryHandleDesc;
/// ```
///
/// where [`cudaExternalMemoryHandleDesc::type`](cudaExternalMemoryHandleDesc::type_) specifies the type of handle being imported. [`cudaExternalMemoryHandleType`] is defined as:
///
/// ```text
/// typedef enum cudaExternalMemoryHandleType_enum {
/// cudaExternalMemoryHandleTypeOpaqueFd = 1,
/// cudaExternalMemoryHandleTypeOpaqueWin32 = 2,
/// cudaExternalMemoryHandleTypeOpaqueWin32Kmt = 3,
/// cudaExternalMemoryHandleTypeD3D12Heap = 4,
/// cudaExternalMemoryHandleTypeD3D12Resource = 5,
/// cudaExternalMemoryHandleTypeD3D11Resource = 6,
/// cudaExternalMemoryHandleTypeD3D11ResourceKmt = 7,
/// cudaExternalMemoryHandleTypeNvSciBuf = 8
/// } cudaExternalMemoryHandleType;
/// ```
///
/// If [`cudaExternalMemoryHandleDesc::type`](cudaExternalMemoryHandleDesc::type_) 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`](cudaExternalMemoryHandleDesc::type_) 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`](cudaExternalMemoryHandleDesc::type_) 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`](cudaExternalMemoryHandleDesc::type_) 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`](cudaExternalMemoryHandleDesc::type_) 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`](cudaExternalMemoryHandleDesc::type_) 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
///
/// returned by IDXGIResource1::CreateSharedHandle when referring to a ID3D11Resource 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 ID3D11Resource object.
///
/// If [`cudaExternalMemoryHandleDesc::type`](cudaExternalMemoryHandleDesc::type_) 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`](cudaExternalMemoryHandleDesc::type_) 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`](cudaExternalMemoryHandleDesc::size).
///
/// 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`](cudaExternalMemoryHandleDesc::flags) 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`](cudaExternalMemoryHandleDesc::type_) is one of the following: [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D12Resource`] [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11Resource`] [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11ResourceKmt`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: If the Vulkan memory imported into CUDA is mapped on the CPU then the application must use vkInvalidateMappedMemoryRanges/vkFlushMappedMemoryRanges as well as appropriate Vulkan pipeline barriers to maintain coherence between CPU and GPU. For more information on these APIs, please refer to “Synchronization
///
/// and Cache Control” chapter from Vulkan specification.
///
/// # Parameters
///
/// - `extMem_out`: Returned handle to an external memory object.
/// - `memHandleDesc`: Memory import handle descriptor.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_OPERATING_SYSTEM`]
///
/// See also: [`cudaDestroyExternalMemory`], [`cudaExternalMemoryGetMappedBuffer`], [`cudaExternalMemoryGetMappedMipmappedArray`].
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:
///
/// ```text
/// typedef struct cudaExternalMemoryBufferDesc_st {
/// unsigned long long offset;
/// unsigned long long size;
/// unsigned int flags;
/// } cudaExternalMemoryBufferDesc;
/// ```
///
/// where [`cudaExternalMemoryBufferDesc::offset`](cudaExternalMemoryBufferDesc::offset) is the offset in the memory object where the buffer’s base address is. [`cudaExternalMemoryBufferDesc::size`](cudaExternalMemoryBufferDesc::size) is the size of the buffer. [`cudaExternalMemoryBufferDesc::flags`](cudaExternalMemoryBufferDesc::flags) 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`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `devPtr`: Returned device pointer to buffer.
/// - `extMem`: Handle to external memory object.
/// - `bufferDesc`: Buffer descriptor.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaImportExternalMemory`], [`cudaDestroyExternalMemory`], [`cudaExternalMemoryGetMappedMipmappedArray`].
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:
///
/// ```text
/// typedef struct cudaExternalMemoryMipmappedArrayDesc_st {
/// unsigned long long offset;
/// cudaChannelFormatDesc formatDesc;
/// cudaExtent extent;
/// unsigned int flags;
/// unsigned int numLevels;
/// } cudaExternalMemoryMipmappedArrayDesc;
/// ```
///
/// where [`cudaExternalMemoryMipmappedArrayDesc::offset`](cudaExternalMemoryMipmappedArrayDesc::offset) is the offset in the memory object where the base level of the mipmap chain is. [`cudaExternalMemoryMipmappedArrayDesc::formatDesc`](cudaExternalMemoryMipmappedArrayDesc::formatDesc) describes the format of the data. [`cudaExternalMemoryMipmappedArrayDesc::extent`](cudaExternalMemoryMipmappedArrayDesc::extent) specifies the dimensions of the base level of the mipmap chain. [`cudaExternalMemoryMipmappedArrayDesc::flags`](cudaExternalMemoryMipmappedArrayDesc::flags) 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`](cudaExternalMemoryMipmappedArrayDesc::flags). [`cudaExternalMemoryMipmappedArrayDesc::numLevels`](cudaExternalMemoryMipmappedArrayDesc::numLevels) specifies the total number of levels in the mipmap chain.
///
/// The returned CUDA mipmapped array must be freed using [`cudaFreeMipmappedArray`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: If [`cudaExternalMemoryHandleDesc::type`](cudaExternalMemoryHandleDesc::type_) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeNvSciBuf`], then [`cudaExternalMemoryMipmappedArrayDesc::numLevels`](cudaExternalMemoryMipmappedArrayDesc::numLevels) must not be greater than 1.
///
/// # Parameters
///
/// - `mipmap`: Returned CUDA mipmapped array.
/// - `extMem`: Handle to external memory object.
/// - `mipmapDesc`: CUDA array descriptor.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaImportExternalMemory`], [`cudaDestroyExternalMemory`], [`cudaExternalMemoryGetMappedBuffer`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// # Parameters
///
/// - `extMem`: External memory object to be destroyed
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaImportExternalMemory`], [`cudaExternalMemoryGetMappedBuffer`], [`cudaExternalMemoryGetMappedMipmappedArray`].
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:
///
/// ```text
/// typedef struct cudaExternalSemaphoreHandleDesc_st {
/// cudaExternalSemaphoreHandleType type;
/// union {
/// int fd;
/// struct {
/// void *handle;
/// const void *name;
/// } win32;
/// const void* NvSciSyncObj;
/// } handle;
/// unsigned int flags;
/// } cudaExternalSemaphoreHandleDesc;
/// ```
///
/// where [`cudaExternalSemaphoreHandleDesc::type`](cudaExternalSemaphoreHandleDesc::type_) specifies the type of handle being imported. [`cudaExternalSemaphoreHandleType`] is defined as:
///
/// ```text
/// typedef enum cudaExternalSemaphoreHandleType_enum {
/// cudaExternalSemaphoreHandleTypeOpaqueFd = 1,
/// cudaExternalSemaphoreHandleTypeOpaqueWin32 = 2,
/// cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt = 3,
/// cudaExternalSemaphoreHandleTypeD3D12Fence = 4,
/// cudaExternalSemaphoreHandleTypeD3D11Fence = 5,
/// cudaExternalSemaphoreHandleTypeNvSciSync = 6,
/// cudaExternalSemaphoreHandleTypeKeyedMutex = 7,
/// cudaExternalSemaphoreHandleTypeKeyedMutexKmt = 8,
/// cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd = 9,
/// cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 = 10
/// } cudaExternalSemaphoreHandleType;
/// ```
///
/// If [`cudaExternalSemaphoreHandleDesc::type`](cudaExternalSemaphoreHandleDesc::type_) 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`](cudaExternalSemaphoreHandleDesc::type_) 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`](cudaExternalSemaphoreHandleDesc::type_) 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`](cudaExternalSemaphoreHandleDesc::type_) 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`](cudaExternalSemaphoreHandleDesc::type_) 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`](cudaExternalSemaphoreHandleDesc::type_) 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`](cudaExternalSemaphoreHandleDesc::type_) 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`](cudaExternalSemaphoreHandleDesc::type_) 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`](cudaExternalSemaphoreHandleDesc::type_) 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `extSem_out`: Returned handle to an external semaphore.
/// - `semHandleDesc`: Semaphore import handle descriptor.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_OPERATING_SYSTEM`]
///
/// See also: [`cudaDestroyExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaImportExternalSemaphore`], [`cudaDestroyExternalSemaphore`], [`cudaWaitExternalSemaphoresAsync`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_TIMEOUT`]
///
/// See also: [`cudaImportExternalSemaphore`], [`cudaDestroyExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// # Parameters
///
/// - `extSem`: External semaphore to be destroyed
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
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.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `gridDim`: Grid dimentions.
/// - `blockDim`: Block dimentions.
/// - `args`: Arguments.
/// - `sharedMem`: Shared memory.
/// - `stream`: Stream identifier.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaErrorInvalidConfiguration`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad3934977826b2e1488dfeb7e0614e776)
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_TIMEOUT`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES`]
/// - [`cudaError_t::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_PTX`]
/// - [`cudaError_t::CUDA_ERROR_UNSUPPORTED_PTX_VERSION`]
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILER_NOT_FOUND`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILATION_DISABLED`]
///
/// See also: (C++, API), [`cuLaunchKernel`](crate::driver::cuLaunchKernel).
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`] 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.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # Parameters
///
/// - `config`: Launch configuration.
/// - `func`: Kernel to launch.
/// - `args`: Array of pointers to kernel parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaErrorInvalidConfiguration`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad3934977826b2e1488dfeb7e0614e776)
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_TIMEOUT`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES`]
/// - [`cudaError_t::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_PTX`]
/// - [`cudaError_t::CUDA_ERROR_UNSUPPORTED_PTX_VERSION`]
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILER_NOT_FOUND`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILATION_DISABLED`]
///
/// See also: [`cudaLaunchKernelEx`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga7d9168c86a4293639c75ea437465ed53), (const, [`cudaLaunchConfig_t`], *config, `void`, (*kernel)(ExpTypes…), `ActTypes`, &&…, args), “cudaLaunchKernelEx, (C++, API)”, [`cuLaunchKernelEx`](crate::driver::cuLaunchKernelEx).
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_COOPERATIVE_LAUNCH`].
///
/// 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT`].
///
/// 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.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `gridDim`: Grid dimentions.
/// - `blockDim`: Block dimentions.
/// - `args`: Arguments.
/// - `sharedMem`: Shared memory.
/// - `stream`: Stream identifier.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaErrorInvalidConfiguration`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ad3934977826b2e1488dfeb7e0614e776)
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_TIMEOUT`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES`]
/// - [`cudaError_t::CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE`]
/// - [`cudaError_t::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED`]
///
/// See also: (C++, API), [`cuLaunchCooperativeKernel`](crate::driver::cuLaunchCooperativeKernel).
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:
///
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_NONE`]: no preference for shared memory or L1 (default)
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_SHARED`]: prefer larger shared memory and smaller L1 cache
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_L1`]: prefer larger L1 cache and smaller shared memory
/// * [`cudaFuncCache::CU_FUNC_CACHE_PREFER_EQUAL`]: prefer equal size L1 cache and shared memory.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: Use of a string naming a function as the `func` parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: This API does not accept a [`cudaKernel_t`] casted as void\*. If cache config modification is required for a [`cudaKernel_t`] (or a *`global`* function), it can be replaced with a call to `cudaFuncSetAttributes` with the attribute [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT`] to specify a more granular L1 cache and shared memory split configuration.
///
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `cacheConfig`: Requested cache configuration.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
///
/// See also: [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), [`cudaLaunchKernel`] (C API), [`cuFuncSetCacheConfig`](crate::driver::cuFuncSetCacheConfig).
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`] 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: Use of a string naming a function as the `func` parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # Parameters
///
/// - `attr`: Return pointer to function’s attributes.
/// - `func`: Device function symbol.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
///
/// See also: [`cudaFuncSetCacheConfig`] (C API), [cudaFuncGetAttributes (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga36a9bf322521126dd7148a21aa48ff6c), [`cudaLaunchKernel`] (C API), [`cuFuncGetAttribute`](crate::driver::cuFuncGetAttribute).
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`] and used as is. If the specified attribute cannot be written, or if the value is incorrect, then [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Valid values for `attr` are:
///
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES`] - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute `sharedSizeBytes` cannot exceed the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN`]. The maximal size of requestable dynamic shared memory may differ by GPU architecture.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT`] - On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the total shared memory. See [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR`]. This is only a hint, and the driver can choose a different ratio if required to execute the function.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH`]: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT`]: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH`]: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED`]: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE`]: The block scheduling policy of a function. The value type is cudaClusterSchedulingPolicy.
///
/// 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),.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # Parameters
///
/// - `func`: Function to get attributes of.
/// - `attr`: Attribute to set.
/// - `value`: Value to set.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
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, [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] is returned. If `func` is not a device entry function, then it is assumed to be a [`cudaKernel_t`] and used as is.
///
/// cudaFuncGetName (C++ API).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # Parameters
///
/// - `name`: The returned name of the function.
/// - `func`: The function pointer to retrieve name for.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # 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.
///
/// # Return value
///
/// CUDA_SUCCESS, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`](crate::driver::cudaError_enum::CUDA_ERROR_INVALID_VALUE),.
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # Parameters
///
/// - `func`: The function to query.
/// - `paramCount`: Returns the number of parameters used by the function.
///
/// # Return value
///
/// CUDA_SUCCESS, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`](crate::driver::cudaError_enum::CUDA_ERROR_INVALID_VALUE),.
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 [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`], but this is not required. The host function must not perform any synchronization that may depend on outstanding CUDA work not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined order and may be serialized.
///
/// For the purposes of Unified Memory, execution makes a number of guarantees:
///
/// * The stream is considered idle for the duration of the function’s execution. Thus, for example, the function may always use memory attached to the stream it was enqueued in.
/// * The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately prior to the function. It thus synchronizes streams which have been “joined” prior to the function.
/// * Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added to another stream, if the work has been ordered behind the function call with an event.
/// * Completion of the function does not cause a stream to become active except as described above. The stream will remain idle if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end of the stream.
///
/// Note that, in constrast to [`cuStreamAddCallback`](crate::driver::cuStreamAddCallback), the function will not be called in the event of an error in the CUDA context.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamDestroy`], [`cudaMallocManaged`], [`cudaStreamAttachMemAsync`], [`cudaStreamAddCallback`], [`cuLaunchHostFunc`](crate::driver::cuLaunchHostFunc).
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 [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`], but this is not required. The host function must not perform any synchronization that may depend on outstanding CUDA work not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined order and may be serialized.
///
/// For the purposes of Unified Memory, execution makes a number of guarantees:
///
/// * The stream is considered idle for the duration of the function’s execution. Thus, for example, the function may always use memory attached to the stream it was enqueued in.
/// * The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately prior to the function. It thus synchronizes streams which have been “joined” prior to the function.
/// * Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added to another stream, if the work has been ordered behind the function call with an event.
/// * Completion of the function does not cause a stream to become active except as described above. The stream will remain idle if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end of the stream.
///
/// Note that, in constrast to [`cuStreamAddCallback`](crate::driver::cuStreamAddCallback), the function will not be called in the event of an error in the CUDA context.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaStreamCreate`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamDestroy`], [`cudaMallocManaged`], [`cudaStreamAttachMemAsync`], [`cudaStreamAddCallback`], [`cuLaunchHostFunc`](crate::driver::cuLaunchHostFunc).
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:
///
/// * cudaSharedMemBankSizeDefault: use the device’s shared memory configuration when launching this function.
/// * cudaSharedMemBankSizeFourByte: set shared memory bank width to be four bytes natively when launching this function.
/// * cudaSharedMemBankSizeEightByte: set shared memory bank width to be eight bytes natively when launching this function.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: Use of a string naming a function as the `func` parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `config`: Requested shared memory configuration.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDeviceSetSharedMemConfig`], [`cudaDeviceGetSharedMemConfig`], [`cudaDeviceSetCacheConfig`], [`cudaDeviceGetCacheConfig`], [`cudaFuncSetCacheConfig`], [`cuFuncSetSharedMemConfig`](crate::driver::cuFuncSetSharedMemConfig).
#[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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags`], [cudaOccupancyMaxPotentialBlockSize (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1gab3e5d4de4f1b514811746129733f61a5), [cudaOccupancyMaxPotentialBlockSizeWithFlags (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga39214f0e1b063a3e54e108f8fab44e80), [cudaOccupancyMaxPotentialBlockSizeVariableSMem (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga26aa6bf18325fdc9341bf64785f04c23), [cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga005a74fcd98441f5b5a1816baeba2b34), [`cudaOccupancyAvailableDynamicSMemPerBlock`], (C++, API), [`cuOccupancyMaxActiveBlocksPerMultiprocessor`](crate::driver::cuOccupancyMaxActiveBlocksPerMultiprocessor).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags`], [cudaOccupancyMaxPotentialBlockSize (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1gab3e5d4de4f1b514811746129733f61a5), [cudaOccupancyMaxPotentialBlockSizeWithFlags (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga39214f0e1b063a3e54e108f8fab44e80), [cudaOccupancyMaxPotentialBlockSizeVariableSMem (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga26aa6bf18325fdc9341bf64785f04c23), [cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga005a74fcd98441f5b5a1816baeba2b34).
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:
///
/// * [cudaOccupancyDefault](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga11570371f508845a9df47b17f85d90ac): keeps the default behavior as [`cudaOccupancyMaxActiveBlocksPerMultiprocessor`]
/// * [cudaOccupancyDisableCachingOverride](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga0a30e61b561f0678f1bf39eb051033bf): This flag suppresses the default behavior on platform where global caching affects occupancy. On such platforms, if caching is enabled, but per-block SM resource usage would result in zero occupancy, the occupancy calculator will calculate the occupancy as if caching is disabled. Setting this flag makes the occupancy calculator to return 0 in such cases. More information can be found about this feature in the “Unified L1/Texture Cache” section of the Maxwell tuning guide.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaOccupancyMaxActiveBlocksPerMultiprocessor`], [cudaOccupancyMaxPotentialBlockSize (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1gab3e5d4de4f1b514811746129733f61a5), [cudaOccupancyMaxPotentialBlockSizeWithFlags (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga39214f0e1b063a3e54e108f8fab44e80), [cudaOccupancyMaxPotentialBlockSizeVariableSMem (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga26aa6bf18325fdc9341bf64785f04c23), [cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga005a74fcd98441f5b5a1816baeba2b34), [`cudaOccupancyAvailableDynamicSMemPerBlock`], (C++, API), [`cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags`](crate::driver::cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaFuncGetAttributes`], (C++, API), [`cuOccupancyMaxPotentialClusterSize`](crate::driver::cuOccupancyMaxPotentialClusterSize).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_CLUSTER_SIZE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaFuncGetAttributes`], (C++, API), [`cuOccupancyMaxActiveClusters`](crate::driver::cuOccupancyMaxActiveClusters).
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, [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`] is returned. Support for managed memory can be queried using the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY`]. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. If `size` is 0, [`cudaMallocManaged`] returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]. The pointer is valid on the CPU and on all GPUs in the system that support managed memory. All accesses to this pointer must obey the Unified Memory programming model.
///
/// `flags` specifies the default stream association for this allocation. `flags` must be one of [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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]; 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. Managed memory on such GPUs may be evicted from device memory to host memory at any time by the Unified Memory driver in order to make room for other allocations.
///
/// In a system where all GPUs have a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`], managed memory may not be populated when this API returns and instead may be populated on access. In such systems, managed memory can migrate to any processor’s memory at any time. The Unified Memory driver will employ heuristics to maintain data locality and prevent excessive page faults to the extent possible. The application can also guide the driver about memory usage patterns via [`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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] and all the GPUs have peer-to-peer support with each other, the physical storage for managed memory is created on the GPU which is active at the time [`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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] is zero for at least one of those GPUs, the location chosen for physical storage of managed memory is system-dependent.
///
/// * On Linux, the location chosen will be device memory as long as the current set of active contexts are on devices that either have peer-to-peer support with each other or have a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. If there is an active context on a GPU that does not have a non-zero value for that device attribute and it does not have peer-to-peer support with the other devices that have active contexts on them, then the location for physical storage will be ‘zero-copy’ or host memory. Note that this means that managed memory that is located in device memory is migrated to host memory if a new context is created on a GPU that doesn’t have a non-zero value for the device attribute and does not support peer-to-peer with at least one of the other devices that has an active context. This in turn implies that context creation may fail if there is insufficient host memory to migrate all managed allocations.
/// * On Windows, the physical storage is always created in ‘zero-copy’ or host memory. All GPUs will reference the data at reduced bandwidth over the PCIe bus. In these circumstances, use of the environment variable CUDA_VISIBLE_DEVICES is recommended to restrict CUDA to only use those GPUs that have peer-to-peer support. Alternatively, users can also set CUDA_MANAGED_FORCE_DEVICE_ALLOC to a non-zero value to force the driver to always use device memory for physical storage. When this environment variable is set to a non-zero value, all devices used in that process that support managed memory have to be peer-to-peer compatible with each other. The error [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`] will be returned if a device that supports managed memory is used and it is not peer-to-peer compatible with any of the other managed memory supporting devices that were previously used in that process, even if [`cudaDeviceReset`] has been called on those devices. These environment variables are described in the CUDA programming guide under the “CUDA environment variables” section.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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)).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaHostAlloc`], [`cudaDeviceGetAttribute`], [`cudaStreamAttachMemAsync`], [`cuMemAllocManaged`](crate::driver::cuMemAllocManaged).
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 [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`] in case of failure.
///
/// The device version of [`cudaFree`] cannot be used with a `*devPtr` allocated using the host API, and vice versa.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `devPtr`: Pointer to allocated device memory.
/// - `size`: Requested allocation size in bytes.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_EXTERNAL_DEVICE`]
///
/// See also: [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaHostAlloc`], [`cuMemAlloc`](crate::driver::cuMemAlloc).
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*()`](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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `ptr`: Pointer to allocated host memory.
/// - `size`: Requested allocation size in bytes.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_EXTERNAL_DEVICE`]
///
/// See also: [`cudaMalloc`], [`cudaMallocPitch`], [`cudaMallocArray`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [`cudaFree`], [`cudaFreeArray`], [cudaMallocHost (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1gad5c991beb38e2b8419f50285707ae87e), [`cudaFreeHost`], [`cuMemAllocHost`](crate::driver::cuMemAllocHost).
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:
///
/// ```text
/// T* pElement = (T*)((char*)BaseAddress + Row * pitch) + Column;
/// ```
///
/// 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).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `devPtr`: Pointer to allocated pitched device memory.
/// - `pitch`: Pitch for allocation.
/// - `width`: Requested pitched allocation width (in bytes).
/// - `height`: Requested pitched allocation height.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaMalloc`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [`cuMemAllocPitch`](crate::driver::cuMemAllocPitch).
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:
///
/// ```text
/// struct cudaChannelFormatDesc {
/// int x, y, z, w;
/// enum cudaChannelFormatKind f;
/// };
/// ```
///
/// where [`cudaChannelFormatKind`] is one of [`cudaChannelFormatKind::cudaChannelFormatKindSigned`] , [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`] , or [`cudaChannelFormatKind::cudaChannelFormatKindFloat`] .
///
/// The `flags` parameter enables different options to be specified that affect the allocation, as follows.
///
/// * [cudaArrayDefault](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga6c47e87081bfd4f6030937f99ef12412): This flag’s value is defined to be 0 and provides default array allocation
/// * [cudaArraySurfaceLoadStore](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga8cb5bdac32ad53c423992a125b3f9a66): Allocates an array that can be read from or written to using a surface reference
/// * [cudaArrayTextureGather](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga142b19a14d56a03b1e410430aa5202d1): This flag indicates that texture gather operations will be performed on the array.
/// * [cudaArraySparse](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga42c353686a15da063dc7722594ae4bff): Allocates a CUDA array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling [`cuMemMapArrayAsync`](crate::driver::cuMemMapArrayAsync). The physical backing memory must be allocated via [`cuMemCreate`](crate::driver::cuMemCreate).
/// * [cudaArrayDeferredMapping](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga91a50795515848406a89c2e6cef2fb02): Allocates a CUDA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling [`cuMemMapArrayAsync`](crate::driver::cuMemMapArrayAsync). The physical backing memory must be allocated via [`cuMemCreate`](crate::driver::cuMemCreate).
///
/// `width` and `height` must meet certain size requirements. See [`cudaMalloc3DArray`] for more details.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [`cuArrayCreate`](crate::driver::cuArrayCreate).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `devPtr`: Device pointer to memory to free
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMalloc`], [`cudaMallocPitch`], [`cudaMallocManaged`], [`cudaMallocArray`], [`cudaFreeArray`], [`cudaMallocAsync`], [`cudaMallocFromPoolAsync`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaFreeAsync`], [`cudaHostAlloc`], [`cuMemFree`](crate::driver::cuMemFree).
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`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `ptr`: Pointer to memory to free
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], [`cudaMallocHost`] (C API), [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [`cuMemFreeHost`](crate::driver::cuMemFreeHost).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `array`: Pointer to array to free
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaHostAlloc`], [`cuArrayDestroy`](crate::driver::cuArrayDestroy).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `mipmappedArray`: Pointer to mipmapped array to free
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaHostAlloc`], [`cuMipmappedArrayDestroy`](crate::driver::cuMipmappedArrayDestroy).
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.
///
/// * [`cudaHostAllocDefault`]: This flag’s value is defined to be 0 and causes [`cudaHostAlloc`] to emulate [`cudaMallocHost`].
/// * [`cudaHostAllocPortable`]: The memory returned by this call will be considered as pinned memory by all CUDA contexts, not just the one that performed the allocation.
/// * [`cudaHostAllocMapped`]: Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling [`cudaHostGetDevicePointer`].
/// * [`cudaHostAllocWriteCombined`]: Allocates the memory as write-combined (WC). WC memory can be transferred across the PCI Express bus more quickly on some system configurations, but cannot be read efficiently by most CPUs. WC memory is a good option for buffers that will be written by the CPU and read by the device via mapped pinned memory or host->device transfers.
///
/// All of these flags are orthogonal to one another: a developer may allocate memory that is portable, mapped and/or write-combined with no restrictions.
///
/// 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`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pHost`: Device pointer to allocated memory.
/// - `size`: Requested allocation size in bytes.
/// - `flags`: Requested properties of allocated memory.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_EXTERNAL_DEVICE`]
///
/// See also: [`cudaSetDeviceFlags`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaGetDeviceFlags`], [`cuMemHostAlloc`](crate::driver::cuMemHostAlloc).
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_HOST_REGISTER_SUPPORTED`].
///
/// The `flags` parameter enables different options to be specified that affect the allocation, as follows.
///
/// * [`cudaHostRegisterDefault`]: On a system with unified virtual addressing, the memory will be both mapped and portable. On a system with no unified virtual addressing, the memory will be neither mapped nor portable.
/// * [`cudaHostRegisterPortable`]: The memory returned by this call will be considered as pinned memory by all CUDA contexts, not just the one that performed the allocation.
/// * [`cudaHostRegisterMapped`]: Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling [`cudaHostGetDevicePointer`].
/// * [`cudaHostRegisterIoMemory`]: The passed memory pointer is treated as pointing to some memory-mapped I/O space, e.g. belonging to a third-party PCIe device, and it will marked as non cache-coherent and contiguous.
/// * [`cudaHostRegisterReadOnly`]: The passed memory pointer is treated as pointing to memory that is considered read-only by the device. On platforms without [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`], this flag is required in order to register memory mapped to the CPU as read-only. Support for the use of this flag can be queried from the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_READ_ONLY_HOST_REGISTER_SUPPORTED`]. Using this flag with a current context associated with a device that does not have this attribute set will cause [`cudaHostRegister`] to error with cudaErrorNotSupported.
///
/// 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM`], 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`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_EXTERNAL_DEVICE`]
///
/// See also: [`cudaHostUnregister`], [`cudaHostGetFlags`], [`cudaHostGetDevicePointer`], [`cuMemHostRegister`](crate::driver::cuMemHostRegister).
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`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `ptr`: Host pointer to memory to unregister
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED`]
///
/// See also: [`cuMemHostUnregister`](crate::driver::cuMemHostUnregister).
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM`], 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pDevice`: Returned device pointer for mapped memory.
/// - `pHost`: Requested host pointer mapping.
/// - `flags`: Flags for extensions (must be 0 for now).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaSetDeviceFlags`], [`cudaHostAlloc`], [`cuMemHostGetDevicePointer`](crate::driver::cuMemHostGetDevicePointer).
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`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pFlags`: Returned flags word.
/// - `pHost`: Host pointer.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaHostAlloc`], [`cuMemHostGetFlags`](crate::driver::cuMemHostGetFlags).
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).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pitchedDevPtr`: Pointer to allocated pitched device memory.
/// - `extent`: Requested allocation size (`width` field in bytes).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaMallocPitch`], [`cudaFree`], [`cudaMemcpy3D`], [`cudaMemset3D`], [`cudaMalloc3DArray`], [`cudaMallocArray`], [`cudaFreeArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaHostAlloc`], [`make_cudaPitchedPtr`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1gac3f66f8f11f9949768ae8d10cad5a1a0), [`make_cudaExtent`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1ga66d2e640656aa155d4ed6650fc7a2a5e), [`cuMemAllocPitch`](crate::driver::cuMemAllocPitch).
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:
///
/// ```text
/// struct cudaChannelFormatDesc {
/// int x, y, z, w;
/// enum cudaChannelFormatKind f;
/// };
/// ```
///
/// where [`cudaChannelFormatKind`] is one of [`cudaChannelFormatKind::cudaChannelFormatKindSigned`] , [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`] , or [`cudaChannelFormatKind::cudaChannelFormatKindFloat`] .
///
/// [`cudaMalloc3DArray`] can allocate the following:
///
/// * A 1D array is allocated if the height and depth extents are both zero.
/// * A 2D array is allocated if only the depth extent is zero.
/// * A 3D array is allocated if all three extents are non-zero.
/// * A 1D layered CUDA array is allocated if only the height extent is zero and the cudaArrayLayered flag is set. Each layer is a 1D array. The number of layers is determined by the depth extent.
/// * A 2D layered CUDA array is allocated if all three extents are non-zero and the cudaArrayLayered flag is set. Each layer is a 2D array. The number of layers is determined by the depth extent.
/// * A cubemap CUDA array is allocated if all three extents are non-zero and the cudaArrayCubemap flag is set. Width must be equal to height, and depth must be six. A cubemap is a special type of 2D layered CUDA array, where the six layers represent the six faces of a cube. The order of the six layers in memory is the same as that listed in [cudaGraphicsCubeFace](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gabf3ce16a621826a09263b8a58902fee8).
/// * A cubemap layered CUDA array is allocated if all three extents are non-zero, and both, cudaArrayCubemap and cudaArrayLayered flags are set. Width must be equal to height, and depth must be a multiple of six. A cubemap layered CUDA array is a special type of 2D layered CUDA array that consists of a collection of cubemaps. The first six layers represent the first cubemap, the next six layers form the second cubemap, and so on.
///
/// The `flags` parameter enables different options to be specified that affect the allocation, as follows.
///
/// * [cudaArrayDefault](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga6c47e87081bfd4f6030937f99ef12412): This flag’s value is defined to be 0 and provides default array allocation
/// * [cudaArrayLayered](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga6d9a27dfb1207df13de0e822f75f4ab8): Allocates a layered CUDA array, with the depth extent indicating the number of layers
/// * [cudaArrayCubemap](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga802843d69ca8be35ee050ff66782179e): Allocates a cubemap CUDA array. Width must be equal to height, and depth must be six. If the cudaArrayLayered flag is also set, depth must be a multiple of six.
/// * [cudaArraySurfaceLoadStore](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga8cb5bdac32ad53c423992a125b3f9a66): Allocates a CUDA array that could be read from or written to using a surface reference.
/// * [cudaArrayTextureGather](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga142b19a14d56a03b1e410430aa5202d1): This flag indicates that texture gather operations will be performed on the CUDA array. Texture gather can only be performed on 2D CUDA arrays.
/// * [cudaArraySparse](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga42c353686a15da063dc7722594ae4bff): Allocates a CUDA array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling [`cuMemMapArrayAsync`](crate::driver::cuMemMapArrayAsync). This flag can only be used for creating 2D, 3D or 2D layered sparse CUDA arrays. The physical backing memory must be allocated via [`cuMemCreate`](crate::driver::cuMemCreate).
/// * [cudaArrayDeferredMapping](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga91a50795515848406a89c2e6cef2fb02): Allocates a CUDA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling [`cuMemMapArrayAsync`](crate::driver::cuMemMapArrayAsync). The physical backing memory must be allocated via [`cuMemCreate`](crate::driver::cuMemCreate).
///
/// 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).
///
/// | CUDA array type | Valid extents that must always be met {(width range in elements), (height range), (depth range)} | Valid extents with cudaArraySurfaceLoadStore set {(width range in elements), (height range), (depth range)} |
/// | --- | --- | --- |
/// | 1D | { (1,maxTexture1D), 0, 0 } | { (1,maxSurface1D), 0, 0 } |
/// | 2D | { (1,maxTexture2D\[0\]), (1,maxTexture2D\[1\]), 0 } | { (1,maxSurface2D\[0\]), (1,maxSurface2D\[1\]), 0 } |
/// | 3D | { (1,maxTexture3D\[0\]), (1,maxTexture3D\[1\]), (1,maxTexture3D\[2\]) } OR { (1,maxTexture3DAlt\[0\]), (1,maxTexture3DAlt\[1\]), (1,maxTexture3DAlt\[2\]) } | { (1,maxSurface3D\[0\]), (1,maxSurface3D\[1\]), (1,maxSurface3D\[2\]) } |
/// | 1D Layered | { (1,maxTexture1DLayered\[0\]), 0, (1,maxTexture1DLayered\[1\]) } | { (1,maxSurface1DLayered\[0\]), 0, (1,maxSurface1DLayered\[1\]) } |
/// | 2D Layered | { (1,maxTexture2DLayered\[0\]), (1,maxTexture2DLayered\[1\]), (1,maxTexture2DLayered\[2\]) } | { (1,maxSurface2DLayered\[0\]), (1,maxSurface2DLayered\[1\]), (1,maxSurface2DLayered\[2\]) } |
/// | Cubemap | { (1,maxTextureCubemap), (1,maxTextureCubemap), 6 } | { (1,maxSurfaceCubemap), (1,maxSurfaceCubemap), 6 } |
/// | Cubemap Layered | { (1,maxTextureCubemapLayered\[0\]), (1,maxTextureCubemapLayered\[0\]), (1,maxTextureCubemapLayered\[1\]) } | { (1,maxSurfaceCubemapLayered\[0\]), (1,maxSurfaceCubemapLayered\[0\]), (1,maxSurfaceCubemapLayered\[1\]) } |
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaMalloc3D`], [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaHostAlloc`], [`make_cudaExtent`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1ga66d2e640656aa155d4ed6650fc7a2a5e), [`cuArray3DCreate`](crate::driver::cuArray3DCreate).
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:
///
/// ```text
/// struct cudaChannelFormatDesc {
/// int x, y, z, w;
/// enum cudaChannelFormatKind f;
/// };
/// ```
///
/// where [`cudaChannelFormatKind`] is one of [`cudaChannelFormatKind::cudaChannelFormatKindSigned`] , [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`] , or [`cudaChannelFormatKind::cudaChannelFormatKindFloat`] .
///
/// [`cudaMallocMipmappedArray`] can allocate the following:
///
/// * A 1D mipmapped array is allocated if the height and depth extents are both zero.
/// * A 2D mipmapped array is allocated if only the depth extent is zero.
/// * A 3D mipmapped array is allocated if all three extents are non-zero.
/// * A 1D layered CUDA mipmapped array is allocated if only the height extent is zero and the cudaArrayLayered flag is set. Each layer is a 1D mipmapped array. The number of layers is determined by the depth extent.
/// * A 2D layered CUDA mipmapped array is allocated if all three extents are non-zero and the cudaArrayLayered flag is set. Each layer is a 2D mipmapped array. The number of layers is determined by the depth extent.
/// * A cubemap CUDA mipmapped array is allocated if all three extents are non-zero and the cudaArrayCubemap flag is set. Width must be equal to height, and depth must be six. The order of the six layers in memory is the same as that listed in [cudaGraphicsCubeFace](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gabf3ce16a621826a09263b8a58902fee8).
/// * A cubemap layered CUDA mipmapped array is allocated if all three extents are non-zero, and both, cudaArrayCubemap and cudaArrayLayered flags are set. Width must be equal to height, and depth must be a multiple of six. A cubemap layered CUDA mipmapped array is a special type of 2D layered CUDA mipmapped array that consists of a collection of cubemap mipmapped arrays. The first six layers represent the first cubemap mipmapped array, the next six layers form the second cubemap mipmapped array, and so on.
///
/// The `flags` parameter enables different options to be specified that affect the allocation, as follows.
///
/// * [cudaArrayDefault](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga6c47e87081bfd4f6030937f99ef12412): This flag’s value is defined to be 0 and provides default mipmapped array allocation
/// * [cudaArrayLayered](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga6d9a27dfb1207df13de0e822f75f4ab8): Allocates a layered CUDA mipmapped array, with the depth extent indicating the number of layers
/// * [cudaArrayCubemap](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga802843d69ca8be35ee050ff66782179e): Allocates a cubemap CUDA mipmapped array. Width must be equal to height, and depth must be six. If the cudaArrayLayered flag is also set, depth must be a multiple of six.
/// * [cudaArraySurfaceLoadStore](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga8cb5bdac32ad53c423992a125b3f9a66): This flag indicates that individual mipmap levels of the CUDA mipmapped array will be read from or written to using a surface reference.
/// * [cudaArrayTextureGather](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga142b19a14d56a03b1e410430aa5202d1): This flag indicates that texture gather operations will be performed on the CUDA array. Texture gather can only be performed on 2D CUDA mipmapped arrays, and the gather operations are performed only on the most detailed mipmap level.
/// * [cudaArraySparse](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga42c353686a15da063dc7722594ae4bff): Allocates a CUDA mipmapped array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling [`cuMemMapArrayAsync`](crate::driver::cuMemMapArrayAsync). This flag can only be used for creating 2D, 3D or 2D layered sparse CUDA mipmapped arrays. The physical backing memory must be allocated via [`cuMemCreate`](crate::driver::cuMemCreate).
/// * [cudaArrayDeferredMapping](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga91a50795515848406a89c2e6cef2fb02): Allocates a CUDA mipmapped array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling [`cuMemMapArrayAsync`](crate::driver::cuMemMapArrayAsync). The physical backing memory must be allocated via [`cuMemCreate`](crate::driver::cuMemCreate).
///
/// The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified in elements.
///
/// | CUDA array type | Valid extents that must always be met {(width range in elements), (height range), (depth range)} | Valid extents with cudaArraySurfaceLoadStore set {(width range in elements), (height range), (depth range)} |
/// | --- | --- | --- |
/// | 1D | { (1,maxTexture1DMipmap), 0, 0 } | { (1,maxSurface1D), 0, 0 } |
/// | 2D | { (1,maxTexture2DMipmap\[0\]), (1,maxTexture2DMipmap\[1\]), 0 } | { (1,maxSurface2D\[0\]), (1,maxSurface2D\[1\]), 0 } |
/// | 3D | { (1,maxTexture3D\[0\]), (1,maxTexture3D\[1\]), (1,maxTexture3D\[2\]) } OR { (1,maxTexture3DAlt\[0\]), (1,maxTexture3DAlt\[1\]), (1,maxTexture3DAlt\[2\]) } | { (1,maxSurface3D\[0\]), (1,maxSurface3D\[1\]), (1,maxSurface3D\[2\]) } |
/// | 1D Layered | { (1,maxTexture1DLayered\[0\]), 0, (1,maxTexture1DLayered\[1\]) } | { (1,maxSurface1DLayered\[0\]), 0, (1,maxSurface1DLayered\[1\]) } |
/// | 2D Layered | { (1,maxTexture2DLayered\[0\]), (1,maxTexture2DLayered\[1\]), (1,maxTexture2DLayered\[2\]) } | { (1,maxSurface2DLayered\[0\]), (1,maxSurface2DLayered\[1\]), (1,maxSurface2DLayered\[2\]) } |
/// | Cubemap | { (1,maxTextureCubemap), (1,maxTextureCubemap), 6 } | { (1,maxSurfaceCubemap), (1,maxSurfaceCubemap), 6 } |
/// | Cubemap Layered | { (1,maxTextureCubemapLayered\[0\]), (1,maxTextureCubemapLayered\[0\]), (1,maxTextureCubemapLayered\[1\]) } | { (1,maxSurfaceCubemapLayered\[0\]), (1,maxSurfaceCubemapLayered\[0\]), (1,maxSurfaceCubemapLayered\[1\]) } |
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaMalloc3D`], [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaHostAlloc`], [`make_cudaExtent`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1ga66d2e640656aa155d4ed6650fc7a2a5e), [`cuMipmappedArrayCreate`](crate::driver::cuMipmappedArrayCreate).
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, [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// If `mipmappedArray` is NULL, [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] is returned.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `levelArray`: Returned mipmap level CUDA array.
/// - `mipmappedArray`: CUDA mipmapped array.
/// - `level`: Mipmap level.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaMalloc3D`], [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], [`cudaMallocHost`] (C API), [`cudaFreeHost`], [`cudaHostAlloc`], [`make_cudaExtent`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1ga66d2e640656aa155d4ed6650fc7a2a5e), [`cuMipmappedArrayGetLevel`](crate::driver::cuMipmappedArrayGetLevel).
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.
///
/// ```text
/// struct cudaExtent {
/// size_t width;
/// size_t height;
/// size_t depth;
/// };
/// struct cudaExtent make_cudaExtent(size_t w, size_t h, size_t d);
///
/// struct cudaPos {
/// size_t x;
/// size_t y;
/// size_t z;
/// };
/// struct cudaPos make_cudaPos(size_t x, size_t y, size_t z);
///
/// struct cudaMemcpy3DParms {
/// cudaArray_t srcArray;
/// struct cudaPos srcPos;
/// struct cudaPitchedPtr srcPtr;
/// cudaArray_t dstArray;
/// struct cudaPos dstPos;
/// struct cudaPitchedPtr dstPtr;
/// struct cudaExtent extent;
/// enum cudaMemcpyKind kind;
/// };
/// ```
///
/// [`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:
///
/// ```text
/// cudaMemcpy3DParms myParms = {0};
/// ```
///
/// 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `p`: 3D memory copy parameters
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaMemset3D`], [`cudaMemcpy3DAsync`], [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`make_cudaExtent`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1ga66d2e640656aa155d4ed6650fc7a2a5e), [`make_cudaPos`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1gafdde5695fcf95a6ec8899c3943f7dd8c), [`cuMemcpy3D`](crate::driver::cuMemcpy3D).
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).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `p`: Parameters for the memory copy
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpyPeerAsync`], [`cudaMemcpy3DPeerAsync`], [`cuMemcpy3DPeer`](crate::driver::cuMemcpy3DPeer).
pub fn cudaMemcpy3DPeer(p: *const cudaMemcpy3DPeerParms) -> cudaError_t;
}
singe_loader::functions! { crate::RUNTIME;
/// Copies data between 3D objects.
///
/// ```text
/// struct cudaExtent {
/// size_t width;
/// size_t height;
/// size_t depth;
/// };
/// struct cudaExtent make_cudaExtent(size_t w, size_t h, size_t d);
///
/// struct cudaPos {
/// size_t x;
/// size_t y;
/// size_t z;
/// };
/// struct cudaPos make_cudaPos(size_t x, size_t y, size_t z);
///
/// struct cudaMemcpy3DParms {
/// cudaArray_t srcArray;
/// struct cudaPos srcPos;
/// struct cudaPitchedPtr srcPtr;
/// cudaArray_t dstArray;
/// struct cudaPos dstPos;
/// struct cudaPitchedPtr dstPtr;
/// struct cudaExtent extent;
/// enum cudaMemcpyKind kind;
/// };
/// ```
///
/// [`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:
///
/// ```text
/// cudaMemcpy3DParms myParms = {0};
/// ```
///
/// 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 [`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, [`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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `p`: 3D memory copy parameters.
/// - `stream`: Stream identifier.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaMemset3D`], [`cudaMemcpy3D`], [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], :, [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`make_cudaExtent`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1ga66d2e640656aa155d4ed6650fc7a2a5e), [`make_cudaPos`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1gafdde5695fcf95a6ec8899c3943f7dd8c), [`cuMemcpy3DAsync`](crate::driver::cuMemcpy3DAsync).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `p`: Parameters for the memory copy.
/// - `stream`: Stream identifier.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpyPeerAsync`], [`cuMemcpy3DPeerAsync`](crate::driver::cuMemcpy3DPeerAsync).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `free`: Returned free memory in bytes.
/// - `total`: Returned total memory in bytes.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_LAUNCH_FAILED`]
///
/// See also: [`cuMemGetInfo`](crate::driver::cuMemGetInfo).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cuArrayGetDescriptor`](crate::driver::cuArrayGetDescriptor), [`cuArray3DGetDescriptor`](crate::driver::cuArray3DGetDescriptor).
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `pPlaneArray`: Returned CUDA array referenced by the `planeIdx`.
/// - `hArray`: CUDA array.
/// - `planeIdx`: Plane index.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cuArrayGetPlane`](crate::driver::cuArrayGetPlane).
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) [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] will be returned.
///
/// The returned value in [`cudaArrayMemoryRequirements::size`](crate::driver::CUDA_ARRAY_MEMORY_REQUIREMENTS_st::size) represents the total size of the CUDA array. The returned value in [`cudaArrayMemoryRequirements::alignment`](crate::driver::CUDA_ARRAY_MEMORY_REQUIREMENTS_st::alignment) represents the alignment necessary for mapping the CUDA array.
///
/// # Parameters
///
/// - `memoryRequirements`: Pointer to [`cudaArrayMemoryRequirements`].
/// - `array`: CUDA array to get the memory requirements of.
/// - `device`: Device to get the memory requirements for.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMipmappedArrayGetMemoryRequirements`].
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) [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] will be returned.
///
/// The returned value in [`cudaArrayMemoryRequirements::size`](crate::driver::CUDA_ARRAY_MEMORY_REQUIREMENTS_st::size) represents the total size of the CUDA mipmapped array. The returned value in [`cudaArrayMemoryRequirements::alignment`](crate::driver::CUDA_ARRAY_MEMORY_REQUIREMENTS_st::alignment) represents the alignment necessary for mapping the CUDA mipmapped array.
///
/// # Parameters
///
/// - `memoryRequirements`: Pointer to [`cudaArrayMemoryRequirements`].
/// - `mipmap`: CUDA mipmapped array to get the memory requirements of.
/// - `device`: Device to get the memory requirements for.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaArrayGetMemoryRequirements`].
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) [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] will be returned.
///
/// If the returned value in [`cudaArraySparseProperties::flags`](crate::driver::CUDA_ARRAY_SPARSE_PROPERTIES_st::flags) 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`](crate::driver::CUDA_ARRAY_SPARSE_PROPERTIES_st::miptailSize) represents the total size of the array. Otherwise, it will be zero. Also, the returned value in [`cudaArraySparseProperties::miptailFirstLevel`](crate::driver::CUDA_ARRAY_SPARSE_PROPERTIES_st::miptailFirstLevel) is always zero. Note that the `array` must have been allocated using [`cudaMallocArray`] or [`cudaMalloc3DArray`]. For CUDA arrays obtained using `cudaMipmappedArrayGetLevel`, [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] 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`].
/// - `array`: The CUDA array to get the sparse properties of.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMipmappedArrayGetSparseProperties`], [`cuMemMapArrayAsync`](crate::driver::cuMemMapArrayAsync).
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) [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] will be returned.
///
/// For non-layered CUDA mipmapped arrays, [`cudaArraySparseProperties::miptailSize`](crate::driver::CUDA_ARRAY_SPARSE_PROPERTIES_st::miptailSize) 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`](crate::driver::CUDA_ARRAY_SPARSE_PROPERTIES_st::flags) 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`](crate::driver::CUDA_ARRAY_SPARSE_PROPERTIES_st::miptailSize) specifies the size of the mip tail of all layers combined. Otherwise, [`cudaArraySparseProperties::miptailSize`](crate::driver::CUDA_ARRAY_SPARSE_PROPERTIES_st::miptailSize) specifies mip tail size per layer. The returned value of [`cudaArraySparseProperties::miptailFirstLevel`](crate::driver::CUDA_ARRAY_SPARSE_PROPERTIES_st::miptailFirstLevel) is valid only if [`cudaArraySparseProperties::miptailSize`](crate::driver::CUDA_ARRAY_SPARSE_PROPERTIES_st::miptailSize) is non-zero.
///
/// # Parameters
///
/// - `sparseProperties`: Pointer to return [`cudaArraySparseProperties`].
/// - `mipmap`: The CUDA mipmapped array to get the sparse properties of.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaArrayGetSparseProperties`], [`cuMemMapArrayAsync`](crate::driver::cuMemMapArrayAsync).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpyDtoH`](crate::driver::cuMemcpyDtoH), [`cuMemcpyHtoD`](crate::driver::cuMemcpyHtoD), [`cuMemcpyDtoD`](crate::driver::cuMemcpyDtoD), [`cuMemcpy`](crate::driver::cuMemcpy).
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).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `dst`: Destination device pointer.
/// - `dstDevice`: Destination device.
/// - `src`: Source device pointer.
/// - `srcDevice`: Source device.
/// - `count`: Size of memory copy in bytes.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaMemcpy`], [`cudaMemcpyAsync`], [`cudaMemcpyPeerAsync`], [`cudaMemcpy3DPeerAsync`], [`cuMemcpyPeer`](crate::driver::cuMemcpyPeer).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpy2D`](crate::driver::cuMemcpy2D), [`cuMemcpy2DUnaligned`](crate::driver::cuMemcpy2DUnaligned).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpy2D`](crate::driver::cuMemcpy2D), [`cuMemcpy2DUnaligned`](crate::driver::cuMemcpy2DUnaligned).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpy2D`](crate::driver::cuMemcpy2D), [`cuMemcpy2DUnaligned`](crate::driver::cuMemcpy2DUnaligned).
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpy2D`](crate::driver::cuMemcpy2D), [`cuMemcpy2DUnaligned`](crate::driver::cuMemcpy2DUnaligned).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note: Use of a string naming a variable as the `symbol` parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidSymbol`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpy`](crate::driver::cuMemcpy), [`cuMemcpyHtoD`](crate::driver::cuMemcpyHtoD), [`cuMemcpyDtoD`](crate::driver::cuMemcpyDtoD).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note: Use of a string naming a variable as the `symbol` parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidSymbol`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpy`](crate::driver::cuMemcpy), [`cuMemcpyDtoH`](crate::driver::cuMemcpyDtoH), [`cuMemcpyDtoD`](crate::driver::cuMemcpyDtoD).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpyAsync`](crate::driver::cuMemcpyAsync), [`cuMemcpyDtoHAsync`](crate::driver::cuMemcpyDtoHAsync), [`cuMemcpyHtoDAsync`](crate::driver::cuMemcpyHtoDAsync), [`cuMemcpyDtoDAsync`](crate::driver::cuMemcpyDtoDAsync).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpy3DPeerAsync`], [`cuMemcpyPeerAsync`](crate::driver::cuMemcpyPeerAsync).
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`](crate::driver::CUmemcpyAttributes_st::srcAccessOrder) 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`] corresponding to it including the appropriate srcAccessOrder setting, otherwise the API will return [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// The [`cudaMemcpyAttributes::srcLocHint`](crate::driver::CUmemcpyAttributes_st::srcLocHint) and [`cudaMemcpyAttributes::dstLocHint`](crate::driver::CUmemcpyAttributes_st::dstLocHint) 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] is true or system-allocated pageable memory on devices where [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`] is true. For other cases, these hints are ignored.
///
/// The [`cudaMemcpyAttributes::flags`](crate::driver::CUmemcpyAttributes_st::flags) 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # Parameters
///
/// - `dsts`: Array of destination pointers.
/// - `srcs`: Array of memcpy source pointers.
/// - `sizes`: Array of sizes for memcpy operations.
/// - `count`: Size of `dsts`, `srcs` and `sizes` arrays.
/// - `attrs`: Array of memcpy attributes.
/// - `attrsIdxs`: Array of indices to specify which copies each entry in the `attrs` array applies to. The attributes specified in attrs\[k\] will be applied to copies starting from attrsIdxs\[k\] through attrsIdxs\[k+1\] - 1. Also attrs\[numAttrs-1\] will apply to copies starting from attrsIdxs\[numAttrs-1\] through count - 1.
/// - `numAttrs`: Size of `attrs` and `attrsIdxs` arrays.
/// - `stream`: The stream to enqueue the operations in. Must not be legacy NULL stream.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
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`](crate::driver::CUDA_MEMCPY3D_BATCH_OP_st::src) and [`cudaMemcpy3DBatchOp::dst`](crate::driver::CUDA_MEMCPY3D_BATCH_OP_st::dst) respectively. The source and destination operands of a copy can either be a pointer or a CUDA array. The width, height and depth of a copy is specified in [`cudaMemcpy3DBatchOp::extent`](crate::driver::CUDA_MEMCPY3D_BATCH_OP_st::extent). The width, height and depth of a copy are specified in elements and must not be zero. For pointer-to-pointer copies, the element size is considered to be 1. For pointer to CUDA array or vice versa copies, the element size is determined by the CUDA array. For CUDA array to CUDA array copies, the element size of the two CUDA arrays must match.
///
/// For a given operand, if 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] is true or system-allocated pageable memory on devices where [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`] 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`](crate::driver::CUmemcpyAttributes_st::srcAccessOrder) 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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// The [`cudaMemcpyAttributes::flags`](crate::driver::CUmemcpyAttributes_st::flags) 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # Parameters
///
/// - `numOps`: Total number of memcpy operations.
/// - `opList`: Array of size `numOps` containing the actual memcpy operations.
/// - `flags`: Flags for future use, must be zero now.
/// - `stream`: The stream to enqueue the operations in. Must not be default NULL stream.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
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`] and it’s usage desciption in::cudaMemcpyBatchAsync.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemcpyBatchAsync`].
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`] and it’s usage desciption in::cudaMemcpy3DBatchAsync.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # Parameters
///
/// - `op`: Operation to perform.
/// - `flags`: Flags for the copy, must be zero now.
/// - `stream`: Stream to enqueue the operation in.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemcpy3DBatchAsync`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpy2DAsync`](crate::driver::cuMemcpy2DAsync).
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`](crate::driver::cuMemcpy2DAsync).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`].
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`](crate::driver::cuMemcpy2DAsync).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and will return CUDA_ERROR_INVALID_VALUE.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidPitchValue`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a225c65c0348cced651d5dd87ccc22f48)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note: Use of a string naming a variable as the `symbol` parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidSymbol`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpyAsync`](crate::driver::cuMemcpyAsync), [`cuMemcpyHtoDAsync`](crate::driver::cuMemcpyHtoDAsync), [`cuMemcpyDtoDAsync`](crate::driver::cuMemcpyDtoDAsync).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note: Use of a string naming a variable as the `symbol` parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidSymbol`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a)
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cuMemcpyAsync`](crate::driver::cuMemcpyAsync), [`cuMemcpyDtoHAsync`](crate::driver::cuMemcpyDtoHAsync), [`cuMemcpyDtoDAsync`](crate::driver::cuMemcpyDtoDAsync).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: See also memset synchronization details.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `devPtr`: Pointer to device memory.
/// - `value`: Value to set for each byte of specified memory.
/// - `count`: Size in bytes to set.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cuMemsetD8`](crate::driver::cuMemsetD8), [`cuMemsetD16`](crate::driver::cuMemsetD16), [`cuMemsetD32`](crate::driver::cuMemsetD32).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: See also memset synchronization details.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemset`], [`cudaMemset3D`], [`cudaMemsetAsync`], [`cudaMemset2DAsync`], [`cudaMemset3DAsync`], [`cuMemsetD2D8`](crate::driver::cuMemsetD2D8), [`cuMemsetD2D16`](crate::driver::cuMemsetD2D16), [`cuMemsetD2D32`](crate::driver::cuMemsetD2D32).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: See also memset synchronization details.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemset`], [`cudaMemset2D`], [`cudaMemsetAsync`], [`cudaMemset2DAsync`], [`cudaMemset3DAsync`], [`cudaMalloc3D`], [`make_cudaPitchedPtr`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1gac3f66f8f11f9949768ae8d10cad5a1a0), [`make_cudaExtent`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1ga66d2e640656aa155d4ed6650fc7a2a5e).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: See also memset synchronization details.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemset`], [`cudaMemset2D`], [`cudaMemset3D`], [`cudaMemset2DAsync`], [`cudaMemset3DAsync`], [`cuMemsetD8Async`](crate::driver::cuMemsetD8Async), [`cuMemsetD16Async`](crate::driver::cuMemsetD16Async), [`cuMemsetD32Async`](crate::driver::cuMemsetD32Async).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: See also memset synchronization details.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemset`], [`cudaMemset2D`], [`cudaMemset3D`], [`cudaMemsetAsync`], [`cudaMemset3DAsync`], [`cuMemsetD2D8Async`](crate::driver::cuMemsetD2D8Async), [`cuMemsetD2D16Async`](crate::driver::cuMemsetD2D16Async), [`cuMemsetD2D32Async`](crate::driver::cuMemsetD2D32Async).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: See also memset synchronization details.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemset`], [`cudaMemset2D`], [`cudaMemset3D`], [`cudaMemsetAsync`], [`cudaMemset2DAsync`], [`cudaMalloc3D`], [`make_cudaPitchedPtr`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1gac3f66f8f11f9949768ae8d10cad5a1a0), [`make_cudaExtent`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__MEMORY.html#group__cudart__memory_1ga66d2e640656aa155d4ed6650fc7a2a5e).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: Use of a string naming a variable as the `symbol` parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `devPtr`: Return device pointer associated with symbol.
/// - `symbol`: Device symbol address.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidSymbol`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a)
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
///
/// See also: [cudaGetSymbolAddress (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1gab4ba467fefaf5bd30bfcc398cc8fe978), [`cudaGetSymbolSize`] (C API), [`cuModuleGetGlobal`](crate::driver::cuModuleGetGlobal).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: Use of a string naming a variable as the `symbol` parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `size`: Size of object associated with symbol.
/// - `symbol`: Device symbol address.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidSymbol`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a01a4a97f3060ec714ffa9dd650b9213a)
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
///
/// See also: [`cudaGetSymbolAddress`] (C API), [cudaGetSymbolSize (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1gab3d89a5d7d8d7fd72d9a99cf714fef9e), [`cuModuleGetGlobal`](crate::driver::cuModuleGetGlobal).
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`](crate::driver::CUmemLocation_st::type_) 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`](crate::driver::CUmemLocation_st::type_) 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`](crate::driver::CUmemLocation_st::type_) 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`](crate::driver::CUmemLocation_st::type_). Note when [`cudaMemLocation::type`](crate::driver::CUmemLocation_st::type_) 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`](crate::driver::cuMemAdvise) as described below:
///
/// If [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_READ_MOSTLY`] was set on any subset of this memory range, then that subset will create a read-only copy of the pages on destination location. If however the destination location is a host NUMA node, then any pages of that subset that are already in another host NUMA node will be transferred to the destination.
///
/// If [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_PREFERRED_LOCATION`] was called on any subset of this memory range, then the pages will be migrated to `location` even if `location` is not the preferred location of any pages in the memory range.
///
/// If [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_ACCESSED_BY`] was called on any subset of this memory range, then mappings to those pages from all the appropriate processors are updated to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared.
///
/// Note that this API is not required for functionality and only serves to improve performance by allowing the application to migrate data to a suitable location before it is accessed. Memory accesses to this range are always coherent and are allowed even when the data is actively being migrated.
///
/// Note that this function is asynchronous with respect to the host and all work on other devices.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpy3DPeerAsync`], [`cudaMemAdvise`], [`cuMemPrefetchAsync`](crate::driver::cuMemPrefetchAsync).
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`]. The prefetch location for every operation in the batch is specified in the `prefetchLocs` array. Each entry in this array can apply to more than one operation. This can be done by specifying in the `prefetchLocIdxs` array, the index of the first prefetch operation that the corresponding entry in the `prefetchLocs` array applies to. Both `prefetchLocs` and `prefetchLocIdxs` must be of the same length as specified by `numPrefetchLocs`. For example, if a batch has 10 prefetches listed in dptrs/sizes, the first 4 of which are to be prefetched to one location and the remaining 6 are to be prefetched to another, then `numPrefetchLocs` will be 2, `prefetchLocIdxs` will be {0, 4} and `prefetchLocs` will contain the two locations. Note the first entry in `prefetchLocIdxs` must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than `count`. Furthermore, `numPrefetchLocs` must be lesser than or equal to `count`.
///
/// # Parameters
///
/// - `dptrs`: Array of pointers to be prefetched.
/// - `sizes`: Array of sizes for memory prefetch operations.
/// - `count`: Size of `dptrs` and `sizes` arrays.
/// - `prefetchLocs`: Array of locations to prefetch to.
/// - `prefetchLocIdxs`: Array of indices to specify which operands each entry in the `prefetchLocs` array applies to. The locations specified in prefetchLocs\[k\] will be applied to copies starting from prefetchLocIdxs\[k\] through prefetchLocIdxs\[k+1\] - 1. Also prefetchLocs\[numPrefetchLocs - 1\] will apply to prefetches starting from prefetchLocIdxs\[numPrefetchLocs - 1\] through count - 1.
/// - `numPrefetchLocs`: Size of `prefetchLocs` and `prefetchLocIdxs` arrays.
/// - `flags`: Flags reserved for future use. Must be zero.
/// - `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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] otherwise the API will return an error.
///
/// Discarding a memory range informs the driver that the contents of that range are no longer useful. Discarding memory ranges allows the driver to optimize certain data migrations and can also help reduce memory pressure. This operation can be undone on any part of the range by either writing to it or prefetching it via [`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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`].
///
/// # Parameters
///
/// - `dptrs`: Array of pointers to be discarded.
/// - `sizes`: Array of sizes for memory discard operations.
/// - `count`: Size of `dptrs` and `sizes` arrays.
/// - `flags`: Flags reserved for future use. Must be zero.
/// - `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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`]. Every operation in the batch has to be associated with a valid location to prefetch the address range to and specified in the `prefetchLocs` array. Each entry in this array can apply to more than one operation. This can be done by specifying in the `prefetchLocIdxs` array, the index of the first operation that the corresponding entry in the `prefetchLocs` array applies to. Both `prefetchLocs` and `prefetchLocIdxs` must be of the same length as specified by `numPrefetchLocs`. For example, if a batch has 10 operations listed in dptrs/sizes, the first 6 of which are to be prefetched to one location and the remaining 4 are to be prefetched to another, then `numPrefetchLocs` will be 2, `prefetchLocIdxs` will be {0, 6} and `prefetchLocs` will contain the two set of locations. Note the first entry in `prefetchLocIdxs` must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than `count`. Furthermore, `numPrefetchLocs` must be lesser than or equal to `count`.
///
/// # Parameters
///
/// - `dptrs`: Array of pointers to be discarded.
/// - `sizes`: Array of sizes for memory discard operations.
/// - `count`: Size of `dptrs` and `sizes` arrays.
/// - `prefetchLocs`: Array of locations to prefetch to.
/// - `prefetchLocIdxs`: Array of indices to specify which operands each entry in the `prefetchLocs` array applies to. The locations specified in prefetchLocs\[k\] will be applied to operations starting from prefetchLocIdxs\[k\] through prefetchLocIdxs\[k+1\] - 1. Also prefetchLocs\[numPrefetchLocs - 1\] will apply to copies starting from prefetchLocIdxs\[numPrefetchLocs - 1\] through count - 1.
/// - `numPrefetchLocs`: Size of `prefetchLocs` and `prefetchLocIdxs` arrays.
/// - `flags`: Flags reserved for future use. Must be zero.
/// - `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:
///
/// * Divide the 1GB range into 8 summary regions of 128MB each
/// * Within each 128MB region, sample every 2MB to determine the most common location. If there is a tie a random winner is chosen.
/// * Populate the `location_out` array with 8 entries, one for each 128MB region `summaryGranularity` should be less than or equal to `size` and greater than 0. `samplingGranularity` should be less than or equal to `summaryGranularity`. If the `samplingGranularity` is set to 0 it is set to a system dependent default value. In all other cases, the call returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// When the memory is not resident on any processor, the call returns [`cudaError_t::CUDA_SUCCESS`] 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:
///
/// * Managed memory allocated via [`cudaMallocManaged`], via [`cudaMallocFromPoolAsync`] from a managed memory pool or declared via **managed** variables.
/// * System-allocated pageable memory that is not registered via [`cudaHostRegister`]. If the memory range does not refer to one of the above, the call returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// All devices on the system must have non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. If not, this call returns [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
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:
///
/// * [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_READ_MOSTLY`]: This implies that the data is mostly going to be read from and only occasionally written to. Any read accesses from any processor to this region will create a read-only copy of at least the accessed pages in that processor’s memory. Additionally, if [`cudaMemPrefetchAsync`] or [`cudaMemPrefetchAsync`] is called on this region, it will create a read-only copy of the data on the destination processor. If the target location for [`cudaMemPrefetchAsync`] is a host NUMA node and a read-only copy already exists on another host NUMA node, that copy will be migrated to the targeted host NUMA node. If any processor writes to this region, all copies of the corresponding page will be invalidated except for the one where the write occurred. If the writing processor is the CPU and the preferred location of the page is a host NUMA node, then the page will also be migrated to that host NUMA node. The `location` argument is ignored for this advice. Note that for a page to be read-duplicated, the accessing processor must either be the CPU or a GPU that has a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. Also, if a context is created on a device that does not have the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] set, then read-duplication will not occur until all such contexts are destroyed. If the memory region refers to valid system-allocated pageable memory, then the accessing device must have a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`] for a read-only copy to be created on that device. Note however that if the accessing device also has a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`], then setting this advice will not create a read-only copy when that device accesses this memory region.
/// * `cudaMemAdviceUnsetReadMostly`: Undoes the effect of [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_READ_MOSTLY`] and also prevents the Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated copies of the data will be collapsed into a single copy. The location for the collapsed copy will be the preferred location if the page has a preferred location and one of the read-duplicated copies was resident at that location. Otherwise, the location chosen is arbitrary. Note: The `location` argument is ignored for this advice.
/// * [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_PREFERRED_LOCATION`]: This advice sets the preferred location for the data to be the memory belonging to `location`. When [`cudaMemLocation::type`](crate::driver::CUmemLocation_st::type_) is [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5), [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) is ignored and the preferred location is set to be host memory. To set the preferred location to a specific host NUMA node, applications must set [`cudaMemLocation::type`](crate::driver::CUmemLocation_st::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 [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) must specify the NUMA ID of the host NUMA node. If [`cudaMemLocation::type`](crate::driver::CUmemLocation_st::type_) is set to [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 and the host NUMA node closest to the calling thread’s CPU will be used as the preferred location. If [`cudaMemLocation::type`](crate::driver::CUmemLocation_st::type_) is a [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4), then [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) must be a valid device ordinal and the device must have a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`]. Setting the preferred location does not cause data to migrate to that location immediately. Instead, it guides the migration policy when a fault occurs on that memory region. If the data is already in its preferred location and the faulting processor can establish a mapping without requiring the data to be migrated, then data migration will be avoided. On the other hand, if the data is not in its preferred location or if a direct mapping cannot be established, then it will be migrated to the processor accessing it. It is important to note that setting the preferred location does not prevent data prefetching done using [`cudaMemPrefetchAsync`]. Having a preferred location can override the page thrash detection and resolution logic in the Unified Memory driver. Normally, if a page is detected to be constantly thrashing between for example host and device memory, the page may eventually be pinned to host memory by the Unified Memory driver. But if the preferred location is set as device memory, then the page will continue to thrash indefinitely. If [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_READ_MOSTLY`] is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice, unless read accesses from `location` will not result in a read-only copy being created on that procesor as outlined in description for the advice [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_READ_MOSTLY`]. If the memory region refers to valid system-allocated pageable memory, and [`cudaMemLocation::type`](crate::driver::CUmemLocation_st::type_) is [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4) then [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) must be a valid device that has a non-zero alue for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`].
/// * [`cudaMemoryAdvise::CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION`]: Undoes the effect of [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_PREFERRED_LOCATION`] and changes the preferred location to none. The `location` argument is ignored for this advice.
/// * [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_ACCESSED_BY`]: This advice implies that the data will be accessed by processor `location`. The [`cudaMemLocation::type`](crate::driver::CUmemLocation_st::type_) must be either [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4) with [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) representing a valid device ordinal 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) and [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) will be ignored. All other location types are invalid. If [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) is a GPU, then the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`] must be non-zero. This advice does not cause data migration and has no impact on the location of the data per se. Instead, it causes the data to always be mapped in the specified processor’s page tables, as long as the location of the data permits a mapping to be established. If the data gets migrated for any reason, the mappings are updated accordingly. This advice is recommended in scenarios where data locality is not important, but avoiding faults is. Consider for example a system containing multiple GPUs with peer-to-peer access enabled, where the data located on one GPU is occasionally accessed by peer GPUs. In such scenarios, migrating data over to the other GPUs is not as important because the accesses are infrequent and the overhead of migration may be too high. But preventing faults can still help improve performance, and so having a mapping set up in advance is useful. Note that on CPU access of this data, the data may be migrated to host memory because the CPU typically cannot access device memory directly. Any GPU that had the [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_ACCESSED_BY`] flag set for this data will now have its mapping updated to point to the page in host memory. If [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_READ_MOSTLY`] is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice. Additionally, if the preferred location of this memory region or any subset of it is also `location`, then the policies associated with [`CUmem_advise_enum::CU_MEM_ADVISE_SET_PREFERRED_LOCATION`](crate::driver::CUmem_advise_enum::CU_MEM_ADVISE_SET_PREFERRED_LOCATION) will override the policies of this advice. If the memory region refers to valid system-allocated pageable memory, and [`cudaMemLocation::type`](crate::driver::CUmemLocation_st::type_) is [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4) then device in [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) must have a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`]. Additionally, if [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) has a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`], then this call has no effect.
/// * [`CUmem_advise_enum::CU_MEM_ADVISE_UNSET_ACCESSED_BY`](crate::driver::CUmem_advise_enum::CU_MEM_ADVISE_UNSET_ACCESSED_BY): Undoes the effect of [`cudaMemoryAdvise::CU_MEM_ADVISE_SET_ACCESSED_BY`]. Any mappings to the data from `location` may be removed at any time causing accesses to result in non-fatal page faults. If the memory region refers to valid system-allocated pageable memory, and [`cudaMemLocation::type`](crate::driver::CUmemLocation_st::type_) is [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4) then device in [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) must have a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS`]. Additionally, if [cudaMemLocation::id](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaMemLocation.html#structcudamemlocation_1a1c914cd5c3cc7323b4fde9756458efb0) has a non-zero value for the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES`], then this call has no effect.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpy3DPeerAsync`], [`cudaMemPrefetchAsync`], [`cuMemAdvise`](crate::driver::cuMemAdvise).
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:
///
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY`]: If this attribute is specified, `data` will be interpreted as a 32-bit integer, and `dataSize` must be 4. The result returned will be 1 if all pages in the given memory range have read-duplication enabled, or 0 otherwise.
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION`]: If this attribute is specified, `data` will be interpreted as a 32-bit integer, and `dataSize` must be 4. The result returned will be a GPU device id if all pages in the memory range have that GPU as their preferred location, or it will be cudaCpuDeviceId if all pages in the memory range have the CPU as their preferred location, or it will be cudaInvalidDeviceId if either all the pages don’t have the same preferred location or some of the pages don’t have a preferred location at all. Note that the actual location of the pages in the memory range at the time of the query may be different from the preferred location.
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY`]: If this attribute is specified, `data` will be interpreted as an array of 32-bit integers, and `dataSize` must be a non-zero multiple of 4. The result returned will be a list of device ids that had `cudaMemAdviceSetAccessedBy` set for that entire memory range. If any device does not have that advice set for the entire memory range, that device will not be included. If `data` is larger than the number of devices that have that advice set for that memory range, cudaInvalidDeviceId will be returned in all the extra space provided. For ex., if `dataSize` is 12 (i.e. `data` has 3 elements) and only device 0 has the advice set, then the result returned will be { 0, cudaInvalidDeviceId, cudaInvalidDeviceId }. If `data` is smaller than the number of devices that have that advice set, then only as many devices will be returned as can fit in the array. There is no guarantee on which specific devices will be returned, however.
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION`]: If this attribute is specified, `data` will be interpreted as a 32-bit integer, and `dataSize` must be 4. The result returned will be the last location to which all pages in the memory range were prefetched explicitly via [`cudaMemPrefetchAsync`]. This will either be a GPU id or cudaCpuDeviceId depending on whether the last location for prefetch was a GPU or the CPU respectively. If any page in the memory range was never explicitly prefetched or if all pages were not prefetched to the same location, cudaInvalidDeviceId will be returned. Note that this simply returns the last location that the applicaton requested to prefetch the memory range to. It gives no indication as to whether the prefetch operation to that location has completed or even begun.
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE`]: If this attribute is specified, `data` will be interpreted as a [cudaMemLocationType](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga2279aa08666f329f3ba4afe397fa60f0), and `dataSize` must be sizeof(cudaMemLocationType). The [cudaMemLocationType](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga2279aa08666f329f3ba4afe397fa60f0) returned will be [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4) if all pages in the memory range have the same GPU as their preferred location, or [cudaMemLocationType](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga2279aa08666f329f3ba4afe397fa60f0) will be [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a1ec97ff5f3c715e4b18e39dabf9e31c5) if all pages in the memory range have the CPU as their preferred location, or or it will be [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0) if all the pages in the memory range have the same host NUMA node ID as their preferred location or it will be cudaMemLocationTypeInvalid if either all the pages don’t have the same preferred location or some of the pages don’t have a preferred location at all. Note that the actual location type of the pages in the memory range at the time of the query may be different from the preferred location type.
///
/// + [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_ID`]: If this attribute is specified, `data` will be interpreted as a 32-bit integer, and `dataSize` must be 4. If the [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE`] query for the same address range returns [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4), it will be a valid device ordinal or if it returns [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0), it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored.
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE`]: If this attribute is specified, `data` will be interpreted as a [cudaMemLocationType](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga2279aa08666f329f3ba4afe397fa60f0), and `dataSize` must be sizeof(cudaMemLocationType). The result returned will be the last location type to which all pages in the memory range were prefetched explicitly via [`cuMemPrefetchAsync`](crate::driver::cuMemPrefetchAsync). The [cudaMemLocationType](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga2279aa08666f329f3ba4afe397fa60f0) returned will be [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4) if the last prefetch location was the GPU 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) if it was the CPU or [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0) if the last prefetch location was a specific host NUMA node. If any page in the memory range was never explicitly prefetched or if all pages were not prefetched to the same location, [`CUmemLocationType`](crate::driver::CUmemLocationType) will be cudaMemLocationTypeInvalid. Note that this simply returns the last location type that the application requested to prefetch the memory range to. It gives no indication as to whether the prefetch operation to that location has completed or even begun.
///
/// + [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_ID`]: If this attribute is specified, `data` will be interpreted as a 32-bit integer, and `dataSize` must be 4. If the [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION_TYPE`] query for the same address range returns [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4), it will be a valid device ordinal or if it returns [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0a24dc63fb938dee27b41e3842da35d2d0), it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemRangeGetAttributes`], [`cudaMemPrefetchAsync`], [`cudaMemAdvise`], [`cuMemRangeGetAttribute`](crate::driver::cuMemRangeGetAttribute).
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.
///
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY`]
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION`]
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY`]
/// * [`cudaMemRangeAttribute::CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION`]
/// * :: cudaMemRangeAttributePreferredLocationType
/// * :: cudaMemRangeAttributePreferredLocationId
/// * :: cudaMemRangeAttributeLastPrefetchLocationType
/// * :: cudaMemRangeAttributeLastPrefetchLocationId.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemRangeGetAttribute`], [`cudaMemAdvise`], [`cudaMemPrefetchAsync`], [`cuMemRangeGetAttributes`](crate::driver::cuMemRangeGetAttributes).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpyHtoA`](crate::driver::cuMemcpyHtoA), [`cuMemcpyDtoA`](crate::driver::cuMemcpyDtoA).
#[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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits synchronous behavior for most use cases.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpyAtoH`](crate::driver::cuMemcpyAtoH), [`cuMemcpyAtoD`](crate::driver::cuMemcpyAtoD).
#[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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpyAtoA`](crate::driver::cuMemcpyAtoA).
#[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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpyHtoAAsync`](crate::driver::cuMemcpyHtoAAsync), [`cuMemcpy2DAsync`](crate::driver::cuMemcpy2DAsync).
#[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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function exhibits asynchronous behavior for most use cases.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidMemcpyDirection`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a72ce39cee8ef48a83b0191b2e33d2630)
///
/// See also: [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [`cuMemcpyAtoHAsync`](crate::driver::cuMemcpyAtoHAsync), [`cuMemcpy2DAsync`](crate::driver::cuMemcpy2DAsync).
#[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 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]: cudaErrorOutOfMemory.
///
/// See also: [`cuMemAllocAsync`](crate::driver::cuMemAllocAsync), [cudaMallocAsync (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1gaa31efcffc48981621feddd98d71a0feb), [`cudaMallocFromPoolAsync`], [`cudaFreeAsync`], [`cudaDeviceSetMemPool`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolSetAccess`], [`cudaMemPoolSetAttribute`], [`cudaMemPoolGetAttribute`].
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.
///
/// Note: During stream capture, this function results in the creation of a free node and must therefore be passed the address of a graph allocation.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hStream`: The stream establishing the stream ordering promise.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuMemFreeAsync`](crate::driver::cuMemFreeAsync), [`cudaMallocAsync`].
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.
///
/// Note: Allocations that have not been freed count as outstanding.
///
/// Note: Allocations that have been asynchronously freed but whose completion has not been observed on the host (eg. by a synchronize) can count as outstanding.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cuMemPoolTrimTo`](crate::driver::cuMemPoolTrimTo), [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`].
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:
///
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_RELEASE_THRESHOLD`]: (value type = cuuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS. When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory back to the OS on the next call to stream, event or context synchronize. (default 0)
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES`]: (value type = int) Allow [`cudaMallocAsync`] to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on the free action exists. CUDA events and null stream interactions can create the required stream ordered dependencies. (default enabled)
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC`]: (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default enabled)
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES`]: (value type = int) Allow [`cudaMallocAsync`] to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released by [`cudaFreeAsync`] (default enabled).
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH`]: (value type = cuuint64_t) Reset the high watermark that tracks the amount of backing memory that was allocated for the memory pool. It is illegal to set this attribute to a non-zero value.
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_USED_MEM_HIGH`]: (value type = cuuint64_t) Reset the high watermark that tracks the amount of used memory that was allocated for the memory pool. It is illegal to set this attribute to a non-zero value.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `attr`: The attribute to modify.
/// - `value`: Pointer to the value to assign.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cuMemPoolSetAttribute`](crate::driver::cuMemPoolSetAttribute), [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`].
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:
///
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_RELEASE_THRESHOLD`]: (value type = cuuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS. When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory back to the OS on the next call to stream, event or context synchronize. (default 0)
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES`]: (value type = int) Allow [`cudaMallocAsync`] to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on the free action exists. CUDA events and null stream interactions can create the required stream ordered dependencies. (default enabled)
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC`]: (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default enabled)
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES`]: (value type = int) Allow [`cudaMallocAsync`] to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released by [`cudaFreeAsync`] (default enabled).
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_RESERVED_MEM_CURRENT`]: (value type = cuuint64_t) Amount of backing memory currently allocated for the mempool.
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH`]: (value type = cuuint64_t) High watermark of backing memory allocated for the mempool since the last time it was reset.
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_USED_MEM_CURRENT`]: (value type = cuuint64_t) Amount of memory from the pool that is currently in use by the application.
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_USED_MEM_HIGH`]: (value type = cuuint64_t) High watermark of the amount of memory from the pool that was in use by the application since the last time it was reset.
///
/// The following properties can be also be queried on imported and default pools:
///
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_ALLOCATION_TYPE`]: (value type = cudaMemAllocationType) The allocation type of the mempool
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_EXPORT_HANDLE_TYPES`]: (value type = cudaMemAllocationHandleType) Available export handle types for the mempool. For imported pools this value is always cudaMemHandleTypeNone as an imported pool cannot be re-exported
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_LOCATION_ID`]: (value type = int) The location id for the mempool. If the location type for this pool is cudaMemLocationTypeInvisible then ID will be cudaInvalidDeviceId.
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_LOCATION_TYPE`]: (value type = cudaMemLocationType) The location type for the mempool. For imported memory pools where the device is not directly visible to the importing process or pools imported via fabric handles across nodes this will be cudaMemlocataionTypeInvisible.
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_LOCALITY_DOMAIN_ID`]: (value type = int) The locality domain id for the mempool, if the mempool is localized to a locality domain. A value of -1 indicates that the mempool is not localized to a locality domain.
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_MAX_POOL_SIZE`]: (value type = cuuint64_t) Maximum size of the pool in bytes, this value may be higher than what was initially passed to cuMemPoolCreate due to alignment requirements. A value of 0 indicates no maximum size. For cudaMemAllocationTypeManaged and IPC imported pools this value will be system dependent.
/// * [`cudaMemPoolAttr::CU_MEMPOOL_ATTR_HW_DECOMPRESS_ENABLED`]: (value type = int) Indicates whether the pool has hardware compresssion enabled.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `attr`: The attribute to get.
/// - `value`: Retrieved value.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cuMemPoolGetAttribute`](crate::driver::cuMemPoolGetAttribute), [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuMemPoolSetAccess`](crate::driver::cuMemPoolSetAccess), [`cudaMemPoolGetAccess`], [`cudaMallocAsync`], [`cudaFreeAsync`].
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.
///
/// See also: [`cuMemPoolGetAccess`](crate::driver::cuMemPoolGetAccess), [`cudaMemPoolSetAccess`].
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`](crate::driver::CUmemPoolProps_st::handleTypes) must be 0, any other values will result in [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]. 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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]. 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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_LOCALITY_DOMAIN_COUNT`]. 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`](crate::driver::CUmemPoolProps_st::maxSize). If set to 0, the maximum size of the pool will default to a system dependent value.
///
/// Applications that intend to use [`CUmemAllocationHandleType_enum::CU_MEM_HANDLE_TYPE_FABRIC`](crate::driver::CUmemAllocationHandleType_enum::CU_MEM_HANDLE_TYPE_FABRIC) based memory sharing must ensure: (1) `nvidia-caps-imex-channels` character device is created by the driver and is listed under /proc/devices (2) have at least one IMEX channel file accessible by the user launching the application.
///
/// When exporter and importer CUDA processes have been granted access to the same IMEX channel, they can securely share memory.
///
/// The IMEX channel security model works on a per user basis. Which means all processes under a user can share memory if the user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX channel is required for each user.
///
/// These channel files exist in /dev/nvidia-caps-imex-channels/channel\* and can be created using standard OS native calls like mknod on Linux. For example: To create channel0 with the major number from /proc/devices users can execute the following command: `mknod /dev/nvidia-caps-imex-channels/channel0 c <major number> 0`
///
/// To create a managed memory pool, applications must set [`cudaMemPoolProps`]:cudaMemAllocationType to [`cudaMemAllocationType::cudaMemAllocationTypeManaged`]. [`cudaMemAllocationHandleType`] must also be set to [`cudaMemAllocationHandleType::CU_MEM_HANDLE_TYPE_NONE`] since IPC is not supported. For managed memory pools, [`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`](crate::driver::CUmemPoolProps_st::maxSize) must be set to zero for managed memory pools. [`cudaMemPoolProps::usage`](crate::driver::CUmemPoolProps_st::usage) 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 [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`].
///
/// Note: Specifying [`cudaMemAllocationHandleType::CU_MEM_HANDLE_TYPE_NONE`] creates a memory pool that will not support IPC.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuMemPoolCreate`](crate::driver::cuMemPoolCreate), [`cudaDeviceSetMemPool`], [`cudaMallocFromPoolAsync`], [`cudaMemPoolExportToShareableHandle`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`].
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.
///
/// Note: A device’s default memory pool cannot be destroyed.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cuMemPoolDestroy`](crate::driver::cuMemPoolDestroy), [`cudaFreeAsync`], [`cudaDeviceSetMemPool`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`].
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuMemAllocAsync`](crate::driver::cuMemAllocAsync), [`cuMemPoolTrimTo`](crate::driver::cuMemPoolTrimTo), [`cuMemPoolGetAttribute`](crate::driver::cuMemPoolGetAttribute), [`cuMemPoolSetAttribute`](crate::driver::cuMemPoolSetAttribute), [`cuMemPoolSetAccess`](crate::driver::cuMemPoolSetAccess), [`cuMemGetMemPool`](crate::driver::cuMemGetMemPool), [`cuMemPoolCreate`](crate::driver::cuMemPoolCreate).
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// 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`].
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuDeviceGetDefaultMemPool`](crate::driver::cuDeviceGetDefaultMemPool), [`cuMemPoolCreate`](crate::driver::cuMemPoolCreate), [`cuDeviceSetMemPool`](crate::driver::cuDeviceSetMemPool), [`cuMemSetMemPool`](crate::driver::cuMemSetMemPool).
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// When a memory pool is set as the current memory pool, the location parameter should be the same as the location of the pool. If the location type or index don’t match, the call returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]. The type of memory pool should also match the parameter allocType. Else the call returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// .
///
/// By default, a memory location’s current memory pool is its default memory pool. If the location type is
///
/// [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2279aa08666f329f3ba4afe397fa60f0ae479b8710f3c5270117ee9d8cf5868d4) and the allocation type is [`cudaMemAllocationType::cudaMemAllocationTypePinned`] , then this API is the equivalent of calling [`cudaDeviceSetMemPool`] with the location id as the device. For further details on the implications, please refer to the documentation for [`cudaDeviceSetMemPool`] .
///
/// Note: Use [`cudaMallocFromPoolAsync`] to specify asynchronous allocations from a device different than the one the stream runs on.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuDeviceGetDefaultMemPool`](crate::driver::cuDeviceGetDefaultMemPool), [`cuDeviceGetMemPool`](crate::driver::cuDeviceGetMemPool), [`cuMemGetMemPool`](crate::driver::cuMemGetMemPool), [`cuMemPoolCreate`](crate::driver::cuMemPoolCreate), [`cuMemPoolDestroy`](crate::driver::cuMemPoolDestroy), [`cuMemAllocFromPoolAsync`](crate::driver::cuMemAllocFromPoolAsync).
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.
///
/// Note: The specified memory pool may be from a device different than that of the specified `stream`.
/// * 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.
///
/// # Parameters
///
/// - `ptr`: Returned device pointer.
/// - `memPool`: The pool to allocate from.
/// - `stream`: The stream establishing the stream ordering semantic.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]: cudaErrorOutOfMemory.
///
/// See also: [`cuMemAllocFromPoolAsync`](crate::driver::cuMemAllocFromPoolAsync), [cudaMallocAsync (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1gaa31efcffc48981621feddd98d71a0feb), [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaMemPoolCreate`], [`cudaMemPoolSetAccess`], [`cudaMemPoolSetAttribute`].
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.
///
/// Note: To create an IPC capable mempool, create a mempool with a CUmemAllocationHandleType other than cudaMemHandleTypeNone.
///
/// # Parameters
///
/// - `handleType`: the type of handle to create.
/// - `flags`: must be 0.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]: cudaErrorOutOfMemory.
///
/// See also: [`cuMemPoolExportToShareableHandle`](crate::driver::cuMemPoolExportToShareableHandle), [`cudaMemPoolImportFromShareableHandle`], [`cudaMemPoolExportPointer`], [`cudaMemPoolImportPointer`].
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`].
///
/// Note: Imported memory pools do not support creating new allocations. As such imported memory pools may not be used in [`cudaDeviceSetMemPool`] or [`cudaMallocFromPoolAsync`] calls.
///
/// # Parameters
///
/// - `handleType`: The type of handle being imported.
/// - `flags`: must be 0.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]: cudaErrorOutOfMemory.
///
/// See also: [`cuMemPoolImportFromShareableHandle`](crate::driver::cuMemPoolImportFromShareableHandle), [`cudaMemPoolExportToShareableHandle`], [`cudaMemPoolExportPointer`], [`cudaMemPoolImportPointer`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]: cudaErrorOutOfMemory.
///
/// See also: [`cuMemPoolExportPointer`](crate::driver::cuMemPoolExportPointer), [`cudaMemPoolExportToShareableHandle`], [`cudaMemPoolImportFromShareableHandle`], [`cudaMemPoolImportPointer`].
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.
///
/// Note: The [`cudaFreeAsync`] api may be used in the exporting process before the [`cudaFreeAsync`] operation completes in its stream as long as the [`cudaFreeAsync`] in the exporting process specifies a stream with a stream dependency on the importing process’s [`cudaFreeAsync`].
///
/// # Return value
///
/// CUDA_SUCCESS, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`](crate::driver::cudaError_enum::CUDA_ERROR_INVALID_VALUE), [`cudaError_enum::CUDA_ERROR_NOT_INITIALIZED`](crate::driver::cudaError_enum::CUDA_ERROR_NOT_INITIALIZED), [`cudaError_enum::CUDA_ERROR_OUT_OF_MEMORY`](crate::driver::cudaError_enum::CUDA_ERROR_OUT_OF_MEMORY).
///
/// See also: [`cuMemPoolImportPointer`](crate::driver::cuMemPoolImportPointer), [`cudaMemPoolExportToShareableHandle`], [`cudaMemPoolImportFromShareableHandle`], [`cudaMemPoolExportPointer`].
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// The [`cudaPointerAttributes`] structure is defined as:
///
/// ```text
/// struct cudaPointerAttributes {
/// enum cudaMemoryType type;
/// int device;
/// void *devicePointer;
/// void *hostPointer;
/// int localityDomainOrdinal;
/// }
/// ```
///
/// In this structure, the individual fields mean
///
/// * [`cudaPointerAttributes::type`](cudaPointerAttributes::type_) identifies type of memory. It can be [`cudaMemoryType::cudaMemoryTypeUnregistered`] for unregistered host memory, [`cudaMemoryType::cudaMemoryTypeHost`] for registered host memory, [`cudaMemoryType::cudaMemoryTypeDevice`] for device memory or [`cudaMemoryType::cudaMemoryTypeManaged`] for managed memory.
/// * [device](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaPointerAttributes.html#structcudapointerattributes_1a20015540684b0c85e0debf64923bedec) is the device against which `ptr` was allocated. If `ptr` has memory type [`cudaMemoryType::cudaMemoryTypeDevice`] then this identifies the device on which the memory referred to by `ptr` physically resides. If `ptr` has memory type [`cudaMemoryType::cudaMemoryTypeHost`] then this identifies the device which was current when the allocation was made (and if that device is deinitialized then this allocation will vanish with that device’s state).
/// * [devicePointer](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaPointerAttributes.html#structcudapointerattributes_1a9edc9782e1ee337072994780fd3b675f) is the device pointer alias through which the memory referred to by `ptr` may be accessed on the current device. If the memory referred to by `ptr` cannot be accessed directly by the current device then this is NULL.
/// * [hostPointer](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/structcudaPointerAttributes.html#structcudapointerattributes_1a19cbae18cd685096287e41cce1c9a087) is the host pointer alias through which the memory referred to by `ptr` may be accessed on the host. If the memory referred to by `ptr` cannot be accessed directly by the host then this is NULL.
/// * localityDomainOrdinal is the locality domain ordinal for device allocations localized to a locality domain, or -1 when the allocation is not localized to a locality domain.
///
/// Note: In CUDA 11.0 forward passing host pointer will return [`cudaMemoryType::cudaMemoryTypeUnregistered`] in [`cudaPointerAttributes::type`](cudaPointerAttributes::type_) and call will return [`cudaError_t::CUDA_SUCCESS`].
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `attributes`: Attributes for the specified pointer.
/// - `ptr`: Pointer to get attributes for.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaChooseDevice`], [`cudaInitDevice`], [`cuPointerGetAttributes`](crate::driver::cuPointerGetAttributes).
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`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaDeviceEnablePeerAccess`], [`cudaDeviceDisablePeerAccess`], [`cuDeviceCanAccessPeer`](crate::driver::cuDeviceCanAccessPeer).
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 [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`] if [`cudaDeviceCanAccessPeer`] indicates that the current device cannot directly access memory from `peerDevice`.
///
/// Returns [`cudaError_t::CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED`] if direct access of `peerDevice` from the current device has already been enabled.
///
/// Returns [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if `flags` is not 0.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `peerDevice`: Peer device to enable direct access to from the current device.
/// - `flags`: Reserved for future use and must be set to 0.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDeviceCanAccessPeer`], [`cudaDeviceDisablePeerAccess`], [`cuCtxEnablePeerAccess`](crate::driver::cuCtxEnablePeerAccess).
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 [`cudaError_t::CUDA_ERROR_PEER_ACCESS_NOT_ENABLED`] if direct access to memory on `peerDevice` has not yet been enabled from the current device.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `peerDevice`: Peer device to disable direct access to
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_PEER_ACCESS_NOT_ENABLED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaDeviceCanAccessPeer`], [`cudaDeviceEnablePeerAccess`], [`cuCtxDisablePeerAccess`](crate::driver::cuCtxDisablePeerAccess).
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 [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] is returned.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// # Parameters
///
/// - `resource`: Resource to unregister
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaGraphicsD3D9RegisterResource`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__D3D9.html#group__cudart__d3d9_1gaab5efa8a8882a6e0ee99717a434730b0), [`cudaGraphicsD3D10RegisterResource`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__D3D10.html#group__cudart__d3d10_1ga438731f7af2b799fb757910be6cff62b), [`cudaGraphicsD3D11RegisterResource`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__D3D11.html#group__cudart__d3d11_1ga85d07753780643584b8febab0370623b), [`cudaGraphicsGLRegisterBuffer`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__OPENGL.html#group__cudart__opengl_1ga0fd33bea77ca7b1e69d1619caf44214b), [`cudaGraphicsGLRegisterImage`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__OPENGL.html#group__cudart__opengl_1ga80d12187ae7590807c7676697d9fe03d), [`cuGraphicsUnregisterResource`](crate::driver::cuGraphicsUnregisterResource).
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:
///
/// * [cudaGraphicsMapFlagsNone](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2c3c3a69caaf333d29d0b38b75de5ffda81ae074138583e9421692bec52bfe44b): Specifies no hints about how `resource` will be used. It is therefore assumed that CUDA may read from or write to `resource`.
/// * [cudaGraphicsMapFlagsReadOnly](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2c3c3a69caaf333d29d0b38b75de5ffdae34096084cfafea1399b5682efd8b74c): Specifies that CUDA will not write to `resource`.
/// * [cudaGraphicsMapFlagsWriteDiscard](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga2c3c3a69caaf333d29d0b38b75de5ffda3d4fa7699e964ffc201daac20d2ecd6b): Specifies CUDA will not read from `resource` and will write over the entire contents of `resource`, so none of the data previously stored in `resource` will be preserved.
///
/// If `resource` is presently mapped for access by CUDA then [`cudaError_t::CUDA_ERROR_UNKNOWN`] is returned. If `flags` is not one of the above values then [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `resource`: Registered resource to set flags for.
/// - `flags`: Parameters for resource mapping.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaGraphicsMapResources`], [`cuGraphicsResourceSetMapFlags`](crate::driver::cuGraphicsResourceSetMapFlags).
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 [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] is returned. If any of `resources` are presently mapped for access by CUDA then [`cudaError_t::CUDA_ERROR_UNKNOWN`] is returned.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `count`: Number of resources to map.
/// - `resources`: Resources to map for CUDA.
/// - `stream`: Stream for synchronization.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaGraphicsResourceGetMappedPointer`], [`cudaGraphicsSubResourceGetMappedArray`], [`cudaGraphicsUnmapResources`], [`cuGraphicsMapResources`](crate::driver::cuGraphicsMapResources).
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 [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`] is returned. If any of `resources` are not presently mapped for access by CUDA then [`cudaError_t::CUDA_ERROR_UNKNOWN`] is returned.
///
/// Note: This function uses standard default stream semantics.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `count`: Number of resources to unmap.
/// - `resources`: Resources to unmap.
/// - `stream`: Stream for synchronization.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaGraphicsMapResources`], [`cuGraphicsUnmapResources`](crate::driver::cuGraphicsUnmapResources).
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 [`cudaError_t::CUDA_ERROR_UNKNOWN`] is returned. If `resource` is not mapped then [`cudaError_t::CUDA_ERROR_UNKNOWN`] is returned.
///
/// * See also
///
/// [`cudaGraphicsMapResources`], [`cudaGraphicsSubResourceGetMappedArray`], [`cuGraphicsResourceGetMappedPointer`](crate::driver::cuGraphicsResourceGetMappedPointer).
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
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 [`cudaError_t::CUDA_ERROR_UNKNOWN`] is returned. If `arrayIndex` is not a valid array index for `resource` then [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] is returned. If `mipLevel` is not a valid mipmap level for `resource` then [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] is returned. If `resource` is not mapped then [`cudaError_t::CUDA_ERROR_UNKNOWN`] is returned.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaGraphicsResourceGetMappedPointer`], [`cuGraphicsSubResourceGetMappedArray`](crate::driver::cuGraphicsSubResourceGetMappedArray).
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 [`cudaError_t::CUDA_ERROR_UNKNOWN`] is returned. If `resource` is not mapped then [`cudaError_t::CUDA_ERROR_UNKNOWN`] is returned.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `mipmappedArray`: Returned mipmapped array through which `resource` may be accessed.
/// - `resource`: Mapped resource to access.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_UNKNOWN`]
///
/// See also: [`cudaGraphicsResourceGetMappedPointer`], [`cuGraphicsResourceGetMappedMipmappedArray`](crate::driver::cuGraphicsResourceGetMappedMipmappedArray).
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `desc`: Channel format.
/// - `array`: Memory array on device.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaCreateChannelDesc`] (C API), [`cudaCreateTextureObject`], [`cudaCreateSurfaceObject`].
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 [`cudaChannelFormatKind::cudaChannelFormatKindSigned`], [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`], or [`cudaChannelFormatKind::cudaChannelFormatKindFloat`].
///
/// # Parameters
///
/// - `x`: X component.
/// - `y`: Y component.
/// - `z`: Z component.
/// - `w`: W component.
/// - `f`: Channel format.
///
/// # Return value
///
/// Channel descriptor with format `f`.
///
/// See also: [cudaCreateChannelDesc (C++ API)](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__HIGHLEVEL.html#group__cudart__highlevel_1ga7a006216e07167cd4e01ffc90e08be37), [`cudaGetChannelDesc`], [`cudaCreateTextureObject`], [`cudaCreateSurfaceObject`].
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:
///
/// ```text
/// struct cudaResourceDesc {
/// enum cudaResourceType resType;
///
/// union {
/// struct {
/// cudaArray_t array;
/// } array;
/// struct {
/// cudaMipmappedArray_t mipmap;
/// } mipmap;
/// struct {
/// void *devPtr;
/// struct cudaChannelFormatDesc desc;
/// size_t sizeInBytes;
/// } linear;
/// struct {
/// void *devPtr;
/// struct cudaChannelFormatDesc desc;
/// size_t width;
/// size_t height;
/// size_t pitchInBytes;
/// } pitch2D;
/// } res;
/// };
/// ```
///
/// where:
///
/// * [`cudaResourceDesc::resType`](cudaResourceDesc::resType) specifies the type of resource to texture from. CUresourceType is defined as:
///
/// ```text
/// enum cudaResourceType {
/// cudaResourceTypeArray = 0x00,
/// cudaResourceTypeMipmappedArray = 0x01,
/// cudaResourceTypeLinear = 0x02,
/// cudaResourceTypePitch2D = 0x03
/// };
/// ```
///
/// The [`cudaTextureDesc`] struct is defined as
///
/// ```text
/// struct cudaTextureDesc {
/// enum cudaTextureAddressMode addressMode\[3\];
/// enum cudaTextureFilterMode filterMode;
/// enum cudaTextureReadMode readMode;
/// int sRGB;
/// float borderColor\[4\];
/// int normalizedCoords;
/// unsigned int maxAnisotropy;
/// enum cudaTextureFilterMode mipmapFilterMode;
/// float mipmapLevelBias;
/// float minMipmapLevelClamp;
/// float maxMipmapLevelClamp;
/// int disableTrilinearOptimization;
/// int seamlessCubemap;
/// };
/// ```
///
/// where
///
/// * [`cudaTextureDesc::addressMode`](cudaTextureDesc::addressMode) specifies the addressing mode for each dimension of the texture data. [`cudaTextureAddressMode`] is defined as:
///
/// ```text
/// enum cudaTextureAddressMode {
/// cudaAddressModeWrap = 0,
/// cudaAddressModeClamp = 1,
/// cudaAddressModeMirror = 2,
/// cudaAddressModeBorder = 3
/// };
/// ```
///
/// This is ignored if [`cudaResourceDesc::resType`](cudaResourceDesc::resType) is [`cudaResourceType::cudaResourceTypeLinear`]. Also, if [`cudaTextureDesc::normalizedCoords`](cudaTextureDesc::normalizedCoords) is set to zero, [`cudaTextureAddressMode::cudaAddressModeWrap`] and [`cudaTextureAddressMode::cudaAddressModeMirror`] won’t be supported and will be switched to [`cudaTextureAddressMode::cudaAddressModeClamp`].
/// * [`cudaTextureDesc::filterMode`](cudaTextureDesc::filterMode) specifies the filtering mode to be used when fetching from the texture. [`cudaTextureFilterMode`] is defined as:
///
/// ```text
/// enum cudaTextureFilterMode {
/// cudaFilterModePoint = 0,
/// cudaFilterModeLinear = 1
/// };
/// ```
///
/// This is ignored if [`cudaResourceDesc::resType`](cudaResourceDesc::resType) is [`cudaResourceType::cudaResourceTypeLinear`].
/// * [`cudaTextureDesc::readMode`](cudaTextureDesc::readMode) specifies whether integer data should be converted to floating point or not. [`cudaTextureReadMode`] is defined as:
///
/// ```text
/// enum cudaTextureReadMode {
/// cudaReadModeElementType = 0,
/// cudaReadModeNormalizedFloat = 1
/// };
/// ```
///
/// Note that this applies only to 8-bit and 16-bit integer formats. 32-bit integer format would not be promoted, regardless of whether or not this [`cudaTextureDesc::readMode`](cudaTextureDesc::readMode) is set [`cudaTextureReadMode::cudaReadModeNormalizedFloat`] is specified.
/// * [`cudaTextureDesc::sRGB`](cudaTextureDesc::sRGB) specifies whether sRGB to linear conversion should be performed during texture fetch.
/// * [`cudaTextureDesc::borderColor`](cudaTextureDesc::borderColor) specifies the float values of color. where: [`cudaTextureDesc::borderColor`](cudaTextureDesc::borderColor)\[0\] contains value of ‘R’, [`cudaTextureDesc::borderColor`](cudaTextureDesc::borderColor)\[1\] contains value of ‘G’, [`cudaTextureDesc::borderColor`](cudaTextureDesc::borderColor)\[2\] contains value of ‘B’, [`cudaTextureDesc::borderColor`](cudaTextureDesc::borderColor)\[3\] contains value of ‘A’ Note that application using integer border color values will need to <reinterpret_cast> these values to float. The values are set only when the addressing mode specified by [`cudaTextureDesc::addressMode`](cudaTextureDesc::addressMode) is cudaAddressModeBorder.
/// * [`cudaTextureDesc::normalizedCoords`](cudaTextureDesc::normalizedCoords) specifies whether the texture coordinates will be normalized or not.
/// * [`cudaTextureDesc::maxAnisotropy`](cudaTextureDesc::maxAnisotropy) specifies the maximum anistropy ratio to be used when doing anisotropic filtering. This value will be clamped to the range \[1,16\].
/// * [`cudaTextureDesc::mipmapFilterMode`](cudaTextureDesc::mipmapFilterMode) specifies the filter mode when the calculated mipmap level lies between two defined mipmap levels.
/// * [`cudaTextureDesc::mipmapLevelBias`](cudaTextureDesc::mipmapLevelBias) specifies the offset to be applied to the calculated mipmap level.
/// * [`cudaTextureDesc::minMipmapLevelClamp`](cudaTextureDesc::minMipmapLevelClamp) specifies the lower end of the mipmap level range to clamp access to.
/// * [`cudaTextureDesc::maxMipmapLevelClamp`](cudaTextureDesc::maxMipmapLevelClamp) specifies the upper end of the mipmap level range to clamp access to.
/// * [`cudaTextureDesc::disableTrilinearOptimization`](cudaTextureDesc::disableTrilinearOptimization) specifies whether the trilinear filtering optimizations will be disabled.
/// * [`cudaTextureDesc::seamlessCubemap`](cudaTextureDesc::seamlessCubemap) specifies whether seamless cube map filtering is enabled. This flag can only be specified if the underlying resource is a CUDA array or a CUDA mipmapped array that was created with the flag [cudaArrayCubemap](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ga802843d69ca8be35ee050ff66782179e). When seamless cube map filtering is enabled, texture address modes specified by [`cudaTextureDesc::addressMode`](cudaTextureDesc::addressMode) are ignored. Instead, if the [`cudaTextureDesc::filterMode`](cudaTextureDesc::filterMode) is set to [`cudaTextureFilterMode::cudaFilterModePoint`] the address mode [`cudaTextureAddressMode::cudaAddressModeClamp`] will be applied for all dimensions. If the [`cudaTextureDesc::filterMode`](cudaTextureDesc::filterMode) is set to [`cudaTextureFilterMode::cudaFilterModeLinear`] seamless cube map filtering will be performed when sampling along the cube face borders.
///
/// If [`cudaResourceDesc::resType`](cudaResourceDesc::resType) is set to [`cudaResourceType::cudaResourceTypeArray`], `cudaResourceDesc::res::array::array` must be set to a valid CUDA array handle.
///
/// If [`cudaResourceDesc::resType`](cudaResourceDesc::resType) is set to [`cudaResourceType::cudaResourceTypeMipmappedArray`], `cudaResourceDesc::res::mipmap::mipmap` must be set to a valid CUDA mipmapped array handle and [`cudaTextureDesc::normalizedCoords`](cudaTextureDesc::normalizedCoords) must be set to true.
///
/// If [`cudaResourceDesc::resType`](cudaResourceDesc::resType) is set to [`cudaResourceType::cudaResourceTypeLinear`], `cudaResourceDesc::res::linear::devPtr` must be set to a valid device pointer, that is aligned to [`cudaDeviceProp::textureAlignment`](cudaDeviceProp::textureAlignment). `cudaResourceDesc::res::linear::desc` describes the format and the number of components per array element. `cudaResourceDesc::res::linear::sizeInBytes` specifies the size of the array in bytes. The total number of elements in the linear address range cannot exceed [`cudaDeviceGetTexture1DLinearMaxWidth`]. The number of elements is computed as (sizeInBytes / sizeof(desc)).
///
/// If [`cudaResourceDesc::resType`](cudaResourceDesc::resType) is set to [`cudaResourceType::cudaResourceTypePitch2D`], `cudaResourceDesc::res::pitch2D::devPtr` must be set to a valid device pointer, that is aligned to [`cudaDeviceProp::textureAlignment`](cudaDeviceProp::textureAlignment). `cudaResourceDesc::res::pitch2D::desc` describes the format and the number of components per array element. `cudaResourceDesc::res::pitch2D::width` and `cudaResourceDesc::res::pitch2D::height` specify the width and height of the array in elements, and cannot exceed [`cudaDeviceProp::maxTexture2DLinear`](cudaDeviceProp::maxTexture2DLinear)\[0\] and [`cudaDeviceProp::maxTexture2DLinear`](cudaDeviceProp::maxTexture2DLinear)\[1\] respectively. `cudaResourceDesc::res::pitch2D::pitchInBytes` specifies the pitch between two rows in bytes and has to be aligned to [`cudaDeviceProp::texturePitchAlignment`](cudaDeviceProp::texturePitchAlignment). Pitch cannot exceed [`cudaDeviceProp::maxTexture2DLinear`](cudaDeviceProp::maxTexture2DLinear)\[2\].
///
/// The [`cudaResourceViewDesc`] struct is defined as
///
/// ```text
/// struct cudaResourceViewDesc {
/// enum cudaResourceViewFormat format;
/// size_t width;
/// size_t height;
/// size_t depth;
/// unsigned int firstMipmapLevel;
/// unsigned int lastMipmapLevel;
/// unsigned int firstLayer;
/// unsigned int lastLayer;
/// };
/// ```
///
/// where:
///
/// * [`cudaResourceViewDesc::format`](cudaResourceViewDesc::format) specifies how the data contained in the CUDA array or CUDA mipmapped array should be interpreted. Note that this can incur a change in size of the texture data. If the resource view format is a block compressed format, then the underlying CUDA array or CUDA mipmapped array has to have a 32-bit unsigned integer format with 2 or 4 channels, depending on the block compressed format. For ex., BC1 and BC4 require the underlying CUDA array to have a 32-bit unsigned int with 2 channels. The other BC formats require the underlying resource to have the same 32-bit unsigned int format but with 4 channels.
/// * [`cudaResourceViewDesc::width`](cudaResourceViewDesc::width) specifies the new width of the texture data. If the resource view format is a block compressed format, this value has to be 4 times the original width of the resource. For non block compressed formats, this value has to be equal to that of the original resource.
/// * [`cudaResourceViewDesc::height`](cudaResourceViewDesc::height) specifies the new height of the texture data. If the resource view format is a block compressed format, this value has to be 4 times the original height of the resource. For non block compressed formats, this value has to be equal to that of the original resource.
/// * [`cudaResourceViewDesc::depth`](cudaResourceViewDesc::depth) specifies the new depth of the texture data. This value has to be equal to that of the original resource.
/// * [`cudaResourceViewDesc::firstMipmapLevel`](cudaResourceViewDesc::firstMipmapLevel) specifies the most detailed mipmap level. This will be the new mipmap level zero. For non-mipmapped resources, this value has to be zero.[`cudaTextureDesc::minMipmapLevelClamp`](cudaTextureDesc::minMipmapLevelClamp) and [`cudaTextureDesc::maxMipmapLevelClamp`](cudaTextureDesc::maxMipmapLevelClamp) will be relative to this value. For ex., if the firstMipmapLevel is set to 2, and a minMipmapLevelClamp of 1.2 is specified, then the actual minimum mipmap level clamp will be 3.2.
/// * [`cudaResourceViewDesc::lastMipmapLevel`](cudaResourceViewDesc::lastMipmapLevel) specifies the least detailed mipmap level. For non-mipmapped resources, this value has to be zero.
/// * [`cudaResourceViewDesc::firstLayer`](cudaResourceViewDesc::firstLayer) specifies the first layer index for layered textures. This will be the new layer zero. For non-layered resources, this value has to be zero.
/// * [`cudaResourceViewDesc::lastLayer`](cudaResourceViewDesc::lastLayer) specifies the last layer index for layered textures. For non-layered resources, this value has to be zero.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pTexObject`: Texture object to create.
/// - `pResDesc`: Resource descriptor.
/// - `pTexDesc`: Texture descriptor.
/// - `pResViewDesc`: Resource view descriptor.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDestroyTextureObject`], [`cuTexObjectCreate`](crate::driver::cuTexObjectCreate).
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`.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// # Parameters
///
/// - `texObject`: Texture object to destroy
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaCreateTextureObject`], [`cuTexObjectDestroy`](crate::driver::cuTexObjectDestroy).
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`.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pResDesc`: Resource descriptor.
/// - `texObject`: Texture object.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaCreateTextureObject`], [`cuTexObjectGetResourceDesc`](crate::driver::cuTexObjectGetResourceDesc).
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`.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pTexDesc`: Texture descriptor.
/// - `texObject`: Texture object.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaCreateTextureObject`], [`cuTexObjectGetTextureDesc`](crate::driver::cuTexObjectGetTextureDesc).
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, [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] is returned.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pResViewDesc`: Resource view descriptor.
/// - `texObject`: Texture object.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaCreateTextureObject`], [`cuTexObjectGetResourceViewDesc`](crate::driver::cuTexObjectGetResourceViewDesc).
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`](cudaResourceDesc::resType) 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.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pSurfObject`: Surface object to create.
/// - `pResDesc`: Resource descriptor.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidChannelDescriptor`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038a5abd0c4b36ef85f853c51bc18c516e0b)
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaDestroySurfaceObject`], [`cuSurfObjectCreate`](crate::driver::cuSurfObjectCreate).
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`.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// # Parameters
///
/// - `surfObject`: Surface object to destroy
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaCreateSurfaceObject`], [`cuSurfObjectDestroy`](crate::driver::cuSurfObjectDestroy).
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`.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pResDesc`: Resource descriptor.
/// - `surfObject`: Surface object.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaCreateSurfaceObject`], [`cuSurfObjectGetResourceDesc`](crate::driver::cuSurfObjectGetResourceDesc).
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if `driverVersion` is NULL.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `driverVersion`: Returns the CUDA driver version.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaRuntimeGetVersion`], [`cuDriverGetVersion`](crate::driver::cuDriverGetVersion).
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if the `runtimeVersion` argument is NULL.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `runtimeVersion`: Returns the CUDA Runtime version.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaDriverGetVersion`], [`cuDriverGetVersion`](crate::driver::cuDriverGetVersion).
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
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
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
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.
///
/// Note: `iterator` is auto-advancing. Dumping logs will update the value of `iterator` to receive the next generated log.
///
/// Note: The driver reserves limited memory for storing logs. The oldest logs may be overwritten and become unrecoverable. An indication will appear in the destination outupt if the logs have been truncated. Call dump after each failed API to mitigate this risk.
///
/// # Parameters
///
/// - `iterator`: Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
/// - `pathToFile`: Path to output file for dumping logs.
/// - `flags`: Reserved for future use, must be 0.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
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 [`cudaError_enum::CUDA_SUCCESS`](crate::driver::cudaError_enum::CUDA_SUCCESS). If the provided `buffer` is not large enough to hold any messages, `*size` will be set to 0 and the function will return [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`](crate::driver::cudaError_enum::CUDA_ERROR_INVALID_VALUE).
///
/// Note: `iterator` is auto-advancing. Dumping logs will update the value of `iterator` to receive the next generated log.
///
/// Note: The driver reserves limited memory for storing logs. The maximum size of the buffer is 25600 bytes. The oldest logs may be overwritten and become unrecoverable. An indication will appear in the destination outupt if the logs have been truncated. Call dump after each failed API to mitigate this risk.
///
/// Note: If the provided value in `*size` is not large enough to hold all buffered messages, a message will be added at the head of the buffer indicating this. The driver then computes the number of messages it is able to store in `buffer` and writes it out. The final message in `buffer` will always be the most recent log message as of when the API is called.
///
/// # Parameters
///
/// - `iterator`: Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
/// - `buffer`: Pointer to dump logs.
/// - `size`: See description.
/// - `flags`: Reserved for future use, must be 0.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pGraph`: Returns newly created graph.
/// - `flags`: Graph creation flags, must be 0.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`], [`cudaGraphInstantiate`], [`cudaGraphDestroy`], [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphClone`].
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:
///
/// ```text
/// struct cudaKernelNodeParams
/// {
/// void* func;
/// dim3 gridDim;
/// dim3 blockDim;
/// unsigned int sharedMemBytes;
/// void **kernelParams;
/// void **extra;
/// };
/// ```
///
/// 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.
///
/// * `CU_LAUNCH_PARAM_END`, which indicates the end of the `extra` array;
/// * `CU_LAUNCH_PARAM_BUFFER_POINTER`, which specifies that the next value in `extra` will be a pointer to a buffer containing all the kernel parameters for launching kernel `func`;
/// * `CU_LAUNCH_PARAM_BUFFER_SIZE`, which specifies that the next value in `extra` will be a pointer to a size_t containing the size of the buffer specified with `CU_LAUNCH_PARAM_BUFFER_POINTER`;
///
/// The error [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] will be returned if kernel parameters are specified with both `kernelParams` and `extra` (i.e. both `kernelParams` and `extra` are non-NULL).
///
/// The `kernelParams` or `extra` array, as well as the argument values it points to, are copied during this call.
///
/// Note: Kernels launched using graphs must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
///
/// See also: [`cudaGraphAddNode`], [`cudaLaunchKernel`], [`cudaGraphKernelNodeGetParams`], [`cudaGraphKernelNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
///
/// See also: [`cudaGraphNodeGetParams`], [`cudaLaunchKernel`], [`cudaGraphAddKernelNode`], [`cudaGraphKernelNodeSetParams`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaGraphNodeSetParams`], [`cudaLaunchKernel`], [`cudaGraphAddKernelNode`], [`cudaGraphKernelNodeGetParams`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Parameters
///
/// - `hDst`: Destination node.
/// - `hSrc`: Source node For list of attributes see cudaKernelNodeAttrID.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]: cudaErrorInvalidContext.
///
/// See also: [`cudaAccessPolicyWindow`].
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaAccessPolicyWindow`].
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaAccessPolicyWindow`].
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`].
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddNode`], [`cudaMemcpy3D`], [`cudaGraphAddMemcpyNodeToSymbol`], [`cudaGraphAddMemcpyNodeFromSymbol`], [`cudaGraphAddMemcpyNode1D`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemsetNode`].
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`].
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemcpyToSymbol`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemcpyNodeFromSymbol`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParamsToSymbol`], [`cudaGraphMemcpyNodeSetParamsFromSymbol`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemsetNode`].
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`].
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemcpyFromSymbol`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemcpyNodeToSymbol`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParamsFromSymbol`], [`cudaGraphMemcpyNodeSetParamsToSymbol`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemsetNode`].
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 [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS`].
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemcpy`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParams1D`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemsetNode`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetParams`], [`cudaMemcpy3D`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeSetParams`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeSetParams`], [`cudaMemcpy3D`], [`cudaGraphMemcpyNodeSetParamsToSymbol`], [`cudaGraphMemcpyNodeSetParamsFromSymbol`], [`cudaGraphMemcpyNodeSetParams1D`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemcpyToSymbol`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParamsFromSymbol`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemcpyFromSymbol`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParamsToSymbol`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaMemcpy`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaGraphAddNode`], [`cudaMemset2D`], [`cudaGraphMemsetNodeGetParams`], [`cudaGraphMemsetNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetParams`], [`cudaMemset2D`], [`cudaGraphAddMemsetNode`], [`cudaGraphMemsetNodeSetParams`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeSetParams`], [`cudaMemset2D`], [`cudaGraphAddMemsetNode`], [`cudaGraphMemsetNodeGetParams`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddNode`], [`cudaLaunchHostFunc`], [`cudaGraphHostNodeGetParams`], [`cudaGraphHostNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetParams`], [`cudaLaunchHostFunc`], [`cudaGraphAddHostNode`], [`cudaGraphHostNodeSetParams`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeSetParams`], [`cudaLaunchHostFunc`], [`cudaGraphAddHostNode`], [`cudaGraphHostNodeGetParams`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddNode`], [`cudaGraphChildGraphNodeGetGraph`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`], [`cudaGraphClone`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to get the embedded graph for.
/// - `pGraph`: Location to store a handle to the graph.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddChildGraphNode`], [`cudaGraphNodeFindInClone`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddNode`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `numDependencies`: Number of dependencies.
/// - `event`: Event for the node.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddNode`], [`cudaGraphAddEventWaitNode`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `event_out`: Pointer to return the event.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddEventRecordNode`], [`cudaGraphEventRecordNodeSetEvent`], [`cudaGraphEventWaitNodeGetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `event`: Event to use.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeSetParams`], [`cudaGraphAddEventRecordNode`], [`cudaGraphEventRecordNodeGetEvent`], [`cudaGraphEventWaitNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`].
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`](crate::driver::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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `numDependencies`: Number of dependencies.
/// - `event`: Event for the node.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddNode`], [`cudaGraphAddEventRecordNode`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `event_out`: Pointer to return the event.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddEventWaitNode`], [`cudaGraphEventWaitNodeSetEvent`], [`cudaGraphEventRecordNodeGetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `event`: Event to use.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeSetParams`], [`cudaGraphAddEventWaitNode`], [`cudaGraphEventWaitNodeGetEvent`], [`cudaGraphEventRecordNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddNode`], [`cudaGraphExternalSemaphoresSignalNodeGetParams`], [`cudaGraphExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetParams`], [`cudaLaunchKernel`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphExternalSemaphoresSignalNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeSetParams`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddNode`], [`cudaGraphExternalSemaphoresWaitNodeGetParams`], [`cudaGraphExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetParams`], [`cudaLaunchKernel`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphExternalSemaphoresWaitNodeSetParams`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
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:
///
/// * passing the allocation to `cudaMemFreeAsync` or `cudaMemFree`;
/// * launching a graph with a free node for that allocation; or
/// * specifying [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a4258c8d3adc203f97e73e92810e1785f) during instantiation, which makes each launch behave as though it called `cudaMemFreeAsync` for every unfreed allocation.
///
/// It is not possible to free an allocation in both the owning graph and another graph. If the allocation is freed in the same graph, a free node cannot be added to another graph. If the allocation is freed in another graph, a free node can no longer be added to the owning graph.
///
/// The following restrictions apply to graphs which contain allocation and/or memory free nodes:
///
/// * Nodes and edges of the graph cannot be deleted.
/// * The graph can only be used in a child node if the ownership is moved to the parent.
/// * Only one instantiation of the graph may exist at any point in time.
/// * The graph cannot be cloned.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]: cudaErrorOutOfMemory.
///
/// See also: [`cudaGraphAddNode`], [`cudaGraphAddMemFreeNode`], [`cudaGraphMemAllocNodeGetParams`], [`cudaDeviceGraphMemTrim`], [`cudaDeviceGetGraphMemAttribute`], [`cudaDeviceSetGraphMemAttribute`], [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetParams`], [`cudaGraphAddMemAllocNode`], [`cudaGraphMemFreeNodeGetParams`].
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if the user attempts to free:
///
/// * an allocation twice in the same graph.
/// * an address that was not returned by an allocation node.
/// * an invalid address.
///
/// The following restrictions apply to graphs which contain allocation and/or memory free nodes:
///
/// * Nodes and edges of the graph cannot be deleted.
/// * The graph can only be used in a child node if the ownership is moved to the parent.
/// * Only one instantiation of the graph may exist at any point in time.
/// * The graph cannot be cloned.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]: cudaErrorOutOfMemory.
///
/// See also: [`cudaGraphAddNode`], [`cudaGraphAddMemAllocNode`], [`cudaGraphMemFreeNodeGetParams`], [`cudaDeviceGraphMemTrim`], [`cudaDeviceGetGraphMemAttribute`], [`cudaDeviceSetGraphMemAttribute`], [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `dptr_out`: Pointer to return the device address.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetParams`], [`cudaGraphAddMemFreeNode`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device`: The device for which cached memory should be freed.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddMemAllocNode`], [`cudaGraphAddMemFreeNode`], [`cudaDeviceGetGraphMemAttribute`], [`cudaDeviceSetGraphMemAttribute`], [`cudaMallocAsync`], [`cudaFreeAsync`].
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:
///
/// * [`cudaGraphMemAttributeType::CU_GRAPH_MEM_ATTR_USED_MEM_CURRENT`]: Amount of memory, in bytes, currently associated with graphs
/// * [`cudaGraphMemAttributeType::CU_GRAPH_MEM_ATTR_USED_MEM_HIGH`]: High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be reset to zero.
/// * [`cudaGraphMemAttributeType::CU_GRAPH_MEM_ATTR_RESERVED_MEM_CURRENT`]: Amount of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
/// * [`cudaGraphMemAttributeType::CU_GRAPH_MEM_ATTR_RESERVED_MEM_HIGH`]: High watermark of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device`: Specifies the scope of the query.
/// - `attr`: attribute to get.
/// - `value`: retrieved value.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaDeviceSetGraphMemAttribute`], [`cudaGraphAddMemAllocNode`], [`cudaGraphAddMemFreeNode`], [`cudaDeviceGraphMemTrim`], [`cudaMallocAsync`], [`cudaFreeAsync`].
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:
///
/// * [`cudaGraphMemAttributeType::CU_GRAPH_MEM_ATTR_USED_MEM_HIGH`]: High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be reset to zero.
/// * [`cudaGraphMemAttributeType::CU_GRAPH_MEM_ATTR_RESERVED_MEM_HIGH`]: High watermark of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device`: Specifies the scope of the query.
/// - `attr`: attribute to get.
/// - `value`: pointer to value to set.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaDeviceGetGraphMemAttribute`], [`cudaGraphAddMemAllocNode`], [`cudaGraphAddMemFreeNode`], [`cudaDeviceGraphMemTrim`], [`cudaMallocAsync`], [`cudaFreeAsync`].
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.
///
/// Note: Cloning is not supported for graphs which contain memory allocation nodes, memory free nodes, or conditional nodes.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pGraphClone`: Returns newly created cloned graph.
/// - `originalGraph`: Graph to clone.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
///
/// See also: [`cudaGraphCreate`], [`cudaGraphNodeFindInClone`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pNode`: Returns handle to the cloned node.
/// - `originalNode`: Handle to the original node.
/// - `clonedGraph`: Cloned graph to query.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphClone`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to query.
/// - `pType`: Pointer to return the node type.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphChildGraphNodeGetGraph`], [`cudaGraphKernelNodeGetParams`], [`cudaGraphKernelNodeSetParams`], [`cudaGraphHostNodeGetParams`], [`cudaGraphHostNodeSetParams`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemsetNodeGetParams`], [`cudaGraphMemsetNodeSetParams`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`], [`cudaGraphNodeGetLocalId`], [`cudaGraphNodeGetToolsId`], [`cudaGraphGetId`], [`cudaGraphExecGetId`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`], [`cudaGraphNodeGetContainingGraph`], [`cudaGraphNodeGetToolsId`], [`cudaGraphGetId`], [`cudaGraphExecGetId`].
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.
///
/// # Return value
///
/// CUDA_SUCCESS [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// See also: [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`], [`cudaGraphNodeGetContainingGraph`], [`cudaGraphNodeGetLocalId`], [`cudaGraphGetId`], [`cudaGraphExecGetId`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`], [`cudaGraphNodeGetContainingGraph`], [`cudaGraphNodeGetLocalId`], [`cudaGraphNodeGetToolsId`], [`cudaGraphExecGetId`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`], [`cudaGraphNodeGetContainingGraph`], [`cudaGraphNodeGetLocalId`], [`cudaGraphNodeGetToolsId`], [`cudaGraphGetId`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `graph`: Graph to query.
/// - `nodes`: Pointer to return the nodes.
/// - `numNodes`: See description.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphCreate`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetType`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `graph`: Graph to query.
/// - `pRootNodes`: Pointer to return the root nodes.
/// - `pNumRootNodes`: See description.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphCreate`], [`cudaGraphGetNodes`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetType`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
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 [`cudaError_t::CUDA_ERROR_LOSSY_QUERY`]. If `edgeData` is non-NULL then `from` and `to` must be as well.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_LOSSY_QUERY`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphAddDependencies`], [`cudaGraphRemoveDependencies`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
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 [`cudaError_t::CUDA_ERROR_LOSSY_QUERY`]. If `edgeData` is non-NULL, then `pDependencies` must be as well.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to query.
/// - `pDependencies`: Pointer to return the dependencies.
/// - `edgeData`: Optional array to return edge data for each dependency.
/// - `pNumDependencies`: See description.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_LOSSY_QUERY`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetDependentNodes`], [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphAddDependencies`], [`cudaGraphRemoveDependencies`].
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 [`cudaError_t::CUDA_ERROR_LOSSY_QUERY`]. If `edgeData` is non-NULL, then `pDependentNodes` must be as well.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_LOSSY_QUERY`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetDependencies`], [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphAddDependencies`], [`cudaGraphRemoveDependencies`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphRemoveDependencies`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddDependencies`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// # Parameters
///
/// - `node`: Node to remove
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
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](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a4258c8d3adc203f97e73e92810e1785f), which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched.
/// * [cudaGraphInstantiateFlagDeviceLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a3fee5a1234b9f5d4ef329a660e6e3f5a), 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](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a4258c8d3adc203f97e73e92810e1785f).
/// * [cudaGraphInstantiateFlagUseNodePriority](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a95adbcaa8c89c323deec4b2070a4bab5), 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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pGraphExec`: Returns instantiated graph.
/// - `graph`: Graph to instantiate.
/// - `flags`: Flags to control instantiation. See [`CUgraphInstantiate_flags`](crate::driver::CUgraphInstantiate_flags).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphInstantiateWithFlags`], [`cudaGraphCreate`], [`cudaGraphUpload`], [`cudaGraphLaunch`], [`cudaGraphExecDestroy`].
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:
///
/// * [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a4258c8d3adc203f97e73e92810e1785f), which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched.
/// * [cudaGraphInstantiateFlagDeviceLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a3fee5a1234b9f5d4ef329a660e6e3f5a), which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing. This flag cannot be used in conjunction with [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a4258c8d3adc203f97e73e92810e1785f).
/// * [cudaGraphInstantiateFlagUseNodePriority](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a95adbcaa8c89c323deec4b2070a4bab5), 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.
///
/// 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:
///
/// * 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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pGraphExec`: Returns instantiated graph.
/// - `graph`: Graph to instantiate.
/// - `flags`: Flags to control instantiation. See [`CUgraphInstantiate_flags`](crate::driver::CUgraphInstantiate_flags).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphInstantiate`], [`cudaGraphCreate`], [`cudaGraphUpload`], [`cudaGraphLaunch`], [`cudaGraphExecDestroy`].
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`] is defined as:
///
/// ```text
/// typedef struct {
/// unsigned long long flags;
/// cudaStream_t uploadStream;
/// cudaGraphNode_t errNode_out;
/// cudaGraphInstantiateResult result_out;
/// } cudaGraphInstantiateParams;
/// ```
///
/// The `flags` field controls the behavior of instantiation and subsequent graph launches. Valid flags are:
///
/// * [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a4258c8d3adc203f97e73e92810e1785f), which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched.
/// * [cudaGraphInstantiateFlagUpload](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a565872dd74cc9d97125bf43740345238), which will perform an upload of the graph into `uploadStream` once the graph has been instantiated.
/// * [cudaGraphInstantiateFlagDeviceLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a3fee5a1234b9f5d4ef329a660e6e3f5a), which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing. This flag cannot be used in conjunction with [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a4258c8d3adc203f97e73e92810e1785f).
/// * [cudaGraphInstantiateFlagUseNodePriority](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga638577f2b0f6a98b5e6a0e6a72d09004a95adbcaa8c89c323deec4b2070a4bab5), 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.
///
/// 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:
///
/// * 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.
///
/// 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:
///
/// * [cudaGraphInstantiateError](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3faefd09000966e3b9d6ca5bcf7b2b9dab27a3438c6c187c9d105ff36692abebd), if passed an invalid value or if an unexpected error occurred which is described by the return value of the function. `errNode_out` will be set to NULL.
/// * [cudaGraphInstantiateInvalidStructure](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3faefd09000966e3b9d6ca5bcf7b2b9da1f6436346e713fc9ddf43408e9b63da0), if the graph structure is invalid. `errNode_out` will be set to one of the offending nodes.
/// * [cudaGraphInstantiateNodeOperationNotSupported](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3faefd09000966e3b9d6ca5bcf7b2b9dafe90eb1caaa8ce17e628dd5fa4651e25), if the graph is instantiated for device launch but contains a node of an unsupported node type, or a node which performs unsupported operations, such as use of CUDA dynamic parallelism within a kernel node. `errNode_out` will be set to this node.
/// * [cudaGraphInstantiateMultipleDevicesNotSupported](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3faefd09000966e3b9d6ca5bcf7b2b9da344068129ac717f6ec29a4a6c88e90f0), if the graph is instantiated for device launch but a node’s device differs from that of another node. This error can also be returned if a graph is not instantiated for device launch and it contains kernels which call device-side [`cudaGraphLaunch`] from multiple devices. `errNode_out` will be set to this node.
///
/// 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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `pGraphExec`: Returns instantiated graph.
/// - `graph`: Graph to instantiate.
/// - `instantiateParams`: Instantiation parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphCreate`], [`cudaGraphInstantiate`], [`cudaGraphInstantiateWithFlags`], [`cudaGraphExecDestroy`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `graphExec`: The executable graph to query.
/// - `flags`: Returns the instantiation flags.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphInstantiate`], [`cudaGraphInstantiateWithFlags`], [`cudaGraphInstantiateWithParams`].
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 owning device of the function cannot change.
/// * A node whose function originally did not use CUDA dynamic parallelism cannot be updated to a function which uses CDP
/// * A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side update calls.
/// * If `hGraphExec` was not instantiated for device launch, a node whose function originally did not use device-side [`cudaGraphLaunch`] 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.
///
/// 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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The API can also be used with a kernel [`cudaKernel_t`] by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol `entryFuncAddr` passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
///
/// Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is [`cudaKernel_t`].
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphExecNodeSetParams`], [`cudaGraphAddKernelNode`], [`cudaGraphKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if the memory operands’ mappings changed or either the original or new memory operands are multidimensional.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphExecNodeSetParams`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParamsToSymbol`], [`cudaGraphExecMemcpyNodeSetParamsFromSymbol`], [`cudaGraphExecMemcpyNodeSetParams1D`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if the memory operands’ mappings changed or the original memory operands are multidimensional.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemcpyNodeToSymbol`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParamsToSymbol`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParamsFromSymbol`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if the memory operands’ mappings changed or the original memory operands are multidimensional.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemcpyNodeFromSymbol`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParamsFromSymbol`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParamsToSymbol`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`] if the memory operands’ mappings changed or the original memory operands are multidimensional.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemcpyNode1D`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParams1D`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphExecNodeSetParams`], [`cudaGraphAddMemsetNode`], [`cudaGraphMemsetNodeSetParams`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphExecNodeSetParams`], [`cudaGraphAddHostNode`], [`cudaGraphHostNodeSetParams`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphExecNodeSetParams`], [`cudaGraphAddChildGraphNode`], [`cudaGraphChildGraphNodeGetGraph`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphExecNodeSetParams`], [`cudaGraphAddEventRecordNode`], [`cudaGraphEventRecordNodeGetEvent`], [`cudaGraphEventWaitNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphExecNodeSetParams`], [`cudaGraphAddEventWaitNode`], [`cudaGraphEventWaitNodeGetEvent`], [`cudaGraphEventRecordNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphExecNodeSetParams`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphExecNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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.
///
/// Note: Currently only kernel, memset and memcpy nodes are supported.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeGetEnabled`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`], [`cudaGraphLaunch`].
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.
///
/// Note: Currently only kernel, memset and memcpy nodes are supported.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphNodeSetEnabled`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`], [`cudaGraphLaunch`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hGraphExec`: The instantiated graph to be updated.
/// - `hGraph`: The graph containing the updated parameters.
/// - `resultInfo`: the error info structure.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE`]
///
/// See also: [`cudaGraphInstantiate`].
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`.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// # Parameters
///
/// - `graphExec`: Executable graph to upload.
/// - `stream`: Stream in which to upload the graph.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphInstantiate`], [`cudaGraphLaunch`], [`cudaGraphExecDestroy`].
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `graphExec`: Executable graph to launch.
/// - `stream`: Stream in which to launch the graph.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphInstantiate`], [`cudaGraphUpload`], [`cudaGraphExecDestroy`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// # Parameters
///
/// - `graphExec`: Executable graph to destroy
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphInstantiate`], [`cudaGraphUpload`], [`cudaGraphLaunch`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: Use of the handle after this call is undefined behavior.
///
/// # Parameters
///
/// - `graph`: Graph to destroy
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGraphCreate`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OPERATING_SYSTEM`]
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaUserObjectRetain`], [`cudaUserObjectRelease`], [`cudaGraphRetainUserObject`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaUserObjectCreate`], [`cudaUserObjectRelease`], [`cudaGraphRetainUserObject`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaUserObjectCreate`], [`cudaUserObjectRetain`], [`cudaGraphRetainUserObject`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaUserObjectCreate`], [`cudaUserObjectRetain`], [`cudaUserObjectRelease`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaUserObjectCreate`], [`cudaUserObjectRetain`], [`cudaUserObjectRelease`], [`cudaGraphRetainUserObject`], [`cudaGraphCreate`].
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`.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaGraphCreate`], [`cudaGraphNodeSetParams`], [`cudaGraphExecNodeSetParams`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaGraphNodeGetParams`], [`cudaGraphAddNode`], [`cudaGraphExecNodeSetParams`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `nodeParams`: Pointer to return the parameters.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaGraphNodeSetParams`], [`cudaGraphAddNode`], [`cudaGraphExecNodeSetParams`].
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:
///
/// | Node type | Allowed changes |
/// | --- | --- |
/// | kernel | See [`cudaGraphExecKernelNodeSetParams`] |
/// | memcpy | Addresses for 1-dimensional copies if allocated in same context; see [`cudaGraphExecMemcpyNodeSetParams`] |
/// | memset | Addresses for 1-dimensional memsets if allocated in same context; see [`cudaGraphExecMemsetNodeSetParams`] |
/// | host | Unrestricted |
/// | child graph | Topology must match and restrictions apply recursively; see [`cudaGraphExecUpdate`] |
/// | event wait | Unrestricted |
/// | event record | Unrestricted |
/// | external semaphore signal | Number of semaphore operations cannot change |
/// | external semaphore wait | Number of semaphore operations cannot change |
/// | memory allocation | API unsupported |
/// | memory free | API unsupported |
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cudaGraphAddNode`], [`cudaGraphNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`].
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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.
///
/// # Return value
///
/// CUDA_SUCCESS, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`](crate::driver::cudaError_enum::CUDA_ERROR_INVALID_VALUE), [`cudaError_enum::CUDA_ERROR_NOT_SUPPORTED`](crate::driver::cudaError_enum::CUDA_ERROR_NOT_SUPPORTED).
///
/// See also: [`cuGraphAddNode`](crate::driver::cuGraphAddNode).
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.
///
/// Note: Graph objects are not threadsafe. More here.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// # 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.
///
/// # Return value
///
/// CUDA_SUCCESS, [`cudaError_enum::CUDA_ERROR_INVALID_VALUE`](crate::driver::cudaError_enum::CUDA_ERROR_INVALID_VALUE), [`cudaError_enum::CUDA_ERROR_NOT_SUPPORTED`](crate::driver::cudaError_enum::CUDA_ERROR_NOT_SUPPORTED).
///
/// See also: [`cuGraphAddNode`](crate::driver::cuGraphAddNode).
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 [`cudaError_t::CUDA_SUCCESS`] and set the returned `funcPtr` if the requested driver function is valid and supported on the platform.
///
/// The API will return [`cudaError_t::CUDA_SUCCESS`] 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`] with the following meanings:
///
/// * [`cudaDriverEntryPointQueryResult::CU_GET_PROC_ADDRESS_SUCCESS`] - The requested symbol was succesfully found based on input arguments and `pfn` is valid
/// * [`cudaDriverEntryPointQueryResult::CU_GET_PROC_ADDRESS_SYMBOL_NOT_FOUND`] - The requested symbol was not found
/// * [`cudaDriverEntryPointQueryResult::CU_GET_PROC_ADDRESS_VERSION_NOT_SUFFICIENT`] - The requested symbol was found but is not supported by the current runtime version (CUDART_VERSION)
///
/// The requested flags can be:
///
/// * [cudaEnableDefault](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61aa9c0bcf076678d03418b7922a39bb1d5): This is the default mode. This is equivalent to [cudaEnablePerThreadDefaultStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61a1bd1da9af3fbaa465a199706ef94328f) if the code is compiled with —default-stream per-thread compilation flag or the macro CUDA_API_PER_THREAD_DEFAULT_STREAM is defined; [cudaEnableLegacyStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61ae37885317cc9edcece9b5069b1494e1b) otherwise.
/// * [cudaEnableLegacyStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61ae37885317cc9edcece9b5069b1494e1b): This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding per-thread versions.
/// * [cudaEnablePerThreadDefaultStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61a1bd1da9af3fbaa465a199706ef94328f): This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread versions. If a per-thread version is not found, the API will return the legacy version of the driver function.
///
/// Deprecated: This function is deprecated as of CUDA 13.0.
///
/// Note: This API is deprecated and [`cudaGetDriverEntryPointByVersion`] (with a hardcoded `cudaVersion`) should be used instead.
///
/// Note: Version mixing among CUDA-defined types and driver API versions is strongly discouraged and doing so can result in an undefined behavior. See Rules for version mixing.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `symbol`: The base name of the driver API function to look for. As an example, for the driver API [`cuMemAlloc_v2`](crate::driver::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`](crate::driver::cuMemAlloc) or [`cuMemAlloc_v2`](crate::driver::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`] for possible values.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuGetProcAddress`](crate::driver::cuGetProcAddress).
#[deprecated]
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 [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// The pointer returned by the API should be cast to a function pointer matching the requested driver function’s definition in the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example, cudaTypedefs.h consists of function pointer typedefs for driver APIs defined in cuda.h.
///
/// 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 [`cudaError_t::CUDA_SUCCESS`] and set the returned `funcPtr` if the requested driver function is valid and supported on the platform.
///
/// The API will return [`cudaError_t::CUDA_SUCCESS`] 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`] with the following meanings:
///
/// * [`cudaDriverEntryPointQueryResult::CU_GET_PROC_ADDRESS_SUCCESS`] - The requested symbol was succesfully found based on input arguments and `pfn` is valid
/// * [`cudaDriverEntryPointQueryResult::CU_GET_PROC_ADDRESS_SYMBOL_NOT_FOUND`] - The requested symbol was not found
/// * [`cudaDriverEntryPointQueryResult::CU_GET_PROC_ADDRESS_VERSION_NOT_SUFFICIENT`] - The requested symbol was found but is not supported by the specified version `cudaVersion`
///
/// The requested flags can be:
///
/// * [cudaEnableDefault](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61aa9c0bcf076678d03418b7922a39bb1d5): This is the default mode. This is equivalent to [cudaEnablePerThreadDefaultStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61a1bd1da9af3fbaa465a199706ef94328f) if the code is compiled with —default-stream per-thread compilation flag or the macro CUDA_API_PER_THREAD_DEFAULT_STREAM is defined; [cudaEnableLegacyStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61ae37885317cc9edcece9b5069b1494e1b) otherwise.
/// * [cudaEnableLegacyStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61ae37885317cc9edcece9b5069b1494e1b): This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding per-thread versions.
/// * [cudaEnablePerThreadDefaultStream](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1ggaf2f2b7ea8f2f705095200807ac5dfd61a1bd1da9af3fbaa465a199706ef94328f): This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread versions. If a per-thread version is not found, the API will return the legacy version of the driver function.
///
/// Note: Version mixing among CUDA-defined types and driver API versions is strongly discouraged and doing so can result in an undefined behavior. See Rules for version mixing.
///
/// Note that this function may also return [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`], [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038af5e52d1774934b77ba55d2aa2c063067) or [`cudaError_t::CUDA_ERROR_NO_DEVICE`] if this call tries to initialize internal CUDA RT state.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `symbol`: The base name of the driver API function to look for. As an example, for the driver API [`cuMemAlloc_v2`](crate::driver::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`] for possible values.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
///
/// See also: [`cuGetProcAddress`](crate::driver::cuGetProcAddress).
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:
///
/// * If module loading is set to EAGER, via the environment variables described in “Module loading”, `library` is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library is unloaded with [`cudaLibraryUnload`].
/// * If the environment variables are set to LAZY, `library` is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context, such as a kernel launch.
///
/// These environment variables are described in the CUDA programming guide under the “CUDA environment variables” section.
///
/// The `code` may be a `cubin` or `fatbin` as output by **nvcc**, or a NULL-terminated `PTX`, either as output by **nvcc** or hand-written, or `Tile` IR data. A fatbin should also contain relocatable code when doing separate compilation. 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_PTX`]
/// - [`cudaError_t::CUDA_ERROR_UNSUPPORTED_PTX_VERSION`]
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
/// - [`cudaError_t::CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND`]
/// - [`cudaError_t::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILER_NOT_FOUND`]
///
/// See also: [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [`cuLibraryLoadData`](crate::driver::cuLibraryLoadData).
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:
///
/// * If module loading is set to EAGER, via the environment variables described in “Module loading”, `library` is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library is unloaded with [`cudaLibraryUnload`].
/// * If the environment variables are set to LAZY, `library` is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context, such as a kernel launch.
///
/// These environment variables are described in the CUDA programming guide under the “CUDA environment variables” section.
///
/// The file should be a `cubin` file as output by **nvcc**, or a `PTX` file either as output by **nvcc** or handwritten, or a `fatbin` file as output by **nvcc** or hand-written, or `Tile` IR file. A fatbin should also contain relocatable code when doing separate compilation. 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_OUT_OF_MEMORY`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_PTX`]
/// - [`cudaError_t::CUDA_ERROR_UNSUPPORTED_PTX_VERSION`]
/// - [`cudaError_t::CUDA_ERROR_NO_BINARY_FOR_GPU`]
/// - [`cudaError_t::CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND`]
/// - [`cudaError_t::CUDA_ERROR_SHARED_OBJECT_INIT_FAILED`]
/// - [`cudaError_t::CUDA_ERROR_JIT_COMPILER_NOT_FOUND`]
///
/// See also: [`cudaLibraryLoadData`], [`cudaLibraryUnload`], [`cuLibraryLoadFromFile`](crate::driver::cuLibraryLoadFromFile).
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
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cuLibraryUnload`](crate::driver::cuLibraryUnload).
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 [`cudaError_t::CUDA_ERROR_NOT_FOUND`].
///
/// # Parameters
///
/// - `pKernel`: Returned kernel handle.
/// - `library`: Library to retrieve kernel from.
/// - `name`: Name of kernel to retrieve.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_FOUND`]
///
/// See also: [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [`cuLibraryGetKernel`](crate::driver::cuLibraryGetKernel).
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 [`cudaError_t::CUDA_ERROR_NOT_FOUND`]. 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_FOUND`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_CONTEXT`]
/// - [`cudaError_t::CUDA_ERROR_CONTEXT_IS_DESTROYED`]
///
/// See also: [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [`cudaLibraryGetManaged`], [`cuLibraryGetGlobal`](crate::driver::cuLibraryGetGlobal).
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 [`cudaError_t::CUDA_ERROR_NOT_FOUND`]. One of the parameters `dptr` or `bytes` (not both) can be NULL in which case it is ignored. Note that managed memory for library `library` is shared across devices and is registered when the library is loaded. 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_FOUND`]
///
/// See also: [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [`cudaLibraryGetGlobal`], [`cuLibraryGetManaged`](crate::driver::cuLibraryGetManaged).
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 [`cudaError_t::CUDA_ERROR_NOT_FOUND`]. If there is no device with attribute [`cudaDeviceProp::unifiedFunctionPointers`](cudaDeviceProp::unifiedFunctionPointers) present in the system, the call may return [`cudaError_t::CUDA_ERROR_NOT_FOUND`].
///
/// # Parameters
///
/// - `fptr`: Returned pointer to a unified function.
/// - `library`: Library to retrieve function pointer memory from.
/// - `symbol`: Name of function pointer to retrieve.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_FOUND`]
///
/// See also: [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [`cuLibraryGetUnifiedFunction`](crate::driver::cuLibraryGetUnifiedFunction).
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaLibraryEnumerateKernels`], [`cudaLibraryLoadFromFile`], [`cudaLibraryLoadData`], [`cuLibraryGetKernelCount`](crate::driver::cuLibraryGetKernelCount).
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_HANDLE`]
///
/// See also: [`cudaLibraryGetKernelCount`], [`cuLibraryEnumerateKernels`](crate::driver::cuLibraryEnumerateKernels).
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 [`cudaError_t::CUDA_SUCCESS`] if the new value of the attribute could be successfully set. If the set fails, this call will return an error. Not all attributes can have values set. Attempting to set a value on a read-only attribute will result in an error ([`cudaError_t::CUDA_ERROR_INVALID_VALUE`])
///
/// 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:
///
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES`] - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute `sharedSizeBytes` cannot exceed the device attribute [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN`]. The maximal size of requestable dynamic shared memory may differ by GPU architecture.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT`] - On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the total shared memory. See [`cudaDeviceAttr::CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR`]. This is only a hint, and the driver can choose a different ratio if required to execute the function.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_WIDTH`]: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_HEIGHT`]: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_REQUIRED_CLUSTER_DEPTH`]: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return cudaErrorNotPermitted.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_NON_PORTABLE_CLUSTER_SIZE_ALLOWED`]: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed.
/// * [`cudaFuncAttribute::CU_FUNC_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE`]: The block scheduling policy of a function. The value type is cudaClusterSchedulingPolicy.
///
/// Note: The API has stricter locking requirements in comparison to its legacy counterpart [`cudaFuncSetAttribute`] due to device-wide semantics. If multiple threads are trying to set the same attribute on the same device simultaneously, the attribute setting will depend on the interleavings chosen by the OS scheduler and memory consistency.
///
/// # Parameters
///
/// - `kernel`: Kernel to set attribute of.
/// - `attr`: Attribute requested.
/// - `value`: Value to set.
/// - `device`: Device to set attribute of.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaErrorInvalidDeviceFunction`](https://docs.nvidia.com/cuda/archive/13.4.2/cuda-runtime-api/cuda_runtime_api/group__CUDART__TYPES.html#group__cudart__types_1gga3f51e3575c2178246db0a94a430e0038ab6af535e7e53d3f21e2437e8977b8c2e)
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [`cudaLibraryGetKernel`], [`cudaLaunchKernel`], [`cudaFuncSetAttribute`], [`cuKernelSetAttribute`](crate::driver::cuKernelSetAttribute).
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.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `device`: Device to get resource for.
/// - `resource`: Output pointer to a [`cudaDevResource`] structure.
/// - `type_`: Type of resource to retrieve.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_TYPE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
///
/// See also: [`cuDeviceGetDevResource`](crate::driver::cuDeviceGetDevResource), [`cudaExecutionCtxGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`].
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:
///
/// * `cudaDevSmResourceSplitIgnoreSmCoscheduling`: Lower the minimum SM count and alignment, and treat each SM independent of its hierarchy. This allows more fine grained partitions but at the cost of advanced features (such as large clusters on compute capability 9.0+).
/// * `cudaDevSmResourceSplitMaxPotentialClusterSize`: Compute Capability 9.0+ only. Attempt to create groups that may allow for maximally sized thread clusters. This can be queried post green context creation using [`cudaOccupancyMaxPotentialClusterSize`].
///
/// A successful API call must either have:
///
/// * A valid array of `result` pointers of size passed in `nbGroups`, with `input` of type [`cudaDevResourceType::cudaDevResourceTypeSm`]. Value of `minCount` must be between 0 and the SM count specified in `input`. `remaining` may be NULL.
/// * NULL passed in for `result`, with a valid integer pointer in `nbGroups` and `input` of type [`cudaDevResourceType::cudaDevResourceTypeSm`]. Value of `minCount` must be between 0 and the SM count specified in `input`. `remaining` may be NULL. This queries the number of groups that would be created by the API.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_TYPE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
///
/// See also: [`cuDevSmResourceSplitByCount`](crate::driver::cuDevSmResourceSplitByCount), [`cudaDeviceGetDevResource`], [`cudaExecutionCtxGetDevResource`], [`cudaDevResourceGenerateDesc`].
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:
///
/// * `result` should point to a [`cudaDevResource`] array of size `nbGroups`, or alternatively, may be NULL, if the developer wishes for only the groupParams entries to be updated
/// * `input` should be a valid [`cudaDevResourceType::cudaDevResourceTypeSm`] resource that originates from querying the execution context, or device.
/// * The `remainder` group may be NULL.
/// * There are no API `flags` at this time, so the value passed in should be 0.
/// * A [`cudaDevSmResourceGroupParams`] array of size `nbGroups`. Each entry must be zero-initialized.
///
/// + `smCount:` must be either 0 or in the range of \[2,inputSmCount\] where inputSmCount is the amount of SMs the `input` resource has. `smCount` must be a multiple of 2, as well as a multiple of `coscheduledSmCount`. When assigning SMs to a group (and if results are expected by having the `result` parameter set), `smCount` cannot end up with 0 or a value less than `coscheduledSmCount` otherwise [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`] will be returned.
/// + `coscheduledSmCount:` allows grouping SMs together in order to be able to launch clusters on Compute Architecture 9.0+. The default value may be queried from the device’s [`cudaDevResourceType::cudaDevResourceTypeSm`] resource (8 on Compute Architecture 9.0+ and 2 otherwise). The maximum is 32 on Compute Architecture 9.0+ and 2 otherwise.
/// + `preferredCoscheduledSmCount:` Attempts to merge `coscheduledSmCount` groups into larger groups, in order to make use of `preferredClusterDimensions` on Compute Architecture 10.0+. The default value is set to `coscheduledSmCount`.
/// + `flags:`
///
/// - `cudaDevSmResourceGroupBackfill:` Treats constraints as a hint, ignoring them if necessary to reach the requested `smCount`. Lets `smCount` be a non-multiple of `coscheduledSmCount`, filling the difference between SM count and already assigned co-scheduled groupings with other SMs. This lets any resulting group behave similar to the `remainder` group for example. When used with `cudaDevSmResourceGroupLocalityDomainId`, backfill fills up to the requested `smCount` using the target locality domain first, then SMs not attributed to any locality domain, then SMs from other locality domains. If no SMs can be found in the requested locality domain, [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`] is returned.
///
/// **Example params and their effect:**
///
/// A groupParams array element is defined in the following order:
///
/// ```text
/// { .smCount, .coscheduledSmCount, .preferredCoscheduledSmCount, .flags, \/\* .reserved \*\/ }
/// ```
///
/// ```text
/// // Example 1
/// // Will discover how many SMs there are, that are co-scheduled in groups of smCoscheduledAlignment.
/// // The rest is placed in the optional remainder.
/// cudaDevSmResourceGroupParams params { 0, 0, 0, 0 };
/// ```
///
/// ```text
/// // Example 2
/// // Assuming the device has 10+ SMs, the result will have 10 SMs that are co-scheduled in groups of 2 SMs.
/// // The rest is placed in the optional remainder.
/// cudaDevSmResourceGroupParams params { 10, 2, 0, 0};
/// // Setting the coscheduledSmCount to 2 guarantees that we can always have a valid result
/// // as long as the SM count is less than or equal to the input resource SM count.
/// ```
///
/// ```text
/// // Example 3
/// // A single piece is split-off, but instead of assigning the rest to the remainder, a second group contains everything else
/// // This assumes the device has 10+ SMs (8 of which are coscheduled in groups of 4),
/// // otherwise the second group could end up with 0 SMs, which is not allowed.
/// cudaDevSmResourceGroupParams params { {8, 4, 0, 0}, {0, 2, 0, cudaDevSmResourceGroupBackfill } }
/// ```
///
/// The difference between a catch-all param group as the last entry and the remainder is in two aspects:
///
/// * The remainder may be NULL / _TYPE_INVALID (if there are no SMs remaining), while a result group must always be valid.
/// * The remainder does not have a structure, while the result group will always need to adhere to a structure of coscheduledSmCount (even if its just 2), and therefore must always have enough coscheduled SMs to cover that requirement (even with the `cudaDevSmResourceGroupBackfill` flag enabled).
///
/// Splitting an input into N groups, can be accomplished by repeatedly splitting off 1 group and re-splitting the remainder (a bisect operation). However, it’s recommended to accomplish this with a single call wherever possible.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_TYPE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
///
/// See also: [`cuDevSmResourceSplit`](crate::driver::cuDevSmResourceSplit), [`cudaDeviceGetDevResource`], [`cudaExecutionCtxGetDevResource`], [`cudaDevResourceGenerateDesc`].
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:
///
/// * A valid output pointer for the `phDesc` descriptor as well as a valid array of `resources` pointers, with the array size passed in `nbResources`. If multiple resources are provided in `resources`, the device they came from must be the same, otherwise [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`] is returned. If multiple resources are provided in `resources` and they are of type [`cudaDevResourceType::cudaDevResourceTypeSm`], they must be outputs (whether `result` or `remaining`) from the same split API instance and have the same smCoscheduledAlignment values, otherwise [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`] is returned.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `phDesc`: Output descriptor.
/// - `resources`: Array of resources to be included in the descriptor.
/// - `nbResources`: Number of resources passed in `resources`.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_TYPE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]: cudaErrorOutOfMemory.
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
///
/// See also: [`cuDevResourceGenerateDesc`](crate::driver::cuDevResourceGenerateDesc), [`cudaDeviceGetDevResource`], [`cudaExecutionCtxGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaGreenCtxCreate`].
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.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]: cudaErrorOutOfMemory.
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
///
/// See also: [`cudaDeviceGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`], [`cudaExecutionCtxGetDevResource`], [`cudaExecutionCtxDestroy`], [`cudaInitDevice`], [`cudaExecutionCtxStreamCreate`].
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 [`cudaError_t::CUDA_ERROR_STREAM_DETACHED`] with the exception of the following APIs:
///
/// * [`cudaStreamDestroy`]. Note this is only supported on CUDA drivers 13.1 and above.
///
/// 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.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit context-based programming without relying on thread-local state. If no context is specified, the API will return [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// # Parameters
///
/// - `ctx`: Execution context to destroy (required parameter, see note below)
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
///
/// See also: [`cudaGreenCtxCreate`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit context-based programming without relying on thread-local state. If no context is specified, the API will return [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// # Parameters
///
/// - `ctx`: Execution context to get resource for (required parameter, see note below).
/// - `resource`: Output pointer to a [`cudaDevResource`] structure.
/// - `type_`: Type of resource to retrieve.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_SUPPORTED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
///
/// See also: [`cudaDeviceGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`], [`cudaGreenCtxCreate`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit context-based programming without relying on thread-local state. If no context is specified, the API will return [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// # Parameters
///
/// - `device`: Returned device handle for the specified execution context.
/// - `ctx`: Execution context for which to obtain the device (required parameter, see note below).
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
///
/// See also: [`cudaGreenCtxCreate`], [`cudaExecutionCtxDestroy`], [`cuCtxGetDevice`](crate::driver::cuCtxGetDevice).
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit context-based programming without relying on thread-local state. If no context is specified, the API will return [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// # Parameters
///
/// - `ctx`: Context for which to obtain the Id (required parameter, see note below).
/// - `ctxId`: Pointer to store the Id of the context.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
///
/// See also: [`cudaGreenCtxCreate`], [`cudaExecutionCtxDestroy`], [`cudaExecutionCtxGetDevice`], [`cuCtxGetId`](crate::driver::cuCtxGetId).
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:
///
/// * [`cudaStreamDefault`]: Default stream creation flag. This would be [`cudaStreamNonBlocking`] for streams created on a green context.
/// * [`cudaStreamNonBlocking`]: Specifies that work running in the created stream may run concurrently with work in stream 0 (the NULL stream), and that the created stream should perform no implicit synchronization with stream 0
///
/// 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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit context-based programming without relying on thread-local state. If no context is specified, the API will return [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// Note: In the current implementation, only compute kernels launched in priority streams are affected by the stream’s priority. Stream priorities have no effect on host-to-device and device-to-host memory operations.
///
/// # 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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]: cudaErrorOutOfMemory.
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
///
/// See also: [`cudaStreamDestroy`], [`cudaGreenCtxCreate`], [`cudaDeviceGetStreamPriorityRange`], [`cudaStreamGetFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [`cudaLaunchKernel`], [`cudaEventRecord`], [`cudaStreamWaitEvent`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`].
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.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit context-based programming without relying on thread-local state. If no context is specified, the API will return [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// # Parameters
///
/// - `ctx`: Execution context to synchronize (required parameter, see note below)
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_CONTEXT`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
///
/// See also: [`cudaGreenCtxCreate`], [`cudaExecutionCtxDestroy`], [`cudaDeviceSynchronize`], [`cuCtxSynchronize_v2`](crate::driver::cuCtxSynchronize_v2).
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 [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_TYPE`] is `type` is [`cudaDevResourceType::cudaDevResourceTypeWorkqueueConfig`] or [`cudaDevResourceType::cudaDevResourceTypeWorkqueue`].
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// # Parameters
///
/// - `hStream`: Stream to get resource for.
/// - `resource`: Output pointer to a [`cudaDevResource`] structure.
/// - `type_`: Type of resource to retrieve.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_CONTEXT`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_RESOURCE_TYPE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]: cudaErrorInvalidHandle.
/// - [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`]
/// - [`cudaError_t::CUDA_ERROR_CALL_REQUIRES_NEWER_DRIVER`]
///
/// See also: [`cudaGreenCtxCreate`], [`cudaExecutionCtxStreamCreate`], [`cudaStreamCreate`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`], [`cuStreamGetDevResource`](crate::driver::cuStreamGetDevResource).
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.
///
/// Note: The API will return [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED`] if the specified execution context `ctx` has a stream in the capture mode. In such a case, the call will invalidate all the conflicting captures.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit context-based programming without relying on thread-local state. If no context is specified, the API will return [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// # Parameters
///
/// - `ctx`: Execution context to record event for (required parameter, see note below).
/// - `event`: Event to record.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]: cudaErrorInvalidHandle.
/// - [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED`]
///
/// See also: [`cudaEventRecord`], [`cudaExecutionCtxWaitEvent`], [`cuCtxRecordEvent`](crate::driver::cuCtxRecordEvent), [`cuGreenCtxRecordEvent`](crate::driver::cuGreenCtxRecordEvent).
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.
///
/// Note: `event` may be from a different execution context or device than `ctx`.
///
/// Note: The API will return [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED`] and invalidate the capture if the specified event `event` is part of an ongoing capture sequence or if the specified execution context `ctx` has a stream in the capture mode.
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [`cudaError_t::CUDA_ERROR_NOT_PERMITTED`] may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// Note: The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit context-based programming without relying on thread-local state. If no context is specified, the API will return [`cudaError_t::CUDA_ERROR_INVALID_VALUE`].
///
/// # Parameters
///
/// - `ctx`: Execution context to wait for (required parameter, see note below).
/// - `event`: Event to wait on.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_DEINITIALIZED`]
/// - [`cudaError_t::CUDA_ERROR_NOT_INITIALIZED`]: cudaErrorInvalidHandle.
/// - [`cudaError_t::CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED`]
///
/// See also: [`cudaExecutionCtxRecordEvent`], [`cudaStreamWaitEvent`], [`cuCtxWaitEvent`](crate::driver::cuCtxWaitEvent), [`cuGreenCtxWaitEvent`](crate::driver::cuGreenCtxWaitEvent).
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_VALUE`]
/// - [`cudaError_t::CUDA_ERROR_INVALID_DEVICE`]
///
/// See also: [`cudaExecutionCtxGetDevice`], [`cudaExecutionCtxGetId`].
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
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.
///
/// # Return value
///
/// - [`cudaError_t::CUDA_SUCCESS`]
///
/// See also: (C++, API).
pub fn cudaGetKernel(
kernelPtr: *mut cudaKernel_t,
entryFuncAddr: *const ::core::ffi::c_void,
) -> cudaError_t;
}