/* automatically generated by rust-bindgen 0.72.1 */
pub const CUDART_VERSION: u32 = 13020;
pub const cudaSurfaceType1D: u32 = 1;
pub const cudaSurfaceType2D: u32 = 2;
pub const cudaSurfaceType3D: u32 = 3;
pub const cudaSurfaceTypeCubemap: u32 = 12;
pub const cudaSurfaceType1DLayered: u32 = 241;
pub const cudaSurfaceType2DLayered: u32 = 242;
pub const cudaSurfaceTypeCubemapLayered: u32 = 252;
pub const cudaTextureType1D: u32 = 1;
pub const cudaTextureType2D: u32 = 2;
pub const cudaTextureType3D: u32 = 3;
pub const cudaTextureTypeCubemap: u32 = 12;
pub const cudaTextureType1DLayered: u32 = 241;
pub const cudaTextureType2DLayered: u32 = 242;
pub const cudaTextureTypeCubemapLayered: u32 = 252;
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum cudaRoundMode {
cudaRoundNearest = 0,
cudaRoundZero = 1,
cudaRoundPosInf = 2,
cudaRoundMinInf = 3,
}
pub type size_t = ::core::ffi::c_ulong;
/// CUDA Surface boundary modes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum cudaSurfaceBoundaryMode {
/// Zero boundary mode.
cudaBoundaryModeZero = 0,
/// Clamp boundary mode.
cudaBoundaryModeClamp = 1,
/// Trap boundary mode.
cudaBoundaryModeTrap = 2,
}
/// CUDA Surface format modes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum cudaSurfaceFormatMode {
/// Forced format mode.
cudaFormatModeForced = 0,
/// Auto format mode.
cudaFormatModeAuto = 1,
}
/// An opaque value that represents a CUDA Surface object.
pub type cudaSurfaceObject_t = ::core::ffi::c_ulonglong;
/// CUDA texture address modes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum cudaTextureAddressMode {
/// Wrapping address mode.
cudaAddressModeWrap = 0,
/// Clamp to edge address mode.
cudaAddressModeClamp = 1,
/// Mirror address mode.
cudaAddressModeMirror = 2,
/// Border address mode.
cudaAddressModeBorder = 3,
}
/// CUDA texture filter modes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum cudaTextureFilterMode {
/// Point filter mode.
cudaFilterModePoint = 0,
/// Linear filter mode.
cudaFilterModeLinear = 1,
}
/// CUDA texture read modes.
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
Hash,
PartialOrd,
Ord,
PartialEq,
Eq,
TryFromPrimitive,
IntoPrimitive,
)]
pub enum cudaTextureReadMode {
/// Read texture as specified element type.
cudaReadModeElementType = 0,
/// Read texture as normalized float.
cudaReadModeNormalizedFloat = 1,
}
/// 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;
unsafe extern "C" {
/// 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](#cudaStream_t), [cudaEvent_t](#cudaEvent_t), [cudaArray_t](#cudaArray_t), [cudaMipmappedArray_t](#cudaMipmappedArray_t), [cudaPitchedPtr](#cudaPitchedPtr), [`cudaTextureObject_t`], [`cudaSurfaceObject_t`], textureReference, surfaceReference, [cudaExternalMemory_t](#cudaExternalMemory_t), [cudaExternalSemaphore_t](#cudaExternalSemaphore_t) and [cudaGraphicsResource_t](#cudaGraphicsResource_t). These resources also include memory allocations by [`cudaMalloc`], [cudaMallocHost](high-level-api.md#group__CUDART__HIGHLEVEL_1gd5c991beb38e2b8419f50285707ae87e "[C++ API] Allocates page-locked memory on the host"), [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system.") 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()](memory-pools.md#group__CUDART__MEMORY__POOLS_1gbbf70065888d61853c047513baa14081 "Allocates memory with stream ordered semantics.") and [`cudaMallocFromPoolAsync`]. These memory allocations need to be destroyed explicitly.
/// * If a non-primary [CUcontext](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1gf9f5bd81658f866613785b3a0bb7d7d9) is current to the thread, [`cudaDeviceReset`] will destroy only the internal CUDA RT state for that [CUcontext](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1gf9f5bd81658f866613785b3a0bb7d7d9).
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceSynchronize`]
pub fn cudaDeviceReset() -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaDeviceScheduleBlockingSync) 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 [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceReset`], [cuCtxSynchronize](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g7a54725f28d34b8c6299f0c6ca579616).
pub fn cudaDeviceSynchronize() -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaLimit) has its own specific restrictions, so each is discussed here.
///
/// * [cudaLimitStackSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc93651fc8f54e641c9b133f1b57703d22ce656) controls the stack size in bytes of each GPU thread.
///
/// * [cudaLimitPrintfFifoSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc9365123b80a6221a6853e918c2816bb76742c) controls the size in bytes of the shared FIFO used by the printf() device system call. Setting [cudaLimitPrintfFifoSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc9365123b80a6221a6853e918c2816bb76742c) must not be performed after launching any kernel that uses the printf() device system call - in such case [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// * [cudaLimitMallocHeapSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc93651b399716bf0a592bc42055473c1273881) controls the size in bytes of the heap used by the malloc() and free() device system calls. Setting [cudaLimitMallocHeapSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc93651b399716bf0a592bc42055473c1273881) must not be performed after launching any kernel that uses the malloc() or free() device system calls - in such case [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// * [cudaLimitDevRuntimeSyncDepth](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc9365123c4900be4af436cb769e4c72d07be11) 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](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038265dbf94c45903cd582cfc40f93a176a) if the limitation is violated. This limit can be set smaller than the default or up the maximum launch depth of 24. When
/// setting this limit, keep in mind that additional levels of sync depth require the 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 [cudaErrorMemoryAllocation](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f210f50ae7f17f655e0504929606add9), 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 [cudaErrorUnsupportedLimit](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c3b950b6f8668f7282fae25bfcefd13a) being returned.
///
/// * [cudaLimitDevRuntimePendingLaunchCount](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc9365118712cb05d2c3efaeea73afba823d916) 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](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382372902b9ffd65825d138e16125b1376) 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 [cudaErrorMemoryAllocation](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f210f50ae7f17f655e0504929606add9), 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 [cudaErrorUnsupportedLimit](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c3b950b6f8668f7282fae25bfcefd13a) being returned.
///
/// * [cudaLimitMaxL2FetchGranularity](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc9365168d3522068213e4ba46c4c99ebc4ce12) 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.
///
/// * [cudaLimitPersistingL2CacheSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc93651fc5135f91c07d7aa2d1072db9854b113) controls size in bytes available for persisting L2 cache. This is purely a performance hint and it can be ignored or clamped
/// depending on the platform.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceGetLimit`], [cuCtxSetLimit](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g0651954dfb9788173e60a9af7201e65a).
///
/// # Parameters
///
/// - `limit`: Limit to set.
/// - `value`: Size of limit.
pub fn cudaDeviceSetLimit(limit: cudaLimit, value: size_t) -> cudaError_t;
}
unsafe extern "C" {
/// Return resource limits.
///
/// Returns in \*pValue the current size of limit. The following [cudaLimit](#cudaLimit) values are supported.
///
/// * [cudaLimitStackSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc93651fc8f54e641c9b133f1b57703d22ce656) is the stack size in bytes of each GPU thread.
/// * [cudaLimitPrintfFifoSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc9365123b80a6221a6853e918c2816bb76742c) is the size in bytes of the shared FIFO used by the printf() device system call.
/// * [cudaLimitMallocHeapSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc93651b399716bf0a592bc42055473c1273881) is the size in bytes of the heap used by the malloc() and free() device system calls.
/// * [cudaLimitDevRuntimeSyncDepth](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc9365123c4900be4af436cb769e4c72d07be11) 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 [cudaErrorUnsupportedLimit](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c3b950b6f8668f7282fae25bfcefd13a) on such devices.
/// * [cudaLimitDevRuntimePendingLaunchCount](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc9365118712cb05d2c3efaeea73afba823d916) is the maximum number of outstanding device runtime launches.
/// * [cudaLimitMaxL2FetchGranularity](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc9365168d3522068213e4ba46c4c99ebc4ce12) is the L2 cache fetch granularity.
/// * [cudaLimitPersistingL2CacheSize](types.md#group__CUDART__TYPES_1gg4c4b34c054d383b0e9a63ab0ffc93651fc5135f91c07d7aa2d1072db9854b113) is the persisting L2 cache size in bytes.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceSetLimit`], [cuCtxGetLimit](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g9f2d47d1745752aa16da7ed0d111b6a8).
///
/// # Parameters
///
/// - `pValue`: Returned size of the limit.
/// - `limit`: Limit to query.
pub fn cudaDeviceGetLimit(pValue: *mut size_t, limit: cudaLimit) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuDeviceGetTexture1DLinearMaxWidth](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gb41b3a675bae9932bffa1c0ae969b1e0).
///
/// # Parameters
///
/// - `maxWidthInElements`: Returns maximum number of texture elements allocatable for given fmtDesc.
/// - `fmtDesc`: Texture format description.
pub fn cudaDeviceGetTexture1DLinearMaxWidth(
maxWidthInElements: *mut size_t,
fmtDesc: *const cudaChannelFormatDesc,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the preferred cache configuration for the current device.
///
/// On devices where the L1 cache and shared memory use the same hardware resources, this returns through pCacheConfig the preferred cache configuration for the current device. This is only a preference. The runtime will use the requested configuration
/// if possible, but it is free to choose a different configuration if required to execute functions.
///
/// This will return a pCacheConfig of [cudaFuncCachePreferNone](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b3b4b8c65376ce1ca107be413e15981bc) on devices where the size of the L1 cache and shared memory are fixed.
///
/// The supported cache configurations are:
///
/// * [cudaFuncCachePreferNone](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b3b4b8c65376ce1ca107be413e15981bc): no preference for shared memory or L1 (default)
/// * [cudaFuncCachePreferShared](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b84725d25c531f9bafc61ae329afe5b2b): prefer larger shared memory and smaller L1 cache
/// * [cudaFuncCachePreferL1](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b8ecb48ccbc2230c81528a2c7c695100e): prefer larger L1 cache and smaller shared memory
/// * [cudaFuncCachePreferEqual](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49bd151ac8d667150c601de4b9542887a3b): prefer equal size L1 cache and shared memory
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceSetCacheConfig`], [cudaFuncSetCacheConfig ( C API)](execution-control.md#group__CUDART__EXECUTION_1g6699ca1943ac2655effa0d571b2f4f15 "Sets the preferred cache configuration for a device function."), [cudaFuncSetCacheConfig ( C++ API)](high-level-api.md#group__CUDART__HIGHLEVEL_1g7d9cc996fe45b6260ebb086caff1c685 "[C++ API] Sets the preferred cache configuration for a device function"), [cuCtxGetCacheConfig](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g40b6b141698f76744dea6e39b9a25360).
///
/// # Parameters
///
/// - `pCacheConfig`: Returned cache configuration.
pub fn cudaDeviceGetCacheConfig(pCacheConfig: *mut cudaFuncCache) -> cudaError_t;
}
unsafe extern "C" {
/// Returns numerical values that correspond to the least and greatest stream priorities.
///
/// Returns in \*leastPriority and \*greatestPriority the numerical values that correspond to the least and greatest stream priorities respectively. Stream priorities follow a
/// convention where lower numbers imply greater priorities. The range of meaningful stream priorities is given by [\*greatestPriority, \*leastPriority]. If the user attempts to create a stream with a priority value that is outside the 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreateWithPriority`], [`cudaStreamGetPriority`], [cuCtxGetStreamPriorityRange](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g137920ab61a71be6ce67605b9f294091).
///
/// # Parameters
///
/// - `leastPriority`: Pointer to an int in which the numerical value for least stream priority is returned.
/// - `greatestPriority`: Pointer to an int in which the numerical value for greatest stream priority is returned.
pub fn cudaDeviceGetStreamPriorityRange(
leastPriority: *mut ::core::ffi::c_int,
greatestPriority: *mut ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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)](execution-control.md#group__CUDART__EXECUTION_1g6699ca1943ac2655effa0d571b2f4f15 "Sets the preferred cache configuration for a device function.") or [cudaFuncSetCacheConfig ( C++ API)](high-level-api.md#group__CUDART__HIGHLEVEL_1g7d9cc996fe45b6260ebb086caff1c685 "[C++ API] Sets the preferred cache configuration for a device function") will be preferred over this device-wide setting. Setting the device-wide cache configuration to [cudaFuncCachePreferNone](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b3b4b8c65376ce1ca107be413e15981bc) 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:
///
/// * [cudaFuncCachePreferNone](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b3b4b8c65376ce1ca107be413e15981bc): no preference for shared memory or L1 (default)
/// * [cudaFuncCachePreferShared](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b84725d25c531f9bafc61ae329afe5b2b): prefer larger shared memory and smaller L1 cache
/// * [cudaFuncCachePreferL1](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b8ecb48ccbc2230c81528a2c7c695100e): prefer larger L1 cache and smaller shared memory
/// * [cudaFuncCachePreferEqual](types.md#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49bd151ac8d667150c601de4b9542887a3b): prefer equal size L1 cache and shared memory
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceGetCacheConfig`], [cudaFuncSetCacheConfig ( C API)](execution-control.md#group__CUDART__EXECUTION_1g6699ca1943ac2655effa0d571b2f4f15 "Sets the preferred cache configuration for a device function."), [cudaFuncSetCacheConfig ( C++ API)](high-level-api.md#group__CUDART__HIGHLEVEL_1g7d9cc996fe45b6260ebb086caff1c685 "[C++ API] Sets the preferred cache configuration for a device function"), [cuCtxSetCacheConfig](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g54699acf7e2ef27279d013ca2095f4a3).
///
/// # Parameters
///
/// - `cacheConfig`: Requested cache configuration.
pub fn cudaDeviceSetCacheConfig(cacheConfig: cudaFuncCache) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a handle to a compute device.
///
/// Returns in \*device a device ordinal given a PCI bus ID string.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceGetPCIBusId`], [cuDeviceGetByPCIBusId](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ga89cd3fa06334ba7853ed1232c5ebe2a).
///
/// # Parameters
///
/// - `device`: Returned device ordinal.
/// - `pciBusId`: String in one of the following forms: [domain]:[bus]:[device].[function] [domain]:[bus]:[device] [bus]:[device].[function]
/// where domain, bus, device, and function are all hexadecimal values.
pub fn cudaDeviceGetByPCIBusId(
device: *mut ::core::ffi::c_int,
pciBusId: *const ::core::ffi::c_char,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a PCI Bus Id string for the device.
///
/// Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by pciBusId. len specifies the maximum length of the string that may be returned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceGetByPCIBusId`], [cuDeviceGetPCIBusId](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g85295e7d9745ab8f0aa80dd1e172acfc).
///
/// # Parameters
///
/// - `pciBusId`: Returned identifier string for the device in the following format [domain]:[bus]:[device].[function] where domain, bus, device, and function are all hexadecimal values. pciBusId should be large enough to store 13 characters including the NULL-terminator.
/// - `len`: Maximum length of string to store in name.
/// - `device`: Device to get identifier string for.
pub fn cudaDeviceGetPCIBusId(
pciBusId: *mut ::core::ffi::c_char,
len: ::core::ffi::c_int,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Gets an interprocess handle for a previously allocated event.
///
/// Takes as input a previously allocated event. This event must have been created with the [cudaEventInterprocess](#cudaEventInterprocess) and [cudaEventDisableTiming](#cudaEventDisableTiming) flags set. This opaque handle may be copied into other processes and opened with [`cudaIpcOpenEventHandle`] to allow efficient hardware synchronization between GPU work in different processes.
///
/// After the event has been been opened in the importing process, [`cudaEventRecord`], [`cudaEventSynchronize`], [`cudaStreamWaitEvent`] and [`cudaEventQuery`] may be used in either process. Performing operations on the imported event after the exported event has been freed with [`cudaEventDestroy`] will result in undefined behavior.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cudaEventCreate](high-level-api.md#group__CUDART__HIGHLEVEL_1g4b5fdb19d7fb5f6f8862559f9279f6c3 "[C++ API] Creates an event object with the specified flags"), [`cudaEventDestroy`], [`cudaEventSynchronize`], [`cudaEventQuery`], [`cudaStreamWaitEvent`], [`cudaIpcOpenEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcOpenMemHandle`], [`cudaIpcCloseMemHandle`], [cuIpcGetEventHandle](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gea02eadd12483de5305878b13288a86c).
///
/// # Parameters
///
/// - `handle`: Pointer to a user allocated cudaIpcEventHandle in which to return the opaque event handle.
/// - `event`: Event allocated with [cudaEventInterprocess](#cudaEventInterprocess) and [cudaEventDisableTiming](#cudaEventDisableTiming) flags.
pub fn cudaIpcGetEventHandle(
handle: *mut cudaIpcEventHandle_t,
event: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaEvent_t) that behaves like a locally created event with the [cudaEventDisableTiming](#cudaEventDisableTiming) flag specified. This event must be freed with [`cudaEventDestroy`].
///
/// Performing operations on the imported event after the exported event has been freed with [`cudaEventDestroy`] will result in undefined behavior.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cudaEventCreate](high-level-api.md#group__CUDART__HIGHLEVEL_1g4b5fdb19d7fb5f6f8862559f9279f6c3 "[C++ API] Creates an event object with the specified flags"), [`cudaEventDestroy`], [`cudaEventSynchronize`], [`cudaEventQuery`], [`cudaStreamWaitEvent`], [`cudaIpcGetEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcOpenMemHandle`], [`cudaIpcCloseMemHandle`], [cuIpcOpenEventHandle](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf1d525918b6c643b99ca8c8e42e36c2e).
///
/// # Parameters
///
/// - `event`: Returns the imported event.
/// - `handle`: Interprocess handle to open.
pub fn cudaIpcOpenEventHandle(
event: *mut cudaEvent_t,
handle: cudaIpcEventHandle_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Gets an interprocess memory handle for an existing device memory allocation.
///
/// Takes a pointer to the base of an existing device memory allocation created with [`cudaMalloc`] and exports it for use in another process. This is a lightweight operation and may be called multiple times on an allocation
/// without adverse effects.
///
/// If a region of memory is freed with [`cudaFree`] and a subsequent call to [`cudaMalloc`] returns memory with the same device address, [`cudaIpcGetMemHandle`] will return a unique handle for the new memory.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc`], [`cudaFree`], [`cudaIpcGetEventHandle`], [`cudaIpcOpenEventHandle`], [`cudaIpcOpenMemHandle`], [`cudaIpcCloseMemHandle`], [cuIpcGetMemHandle](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g6f1b5be767b275f016523b2ac49ebec1).
///
/// # Parameters
///
/// - `handle`: Pointer to user allocated cudaIpcMemHandle to return the handle in.
/// - `devPtr`: Base pointer to previously allocated device memory.
pub fn cudaIpcGetMemHandle(
handle: *mut cudaIpcMemHandle_t,
devPtr: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process.
///
/// Maps memory exported from another process with [`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](#cudaIpcMemLazyEnablePeerAccess) flag. [`cudaDeviceCanAccessPeer`] can determine if a mapping is possible.
///
/// [`cudaIpcOpenMemHandle`] can open handles to devices that may not be visible in the process calling the API.
///
/// Contexts that may open cudaIpcMemHandles are restricted in the following way. cudaIpcMemHandles from each device in a given
/// process may only be opened by one context per device per other process.
///
/// If the memory handle has already been opened by the current context, the reference count on the handle is incremented by 1
/// and the existing device pointer is returned.
///
/// Memory returned from [`cudaIpcOpenMemHandle`] must be freed with [`cudaIpcCloseMemHandle`].
///
/// Calling [`cudaFree`] on an exported memory region before calling [`cudaIpcCloseMemHandle`] in the importing context will result in undefined behavior.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * No guarantees are made about the address returned in \*devPtr. In particular, multiple processes may not receive the same address for the same handle.
///
/// **See also:**
///
/// [`cudaMalloc`], [`cudaFree`], [`cudaIpcGetEventHandle`], [`cudaIpcOpenEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcCloseMemHandle`], [`cudaDeviceEnablePeerAccess`], [`cudaDeviceCanAccessPeer`], [cuIpcOpenMemHandle](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ga8bd126fcff919a0c996b7640f197b79).
///
/// # Parameters
///
/// - `devPtr`: Returned device pointer.
/// - `handle`: cudaIpcMemHandle to open.
/// - `flags`: Flags for this operation. Must be specified as [cudaIpcMemLazyEnablePeerAccess](#cudaIpcMemLazyEnablePeerAccess).
pub fn cudaIpcOpenMemHandle(
devPtr: *mut *mut ::core::ffi::c_void,
handle: cudaIpcMemHandle_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Attempts to close memory mapped with cudaIpcOpenMemHandle.
///
/// Decrements the reference count of the memory returnd by [`cudaIpcOpenMemHandle`] by 1. When the reference count reaches 0, this API unmaps the memory. The original allocation in the exporting process as
/// well as imported mappings in other processes will be unaffected.
///
/// Any resources used to enable peer access will be freed if this is the last mapping using them.
///
/// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
/// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
/// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc`], [`cudaFree`], [`cudaIpcGetEventHandle`], [`cudaIpcOpenEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcOpenMemHandle`], [cuIpcCloseMemHandle](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gd6f5d5bcf6376c6853b64635b0157b9e).
///
/// # Parameters
///
/// - `devPtr`: Device pointer returned by [`cudaIpcOpenMemHandle`]
pub fn cudaIpcCloseMemHandle(devPtr: *mut ::core::ffi::c_void) -> cudaError_t;
}
unsafe extern "C" {
/// Blocks until remote writes are visible to the specified scope.
///
/// Blocks until remote writes to the target context via mappings created through GPUDirect RDMA APIs, like nvidia_p2p_get_pages
/// (see <https://docs.nvidia.com/cuda/gpudirect-rdma> for more information), are visible to the specified scope.
///
/// If the scope equals or lies within the scope indicated by [cudaDevAttrGPUDirectRDMAWritesOrdering](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd881d5b0c5bf7777e382920af4d743bde), the call will be a no-op and can be safely omitted for performance. This can be determined by comparing the numerical values
/// between the two enums, with smaller scopes having smaller values.
///
/// Users may query support for this API via [cudaDevAttrGPUDirectRDMAFlushWritesOptions](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd7b3462e13705248606f39fb5381446ee).
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuFlushGPUDirectRDMAWrites](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g265e3c82ef0f0fe035f85c4c45a8fbdf).
///
/// # Parameters
///
/// - `target`: The target of the operation, see cudaFlushGPUDirectRDMAWritesTarget.
/// - `scope`: The scope of the operation, see cudaFlushGPUDirectRDMAWritesScope.
pub fn cudaDeviceFlushGPUDirectRDMAWrites(
target: cudaFlushGPUDirectRDMAWritesTarget,
scope: cudaFlushGPUDirectRDMAWritesScope,
) -> cudaError_t;
}
unsafe extern "C" {
/// Registers a callback function to receive async notifications.
///
/// Registers callbackFunc to receive async notifications.
///
/// The userData parameter is passed to the callback function at async notification time. Likewise, callback is also passed to the callback function to distinguish between multiple registered callbacks.
///
/// The callback function being registered should be designed to return quickly (~10ms). Any long running tasks should be queued
/// for execution on an application thread.
///
/// Callbacks may not call cudaDeviceRegisterAsyncNotification or cudaDeviceUnregisterAsyncNotification. Doing so will result
/// in [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3). Async notification callbacks execute in an undefined order and may be serialized.
///
/// Returns in \*callback a handle representing the registered callback instance.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaDeviceUnregisterAsyncNotification`]
///
/// # Parameters
///
/// - `device`: The device on which to register the callback.
/// - `callbackFunc`: The function to register as a callback.
/// - `userData`: A generic pointer to user data. This is passed into the callback function.
/// - `callback`: A handle representing the registered callback instance.
pub fn cudaDeviceRegisterAsyncNotification(
device: ::core::ffi::c_int,
callbackFunc: cudaAsyncCallback,
userData: *mut ::core::ffi::c_void,
callback: *mut cudaAsyncCallbackHandle_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Unregisters an async notification callback.
///
/// Unregisters callback so that the corresponding callback function will stop receiving async notifications.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaDeviceRegisterAsyncNotification`]
///
/// # Parameters
///
/// - `device`: The device from which to remove callback.
/// - `callback`: The callback instance to unregister from receiving async notifications.
pub fn cudaDeviceUnregisterAsyncNotification(
device: ::core::ffi::c_int,
callback: cudaAsyncCallbackHandle_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the shared memory configuration for the current device.
///
/// pConfig
///
/// [`cudaDeviceSetSharedMemConfig`]
///
/// [`cudaDeviceGetSharedMemConfig`]
///
/// The returned bank configurations can be either:
///
/// * cudaSharedMemBankSizeFourByte - shared memory bank width is four bytes.
/// * cudaSharedMemBankSizeEightByte - shared memory bank width is eight bytes.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceSetCacheConfig`], [`cudaDeviceGetCacheConfig`], [`cudaDeviceSetSharedMemConfig`], [cudaFuncSetCacheConfig](high-level-api.md#group__CUDART__HIGHLEVEL_1g7d9cc996fe45b6260ebb086caff1c685 "[C++ API] Sets the preferred cache configuration for a device function"), [cuCtxGetSharedMemConfig](../cuda-driver-api/group__CUDA__CTX__DEPRECATED.html#group__CUDA__CTX__DEPRECATED_1gfac1414497a1a2a40bba474c6b5bf194).
///
/// # Parameters
///
/// - `pConfig`: Returned cache configuration.
#[deprecated]
pub fn cudaDeviceGetSharedMemConfig(
pConfig: *mut cudaSharedMemConfig,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the shared memory configuration for the current device.
///
/// [`cudaFuncSetSharedMemConfig`]
///
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceSetCacheConfig`], [`cudaDeviceGetCacheConfig`], [`cudaDeviceGetSharedMemConfig`], [cudaFuncSetCacheConfig](high-level-api.md#group__CUDART__HIGHLEVEL_1g7d9cc996fe45b6260ebb086caff1c685 "[C++ API] Sets the preferred cache configuration for a device function"), [cuCtxSetSharedMemConfig](../cuda-driver-api/group__CUDA__CTX__DEPRECATED.html#group__CUDA__CTX__DEPRECATED_1gb1fef6f9fd5c252245214f85ae01ec23).
///
/// # Parameters
///
/// - `config`: Requested cache configuration.
#[deprecated]
pub fn cudaDeviceSetSharedMemConfig(config: cudaSharedMemConfig) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the last error from a runtime call.
///
/// Returns the last error that has been produced by any of the runtime calls in the same instance of the CUDA Runtime library
/// in the host thread and resets it to [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591).
///
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaPeekAtLastError`], [`cudaGetErrorName`], [`cudaGetErrorString`], [cudaError](#cudaError).
pub fn cudaGetLastError() -> cudaError_t;
}
unsafe extern "C" {
/// Returns the last error from a runtime call.
///
/// Returns the last error that has been produced by any of the runtime calls in the same instance of the CUDA Runtime library
/// in the host thread. This call does not reset the error to [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetLastError`], [`cudaGetErrorName`], [`cudaGetErrorString`], [cudaError](#cudaError).
pub fn cudaPeekAtLastError() -> cudaError_t;
}
unsafe extern "C" {
/// 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.
///
/// **See also:**
///
/// [`cudaGetErrorString`], [`cudaGetLastError`], [`cudaPeekAtLastError`], [cudaError](#cudaError), [cuGetErrorName](../cuda-driver-api/group__CUDA__ERROR.html#group__CUDA__ERROR_1g2c4ac087113652bb3d1f95bf2513c468).
///
/// # Parameters
///
/// - `error`: Error code to convert to string.
pub fn cudaGetErrorName(error: cudaError_t) -> *const ::core::ffi::c_char;
}
unsafe extern "C" {
/// 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.
///
/// **See also:**
///
/// [`cudaGetErrorName`], [`cudaGetLastError`], [`cudaPeekAtLastError`], [cudaError](#cudaError), [cuGetErrorString](../cuda-driver-api/group__CUDA__ERROR.html#group__CUDA__ERROR_1g72758fcaf05b5c7fac5c25ead9445ada).
///
/// # Parameters
///
/// - `error`: Error code to convert to string.
pub fn cudaGetErrorString(error: cudaError_t) -> *const ::core::ffi::c_char;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDevice`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cudaInitDevice`], [cuDeviceGetCount](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g52b5ce05cb8c5fb6831b2c0ff2887c74).
///
/// # Parameters
///
/// - `count`: Returns the number of devices with compute capability greater or equal to 2.0.
pub fn cudaGetDeviceCount(count: *mut ::core::ffi::c_int) -> cudaError_t;
}
unsafe extern "C" {
/// Returns information about the compute-device.
///
/// Returns in \*prop the properties of device dev.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaChooseDevice`], [`cudaDeviceGetAttribute`], [`cudaInitDevice`], [cuDeviceGetAttribute](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g9c3e1414f0ad901d3278a4d6645fc266), [cuDeviceGetName](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gef75aa30df95446a845f2a7b9fffbb7f).
///
/// # Parameters
///
/// - `prop`: Properties for the specified device.
/// - `device`: Device number to get properties for.
pub fn cudaGetDeviceProperties(
prop: *mut cudaDeviceProp,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns information about the device.
///
/// Returns in \*value the integer value of the attribute attr on device device.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaChooseDevice`], [`cudaGetDeviceProperties`], [`cudaInitDevice`], [cuDeviceGetAttribute](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g9c3e1414f0ad901d3278a4d6645fc266).
///
/// # Parameters
///
/// - `value`: Returned device attribute value.
/// - `attr`: Device attribute to query.
/// - `device`: Device number to query.
pub fn cudaDeviceGetAttribute(
value: *mut ::core::ffi::c_int,
attr: cudaDeviceAttr,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Queries details about atomic operations supported between the device and host.
///
/// Returns in \*capabilities the details about requested atomic \*operations over the the link between dev and the host. The allocated size of \*operations and \*capabilities must be count.
///
/// For each [cudaAtomicOperation](#cudaAtomicOperation) in \*operations, the corresponding result in \*capabilities will be a bitmask indicating which of [cudaAtomicOperationCapability](#cudaAtomicOperationCapability) the link supports natively.
///
/// Returns [cudaErrorInvalidDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a) if dev is not valid.
///
/// Returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if \*capabilities or \*operations is NULL, if count is 0, or if any of \*operations is not valid.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaDeviceGetAttribute`], [`cudaDeviceGetP2PAtomicCapabilities`], cuDeviceGeHostAtomicCapabilities.
///
/// # Parameters
///
/// - `capabilities`: Returned capability details of each requested operation.
/// - `operations`: Requested operations.
/// - `count`: Count of requested operations and size of capabilities.
pub fn cudaDeviceGetHostAtomicCapabilities(
capabilities: *mut ::core::ffi::c_uint,
operations: *const cudaAtomicOperation,
count: ::core::ffi::c_uint,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the default mempool of a device.
///
/// The default mempool of a device contains device memory from that device.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuDeviceGetDefaultMemPool](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gc8bca3c97a78816303b8aa5773b741f2), [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaMemPoolTrimTo`], [`cudaMemPoolGetAttribute`], [`cudaDeviceSetMemPool`], [`cudaMemPoolSetAttribute`], [`cudaMemPoolSetAccess`]
pub fn cudaDeviceGetDefaultMemPool(
memPool: *mut cudaMemPool_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool.") call, [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool.") 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:
///
/// * 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. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuDeviceSetMemPool](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g4f2f276b84d9c2eaefdc76d6274db4a0), [`cudaDeviceGetMemPool`], [`cudaDeviceGetDefaultMemPool`], [`cudaMemPoolCreate`], [`cudaMemPoolDestroy`], [`cudaMallocFromPoolAsync`]
pub fn cudaDeviceSetMemPool(
device: ::core::ffi::c_int,
memPool: cudaMemPool_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g4f2f276b84d9c2eaefdc76d6274db4a0) or [`cudaDeviceSetMemPool`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuDeviceGetMemPool](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gdf186e9559d53a5eb18e572d48c1121b), [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceSetMemPool`]
pub fn cudaDeviceGetMemPool(
memPool: *mut cudaMemPool_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Return NvSciSync attributes that this device can support.
///
/// Returns in nvSciSyncAttrList, the properties of NvSciSync that this CUDA device, dev can support. The returned nvSciSyncAttrList can be used to create an NvSciSync that matches this device's capabilities.
///
/// If NvSciSyncAttrKey_RequiredPerm field in nvSciSyncAttrList is already set this API will return [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// 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](#cudaNvSciSyncAttrSignal), specifies that the applications intends to signal an NvSciSync on this CUDA device.
/// * [cudaNvSciSyncAttrWait](#cudaNvSciSyncAttrWait), 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 [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c). 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](#cudaNvSciSyncAttrSignal) is set in flags.
/// * NvSciSyncAccessPerm_WaitOnly if [cudaNvSciSyncAttrWait](#cudaNvSciSyncAttrWait) is set in flags.
/// * NvSciSyncAccessPerm_WaitSignal if both [cudaNvSciSyncAttrWait](#cudaNvSciSyncAttrWait) and [cudaNvSciSyncAttrSignal](#cudaNvSciSyncAttrSignal) 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](structcudaDeviceProp.html#structcudaDeviceProp_1626c20637498c7be1381db55a6261308) from cudaDeviceGetProperties for this device.
///
/// [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591), [cudaErrorDeviceUninitialized](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00389e95927732f0d5a68151c72296581504), [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c), cudaErrorInvalidHandle, [cudaErrorInvalidDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a), [cudaErrorNotSupported](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d846fd9f2e8ba5e2fb4f1695b7ab6164), [cudaErrorMemoryAllocation](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f210f50ae7f17f655e0504929606add9)
///
/// **See also:**
///
/// [`cudaImportExternalSemaphore`], [`cudaDestroyExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`]
///
/// # Parameters
///
/// - `nvSciSyncAttrList`: Return NvSciSync attributes supported.
/// - `device`: Valid Cuda Device to get NvSciSync attributes for.
/// - `flags`: flags describing NvSciSync usage.
pub fn cudaDeviceGetNvSciSyncAttributes(
nvSciSyncAttrList: *mut ::core::ffi::c_void,
device: ::core::ffi::c_int,
flags: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Queries attributes of the link between two devices.
///
/// Returns in \*value the value of the requested attribute attrib of the link between srcDevice and dstDevice. The supported attributes are:
///
/// * [cudaDevP2PAttrPerformanceRank](types.md#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1bdca8430f659738ac2ebfbfc4e0899d3b): 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).
/// * [cudaDevP2PAttrAccessSupported](types.md#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1b0fa6e51b6472b6ea6ea0cd27fea05a3c): 1 if peer access is enabled.
/// * [cudaDevP2PAttrNativeAtomicSupported](types.md#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1b8513982962e4439fa60f2a24348be587): 1 if all native atomic operations over the link are supported.
/// * [cudaDevP2PAttrCudaArrayAccessSupported](types.md#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1bc11dffbfb7a6d8872dfaeca4b971c11e): 1 if accessing CUDA arrays over the link is supported.
/// * [cudaDevP2PAttrOnlyPartialNativeAtomicSupported](types.md#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1be2a84f673603b20a1a3c41f2ab96621f): 1 if some CUDA-valid atomic operations over the link are supported. Information about specific operations can be retrieved
/// with [`cudaDeviceGetP2PAtomicCapabilities`].
///
/// Returns [cudaErrorInvalidDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a) if srcDevice or dstDevice are not valid or if they represent the same device.
///
/// Returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if attrib is not valid or if value is a null pointer.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceEnablePeerAccess`], [`cudaDeviceDisablePeerAccess`], [`cudaDeviceCanAccessPeer`], [cuDeviceGetP2PAttribute](../cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g4c55c60508f8eba4546b51f2ee545393)[`cudaDeviceGetP2PAtomicCapabilities`]
///
/// # Parameters
///
/// - `value`: Returned value of the requested attribute.
/// - `srcDevice`: The source device of the target link.
/// - `dstDevice`: The destination device of the target link.
pub fn cudaDeviceGetP2PAttribute(
value: *mut ::core::ffi::c_int,
attr: cudaDeviceP2PAttr,
srcDevice: ::core::ffi::c_int,
dstDevice: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Queries details about atomic operations supported between two devices.
///
/// Returns in \*capabilities the details about requested atomic \*operations over the the link between srcDevice and dstDevice. The allocated size of \*operations and \*capabilities must be count.
///
/// For each [cudaAtomicOperation](#cudaAtomicOperation) in \*operations, the corresponding result in \*capabilities will be a bitmask indicating which of [cudaAtomicOperationCapability](#cudaAtomicOperationCapability) the link supports natively.
///
/// Returns [cudaErrorInvalidDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a) if srcDevice or dstDevice are not valid or if they represent the same device.
///
/// Returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if \*capabilities or \*operations is NULL, if count is 0, or if any of \*operations is not valid.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaDeviceGetP2PAttribute`], [cuDeviceGetP2PAttribute](../cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g4c55c60508f8eba4546b51f2ee545393), [cuDeviceGetP2PAtomicCapabilities](../cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1gfd989876c8fd3291b520c0b561d5282d).
///
/// # Parameters
///
/// - `capabilities`: Returned capability details of each requested operation.
/// - `operations`: Requested operations.
/// - `count`: Count of requested operations and size of capabilities.
/// - `srcDevice`: The source device of the target link.
/// - `dstDevice`: The destination device of the target link.
pub fn cudaDeviceGetP2PAtomicCapabilities(
capabilities: *mut ::core::ffi::c_uint,
operations: *const cudaAtomicOperation,
count: ::core::ffi::c_uint,
srcDevice: ::core::ffi::c_int,
dstDevice: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Select compute-device which best matches criteria.
///
/// Returns in \*device the device which has properties that best match \*prop.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaInitDevice`]
///
/// # Parameters
///
/// - `device`: Device with best match.
/// - `prop`: Desired device properties.
pub fn cudaChooseDevice(
device: *mut ::core::ffi::c_int,
prop: *const cudaDeviceProp,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaInitDeviceFlagsAreValid) 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 [cudaComputeModeExclusiveProcess](types.md#group__CUDART__TYPES_1gg7eb25f5413a962faad0956d92bae10d02cd032834fecbec513ea1018145b111d) and is occupied by another process or if the device is in [cudaComputeModeProhibited](types.md#group__CUDART__TYPES_1gg7eb25f5413a962faad0956d92bae10d0fc71b88518e4501544d6e65b5f3671b6).
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cudaSetDevice`][cuCtxSetCurrent](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1gbe562ee6258b4fcc272ca6478ca2a2f7).
///
/// # Parameters
///
/// - `device`: Device on which the runtime will initialize itself.
/// - `deviceFlags`: Parameters for device operation.
/// - `flags`: Flags for controlling the device initialization.
pub fn cudaInitDevice(
device: ::core::ffi::c_int,
deviceFlags: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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()](memory-management.md#group__CUDART__MEMORY_1gab84100ae1fa1b12eaca660207ef585b "Allocates page-locked memory on the host.") 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()](execution-control.md#group__CUDART__EXECUTION_1g5064cdf5d8e6741ace56fd8be951783c "Launches a device function.") 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 [cudaComputeModeExclusiveProcess](types.md#group__CUDART__TYPES_1gg7eb25f5413a962faad0956d92bae10d02cd032834fecbec513ea1018145b111d) and is occupied by another process or if the device is in [cudaComputeModeProhibited](types.md#group__CUDART__TYPES_1gg7eb25f5413a962faad0956d92bae10d0fc71b88518e4501544d6e65b5f3671b6).
///
/// It is not required to call [`cudaInitDevice`] before using this function.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cudaInitDevice`], [cuCtxSetCurrent](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1gbe562ee6258b4fcc272ca6478ca2a2f7).
///
/// # Parameters
///
/// - `device`: Device on which the active host thread should execute the device code.
pub fn cudaSetDevice(device: ::core::ffi::c_int) -> cudaError_t;
}
unsafe extern "C" {
/// Returns which device is currently being used.
///
/// Returns in \*device the current device for the calling host thread.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDeviceCount`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [cuCtxGetCurrent](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g8f13165846b73750693640fb3e8380d0).
///
/// # Parameters
///
/// - `device`: Returns the device on which the active host thread executes the device code.
pub fn cudaGetDevice(device: *mut ::core::ffi::c_int) -> cudaError_t;
}
unsafe extern "C" {
/// Set a list of devices that can be used for CUDA.
///
/// Sets a list of devices for CUDA execution in priority order using device_arr. The parameter len specifies the number of elements in the list. CUDA will try devices from the list sequentially until it finds one that works.
/// If this function is not called, or if it is called with a len of 0, then CUDA will go back to its default behavior of trying devices sequentially from a default list containing all of
/// the available CUDA devices in the system. If a specified device ID in the list does not exist, this function will return [cudaErrorInvalidDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a). If len is not 0 and device_arr is NULL or if len exceeds the number of devices in the system, then [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDeviceCount`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaSetDeviceFlags`], [`cudaChooseDevice`]
///
/// # Parameters
///
/// - `device_arr`: List of devices to try.
/// - `len`: Number of devices in specified list.
pub fn cudaSetValidDevices(
device_arr: *mut ::core::ffi::c_int,
len: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaDeviceScheduleAuto): 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](#cudaDeviceScheduleAuto) uses a heuristic based on the power profile of the platform and may choose [cudaDeviceScheduleBlockingSync](#cudaDeviceScheduleBlockingSync) for low-powered devices.
/// * [cudaDeviceScheduleSpin](#cudaDeviceScheduleSpin): 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](#cudaDeviceScheduleYield): 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](#cudaDeviceScheduleBlockingSync): Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the device to finish work.
/// * [cudaDeviceBlockingSync](#cudaDeviceBlockingSync): Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the device to finish work.
///
/// [Deprecated:](deprecated.html#deprecated) This flag was deprecated as of CUDA 4.0 and replaced with [cudaDeviceScheduleBlockingSync](#cudaDeviceScheduleBlockingSync).
/// * [cudaDeviceMapHost](#cudaDeviceMapHost): 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](#cudaDeviceLmemResizeToMax): 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:](deprecated.html#deprecated) This flag is deprecated and the behavior enabled by this flag is now the default and cannot be disabled.
/// * [cudaDeviceSyncMemops](#cudaDeviceSyncMemops): Ensures that synchronous memory operations initiated on this context will always synchronize. See further documentation
/// in the section titled "API Synchronization behavior" to learn more about cases when synchronous memory operations can exhibit
/// asynchronous behavior.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDeviceFlags`], [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaSetDevice`], [`cudaSetValidDevices`], [`cudaInitDevice`], [`cudaChooseDevice`], [cuDevicePrimaryCtxSetFlags](../cuda-driver-api/group__CUDA__PRIMARY__CTX.html#group__CUDA__PRIMARY__CTX_1gd779a84f17acdad0d9143d9fe719cfdf).
///
/// # Parameters
///
/// - `flags`: Parameters for device operation.
pub fn cudaSetDeviceFlags(flags: ::core::ffi::c_uint) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaDeviceMapHost) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaSetDevice`], [`cudaSetDeviceFlags`], [`cudaInitDevice`], [cuCtxGetFlags](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1gf81eef983c1e3b2ef4f166d7a930c86d), [cuDevicePrimaryCtxGetState](../cuda-driver-api/group__CUDA__PRIMARY__CTX.html#group__CUDA__PRIMARY__CTX_1g65f3e018721b6d90aa05cfb56250f469).
///
/// # Parameters
///
/// - `flags`: Pointer to store the device flags.
pub fn cudaGetDeviceFlags(flags: *mut ::core::ffi::c_uint) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreateWithPriority`], [`cudaStreamCreateWithFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetFlags`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaSetDevice`], [`cudaStreamDestroy`], [cuStreamCreate](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1ga581f0c5833e21ded8b5a56594e243f4).
///
/// # Parameters
///
/// - `pStream`: Pointer to new stream identifier.
pub fn cudaStreamCreate(pStream: *mut cudaStream_t) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaStreamDefault): Default stream creation flag.
/// * [cudaStreamNonBlocking](#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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamCreateWithPriority`], [`cudaStreamGetFlags`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaSetDevice`], [`cudaStreamDestroy`], [cuStreamCreate](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1ga581f0c5833e21ded8b5a56594e243f4).
///
/// # Parameters
///
/// - `pStream`: Pointer to new stream identifier.
/// - `flags`: Parameters for stream creation.
pub fn cudaStreamCreateWithFlags(
pStream: *mut cudaStream_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Stream priorities are supported only on GPUs with compute capability 3.5 or higher.
/// * In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream
/// priorities have no effect on host-to-device and device-to-host memory operations.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaDeviceGetStreamPriorityRange`], [`cudaStreamGetPriority`], [`cudaStreamQuery`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaStreamSynchronize`], [`cudaSetDevice`], [`cudaStreamDestroy`], [cuStreamCreateWithPriority](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g95c1a8c7c3dacb13091692dd9c7f7471).
///
/// # Parameters
///
/// - `pStream`: Pointer to new stream identifier.
/// - `flags`: Flags for stream creation. See [`cudaStreamCreateWithFlags`] for a list of valid flags that can be passed.
/// - `priority`: Priority of the stream. Lower numbers represent higher priorities. See [`cudaDeviceGetStreamPriorityRange`] for more information about the meaningful stream priorities that can be passed.
pub fn cudaStreamCreateWithPriority(
pStream: *mut cudaStream_t,
flags: ::core::ffi::c_uint,
priority: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreateWithPriority`], [`cudaDeviceGetStreamPriorityRange`], [`cudaStreamGetFlags`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [cuStreamGetPriority](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g5bd5cb26915a2ecf1921807339488484).
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `priority`: Pointer to a signed integer in which the stream's priority is returned.
pub fn cudaStreamGetPriority(
hStream: cudaStream_t,
priority: *mut ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreateWithPriority`], [`cudaStreamCreateWithFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetDevice`], [cuStreamGetFlags](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g4d39786855a6bed01215c1907fbbfbb7).
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `flags`: Pointer to an unsigned integer in which the stream's flags are returned.
pub fn cudaStreamGetFlags(
hStream: cudaStream_t,
flags: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1ga581f0c5833e21ded8b5a56594e243f4) or [cuStreamCreateWithPriority](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g95c1a8c7c3dacb13091692dd9c7f7471). Passing an invalid handle will result in undefined behavior.
/// * any of the special streams such as the NULL stream, [cudaStreamLegacy](#cudaStreamLegacy) and [cudaStreamPerThread](#cudaStreamPerThread) respectively. The driver API equivalents of these are also accepted which are NULL, [CU_STREAM_LEGACY](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1ga53e8210837f039dd6434a3a4c3324aa) and [CU_STREAM_PER_THREAD](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1g02e40b82600f62c42ed29abb150f857c).
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreateWithPriority`], [`cudaStreamCreateWithFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetFlags`], [cuStreamGetId](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g5dafd2b6f48caeb13d5110a7f21e60e3).
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `streamId`: Pointer to an unsigned long long in which the stream Id is returned.
pub fn cudaStreamGetId(
hStream: cudaStream_t,
streamId: *mut ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
unsafe extern "C" {
/// Query the device of a stream.
///
/// Returns in \*device the device of the stream.
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaSetDevice`], [`cudaGetDevice`], [`cudaStreamCreate`], [`cudaStreamGetPriority`], [`cudaStreamGetFlags`], [cuStreamGetId](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g5dafd2b6f48caeb13d5110a7f21e60e3).
///
/// # Parameters
///
/// - `hStream`: Handle to the stream to be queried.
/// - `device`: Returns the device to which the stream belongs.
pub fn cudaStreamGetDevice(
hStream: cudaStream_t,
device: *mut ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Resets all persisting lines in cache to normal status.
///
/// Resets all persisting lines in cache to normal status. Takes effect on function return.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaAccessPolicyWindow](#cudaAccessPolicyWindow).
pub fn cudaCtxResetPersistingL2Cache() -> cudaError_t;
}
unsafe extern "C" {
/// Copies attributes from source stream to destination stream.
///
/// Copies attributes from source stream src to destination stream dst. Both streams must have the same context.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaAccessPolicyWindow](#cudaAccessPolicyWindow).
///
/// # Parameters
///
/// - `dst`: Destination stream.
/// - `src`: Source stream For attributes see cudaStreamAttrID.
pub fn cudaStreamCopyAttributes(dst: cudaStream_t, src: cudaStream_t) -> cudaError_t;
}
unsafe extern "C" {
/// Queries stream attribute.
///
/// Queries attribute attr from hStream and stores it in corresponding member of value_out.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaAccessPolicyWindow](#cudaAccessPolicyWindow).
pub fn cudaStreamGetAttribute(
hStream: cudaStream_t,
attr: cudaLaunchAttributeID,
value_out: *mut cudaLaunchAttributeValue,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets stream attribute.
///
/// Sets attribute attr on hStream from corresponding attribute of value. The updated attribute will be applied to subsequent work submitted to the stream. It will not affect previously submitted
/// work.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaAccessPolicyWindow](#cudaAccessPolicyWindow).
pub fn cudaStreamSetAttribute(
hStream: cudaStream_t,
attr: cudaLaunchAttributeID,
value: *const cudaLaunchAttributeValue,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamWaitEvent`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [cuStreamDestroy](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g244c8833de4596bcd31a06cdf21ee758).
///
/// # Parameters
///
/// - `stream`: Stream identifier.
pub fn cudaStreamDestroy(stream: cudaStream_t) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaEventWaitDefault): Default event creation flag.
/// * [cudaEventWaitExternal](#cudaEventWaitExternal): Event is captured in the graph as an external event node when performing stream capture.
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [cuStreamWaitEvent](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g6a898b652dfc6aa1d5c8d97062618b2f).
///
/// # Parameters
///
/// - `stream`: Stream to wait.
/// - `event`: Event to wait on.
/// - `flags`: Parameters for the operation(See above).
pub fn cudaStreamWaitEvent(
stream: cudaStream_t,
event: cudaEvent_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
/// Type of stream callback functions.
pub type cudaStreamCallback_t = ::core::option::Option<
unsafe extern "C" fn(
stream: cudaStream_t,
status: cudaError_t,
userData: *mut ::core::ffi::c_void,
),
>;
unsafe extern "C" {
/// Add a callback to a compute stream.
///
/// Note:
///
/// This function is slated for eventual deprecation and removal. If you do not require the callback to execute in case of a device
/// error, consider using [`cudaLaunchHostFunc`]. Additionally, this function is not supported with [`cudaStreamBeginCapture`] and [`cudaStreamEndCapture`], unlike [`cudaLaunchHostFunc`].
///
/// Adds a callback to be called on the host after all currently enqueued items in the stream have completed. For each cudaStreamAddCallback
/// call, a callback will be executed exactly once. The callback will block later work in the stream until it is finished.
///
/// The callback may be passed [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) or an error code. In the event of a device error, all subsequently executed callbacks will receive an appropriate [cudaError_t](#cudaError_t).
///
/// Callbacks must not make any CUDA API calls. Attempting to use CUDA APIs may result in [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3). 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 uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamDestroy`], [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system."), [cudaStreamAttachMemAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g496353d630c29c44a2e33f531a3944d1 "Attach memory to a stream asynchronously."), [`cudaLaunchHostFunc`], [cuStreamAddCallback](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g613d97a277d7640f4cb1c03bd51c2483).
///
/// # Parameters
///
/// - `stream`: Stream to add callback to.
/// - `callback`: The function to call once preceding stream operations are complete.
/// - `userData`: User specified data to be passed to the callback function.
/// - `flags`: Reserved for future use, must be 0.
pub fn cudaStreamAddCallback(
stream: cudaStream_t,
callback: cudaStreamCallback_t,
userData: *mut ::core::ffi::c_void,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Waits for stream tasks to complete.
///
/// Blocks until stream has completed all operations. If the [cudaDeviceScheduleBlockingSync](#cudaDeviceScheduleBlockingSync) 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](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [cuStreamSynchronize](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g15e49dd91ec15991eb7c0a741beb7dad).
///
/// # Parameters
///
/// - `stream`: Stream identifier.
pub fn cudaStreamSynchronize(stream: cudaStream_t) -> cudaError_t;
}
unsafe extern "C" {
/// Queries an asynchronous stream for completion status.
///
/// Returns [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) if all operations in stream have completed, or [cudaErrorNotReady](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038285d0c852ab65b8925505e1065563f6d) if not.
///
/// For the purposes of Unified Memory, a return value of [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) is equivalent to having called [`cudaStreamSynchronize`].
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamWaitEvent`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [cuStreamQuery](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g1b0d24bbe97fa68e4bc511fb6adfeb0b).
///
/// # Parameters
///
/// - `stream`: Stream identifier.
pub fn cudaStreamQuery(stream: cudaStream_t) -> cudaError_t;
}
unsafe extern "C" {
/// # 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](#cudaMemAttachGlobal), [cudaMemAttachHost](#cudaMemAttachHost) or [cudaMemAttachSingle](#cudaMemAttachSingle) (defaults to [cudaMemAttachSingle](#cudaMemAttachSingle)).
pub fn cudaStreamAttachMemAsync(
stream: cudaStream_t,
devPtr: *mut ::core::ffi::c_void,
length: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaStreamLegacy). 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:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamIsCapturing`], [`cudaStreamEndCapture`], [`cudaThreadExchangeStreamCaptureMode`]
///
/// # Parameters
///
/// - `stream`: Stream in which to initiate capture.
/// - `mode`: Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see
/// [`cudaThreadExchangeStreamCaptureMode`].
pub fn cudaStreamBeginCapture(
stream: cudaStream_t,
mode: cudaStreamCaptureMode,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaStreamLegacy). 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:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamIsCapturing`], [`cudaStreamEndCapture`], [`cudaThreadExchangeStreamCaptureMode`]
///
/// # Parameters
///
/// - `stream`: Stream in which to initiate capture.
/// - `graph`: Graph to capture into.
/// - `dependencies`: Dependencies of the first node captured in the stream. Can be NULL if numDependencies is 0.
/// - `dependencyData`: Optional array of data associated with each dependency.
/// - `numDependencies`: Number of dependencies.
/// - `mode`: Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see
/// [`cudaThreadExchangeStreamCaptureMode`].
pub fn cudaStreamBeginCaptureToGraph(
stream: cudaStream_t,
graph: cudaGraph_t,
dependencies: *const cudaGraphNode_t,
dependencyData: *const cudaGraphEdgeData,
numDependencies: size_t,
mode: cudaStreamCaptureMode,
) -> cudaError_t;
}
unsafe extern "C" {
/// Swaps the stream capture interaction mode for a thread.
///
/// Sets the calling thread's stream capture interaction mode to the value contained in \*mode, and overwrites \*mode with the previous mode for the thread. To facilitate deterministic behavior across function or module boundaries, callers
/// are encouraged to use this API in a push-pop fashion:
///
/// ```text
/// 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 cudaStreamCaptureModeRelaxed at cuStreamBeginCapture, or if any other thread has a concurrent capture sequence initiated with cudaStreamCaptureModeGlobal, this thread is prohibited from potentially unsafe API calls.
/// * cudaStreamCaptureModeThreadLocal: If the local thread has an ongoing capture sequence not initiated with cudaStreamCaptureModeRelaxed, 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:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaStreamBeginCapture`]
///
/// # Parameters
///
/// - `mode`: Pointer to mode value to swap with the current mode.
pub fn cudaThreadExchangeStreamCaptureMode(
mode: *mut cudaStreamCaptureMode,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamBeginCapture`], [`cudaStreamIsCapturing`], [`cudaGraphDestroy`]
///
/// # Parameters
///
/// - `stream`: Stream to query.
/// - `pGraph`: The captured graph.
pub fn cudaStreamEndCapture(
stream: cudaStream_t,
pGraph: *mut cudaGraph_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * [cudaStreamCaptureStatusNone](types.md#group__CUDART__TYPES_1gg0ec4aacc66fe76c145252d12b189e233dbbe6269245e62cd99e6c95206008e50): The stream is not capturing.
/// * [cudaStreamCaptureStatusActive](types.md#group__CUDART__TYPES_1gg0ec4aacc66fe76c145252d12b189e233b165b0917377d0d7283ca5ac8013568b): The stream is capturing.
/// * [cudaStreamCaptureStatusInvalidated](types.md#group__CUDART__TYPES_1gg0ec4aacc66fe76c145252d12b189e2334c61e87e6268a6f9b6c928c574c12c76): 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](#cudaStreamLegacy) (the "null stream") while a blocking stream on the same device is capturing, it will return [cudaErrorStreamCaptureImplicit](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038cf775033deb76dbde57b8df7bd9244e7) 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:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamBeginCapture`], [`cudaStreamEndCapture`]
///
/// # Parameters
///
/// - `stream`: Stream to query.
/// - `pCaptureStatus`: Returns the stream's capture status.
pub fn cudaStreamIsCapturing(
stream: cudaStream_t,
pCaptureStatus: *mut cudaStreamCaptureStatus,
) -> cudaError_t;
}
unsafe extern "C" {
/// Query a stream's capture state.
///
/// Query stream state related to stream capture.
///
/// If called on [cudaStreamLegacy](#cudaStreamLegacy) (the "null stream") while a stream not created with [cudaStreamNonBlocking](#cudaStreamNonBlocking) is capturing, returns [cudaErrorStreamCaptureImplicit](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038cf775033deb76dbde57b8df7bd9244e7).
///
/// 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 [cudaStreamCaptureStatusActive](types.md#group__CUDART__TYPES_1gg0ec4aacc66fe76c145252d12b189e233b165b0917377d0d7283ca5ac8013568b)
///
/// If edgeData_out is non-NULL then dependencies_out must be as well. If dependencies_out is non-NULL and edgeData_out is NULL, but there is non-zero edge data for one or more of the current stream dependencies, the call will return [cudaErrorLossyQuery](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d484d9d8e8f269cf93d4c111b646f908).
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaStreamBeginCapture`], [`cudaStreamIsCapturing`], [`cudaStreamUpdateCaptureDependencies`]
///
/// # Parameters
///
/// - `stream`: The stream to query.
/// - `captureStatus_out`: Location to return the capture status of the stream; required.
/// - `id_out`: Optional location to return an id for the capture sequence, which is unique over the lifetime of the process.
/// - `graph_out`: Optional location to return the graph being captured into. All operations other than destroy and node removal are permitted
/// on the graph while the capture sequence is in progress. This API does not transfer ownership of the graph, which is transferred
/// or destroyed at [`cudaStreamEndCapture`]. Note that the graph handle may be invalidated before end of capture for certain errors. Nodes that are or become unreachable
/// from the original stream at [`cudaStreamEndCapture`] due to direct actions on the graph do not trigger [cudaErrorStreamCaptureUnjoined](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce9e4b4b58c1abf9faa1ce8b1079076d).
/// - `dependencies_out`: Optional location to store a pointer to an array of nodes. The next node to be captured in the stream will depend on this
/// set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call
/// which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they
/// or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream)
/// without copying.
/// - `edgeData_out`: Optional location to store a pointer to an array of graph edge data. This array parallels dependencies_out; the next node to be added has an edge to dependencies_out[i] with annotation edgeData_out[i] for each i. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated.
/// - `numDependencies_out`: Optional location to store the size of the array returned in dependencies_out.
pub fn cudaStreamGetCaptureInfo(
stream: cudaStream_t,
captureStatus_out: *mut cudaStreamCaptureStatus,
id_out: *mut ::core::ffi::c_ulonglong,
graph_out: *mut cudaGraph_t,
dependencies_out: *mut *const cudaGraphNode_t,
edgeData_out: *mut *const cudaGraphEdgeData,
numDependencies_out: *mut size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Update the set of dependencies in a capturing stream.
///
/// Modifies the dependency set of a capturing stream. The dependency set is the set of nodes that the next captured node in the
/// stream will depend on.
///
/// Valid flags are [cudaStreamAddCaptureDependencies](types.md#group__CUDART__TYPES_1gg36421316e18c4a2f66905cf41bf8ce6f2d9c20d80bfa97109439be472c67d9c4) and [cudaStreamSetCaptureDependencies](types.md#group__CUDART__TYPES_1gg36421316e18c4a2f66905cf41bf8ce6fda9c5ad0afcd24d659a48769b931563a). 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 [cudaStreamAddCaptureDependencies](types.md#group__CUDART__TYPES_1gg36421316e18c4a2f66905cf41bf8ce6f2d9c20d80bfa97109439be472c67d9c4).
///
/// Nodes that are removed from the dependency set via this API do not result in [cudaErrorStreamCaptureUnjoined](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce9e4b4b58c1abf9faa1ce8b1079076d) if they are unreachable from the stream at [`cudaStreamEndCapture`].
///
/// Returns [cudaErrorIllegalState](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00380604022302a2ed15d31bc33546b2e963) if the stream is not capturing.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaStreamBeginCapture`], [`cudaStreamGetCaptureInfo`],.
///
/// # Parameters
///
/// - `stream`: The stream to update.
/// - `dependencies`: The set of dependencies to add.
/// - `dependencyData`: Optional array of data associated with each dependency.
/// - `numDependencies`: The size of the dependencies array.
/// - `flags`: See above.
pub fn cudaStreamUpdateCaptureDependencies(
stream: cudaStream_t,
dependencies: *mut cudaGraphNode_t,
dependencyData: *const cudaGraphEdgeData,
numDependencies: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `event`: Newly created event.
pub fn cudaEventCreate(event: *mut cudaEvent_t) -> cudaError_t;
}
unsafe extern "C" {
/// Creates an event object with the specified flags.
///
/// Creates an event object for the current device with the specified flags. Valid flags include:
///
/// * [cudaEventDefault](#cudaEventDefault): Default event creation flag.
/// * [cudaEventBlockingSync](#cudaEventBlockingSync): 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](#cudaEventDisableTiming): Specifies that the created event does not need to record timing data. Events created with this flag specified and the [cudaEventBlockingSync](#cudaEventBlockingSync) flag not specified will provide the best performance when used with [`cudaStreamWaitEvent`] and [`cudaEventQuery`].
/// * [cudaEventInterprocess](#cudaEventInterprocess): Specifies that the created event may be used as an interprocess event by [`cudaIpcGetEventHandle`]. [cudaEventInterprocess](#cudaEventInterprocess) must be specified along with [cudaEventDisableTiming](#cudaEventDisableTiming).
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// cudaEventCreate ( C API), [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [cuEventCreate](../cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g450687e75f3ff992fe01662a43d9d3db).
///
/// # Parameters
///
/// - `event`: Newly created event.
/// - `flags`: Flags for new event.
pub fn cudaEventCreateWithFlags(
event: *mut cudaEvent_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Records an event.
///
/// Captures in event the contents of stream at the time of this call. event and stream must be on the same CUDA context. Calls such as [`cudaEventQuery`] or [`cudaStreamWaitEvent`] will then examine or wait for completion of the work that was captured. Uses of stream after this call do not modify event. See note on default stream behavior for what is captured in the default case.
///
/// [`cudaEventRecord`] can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as [`cudaStreamWaitEvent`] use the most recently captured state at the time of the API call, and are not affected by later calls to [`cudaEventRecord`]. Before the first call to [`cudaEventRecord`], an event represents an empty set of work, so for example [`cudaEventQuery`] would return [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591).
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Returns [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
///
/// **See also:**
///
/// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [`cudaEventRecordWithFlags`], [cuEventRecord](../cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g95424d3be52c4eb95d83861b70fb89d1).
///
/// # Parameters
///
/// - `event`: Event to record.
/// - `stream`: Stream in which to record event.
pub fn cudaEventRecord(event: cudaEvent_t, stream: cudaStream_t) -> cudaError_t;
}
unsafe extern "C" {
/// Records an event.
///
/// Captures in event the contents of stream at the time of this call. event and stream must be on the same CUDA context. Calls such as [`cudaEventQuery`] or [`cudaStreamWaitEvent`] will then examine or wait for completion of the work that was captured. Uses of stream after this call do not modify event. See note on default stream behavior for what is captured in the default case.
///
/// [`cudaEventRecordWithFlags`] can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as [`cudaStreamWaitEvent`] use the most recently captured state at the time of the API call, and are not affected by later calls to [`cudaEventRecordWithFlags`]. Before the first call to [`cudaEventRecordWithFlags`], an event represents an empty set of work, so for example [`cudaEventQuery`] would return [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591).
///
/// flags include:
///
/// * [cudaEventRecordDefault](#cudaEventRecordDefault): Default event creation flag.
/// * [cudaEventRecordExternal](#cudaEventRecordExternal): Event is captured in the graph as an external event node when performing stream capture.
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Returns [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
///
/// **See also:**
///
/// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [`cudaEventRecord`], [cuEventRecord](../cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g95424d3be52c4eb95d83861b70fb89d1),.
///
/// # Parameters
///
/// - `event`: Event to record.
/// - `stream`: Stream in which to record event.
/// - `flags`: Parameters for the operation(See above).
pub fn cudaEventRecordWithFlags(
event: cudaEvent_t,
stream: cudaStream_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Queries an event's status.
///
/// Queries the status of all work currently captured by event. See [`cudaEventRecord`] for details on what is captured by an event.
///
/// Returns [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) if all captured work has been completed, or [cudaErrorNotReady](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038285d0c852ab65b8925505e1065563f6d) if any captured work is incomplete.
///
/// For the purposes of Unified Memory, a return value of [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) is equivalent to having called [`cudaEventSynchronize`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Returns [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
///
/// **See also:**
///
/// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventRecord`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [cuEventQuery](../cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g6f0704d755066b0ee705749ae911deef).
///
/// # Parameters
///
/// - `event`: Event to query.
pub fn cudaEventQuery(event: cudaEvent_t) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaEventBlockingSync) flag will cause the calling CPU thread to block until the event has been completed by the device. If the [cudaEventBlockingSync](#cudaEventBlockingSync) flag has not been set, then the CPU thread will busy-wait until the event has been completed by the device.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Returns [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
///
/// **See also:**
///
/// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventRecord`], [`cudaEventQuery`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [cuEventSynchronize](../cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g9e520d34e51af7f5375610bca4add99c).
///
/// # Parameters
///
/// - `event`: Event to wait for.
pub fn cudaEventSynchronize(event: cudaEvent_t) -> cudaError_t;
}
unsafe extern "C" {
/// Destroys an event object.
///
/// Destroys the event specified by event.
///
/// An event may be destroyed before it is complete (i.e., while [`cudaEventQuery`] would return [cudaErrorNotReady](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038285d0c852ab65b8925505e1065563f6d)). In this case, the call does not block on completion of the event, and any associated resources will automatically be released
/// asynchronously at completion.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
/// * Returns [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
///
/// **See also:**
///
/// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventRecord`], [`cudaEventElapsedTime`], [cuEventDestroy](../cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g593ec73a8ec5a5fc031311d3e4dca1ef).
///
/// # Parameters
///
/// - `event`: Event to destroy.
pub fn cudaEventDestroy(event: cudaEvent_t) -> cudaError_t;
}
unsafe extern "C" {
/// Computes the elapsed time between events.
///
/// Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). Note this API
/// is not guaranteed to return the latest errors for pending work. As such this API is intended to serve as a elapsed time calculation
/// only and polling for completion on the events to be compared should be done with [`cudaEventQuery`] instead.
///
/// If either event was last recorded in a non-NULL stream, the resulting time may be greater than expected (even if both used
/// the same stream handle). This happens because the [`cudaEventRecord`] operation takes place asynchronously and there is no guarantee that the measured latency is actually just between the two
/// events. Any number of other different stream operations could execute in between the two measured events, thus altering the
/// timing in a significant way.
///
/// If [`cudaEventRecord`] has not been called on either event, then [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) is returned. If [`cudaEventRecord`] has been called on both events but one or both of them has not yet been completed (that is, [`cudaEventQuery`] would return [cudaErrorNotReady](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038285d0c852ab65b8925505e1065563f6d) on at least one of the events), [cudaErrorNotReady](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038285d0c852ab65b8925505e1065563f6d) is returned. If either event was created with the [cudaEventDisableTiming](#cudaEventDisableTiming) flag, then this function will return [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273).
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Returns [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
///
/// **See also:**
///
/// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventRecord`], [cuEventElapsedTime](../cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1gdfb1178807353bbcaa9e245da497cf97).
///
/// # Parameters
///
/// - `ms`: Time between start and end in ms.
/// - `start`: Starting event.
/// - `end`: Ending event.
pub fn cudaEventElapsedTime(
ms: *mut f32,
start: cudaEvent_t,
end: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Imports an external memory object.
///
/// Imports an externally allocated memory object and returns a handle to that in extMem_out.
///
/// The properties of the handle being imported must be described in memHandleDesc. The [cudaExternalMemoryHandleDesc](#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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) specifies the type of handle being imported. [cudaExternalMemoryHandleType](#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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [cudaExternalMemoryHandleTypeOpaqueFd](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749ed7c20291dcaa0968289cbdc1d1ef9884), 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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [cudaExternalMemoryHandleTypeOpaqueWin32](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749eec5cd1d822bad3573f1129495e72c204), 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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [cudaExternalMemoryHandleTypeOpaqueWin32Kmt](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e66df5304ef7a62824165c3d6a2f43ef9), 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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [cudaExternalMemoryHandleTypeD3D12Heap](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e7a10ea0c93364ebe656086758b6b8a7f), 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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [cudaExternalMemoryHandleTypeD3D12Resource](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e9acb977c3b7bceb6a653e6a718e0f4a0), 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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [cudaExternalMemoryHandleTypeD3D11Resource](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e33f59a34502f2dd974a9672688313133),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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [cudaExternalMemoryHandleTypeD3D11ResourceKmt](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e351d57fdb273343579635c8d86eb5add), 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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [cudaExternalMemoryHandleTypeNvSciBuf](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e6f8cf38ae8bb776722f29fe5f076bdcf), 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](#cudaExternalSemaphoreWaitSkipNvSciBufMemSync) and [cudaExternalSemaphoreSignalSkipNvSciBufMemSync](#cudaExternalSemaphoreSignalSkipNvSciBufMemSync) for memory synchronization.
///
/// The size of the memory object must be specified in [cudaExternalMemoryHandleDesc::size](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_1362086a22da90ac8fba1ca294e65548e).
///
/// Specifying the flag [cudaExternalMemoryDedicated](#cudaExternalMemoryDedicated) in [cudaExternalMemoryHandleDesc::flags](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_174412d3d2777ebc856aea0b9158aaafa) 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](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is one of the following: [cudaExternalMemoryHandleTypeD3D12Resource](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e9acb977c3b7bceb6a653e6a718e0f4a0)[cudaExternalMemoryHandleTypeD3D11Resource](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e33f59a34502f2dd974a9672688313133)[cudaExternalMemoryHandleTypeD3D11ResourceKmt](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e351d57fdb273343579635c8d86eb5add)
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * If the Vulkan memory imported into CUDA is mapped on the CPU then the application must use vkInvalidateMappedMemoryRanges/vkFlushMappedMemoryRanges
/// as well as appropriate Vulkan pipeline barriers to maintain coherence between CPU and GPU. For more information on these APIs,
/// please refer to "Synchronization and Cache Control" chapter from Vulkan specification.
///
/// **See also:**
///
/// [`cudaDestroyExternalMemory`], [`cudaExternalMemoryGetMappedBuffer`], [`cudaExternalMemoryGetMappedMipmappedArray`]
///
/// # Parameters
///
/// - `extMem_out`: Returned handle to an external memory object.
/// - `memHandleDesc`: Memory import handle descriptor.
pub fn cudaImportExternalMemory(
extMem_out: *mut cudaExternalMemory_t,
memHandleDesc: *const cudaExternalMemoryHandleDesc,
) -> cudaError_t;
}
unsafe extern "C" {
/// Maps a buffer onto an imported memory object.
///
/// Maps a buffer onto an imported memory object and returns a device pointer in devPtr.
///
/// The properties of the buffer being mapped must be described in bufferDesc. The [cudaExternalMemoryBufferDesc](#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](structcudaExternalMemoryBufferDesc.html#structcudaExternalMemoryBufferDesc_1034839893ecb4e103f82498888157ba6) is the offset in the memory object where the buffer's base address is. [cudaExternalMemoryBufferDesc::size](structcudaExternalMemoryBufferDesc.html#structcudaExternalMemoryBufferDesc_156bdddff67c72329350ed4fa4f2cd746) is the size of the buffer. [cudaExternalMemoryBufferDesc::flags](structcudaExternalMemoryBufferDesc.html#structcudaExternalMemoryBufferDesc_10a7888cacfea49ab9b30ae7e9ab47d32) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaImportExternalMemory`], [`cudaDestroyExternalMemory`], [`cudaExternalMemoryGetMappedMipmappedArray`]
///
/// # Parameters
///
/// - `devPtr`: Returned device pointer to buffer.
/// - `extMem`: Handle to external memory object.
/// - `bufferDesc`: Buffer descriptor.
pub fn cudaExternalMemoryGetMappedBuffer(
devPtr: *mut *mut ::core::ffi::c_void,
extMem: cudaExternalMemory_t,
bufferDesc: *const cudaExternalMemoryBufferDesc,
) -> cudaError_t;
}
unsafe extern "C" {
/// Maps a CUDA mipmapped array onto an external memory object.
///
/// Maps a CUDA mipmapped array onto an external object and returns a handle to it in mipmap.
///
/// The properties of the CUDA mipmapped array being mapped must be described in mipmapDesc. The structure [cudaExternalMemoryMipmappedArrayDesc](#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](structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_12f9441c3c6e3100f1517ccaf668ffd83) is the offset in the memory object where the base level of the mipmap chain is. [cudaExternalMemoryMipmappedArrayDesc::formatDesc](structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_142333e3049cc4a40213b086be45927e1) describes the format of the data. [cudaExternalMemoryMipmappedArrayDesc::extent](structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_1cba41d5152a8458ac72a24e65ee0f3ac) specifies the dimensions of the base level of the mipmap chain. [cudaExternalMemoryMipmappedArrayDesc::flags](structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_1de6d5579b7f13034ea82e06012c8758f) 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](#cudaArrayColorAttachment) must be specified in [cudaExternalMemoryMipmappedArrayDesc::flags](structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_1de6d5579b7f13034ea82e06012c8758f). [cudaExternalMemoryMipmappedArrayDesc::numLevels](structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_14a939b3d6c1fca916dd78679049f36eb) specifies the total number of levels in the mipmap chain.
///
/// The returned CUDA mipmapped array must be freed using [`cudaFreeMipmappedArray`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaImportExternalMemory`], [`cudaDestroyExternalMemory`], [`cudaExternalMemoryGetMappedBuffer`]
///
/// Note:
///
/// If [cudaExternalMemoryHandleDesc::type](structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [cudaExternalMemoryHandleTypeNvSciBuf](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e6f8cf38ae8bb776722f29fe5f076bdcf), then [cudaExternalMemoryMipmappedArrayDesc::numLevels](structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_14a939b3d6c1fca916dd78679049f36eb) must not be greater than 1.
///
/// # Parameters
///
/// - `mipmap`: Returned CUDA mipmapped array.
/// - `extMem`: Handle to external memory object.
/// - `mipmapDesc`: CUDA array descriptor.
pub fn cudaExternalMemoryGetMappedMipmappedArray(
mipmap: *mut cudaMipmappedArray_t,
extMem: cudaExternalMemory_t,
mipmapDesc: *const cudaExternalMemoryMipmappedArrayDesc,
) -> cudaError_t;
}
unsafe extern "C" {
/// Destroys an external memory object.
///
/// Destroys the specified external memory object. Any existing buffers and CUDA mipmapped arrays mapped onto this object must
/// no longer be used and must be explicitly freed using [`cudaFree`] and [`cudaFreeMipmappedArray`] respectively.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [`cudaImportExternalMemory`], [`cudaExternalMemoryGetMappedBuffer`], [`cudaExternalMemoryGetMappedMipmappedArray`]
///
/// # Parameters
///
/// - `extMem`: External memory object to be destroyed.
pub fn cudaDestroyExternalMemory(extMem: cudaExternalMemory_t) -> cudaError_t;
}
unsafe extern "C" {
/// Imports an external semaphore.
///
/// Imports an externally allocated synchronization object and returns a handle to that in extSem_out.
///
/// The properties of the handle being imported must be described in semHandleDesc. The [cudaExternalSemaphoreHandleDesc](#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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) specifies the type of handle being imported. [cudaExternalSemaphoreHandleType](#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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [cudaExternalSemaphoreHandleTypeOpaqueFd](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9bea12319bd1541e50566488b94593287), 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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [cudaExternalSemaphoreHandleTypeOpaqueWin32](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d933c48895ae68d3231c03dcf588f0f6e6), 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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9316a2e395a1a6ea501999dffa6511e00), 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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [cudaExternalSemaphoreHandleTypeD3D12Fence](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d963abc56296a03fafc4c478a9c2a6fb9d), 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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [cudaExternalSemaphoreHandleTypeD3D11Fence](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d944e489826c50b7e7d32819ea493ba979), 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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [cudaExternalSemaphoreHandleTypeNvSciSync](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d91f340d33a5242e6aeb3a6a528046f062), then cudaExternalSemaphoreHandleDesc::handle::nvSciSyncObj represents a valid NvSciSyncObj.
///
/// [cudaExternalSemaphoreHandleTypeKeyedMutex](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d959ccb7602ab44b5c48c923a02860dec2), 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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [cudaExternalSemaphoreHandleTypeKeyedMutexKmt](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9dc55dd5ff8c457112ce75ac9e0433120), 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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9c114b87111d1cf5315e8370bfab80fe4), 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](structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d97f1cd5d08ce74ca5ce68b47afd3f5072), 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDestroyExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`]
///
/// # Parameters
///
/// - `extSem_out`: Returned handle to an external semaphore.
/// - `semHandleDesc`: Semaphore import handle descriptor.
pub fn cudaImportExternalSemaphore(
extSem_out: *mut cudaExternalSemaphore_t,
semHandleDesc: *const cudaExternalSemaphoreHandleDesc,
) -> cudaError_t;
}
unsafe extern "C" {
/// Signals a set of external semaphore objects.
///
/// Enqueues a signal operation on a set of externally allocated semaphore object in the specified stream. The operations will
/// be executed when all prior operations in the stream complete.
///
/// The exact semantics of signaling a semaphore depends on the type of the object.
///
/// If the semaphore object is any one of the following types: [cudaExternalSemaphoreHandleTypeOpaqueFd](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9bea12319bd1541e50566488b94593287), [cudaExternalSemaphoreHandleTypeOpaqueWin32](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d933c48895ae68d3231c03dcf588f0f6e6), [cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9316a2e395a1a6ea501999dffa6511e00) then signaling the semaphore will set it to the signaled state.
///
/// If the semaphore object is any one of the following types: [cudaExternalSemaphoreHandleTypeD3D12Fence](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d963abc56296a03fafc4c478a9c2a6fb9d), [cudaExternalSemaphoreHandleTypeD3D11Fence](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d944e489826c50b7e7d32819ea493ba979), [cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9c114b87111d1cf5315e8370bfab80fe4), [cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d97f1cd5d08ce74ca5ce68b47afd3f5072) then the semaphore will be set to the value specified in cudaExternalSemaphoreSignalParams::params::fence::value.
///
/// If the semaphore object is of the type [cudaExternalSemaphoreHandleTypeNvSciSync](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d91f340d33a5242e6aeb3a6a528046f062) 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 [cudaExternalMemoryHandleTypeNvSciBuf](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e6f8cf38ae8bb776722f29fe5f076bdcf). 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](#cudaExternalSemaphoreSignalSkipNvSciBufMemSync), 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 [cudaExternalSemaphoreHandleTypeNvSciSync](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d91f340d33a5242e6aeb3a6a528046f062), 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 [cudaExternalSemaphoreHandleTypeNvSciSync](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d91f340d33a5242e6aeb3a6a528046f062) 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 [cudaExternalSemaphoreHandleTypeNvSciSync](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d91f340d33a5242e6aeb3a6a528046f062) 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 behaviour. Timestamp extracted via appropriate NvSciSync API would be in microseconds.
///
/// If the semaphore object is any one of the following types: [cudaExternalSemaphoreHandleTypeKeyedMutex](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d959ccb7602ab44b5c48c923a02860dec2), [cudaExternalSemaphoreHandleTypeKeyedMutexKmt](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9dc55dd5ff8c457112ce75ac9e0433120), then the keyed mutex will be released with the key specified in cudaExternalSemaphoreSignalParams::params::keyedmutex::key.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaImportExternalSemaphore`], [`cudaDestroyExternalSemaphore`], [`cudaWaitExternalSemaphoresAsync`]
///
/// # Parameters
///
/// - `extSemArray`: Set of external semaphores to be signaled.
/// - `paramsArray`: Array of semaphore parameters.
/// - `numExtSems`: Number of semaphores to signal.
/// - `stream`: Stream to enqueue the signal operations in.
pub fn cudaSignalExternalSemaphoresAsync(
extSemArray: *const cudaExternalSemaphore_t,
paramsArray: *const cudaExternalSemaphoreSignalParams,
numExtSems: ::core::ffi::c_uint,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Waits on a set of external semaphore objects.
///
/// Enqueues a wait operation on a set of externally allocated semaphore object in the specified stream. The operations will be
/// executed when all prior operations in the stream complete.
///
/// The exact semantics of waiting on a semaphore depends on the type of the object.
///
/// If the semaphore object is any one of the following types: [cudaExternalSemaphoreHandleTypeOpaqueFd](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9bea12319bd1541e50566488b94593287), [cudaExternalSemaphoreHandleTypeOpaqueWin32](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d933c48895ae68d3231c03dcf588f0f6e6), [cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9316a2e395a1a6ea501999dffa6511e00) 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: [cudaExternalSemaphoreHandleTypeD3D12Fence](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d963abc56296a03fafc4c478a9c2a6fb9d), [cudaExternalSemaphoreHandleTypeD3D11Fence](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d944e489826c50b7e7d32819ea493ba979), [cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9c114b87111d1cf5315e8370bfab80fe4), [cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d97f1cd5d08ce74ca5ce68b47afd3f5072) 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 [cudaExternalSemaphoreHandleTypeNvSciSync](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d91f340d33a5242e6aeb3a6a528046f062) 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 [cudaExternalMemoryHandleTypeNvSciBuf](types.md#group__CUDART__TYPES_1gg62ab2fcc2eb066702c3694148383749e6f8cf38ae8bb776722f29fe5f076bdcf). 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](#cudaExternalSemaphoreWaitSkipNvSciBufMemSync), 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 [cudaExternalSemaphoreHandleTypeNvSciSync](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d91f340d33a5242e6aeb3a6a528046f062), 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: [cudaExternalSemaphoreHandleTypeKeyedMutex](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d959ccb7602ab44b5c48c923a02860dec2), [cudaExternalSemaphoreHandleTypeKeyedMutexKmt](types.md#group__CUDART__TYPES_1ggb35390be1e170db8671b0abfb57ad3d9dc55dd5ff8c457112ce75ac9e0433120), 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaImportExternalSemaphore`], [`cudaDestroyExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`]
///
/// # Parameters
///
/// - `extSemArray`: External semaphores to be waited on.
/// - `paramsArray`: Array of semaphore parameters.
/// - `numExtSems`: Number of semaphores to wait on.
/// - `stream`: Stream to enqueue the wait operations in.
pub fn cudaWaitExternalSemaphoresAsync(
extSemArray: *const cudaExternalSemaphore_t,
paramsArray: *const cudaExternalSemaphoreWaitParams,
numExtSems: ::core::ffi::c_uint,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Destroys an external semaphore.
///
/// Destroys an external semaphore object and releases any references to the underlying resource. Any outstanding signals or waits
/// must have completed before the semaphore is destroyed.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`]
///
/// # Parameters
///
/// - `extSem`: External semaphore to be destroyed.
pub fn cudaDestroyExternalSemaphore(extSem: cudaExternalSemaphore_t) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `gridDim`: Grid dimentions.
/// - `blockDim`: Block dimentions.
/// - `args`: Arguments.
/// - `sharedMem`: Shared memory (defaults to 0).
/// - `stream`: Stream identifier (defaults to NULL).
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;
}
unsafe extern "C" {
/// Launches a CUDA function with launch-time configuration.
///
/// Note that the functionally equivalent variadic template [cudaLaunchKernelEx](high-level-api.md#group__CUDART__HIGHLEVEL_1g81f2b11c6726c7b2f3fc54fc718eaf1c "Launches a CUDA function with launch-time configuration.") is available for C++11 and newer.
///
/// Invokes the kernel func on config->gridDim (config->gridDim.xconfig->gridDim.yconfig->gridDim.z) grid of blocks. Each block contains config->blockDim (config->blockDim.xconfig->blockDim.yconfig->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](#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](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * The API can also be used with a kernel [cudaKernel_t](#cudaKernel_t) by querying the handle using [`cudaLibraryGetKernel`] or [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") should be a symbol that is registered with the same CUDA Runtime instance.
/// * 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](#cudaKernel_t)
///
/// **See also:**
///
/// [cudaLaunchKernelEx](high-level-api.md#group__CUDART__HIGHLEVEL_1g81f2b11c6726c7b2f3fc54fc718eaf1c "Launches a CUDA function with launch-time configuration.")(const [cudaLaunchConfig_t](#cudaLaunchConfig_t) \*config, void (\*kernel)(ExpTypes...), ActTypes &&... args) "cudaLaunchKernelEx (C++ API)", [cuLaunchKernelEx](../cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC_1gb9c891eb6bb8f4089758e64c9c976db9).
///
/// # Parameters
///
/// - `config`: Launch configuration.
/// - `func`: Kernel to launch.
/// - `args`: Array of pointers to kernel parameters.
pub fn cudaLaunchKernelExC(
config: *const cudaLaunchConfig_t,
func: *const ::core::ffi::c_void,
args: *mut *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `gridDim`: Grid dimentions.
/// - `blockDim`: Block dimentions.
/// - `args`: Arguments.
/// - `sharedMem`: Shared memory (defaults to 0).
/// - `stream`: Stream identifier (defaults to NULL).
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;
}
unsafe extern "C" {
/// # Parameters
///
/// - `func`: device function pointer.
/// - `cacheConfig`: Requested cache configuration.
pub fn cudaFuncSetCacheConfig(
func: *const ::core::ffi::c_void,
cacheConfig: cudaFuncCache,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `attr`: Return pointer to function's attributes.
pub fn cudaFuncGetAttributes(
attr: *mut cudaFuncAttributes,
func: *const ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `attr`: Attribute to set.
/// - `value`: Value to set.
pub fn cudaFuncSetAttribute(
func: *const ::core::ffi::c_void,
attr: cudaFuncAttribute,
value: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `name`: The returned name of the function.
/// - `func`: The function pointer to retrieve name for.
pub fn cudaFuncGetName(
name: *mut *const ::core::ffi::c_char,
func: *const ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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()](graph-management.md#group__CUDART__GRAPH_1g9171bc40a4f9be650b3fe867e8bfb549 "Updates the kernel parameters of the given kernel node.") and [cudaGraphKernelNodeUpdatesApply()](#cudaGraphKernelNodeUpdatesApply "Batch applies multiple kernel node updates."). paramIndex must be less than the number of parameters that func takes.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * The API can also be used with a kernel [cudaKernel_t](#cudaKernel_t) by querying the handle using [`cudaLibraryGetKernel`] or [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") should be a symbol that is registered with the same CUDA Runtime instance.
/// * 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](#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.
pub fn cudaFuncGetParamInfo(
func: *const ::core::ffi::c_void,
paramIndex: size_t,
paramOffset: *mut size_t,
paramSize: *mut size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the number of parameters used by the function.
///
/// Queries the number of kernel parameters used by func and returns it in paramCount.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * The API can also be used with a kernel [cudaKernel_t](#cudaKernel_t) by querying the handle using [`cudaLibraryGetKernel`] or [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") should be a symbol that is registered with the same CUDA Runtime instance.
/// * 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](#cudaKernel_t).
///
/// # Parameters
///
/// - `func`: The function to query.
/// - `paramCount`: Returns the number of parameters used by the function.
pub fn cudaFuncGetParamCount(
func: *const ::core::ffi::c_void,
paramCount: *mut size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Enqueues a host function call in a stream.
///
/// Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work
/// added after it.
///
/// The host function must not make any CUDA API calls. Attempting to use a CUDA API may result in [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3), 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](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g613d97a277d7640f4cb1c03bd51c2483), the function will not be called in the event of an error in the CUDA context.
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamDestroy`], [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system."), [cudaStreamAttachMemAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g496353d630c29c44a2e33f531a3944d1 "Attach memory to a stream asynchronously."), [`cudaStreamAddCallback`], [cuLaunchHostFunc](../cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC_1gab95a78143bae7f21eebb978f91e7f3f).
///
/// # Parameters
///
/// - `userData`: User-specified data to be passed to the function.
pub fn cudaLaunchHostFunc(
stream: cudaStream_t,
fn_: cudaHostFn_t,
userData: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// Enqueues a host function call in a stream.
///
/// Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work
/// added after it.
///
/// The host function must not make any CUDA API calls. Attempting to use a CUDA API may result in [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3), 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](../cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g613d97a277d7640f4cb1c03bd51c2483), the function will not be called in the event of an error in the CUDA context.
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaStreamCreate`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamDestroy`], [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system."), [cudaStreamAttachMemAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g496353d630c29c44a2e33f531a3944d1 "Attach memory to a stream asynchronously."), [`cudaStreamAddCallback`], [cuLaunchHostFunc](../cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC_1gab95a78143bae7f21eebb978f91e7f3f).
///
/// # Parameters
///
/// - `userData`: User-specified data to be passed to the function.
/// - `syncMode`: Sync mode for the host function.
pub fn cudaLaunchHostFunc_v2(
stream: cudaStream_t,
fn_: cudaHostFn_t,
userData: *mut ::core::ffi::c_void,
syncMode: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the shared memory configuration for a device function.
///
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * 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 [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceSetSharedMemConfig`], [`cudaDeviceGetSharedMemConfig`], [`cudaDeviceSetCacheConfig`], [`cudaDeviceGetCacheConfig`], [cudaFuncSetCacheConfig](high-level-api.md#group__CUDART__HIGHLEVEL_1g7d9cc996fe45b6260ebb086caff1c685 "[C++ API] Sets the preferred cache configuration for a device function"), [cuFuncSetSharedMemConfig](../cuda-driver-api/group__CUDA__EXEC__DEPRECATED.html#group__CUDA__EXEC__DEPRECATED_1g3fe2417a78a7b5554a694c40355b54ce).
///
/// # Parameters
///
/// - `func`: Device function symbol.
/// - `config`: Requested shared memory configuration.
#[deprecated]
pub fn cudaFuncSetSharedMemConfig(
func: *const ::core::ffi::c_void,
config: cudaSharedMemConfig,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `numBlocks`: Returned occupancy.
/// - `func`: Kernel function for which occupancy is calulated.
/// - `blockSize`: Block size the kernel is intended to be launched with.
/// - `dynamicSMemSize`: Per-block dynamic shared memory usage intended, in bytes.
pub fn cudaOccupancyMaxActiveBlocksPerMultiprocessor(
numBlocks: *mut ::core::ffi::c_int,
func: *const ::core::ffi::c_void,
blockSize: ::core::ffi::c_int,
dynamicSMemSize: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `dynamicSmemSize`: Returned maximum dynamic shared memory.
/// - `func`: Kernel function for which occupancy is calculated.
/// - `numBlocks`: Number of blocks to fit on SM.
/// - `blockSize`: Size of the block.
pub fn cudaOccupancyAvailableDynamicSMemPerBlock(
dynamicSmemSize: *mut size_t,
func: *const ::core::ffi::c_void,
numBlocks: ::core::ffi::c_int,
blockSize: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `numBlocks`: Returned occupancy.
/// - `func`: Kernel function for which occupancy is calulated.
/// - `blockSize`: Block size the kernel is intended to be launched with.
/// - `dynamicSMemSize`: Per-block dynamic shared memory usage intended, in bytes.
/// - `flags`: Requested behavior for the occupancy calculator.
pub fn cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
numBlocks: *mut ::core::ffi::c_int,
func: *const ::core::ffi::c_void,
blockSize: ::core::ffi::c_int,
dynamicSMemSize: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `clusterSize`: Returned maximum cluster size that can be launched for the given kernel function and launch configuration.
/// - `func`: Kernel function for which maximum cluster size is calculated.
pub fn cudaOccupancyMaxPotentialClusterSize(
clusterSize: *mut ::core::ffi::c_int,
func: *const ::core::ffi::c_void,
launchConfig: *const cudaLaunchConfig_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `numClusters`: Returned maximum number of clusters that could co-exist on the target device.
/// - `func`: Kernel function for which maximum number of clusters are calculated.
pub fn cudaOccupancyMaxActiveClusters(
numClusters: *mut ::core::ffi::c_int,
func: *const ::core::ffi::c_void,
launchConfig: *const cudaLaunchConfig_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `devPtr`: Pointer to allocated device memory.
/// - `size`: Requested allocation size in bytes.
/// - `flags`: Must be either [cudaMemAttachGlobal](#cudaMemAttachGlobal) or [cudaMemAttachHost](#cudaMemAttachHost) (defaults to [cudaMemAttachGlobal](#cudaMemAttachGlobal)).
pub fn cudaMallocManaged(
devPtr: *mut *mut ::core::ffi::c_void,
size: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Allocate memory on the device.
///
/// Allocates size bytes of linear memory on the device and returns in \*devPtr a pointer to the allocated memory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared.
/// [`cudaMalloc`] returns [cudaErrorMemoryAllocation](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f210f50ae7f17f655e0504929606add9) in case of failure.
///
/// The device version of [`cudaFree`] cannot be used with a \*devPtr allocated using the host API, and vice versa.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [cuMemAlloc](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gb82d2a09844a58dd9e744dc31e8aa467).
///
/// # Parameters
///
/// - `devPtr`: Pointer to allocated device memory.
/// - `size`: Requested allocation size in bytes.
pub fn cudaMalloc(
devPtr: *mut *mut ::core::ffi::c_void,
size: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `ptr`: Device pointer to allocated memory.
/// - `size`: Requested allocation size in bytes.
pub fn cudaMallocHost(
ptr: *mut *mut ::core::ffi::c_void,
size: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [cuMemAllocPitch](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gcbe9b033f6c4de80f63cc6e58ed9a45a).
///
/// # Parameters
///
/// - `devPtr`: Pointer to allocated pitched device memory.
/// - `pitch`: Pitch for allocation.
/// - `width`: Requested pitched allocation width (in bytes).
/// - `height`: Requested pitched allocation height.
pub fn cudaMallocPitch(
devPtr: *mut *mut ::core::ffi::c_void,
pitch: *mut size_t,
width: size_t,
height: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Allocate an array on the device.
///
/// Allocates a CUDA array according to the [cudaChannelFormatDesc](#cudaChannelFormatDesc) structure desc and returns a handle to the new CUDA array in \*array.
///
/// The [cudaChannelFormatDesc](#cudaChannelFormatDesc) is defined as:
///
/// ```text
/// struct cudaChannelFormatDesc {
/// int x, y, z, w;
/// enum cudaChannelFormatKind
/// f;
/// };
/// ```
///
/// [cudaChannelFormatKind](#cudaChannelFormatKind)
///
/// [cudaChannelFormatKindSigned](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119943e8b95cd113175ac55c56d90b40ae0)
///
/// [cudaChannelFormatKindUnsigned](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119240d73fa2dc05cbaa58f093f169ab3d4)
///
/// [cudaChannelFormatKindFloat](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f2351191107be31913affb6b3b49d8a6e795ee0)
///
/// The flags parameter enables different options to be specified that affect the allocation, as follows.
///
/// * [cudaArrayDefault](#cudaArrayDefault): This flag's value is defined to be 0 and provides default array allocation
/// * [cudaArraySurfaceLoadStore](#cudaArraySurfaceLoadStore): Allocates an array that can be read from or written to using a surface reference
/// * [cudaArrayTextureGather](#cudaArrayTextureGather): This flag indicates that texture gather operations will be performed on the array.
/// * [cudaArraySparse](#cudaArraySparse): 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](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). The physical backing memory must be allocated via [cuMemCreate](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
/// * [cudaArrayDeferredMapping](#cudaArrayDeferredMapping): Allocates a CUDA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation
/// by calling [cuMemMapArrayAsync](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). The physical backing memory must be allocated via [cuMemCreate](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
///
/// width and height must meet certain size requirements. See [`cudaMalloc3DArray`] for more details.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [cuArrayCreate](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4192ff387a81c3bd5ed8c391ed62ca24).
///
/// # Parameters
///
/// - `array`: Pointer to allocated array in device memory.
/// - `desc`: Requested channel format.
/// - `width`: Requested array allocation width.
/// - `height`: Requested array allocation height.
/// - `flags`: Requested properties of allocated array.
pub fn cudaMallocArray(
array: *mut cudaArray_t,
desc: *const cudaChannelFormatDesc,
width: size_t,
height: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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()](memory-pools.md#group__CUDART__MEMORY__POOLS_1gbbf70065888d61853c047513baa14081 "Allocates memory with stream ordered semantics."), [`cudaMallocFromPoolAsync`].
///
/// Note - This API will not perform any implicit synchronization when the pointer was allocated with [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool.") 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc`], [`cudaMallocPitch`], [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system."), [`cudaMallocArray`], [`cudaFreeArray`], [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaMallocFromPoolAsync`]cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaFreeAsync`][`cudaHostAlloc`], [cuMemFree](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g89b3f154e17cc89b6eea277dbdf5c93a).
///
/// # Parameters
///
/// - `devPtr`: Device pointer to memory to free.
pub fn cudaFree(devPtr: *mut ::core::ffi::c_void) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [cuMemFreeHost](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g62e0fdbe181dab6b1c90fa1a51c7b92c).
///
/// # Parameters
///
/// - `ptr`: Pointer to memory to free.
pub fn cudaFreeHost(ptr: *mut ::core::ffi::c_void) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [cuArrayDestroy](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g982878affbbc023de84874faac838b0b).
///
/// # Parameters
///
/// - `array`: Pointer to array to free.
pub fn cudaFreeArray(array: cudaArray_t) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [cuMipmappedArrayDestroy](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ge0d7c768b6a6963c4d4bde5bbc74f0ad).
///
/// # Parameters
///
/// - `mipmappedArray`: Pointer to mipmapped array to free.
pub fn cudaFreeMipmappedArray(mipmappedArray: cudaMipmappedArray_t) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaHostAllocDefault): This flag's value is defined to be 0 and causes [`cudaHostAlloc`] to emulate cudaMallocHost().
/// * [cudaHostAllocPortable](#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](#cudaHostAllocMapped): Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling [`cudaHostGetDevicePointer`].
/// * [cudaHostAllocWriteCombined](#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](#cudaHostAllocMapped) flag to have any effect, the CUDA context must support the [cudaDeviceMapHost](#cudaDeviceMapHost) flag, which can be checked via [`cudaGetDeviceFlags`]. The [cudaDeviceMapHost](#cudaDeviceMapHost) flag is implicitly set for contexts created via the runtime API.
///
/// The [cudaHostAllocMapped](#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](#cudaHostAllocPortable) flag.
///
/// Memory allocated by this function must be freed with [`cudaFreeHost`].
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaSetDeviceFlags`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaGetDeviceFlags`], [cuMemHostAlloc](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g572ca4011bfcb25034888a14d4e035b9).
///
/// # Parameters
///
/// - `pHost`: Device pointer to allocated memory.
/// - `size`: Requested allocation size in bytes.
/// - `flags`: Requested properties of allocated memory.
pub fn cudaHostAlloc(
pHost: *mut *mut ::core::ffi::c_void,
size: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Registers an existing host memory range for use by CUDA.
///
/// Page-locks the memory range specified by ptr and size and maps it for the device(s) as specified by flags. This memory range also is added to the same tracking mechanism as [`cudaHostAlloc`] to automatically accelerate calls to functions such as [`cudaMemcpy`]. Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable
/// memory that has not been registered. Page-locking excessive amounts of memory may degrade system performance, since it reduces
/// the amount of memory available to the system for paging. As a result, this function is best used sparingly to register staging
/// areas for data exchange between host and device.
///
/// On systems where pageableMemoryAccessUsesHostPageTables is true, [`cudaHostRegister`] will not page-lock the memory range specified by ptr but only populate unpopulated pages.
///
/// [`cudaHostRegister`] is supported only on I/O coherent devices that have a non-zero value for the device attribute [cudaDevAttrHostRegisterSupported](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd6ea4a004a336c3c95b6ff06ec6269e29).
///
/// The flags parameter enables different options to be specified that affect the allocation, as follows.
///
/// * [cudaHostRegisterDefault](#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](#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](#cudaHostRegisterMapped): Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling [`cudaHostGetDevicePointer`].
///
/// * [cudaHostRegisterIoMemory](#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](#cudaHostRegisterReadOnly): The passed memory pointer is treated as pointing to memory that is considered read-only by the device. On platforms without
/// [cudaDevAttrPageableMemoryAccessUsesHostPageTables](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc228cf8983c97d0e035da72a71494eaa), 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 [cudaDevAttrHostRegisterReadOnlySupported](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cde8ea38ec2872f63a74170354e375edb3). 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](#cudaHostRegisterMapped) flag to have any effect.
///
/// The [cudaHostRegisterMapped](#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](#cudaHostRegisterPortable) flag.
///
/// For devices that have a non-zero value for the device attribute [cudaDevAttrCanUseHostPointerForRegisteredMem](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdb08e379a7a038dc8134914702c223f69), 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaHostUnregister`], [`cudaHostGetFlags`], [`cudaHostGetDevicePointer`], [cuMemHostRegister](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf0a9fe11544326dabd743b7aa6b54223).
///
/// # Parameters
///
/// - `ptr`: Host pointer to memory to page-lock.
/// - `size`: Size in bytes of the address range to page-lock in bytes.
/// - `flags`: Flags for allocation request.
pub fn cudaHostRegister(
ptr: *mut ::core::ffi::c_void,
size: size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaHostUnregister`], [cuMemHostUnregister](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g63f450c8125359be87b7623b1c0b2a14).
///
/// # Parameters
///
/// - `ptr`: Host pointer to memory to unregister.
pub fn cudaHostUnregister(ptr: *mut ::core::ffi::c_void) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaDeviceMapHost) flag was not specified before deferred context creation occurred, or if called on a device that does not support mapped,
/// pinned memory.
///
/// For devices that have a non-zero value for the device attribute [cudaDevAttrCanUseHostPointerForRegisteredMem](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdb08e379a7a038dc8134914702c223f69), 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaSetDeviceFlags`], [`cudaHostAlloc`], [cuMemHostGetDevicePointer](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g57a39e5cba26af4d06be67fc77cc62f0).
///
/// # Parameters
///
/// - `pDevice`: Returned device pointer for mapped memory.
/// - `pHost`: Requested host pointer mapping.
/// - `flags`: Flags for extensions (must be 0 for now).
pub fn cudaHostGetDevicePointer(
pDevice: *mut *mut ::core::ffi::c_void,
pHost: *mut ::core::ffi::c_void,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaHostAlloc`], [cuMemHostGetFlags](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g42066246915fcb0400df2a17a851b35f).
///
/// # Parameters
///
/// - `pFlags`: Returned flags word.
/// - `pHost`: Host pointer.
pub fn cudaHostGetFlags(
pFlags: *mut ::core::ffi::c_uint,
pHost: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#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](#cudaPitchedPtr) contains additional fields xsize and ysize, the logical width and height of the allocation, which are equivalent to the width and heightextent 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMallocPitch`], [`cudaFree`], [`cudaMemcpy3D`], [`cudaMemset3D`], [`cudaMalloc3DArray`], [`cudaMallocArray`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [make_cudaPitchedPtr](#make_cudaPitchedPtr "Returns a cudaPitchedPtr based on input parameters."), [make_cudaExtent](#make_cudaExtent "Returns a cudaExtent based on input parameters."), [cuMemAllocPitch](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gcbe9b033f6c4de80f63cc6e58ed9a45a).
///
/// # Parameters
///
/// - `pitchedDevPtr`: Pointer to allocated pitched device memory.
/// - `extent`: Requested allocation size (width field in bytes).
pub fn cudaMalloc3D(
pitchedDevPtr: *mut cudaPitchedPtr,
extent: cudaExtent,
) -> cudaError_t;
}
unsafe extern "C" {
/// Allocate an array on the device.
///
/// Allocates a CUDA array according to the [cudaChannelFormatDesc](#cudaChannelFormatDesc) structure desc and returns a handle to the new CUDA array in \*array.
///
/// The [cudaChannelFormatDesc](#cudaChannelFormatDesc) is defined as:
///
/// ```text
/// struct cudaChannelFormatDesc {
/// int x, y, z, w;
/// enum cudaChannelFormatKind
/// f;
/// };
/// ```
///
/// [cudaChannelFormatKind](#cudaChannelFormatKind)
///
/// [cudaChannelFormatKindSigned](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119943e8b95cd113175ac55c56d90b40ae0)
///
/// [cudaChannelFormatKindUnsigned](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119240d73fa2dc05cbaa58f093f169ab3d4)
///
/// [cudaChannelFormatKindFloat](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f2351191107be31913affb6b3b49d8a6e795ee0)
///
/// [`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](#cudaGraphicsCubeFace).
/// * 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](#cudaArrayDefault): This flag's value is defined to be 0 and provides default array allocation
/// * [cudaArrayLayered](#cudaArrayLayered): Allocates a layered CUDA array, with the depth extent indicating the number of layers
/// * [cudaArrayCubemap](#cudaArrayCubemap): 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](#cudaArraySurfaceLoadStore): Allocates a CUDA array that could be read from or written to using a surface reference.
/// * [cudaArrayTextureGather](#cudaArrayTextureGather): 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](#cudaArraySparse): 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](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). 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](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
/// * [cudaArrayDeferredMapping](#cudaArrayDeferredMapping): Allocates a CUDA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation
/// by calling [cuMemMapArrayAsync](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). The physical backing memory must be allocated via [cuMemCreate](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
///
/// 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](#cudaArrayTextureGather) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc3D`], [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [make_cudaExtent](#make_cudaExtent "Returns a cudaExtent based on input parameters."), [cuArray3DCreate](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gc2322c70b38c2984536c90ed118bb1d7).
///
/// # Parameters
///
/// - `array`: Pointer to allocated array in device memory.
/// - `desc`: Requested channel format.
/// - `extent`: Requested allocation size (width field in elements).
/// - `flags`: Flags for extensions.
pub fn cudaMalloc3DArray(
array: *mut cudaArray_t,
desc: *const cudaChannelFormatDesc,
extent: cudaExtent,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Allocate a mipmapped array on the device.
///
/// Allocates a CUDA mipmapped array according to the [cudaChannelFormatDesc](#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](#cudaChannelFormatDesc) is defined as:
///
/// ```text
/// struct cudaChannelFormatDesc {
/// int x, y, z, w;
/// enum cudaChannelFormatKind
/// f;
/// };
/// ```
///
/// [cudaChannelFormatKind](#cudaChannelFormatKind)
///
/// [cudaChannelFormatKindSigned](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119943e8b95cd113175ac55c56d90b40ae0)
///
/// [cudaChannelFormatKindUnsigned](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119240d73fa2dc05cbaa58f093f169ab3d4)
///
/// [cudaChannelFormatKindFloat](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f2351191107be31913affb6b3b49d8a6e795ee0)
///
/// [`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](#cudaGraphicsCubeFace).
/// * 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](#cudaArrayDefault): This flag's value is defined to be 0 and provides default mipmapped array allocation
/// * [cudaArrayLayered](#cudaArrayLayered): Allocates a layered CUDA mipmapped array, with the depth extent indicating the number of layers
/// * [cudaArrayCubemap](#cudaArrayCubemap): 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](#cudaArraySurfaceLoadStore): This flag indicates that individual mipmap levels of the CUDA mipmapped array will be read from or written to using a surface
/// reference.
/// * [cudaArrayTextureGather](#cudaArrayTextureGather): 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](#cudaArraySparse): 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](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). 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](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
/// * [cudaArrayDeferredMapping](#cudaArrayDeferredMapping): Allocates a CUDA mipmapped array without physical backing memory. The entire array can later be mapped onto a physical memory
/// allocation by calling [cuMemMapArrayAsync](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). The physical backing memory must be allocated via [cuMemCreate](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
///
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc3D`], [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [make_cudaExtent](#make_cudaExtent "Returns a cudaExtent based on input parameters."), [cuMipmappedArrayCreate](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ga5d2e311c7f9b0bc6d130af824a40bd3).
///
/// # Parameters
///
/// - `mipmappedArray`: Pointer to allocated mipmapped array in device memory.
/// - `desc`: Requested channel format.
/// - `extent`: Requested allocation size (width field in elements).
/// - `numLevels`: Number of mipmap levels to allocate.
/// - `flags`: Flags for extensions.
pub fn cudaMallocMipmappedArray(
mipmappedArray: *mut cudaMipmappedArray_t,
desc: *const cudaChannelFormatDesc,
extent: cudaExtent,
numLevels: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Gets a mipmap level of a CUDA mipmapped array.
///
/// Returns in \*levelArray a CUDA array that represents a single mipmap level of the CUDA mipmapped array mipmappedArray.
///
/// If level is greater than the maximum number of levels in this mipmapped array, [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// If mipmappedArray is NULL, [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) is returned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc3D`], [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [make_cudaExtent](#make_cudaExtent "Returns a cudaExtent based on input parameters."), [cuMipmappedArrayGetLevel](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g82f276659f05be14820e99346b0f86b7).
///
/// # Parameters
///
/// - `levelArray`: Returned mipmap level CUDA array.
/// - `mipmappedArray`: CUDA mipmapped array.
/// - `level`: Mipmap level.
pub fn cudaGetMipmappedArrayLevel(
levelArray: *mut cudaArray_t,
mipmappedArray: cudaMipmappedArray_const_t,
level: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is only allowed on systems that support unified virtual addressing. For [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7) or [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568) or [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253) 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](#cudaPitchedPtr) allocated with [`cudaMalloc3D`] will always be valid.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaMemset3D`], [`cudaMemcpy3DAsync`], [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [make_cudaExtent](#make_cudaExtent "Returns a cudaExtent based on input parameters."), [make_cudaPos](#make_cudaPos "Returns a cudaPos based on input parameters."), [cuMemcpy3D](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4b5238975579f002c0199a3800ca44df).
///
/// # Parameters
///
/// - `p`: 3D memory copy parameters.
pub fn cudaMemcpy3D(p: *const cudaMemcpy3DParms) -> cudaError_t;
}
unsafe extern "C" {
/// Copies memory between devices.
///
/// Perform a 3D memory copy according to the parameters specified in p. See the definition of the [cudaMemcpy3DPeerParms](#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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpyPeer`], [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpyPeerAsync`], [`cudaMemcpy3DPeerAsync`], [cuMemcpy3DPeer](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g11466fd70cde9329a4e16eb1f258c433).
///
/// # Parameters
///
/// - `p`: Parameters for the memory copy.
pub fn cudaMemcpy3DPeer(p: *const cudaMemcpy3DPeerParms) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is only allowed on systems that support unified virtual addressing. For [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7) or [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568) or [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253) 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](#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 [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568) or [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaMemset3D`], [`cudaMemcpy3D`], [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], :[`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [make_cudaExtent](#make_cudaExtent "Returns a cudaExtent based on input parameters."), [make_cudaPos](#make_cudaPos "Returns a cudaPos based on input parameters."), [cuMemcpy3DAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g79f4f3fde6ae0f529568d881d9e11987).
///
/// # Parameters
///
/// - `p`: 3D memory copy parameters.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy3DAsync(
p: *const cudaMemcpy3DParms,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Copies memory between devices asynchronously.
///
/// Perform a 3D memory copy according to the parameters specified in p. See the definition of the [cudaMemcpy3DPeerParms](#cudaMemcpy3DPeerParms) structure for documentation of its parameters.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpyPeer`], [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpyPeerAsync`], [`cudaMemcpy3DPeerAsync`], [cuMemcpy3DPeerAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gc4e4bfd9f627d3aa3695979e058f1bb8).
///
/// # Parameters
///
/// - `p`: Parameters for the memory copy.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy3DPeerAsync(
p: *const cudaMemcpy3DPeerParms,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Gets free and total device memory.
///
/// Returns in \*total the total amount of memory available to the the current context. Returns in \*free the amount of memory on the device that is free according to the OS. CUDA is not guaranteed to be able to allocate all of
/// the memory that the OS reports as free. In a multi-tenet situation, free estimate returned is prone to race condition where
/// a new allocation/free done by a different process or a different thread in the same process between the time when free memory
/// was estimated and reported, will result in deviation in free value reported and actual free memory.
///
/// The integrated GPU on Tegra shares memory with CPU and other component of the SoC. The free and total values returned by the
/// API excludes the SWAP memory space maintained by the OS on some platforms. The OS may move some of the memory pages into swap
/// area as the GPU or CPU allocate or access memory. See Tegra app note on how to calculate total and free memory on Tegra.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuMemGetInfo](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g808f555540d0143a331cc42aa98835c0).
///
/// # Parameters
///
/// - `free`: Returned free memory in bytes.
/// - `total`: Returned total memory in bytes.
pub fn cudaMemGetInfo(free: *mut size_t, total: *mut size_t) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuArrayGetDescriptor](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g661fe823dbd37bf11f82a71bd4762acf), [cuArray3DGetDescriptor](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gb58549f2f3f390b9e0e7c8f3acd53857).
///
/// # Parameters
///
/// - `desc`: Returned array type.
/// - `extent`: Returned array shape. 2D arrays will have depth of zero.
/// - `flags`: Returned array flags.
/// - `array`: The cudaArray to get info for.
pub fn cudaArrayGetInfo(
desc: *mut cudaChannelFormatDesc,
extent: *mut cudaExtent,
flags: *mut ::core::ffi::c_uint,
array: cudaArray_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Gets a CUDA array plane from a CUDA array.
///
/// Returns in pPlaneArray a CUDA array that represents a single format plane of the CUDA array hArray.
///
/// If planeIdx is greater than the maximum number of planes in this array or if the array does not have a multi-planar format e.g: [cudaChannelFormatKindNV12](types.md#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119c89d051aff61fb1bd60a69fdd82a97c2), then [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// Note that if the hArray has format [cudaChannelFormatKindNV12](types.md#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119c89d051aff61fb1bd60a69fdd82a97c2), then passing in 0 for planeIdx returns a CUDA array of the same size as hArray but with one 8-bit channel and [cudaChannelFormatKindUnsigned](types.md#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119240d73fa2dc05cbaa58f093f169ab3d4) 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 [cudaChannelFormatKindUnsigned](types.md#group__CUDART__TYPES_1gg8085eac5cb54b4228f3619a60f235119240d73fa2dc05cbaa58f093f169ab3d4) as its format kind.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cuArrayGetPlane](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ge66ce245a1e3802f9ccc3583cec6b71f).
///
/// # Parameters
///
/// - `pPlaneArray`: Returned CUDA array referenced by the planeIdx.
/// - `hArray`: CUDA array.
/// - `planeIdx`: Plane index.
pub fn cudaArrayGetPlane(
pPlaneArray: *mut cudaArray_t,
hArray: cudaArray_t,
planeIdx: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the memory requirements of a CUDA array.
///
/// Returns the memory requirements of a CUDA array in memoryRequirements If the CUDA array is not allocated with flag [cudaArrayDeferredMapping](#cudaArrayDeferredMapping)[cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// The returned value in [cudaArrayMemoryRequirements::size](structcudaArrayMemoryRequirements.html#structcudaArrayMemoryRequirements_1cff0bc12daa05c6c40892a2187befd87) represents the total size of the CUDA array. The returned value in [cudaArrayMemoryRequirements::alignment](structcudaArrayMemoryRequirements.html#structcudaArrayMemoryRequirements_137898b13b500d39e4a43d0ee04cf0ef3) represents the alignment necessary for mapping the CUDA array.
///
/// **See also:**
///
/// [`cudaMipmappedArrayGetMemoryRequirements`]
///
/// # Parameters
///
/// - `memoryRequirements`: Pointer to [cudaArrayMemoryRequirements](#cudaArrayMemoryRequirements).
/// - `array`: CUDA array to get the memory requirements of.
/// - `device`: Device to get the memory requirements for.
pub fn cudaArrayGetMemoryRequirements(
memoryRequirements: *mut cudaArrayMemoryRequirements,
array: cudaArray_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the memory requirements of a CUDA mipmapped array.
///
/// Returns the memory requirements of a CUDA mipmapped array in memoryRequirements If the CUDA mipmapped array is not allocated with flag [cudaArrayDeferredMapping](#cudaArrayDeferredMapping)[cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// The returned value in [cudaArrayMemoryRequirements::size](structcudaArrayMemoryRequirements.html#structcudaArrayMemoryRequirements_1cff0bc12daa05c6c40892a2187befd87) represents the total size of the CUDA mipmapped array. The returned value in [cudaArrayMemoryRequirements::alignment](structcudaArrayMemoryRequirements.html#structcudaArrayMemoryRequirements_137898b13b500d39e4a43d0ee04cf0ef3) represents the alignment necessary for mapping the CUDA mipmapped array.
///
/// **See also:**
///
/// [`cudaArrayGetMemoryRequirements`]
///
/// # Parameters
///
/// - `memoryRequirements`: Pointer to [cudaArrayMemoryRequirements](#cudaArrayMemoryRequirements).
/// - `mipmap`: CUDA mipmapped array to get the memory requirements of.
/// - `device`: Device to get the memory requirements for.
pub fn cudaMipmappedArrayGetMemoryRequirements(
memoryRequirements: *mut cudaArrayMemoryRequirements,
mipmap: cudaMipmappedArray_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the layout properties of a sparse CUDA array.
///
/// Returns the layout properties of a sparse CUDA array in sparseProperties. If the CUDA array is not allocated with flag [cudaArraySparse](#cudaArraySparse)[cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// If the returned value in [cudaArraySparseProperties::flags](structcudaArraySparseProperties.html#structcudaArraySparseProperties_144c8728469d60e511aceb4ba7086c164) contains [cudaArraySparsePropertiesSingleMipTail](#cudaArraySparsePropertiesSingleMipTail), then [cudaArraySparseProperties::miptailSize](structcudaArraySparseProperties.html#structcudaArraySparseProperties_122cfa4ad83195f0e9585303c988bb886) represents the total size of the array. Otherwise, it will be zero. Also, the returned value in [cudaArraySparseProperties::miptailFirstLevel](structcudaArraySparseProperties.html#structcudaArraySparseProperties_1b6909e5db55b866477b6cc16fb02f9d3) is always zero. Note that the array must have been allocated using [`cudaMallocArray`] or [`cudaMalloc3DArray`]. For CUDA arrays obtained using cudaMipmappedArrayGetLevel, [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned. Instead, [`cudaMipmappedArrayGetSparseProperties`] must be used to obtain the sparse properties of the entire CUDA mipmapped array to which array belongs to.
///
/// **See also:**
///
/// [`cudaMipmappedArrayGetSparseProperties`], [cuMemMapArrayAsync](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab).
///
/// # Parameters
///
/// - `sparseProperties`: Pointer to return the [cudaArraySparseProperties](#cudaArraySparseProperties).
/// - `array`: The CUDA array to get the sparse properties of.
pub fn cudaArrayGetSparseProperties(
sparseProperties: *mut cudaArraySparseProperties,
array: cudaArray_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the layout properties of a sparse CUDA mipmapped array.
///
/// Returns the sparse array layout properties in sparseProperties. If the CUDA mipmapped array is not allocated with flag [cudaArraySparse](#cudaArraySparse)[cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
///
/// For non-layered CUDA mipmapped arrays, [cudaArraySparseProperties::miptailSize](structcudaArraySparseProperties.html#structcudaArraySparseProperties_122cfa4ad83195f0e9585303c988bb886) 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](structcudaArraySparseProperties.html#structcudaArraySparseProperties_144c8728469d60e511aceb4ba7086c164) contains [cudaArraySparsePropertiesSingleMipTail](#cudaArraySparsePropertiesSingleMipTail), then [cudaArraySparseProperties::miptailSize](structcudaArraySparseProperties.html#structcudaArraySparseProperties_122cfa4ad83195f0e9585303c988bb886) specifies the size of the mip tail of all layers combined. Otherwise, [cudaArraySparseProperties::miptailSize](structcudaArraySparseProperties.html#structcudaArraySparseProperties_122cfa4ad83195f0e9585303c988bb886) specifies mip tail size per layer. The returned value of [cudaArraySparseProperties::miptailFirstLevel](structcudaArraySparseProperties.html#structcudaArraySparseProperties_1b6909e5db55b866477b6cc16fb02f9d3) is valid only if [cudaArraySparseProperties::miptailSize](structcudaArraySparseProperties.html#structcudaArraySparseProperties_122cfa4ad83195f0e9585303c988bb886) is non-zero.
///
/// **See also:**
///
/// [`cudaArrayGetSparseProperties`], [cuMemMapArrayAsync](../cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab).
///
/// # Parameters
///
/// - `sparseProperties`: Pointer to return [cudaArraySparseProperties](#cudaArraySparseProperties).
/// - `mipmap`: The CUDA mipmapped array to get the sparse properties of.
pub fn cudaMipmappedArrayGetSparseProperties(
sparseProperties: *mut cudaArraySparseProperties,
mipmap: cudaMipmappedArray_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * This function exhibits [synchronous](api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return CUDA_ERROR_INVALID_VALUE.
///
/// **See also:**
///
/// [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpyDtoH](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g3480368ee0208a98f75019c9a8450893), [cuMemcpyHtoD](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4d32266788c440b0220b1a9ba5795169), [cuMemcpyDtoD](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g1725774abf8b51b91945f3336b778c8b), [cuMemcpy](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g8d0ff510f26d4b87bd3a51e731e7f698).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
pub fn cudaMemcpy(
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpyPeerAsync`], [`cudaMemcpy3DPeerAsync`], [cuMemcpyPeer](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ge1f5c7771544fee150ada8853c7cbf4a).
///
/// # Parameters
///
/// - `dst`: Destination device pointer.
/// - `dstDevice`: Destination device.
/// - `src`: Source device pointer.
/// - `srcDevice`: Source device.
/// - `count`: Size of memory copy in bytes.
pub fn cudaMemcpyPeer(
dst: *mut ::core::ffi::c_void,
dstDevice: ::core::ffi::c_int,
src: *const ::core::ffi::c_void,
srcDevice: ::core::ffi::c_int,
count: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpy2D](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g27f885b30c34cc20a663a671dbf6fc27), [cuMemcpy2DUnaligned](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g2fa285d47fd7020e596bfeab3deb651b).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `dpitch`: Pitch of destination memory.
/// - `src`: Source memory address.
/// - `spitch`: Pitch of source memory.
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
pub fn cudaMemcpy2D(
dst: *mut ::core::ffi::c_void,
dpitch: size_t,
src: *const ::core::ffi::c_void,
spitch: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpy2D](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g27f885b30c34cc20a663a671dbf6fc27), [cuMemcpy2DUnaligned](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g2fa285d47fd7020e596bfeab3deb651b).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffset`: Destination starting X offset (columns in bytes).
/// - `hOffset`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `spitch`: Pitch of source memory.
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
pub fn cudaMemcpy2DToArray(
dst: cudaArray_t,
wOffset: size_t,
hOffset: size_t,
src: *const ::core::ffi::c_void,
spitch: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpy2D](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g27f885b30c34cc20a663a671dbf6fc27), [cuMemcpy2DUnaligned](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g2fa285d47fd7020e596bfeab3deb651b).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `dpitch`: Pitch of destination memory.
/// - `src`: Source memory address.
/// - `wOffset`: Source starting X offset (columns in bytes).
/// - `hOffset`: Source starting Y offset (rows).
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
pub fn cudaMemcpy2DFromArray(
dst: *mut ::core::ffi::c_void,
dpitch: size_t,
src: cudaArray_const_t,
wOffset: size_t,
hOffset: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpy2D](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g27f885b30c34cc20a663a671dbf6fc27), [cuMemcpy2DUnaligned](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g2fa285d47fd7020e596bfeab3deb651b).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffsetDst`: Destination starting X offset (columns in bytes).
/// - `hOffsetDst`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `wOffsetSrc`: Source starting X offset (columns in bytes).
/// - `hOffsetSrc`: Source starting Y offset (rows).
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
pub fn cudaMemcpy2DArrayToArray(
dst: cudaArray_t,
wOffsetDst: size_t,
hOffsetDst: size_t,
src: cudaArray_const_t,
wOffsetSrc: size_t,
hOffsetSrc: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `symbol`: Device symbol reference.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaMemcpyToSymbol(
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol reference.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaMemcpyFromSymbol(
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpyAsync(
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpyPeer`], [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy3DPeerAsync`], [cuMemcpyPeerAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g82fcecb38018e64b98616a8ac30112f2).
///
/// # Parameters
///
/// - `dst`: Destination device pointer.
/// - `dstDevice`: Destination device.
/// - `src`: Source device pointer.
/// - `srcDevice`: Source device.
/// - `count`: Size of memory copy in bytes.
/// - `stream`: Stream identifier.
pub fn cudaMemcpyPeerAsync(
dst: *mut ::core::ffi::c_void,
dstDevice: ::core::ffi::c_int,
src: *const ::core::ffi::c_void,
srcDevice: ::core::ffi::c_int,
count: size_t,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # 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.
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;
}
unsafe extern "C" {
/// Performs a batch of 3D memory copies asynchronously.
///
/// Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a batch are not guaranteed
/// to execute in any specific order. Note that this means specifying any dependent copies within a batch will result in undefined
/// behavior.
///
/// Performs memory copies as specified in the opList array. The length of this array is specified in numOps. Each entry in this array describes a copy operation. This includes among other things, the source and destination operands
/// for the copy as specified in cudaMemcpy3DBatchOp::src and cudaMemcpy3DBatchOp::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.
/// 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](types.md#group__CUDART__TYPES_1ggda2d93832ded1a29fd7cb28a6261ee6c395369a66615a9cacf1a734334859a67), then cudaMemcpy3DOperand::op::ptr will be used. The cudaMemcpy3DOperand::op::ptr::ptr field must contain the pointer where
/// the copy should begin. The cudaMemcpy3DOperand::op::ptr::rowLength field specifies the length of each row in elements and
/// must either be zero or be greater than or equal to the width of the copy specified in cudaMemcpy3DBatchOp::extent::width.
/// The cudaMemcpy3DOperand::op::ptr::layerHeight field specifies the height of each layer and must either be zero or be greater
/// than or equal to the height of the copy specified in cudaMemcpy3DBatchOp::extent::height. When either of these values is zero,
/// that aspect of the operand is considered to be tightly packed according to the copy extent. For managed memory pointers on
/// devices where [cudaDevAttrConcurrentManagedAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09) is true or system-allocated pageable memory on devices where [cudaDevAttrPageableMemoryAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f) 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](types.md#group__CUDART__TYPES_1ggda2d93832ded1a29fd7cb28a6261ee6c468b9e5daeac88a1cddc387310cb2952), 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](structcudaMemcpyAttributes.html#structcudaMemcpyAttributes_10d466b9b554cfd529fa0d0344c0c391a) indicates the source access ordering to be observed for copies associated with the attribute. If the source access order
/// is set to [cudaMemcpySrcAccessOrderStream](types.md#group__CUDART__TYPES_1gg1a0bf7e313a2ef3dcabacefcf8a013b5b0c0860266a1fe9e640296317e8e32ae), then the source will be accessed in stream order. If the source access order is set to [cudaMemcpySrcAccessOrderDuringApiCall](types.md#group__CUDART__TYPES_1gg1a0bf7e313a2ef3dcabacefcf8a013b5cf1101b874ba5ffe6ad6d89b7e807b29) 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](types.md#group__CUDART__TYPES_1gg1a0bf7e313a2ef3dcabacefcf8a013b517b318d18bd58f8bfb6eb4b44a7d6949) then it indicates that access to the source pointer can be out of stream order and the accesses can happen even after the
/// API call returns. This flag is suited for host pointers allocated outside CUDA (ex., via malloc) when it's known that no prior
/// operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain
/// platforms. Each memcopy operation in opList must have a valid srcAccessOrder setting, otherwise this API will return [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// The [cudaMemcpyAttributes::flags](structcudaMemcpyAttributes.html#structcudaMemcpyAttributes_1f18d7011fefaecb0fa72cbdbf8aad0fb) field can be used to specify certain flags for copies. Setting the [cudaMemcpyFlagPreferOverlapWithCompute](types.md#group__CUDART__TYPES_1gge21aa0690949b1d1e5360e4edcf75dcffef0e1bac799cb33d1ee092124ced948) flag indicates that the associated copies should preferably overlap with any compute work. Note that this flag is a hint
/// and can be ignored depending on the platform and other parameters of the copy.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return 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.
pub fn cudaMemcpy3DBatchAsync(
numOps: size_t,
opList: *mut cudaMemcpy3DBatchOp,
flags: ::core::ffi::c_ulonglong,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Performs asynchronous memory copy operation with the specified attributes.
///
/// Performs asynchronous memory copy operation where dst and src are the destination and source pointers respectively. size specifies the number of bytes to copy. attr specifies the attributes for the copy and hStream specifies the stream to enqueue the operation in.
///
/// For more information regarding the attributes, please refer to [cudaMemcpyAttributes](#cudaMemcpyAttributes) and it's usage desciption [in::cudaMemcpyBatchAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g58cf0d0f10efd8c0748b1722ef9eb070 "Performs a batch of memory copies asynchronously.")
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return CUDA_ERROR_INVALID_VALUE.
///
/// **See also:**
///
/// [cudaMemcpyBatchAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g58cf0d0f10efd8c0748b1722ef9eb070 "Performs a batch of memory copies asynchronously.")
///
/// # Parameters
///
/// - `dst`: Destination device pointer.
/// - `src`: Source device pointer.
/// - `size`: Number of bytes to copy.
/// - `attr`: Attributes for the copy.
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;
}
unsafe extern "C" {
/// Performs 3D asynchronous memory copy with the specified attributes.
///
/// Performs the copy operation specified in op. flags specifies the flags for the copy and hStream specifies the stream to enqueue the operation in.
///
/// For more information regarding the operation, please refer to cudaMemcpy3DBatchOp and it's usage desciption [in::cudaMemcpy3DBatchAsync](#cudaMemcpy3DBatchAsync "Performs a batch of 3D memory copies asynchronously.")
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
/// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
/// will return CUDA_ERROR_INVALID_VALUE.
///
/// **See also:**
///
/// [`cudaMemcpy3DBatchAsync`]
///
/// # Parameters
///
/// - `op`: Operation to perform.
/// - `flags`: Flags for the copy, must be zero now.
pub fn cudaMemcpy3DWithAttributesAsync(
op: *mut cudaMemcpy3DBatchOp,
flags: ::core::ffi::c_ulonglong,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) 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 [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568) or [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253) 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpy2DAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `dpitch`: Pitch of destination memory.
/// - `src`: Source memory address.
/// - `spitch`: Pitch of source memory.
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy2DAsync(
dst: *mut ::core::ffi::c_void,
dpitch: size_t,
src: *const ::core::ffi::c_void,
spitch: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) 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 [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568) or [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253) and stream is non-zero, the copy may overlap with operations in other streams.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`],
///
/// [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpy2DAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffset`: Destination starting X offset (columns in bytes).
/// - `hOffset`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `spitch`: Pitch of source memory.
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy2DToArrayAsync(
dst: cudaArray_t,
wOffset: size_t,
hOffset: size_t,
src: *const ::core::ffi::c_void,
spitch: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) 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 [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568) or [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253) and stream is non-zero, the copy may overlap with operations in other streams.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`],
///
/// [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpy2DAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `dpitch`: Pitch of destination memory.
/// - `src`: Source memory address.
/// - `wOffset`: Source starting X offset (columns in bytes).
/// - `hOffset`: Source starting Y offset (rows).
/// - `width`: Width of matrix transfer (columns in bytes).
/// - `height`: Height of matrix transfer (rows).
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpy2DFromArrayAsync(
dst: *mut ::core::ffi::c_void,
dpitch: size_t,
src: cudaArray_const_t,
wOffset: size_t,
hOffset: size_t,
width: size_t,
height: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `symbol`: Device symbol reference.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpyToSymbolAsync(
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol reference.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
pub fn cudaMemcpyFromSymbolAsync(
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](api-sync-behavior.html#api-sync-behavior__memset).
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuMemsetD8](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g6e582bf866e9e2fb014297bfaf354d7b), [cuMemsetD16](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g7d805e610054392a4d11e8a8bf5eb35c), [cuMemsetD32](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g983e8d8759acd1b64326317481fbf132).
///
/// # Parameters
///
/// - `devPtr`: Pointer to device memory.
/// - `value`: Value to set for each byte of specified memory.
/// - `count`: Size in bytes to set.
pub fn cudaMemset(
devPtr: *mut ::core::ffi::c_void,
value: ::core::ffi::c_int,
count: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](api-sync-behavior.html#api-sync-behavior__memset).
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemset`], [`cudaMemset3D`], [`cudaMemsetAsync`], [`cudaMemset2DAsync`], [`cudaMemset3DAsync`], [cuMemsetD2D8](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ge88b13e646e2be6ba0e0475ef5205974), [cuMemsetD2D16](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g7f561a15a66144fa9f6ab5350edc8a30), [cuMemsetD2D32](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g74b359b2d026bfeb7c795b5038d07523).
///
/// # Parameters
///
/// - `devPtr`: Pointer to 2D device memory.
/// - `pitch`: Pitch in bytes of 2D device memory(Unused if height is 1).
/// - `value`: Value to set for each byte of specified memory.
/// - `width`: Width of matrix set (columns in bytes).
/// - `height`: Height of matrix set (rows).
pub fn cudaMemset2D(
devPtr: *mut ::core::ffi::c_void,
pitch: size_t,
value: ::core::ffi::c_int,
width: size_t,
height: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](api-sync-behavior.html#api-sync-behavior__memset).
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemset`], [`cudaMemset2D`], [`cudaMemsetAsync`], [`cudaMemset2DAsync`], [`cudaMemset3DAsync`], [`cudaMalloc3D`], [make_cudaPitchedPtr](#make_cudaPitchedPtr "Returns a cudaPitchedPtr based on input parameters."), [make_cudaExtent](#make_cudaExtent "Returns a cudaExtent based on input parameters.")
///
/// # Parameters
///
/// - `pitchedDevPtr`: Pointer to pitched device memory.
/// - `value`: Value to set for each byte of specified memory.
/// - `extent`: Size parameters for where to set device memory (width field in bytes).
pub fn cudaMemset3D(
pitchedDevPtr: cudaPitchedPtr,
value: ::core::ffi::c_int,
extent: cudaExtent,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](api-sync-behavior.html#api-sync-behavior__memset).
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemset`], [`cudaMemset2D`], [`cudaMemset3D`], [`cudaMemset2DAsync`], [`cudaMemset3DAsync`], [cuMemsetD8Async](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gaef08a7ccd61112f94e82f2b30d43627), [cuMemsetD16Async](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf731438877dd8ec875e4c43d848c878c), [cuMemsetD32Async](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g58229da5d30f1c0cdf667b320ec2c0f5).
///
/// # Parameters
///
/// - `devPtr`: Pointer to device memory.
/// - `value`: Value to set for each byte of specified memory.
/// - `count`: Size in bytes to set.
/// - `stream`: Stream identifier.
pub fn cudaMemsetAsync(
devPtr: *mut ::core::ffi::c_void,
value: ::core::ffi::c_int,
count: size_t,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](api-sync-behavior.html#api-sync-behavior__memset).
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemset`], [`cudaMemset2D`], [`cudaMemset3D`], [`cudaMemsetAsync`], [`cudaMemset3DAsync`], [cuMemsetD2D8Async](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g3f7b6924a3e49c3265b328f534102e97), [cuMemsetD2D16Async](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g64ee197befac3d74d9fefedcf6ef6b10), [cuMemsetD2D32Async](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g8a78d3147ac93fac955052c815d9ea3c).
///
/// # Parameters
///
/// - `devPtr`: Pointer to 2D device memory.
/// - `pitch`: Pitch in bytes of 2D device memory(Unused if height is 1).
/// - `value`: Value to set for each byte of specified memory.
/// - `width`: Width of matrix set (columns in bytes).
/// - `height`: Height of matrix set (rows).
/// - `stream`: Stream identifier.
pub fn cudaMemset2DAsync(
devPtr: *mut ::core::ffi::c_void,
pitch: size_t,
value: ::core::ffi::c_int,
width: size_t,
height: size_t,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * See also [memset synchronization details](api-sync-behavior.html#api-sync-behavior__memset).
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemset`], [`cudaMemset2D`], [`cudaMemset3D`], [`cudaMemsetAsync`], [`cudaMemset2DAsync`], [`cudaMalloc3D`], [make_cudaPitchedPtr](#make_cudaPitchedPtr "Returns a cudaPitchedPtr based on input parameters."), [make_cudaExtent](#make_cudaExtent "Returns a cudaExtent based on input parameters.")
///
/// # Parameters
///
/// - `pitchedDevPtr`: Pointer to pitched device memory.
/// - `value`: Value to set for each byte of specified memory.
/// - `extent`: Size parameters for where to set device memory (width field in bytes).
/// - `stream`: Stream identifier.
pub fn cudaMemset3DAsync(
pitchedDevPtr: cudaPitchedPtr,
value: ::core::ffi::c_int,
extent: cudaExtent,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `devPtr`: Return device pointer associated with symbol.
/// - `symbol`: Device symbol reference.
pub fn cudaGetSymbolAddress(
devPtr: *mut *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `size`: Size of object associated with symbol.
/// - `symbol`: Device symbol reference.
pub fn cudaGetSymbolSize(
size: *mut size_t,
symbol: *const ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// Prefetches memory to the specified destination location.
///
/// Prefetches memory to the specified destination location. devPtr is the base device pointer of the memory to be prefetched and location specifies the destination location. count specifies the number of bytes to copy. stream is the stream in which the operation is enqueued. The memory range must refer to managed memory allocated via [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system.") 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](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) for [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) will prefetch memory to GPU specified by device ordinal [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) 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](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) as [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) will prefetch data to host memory. Applications can request prefetching memory to a specific host NUMA node by specifying
/// [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) for [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) and a valid host NUMA node id in [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) Users can also request prefetching memory to the host NUMA node closest to the current thread's CPU by specifying [cudaMemLocationTypeHostNumaCurrent](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0a3925690e32332c940cb726ef56a4258) for [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0). Note when [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is etiher [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) OR [cudaMemLocationTypeHostNumaCurrent](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0a3925690e32332c940cb726ef56a4258), [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) will be ignored.
///
/// The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU
/// page size before the prefetch operation is enqueued in the stream.
///
/// If no physical memory has been allocated for this region, then this memory region will be populated and mapped on the destination
/// device. If there's insufficient memory to prefetch the desired region, the Unified Memory driver may evict pages from other
/// [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system.") 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](../cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1gaac8924b2f5a2a93f8775fb81c1a643f) as described below:
///
/// If [cudaMemAdviseSetReadMostly](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857441d911811beda174627f403142d5ff0) was set on any subset of this memory range, then that subset will create a read-only copy of the pages on destination location.
/// If however the destination location is a host NUMA node, then any pages of that subset that are already in another host NUMA
/// node will be transferred to the destination.
///
/// If [cudaMemAdviseSetPreferredLocation](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857a4a2bc3c7d218dcd9a1b425b432759eb) was called on any subset of this memory range, then the pages will be migrated to location even if location is not the preferred location of any pages in the memory range.
///
/// If [cudaMemAdviseSetAccessedBy](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c85750a22279bce0dc29956ad4f257084623) was called on any subset of this memory range, then mappings to those pages from all the appropriate processors are updated
/// to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared.
///
/// Note that this API is not required for functionality and only serves to improve performance by allowing the application to
/// migrate data to a suitable location before it is accessed. Memory accesses to this range are always coherent and are allowed
/// even when the data is actively being migrated.
///
/// Note that this function is asynchronous with respect to the host and all work on other devices.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpyPeer`], [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy3DPeerAsync`], [`cudaMemAdvise`], [cuMemPrefetchAsync](../cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1g45c0e085febc3be8fabf5c526355b6a3).
///
/// # Parameters
///
/// - `devPtr`: Pointer to be prefetched.
/// - `count`: Size in bytes.
/// - `location`: location to prefetch to.
/// - `flags`: flags for future use, must be zero now.
/// - `stream`: Stream to enqueue prefetch operation.
pub fn cudaMemPrefetchAsync(
devPtr: *const ::core::ffi::c_void,
count: size_t,
location: cudaMemLocation,
flags: ::core::ffi::c_uint,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # 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.
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;
}
unsafe extern "C" {
/// Performs a batch of memory discards asynchronously.
///
/// Performs a batch of memory discards. The batch as a whole executes in stream order but operations within a batch are not guaranteed
/// to execute in any specific order. All devices in the system must have a non-zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09) 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](high-level-api.md#group__CUDART__HIGHLEVEL_1g5b111f310ee71647377b78d37bc40d59 "Performs a batch of memory prefetches asynchronously."). 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](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system.") or declared via __managed__ variables or it may also refer to system-allocated memory when all devices have a non-zero value
/// for [cudaDevAttrPageableMemoryAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f).
///
/// # 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.
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;
}
unsafe extern "C" {
/// # 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.
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;
}
unsafe extern "C" {
/// Advise about the usage of a given memory range.
///
/// Advise the Unified Memory subsystem about the usage pattern for the memory range starting at devPtr with a size of count bytes. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned
/// to CPU page size before the advice is applied. The memory range must refer to managed memory allocated via [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system.") 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:
///
/// * [cudaMemAdviseSetReadMostly](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857441d911811beda174627f403142d5ff0): 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 [cudaDevAttrConcurrentManagedAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09). Also, if a context is created on a device that does not have the device attribute [cudaDevAttrConcurrentManagedAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09) 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 [cudaDevAttrPageableMemoryAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f) 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 [cudaDevAttrPageableMemoryAccessUsesHostPageTables](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc228cf8983c97d0e035da72a71494eaa), then setting this advice will not create a read-only copy when that device accesses this memory region.
///
/// * cudaMemAdviceUnsetReadMostly: Undoes the effect of [cudaMemAdviseSetReadMostly](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857441d911811beda174627f403142d5ff0) 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.
///
/// * [cudaMemAdviseSetPreferredLocation](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857a4a2bc3c7d218dcd9a1b425b432759eb): This advice sets the preferred location for the data to be the memory belonging to location. When [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5), [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) 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](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) to [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) and [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must specify the NUMA ID of the host NUMA node. If [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is set to [cudaMemLocationTypeHostNumaCurrent](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0a3925690e32332c940cb726ef56a4258), [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) 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](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is a [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), then [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must be a valid device ordinal and the device must have a non-zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09). 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 [cudaMemAdviseSetReadMostly](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857441d911811beda174627f403142d5ff0) 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 [cudaMemAdviseSetReadMostly](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857441d911811beda174627f403142d5ff0). If the memory region refers to valid system-allocated pageable memory, and [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) then [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must be a valid device that has a non-zero alue for the device attribute [cudaDevAttrPageableMemoryAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f).
///
/// * [cudaMemAdviseUnsetPreferredLocation](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857537caa36d8dddd3cedee0b2de7b74322): Undoes the effect of [cudaMemAdviseSetPreferredLocation](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857a4a2bc3c7d218dcd9a1b425b432759eb) and changes the preferred location to none. The location argument is ignored for this advice.
///
/// * [cudaMemAdviseSetAccessedBy](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c85750a22279bce0dc29956ad4f257084623): This advice implies that the data will be accessed by processor location. The [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) must be either [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) with [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) representing a valid device ordinal or [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) and [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) will be ignored. All other location types are invalid. If [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) is a GPU, then the device attribute [cudaDevAttrConcurrentManagedAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09) 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 [cudaMemAdviseSetAccessedBy](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c85750a22279bce0dc29956ad4f257084623) flag set for this data will now have its mapping updated to point to the page in host memory. If [cudaMemAdviseSetReadMostly](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857441d911811beda174627f403142d5ff0) 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 [CU_MEM_ADVISE_SET_PREFERRED_LOCATION](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1ggcfe2ed2d4567745dd4ad41034136fff3ddee285dc5e0e7d26469009ffd583cea) will override the policies of this advice. If the memory region refers to valid system-allocated pageable memory, and [cudaMemLocation::type](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) then device in [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must have a non-zero value for the device attribute [cudaDevAttrPageableMemoryAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f). Additionally, if [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) has a non-zero value for the device attribute [cudaDevAttrPageableMemoryAccessUsesHostPageTables](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc228cf8983c97d0e035da72a71494eaa), then this call has no effect.
///
/// * [CU_MEM_ADVISE_UNSET_ACCESSED_BY](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1ggcfe2ed2d4567745dd4ad41034136fff3f8118635c5f39d76432654ec13a726a5): Undoes the effect of [cudaMemAdviseSetAccessedBy](types.md#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c85750a22279bce0dc29956ad4f257084623). 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](structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) then device in [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must have a non-zero value for the device attribute [cudaDevAttrPageableMemoryAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f). Additionally, if [cudaMemLocation::id](structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) has a non-zero value for the device attribute [cudaDevAttrPageableMemoryAccessUsesHostPageTables](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc228cf8983c97d0e035da72a71494eaa), then this call has no effect.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpyPeer`], [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy3DPeerAsync`], [`cudaMemPrefetchAsync`], [cuMemAdvise](../cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1gaac8924b2f5a2a93f8775fb81c1a643f).
///
/// # Parameters
///
/// - `devPtr`: Pointer to memory to set the advice for.
/// - `count`: Size in bytes of the memory range.
/// - `advice`: Advice to be applied for the specified memory range.
/// - `location`: location to apply the advice for.
pub fn cudaMemAdvise(
devPtr: *const ::core::ffi::c_void,
count: size_t,
advice: cudaMemoryAdvise,
location: cudaMemLocation,
) -> cudaError_t;
}
unsafe extern "C" {
/// Query an attribute of a given memory range.
///
/// Query an attribute about the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system.") or declared via __managed__ variables.
///
/// The attribute parameter can take the following values:
///
/// * [cudaMemRangeAttributeReadMostly](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3794afd2109d3b8be3e1dd0fdfeed1275ee): 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.
/// * [cudaMemRangeAttributePreferredLocation](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a37946c596738ff234fa4c82859349e698f7): 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.
/// * [cudaMemRangeAttributeAccessedBy](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3790cbc6164d35671ca02e1b0813a8b7b20): 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.
/// * [cudaMemRangeAttributeLastPrefetchLocation](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3794e9e1521833d7ff0a4dcfbd2f6304592): 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.
/// * [cudaMemRangeAttributePreferredLocationType](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a379f2a7a75f029a9066e3cfea932c4870da): If this attribute is specified, data will be interpreted as a [cudaMemLocationType](#cudaMemLocationType), and dataSize must be sizeof(cudaMemLocationType). The [cudaMemLocationType](#cudaMemLocationType) returned will be [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) if all pages in the memory range have the same GPU as their preferred location, or [cudaMemLocationType](#cudaMemLocationType) will be [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) if all pages in the memory range have the CPU as their preferred location, or or it will be [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) 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.
/// + [cudaMemRangeAttributePreferredLocationId](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3794b4222e06b1067f90ffd9e1b250ce184): If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. If the [cudaMemRangeAttributePreferredLocationType](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a379f2a7a75f029a9066e3cfea932c4870da) query for the same address range returns [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), it will be a valid device ordinal or if it returns [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0), it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored.
/// * [cudaMemRangeAttributeLastPrefetchLocationType](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a379f68f9fab3cfdeb75d08e8b129bdd6762): If this attribute is specified, data will be interpreted as a [cudaMemLocationType](#cudaMemLocationType), 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](../cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1g45c0e085febc3be8fabf5c526355b6a3). The [cudaMemLocationType](#cudaMemLocationType) returned will be [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) if the last prefetch location was the GPU or [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) if it was the CPU or [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) 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](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1g75cfd5b9fa5c1c6ee2be2547bfbe882e) 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.
/// + [cudaMemRangeAttributeLastPrefetchLocationId](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a37919d650ef233ba3b126447b0b21cc6a96): If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. If the [cudaMemRangeAttributeLastPrefetchLocationType](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a379f68f9fab3cfdeb75d08e8b129bdd6762) query for the same address range returns [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), it will be a valid device ordinal or if it returns [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0), it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemRangeGetAttributes`], [`cudaMemPrefetchAsync`], [`cudaMemAdvise`], [cuMemRangeGetAttribute](../cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1g1c92408a7d0d8875e19b1a58af56f67d).
///
/// # Parameters
///
/// - `data`: A pointers to a memory location where the result of each attribute query will be written to.
/// - `dataSize`: Array containing the size of data.
/// - `attribute`: The attribute to query.
/// - `devPtr`: Start of the range to query.
/// - `count`: Size of the range to query.
pub fn cudaMemRangeGetAttribute(
data: *mut ::core::ffi::c_void,
dataSize: size_t,
attribute: cudaMemRangeAttribute,
devPtr: *const ::core::ffi::c_void,
count: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Query attributes of a given memory range.
///
/// Query attributes of the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via [cudaMallocManaged](high-level-api.md#group__CUDART__HIGHLEVEL_1gcf6b9b1019e73c5bc2b39b39fe90816e "Allocates memory that will be automatically managed by the Unified Memory system.") 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.
///
/// * [cudaMemRangeAttributeReadMostly](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3794afd2109d3b8be3e1dd0fdfeed1275ee)
/// * [cudaMemRangeAttributePreferredLocation](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a37946c596738ff234fa4c82859349e698f7)
/// * [cudaMemRangeAttributeAccessedBy](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3790cbc6164d35671ca02e1b0813a8b7b20)
/// * [cudaMemRangeAttributeLastPrefetchLocation](types.md#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3794e9e1521833d7ff0a4dcfbd2f6304592)
/// * :: cudaMemRangeAttributePreferredLocationType
/// * :: cudaMemRangeAttributePreferredLocationId
/// * :: cudaMemRangeAttributeLastPrefetchLocationType
/// * :: cudaMemRangeAttributeLastPrefetchLocationId
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemRangeGetAttribute`], [`cudaMemAdvise`], [`cudaMemPrefetchAsync`], [cuMemRangeGetAttributes](../cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1gc7ce142e60f8613cfb7d722b87dc9d12).
///
/// # Parameters
///
/// - `data`: A two-dimensional array containing pointers to memory locations where the result of each attribute query will be written
/// to.
/// - `dataSizes`: Array containing the sizes of each result.
/// - `attributes`: An array of attributes to query (numAttributes and the number of attributes in this array should match).
/// - `numAttributes`: Number of attributes to query.
/// - `devPtr`: Start of the range to query.
/// - `count`: Size of the range to query.
pub fn cudaMemRangeGetAttributes(
data: *mut *mut ::core::ffi::c_void,
dataSizes: *mut size_t,
attributes: *mut cudaMemRangeAttribute,
numAttributes: size_t,
devPtr: *const ::core::ffi::c_void,
count: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Copies data between host and device.
///
/// count
///
/// src
///
/// dst
///
/// hOffset
///
/// wOffset
///
/// kind
///
/// [cudaMemcpyHostToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7)
///
/// [cudaMemcpyHostToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568)
///
/// [cudaMemcpyDeviceToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253)
///
/// [cudaMemcpyDeviceToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpyHtoA](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g57d3d780d165ecc0e3b3ce08e141cd89), [cuMemcpyDtoA](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gad6827247af91600b56ce6e2ddb802e1).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffset`: Destination starting X offset (columns in bytes).
/// - `hOffset`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
#[deprecated]
pub fn cudaMemcpyToArray(
dst: cudaArray_t,
wOffset: size_t,
hOffset: size_t,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// Copies data between host and device.
///
/// count
///
/// src
///
/// hOffset
///
/// wOffset
///
/// dst
///
/// kind
///
/// [cudaMemcpyHostToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7)
///
/// [cudaMemcpyHostToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568)
///
/// [cudaMemcpyDeviceToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253)
///
/// [cudaMemcpyDeviceToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [synchronous](api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpyAtoH](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf7ad1edb2539cccc352c6b8b76f657f4), [cuMemcpyAtoD](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g825b3f037f7f51382cae991bae8173fd).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `wOffset`: Source starting X offset (columns in bytes).
/// - `hOffset`: Source starting Y offset (rows).
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
#[deprecated]
pub fn cudaMemcpyFromArray(
dst: *mut ::core::ffi::c_void,
src: cudaArray_const_t,
wOffset: size_t,
hOffset: size_t,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// Copies data between host and device.
///
/// count
///
/// src
///
/// hOffsetSrc
///
/// wOffsetSrc
///
/// dst
///
/// hOffsetDst
///
/// wOffsetDst
///
/// kind
///
/// [cudaMemcpyHostToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7)
///
/// [cudaMemcpyHostToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568)
///
/// [cudaMemcpyDeviceToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253)
///
/// [cudaMemcpyDeviceToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpyAtoA](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf81b218c984a31436ec9e23a85fb604a).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffsetDst`: Destination starting X offset (columns in bytes).
/// - `hOffsetDst`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `wOffsetSrc`: Source starting X offset (columns in bytes).
/// - `hOffsetSrc`: Source starting Y offset (rows).
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
#[deprecated]
pub fn cudaMemcpyArrayToArray(
dst: cudaArray_t,
wOffsetDst: size_t,
hOffsetDst: size_t,
src: cudaArray_const_t,
wOffsetSrc: size_t,
hOffsetSrc: size_t,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// Copies data between host and device.
///
/// count
///
/// src
///
/// dst
///
/// hOffset
///
/// wOffset
///
/// kind
///
/// [cudaMemcpyHostToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7)
///
/// [cudaMemcpyHostToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568)
///
/// [cudaMemcpyDeviceToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253)
///
/// [cudaMemcpyDeviceToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [`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 [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568) or [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253) and stream is non-zero, the copy may overlap with operations in other streams.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpyHtoAAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gb5c4863f64f132b4bc2661818b3fd188), [cuMemcpy2DAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `wOffset`: Destination starting X offset (columns in bytes).
/// - `hOffset`: Destination starting Y offset (rows).
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
#[deprecated]
pub fn cudaMemcpyToArrayAsync(
dst: cudaArray_t,
wOffset: size_t,
hOffset: size_t,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Copies data between host and device.
///
/// count
///
/// src
///
/// hOffset
///
/// wOffset
///
/// dst
///
/// kind
///
/// [cudaMemcpyHostToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7)
///
/// [cudaMemcpyHostToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568)
///
/// [cudaMemcpyDeviceToHost](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253)
///
/// [cudaMemcpyDeviceToDevice](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [cudaMemcpyDefault](group__CUDART__TYPES.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a)
///
/// [`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 [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568) or [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253) and stream is non-zero, the copy may overlap with operations in other streams.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function exhibits [asynchronous](api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [cudaMemcpyToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g4561bf9c99d91c92684a91a0bd356bfe "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g99db510d18d37fbb0f5c075a8caf3b5f "[C++ API] Copies data from the given symbol on the device"), [cudaMemcpyAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g82d9453206dce593f007c64e60bae45a "Performs a memory copy asynchronously. Allows specifying attributes for the copy."), [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [cudaMemcpyToSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1gd00b41ade29161aafbf6ff8aee3d6eb5 "[C++ API] Copies data to the given symbol on the device"), [cudaMemcpyFromSymbolAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1g2d9f7a440f1e522555dfe994245a5946 "[C++ API] Copies data from the given symbol on the device"), [cuMemcpyAtoHAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g64cbd2e60436699aebdd0bdbf14d0f01), [cuMemcpy2DAsync](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
///
/// # Parameters
///
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `wOffset`: Source starting X offset (columns in bytes).
/// - `hOffset`: Source starting Y offset (rows).
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
/// - `stream`: Stream identifier.
#[deprecated]
pub fn cudaMemcpyFromArrayAsync(
dst: *mut ::core::ffi::c_void,
src: cudaArray_const_t,
wOffset: size_t,
hOffset: size_t,
count: size_t,
kind: cudaMemcpyKind,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `devPtr`: Returned device pointer.
/// - `size`: Number of bytes to allocate.
/// - `hStream`: The stream establishing the stream ordering contract and the memory pool to allocate from.
pub fn cudaMallocAsync(
devPtr: *mut *mut ::core::ffi::c_void,
size: size_t,
hStream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Frees memory with stream ordered semantics.
///
/// Inserts a free operation into hStream. The allocation must not be accessed after stream execution reaches the free. After this API returns, accessing the memory
/// from any subsequent work launched on the GPU or querying its pointer attributes results in undefined behavior.
///
/// Note:
///
/// During stream capture, this function results in the creation of a free node and must therefore be passed the address of a
/// graph allocation.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuMemFreeAsync](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g41acf4131f672a2a75cd93d3241f10cf), [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool.")
///
/// # Parameters
///
/// - `hStream`: The stream establishing the stream ordering promise.
pub fn cudaFreeAsync(
devPtr: *mut ::core::ffi::c_void,
hStream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Tries to release memory back to the OS.
///
/// Releases memory back to the OS until the pool contains fewer than minBytesToKeep reserved bytes, or there is no more memory
/// that the allocator can safely release. The allocator cannot release OS allocations that back outstanding asynchronous allocations.
/// The OS allocations may happen at different granularity from the user allocations.
///
/// Note:
///
/// * : Allocations that have not been freed count as outstanding.
/// * : Allocations that have been asynchronously freed but whose completion has not been observed on the host (eg. by a synchronize)
/// can count as outstanding.
///
/// Note:
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuMemPoolTrimTo](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g9c7e267e3460945b0ca76c48314bb669), [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`]
///
/// # Parameters
///
/// - `minBytesToKeep`: If the pool has less than minBytesToKeep reserved, the TrimTo operation is a no-op. Otherwise the pool will be guaranteed
/// to have at least minBytesToKeep bytes reserved after the operation.
pub fn cudaMemPoolTrimTo(
memPool: cudaMemPool_t,
minBytesToKeep: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets attributes of a memory pool.
///
/// Supported attributes are:
///
/// * [cudaMemPoolAttrReleaseThreshold](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03e0451f4d34d8f3c418882b3ba5259f37): (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)
/// * [cudaMemPoolReuseFollowEventDependencies](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03d75287b5752ea45a3d98b9a339f797ce): (value type = int) Allow [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool.") 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)
/// * [cudaMemPoolReuseAllowOpportunistic](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03858390d544051a61033a05e1a4005d01): (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default
/// enabled)
/// * [cudaMemPoolReuseAllowInternalDependencies](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a031a545a7d23c103583900e784360f9d2a): (value type = int) Allow [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool.") to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released
/// by [`cudaFreeAsync`] (default enabled).
/// * [cudaMemPoolAttrReservedMemHigh](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a035cd74d683873f75a8b4bd27b7511d9fc): (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.
/// * [cudaMemPoolAttrUsedMemHigh](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03eb9b02506f4844de4ea40f01538bc85c): (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:
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuMemPoolSetAttribute](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g223e786cb217709235a06e41bccaec00), [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`]
///
/// # Parameters
///
/// - `attr`: The attribute to modify.
/// - `value`: Pointer to the value to assign.
pub fn cudaMemPoolSetAttribute(
memPool: cudaMemPool_t,
attr: cudaMemPoolAttr,
value: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// Gets attributes of a memory pool.
///
/// Supported attributes are:
///
/// * [cudaMemPoolAttrReleaseThreshold](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03e0451f4d34d8f3c418882b3ba5259f37): (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)
/// * [cudaMemPoolReuseFollowEventDependencies](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03d75287b5752ea45a3d98b9a339f797ce): (value type = int) Allow [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool.") 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)
/// * [cudaMemPoolReuseAllowOpportunistic](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03858390d544051a61033a05e1a4005d01): (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default
/// enabled)
/// * [cudaMemPoolReuseAllowInternalDependencies](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a031a545a7d23c103583900e784360f9d2a): (value type = int) Allow [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool.") to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released
/// by [`cudaFreeAsync`] (default enabled).
/// * [cudaMemPoolAttrReservedMemCurrent](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03accd25158875da327b34d1ee63847b02): (value type = cuuint64_t) Amount of backing memory currently allocated for the mempool.
/// * [cudaMemPoolAttrReservedMemHigh](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a035cd74d683873f75a8b4bd27b7511d9fc): (value type = cuuint64_t) High watermark of backing memory allocated for the mempool since the last time it was reset.
/// * [cudaMemPoolAttrUsedMemCurrent](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03627447991490641c9fcacbfe7b54c5a4): (value type = cuuint64_t) Amount of memory from the pool that is currently in use by the application.
/// * [cudaMemPoolAttrUsedMemHigh](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03eb9b02506f4844de4ea40f01538bc85c): (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:
///
/// * [cudaMemPoolAttrAllocationType](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03eedb98c7c000df951f3d36501a829311): (value type = cudaMemAllocationType) The allocation type of the mempool
/// * [cudaMemPoolAttrExportHandleTypes](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a0364fa069d99766b22111d97e9d3d37e1b): (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
/// * [cudaMemPoolAttrLocationId](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a035867500cd6840751dbeca2d5ff4c638d): (value type = int) The location id for the mempool. If the location type for this pool is cudaMemLocationTypeInvisible then
/// ID will be cudaInvalidDeviceId.
/// * [cudaMemPoolAttrLocationType](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03e53307bbf1d2af20fe4411ae7deba1fe): (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.
/// * [cudaMemPoolAttrMaxPoolSize](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03799958957449f066faf0677ab8a6169e): (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.
/// * [cudaMemPoolAttrHwDecompressEnabled](types.md#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a032c3f8c11ad000a47eca679c2f33ce53b): (value type = int) Indicates whether the pool has hardware compresssion enabled
///
/// Note:
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuMemPoolGetAttribute](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gd45ea7c43e4a1add4b971d06fa72eda4), [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`]
///
/// # Parameters
///
/// - `attr`: The attribute to get.
/// - `value`: Retrieved value.
pub fn cudaMemPoolGetAttribute(
memPool: cudaMemPool_t,
attr: cudaMemPoolAttr,
value: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// Controls visibility of pools between devices.
///
/// **See also:**
///
/// [cuMemPoolSetAccess](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gff3ce33e252443f4b087b94e42913406), [`cudaMemPoolGetAccess`], [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`]
///
/// # Parameters
///
/// - `count`: Number of descriptors in the map array.
pub fn cudaMemPoolSetAccess(
memPool: cudaMemPool_t,
descList: *const cudaMemAccessDesc,
count: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the accessibility of a pool from a device.
///
/// Returns the accessibility of the pool's memory from the specified location.
///
/// **See also:**
///
/// [cuMemPoolGetAccess](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g838f28fd535a1cbd06c5f7fe0edbdcc7), [`cudaMemPoolSetAccess`]
///
/// # Parameters
///
/// - `flags`: the accessibility of the pool from the specified location.
/// - `memPool`: the pool being queried.
/// - `location`: the location accessing the pool.
pub fn cudaMemPoolGetAccess(
flags: *mut cudaMemAccessFlags,
memPool: cudaMemPool_t,
location: *mut cudaMemLocation,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates a memory pool.
///
/// Creates a CUDA memory pool and returns the handle in pool. The poolProps determines the properties of the pool such as the backing device and IPC capabilities.
///
/// To create a memory pool for host memory not targeting a specific NUMA node, applications must set set cudaMemPoolProps::cudaMemLocation::type
/// to [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5). cudaMemPoolProps::cudaMemLocation::id is ignored for such pools. Pools created with the type [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) are not IPC capable and [cudaMemPoolProps::handleTypes](structcudaMemPoolProps.html#structcudaMemPoolProps_14cf896bffe71384e374c4d2decca9a53) must be 0, any other values will result in [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c). To create a memory pool targeting a specific host NUMA node, applications must set cudaMemPoolProps::cudaMemLocation::type
/// to [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) and cudaMemPoolProps::cudaMemLocation::id must specify the NUMA ID of the host memory node. Specifying [cudaMemLocationTypeHostNumaCurrent](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0a3925690e32332c940cb726ef56a4258) as the cudaMemPoolProps::cudaMemLocation::type will result in [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c). By default, the pool's memory will be accessible from the device it is allocated on. In the case of pools created with [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) or [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5), 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](structcudaMemPoolProps.html#structcudaMemPoolProps_12d90e82afb8d577a2aee847d082e145d). If set to 0, the maximum size of the pool will default to a system dependent value.
///
/// Applications that intend to use [CU_MEM_HANDLE_TYPE_FABRIC](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1gg450a23153d86fce0afe30e25d63caef9e38a182adb450da6c1a3f29cd5dca032) 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](#cudaMemPoolProps):cudaMemAllocationType to [cudaMemAllocationTypeManaged](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a3c9f3c6dab46c6c9cf547aba7fe021c0f). [cudaMemPoolProps::cudaMemAllocationHandleType](#cudaMemAllocationHandleType) must also be set to [cudaMemHandleTypeNone](types.md#group__CUDART__TYPES_1ggabde707dfb8a602b917e0b177f77f365fed45251c1591431e1b9da28c1a04191) since IPC is not supported. For managed memory pools, cudaMemPoolProps::cudaMemLocation will be treated as the preferred
/// location for all allocations created from the pool. An application can also set [cudaMemLocationTypeNone](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f053b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location. [cudaMemPoolProps::maxSize](structcudaMemPoolProps.html#structcudaMemPoolProps_12d90e82afb8d577a2aee847d082e145d) must be set to zero for managed memory pools. [cudaMemPoolProps::usage](structcudaMemPoolProps.html#structcudaMemPoolProps_1377241affe79dd0a3c7b40453824bd6b) should be zero as decompress for managed memory is not supported. For managed memory pools, all devices on the system must
/// have non-zero concurrentManagedAccess. If not, this call returns [cudaErrorNotSupported](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d846fd9f2e8ba5e2fb4f1695b7ab6164)
///
/// Note:
///
/// Specifying [cudaMemHandleTypeNone](types.md#group__CUDART__TYPES_1ggabde707dfb8a602b917e0b177f77f365fed45251c1591431e1b9da28c1a04191) creates a memory pool that will not support IPC.
///
/// **See also:**
///
/// [cuMemPoolCreate](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g8aa4c143dbc20293659cd883232b95f2), [`cudaDeviceSetMemPool`], [`cudaMallocFromPoolAsync`], [`cudaMemPoolExportToShareableHandle`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`]
pub fn cudaMemPoolCreate(
memPool: *mut cudaMemPool_t,
poolProps: *const cudaMemPoolProps,
) -> cudaError_t;
}
unsafe extern "C" {
/// Destroys the specified memory pool.
///
/// If any pointers obtained from this pool haven't been freed or the pool has free operations that haven't completed when [`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.
///
/// **See also:**
///
/// [cuMemPoolDestroy](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1ge0e211115e5ad1c79250b9dd425b77f7), [`cudaFreeAsync`], [`cudaDeviceSetMemPool`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`]
pub fn cudaMemPoolDestroy(memPool: cudaMemPool_t) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the default memory pool for a given location and allocation type.
///
/// The memory location can be of one of [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) or [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0). The allocation type can be one of [cudaMemAllocationTypePinned](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a38caa8664e92a198cb429c7a5f2e49c6e) or [cudaMemAllocationTypeManaged](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a3c9f3c6dab46c6c9cf547aba7fe021c0f). When the allocation type is [cudaMemAllocationTypeManaged](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a3c9f3c6dab46c6c9cf547aba7fe021c0f), the location type can also be [cudaMemLocationTypeNone](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f053b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location for the managed memory pool. In all other cases, the call return [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c)
///
/// **See also:**
///
/// [cuMemAllocAsync](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g13413273e84a641bce1929eae9e6501f), [cuMemPoolTrimTo](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g9c7e267e3460945b0ca76c48314bb669), [cuMemPoolGetAttribute](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gd45ea7c43e4a1add4b971d06fa72eda4), [cuMemPoolSetAttribute](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g223e786cb217709235a06e41bccaec00), [cuMemPoolSetAccess](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gff3ce33e252443f4b087b94e42913406), [cuMemGetMemPool](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g5283d28ee187477e1a2b06fd731ec575), [cuMemPoolCreate](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g8aa4c143dbc20293659cd883232b95f2).
pub fn cudaMemGetDefaultMemPool(
memPool: *mut cudaMemPool_t,
location: *mut cudaMemLocation,
type_: cudaMemAllocationType,
) -> cudaError_t;
}
unsafe extern "C" {
/// Gets the current memory pool for a given memory location and allocation type.
///
/// The memory location can be of one of [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) or [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0). The allocation type can be one of [cudaMemAllocationTypePinned](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a38caa8664e92a198cb429c7a5f2e49c6e) or [cudaMemAllocationTypeManaged](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a3c9f3c6dab46c6c9cf547aba7fe021c0f). When the allocation type is [cudaMemAllocationTypeManaged](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a3c9f3c6dab46c6c9cf547aba7fe021c0f), the location type can also be [cudaMemLocationTypeNone](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f053b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location for the managed memory pool. In all other cases, the call return [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c)
///
/// 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`].
///
/// **See also:**
///
/// [cuDeviceGetDefaultMemPool](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gc8bca3c97a78816303b8aa5773b741f2), [cuMemPoolCreate](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g8aa4c143dbc20293659cd883232b95f2), [cuDeviceSetMemPool](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g4f2f276b84d9c2eaefdc76d6274db4a0), [cuMemSetMemPool](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g779e76c810c5f088210ea907730e17c9).
pub fn cudaMemGetMemPool(
memPool: *mut cudaMemPool_t,
location: *mut cudaMemLocation,
type_: cudaMemAllocationType,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the current memory pool for a memory location and allocation type.
///
/// The memory location can be of one of [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), [cudaMemLocationTypeHost](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) or [cudaMemLocationTypeHostNuma](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0). The allocation type can be one of [cudaMemAllocationTypePinned](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a38caa8664e92a198cb429c7a5f2e49c6e) or [cudaMemAllocationTypeManaged](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a3c9f3c6dab46c6c9cf547aba7fe021c0f). When the allocation type is [cudaMemAllocationTypeManaged](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a3c9f3c6dab46c6c9cf547aba7fe021c0f), the location type can also be [cudaMemLocationTypeNone](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f053b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location for the managed memory pool. In all other cases, the call return [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c)
///
/// When a memory pool is set as the current memory pool, the location parameter should be the same as the location of the pool.
/// If the location type or index don't match, the call returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c). The type of memory pool should also match the parameter allocType. Else the call returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c). By default, a memory location's current memory pool is its default memory pool. If the location type is [cudaMemLocationTypeDevice](types.md#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) and the allocation type is [cudaMemAllocationTypePinned](types.md#group__CUDART__TYPES_1gg5cb1470491e08d2c67e9efd3fb5da9a38caa8664e92a198cb429c7a5f2e49c6e), 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.
///
/// **See also:**
///
/// [cuDeviceGetDefaultMemPool](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gc8bca3c97a78816303b8aa5773b741f2), [cuDeviceGetMemPool](../cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gdf186e9559d53a5eb18e572d48c1121b), [cuMemGetMemPool](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g5283d28ee187477e1a2b06fd731ec575), [cuMemPoolCreate](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g8aa4c143dbc20293659cd883232b95f2), [cuMemPoolDestroy](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1ge0e211115e5ad1c79250b9dd425b77f7), [cuMemAllocFromPoolAsync](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gf1dd6e1e2e8f767a5e0ea63f38ff260b).
pub fn cudaMemSetMemPool(
location: *mut cudaMemLocation,
type_: cudaMemAllocationType,
memPool: cudaMemPool_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Allocates memory from a specified pool with stream ordered semantics.
///
/// Inserts an allocation operation into hStream. A pointer to the allocated memory is returned immediately in \*dptr. The allocation must not be accessed until the the allocation
/// operation completes. The allocation comes from the specified memory pool.
///
/// Note:
///
/// * The specified memory pool may be from a device different than that of the specified hStream.
///
/// * Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize,
/// and CUDA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream
/// runs.
///
/// Note:
///
/// During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned
/// by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters.
///
/// **See also:**
///
/// [cuMemAllocFromPoolAsync](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gf1dd6e1e2e8f767a5e0ea63f38ff260b), [cudaMallocAsync ( C++ API)](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaMemPoolCreate`], [`cudaMemPoolSetAccess`], [`cudaMemPoolSetAttribute`]
///
/// # Parameters
///
/// - `ptr`: Returned device pointer.
/// - `memPool`: The pool to allocate from.
/// - `stream`: The stream establishing the stream ordering semantic.
pub fn cudaMallocFromPoolAsync(
ptr: *mut *mut ::core::ffi::c_void,
size: size_t,
memPool: cudaMemPool_t,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Exports a memory pool to the requested handle type.
///
/// Given an IPC capable mempool, create an OS handle to share the pool with another process. A recipient process can convert
/// the shareable handle into a mempool with [`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.
///
/// **See also:**
///
/// [cuMemPoolExportToShareableHandle](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g79ed285fdfffb76932871fb96fbba8f8), [`cudaMemPoolImportFromShareableHandle`], [`cudaMemPoolExportPointer`], [`cudaMemPoolImportPointer`]
///
/// # Parameters
///
/// - `handleType`: the type of handle to create.
/// - `flags`: must be 0.
pub fn cudaMemPoolExportToShareableHandle(
shareableHandle: *mut ::core::ffi::c_void,
memPool: cudaMemPool_t,
handleType: cudaMemAllocationHandleType,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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.
///
/// **See also:**
///
/// [cuMemPoolImportFromShareableHandle](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g02b4f18dd8a1c45b7f302800e90cec5b), [`cudaMemPoolExportToShareableHandle`], [`cudaMemPoolExportPointer`], [`cudaMemPoolImportPointer`]
///
/// # Parameters
///
/// - `handleType`: The type of handle being imported.
/// - `flags`: must be 0.
pub fn cudaMemPoolImportFromShareableHandle(
memPool: *mut cudaMemPool_t,
shareableHandle: *mut ::core::ffi::c_void,
handleType: cudaMemAllocationHandleType,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Export data to share a memory pool allocation between processes.
///
/// Constructs shareData_out for sharing a specific allocation from an already shared memory pool. The recipient process can import the allocation with
/// the [`cudaMemPoolImportPointer`] api. The data is not a handle and may be shared through any IPC mechanism.
///
/// **See also:**
///
/// [cuMemPoolExportPointer](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gfe89f0478d26edaa91eb8a2e0349329d), [`cudaMemPoolExportToShareableHandle`], [`cudaMemPoolImportFromShareableHandle`], [`cudaMemPoolImportPointer`]
///
/// # Parameters
///
/// - `ptr`: pointer to memory being exported.
pub fn cudaMemPoolExportPointer(
exportData: *mut cudaMemPoolPtrExportData,
ptr: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// Import a memory pool allocation from another process.
///
/// Returns in ptr_out a pointer to the imported memory. The imported memory must not be accessed before the allocation operation completes in the
/// exporting process. The imported memory must be freed from all importing processes before being freed in the exporting process.
/// The pointer may be freed with 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`].
///
/// **See also:**
///
/// [cuMemPoolImportPointer](../cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g2620bb972ed5edcce312d3689454acbd), [`cudaMemPoolExportToShareableHandle`], [`cudaMemPoolImportFromShareableHandle`], [`cudaMemPoolExportPointer`]
pub fn cudaMemPoolImportPointer(
ptr: *mut *mut ::core::ffi::c_void,
memPool: cudaMemPool_t,
exportData: *mut cudaMemPoolPtrExportData,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns attributes about a specified pointer.
///
/// Returns in \*attributes the attributes of the pointer ptr. If pointer was not allocated in, mapped by or registered with context supporting unified addressing [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// Note:
///
/// In CUDA 11.0 forward passing host pointer will return [cudaMemoryTypeUnregistered](types.md#group__CUDART__TYPES_1gg13de56a8fe75569530ecc3a3106e9b6d842e996720bbf9b4d3c416abd86e15f4) in [cudaPointerAttributes::type](structcudaPointerAttributes.html#structcudaPointerAttributes_191ef95dac597cc710558dabbc8b9ae38) and call will return [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591).
///
/// The [cudaPointerAttributes](#cudaPointerAttributes) structure is defined as:
///
/// ```text
/// struct cudaPointerAttributes {
/// enum cudaMemoryType
/// type;
/// int device;
/// void *devicePointer;
/// void *hostPointer;
/// }
/// ```
///
/// * [cudaPointerAttributes::type](structcudaPointerAttributes.html#structcudaPointerAttributes_191ef95dac597cc710558dabbc8b9ae38) identifies type of memory. It can be [cudaMemoryTypeUnregistered](types.md#group__CUDART__TYPES_1gg13de56a8fe75569530ecc3a3106e9b6d842e996720bbf9b4d3c416abd86e15f4) for unregistered host memory, [cudaMemoryTypeHost](types.md#group__CUDART__TYPES_1gg13de56a8fe75569530ecc3a3106e9b6d9aa7478ab438d2dfb710c9100194a5be) for registered host memory, [cudaMemoryTypeDevice](types.md#group__CUDART__TYPES_1gg13de56a8fe75569530ecc3a3106e9b6d30c8466dd99563e4b1a43dd27bf7c743) for device memory or [cudaMemoryTypeManaged](types.md#group__CUDART__TYPES_1gg13de56a8fe75569530ecc3a3106e9b6dbb20a4b61c559a4e7629fe60ac04b84e) for managed memory.
///
/// * [device](structcudaPointerAttributes.html#structcudaPointerAttributes_120015540684b0c85e0debf64923bedec) is the device against which ptr was allocated. If ptr has memory type [cudaMemoryTypeDevice](types.md#group__CUDART__TYPES_1gg13de56a8fe75569530ecc3a3106e9b6d30c8466dd99563e4b1a43dd27bf7c743) then this identifies the device on which the memory referred to by ptr physically resides. If ptr has memory type [cudaMemoryTypeHost](types.md#group__CUDART__TYPES_1gg13de56a8fe75569530ecc3a3106e9b6d9aa7478ab438d2dfb710c9100194a5be) 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](structcudaPointerAttributes.html#structcudaPointerAttributes_19edc9782e1ee337072994780fd3b675f) 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](structcudaPointerAttributes.html#structcudaPointerAttributes_119cbae18cd685096287e41cce1c9a087) 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.
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaChooseDevice`], [`cudaInitDevice`], [cuPointerGetAttributes](../cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1gf65e9ea532e311dd049166e4894955ad).
///
/// # Parameters
///
/// - `attributes`: Attributes for the specified pointer.
/// - `ptr`: Pointer to get attributes for.
pub fn cudaPointerGetAttributes(
attributes: *mut cudaPointerAttributes,
ptr: *const ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceEnablePeerAccess`], [`cudaDeviceDisablePeerAccess`], [cuDeviceCanAccessPeer](../cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g496bdaae1f632ebfb695b99d2c40f19e).
///
/// # Parameters
///
/// - `canAccessPeer`: Returned access capability.
/// - `device`: Device from which allocations on peerDevice are to be directly accessed.
/// - `peerDevice`: Device on which the allocations to be directly accessed by device reside.
pub fn cudaDeviceCanAccessPeer(
canAccessPeer: *mut ::core::ffi::c_int,
device: ::core::ffi::c_int,
peerDevice: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Enables direct access to memory allocations on a peer device.
///
/// On success, all allocations from peerDevice will immediately be accessible by the current device. They will remain accessible until access is explicitly disabled using
/// [`cudaDeviceDisablePeerAccess`] or either device is reset using [`cudaDeviceReset`].
///
/// Note that access granted by this call is unidirectional and that in order to access memory on the current device from peerDevice, a separate symmetric call to [`cudaDeviceEnablePeerAccess`] is required.
///
/// Note that there are both device-wide and system-wide limitations per system configuration, as noted in the CUDA Programming
/// Guide under the section "Peer-to-Peer Memory Access".
///
/// Returns [cudaErrorInvalidDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a) if [`cudaDeviceCanAccessPeer`] indicates that the current device cannot directly access memory from peerDevice.
///
/// Returns [cudaErrorPeerAccessAlreadyEnabled](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00380bc28e8217afa14b95f907631cb84f33) if direct access of peerDevice from the current device has already been enabled.
///
/// Returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if flags is not 0.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceCanAccessPeer`], [`cudaDeviceDisablePeerAccess`], [cuCtxEnablePeerAccess](../cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g0889ec6728e61c05ed359551d67b3f5a).
///
/// # Parameters
///
/// - `peerDevice`: Peer device to enable direct access to from the current device.
/// - `flags`: Reserved for future use and must be set to 0.
pub fn cudaDeviceEnablePeerAccess(
peerDevice: ::core::ffi::c_int,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Disables direct access to memory allocations on a peer device.
///
/// Returns [cudaErrorPeerAccessNotEnabled](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038821b54bce59b87db6efc2ea59a867bf7) if direct access to memory on peerDevice has not yet been enabled from the current device.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceCanAccessPeer`], [`cudaDeviceEnablePeerAccess`], [cuCtxDisablePeerAccess](../cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g5b4b6936ea868d4954ce4d841a3b4810).
///
/// # Parameters
///
/// - `peerDevice`: Peer device to disable direct access to.
pub fn cudaDeviceDisablePeerAccess(peerDevice: ::core::ffi::c_int) -> cudaError_t;
}
unsafe extern "C" {
/// Unregisters a graphics resource for access by CUDA.
///
/// Unregisters the graphics resource resource so it is not accessible by CUDA unless registered again.
///
/// If resource is invalid then [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) is returned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [cudaGraphicsD3D9RegisterResource](#cudaGraphicsD3D9RegisterResource "Register a Direct3D 9 resource for access by CUDA."), [cudaGraphicsD3D10RegisterResource](#cudaGraphicsD3D10RegisterResource "Registers a Direct3D 10 resource for access by CUDA."), [cudaGraphicsD3D11RegisterResource](#cudaGraphicsD3D11RegisterResource "Register a Direct3D 11 resource for access by CUDA."), [cudaGraphicsGLRegisterBuffer](#cudaGraphicsGLRegisterBuffer "Registers an OpenGL buffer object."), [cudaGraphicsGLRegisterImage](#cudaGraphicsGLRegisterImage "Register an OpenGL texture or renderbuffer object."), [cuGraphicsUnregisterResource](../cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1ga7e5e97b74eaa13dfa6582e853e4c96d).
///
/// # Parameters
///
/// - `resource`: Resource to unregister.
pub fn cudaGraphicsUnregisterResource(
resource: cudaGraphicsResource_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Set usage flags for mapping a graphics resource.
///
/// Set flags for mapping the graphics resource resource.
///
/// Changes to flags will take effect the next time resource is mapped. The flags argument may be any of the following:
///
/// * [cudaGraphicsMapFlagsNone](types.md#group__CUDART__TYPES_1gg2c3c3a69caaf333d29d0b38b75de5ffd81ae074138583e9421692bec52bfe44b): Specifies no hints about how resource will be used. It is therefore assumed that CUDA may read from or write to resource.
/// * [cudaGraphicsMapFlagsReadOnly](types.md#group__CUDART__TYPES_1gg2c3c3a69caaf333d29d0b38b75de5ffde34096084cfafea1399b5682efd8b74c): Specifies that CUDA will not write to resource.
/// * [cudaGraphicsMapFlagsWriteDiscard](types.md#group__CUDART__TYPES_1gg2c3c3a69caaf333d29d0b38b75de5ffd3d4fa7699e964ffc201daac20d2ecd6b): 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 [cudaErrorUnknown](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. If flags is not one of the above values then [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphicsMapResources`], [cuGraphicsResourceSetMapFlags](../cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1gfe96aa7747f8b11d44a6fa6a851e1b39).
///
/// # Parameters
///
/// - `resource`: Registered resource to set flags for.
/// - `flags`: Parameters for resource mapping.
pub fn cudaGraphicsResourceSetMapFlags(
resource: cudaGraphicsResource_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Map graphics resources for access by CUDA.
///
/// Maps the count graphics resources in resources for access by CUDA.
///
/// The resources in resources may be accessed by CUDA until they are unmapped. The graphics API from which resources were registered should not access any resources while they are mapped by CUDA. If an application does so, the results are
/// undefined.
///
/// This function provides the synchronization guarantee that any graphics calls issued before [`cudaGraphicsMapResources`] will complete before any subsequent CUDA work issued in stream begins.
///
/// If resources contains any duplicate entries then [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) is returned. If any of resources are presently mapped for access by CUDA then [cudaErrorUnknown](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned.
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphicsResourceGetMappedPointer`], [`cudaGraphicsSubResourceGetMappedArray`], [`cudaGraphicsUnmapResources`], [cuGraphicsMapResources](../cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1gffcfd8e78d82cc4f6dd987e8bce4edb0).
///
/// # Parameters
///
/// - `count`: Number of resources to map.
/// - `resources`: Resources to map for CUDA.
/// - `stream`: Stream for synchronization.
pub fn cudaGraphicsMapResources(
count: ::core::ffi::c_int,
resources: *mut cudaGraphicsResource_t,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Unmap graphics resources.
///
/// Unmaps the count graphics resources in resources.
///
/// Once unmapped, the resources in resources may not be accessed by CUDA until they are mapped again.
///
/// This function provides the synchronization guarantee that any CUDA work issued in stream before [`cudaGraphicsUnmapResources`] will complete before any subsequently issued graphics work begins.
///
/// If resources contains any duplicate entries then [cudaErrorInvalidResourceHandle](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) is returned. If any of resources are not presently mapped for access by CUDA then [cudaErrorUnknown](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned.
///
/// Note:
///
/// * This function uses standard [default stream](stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphicsMapResources`], [cuGraphicsUnmapResources](../cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1g8e9ff25d071375a0df1cb5aee924af32).
///
/// # Parameters
///
/// - `count`: Number of resources to unmap.
/// - `resources`: Resources to unmap.
/// - `stream`: Stream for synchronization.
pub fn cudaGraphicsUnmapResources(
count: ::core::ffi::c_int,
resources: *mut cudaGraphicsResource_t,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Get an device pointer through which to access a mapped graphics resource.
///
/// Returns in \*devPtr a pointer through which the mapped graphics resource resource may be accessed. Returns in \*size the size of the memory in bytes which may be accessed from that pointer. The value set in devPtr may change every time that resource is mapped.
///
/// If resource is not a buffer then it cannot be accessed via a pointer and [cudaErrorUnknown](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. If resource is not mapped then [cudaErrorUnknown](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. \*
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphicsMapResources`], [`cudaGraphicsSubResourceGetMappedArray`], [cuGraphicsResourceGetMappedPointer](../cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1g8a634cf4150d399f0018061580592457).
///
/// # Parameters
///
/// - `devPtr`: Returned pointer through which resource may be accessed.
/// - `size`: Returned size of the buffer accessible starting at \*devPtr.
/// - `resource`: Mapped resource to access.
pub fn cudaGraphicsResourceGetMappedPointer(
devPtr: *mut *mut ::core::ffi::c_void,
size: *mut size_t,
resource: cudaGraphicsResource_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Get an array through which to access a subresource of a mapped graphics resource.
///
/// Returns in \*array an array through which the subresource of the mapped graphics resource resource which corresponds to array index arrayIndex and mipmap level mipLevel may be accessed. The value set in array may change every time that resource is mapped.
///
/// If resource is not a texture then it cannot be accessed via an array and [cudaErrorUnknown](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. If arrayIndex is not a valid array index for resource then [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned. If mipLevel is not a valid mipmap level for resource then [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned. If resource is not mapped then [cudaErrorUnknown](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphicsResourceGetMappedPointer`], [cuGraphicsSubResourceGetMappedArray](../cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1g61c55e987e54558cce547240d6123078).
///
/// # 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](#cudaGraphicsCubeFace) for cubemap textures for the subresource to access.
/// - `mipLevel`: Mipmap level for the subresource to access.
pub fn cudaGraphicsSubResourceGetMappedArray(
array: *mut cudaArray_t,
resource: cudaGraphicsResource_t,
arrayIndex: ::core::ffi::c_uint,
mipLevel: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Get a mipmapped array through which to access a mapped graphics resource.
///
/// Returns in \*mipmappedArray a mipmapped array through which the mapped graphics resource resource may be accessed. The value set in mipmappedArray may change every time that resource is mapped.
///
/// If resource is not a texture then it cannot be accessed via an array and [cudaErrorUnknown](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. If resource is not mapped then [cudaErrorUnknown](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphicsResourceGetMappedPointer`], [cuGraphicsResourceGetMappedMipmappedArray](../cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1g37680bbe89c7fe5c613563eaab9d14c1).
///
/// # Parameters
///
/// - `mipmappedArray`: Returned mipmapped array through which resource may be accessed.
/// - `resource`: Mapped resource to access.
pub fn cudaGraphicsResourceGetMappedMipmappedArray(
mipmappedArray: *mut cudaMipmappedArray_t,
resource: cudaGraphicsResource_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Get the channel descriptor of an array.
///
/// Returns in \*desc the channel descriptor of the CUDA array array.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// cudaCreateChannelDesc ( C API), [`cudaCreateTextureObject`], [`cudaCreateSurfaceObject`]
///
/// # Parameters
///
/// - `desc`: Channel format.
/// - `array`: Memory array on device.
pub fn cudaGetChannelDesc(
desc: *mut cudaChannelFormatDesc,
array: cudaArray_const_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `x`: X component.
/// - `y`: Y component.
/// - `z`: Z component.
/// - `w`: W component.
/// - `f`: Channel format.
pub fn cudaCreateChannelDesc(
x: ::core::ffi::c_int,
y: ::core::ffi::c_int,
z: ::core::ffi::c_int,
w: ::core::ffi::c_int,
f: cudaChannelFormatKind,
) -> cudaChannelFormatDesc;
}
unsafe extern "C" {
/// Creates a texture object.
///
/// Creates a texture object and returns it in pTexObject. pResDesc describes the data to texture from. pTexDesc describes how the data should be sampled. pResViewDesc is an optional argument that specifies an alternate format for the data described by pResDesc, and also describes the subresource region to restrict access to when texturing. pResViewDesc can only be specified if the type of resource is a CUDA array or a CUDA mipmapped array not in a block compressed format.
///
/// Texture objects are only supported on devices of compute capability 3.0 or higher. Additionally, a texture object is an opaque
/// value, and, as such, should only be accessed through CUDA API calls.
///
/// The [cudaResourceDesc](#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;
/// };
/// ```
///
/// * [cudaResourceDesc::resType](structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) specifies the type of resource to texture from. CUresourceType is defined as:
///
/// ```text
/// enum cudaResourceType {
/// cudaResourceTypeArray = 0x00,
/// cudaResourceTypeMipmappedArray = 0x01,
/// cudaResourceTypeLinear = 0x02,
/// cudaResourceTypePitch2D = 0x03
/// };
/// ```
///
/// If [cudaResourceDesc::resType](structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is set to [cudaResourceTypeArray](types.md#group__CUDART__TYPES_1gg067b774c0e639817a00a972c8e2c203ca67eb0b4b477d91a86dc043ed310d030), cudaResourceDesc::res::array::array must be set to a valid CUDA array handle.
///
/// If [cudaResourceDesc::resType](structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is set to [cudaResourceTypeMipmappedArray](types.md#group__CUDART__TYPES_1gg067b774c0e639817a00a972c8e2c203cb2b507a3d50791caab51164d40dc44b6), cudaResourceDesc::res::mipmap::mipmap must be set to a valid CUDA mipmapped array handle and [cudaTextureDesc::normalizedCoords](structcudaTextureDesc.html#structcudaTextureDesc_14244ae4f85cd69ff050fdc681be4cd35) must be set to true.
///
/// If [cudaResourceDesc::resType](structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is set to [cudaResourceTypeLinear](types.md#group__CUDART__TYPES_1gg067b774c0e639817a00a972c8e2c203c44e9ff43ebb51d94307d48a57da659f7), cudaResourceDesc::res::linear::devPtr must be set to a valid device pointer, that is aligned to [cudaDeviceProp::textureAlignment](structcudaDeviceProp.html#structcudaDeviceProp_1500248658a996f51752e1ab1769f8a88). 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](structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is set to [cudaResourceTypePitch2D](types.md#group__CUDART__TYPES_1gg067b774c0e639817a00a972c8e2c203c3bb57cdf25448d844f109938a097f6d9), cudaResourceDesc::res::pitch2D::devPtr must be set to a valid device pointer, that is aligned to [cudaDeviceProp::textureAlignment](structcudaDeviceProp.html#structcudaDeviceProp_1500248658a996f51752e1ab1769f8a88). 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](structcudaDeviceProp.html#structcudaDeviceProp_1757a4245a175441c2a1535ef9c9524a4)[0] and [cudaDeviceProp::maxTexture2DLinear](structcudaDeviceProp.html#structcudaDeviceProp_1757a4245a175441c2a1535ef9c9524a4)[1] respectively. cudaResourceDesc::res::pitch2D::pitchInBytes specifies the pitch between two rows in bytes and has to be
/// aligned to [cudaDeviceProp::texturePitchAlignment](structcudaDeviceProp.html#structcudaDeviceProp_13a3f10d2833bdc82ceb370a449aafeec). Pitch cannot exceed [cudaDeviceProp::maxTexture2DLinear](structcudaDeviceProp.html#structcudaDeviceProp_1757a4245a175441c2a1535ef9c9524a4)[2].
///
/// 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;
/// };
/// ```
///
/// * [cudaTextureDesc::addressMode](structcudaTextureDesc.html#structcudaTextureDesc_1444fd48870cf61180673e0ed0abb4a1c) 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](structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is [cudaResourceTypeLinear](types.md#group__CUDART__TYPES_1gg067b774c0e639817a00a972c8e2c203c44e9ff43ebb51d94307d48a57da659f7). Also, if [cudaTextureDesc::normalizedCoords](structcudaTextureDesc.html#structcudaTextureDesc_14244ae4f85cd69ff050fdc681be4cd35) is set to zero, [cudaAddressModeWrap](types.md#group__CUDART__TYPES_1gg03e1bbd2c491d809279c7a47e2cd0351b1cc30b475318b336b3cdf44aecba1d4) and [cudaAddressModeMirror](types.md#group__CUDART__TYPES_1gg03e1bbd2c491d809279c7a47e2cd03511d446f1854f9fe0d4864e9eda56dc06d) won't be supported and will be switched to [cudaAddressModeClamp](types.md#group__CUDART__TYPES_1gg03e1bbd2c491d809279c7a47e2cd0351aef7d489e6752d5e132f45d2d48c7b19).
///
/// * [cudaTextureDesc::filterMode](structcudaTextureDesc.html#structcudaTextureDesc_1c61993bf71d0cdec670ad92e567ba582) 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](structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is [cudaResourceTypeLinear](types.md#group__CUDART__TYPES_1gg067b774c0e639817a00a972c8e2c203c44e9ff43ebb51d94307d48a57da659f7).
///
/// * [cudaTextureDesc::readMode](structcudaTextureDesc.html#structcudaTextureDesc_1279c5b27ef0194711344dc402228af94) 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](structcudaTextureDesc.html#structcudaTextureDesc_1279c5b27ef0194711344dc402228af94) is set [cudaReadModeNormalizedFloat](types.md#group__CUDART__TYPES_1ggd9266d02be93809558036ec4f3d5f43d4f26f2afcd260d6e19df4cea6d87d697) is specified.
///
/// * [cudaTextureDesc::sRGB](structcudaTextureDesc.html#structcudaTextureDesc_1173e8d365c55f50e9eb586c282af30ca) specifies whether sRGB to linear conversion should be performed during texture fetch.
///
/// * [cudaTextureDesc::borderColor](structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e) specifies the float values of color. where: [cudaTextureDesc::borderColor](structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e)[0] contains value of 'R', [cudaTextureDesc::borderColor](structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e)[1] contains value of 'G', [cudaTextureDesc::borderColor](structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e)[2] contains value of 'B', [cudaTextureDesc::borderColor](structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e)[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](structcudaTextureDesc.html#structcudaTextureDesc_1444fd48870cf61180673e0ed0abb4a1c) is cudaAddressModeBorder.
///
/// * [cudaTextureDesc::normalizedCoords](structcudaTextureDesc.html#structcudaTextureDesc_14244ae4f85cd69ff050fdc681be4cd35) specifies whether the texture coordinates will be normalized or not.
///
/// * [cudaTextureDesc::maxAnisotropy](structcudaTextureDesc.html#structcudaTextureDesc_14fadc6bfa59fe7f8f076d58e407381e5) specifies the maximum anistropy ratio to be used when doing anisotropic filtering. This value will be clamped to the range
/// [1,16].
///
/// * [cudaTextureDesc::mipmapFilterMode](structcudaTextureDesc.html#structcudaTextureDesc_1bbdaf1bc430ac931a12ffa7d3f8809ce) specifies the filter mode when the calculated mipmap level lies between two defined mipmap levels.
///
/// * [cudaTextureDesc::mipmapLevelBias](structcudaTextureDesc.html#structcudaTextureDesc_139f79ca1c9fd8f476597df0d3a8ed34c) specifies the offset to be applied to the calculated mipmap level.
///
/// * [cudaTextureDesc::minMipmapLevelClamp](structcudaTextureDesc.html#structcudaTextureDesc_1928642b629ae8fd8d2adc198979b6840) specifies the lower end of the mipmap level range to clamp access to.
///
/// * [cudaTextureDesc::maxMipmapLevelClamp](structcudaTextureDesc.html#structcudaTextureDesc_19cb54762bd472fb9bd58fed7f22e64c2) specifies the upper end of the mipmap level range to clamp access to.
///
/// * [cudaTextureDesc::disableTrilinearOptimization](structcudaTextureDesc.html#structcudaTextureDesc_17a70376ee9551c40991b587b48dbd728) specifies whether the trilinear filtering optimizations will be disabled.
///
/// * [cudaTextureDesc::seamlessCubemap](structcudaTextureDesc.html#structcudaTextureDesc_1d2d887e7ecfead1ed118743bc9dce779) 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](#cudaArrayCubemap). When seamless cube map filtering is enabled, texture address modes specified by [cudaTextureDesc::addressMode](structcudaTextureDesc.html#structcudaTextureDesc_1444fd48870cf61180673e0ed0abb4a1c) are ignored. Instead, if the [cudaTextureDesc::filterMode](structcudaTextureDesc.html#structcudaTextureDesc_1c61993bf71d0cdec670ad92e567ba582) is set to [cudaFilterModePoint](types.md#group__CUDART__TYPES_1ggee4adb3d1b062cf05374de09325a82d5e07c310cc7ac5c14106fbb8dc7a27d11) the address mode [cudaAddressModeClamp](types.md#group__CUDART__TYPES_1gg03e1bbd2c491d809279c7a47e2cd0351aef7d489e6752d5e132f45d2d48c7b19) will be applied for all dimensions. If the [cudaTextureDesc::filterMode](structcudaTextureDesc.html#structcudaTextureDesc_1c61993bf71d0cdec670ad92e567ba582) is set to [cudaFilterModeLinear](types.md#group__CUDART__TYPES_1ggee4adb3d1b062cf05374de09325a82d55bab9bd668bf4bb2e16f7919f5e0caa0) seamless cube map filtering will be performed when sampling along the cube face borders.
///
/// The [cudaResourceViewDesc](#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;
/// };
/// ```
///
/// * [cudaResourceViewDesc::format](structcudaResourceViewDesc.html#structcudaResourceViewDesc_104e9ec20e3b58859dbae8e8e598e1603) 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](structcudaResourceViewDesc.html#structcudaResourceViewDesc_1914fc3c27ce32c98a1d8d21936642924) 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](structcudaResourceViewDesc.html#structcudaResourceViewDesc_1f94839eb926fba26fa5ff28775c79d33) 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](structcudaResourceViewDesc.html#structcudaResourceViewDesc_17f76b4084ffdcb7f88e4149b586a990d) specifies the new depth of the texture data. This value has to be equal to that of the original resource.
///
/// * [cudaResourceViewDesc::firstMipmapLevel](structcudaResourceViewDesc.html#structcudaResourceViewDesc_1f63fa90d2bf6c66f3865bf13006edded) 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](structcudaTextureDesc.html#structcudaTextureDesc_1928642b629ae8fd8d2adc198979b6840) and [cudaTextureDesc::maxMipmapLevelClamp](structcudaTextureDesc.html#structcudaTextureDesc_19cb54762bd472fb9bd58fed7f22e64c2) 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](structcudaResourceViewDesc.html#structcudaResourceViewDesc_1469d25794fec5471648d0d9e42790431) specifies the least detailed mipmap level. For non-mipmapped resources, this value has to be zero.
///
/// * [cudaResourceViewDesc::firstLayer](structcudaResourceViewDesc.html#structcudaResourceViewDesc_1ab0d42bf9dc88944181f697b17e6943a) 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](structcudaResourceViewDesc.html#structcudaResourceViewDesc_16d96c5b3df0bce3d945d4ea99666226f) specifies the last layer index for layered textures. For non-layered resources, this value has to be zero.
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDestroyTextureObject`], [cuTexObjectCreate](../cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1g1f6dd0f9cbf56db725b1f45aa0a7218a).
///
/// # Parameters
///
/// - `pTexObject`: Texture object to create.
/// - `pResDesc`: Resource descriptor.
/// - `pTexDesc`: Texture descriptor.
/// - `pResViewDesc`: Resource view descriptor.
pub fn cudaCreateTextureObject(
pTexObject: *mut cudaTextureObject_t,
pResDesc: *const cudaResourceDesc,
pTexDesc: *const cudaTextureDesc,
pResViewDesc: *const cudaResourceViewDesc,
) -> cudaError_t;
}
unsafe extern "C" {
/// Destroys a texture object.
///
/// Destroys the texture object specified by texObject.
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [`cudaCreateTextureObject`], [cuTexObjectDestroy](../cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1gcd522ba5e2d1852aff8c0388f66247fd).
///
/// # Parameters
///
/// - `texObject`: Texture object to destroy.
pub fn cudaDestroyTextureObject(texObject: cudaTextureObject_t) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a texture object's resource descriptor.
///
/// Returns the resource descriptor for the texture object specified by texObject.
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaCreateTextureObject`], [cuTexObjectGetResourceDesc](../cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1g0cc8eb2fa1e584d2b04d631586d0921f).
///
/// # Parameters
///
/// - `pResDesc`: Resource descriptor.
/// - `texObject`: Texture object.
pub fn cudaGetTextureObjectResourceDesc(
pResDesc: *mut cudaResourceDesc,
texObject: cudaTextureObject_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a texture object's texture descriptor.
///
/// Returns the texture descriptor for the texture object specified by texObject.
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaCreateTextureObject`], [cuTexObjectGetTextureDesc](../cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1g688de37b844df7313c8fce30fc912645).
///
/// # Parameters
///
/// - `pTexDesc`: Texture descriptor.
/// - `texObject`: Texture object.
pub fn cudaGetTextureObjectTextureDesc(
pTexDesc: *mut cudaTextureDesc,
texObject: cudaTextureObject_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a texture object's resource view descriptor.
///
/// Returns the resource view descriptor for the texture object specified by texObject. If no resource view was specified, [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaCreateTextureObject`], [cuTexObjectGetResourceViewDesc](../cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1g185fa4c933a1c3a7b6aebe3e4291a37b).
///
/// # Parameters
///
/// - `pResViewDesc`: Resource view descriptor.
/// - `texObject`: Texture object.
pub fn cudaGetTextureObjectResourceViewDesc(
pResViewDesc: *mut cudaResourceViewDesc,
texObject: cudaTextureObject_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates a surface object.
///
/// Creates a surface object and returns it in pSurfObject. pResDesc describes the data to perform surface load/stores on. [cudaResourceDesc::resType](structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) must be [cudaResourceTypeArray](types.md#group__CUDART__TYPES_1gg067b774c0e639817a00a972c8e2c203ca67eb0b4b477d91a86dc043ed310d030) 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:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDestroySurfaceObject`], [cuSurfObjectCreate](../cuda-driver-api/group__CUDA__SURFOBJECT.html#group__CUDA__SURFOBJECT_1g6bc972c90c9590c9f720b2754e6d079d).
///
/// # Parameters
///
/// - `pSurfObject`: Surface object to create.
/// - `pResDesc`: Resource descriptor.
pub fn cudaCreateSurfaceObject(
pSurfObject: *mut cudaSurfaceObject_t,
pResDesc: *const cudaResourceDesc,
) -> cudaError_t;
}
unsafe extern "C" {
/// Destroys a surface object.
///
/// Destroys the surface object specified by surfObject.
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [`cudaCreateSurfaceObject`], [cuSurfObjectDestroy](../cuda-driver-api/group__CUDA__SURFOBJECT.html#group__CUDA__SURFOBJECT_1g4c4ec48d203d1e0bb71750ddc4d7aef3).
///
/// # Parameters
///
/// - `surfObject`: Surface object to destroy.
pub fn cudaDestroySurfaceObject(surfObject: cudaSurfaceObject_t) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a surface object's resource descriptor Returns the resource descriptor for the surface object specified by surfObject.
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaCreateSurfaceObject`], [cuSurfObjectGetResourceDesc](../cuda-driver-api/group__CUDA__SURFOBJECT.html#group__CUDA__SURFOBJECT_1g2472b7ea0b7e74600ed3d6c244b7ba21).
///
/// # Parameters
///
/// - `pResDesc`: Resource descriptor.
/// - `surfObject`: Surface object.
pub fn cudaGetSurfaceObjectResourceDesc(
pResDesc: *mut cudaResourceDesc,
surfObject: cudaSurfaceObject_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the latest version of CUDA supported by the driver.
///
/// Returns in \*driverVersion the latest version of CUDA supported by the driver. The version is returned as (1000 major + 10 minor). For example, CUDA
/// 9.2 would be represented by 9020. If no driver is installed, then 0 is returned as the driver version.
///
/// This function automatically returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if driverVersion is NULL.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaRuntimeGetVersion`], [cuDriverGetVersion](../cuda-driver-api/group__CUDA__VERSION.html#group__CUDA__VERSION_1g8b7a10395392e049006e61bcdc8ebe71).
///
/// # Parameters
///
/// - `driverVersion`: Returns the CUDA driver version.
pub fn cudaDriverGetVersion(driverVersion: *mut ::core::ffi::c_int) -> cudaError_t;
}
unsafe extern "C" {
/// 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.
///
/// This function automatically returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if the runtimeVersion argument is NULL.
///
/// Note:
///
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDriverGetVersion`], [cuDriverGetVersion](../cuda-driver-api/group__CUDA__VERSION.html#group__CUDA__VERSION_1g8b7a10395392e049006e61bcdc8ebe71).
///
/// # Parameters
///
/// - `runtimeVersion`: Returns the CUDA Runtime version.
pub fn cudaRuntimeGetVersion(runtimeVersion: *mut ::core::ffi::c_int) -> cudaError_t;
}
/// Type of public error reporting callback functions.
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,
),
>;
unsafe extern "C" {
/// Register a callback function to receive error log messages.
///
/// # Parameters
///
/// - `callbackFunc`: The function to register as a callback.
/// - `userData`: A generic pointer to user data. This is passed into the callback function.
/// - `callback_out`: Optional location to store the callback handle after it is registered.
pub fn cudaLogsRegisterCallback(
callbackFunc: cudaLogsCallback_t,
userData: *mut ::core::ffi::c_void,
callback_out: *mut cudaLogsCallbackHandle,
) -> cudaError_t;
}
unsafe extern "C" {
/// Unregister a log message callback.
///
/// # Parameters
///
/// - `callback`: The callback instance to unregister from receiving log messages.
pub fn cudaLogsUnregisterCallback(callback: cudaLogsCallbackHandle) -> cudaError_t;
}
unsafe extern "C" {
/// Sets log iterator to point to the end of log buffer, where the next message would be written.
///
/// # Parameters
///
/// - `iterator_out`: Location to store an iterator to the current tail of the logs.
/// - `flags`: Reserved for future use, must be 0.
pub fn cudaLogsCurrent(
iterator_out: *mut cudaLogIterator,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Dump accumulated driver logs into a file.
///
/// Logs generated by the driver are stored in an internal buffer and can be copied out using this API. This API dumps all driver
/// logs starting from iterator into pathToFile provided.
///
/// Note:
///
/// * iterator is auto-advancing. Dumping logs will update the value of iterator to receive the next generated log.
/// * The driver reserves limited memory for storing logs. The oldest logs may be overwritten and become unrecoverable. An indication
/// will appear in the destination outupt if the logs have been truncated. Call dump after each failed API to mitigate this risk.
///
/// # Parameters
///
/// - `iterator`: Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
/// - `pathToFile`: Path to output file for dumping logs.
/// - `flags`: Reserved for future use, must be 0.
pub fn cudaLogsDumpToFile(
iterator: *mut cudaLogIterator,
pathToFile: *const ::core::ffi::c_char,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Dump accumulated driver logs into a buffer.
///
/// Logs generated by the driver are stored in an internal buffer and can be copied out using this API. This API dumps driver
/// logs from iterator into buffer up to the size specified in \*size. The driver will always null terminate the buffer but there will not be a null character between log entries, only a newline
/// \n. The driver will then return the actual number of bytes written in \*size, excluding the null terminator. If there are no messages to dump, \*size will be set to 0 and the function will return [CUDA_SUCCESS](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1ggc6c391505e117393cc2558fff6bfc2e9a0eed720f8a87cd1c5fd1c453bc7a03d). If the provided buffer is not large enough to hold any messages, \*size will be set to 0 and the function will return [CUDA_ERROR_INVALID_VALUE](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1ggc6c391505e117393cc2558fff6bfc2e990696c86fcee1f536a1ec7d25867feeb).
///
/// Note:
///
/// * iterator is auto-advancing. Dumping logs will update the value of iterator to receive the next generated log.
/// * The driver reserves limited memory for storing logs. The maximum size of the buffer is 25600 bytes. The oldest logs may be
/// overwritten and become unrecoverable. An indication will appear in the destination outupt if the logs have been truncated.
/// Call dump after each failed API to mitigate this risk.
/// * If the provided value in \*size is not large enough to hold all buffered messages, a message will be added at the head of the buffer indicating this. The
/// driver then computes the number of messages it is able to store in buffer and writes it out. The final message in buffer will always be the most recent log message as of when the API is called.
///
/// # Parameters
///
/// - `iterator`: Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
/// - `buffer`: Pointer to dump logs.
/// - `size`: See description.
/// - `flags`: Reserved for future use, must be 0.
pub fn cudaLogsDumpToMemory(
iterator: *mut cudaLogIterator,
buffer: *mut ::core::ffi::c_char,
size: *mut size_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates a graph.
///
/// Creates an empty graph, which is returned via pGraph.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph."), [`cudaGraphDestroy`], [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphClone`]
///
/// # Parameters
///
/// - `pGraph`: Returns newly created graph.
/// - `flags`: Graph creation flags, must be 0.
pub fn cudaGraphCreate(
pGraph: *mut cudaGraph_t,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#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](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1gd5c11cff5adfa5a69d66829399653532), which indicates the end of the extra array;
/// * [CU_LAUNCH_PARAM_BUFFER_POINTER](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1g36d10d0b40c51372877578a2cffd6acd), 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](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1gf339c057cd94562ead93a192e11c17e9), 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](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1g36d10d0b40c51372877578a2cffd6acd);
///
/// The error [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * The API can also be used with a kernel [cudaKernel_t](#cudaKernel_t) by querying the handle using [`cudaLibraryGetKernel`] or [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") should be a symbol that is registered with the same CUDA Runtime instance.
/// * 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](#cudaKernel_t)
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [cudaLaunchKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g2c91bfe5e072fcd28de6606dd43cd64b "Launches a device function."), [`cudaGraphKernelNodeGetParams`], [`cudaGraphKernelNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `pNodeParams`: Parameters for the GPU execution node.
pub fn cudaGraphAddKernelNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
pNodeParams: *const cudaKernelNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [cudaLaunchKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g2c91bfe5e072fcd28de6606dd43cd64b "Launches a device function."), [`cudaGraphAddKernelNode`], [`cudaGraphKernelNodeSetParams`]
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
pub fn cudaGraphKernelNodeGetParams(
node: cudaGraphNode_t,
pNodeParams: *mut cudaKernelNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets a kernel node's parameters.
///
/// Sets the parameters of kernel node node to pNodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * The API can also be used with a kernel [cudaKernel_t](#cudaKernel_t) by querying the handle using [`cudaLibraryGetKernel`] or [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") should be a symbol that is registered with the same CUDA Runtime instance.
/// * 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](#cudaKernel_t)
///
/// **See also:**
///
/// [`cudaGraphNodeSetParams`], [cudaLaunchKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g2c91bfe5e072fcd28de6606dd43cd64b "Launches a device function."), [`cudaGraphAddKernelNode`], [`cudaGraphKernelNodeGetParams`]
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
pub fn cudaGraphKernelNodeSetParams(
node: cudaGraphNode_t,
pNodeParams: *const cudaKernelNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaAccessPolicyWindow](#cudaAccessPolicyWindow).
///
/// # Parameters
///
/// - `hDst`: Destination node.
/// - `hSrc`: Source node For list of attributes see cudaKernelNodeAttrID.
pub fn cudaGraphKernelNodeCopyAttributes(
hDst: cudaGraphNode_t,
hSrc: cudaGraphNode_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Queries node attribute.
///
/// Queries attribute attr from node hNode and stores it in corresponding member of value_out.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaAccessPolicyWindow](#cudaAccessPolicyWindow).
pub fn cudaGraphKernelNodeGetAttribute(
hNode: cudaGraphNode_t,
attr: cudaLaunchAttributeID,
value_out: *mut cudaLaunchAttributeValue,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets node attribute.
///
/// Sets attribute attr on node hNode from corresponding attribute of value.
///
/// Note:
///
/// Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cudaAccessPolicyWindow](#cudaAccessPolicyWindow).
pub fn cudaGraphKernelNodeSetAttribute(
hNode: cudaGraphNode_t,
attr: cudaLaunchAttributeID,
value: *const cudaLaunchAttributeValue,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates a memcpy node and adds it to a graph.
///
/// Creates a new memcpy node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
///
/// When the graph is launched, the node will perform the memcpy described by pCopyParams. See [`cudaMemcpy3D`] for a description of the structure and its restrictions.
///
/// Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device
/// which has a zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09).
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaMemcpy3D`], [cudaGraphAddMemcpyNodeToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g27e7d65595f6aef25cd6fc35053aab5f "Creates a memcpy node to copy to a symbol on the device and adds it to a graph."), [cudaGraphAddMemcpyNodeFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1gd334256f32882963d3143376fa2544bb "Creates a memcpy node to copy from a symbol on the device and adds it to a graph."), [`cudaGraphAddMemcpyNode1D`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `pCopyParams`: Parameters for the memory copy.
pub fn cudaGraphAddMemcpyNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
pCopyParams: *const cudaMemcpy3DParms,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `symbol`: Device symbol address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphAddMemcpyNodeToSymbol(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphAddMemcpyNodeFromSymbol(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that
/// do not match the direction of the copy results in an undefined behavior.
///
/// Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device
/// which has a zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09).
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParams1D`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
pub fn cudaGraphAddMemcpyNode1D(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a memcpy node's parameters.
///
/// Returns the parameters of memcpy node node in pNodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [`cudaMemcpy3D`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeSetParams`]
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
pub fn cudaGraphMemcpyNodeGetParams(
node: cudaGraphNode_t,
pNodeParams: *mut cudaMemcpy3DParms,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets a memcpy node's parameters.
///
/// Sets the parameters of memcpy node node to pNodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeSetParams`], [`cudaMemcpy3D`], [cudaGraphMemcpyNodeSetParamsToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g419c42db51cd9b82f2ba3218c06bac04 "Sets a memcpy node's parameters to copy to a symbol on the device."), [cudaGraphMemcpyNodeSetParamsFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1ga9c21daa8a93536a01896a28577ca221 "Sets a memcpy node's parameters to copy from a symbol on the device."), [`cudaGraphMemcpyNodeSetParams1D`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`]
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
pub fn cudaGraphMemcpyNodeSetParams(
node: cudaGraphNode_t,
pNodeParams: *const cudaMemcpy3DParms,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `symbol`: Device symbol address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphMemcpyNodeSetParamsToSymbol(
node: cudaGraphNode_t,
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphMemcpyNodeSetParamsFromSymbol(
node: cudaGraphNode_t,
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaMemcpyHostToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [cudaMemcpyHostToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b1a03d03a676ea8ec51b9b1e193617568), [cudaMemcpyDeviceToHost](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b5653197602d3455a530db5a7edb1a253), [cudaMemcpyDeviceToDevice](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b783338534304281650c6cb1363f5a00a), or [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a). Passing [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) is recommended, in which case the type of transfer is inferred from the pointer values. However, [cudaMemcpyDefault](types.md#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95b715aff8fb2b8f4f1bb553fee802db57a) 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaMemcpy`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`]
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
pub fn cudaGraphMemcpyNodeSetParams1D(
node: cudaGraphNode_t,
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaMemset2D`], [`cudaGraphMemsetNodeGetParams`], [`cudaGraphMemsetNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `pMemsetParams`: Parameters for the memory set.
pub fn cudaGraphAddMemsetNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
pMemsetParams: *const cudaMemsetParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a memset node's parameters.
///
/// Returns the parameters of memset node node in pNodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [`cudaMemset2D`], [`cudaGraphAddMemsetNode`], [`cudaGraphMemsetNodeSetParams`]
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
pub fn cudaGraphMemsetNodeGetParams(
node: cudaGraphNode_t,
pNodeParams: *mut cudaMemsetParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets a memset node's parameters.
///
/// Sets the parameters of memset node node to pNodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeSetParams`], [`cudaMemset2D`], [`cudaGraphAddMemsetNode`], [`cudaGraphMemsetNodeGetParams`]
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
pub fn cudaGraphMemsetNodeSetParams(
node: cudaGraphNode_t,
pNodeParams: *const cudaMemsetParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaLaunchHostFunc`], [`cudaGraphHostNodeGetParams`], [`cudaGraphHostNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `pNodeParams`: Parameters for the host node.
pub fn cudaGraphAddHostNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
pNodeParams: *const cudaHostNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a host node's parameters.
///
/// Returns the parameters of host node node in pNodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [`cudaLaunchHostFunc`], [`cudaGraphAddHostNode`], [`cudaGraphHostNodeSetParams`]
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `pNodeParams`: Pointer to return the parameters.
pub fn cudaGraphHostNodeGetParams(
node: cudaGraphNode_t,
pNodeParams: *mut cudaHostNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets a host node's parameters.
///
/// Sets the parameters of host node node to nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeSetParams`], [`cudaLaunchHostFunc`], [`cudaGraphAddHostNode`], [`cudaGraphHostNodeGetParams`]
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `pNodeParams`: Parameters to copy.
pub fn cudaGraphHostNodeSetParams(
node: cudaGraphNode_t,
pNodeParams: *const cudaHostNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates a child graph node and adds it to a graph.
///
/// Creates a new node which executes an embedded graph, and adds it to 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaGraphChildGraphNodeGetGraph`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`], [`cudaGraphClone`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `childGraph`: The graph to clone into this node.
pub fn cudaGraphAddChildGraphNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
childGraph: cudaGraph_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Gets a handle to the embedded graph of a child graph node.
///
/// Gets a handle to the embedded graph in a child graph node. This call does not clone the graph. Changes to the graph will be
/// reflected in the node, and the node retains ownership of the graph.
///
/// Allocation and free nodes cannot be added to the returned graph. Attempting to do so will return an error.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddChildGraphNode`], [`cudaGraphNodeFindInClone`]
///
/// # Parameters
///
/// - `node`: Node to get the embedded graph for.
/// - `pGraph`: Location to store a handle to the graph.
pub fn cudaGraphChildGraphNodeGetGraph(
node: cudaGraphNode_t,
pGraph: *mut cudaGraph_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates an empty node and adds it to a graph.
///
/// Creates a new node which performs no operation, and adds it to 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
pub fn cudaGraphAddEmptyNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates an event record node and adds it to a graph.
///
/// Creates a new event record node and adds it to hGraph with numDependencies dependencies specified via dependencies and event specified in event. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// Each launch of the graph will record event to capture execution of the node's dependencies.
///
/// These nodes may not be used in loops or conditionals.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaGraphAddEventWaitNode`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `numDependencies`: Number of dependencies.
/// - `event`: Event for the node.
pub fn cudaGraphAddEventRecordNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
event: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the event associated with an event record node.
///
/// Returns the event of event record node hNode in event_out.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddEventRecordNode`], [`cudaGraphEventRecordNodeSetEvent`], [`cudaGraphEventWaitNodeGetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`]
///
/// # Parameters
///
/// - `event_out`: Pointer to return the event.
pub fn cudaGraphEventRecordNodeGetEvent(
node: cudaGraphNode_t,
event_out: *mut cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets an event record node's event.
///
/// Sets the event of event record node hNode to event.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeSetParams`], [`cudaGraphAddEventRecordNode`], [`cudaGraphEventRecordNodeGetEvent`], [`cudaGraphEventWaitNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`]
///
/// # Parameters
///
/// - `event`: Event to use.
pub fn cudaGraphEventRecordNodeSetEvent(
node: cudaGraphNode_t,
event: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates an event wait node and adds it to a graph.
///
/// Creates a new event wait node and adds it to hGraph with numDependencies dependencies specified via dependencies and event specified in event. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
///
/// The graph node will wait for all work captured in event. See [cuEventRecord()](../cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g95424d3be52c4eb95d83861b70fb89d1) 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaGraphAddEventRecordNode`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `numDependencies`: Number of dependencies.
/// - `event`: Event for the node.
pub fn cudaGraphAddEventWaitNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
event: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the event associated with an event wait node.
///
/// Returns the event of event wait node hNode in event_out.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddEventWaitNode`], [`cudaGraphEventWaitNodeSetEvent`], [`cudaGraphEventRecordNodeGetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`]
///
/// # Parameters
///
/// - `event_out`: Pointer to return the event.
pub fn cudaGraphEventWaitNodeGetEvent(
node: cudaGraphNode_t,
event_out: *mut cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets an event wait node's event.
///
/// Sets the event of event wait node hNode to event.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeSetParams`], [`cudaGraphAddEventWaitNode`], [`cudaGraphEventWaitNodeGetEvent`], [`cudaGraphEventRecordNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`]
///
/// # Parameters
///
/// - `event`: Event to use.
pub fn cudaGraphEventWaitNodeSetEvent(
node: cudaGraphNode_t,
event: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates an external semaphore signal node and adds it to a graph.
///
/// Creates a new external semaphore signal node and adds it to 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaGraphExternalSemaphoresSignalNodeGetParams`], [`cudaGraphExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cudaGraphAddExternalSemaphoresSignalNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
nodeParams: *const cudaExternalSemaphoreSignalNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns an external semaphore signal node's parameters.
///
/// Returns the parameters of an external semaphore signal node hNode in params_out. The extSemArray and paramsArray returned in params_out, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should
/// not be modified directly. Use [`cudaGraphExternalSemaphoresSignalNodeSetParams`] to update the parameters of this node.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [cudaLaunchKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g2c91bfe5e072fcd28de6606dd43cd64b "Launches a device function."), [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphExternalSemaphoresSignalNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`]
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
pub fn cudaGraphExternalSemaphoresSignalNodeGetParams(
hNode: cudaGraphNode_t,
params_out: *mut cudaExternalSemaphoreSignalNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets an external semaphore signal node's parameters.
///
/// Sets the parameters of an external semaphore signal node hNode to nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeSetParams`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphExternalSemaphoresSignalNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`]
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cudaGraphExternalSemaphoresSignalNodeSetParams(
hNode: cudaGraphNode_t,
nodeParams: *const cudaExternalSemaphoreSignalNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates an external semaphore wait node and adds it to a graph.
///
/// Creates a new external semaphore wait node and adds it to 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaGraphExternalSemaphoresWaitNodeGetParams`], [`cudaGraphExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cudaGraphAddExternalSemaphoresWaitNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
nodeParams: *const cudaExternalSemaphoreWaitNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns an external semaphore wait node's parameters.
///
/// Returns the parameters of an external semaphore wait node hNode in params_out. The extSemArray and paramsArray returned in params_out, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should
/// not be modified directly. Use [`cudaGraphExternalSemaphoresSignalNodeSetParams`] to update the parameters of this node.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [cudaLaunchKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g2c91bfe5e072fcd28de6606dd43cd64b "Launches a device function."), [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphExternalSemaphoresWaitNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`]
///
/// # Parameters
///
/// - `hNode`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
pub fn cudaGraphExternalSemaphoresWaitNodeGetParams(
hNode: cudaGraphNode_t,
params_out: *mut cudaExternalSemaphoreWaitNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets an external semaphore wait node's parameters.
///
/// Sets the parameters of an external semaphore wait node hNode to nodeParams.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphExternalSemaphoresWaitNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`]
///
/// # Parameters
///
/// - `hNode`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cudaGraphExternalSemaphoresWaitNodeSetParams(
hNode: cudaGraphNode_t,
nodeParams: *const cudaExternalSemaphoreWaitNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f) 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaGraphAddMemFreeNode`], [`cudaGraphMemAllocNodeGetParams`], [`cudaDeviceGraphMemTrim`], [`cudaDeviceGetGraphMemAttribute`], [`cudaDeviceSetGraphMemAttribute`], [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Parameters for the node.
pub fn cudaGraphAddMemAllocNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
nodeParams: *mut cudaMemAllocNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a memory alloc node's parameters.
///
/// Returns the parameters of a memory alloc node hNode in params_out. The poolProps and accessDescs returned in params_out, are owned by the node. This memory remains valid until the node is destroyed. The returned parameters must not be modified.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [`cudaGraphAddMemAllocNode`], [`cudaGraphMemFreeNodeGetParams`]
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `params_out`: Pointer to return the parameters.
pub fn cudaGraphMemAllocNodeGetParams(
node: cudaGraphNode_t,
params_out: *mut cudaMemAllocNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates a memory free node and adds it to a graph.
///
/// Creates a new memory free node and adds it to graph with numDependencies dependencies specified via pDependencies and address specified in dptr. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
///
/// [`cudaGraphAddMemFreeNode`] will return [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaGraphAddMemAllocNode`], [`cudaGraphMemFreeNodeGetParams`], [`cudaDeviceGraphMemTrim`], [`cudaDeviceGetGraphMemAttribute`], [`cudaDeviceSetGraphMemAttribute`], [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `numDependencies`: Number of dependencies.
/// - `dptr`: Address of memory to free.
pub fn cudaGraphAddMemFreeNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
numDependencies: size_t,
dptr: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a memory free node's parameters.
///
/// Returns the address of a memory free node hNode in dptr_out.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [`cudaGraphAddMemFreeNode`], [`cudaGraphMemFreeNodeGetParams`]
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `dptr_out`: Pointer to return the device address.
pub fn cudaGraphMemFreeNodeGetParams(
node: cudaGraphNode_t,
dptr_out: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// Free unused memory that was cached on the specified device for use with graphs back to the OS.
///
/// Blocks which are not in use by a graph that is either currently executing or scheduled to execute are freed back to the operating
/// system.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddMemAllocNode`], [`cudaGraphAddMemFreeNode`], [`cudaDeviceGetGraphMemAttribute`], [`cudaDeviceSetGraphMemAttribute`], [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`]
///
/// # Parameters
///
/// - `device`: The device for which cached memory should be freed.
pub fn cudaDeviceGraphMemTrim(device: ::core::ffi::c_int) -> cudaError_t;
}
unsafe extern "C" {
/// Query asynchronous allocation attributes related to graphs.
///
/// Valid attributes are:
///
/// * [cudaGraphMemAttrUsedMemCurrent](types.md#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba6872828f088bcae83289bdc6bf9e9cf32): Amount of memory, in bytes, currently associated with graphs
/// * [cudaGraphMemAttrUsedMemHigh](types.md#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba63bbc7271f7ec7c63ec4b7a17a0ae7f59): High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be
/// reset to zero.
/// * [cudaGraphMemAttrReservedMemCurrent](types.md#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba68634b0b4cf96510b19cc684052505a43): Amount of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
/// * [cudaGraphMemAttrReservedMemHigh](types.md#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba611955e0833a2fab17aeb4a6026c6f542): High watermark of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceSetGraphMemAttribute`], [`cudaGraphAddMemAllocNode`], [`cudaGraphAddMemFreeNode`], [`cudaDeviceGraphMemTrim`], [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`]
///
/// # Parameters
///
/// - `device`: Specifies the scope of the query.
/// - `attr`: attribute to get.
/// - `value`: retrieved value.
pub fn cudaDeviceGetGraphMemAttribute(
device: ::core::ffi::c_int,
attr: cudaGraphMemAttributeType,
value: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// Set asynchronous allocation attributes related to graphs.
///
/// Valid attributes are:
///
/// * [cudaGraphMemAttrUsedMemHigh](types.md#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba63bbc7271f7ec7c63ec4b7a17a0ae7f59): High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be
/// reset to zero.
/// * [cudaGraphMemAttrReservedMemHigh](types.md#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba611955e0833a2fab17aeb4a6026c6f542): High watermark of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceGetGraphMemAttribute`], [`cudaGraphAddMemAllocNode`], [`cudaGraphAddMemFreeNode`], [`cudaDeviceGraphMemTrim`], [cudaMallocAsync](high-level-api.md#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaFreeAsync`]
///
/// # Parameters
///
/// - `device`: Specifies the scope of the query.
/// - `attr`: attribute to get.
/// - `value`: pointer to value to set.
pub fn cudaDeviceSetGraphMemAttribute(
device: ::core::ffi::c_int,
attr: cudaGraphMemAttributeType,
value: *mut ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphCreate`], [`cudaGraphNodeFindInClone`]
///
/// # Parameters
///
/// - `pGraphClone`: Returns newly created cloned graph.
/// - `originalGraph`: Graph to clone.
pub fn cudaGraphClone(
pGraphClone: *mut cudaGraph_t,
originalGraph: cudaGraph_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphClone`]
///
/// # Parameters
///
/// - `pNode`: Returns handle to the cloned node.
/// - `originalNode`: Handle to the original node.
/// - `clonedGraph`: Cloned graph to query.
pub fn cudaGraphNodeFindInClone(
pNode: *mut cudaGraphNode_t,
originalNode: cudaGraphNode_t,
clonedGraph: cudaGraph_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a node's type.
///
/// Returns the node type of node in pType.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphChildGraphNodeGetGraph`], [`cudaGraphKernelNodeGetParams`], [`cudaGraphKernelNodeSetParams`], [`cudaGraphHostNodeGetParams`], [`cudaGraphHostNodeSetParams`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemsetNodeGetParams`], [`cudaGraphMemsetNodeSetParams`]
///
/// # Parameters
///
/// - `node`: Node to query.
/// - `pType`: Pointer to return the node type.
pub fn cudaGraphNodeGetType(
node: cudaGraphNode_t,
pType: *mut cudaGraphNodeType,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the graph that contains a given graph node.
///
/// Returns the graph that contains hNode in \*phGraph. If hNode is in a child graph, the child graph it is in is returned.
///
/// **See also:**
///
/// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`][`cudaGraphNodeGetLocalId`][`cudaGraphNodeGetToolsId`][`cudaGraphGetId`][`cudaGraphExecGetId`]
///
/// # Parameters
///
/// - `hNode`: Node to query.
/// - `phGraph`: Pointer to return the containing graph.
pub fn cudaGraphNodeGetContainingGraph(
hNode: cudaGraphNode_t,
phGraph: *mut cudaGraph_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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.
///
/// **See also:**
///
/// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`][`cudaGraphNodeGetContainingGraph`][`cudaGraphNodeGetToolsId`][`cudaGraphGetId`][`cudaGraphExecGetId`]
///
/// # Parameters
///
/// - `hNode`: Node to query.
/// - `nodeId`: Pointer to return the nodeId.
pub fn cudaGraphNodeGetLocalId(
hNode: cudaGraphNode_t,
nodeId: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns an id used by tools to identify a given node.
///
/// **See also:**
///
/// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`][`cudaGraphNodeGetContainingGraph`][`cudaGraphNodeGetLocalId`][`cudaGraphGetId`][`cudaGraphExecGetId`]
///
/// # Parameters
///
/// - `hNode`: Node to query.
pub fn cudaGraphNodeGetToolsId(
hNode: cudaGraphNode_t,
toolsNodeId: *mut ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the id of a given graph.
///
/// Returns the id of hGraph in \*graphId. The value in \*graphId matches that referenced by [`cudaGraphDebugDotPrint`].
///
/// **See also:**
///
/// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`][`cudaGraphNodeGetContainingGraph`][`cudaGraphNodeGetLocalId`][`cudaGraphNodeGetToolsId`][`cudaGraphExecGetId`]
///
/// # Parameters
///
/// - `hGraph`: Graph to query.
pub fn cudaGraphGetId(
hGraph: cudaGraph_t,
graphID: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the id of a given graph exec.
///
/// Returns the id of hGraphExec in \*graphId. The value in \*graphId matches that referenced by [`cudaGraphDebugDotPrint`].
///
/// **See also:**
///
/// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`][`cudaGraphNodeGetContainingGraph`][`cudaGraphNodeGetLocalId`][`cudaGraphNodeGetToolsId`][`cudaGraphGetId`]
///
/// # Parameters
///
/// - `hGraphExec`: Graph to query.
pub fn cudaGraphExecGetId(
hGraphExec: cudaGraphExec_t,
graphID: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphCreate`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetType`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`]
///
/// # Parameters
///
/// - `graph`: Graph to query.
/// - `nodes`: Pointer to return the nodes.
/// - `numNodes`: See description.
pub fn cudaGraphGetNodes(
graph: cudaGraph_t,
nodes: *mut cudaGraphNode_t,
numNodes: *mut size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphCreate`], [`cudaGraphGetNodes`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetType`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`]
///
/// # Parameters
///
/// - `graph`: Graph to query.
/// - `pRootNodes`: Pointer to return the root nodes.
/// - `pNumRootNodes`: See description.
pub fn cudaGraphGetRootNodes(
graph: cudaGraph_t,
pRootNodes: *mut cudaGraphNode_t,
pNumRootNodes: *mut size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a graph's dependency edges.
///
/// Returns a list of graph's dependency edges. Edges are returned via corresponding indices in from, to and edgeData; that is, the node in to[i] has a dependency on the node in from[i] with data edgeData[i]. from and to may both be NULL, in which case this function only returns the number of edges in numEdges. Otherwise, numEdges entries will be filled in. If numEdges is higher than the actual number of edges, the remaining entries in from and to will be set to NULL, and the number of edges actually returned will be written to numEdges. edgeData may alone be NULL, in which case the edges must all have default (zeroed) edge data. Attempting a losst query via NULL edgeData will result in [cudaErrorLossyQuery](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d484d9d8e8f269cf93d4c111b646f908). If edgeData is non-NULL then from and to must be as well.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphAddDependencies`], [`cudaGraphRemoveDependencies`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`]
///
/// # Parameters
///
/// - `graph`: Graph to get the edges from.
/// - `from`: Location to return edge endpoints.
/// - `to`: Location to return edge endpoints.
/// - `edgeData`: Optional location to return edge data.
/// - `numEdges`: See description.
pub fn cudaGraphGetEdges(
graph: cudaGraph_t,
from: *mut cudaGraphNode_t,
to: *mut cudaGraphNode_t,
edgeData: *mut cudaGraphEdgeData,
numEdges: *mut size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a node's dependencies.
///
/// Returns a list of node's dependencies. pDependencies may be NULL, in which case this function will return the number of dependencies in pNumDependencies. Otherwise, pNumDependencies entries will be filled in. If pNumDependencies is higher than the actual number of dependencies, the remaining entries in pDependencies will be set to NULL, and the number of nodes actually obtained will be returned in pNumDependencies.
///
/// Note that if an edge has non-zero (non-default) edge data and edgeData is NULL, this API will return [cudaErrorLossyQuery](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d484d9d8e8f269cf93d4c111b646f908). If edgeData is non-NULL, then pDependencies must be as well.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetDependentNodes`], [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphAddDependencies`], [`cudaGraphRemoveDependencies`]
///
/// # Parameters
///
/// - `node`: Node to query.
/// - `pDependencies`: Pointer to return the dependencies.
/// - `edgeData`: Optional array to return edge data for each dependency.
/// - `pNumDependencies`: See description.
pub fn cudaGraphNodeGetDependencies(
node: cudaGraphNode_t,
pDependencies: *mut cudaGraphNode_t,
edgeData: *mut cudaGraphEdgeData,
pNumDependencies: *mut size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a node's dependent nodes.
///
/// Returns a list of node's dependent nodes. pDependentNodes may be NULL, in which case this function will return the number of dependent nodes in pNumDependentNodes. Otherwise, pNumDependentNodes entries will be filled in. If pNumDependentNodes is higher than the actual number of dependent nodes, the remaining entries in pDependentNodes will be set to NULL, and the number of nodes actually obtained will be returned in pNumDependentNodes.
///
/// Note that if an edge has non-zero (non-default) edge data and edgeData is NULL, this API will return [cudaErrorLossyQuery](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d484d9d8e8f269cf93d4c111b646f908). If edgeData is non-NULL, then pDependentNodes must be as well.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetDependencies`], [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphAddDependencies`], [`cudaGraphRemoveDependencies`]
///
/// # Parameters
///
/// - `node`: Node to query.
/// - `pDependentNodes`: Pointer to return the dependent nodes.
/// - `edgeData`: Optional pointer to return edge data for dependent nodes.
/// - `pNumDependentNodes`: See description.
pub fn cudaGraphNodeGetDependentNodes(
node: cudaGraphNode_t,
pDependentNodes: *mut cudaGraphNode_t,
edgeData: *mut cudaGraphEdgeData,
pNumDependentNodes: *mut size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphRemoveDependencies`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`]
///
/// # Parameters
///
/// - `graph`: Graph to which dependencies are added.
/// - `from`: Array of nodes that provide the dependencies.
/// - `to`: Array of dependent nodes.
/// - `edgeData`: Optional array of edge data. If NULL, default (zeroed) edge data is assumed.
/// - `numDependencies`: Number of dependencies to be added.
pub fn cudaGraphAddDependencies(
graph: cudaGraph_t,
from: *const cudaGraphNode_t,
to: *const cudaGraphNode_t,
edgeData: *const cudaGraphEdgeData,
numDependencies: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddDependencies`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`]
///
/// # Parameters
///
/// - `graph`: Graph from which to remove dependencies.
/// - `from`: Array of nodes that provide the dependencies.
/// - `to`: Array of dependent nodes.
/// - `edgeData`: Optional array of edge data. If NULL, edge data is assumed to be default (zeroed).
/// - `numDependencies`: Number of dependencies to be removed.
pub fn cudaGraphRemoveDependencies(
graph: cudaGraph_t,
from: *const cudaGraphNode_t,
to: *const cudaGraphNode_t,
edgeData: *const cudaGraphEdgeData,
numDependencies: size_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`]
///
/// # Parameters
///
/// - `node`: Node to remove.
pub fn cudaGraphDestroyNode(node: cudaGraphNode_t) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `pGraphExec`: Returns instantiated graph.
/// - `graph`: Graph to instantiate.
pub fn cudaGraphInstantiate(
pGraphExec: *mut cudaGraphExec_t,
graph: cudaGraph_t,
flags: ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f), which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before
/// the graph is relaunched.
///
/// * [cudaGraphInstantiateFlagDeviceLaunch](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090043fee5a1234b9f5d4ef329a660e6e3f5a), 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](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f).
///
/// * [cudaGraphInstantiateFlagUseNodePriority](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d0900495adbcaa8c89c323deec4b2070a4bab5), 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph."), [`cudaGraphCreate`], [`cudaGraphUpload`], [`cudaGraphLaunch`], [`cudaGraphExecDestroy`]
///
/// # Parameters
///
/// - `pGraphExec`: Returns instantiated graph.
/// - `graph`: Graph to instantiate.
/// - `flags`: Flags to control instantiation. See [CUgraphInstantiate_flags](../cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1g070bf5517d3a7915667c256eefce4956).
pub fn cudaGraphInstantiateWithFlags(
pGraphExec: *mut cudaGraphExec_t,
graph: cudaGraph_t,
flags: ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#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](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f), which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before
/// the graph is relaunched.
///
/// * [cudaGraphInstantiateFlagUpload](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d09004565872dd74cc9d97125bf43740345238), which will perform an upload of the graph into uploadStream once the graph has been instantiated.
///
/// * [cudaGraphInstantiateFlagDeviceLaunch](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090043fee5a1234b9f5d4ef329a660e6e3f5a), 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](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f).
///
/// * [cudaGraphInstantiateFlagUseNodePriority](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d0900495adbcaa8c89c323deec4b2070a4bab5), 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](types.md#group__CUDART__TYPES_1gg3faefd09000966e3b9d6ca5bcf7b2b9db27a3438c6c187c9d105ff36692abebd), 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](types.md#group__CUDART__TYPES_1gg3faefd09000966e3b9d6ca5bcf7b2b9d1f6436346e713fc9ddf43408e9b63da0), if the graph structure is invalid. errNode_out will be set to one of the offending nodes.
/// * [cudaGraphInstantiateNodeOperationNotSupported](types.md#group__CUDART__TYPES_1gg3faefd09000966e3b9d6ca5bcf7b2b9dfe90eb1caaa8ce17e628dd5fa4651e25), 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](types.md#group__CUDART__TYPES_1gg3faefd09000966e3b9d6ca5bcf7b2b9d344068129ac717f6ec29a4a6c88e90f0), 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](types.md#group__CUDART__TYPES_1gg3faefd09000966e3b9d6ca5bcf7b2b9d6b92d94f90110623dafb5fe8081f6f45), and hErrNode_out will be set to NULL.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphCreate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph."), [`cudaGraphInstantiateWithFlags`], [`cudaGraphExecDestroy`]
///
/// # Parameters
///
/// - `pGraphExec`: Returns instantiated graph.
/// - `graph`: Graph to instantiate.
/// - `instantiateParams`: Instantiation parameters.
pub fn cudaGraphInstantiateWithParams(
pGraphExec: *mut cudaGraphExec_t,
graph: cudaGraph_t,
instantiateParams: *mut cudaGraphInstantiateParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Query the instantiation flags of an executable graph.
///
/// Returns the flags that were passed to instantiation for the given executable graph. [cudaGraphInstantiateFlagUpload](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d09004565872dd74cc9d97125bf43740345238) will not be returned by this API as it does not affect the resulting executable graph.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph."), [`cudaGraphInstantiateWithFlags`], [`cudaGraphInstantiateWithParams`]
///
/// # Parameters
///
/// - `graphExec`: The executable graph to query.
/// - `flags`: Returns the instantiation flags.
pub fn cudaGraphExecGetFlags(
graphExec: cudaGraphExec_t,
flags: *mut ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the parameters for a kernel node in the given graphExec.
///
/// Sets the parameters of a kernel node in an executable graph hGraphExec. The node is identified by the corresponding node 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * The API can also be used with a kernel [cudaKernel_t](#cudaKernel_t) by querying the handle using [`cudaLibraryGetKernel`] or [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [cudaGetKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g35239908e7b751854b6713dcdac4a903 "Get pointer to device kernel that matches entry function entryFuncAddr.") should be a symbol that is registered with the same CUDA Runtime instance.
/// * 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](#cudaKernel_t)
///
/// **See also:**
///
/// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddKernelNode`], [`cudaGraphKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: kernel node from the graph from which graphExec was instantiated.
/// - `pNodeParams`: Updated Parameters to set.
pub fn cudaGraphExecKernelNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
pNodeParams: *const cudaKernelNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the parameters for a memcpy node in the given graphExec.
///
/// Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored.
///
/// The source and destination memory in pNodeParams must be allocated from the same contexts as the original source and destination memory. Both the instantiation-time memory
/// operands and the memory operands in pNodeParams must be 1-dimensional. Zero-length operations are not supported.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.
///
/// Returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if the memory operands' mappings changed or either the original or new memory operands are multidimensional.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeSetParams`], [cudaGraphExecMemcpyNodeSetParamsToSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1g7d8280a5fc2b827cf8005060c5607479 "Sets the parameters for a memcpy node in the given graphExec to copy to a symbol on the device."), [cudaGraphExecMemcpyNodeSetParamsFromSymbol](high-level-api.md#group__CUDART__HIGHLEVEL_1ga4691ee08c86fe5fb39a3934eeeb2023 "Sets the parameters for a memcpy node in the given graphExec to copy from a symbol on the device."), [`cudaGraphExecMemcpyNodeSetParams1D`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
/// - `pNodeParams`: Updated Parameters to set.
pub fn cudaGraphExecMemcpyNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
pNodeParams: *const cudaMemcpy3DParms,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
/// - `symbol`: Device symbol address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphExecMemcpyNodeSetParamsToSymbol(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
symbol: *const ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
/// - `dst`: Destination memory address.
/// - `symbol`: Device symbol address.
/// - `count`: Size in bytes to copy.
/// - `offset`: Offset from start of symbol in bytes.
/// - `kind`: Type of transfer.
pub fn cudaGraphExecMemcpyNodeSetParamsFromSymbol(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
dst: *mut ::core::ffi::c_void,
symbol: *const ::core::ffi::c_void,
count: size_t,
offset: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the parameters for a memcpy node in the given graphExec to perform a 1-dimensional copy.
///
/// Updates the work represented by node in hGraphExec as though node had contained the given params at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored.
///
/// src and dst must be allocated from the same contexts as the original source and destination memory. The instantiation-time memory operands
/// must be 1-dimensional. Zero-length operations are not supported.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.
///
/// Returns [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if the memory operands' mappings changed or the original memory operands are multidimensional.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemcpyNode1D`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParams1D`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
/// - `dst`: Destination memory address.
/// - `src`: Source memory address.
/// - `count`: Size in bytes to copy.
/// - `kind`: Type of transfer.
pub fn cudaGraphExecMemcpyNodeSetParams1D(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
dst: *mut ::core::ffi::c_void,
src: *const ::core::ffi::c_void,
count: size_t,
kind: cudaMemcpyKind,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddMemsetNode`], [`cudaGraphMemsetNodeSetParams`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Memset node from the graph which was used to instantiate graphExec.
/// - `pNodeParams`: Updated Parameters to set.
pub fn cudaGraphExecMemsetNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
pNodeParams: *const cudaMemsetParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddHostNode`], [`cudaGraphHostNodeSetParams`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Host node from the graph which was used to instantiate graphExec.
/// - `pNodeParams`: Updated Parameters to set.
pub fn cudaGraphExecHostNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
pNodeParams: *const cudaHostNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddChildGraphNode`], [`cudaGraphChildGraphNodeGetGraph`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `node`: Host node from the graph which was used to instantiate graphExec.
/// - `childGraph`: The graph supplying the updated parameters.
pub fn cudaGraphExecChildGraphNodeSetParams(
hGraphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
childGraph: cudaGraph_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the event for an event record node in the given graphExec.
///
/// Sets the event of an event record node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddEventRecordNode`], [`cudaGraphEventRecordNodeGetEvent`], [`cudaGraphEventWaitNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Event record node from the graph from which graphExec was instantiated.
/// - `event`: Updated event to use.
pub fn cudaGraphExecEventRecordNodeSetEvent(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
event: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the event for an event wait node in the given graphExec.
///
/// Sets the event of an event wait node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddEventWaitNode`], [`cudaGraphEventWaitNodeGetEvent`], [`cudaGraphEventRecordNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Event wait node from the graph from which graphExec was instantiated.
/// - `event`: Updated event to use.
pub fn cudaGraphExecEventWaitNodeSetEvent(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
event: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the parameters for an external semaphore signal node in the given graphExec.
///
/// Sets the parameters of an external semaphore signal node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// hNode must not have been removed from the original graph.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Changing nodeParams->numExtSems is not supported.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: semaphore signal node from the graph from which graphExec was instantiated.
/// - `nodeParams`: Updated Parameters to set.
pub fn cudaGraphExecExternalSemaphoresSignalNodeSetParams(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
nodeParams: *const cudaExternalSemaphoreSignalNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets the parameters for an external semaphore wait node in the given graphExec.
///
/// Sets the parameters of an external semaphore wait node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// hNode must not have been removed from the original graph.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Changing nodeParams->numExtSems is not supported.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: semaphore wait node from the graph from which graphExec was instantiated.
/// - `nodeParams`: Updated Parameters to set.
pub fn cudaGraphExecExternalSemaphoresWaitNodeSetParams(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
nodeParams: *const cudaExternalSemaphoreWaitNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Enables or disables the specified node in the given graphExec.
///
/// Sets hNode to be either enabled or disabled. Disabled nodes are functionally equivalent to empty nodes until they are reenabled. Existing
/// node parameters are not affected by disabling/enabling the node.
///
/// The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// hNode must not have been removed from the original graph.
///
/// The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
///
/// Note:
///
/// Currently only kernel, memset and memcpy nodes are supported.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetEnabled`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")[`cudaGraphLaunch`]
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Node from the graph from which graphExec was instantiated.
/// - `isEnabled`: Node is enabled if != 0, otherwise the node is disabled.
pub fn cudaGraphNodeSetEnabled(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
isEnabled: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Query whether a node in the given graphExec is enabled.
///
/// Sets isEnabled to 1 if hNode is enabled, or 0 if hNode is disabled.
///
/// The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
///
/// hNode must not have been removed from the original graph.
///
/// Note:
///
/// Currently only kernel, memset and memcpy nodes are supported.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeSetEnabled`], [`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")[`cudaGraphLaunch`]
///
/// # Parameters
///
/// - `hGraphExec`: The executable graph in which to set the specified node.
/// - `hNode`: Node from the graph from which graphExec was instantiated.
/// - `isEnabled`: Location to return the enabled status of the node.
pub fn cudaGraphNodeGetEnabled(
hGraphExec: cudaGraphExec_t,
hNode: cudaGraphNode_t,
isEnabled: *mut ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Check whether an executable graph can be updated with a graph and perform the update if possible.
///
/// Updates the node parameters in the instantiated graph specified by hGraphExec with the node parameters in a topologically identical graph specified by hGraph.
///
/// Limitations:
///
/// * Kernel nodes:
/// + The owning context of the function cannot change.
/// + A node whose function originally did not use CUDA dynamic parallelism cannot be updated to a function which uses CDP.
/// + A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side
/// update calls.
/// + A cooperative node cannot be updated to a non-cooperative node, and vice-versa.
/// + If the graph was instantiated with 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `hGraphExec`: The instantiated graph to be updated.
/// - `hGraph`: The graph containing the updated parameters.
/// - `resultInfo`: the error info structure.
pub fn cudaGraphExecUpdate(
hGraphExec: cudaGraphExec_t,
hGraph: cudaGraph_t,
resultInfo: *mut cudaGraphExecUpdateResultInfo,
) -> cudaError_t;
}
unsafe extern "C" {
/// Uploads an executable graph in a stream.
///
/// Uploads hGraphExec to the device in hStream without executing it. Uploads of the same hGraphExec will be serialized. Each upload is ordered behind both any previous work in hStream and any previous launches of hGraphExec. Uses memory cached by stream to back the allocations owned by graphExec.
///
/// Note:
///
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
///
/// **See also:**
///
/// [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph."), [`cudaGraphLaunch`], [`cudaGraphExecDestroy`]
pub fn cudaGraphUpload(
graphExec: cudaGraphExec_t,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](types.md#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f), the launch will fail with [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph."), [`cudaGraphUpload`], [`cudaGraphExecDestroy`]
///
/// # Parameters
///
/// - `graphExec`: Executable graph to launch.
/// - `stream`: Stream in which to launch the graph.
pub fn cudaGraphLaunch(
graphExec: cudaGraphExec_t,
stream: cudaStream_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Destroys an executable graph.
///
/// Destroys the executable graph specified by graphExec.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph."), [`cudaGraphUpload`], [`cudaGraphLaunch`]
///
/// # Parameters
///
/// - `graphExec`: Executable graph to destroy.
pub fn cudaGraphExecDestroy(graphExec: cudaGraphExec_t) -> cudaError_t;
}
unsafe extern "C" {
/// Destroys a graph.
///
/// Destroys the graph specified by graph, as well as all of its nodes.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * Use of the handle after this call is undefined behavior.
///
/// **See also:**
///
/// [`cudaGraphCreate`]
///
/// # Parameters
///
/// - `graph`: Graph to destroy.
pub fn cudaGraphDestroy(graph: cudaGraph_t) -> cudaError_t;
}
unsafe extern "C" {
/// Write a DOT file describing graph structure.
///
/// Using the provided graph, write to path a DOT formatted description of the graph. By default this includes the graph topology, node types, node id, kernel names
/// and memcpy direction. flags can be specified to write more detailed information about each node type such as parameter values, kernel attributes, node
/// and function handles.
///
/// # Parameters
///
/// - `graph`: The graph to create a DOT file from.
/// - `path`: The path to write the DOT file to.
/// - `flags`: Flags from cudaGraphDebugDotFlags for specifying which additional node information to write.
pub fn cudaGraphDebugDotPrint(
graph: cudaGraph_t,
path: *const ::core::ffi::c_char,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Create a user object.
///
/// Create a user object with the specified destructor callback and initial reference count. The initial references are owned
/// by the caller.
///
/// Destructor callbacks cannot make CUDA API calls and should avoid blocking behavior, as they are executed by a shared internal
/// thread. Another thread may be signaled to perform such actions, if it does not block forward progress of tasks scheduled through
/// CUDA.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cudaUserObjectRetain`], [`cudaUserObjectRelease`], [`cudaGraphRetainUserObject`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`]
///
/// # 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](types.md#group__CUDART__TYPES_1ggf4748f36762263564ca8a7a47fd902bbca181af9d994c9a5290b509175ea99fe), which is the only defined flag. This indicates that the destroy callback cannot be waited on by any CUDA API. Users requiring
/// synchronization of the callback should signal its completion manually.
pub fn cudaUserObjectCreate(
object_out: *mut cudaUserObject_t,
ptr: *mut ::core::ffi::c_void,
destroy: cudaHostFn_t,
initialRefcount: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Retain a reference to a user object.
///
/// Retains new references to a user object. The new references are owned by the caller.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cudaUserObjectCreate`], [`cudaUserObjectRelease`], [`cudaGraphRetainUserObject`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`]
///
/// # Parameters
///
/// - `object`: The object to retain.
/// - `count`: The number of references to retain, typically 1. Must be nonzero and not larger than INT_MAX.
pub fn cudaUserObjectRetain(
object: cudaUserObject_t,
count: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Release a reference to a user object.
///
/// Releases user object references owned by the caller. The object's destructor is invoked if the reference count reaches zero.
///
/// It is undefined behavior to release references not owned by the caller, or to use a user object handle after all references
/// are released.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cudaUserObjectCreate`], [`cudaUserObjectRetain`], [`cudaGraphRetainUserObject`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`]
///
/// # Parameters
///
/// - `object`: The object to release.
/// - `count`: The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.
pub fn cudaUserObjectRelease(
object: cudaUserObject_t,
count: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Retain a reference to a user object from a graph.
///
/// Creates or moves user object references that will be owned by a CUDA graph.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cudaUserObjectCreate`][`cudaUserObjectRetain`], [`cudaUserObjectRelease`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`]
///
/// # 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](types.md#group__CUDART__TYPES_1gge53f516fc65103fccb14c8318418815796b13064f28cdb8932c782b94ab5802f) transfers references from the calling thread, rather than create new references. Pass 0 to create new references.
pub fn cudaGraphRetainUserObject(
graph: cudaGraph_t,
object: cudaUserObject_t,
count: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Release a user object reference from a graph.
///
/// Releases user object references owned by a graph.
///
/// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
///
/// **See also:**
///
/// [`cudaUserObjectCreate`][`cudaUserObjectRetain`], [`cudaUserObjectRelease`], [`cudaGraphRetainUserObject`], [`cudaGraphCreate`]
///
/// # Parameters
///
/// - `graph`: The graph that will release the reference.
/// - `object`: The user object to release a reference for.
/// - `count`: The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.
pub fn cudaGraphReleaseUserObject(
graph: cudaGraph_t,
object: cudaUserObject_t,
count: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphCreate`], [`cudaGraphNodeSetParams`], [`cudaGraphExecNodeSetParams`]
///
/// # Parameters
///
/// - `pGraphNode`: Returns newly created node.
/// - `graph`: Graph to which to add the node.
/// - `pDependencies`: Dependencies of the node.
/// - `dependencyData`: Optional edge data for the dependencies. If NULL, the data is assumed to be default (zeroed) for all dependencies.
/// - `numDependencies`: Number of dependencies.
/// - `nodeParams`: Specification of the node.
pub fn cudaGraphAddNode(
pGraphNode: *mut cudaGraphNode_t,
graph: cudaGraph_t,
pDependencies: *const cudaGraphNode_t,
dependencyData: *const cudaGraphEdgeData,
numDependencies: size_t,
nodeParams: *mut cudaGraphNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [`cudaGraphAddNode`], [`cudaGraphExecNodeSetParams`]
///
/// # Parameters
///
/// - `node`: Node to set the parameters for.
/// - `nodeParams`: Parameters to copy.
pub fn cudaGraphNodeSetParams(
node: cudaGraphNode_t,
nodeParams: *mut cudaGraphNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphNodeGetParams`], [`cudaGraphNodeSetParams`], [`cudaGraphAddNode`], [`cudaGraphExecNodeSetParams`]
///
/// # Parameters
///
/// - `node`: Node to get the parameters for.
/// - `nodeParams`: Pointer to return the parameters.
pub fn cudaGraphNodeGetParams(
node: cudaGraphNode_t,
nodeParams: *mut cudaGraphNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGraphAddNode`], [`cudaGraphNodeSetParams`][`cudaGraphExecUpdate`], [cudaGraphInstantiate](high-level-api.md#group__CUDART__HIGHLEVEL_1gb25beab33abe4b2d13edbb6e35cb72ff "Creates an executable graph from a graph.")
///
/// # Parameters
///
/// - `graphExec`: The executable graph in which to update the specified node.
/// - `node`: Corresponding node from the graph from which graphExec was instantiated.
/// - `nodeParams`: Updated Parameters to set.
pub fn cudaGraphExecNodeSetParams(
graphExec: cudaGraphExec_t,
node: cudaGraphNode_t,
nodeParams: *mut cudaGraphNodeParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Create a conditional handle.
///
/// Creates a conditional handle associated with hGraph.
///
/// The conditional handle must be associated with a conditional node in this graph or one of its children.
///
/// Handles not associated with a conditional node may cause graph instantiation to fail.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cuGraphAddNode](../cuda-driver-api/group__CUDA__GRAPH.html#group__CUDA__GRAPH_1ge01208e62f72a53367a2af903bf17d23),.
///
/// # Parameters
///
/// - `pHandle_out`: Pointer used to return the handle to the caller.
/// - `graph`: Graph which will contain the conditional node using this handle.
/// - `defaultLaunchValue`: Optional initial value for the conditional variable. Applied at the beginning of each graph execution if cudaGraphCondAssignDefault
/// is set in flags.
/// - `flags`: Currently must be cudaGraphCondAssignDefault or 0.
pub fn cudaGraphConditionalHandleCreate(
pHandle_out: *mut cudaGraphConditionalHandle,
graph: cudaGraph_t,
defaultLaunchValue: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Create a conditional handle.
///
/// Creates a conditional handle associated with hGraph.
///
/// The conditional handle must be associated with a conditional node in this graph or one of its children.
///
/// Handles not associated with a conditional node may cause graph instantiation to fail.
///
/// Note:
///
/// * Graph objects are not threadsafe. [More here](graphs-thread-safety.html#graphs-thread-safety).
/// * Note that this function may also return error codes from previous, asynchronous launches.
///
/// **See also:**
///
/// [cuGraphAddNode](../cuda-driver-api/group__CUDA__GRAPH.html#group__CUDA__GRAPH_1ge01208e62f72a53367a2af903bf17d23),.
///
/// # Parameters
///
/// - `pHandle_out`: Pointer used to return the handle to the caller.
/// - `graph`: Graph which will contain the conditional node using this handle.
/// - `ctx`: Execution context for the handle and associated conditional node. If NULL, current context will be used.
/// - `defaultLaunchValue`: Optional initial value for the conditional variable. Applied at the beginning of each graph execution if cudaGraphCondAssignDefault
/// is set in flags.
/// - `flags`: Currently must be cudaGraphCondAssignDefault or 0.
pub fn cudaGraphConditionalHandleCreate_v2(
pHandle_out: *mut cudaGraphConditionalHandle,
graph: cudaGraph_t,
ctx: cudaExecutionContext_t,
defaultLaunchValue: ::core::ffi::c_uint,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the requested driver API function pointer.
///
/// ###### Deprecated
///
/// This function is deprecated as of CUDA 13.0
///
/// Returns in \*\*funcPtr the address of the CUDA driver function for the requested flags.
///
/// For a requested driver symbol, if the CUDA version in which the driver symbol was introduced is less than or equal to the
/// CUDA runtime version, the API will return the function pointer to the corresponding versioned driver function.
///
/// The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in
/// the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example,
/// cudaTypedefs.h consists of function pointer typedefs for driver APIs defined in cuda.h.
///
/// The API will return [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) and set the returned funcPtr if the requested driver function is valid and supported on the platform.
///
/// The API will return [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) 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](#cudaDriverEntryPointQueryResult) with the following meanings:
///
/// * [cudaDriverEntryPointSuccess](types.md#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1f675c627fcf7d85babf3566ef9b9ae15d) - The requested symbol was succesfully found based on input arguments and pfn is valid
/// * [cudaDriverEntryPointSymbolNotFound](types.md#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1fe498f752ad230907d91c997be955565b) - The requested symbol was not found
/// * [cudaDriverEntryPointVersionNotSufficent](types.md#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1fc5e673dbc3e97f620e20ae5aeb0b7426) - The requested symbol was found but is not supported by the current runtime version (CUDART_VERSION)
///
/// The requested flags can be:
///
/// * [cudaEnableDefault](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61a9c0bcf076678d03418b7922a39bb1d5): This is the default mode. This is equivalent to [cudaEnablePerThreadDefaultStream](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd611bd1da9af3fbaa465a199706ef94328f) if the code is compiled with --default-stream per-thread compilation flag or the macro CUDA_API_PER_THREAD_DEFAULT_STREAM
/// is defined; [cudaEnableLegacyStream](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61e37885317cc9edcece9b5069b1494e1b) otherwise.
/// * [cudaEnableLegacyStream](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61e37885317cc9edcece9b5069b1494e1b): This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding
/// per-thread versions.
/// * [cudaEnablePerThreadDefaultStream](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd611bd1da9af3fbaa465a199706ef94328f): 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:
///
/// 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. [More here](version-mixing-rules.html#version-mixing-rules).
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuGetProcAddress](../cuda-driver-api/group__CUDA__DRIVER__ENTRY__POINT.html#group__CUDA__DRIVER__ENTRY__POINT_1gcae5adad00590572ab35b2508c2d6e0d).
///
/// # Parameters
///
/// - `symbol`: The base name of the driver API function to look for. As an example, for the driver API cuMemAlloc_v2, symbol would be cuMemAlloc. Note that the API will use the CUDA runtime version to return the address to the most recent ABI compatible
/// driver symbol, [cuMemAlloc](../cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gb82d2a09844a58dd9e744dc31e8aa467) or cuMemAlloc_v2.
/// - `funcPtr`: Location to return the function pointer to the requested driver function.
/// - `flags`: Flags to specify search options.
/// - `driverStatus`: Optional location to store the status of finding the symbol from the driver. See [cudaDriverEntryPointQueryResult](#cudaDriverEntryPointQueryResult) for possible values.
pub fn cudaGetDriverEntryPoint(
symbol: *const ::core::ffi::c_char,
funcPtr: *mut *mut ::core::ffi::c_void,
flags: ::core::ffi::c_ulonglong,
driverStatus: *mut cudaDriverEntryPointQueryResult,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the requested driver API function pointer by CUDA version.
///
/// Returns in \*\*funcPtr the address of the CUDA driver function for the requested flags and CUDA driver version.
///
/// The CUDA version is specified as (1000 \* major + 10 \* minor), so CUDA 11.2 should be specified as 11020. For a requested driver
/// symbol, if the specified CUDA version is greater than or equal to the CUDA version in which the driver symbol was introduced,
/// this API will return the function pointer to the corresponding versioned function. If the specified CUDA version is greater
/// than the driver version, the API will return [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in
/// the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example,
/// cudaTypedefs.h consists of function pointer typedefs for driver APIs defined in cuda.h.
///
/// For the case where the CUDA version requested is greater than the CUDA Toolkit installed, there may not be an appropriate
/// function pointer typedef in the corresponding header file and may need a custom typedef to match the driver function signature
/// returned. This can be done by getting the typedefs from a later toolkit or creating appropriately matching custom function
/// typedefs.
///
/// The API will return [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) and set the returned funcPtr if the requested driver function is valid and supported on the platform.
///
/// The API will return [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) 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](#cudaDriverEntryPointQueryResult) with the following meanings:
///
/// * [cudaDriverEntryPointSuccess](types.md#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1f675c627fcf7d85babf3566ef9b9ae15d) - The requested symbol was succesfully found based on input arguments and pfn is valid
/// * [cudaDriverEntryPointSymbolNotFound](types.md#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1fe498f752ad230907d91c997be955565b) - The requested symbol was not found
/// * [cudaDriverEntryPointVersionNotSufficent](types.md#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1fc5e673dbc3e97f620e20ae5aeb0b7426) - The requested symbol was found but is not supported by the specified version cudaVersion
///
/// The requested flags can be:
///
/// * [cudaEnableDefault](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61a9c0bcf076678d03418b7922a39bb1d5): This is the default mode. This is equivalent to [cudaEnablePerThreadDefaultStream](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd611bd1da9af3fbaa465a199706ef94328f) if the code is compiled with --default-stream per-thread compilation flag or the macro CUDA_API_PER_THREAD_DEFAULT_STREAM
/// is defined; [cudaEnableLegacyStream](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61e37885317cc9edcece9b5069b1494e1b) otherwise.
/// * [cudaEnableLegacyStream](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61e37885317cc9edcece9b5069b1494e1b): This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding
/// per-thread versions.
/// * [cudaEnablePerThreadDefaultStream](types.md#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd611bd1da9af3fbaa465a199706ef94328f): This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread
/// versions. If a per-thread version is not found, the API will return the legacy version of the driver function.
///
/// Note:
///
/// * Version mixing among CUDA-defined types and driver API versions is strongly discouraged and doing so can result in an undefined
/// behavior. [More here](version-mixing-rules.html#version-mixing-rules).
/// * Note that this function may also return [cudaErrorInitializationError](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuGetProcAddress](../cuda-driver-api/group__CUDA__DRIVER__ENTRY__POINT.html#group__CUDA__DRIVER__ENTRY__POINT_1gcae5adad00590572ab35b2508c2d6e0d).
///
/// # Parameters
///
/// - `symbol`: The base name of the driver API function to look for. As an example, for the driver API cuMemAlloc_v2, symbol would be cuMemAlloc.
/// - `funcPtr`: Location to return the function pointer to the requested driver function.
/// - `cudaVersion`: The CUDA version to look for the requested driver symbol.
/// - `flags`: Flags to specify search options.
/// - `driverStatus`: Optional location to store the status of finding the symbol from the driver. See [cudaDriverEntryPointQueryResult](#cudaDriverEntryPointQueryResult) for possible values.
pub fn cudaGetDriverEntryPointByVersion(
symbol: *const ::core::ffi::c_char,
funcPtr: *mut *mut ::core::ffi::c_void,
cudaVersion: ::core::ffi::c_uint,
flags: ::core::ffi::c_ulonglong,
driverStatus: *mut cudaDriverEntryPointQueryResult,
) -> cudaError_t;
}
unsafe extern "C" {
/// Load a library with specified code and options.
///
/// Takes a pointer code and loads the corresponding library library based on the application defined library loading mode:
///
/// * If module loading is set to EAGER, via the environment variables described in "Module loading", library is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library
/// is unloaded with [`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.
///
/// **See also:**
///
/// [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [cuLibraryLoadData](../cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g957f12ff5af4166f43c89d17cfb0a74d).
///
/// # Parameters
///
/// - `library`: Returned library.
/// - `code`: Code to load.
/// - `jitOptions`: Options for JIT.
/// - `jitOptionsValues`: Option values for JIT.
/// - `numJitOptions`: Number of options.
/// - `libraryOptions`: Options for loading.
/// - `libraryOptionValues`: Option values for loading.
/// - `numLibraryOptions`: Number of options for loading.
pub fn cudaLibraryLoadData(
library: *mut cudaLibrary_t,
code: *const ::core::ffi::c_void,
jitOptions: *mut cudaJitOption,
jitOptionsValues: *mut *mut ::core::ffi::c_void,
numJitOptions: ::core::ffi::c_uint,
libraryOptions: *mut cudaLibraryOption,
libraryOptionValues: *mut *mut ::core::ffi::c_void,
numLibraryOptions: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Load a library with specified file and options.
///
/// Takes a pointer code and loads the corresponding library library based on the application defined library loading mode:
///
/// * If module loading is set to EAGER, via the environment variables described in "Module loading", library is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library
/// is unloaded with [`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.
///
/// **See also:**
///
/// [`cudaLibraryLoadData`], [`cudaLibraryUnload`], [cuLibraryLoadFromFile](../cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g88cff489fab37c7fd1985ceb61023205).
///
/// # Parameters
///
/// - `library`: Returned library.
/// - `fileName`: File to load from.
/// - `jitOptions`: Options for JIT.
/// - `jitOptionsValues`: Option values for JIT.
/// - `numJitOptions`: Number of options.
/// - `libraryOptions`: Options for loading.
/// - `libraryOptionValues`: Option values for loading.
/// - `numLibraryOptions`: Number of options for loading.
pub fn cudaLibraryLoadFromFile(
library: *mut cudaLibrary_t,
fileName: *const ::core::ffi::c_char,
jitOptions: *mut cudaJitOption,
jitOptionsValues: *mut *mut ::core::ffi::c_void,
numJitOptions: ::core::ffi::c_uint,
libraryOptions: *mut cudaLibraryOption,
libraryOptionValues: *mut *mut ::core::ffi::c_void,
numLibraryOptions: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Unloads a library.
///
/// Unloads the library specified with library
///
/// **See also:**
///
/// [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [cuLibraryUnload](../cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g24969cb24138171edf465bc8669d5914).
///
/// # Parameters
///
/// - `library`: Library to unload.
pub fn cudaLibraryUnload(library: cudaLibrary_t) -> cudaError_t;
}
unsafe extern "C" {
/// Returns a kernel handle.
///
/// Returns in pKernel the handle of the kernel with name name located in library library. If kernel handle is not found, the call returns [cudaErrorSymbolNotFound](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00389d51ecb21a3081d01e078d136c137593).
///
/// **See also:**
///
/// [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [cuLibraryGetKernel](../cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g15336d865f5abd63e3dc6004d5bc037a).
///
/// # Parameters
///
/// - `pKernel`: Returned kernel handle.
/// - `library`: Library to retrieve kernel from.
/// - `name`: Name of kernel to retrieve.
pub fn cudaLibraryGetKernel(
pKernel: *mut cudaKernel_t,
library: cudaLibrary_t,
name: *const ::core::ffi::c_char,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `dptr`: Returned global device pointer for the requested library.
/// - `bytes`: Returned global size in bytes.
/// - `library`: Library to retrieve global from.
/// - `name`: Name of global to retrieve.
pub fn cudaLibraryGetGlobal(
dptr: *mut *mut ::core::ffi::c_void,
bytes: *mut size_t,
library: cudaLibrary_t,
name: *const ::core::ffi::c_char,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `dptr`: Returned pointer to the managed memory.
/// - `bytes`: Returned memory size in bytes.
/// - `library`: Library to retrieve managed memory from.
/// - `name`: Name of managed memory to retrieve.
pub fn cudaLibraryGetManaged(
dptr: *mut *mut ::core::ffi::c_void,
bytes: *mut size_t,
library: cudaLibrary_t,
name: *const ::core::ffi::c_char,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `fptr`: Returned pointer to a unified function.
/// - `library`: Library to retrieve function pointer memory from.
/// - `symbol`: Name of function pointer to retrieve.
pub fn cudaLibraryGetUnifiedFunction(
fptr: *mut *mut ::core::ffi::c_void,
library: cudaLibrary_t,
symbol: *const ::core::ffi::c_char,
) -> cudaError_t;
}
unsafe extern "C" {
/// Returns the number of kernels within a library.
///
/// Returns in count the number of kernels in lib.
///
/// **See also:**
///
/// [`cudaLibraryEnumerateKernels`], [`cudaLibraryLoadFromFile`], [`cudaLibraryLoadData`], [cuLibraryGetKernelCount](../cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g142732b1c9afaa662f21cae9a558d2d4).
///
/// # Parameters
///
/// - `count`: Number of kernels found within the library.
/// - `lib`: Library to query.
pub fn cudaLibraryGetKernelCount(
count: *mut ::core::ffi::c_uint,
lib: cudaLibrary_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Retrieve the kernel handles within a library.
///
/// Returns in kernels a maximum number of numKernels kernel handles within lib. The returned kernel handle becomes invalid when the library is unloaded.
///
/// **See also:**
///
/// [`cudaLibraryGetKernelCount`], [cuLibraryEnumerateKernels](../cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1ga8ae2f42ab3a8fe789ac2dced8219608).
///
/// # Parameters
///
/// - `kernels`: Buffer where the kernel handles are returned to.
/// - `numKernels`: Maximum number of kernel handles may be returned to the buffer.
/// - `lib`: Library to query from.
pub fn cudaLibraryEnumerateKernels(
kernels: *mut cudaKernel_t,
numKernels: ::core::ffi::c_uint,
lib: cudaLibrary_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Sets information about a kernel.
///
/// This call sets the value of a specified attribute attr on the kernel kernel for the requested device device to an integer value specified by value. This function returns [cudaSuccess](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) if the new value of the attribute could be successfully set. If the set fails, this call will return an error. Not all attributes
/// can have values set. Attempting to set a value on a read-only attribute will result in an error ([cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c))
///
/// Note that attributes set using [cudaFuncSetAttribute()](execution-control.md#group__CUDART__EXECUTION_1g317e77d2657abf915fd9ed03e75f3eb0 "Set attributes for a given function.") will override the attribute set by this API irrespective of whether the call to [cudaFuncSetAttribute()](execution-control.md#group__CUDART__EXECUTION_1g317e77d2657abf915fd9ed03e75f3eb0 "Set attributes for a given function.") 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:
///
/// * [cudaFuncAttributeMaxDynamicSharedMemorySize](types.md#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbe9d5a5aea324596d0e686f7c416f71c26) - 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 [cudaDevAttrMaxSharedMemoryPerBlockOptin](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd024f669ca60d8ff7b3126dbfc61fd925). The maximal size of requestable dynamic shared memory may differ by GPU architecture.
/// * [cudaFuncAttributePreferredSharedMemoryCarveout](types.md#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbed410365fab79998b26bf68000cac7194) - 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 [cudaDevAttrMaxSharedMemoryPerMultiprocessor](types.md#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc478150b5ec1689a2944aaf7e25a5685). This is only a hint, and the driver can choose a different ratio if required to execute the function.
/// * [cudaFuncAttributeRequiredClusterWidth](types.md#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbeaff9c1fcfc7b30e1a5cc2af3efa28c74): 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.
/// * [cudaFuncAttributeRequiredClusterHeight](types.md#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbe6919f695b717254c6ade1c158039aaa2): 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.
/// * [cudaFuncAttributeRequiredClusterDepth](types.md#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbec04c7730923141bd5136dcf68c20203d): 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.
/// * [cudaFuncAttributeNonPortableClusterSizeAllowed](types.md#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbe7c8c14bf3a2b16ea255c98439d5c54c6): Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed.
/// * [cudaFuncAttributeClusterSchedulingPolicyPreference](types.md#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbe6f047d04c6fa955aa5d4719e2f510cee): 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()](execution-control.md#group__CUDART__EXECUTION_1g317e77d2657abf915fd9ed03e75f3eb0 "Set attributes for a given function.") due to device-wide semantics. If multiple threads are trying to set the same attribute on the same device simultaneously,
/// the attribute setting will depend on the interleavings chosen by the OS scheduler and memory consistency.
///
/// **See also:**
///
/// [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [`cudaLibraryGetKernel`], [cudaLaunchKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g2c91bfe5e072fcd28de6606dd43cd64b "Launches a device function."), [cudaFuncSetAttribute](high-level-api.md#group__CUDART__HIGHLEVEL_1g61085e9f04656b92573af16072bbc78d "[C++ API] Set attributes for a given function"), [cuKernelSetAttribute](../cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g1093ade718915249de3b14320d567067).
///
/// # Parameters
///
/// - `kernel`: Kernel to set attribute of.
/// - `attr`: Attribute requested.
/// - `value`: Value to set.
/// - `device`: Device to set attribute of.
pub fn cudaKernelSetAttributeForDevice(
kernel: cudaKernel_t,
attr: cudaFuncAttribute,
value: ::core::ffi::c_int,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// Get device resources.
///
/// Get the type resources available to the device. This may often be the starting point for further partitioning or configuring of resources.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// Note:
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuDeviceGetDevResource](../cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g6115d21604653f4eafb257f725538ab6), [`cudaExecutionCtxGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`]
///
/// # Parameters
///
/// - `device`: Device to get resource for.
/// - `resource`: Output pointer to a [cudaDevResource](#cudaDevResource) structure.
pub fn cudaDeviceGetDevResource(
device: ::core::ffi::c_int,
resource: *mut cudaDevResource,
type_: cudaDevResourceType,
) -> cudaError_t;
}
unsafe extern "C" {
/// Splits cudaDevResourceTypeSm resources.
///
/// Splits 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 [cudaDevResourceTypeSm](types.md#group__CUDART__TYPES_1ggf6d72547eca15ba81bc6164286345b9204a93713ba55926b8cccaceb24a4d78b), 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](high-level-api.md#group__CUDART__HIGHLEVEL_1g055357880b84bbb1884f65fb22d6d489 "Given the kernel function (func) and launch configuration (config), return the maximum cluster size in *clusterSize.").
///
/// A successful API call must either have:
///
/// * A valid array of result pointers of size passed in nbGroups, with input of type 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 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:
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuDevSmResourceSplitByCount](../cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1gf8359c74d7286ac32e5db253240d9a6c), [`cudaDeviceGetDevResource`], [`cudaExecutionCtxGetDevResource`], [`cudaDevResourceGenerateDesc`]
///
/// # Parameters
///
/// - `result`: Output array of [cudaDevResource](#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](#cudaDevSmResource) resource.
/// - `remaining`: If the input resource cannot be cleanly split among nbGroups, the remaining is placed in here. Can be ommitted (NULL) if the user does not need the remaining set.
/// - `flags`: Flags specifying how these partitions are used or which constraints to abide by when splitting the input. Zero is valid
/// for default behavior.
/// - `minCount`: Minimum number of SMs required.
pub fn cudaDevSmResourceSplitByCount(
result: *mut cudaDevResource,
nbGroups: *mut ::core::ffi::c_uint,
input: *const cudaDevResource,
remaining: *mut cudaDevResource,
flags: ::core::ffi::c_uint,
minCount: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Splits a cudaDevResourceTypeSm resource into structured groups.
///
/// This API will split a resource of [cudaDevResourceTypeSm](types.md#group__CUDART__TYPES_1ggf6d72547eca15ba81bc6164286345b9204a93713ba55926b8cccaceb24a4d78b) 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](#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 [cudaDevResourceTypeSm](types.md#group__CUDART__TYPES_1ggf6d72547eca15ba81bc6164286345b9204a93713ba55926b8cccaceb24a4d78b) 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](#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 [cudaErrorInvalidResourceConfiguration](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038727a029e221467a4372a957c009fe8d3) 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 [cudaDevResourceTypeSm](types.md#group__CUDART__TYPES_1ggf6d72547eca15ba81bc6164286345b9204a93713ba55926b8cccaceb24a4d78b) 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: lets smCount be a non-multiple of coscheduledSmCount, filling the difference between SM count and already assigned co-scheduled groupings with other SMs. This lets any resulting
/// group behave similar to the remainder group for example.
///
/// **Example params and their effect:**
///
/// A groupParams array element is defined in the following order:
///
/// ```text
/// { .smCount, .coscheduledSmCount, .preferredCoscheduledSmCount, .flags, \/\* .reserved \*\/ }
/// ```
///
/// ```text
/// // Example 1
/// // Will discover how many SMs there are, that are co-scheduled in groups of smCoscheduledAlignment.
/// // The rest is placed in the optional remainder.
/// 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:
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuDevSmResourceSplit](../cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1gc739e0a0b57766ee10437c89909865f3), [`cudaDeviceGetDevResource`], [`cudaExecutionCtxGetDevResource`], [`cudaDevResourceGenerateDesc`]
///
/// # Parameters
///
/// - `result`: Output array of [cudaDevResource](#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 cudaDevResourceTypeSm resource.
/// - `remainder`: If splitting the input resource leaves any SMs, the remainder is placed in here.
/// - `flags`: Flags specifying how the API should behave. The value should be 0 for now.
/// - `groupParams`: Description of how the SMs should be split and assigned to the corresponding result entry.
pub fn cudaDevSmResourceSplit(
result: *mut cudaDevResource,
nbGroups: ::core::ffi::c_uint,
input: *const cudaDevResource,
remainder: *mut cudaDevResource,
flags: ::core::ffi::c_uint,
groupParams: *mut cudaDevSmResourceGroupParams,
) -> cudaError_t;
}
unsafe extern "C" {
/// Generate a resource descriptor.
///
/// Generates a single resource descriptor with the set of resources specified in resources. The generated resource descriptor is necessary for the creation of green contexts via the [`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 [cudaErrorInvalidResourceConfiguration](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038727a029e221467a4372a957c009fe8d3) is returned. If multiple resources are provided in resources and they are of type [cudaDevResourceTypeSm](types.md#group__CUDART__TYPES_1ggf6d72547eca15ba81bc6164286345b9204a93713ba55926b8cccaceb24a4d78b), they must be outputs (whether result or remaining) from the same split API instance and have the same smCoscheduledAlignment values, otherwise [cudaErrorInvalidResourceConfiguration](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038727a029e221467a4372a957c009fe8d3) is returned.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// Note:
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [cuDevResourceGenerateDesc](../cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g1ea7743fd633d2e2dd92eb1c84c4fbc5), [`cudaDeviceGetDevResource`], [`cudaExecutionCtxGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaGreenCtxCreate`]
///
/// # Parameters
///
/// - `phDesc`: Output descriptor.
/// - `resources`: Array of resources to be included in the descriptor.
/// - `nbResources`: Number of resources passed in resources.
pub fn cudaDevResourceGenerateDesc(
phDesc: *mut cudaDevResourceDesc_t,
resources: *mut cudaDevResource,
nbResources: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Creates a green context with a specified set of resources.
///
/// This API creates a green context with the resources specified in the descriptor desc and returns it in the handle represented by phCtx.
///
/// This API 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:
///
/// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaDeviceGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`], [`cudaExecutionCtxGetDevResource`], [`cudaExecutionCtxDestroy`], [`cudaInitDevice`], [`cudaExecutionCtxStreamCreate`]
///
/// # Parameters
///
/// - `phCtx`: Pointer for the output handle to the green context.
/// - `desc`: Descriptor generated via [`cudaDevResourceGenerateDesc`] which contains the set of resources to be used.
/// - `device`: Device on which to create the green context.
/// - `flags`: Green context creation flags. Must be 0, currently reserved for future use.
pub fn cudaGreenCtxCreate(
phCtx: *mut cudaExecutionContext_t,
desc: cudaDevResourceDesc_t,
device: ::core::ffi::c_int,
flags: ::core::ffi::c_uint,
) -> cudaError_t;
}
unsafe extern "C" {
/// Destroy a execution context.
///
/// Destroys the specified execution context ctx. It is the responsibility of the caller to ensure that no API call issues using ctx while [`cudaExecutionCtxDestroy`] is executing or subsequently.
///
/// If ctx is a green context, any resources provisioned for it (that were initially available via the resource descriptor) are released
/// as well.
///
/// The API does not destroy streams created via [`cudaExecutionCtxStreamCreate`]. Users are expected to destroy these streams explicitly using [`cudaStreamDestroy`] to avoid resource leaks. Once the execution context is destroyed, any subsequent API calls involving these streams will return
/// [cudaErrorStreamDetached](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038dac625035f38851dbb8e21a4b556c141) 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:
///
/// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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 [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// **See also:**
///
/// [`cudaGreenCtxCreate`]
///
/// # Parameters
///
/// - `ctx`: Execution context to destroy (required parameter, see note below).
pub fn cudaExecutionCtxDestroy(ctx: cudaExecutionContext_t) -> cudaError_t;
}
unsafe extern "C" {
/// Get context resources.
///
/// Get the type resources available to context represented by ctx.
///
/// Note: The API is not supported on 32-bit platforms.
///
/// Note:
///
/// * 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. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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 [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// **See also:**
///
/// [`cudaDeviceGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`], [`cudaGreenCtxCreate`]
///
/// # Parameters
///
/// - `ctx`: Execution context to get resource for (required parameter, see note below).
/// - `resource`: Output pointer to a [cudaDevResource](#cudaDevResource) structure.
pub fn cudaExecutionCtxGetDevResource(
ctx: cudaExecutionContext_t,
resource: *mut cudaDevResource,
type_: cudaDevResourceType,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * 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. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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 [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// **See also:**
///
/// [`cudaGreenCtxCreate`], [`cudaExecutionCtxDestroy`], [cuCtxGetDevice](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g4e84b109eba36cdaaade167f34ae881e).
///
/// # Parameters
///
/// - `device`: Returned device handle for the specified execution context.
/// - `ctx`: Execution context for which to obtain the device (required parameter, see note below).
pub fn cudaExecutionCtxGetDevice(
device: *mut ::core::ffi::c_int,
ctx: cudaExecutionContext_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * 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. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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 [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// **See also:**
///
/// [`cudaGreenCtxCreate`], [`cudaExecutionCtxDestroy`], [`cudaExecutionCtxGetDevice`], [cuCtxGetId](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g32f492cd6c3f90af0d6935b294392db5).
///
/// # Parameters
///
/// - `ctx`: Context for which to obtain the Id (required parameter, see note below).
/// - `ctxId`: Pointer to store the Id of the context.
pub fn cudaExecutionCtxGetId(
ctx: cudaExecutionContext_t,
ctxId: *mut ::core::ffi::c_ulonglong,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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](#cudaStreamDefault): Default stream creation flag. This would be [cudaStreamNonBlocking](#cudaStreamNonBlocking) for streams created on a green context.
/// * [cudaStreamNonBlocking](#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:
///
/// * 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. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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 [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
/// * In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream
/// priorities have no effect on host-to-device and device-to-host memory operations.
///
/// **See also:**
///
/// [`cudaStreamDestroy`], [`cudaGreenCtxCreate`], [`cudaDeviceGetStreamPriorityRange`], [`cudaStreamGetFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [cudaLaunchKernel](high-level-api.md#group__CUDART__HIGHLEVEL_1g2c91bfe5e072fcd28de6606dd43cd64b "Launches a device function."), [`cudaEventRecord`], [`cudaStreamWaitEvent`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`]
///
/// # Parameters
///
/// - `phStream`: Returned stream handle.
/// - `ctx`: Execution context to initialize the stream with (required parameter, see note below).
/// - `flags`: Flags for stream creation.
/// - `priority`: Stream priority.
pub fn cudaExecutionCtxStreamCreate(
phStream: *mut cudaStream_t,
ctx: cudaExecutionContext_t,
flags: ::core::ffi::c_uint,
priority: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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:
///
/// * 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. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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 [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// **See also:**
///
/// [`cudaGreenCtxCreate`], [`cudaExecutionCtxDestroy`], [`cudaDeviceSynchronize`], [cuCtxSynchronize_v2](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g7c57ec88e825af32ef8cc1754d69eca5).
///
/// # Parameters
///
/// - `ctx`: Execution context to synchronize (required parameter, see note below).
pub fn cudaExecutionCtxSynchronize(ctx: cudaExecutionContext_t) -> cudaError_t;
}
unsafe extern "C" {
/// Get stream resources.
///
/// Get the type resources available to the hStream and store them in resource.
///
/// Note: The API will return [cudaErrorInvalidResourceType](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00384954cdb4893fda9f1a30251a018c32fe) is type is cudaDevResourceTypeWorkqueueConfig or cudaDevResourceTypeWorkqueue.
///
/// Note:
///
/// * 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. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
///
/// **See also:**
///
/// [`cudaGreenCtxCreate`], [`cudaExecutionCtxStreamCreate`], [`cudaStreamCreate`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`], [cuStreamGetDevResource](../cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g25acc306a4e2ba88d1eb8b7bd2b2b578).
///
/// # Parameters
///
/// - `hStream`: Stream to get resource for.
/// - `resource`: Output pointer to a [cudaDevResource](#cudaDevResource) structure.
pub fn cudaStreamGetDevResource(
hStream: cudaStream_t,
resource: *mut cudaDevResource,
type_: cudaDevResourceType,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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 [cudaErrorStreamCaptureUnsupported](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038868e03e02390c8d77f8f60e47038b563) 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:
///
/// * 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. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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 [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// **See also:**
///
/// [`cudaEventRecord`], [`cudaExecutionCtxWaitEvent`], [cuCtxRecordEvent](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1gf3ee63561a7a371fa9d4dc0e31f94afd), [cuGreenCtxRecordEvent](../cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g9dd087071cc217ad7ebda6df96d2ee40).
///
/// # Parameters
///
/// - `ctx`: Execution context to record event for (required parameter, see note below).
/// - `event`: Event to record.
pub fn cudaExecutionCtxRecordEvent(
ctx: cudaExecutionContext_t,
event: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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.
/// * The API will return [cudaErrorStreamCaptureUnsupported](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038868e03e02390c8d77f8f60e47038b563) 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:
///
/// * 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. [cudaErrorNotPermitted](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
/// * 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 [cudaErrorInvalidValue](types.md#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
///
/// **See also:**
///
/// [`cudaExecutionCtxRecordEvent`], [`cudaStreamWaitEvent`], [cuCtxWaitEvent](../cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1gcf64e420275a8141b1f12bfce3f478f9), [cuGreenCtxWaitEvent](../cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g6b26172117084fd024f1396fb66a8ffd).
///
/// # Parameters
///
/// - `ctx`: Execution context to wait for (required parameter, see note below).
/// - `event`: Event to wait on.
pub fn cudaExecutionCtxWaitEvent(
ctx: cudaExecutionContext_t,
event: cudaEvent_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// 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.
///
/// **See also:**
///
/// [`cudaExecutionCtxGetDevice`], [`cudaExecutionCtxGetId`]
///
/// # Parameters
///
/// - `ctx`: Returns the device execution context.
/// - `device`: Device to get the execution context for.
pub fn cudaDeviceGetExecutionCtx(
ctx: *mut cudaExecutionContext_t,
device: ::core::ffi::c_int,
) -> cudaError_t;
}
unsafe extern "C" {
pub fn cudaGetExportTable(
ppExportTable: *mut *const ::core::ffi::c_void,
pExportTableId: *const cudaUUID_t,
) -> cudaError_t;
}
unsafe extern "C" {
/// Get pointer to device entry function that matches entry function symbolPtr.
///
/// Returns in functionPtr the device entry function corresponding to the symbol symbolPtr.
///
/// # Parameters
///
/// - `functionPtr`: Returns the device entry function.
/// - `symbolPtr`: Pointer to device entry function to search for.
pub fn cudaGetFuncBySymbol(
functionPtr: *mut cudaFunction_t,
symbolPtr: *const ::core::ffi::c_void,
) -> cudaError_t;
}
unsafe extern "C" {
/// # Parameters
///
/// - `kernelPtr`: Returns the device kernel.
pub fn cudaGetKernel(
kernelPtr: *mut cudaKernel_t,
entryFuncAddr: *const ::core::ffi::c_void,
) -> cudaError_t;
}