singe_cuda_sys/runtime_sys_13030.rs
1/* automatically generated by rust-bindgen 0.72.1 */
2
3pub const CUDART_VERSION: u32 = 13030;
4pub const cudaSurfaceType1D: u32 = 1;
5pub const cudaSurfaceType2D: u32 = 2;
6pub const cudaSurfaceType3D: u32 = 3;
7pub const cudaSurfaceTypeCubemap: u32 = 12;
8pub const cudaSurfaceType1DLayered: u32 = 241;
9pub const cudaSurfaceType2DLayered: u32 = 242;
10pub const cudaSurfaceTypeCubemapLayered: u32 = 252;
11pub const cudaTextureType1D: u32 = 1;
12pub const cudaTextureType2D: u32 = 2;
13pub const cudaTextureType3D: u32 = 3;
14pub const cudaTextureTypeCubemap: u32 = 12;
15pub const cudaTextureType1DLayered: u32 = 241;
16pub const cudaTextureType2DLayered: u32 = 242;
17pub const cudaTextureTypeCubemapLayered: u32 = 252;
18#[repr(u32)]
19#[derive(
20 Debug,
21 Copy,
22 Clone,
23 Hash,
24 PartialOrd,
25 Ord,
26 PartialEq,
27 Eq,
28 TryFromPrimitive,
29 IntoPrimitive,
30)]
31pub enum cudaRoundMode {
32 cudaRoundNearest = 0,
33 cudaRoundZero = 1,
34 cudaRoundPosInf = 2,
35 cudaRoundMinInf = 3,
36}
37pub type size_t = ::core::ffi::c_ulong;
38/// CUDA Surface boundary modes.
39#[repr(u32)]
40#[derive(
41 Debug,
42 Copy,
43 Clone,
44 Hash,
45 PartialOrd,
46 Ord,
47 PartialEq,
48 Eq,
49 TryFromPrimitive,
50 IntoPrimitive,
51)]
52pub enum cudaSurfaceBoundaryMode {
53 /// Zero boundary mode.
54 cudaBoundaryModeZero = 0,
55 /// Clamp boundary mode.
56 cudaBoundaryModeClamp = 1,
57 /// Trap boundary mode.
58 cudaBoundaryModeTrap = 2,
59}
60/// CUDA Surface format modes.
61#[repr(u32)]
62#[derive(
63 Debug,
64 Copy,
65 Clone,
66 Hash,
67 PartialOrd,
68 Ord,
69 PartialEq,
70 Eq,
71 TryFromPrimitive,
72 IntoPrimitive,
73)]
74pub enum cudaSurfaceFormatMode {
75 /// Forced format mode.
76 cudaFormatModeForced = 0,
77 /// Auto format mode.
78 cudaFormatModeAuto = 1,
79}
80/// An opaque value that represents a CUDA Surface object.
81pub type cudaSurfaceObject_t = ::core::ffi::c_ulonglong;
82/// CUDA texture address modes.
83#[repr(u32)]
84#[derive(
85 Debug,
86 Copy,
87 Clone,
88 Hash,
89 PartialOrd,
90 Ord,
91 PartialEq,
92 Eq,
93 TryFromPrimitive,
94 IntoPrimitive,
95)]
96pub enum cudaTextureAddressMode {
97 /// Wrapping address mode.
98 cudaAddressModeWrap = 0,
99 /// Clamp to edge address mode.
100 cudaAddressModeClamp = 1,
101 /// Mirror address mode.
102 cudaAddressModeMirror = 2,
103 /// Border address mode.
104 cudaAddressModeBorder = 3,
105}
106/// CUDA texture filter modes.
107#[repr(u32)]
108#[derive(
109 Debug,
110 Copy,
111 Clone,
112 Hash,
113 PartialOrd,
114 Ord,
115 PartialEq,
116 Eq,
117 TryFromPrimitive,
118 IntoPrimitive,
119)]
120pub enum cudaTextureFilterMode {
121 /// Point filter mode.
122 cudaFilterModePoint = 0,
123 /// Linear filter mode.
124 cudaFilterModeLinear = 1,
125}
126/// CUDA texture read modes.
127#[repr(u32)]
128#[derive(
129 Debug,
130 Copy,
131 Clone,
132 Hash,
133 PartialOrd,
134 Ord,
135 PartialEq,
136 Eq,
137 TryFromPrimitive,
138 IntoPrimitive,
139)]
140pub enum cudaTextureReadMode {
141 /// Read texture as specified element type.
142 cudaReadModeElementType = 0,
143 /// Read texture as normalized float.
144 cudaReadModeNormalizedFloat = 1,
145}
146/// CUDA texture descriptor.
147#[repr(C)]
148#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
149pub struct cudaTextureDesc {
150 /// Texture address mode for up to 3 dimensions.
151 pub addressMode: [cudaTextureAddressMode; 3usize],
152 /// Texture filter mode.
153 pub filterMode: cudaTextureFilterMode,
154 /// Texture read mode.
155 pub readMode: cudaTextureReadMode,
156 /// Perform sRGB->linear conversion during texture read.
157 pub sRGB: ::core::ffi::c_int,
158 /// Texture Border Color.
159 pub borderColor: [f32; 4usize],
160 /// Indicates whether texture reads are normalized or not.
161 pub normalizedCoords: ::core::ffi::c_int,
162 /// Limit to the anisotropy ratio.
163 pub maxAnisotropy: ::core::ffi::c_uint,
164 /// Mipmap filter mode.
165 pub mipmapFilterMode: cudaTextureFilterMode,
166 /// Offset applied to the supplied mipmap level.
167 pub mipmapLevelBias: f32,
168 /// Lower end of the mipmap level range to clamp access to.
169 pub minMipmapLevelClamp: f32,
170 /// Upper end of the mipmap level range to clamp access to.
171 pub maxMipmapLevelClamp: f32,
172 /// Disable any trilinear filtering optimizations.
173 pub disableTrilinearOptimization: ::core::ffi::c_int,
174 /// Enable seamless cube map filtering.
175 pub seamlessCubemap: ::core::ffi::c_int,
176}
177impl Default for cudaTextureDesc {
178 fn default() -> Self {
179 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
180 unsafe {
181 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
182 s.assume_init()
183 }
184 }
185}
186/// An opaque value that represents a CUDA texture object.
187pub type cudaTextureObject_t = ::core::ffi::c_ulonglong;
188unsafe extern "C" {
189 /// Destroy all allocations and reset all state on the current device in the current process.
190 ///
191 /// Explicitly destroys and cleans up all resources associated with the current device in the current process. It is the caller's
192 /// responsibility to ensure that the resources are not accessed or passed in subsequent API calls and doing so will result in
193 /// undefined behavior. These resources include CUDA types `cudaStream_t`, `cudaEvent_t`, `cudaArray_t`, `cudaMipmappedArray_t`, [`cudaPitchedPtr`], [`cudaTextureObject_t`], [`cudaSurfaceObject_t`], textureReference, surfaceReference, `cudaExternalMemory_t`, `cudaExternalSemaphore_t` and `cudaGraphicsResource_t`. These resources also include memory allocations by [`cudaMalloc`], [`cudaMallocHost`], [`cudaMallocManaged`] and [`cudaMallocPitch`]. Any subsequent API call to this device will reinitialize the device.
194 ///
195 /// Note that this function will reset the device immediately. It is the caller's responsibility to ensure that the device is
196 /// not being accessed by any other host threads from the process when this function is called.
197 ///
198 /// Note:
199 ///
200 /// * [`cudaDeviceReset`] will not destroy memory allocations by [`cudaMallocAsync`] and [`cudaMallocFromPoolAsync`]. These memory allocations need to be destroyed explicitly.
201 /// * If a non-primary [CUcontext](https://docs.nvidia.com/cuda/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](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1gf9f5bd81658f866613785b3a0bb7d7d9).
202 ///
203 /// Note:
204 ///
205 /// * Note that this function may also return error codes from previous, asynchronous launches.
206 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
207 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
208 ///
209 /// **See also:**
210 ///
211 /// [`cudaDeviceSynchronize`].
212 pub fn cudaDeviceReset() -> cudaError_t;
213}
214unsafe extern "C" {
215 /// Wait for compute device to finish.
216 ///
217 /// 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` flag was set for this device, the host thread will block until the device has finished its work.
218 ///
219 /// Note:
220 ///
221 /// * Use of cudaDeviceSynchronize in device code was deprecated in CUDA 11.6 and removed for compute_90+ compilation. For compute
222 /// 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.
223 /// * Note that this function may also return error codes from previous, asynchronous launches.
224 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
225 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
226 ///
227 /// **See also:**
228 ///
229 /// [`cudaDeviceReset`], [cuCtxSynchronize](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g7a54725f28d34b8c6299f0c6ca579616).
230 pub fn cudaDeviceSynchronize() -> cudaError_t;
231}
232unsafe extern "C" {
233 /// Set resource limits.
234 ///
235 /// 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
236 /// value to meet h/w requirements (this could be clamping to minimum or maximum values, rounding up to nearest element size,
237 /// etc). The application can use [`cudaDeviceGetLimit`] to find out exactly what the limit has been set to.
238 ///
239 /// Setting each [`cudaLimit`] has its own specific restrictions, so each is discussed here.
240 ///
241 /// * [`cudaLimit::cudaLimitStackSize`] controls the stack size in bytes of each GPU thread.
242 ///
243 /// * [`cudaLimit::cudaLimitPrintfFifoSize`] controls the size in bytes of the shared FIFO used by the printf() device system call. Setting [`cudaLimit::cudaLimitPrintfFifoSize`] must not be performed after launching any kernel that uses the printf() device system call - in such case [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
244 ///
245 /// * [`cudaLimit::cudaLimitMallocHeapSize`] controls the size in bytes of the heap used by the malloc() and free() device system calls. Setting [`cudaLimit::cudaLimitMallocHeapSize`] must not be performed after launching any kernel that uses the malloc() or free() device system calls - in such case [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
246 ///
247 /// * [`cudaLimit::cudaLimitDevRuntimeSyncDepth`] controls the maximum nesting depth of a grid at which a thread can safely call [`cudaDeviceSynchronize`]. Setting this limit must be performed before any launch of a kernel that uses the device runtime and calls [`cudaDeviceSynchronize`] above the default sync depth, two levels of grids. Calls to [`cudaDeviceSynchronize`] will fail with error code [cudaErrorSyncDepthExceeded](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038265dbf94c45903cd582cfc40f93a176a) if the limitation is violated. This limit can be set smaller than the default or up the maximum launch depth of 24. When
248 /// setting this limit, keep in mind that additional levels of sync depth require the runtime to reserve large amounts of device
249 /// memory which can no longer be used for user allocations. If these reservations of device memory fail, [`cudaDeviceSetLimit`] will return [cudaErrorMemoryAllocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
250 /// to set this limit on devices of other compute capability will results in error [cudaErrorUnsupportedLimit](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c3b950b6f8668f7282fae25bfcefd13a) being returned.
251 ///
252 /// * [`cudaLimit::cudaLimitDevRuntimePendingLaunchCount`] controls the maximum number of outstanding device runtime launches that can be made from the current device. A grid is outstanding
253 /// from the point of launch up until the grid is known to have been completed. Device runtime launches which violate this limitation
254 /// fail and return [cudaErrorLaunchPendingCountExceeded](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
255 /// runtime, this limit can be increased. Keep in mind that being able to sustain additional pending launches will require the
256 /// runtime to reserve larger amounts of device memory upfront which can no longer be used for allocations. If these reservations
257 /// fail, [`cudaDeviceSetLimit`] will return [cudaErrorMemoryAllocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
258 /// Attempting to set this limit on devices of compute capability less than 3.5 will result in the error [cudaErrorUnsupportedLimit](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c3b950b6f8668f7282fae25bfcefd13a) being returned.
259 ///
260 /// * [`cudaLimit::cudaLimitMaxL2FetchGranularity`] controls the L2 cache fetch granularity. Values can range from 0B to 128B. This is purely a performance hint and it can be
261 /// ignored or clamped depending on the platform.
262 ///
263 /// * [`cudaLimit::cudaLimitPersistingL2CacheSize`] controls size in bytes available for persisting L2 cache. This is purely a performance hint and it can be ignored or clamped
264 /// depending on the platform.
265 ///
266 /// Note:
267 ///
268 /// * Note that this function may also return error codes from previous, asynchronous launches.
269 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
270 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
271 ///
272 /// **See also:**
273 ///
274 /// [`cudaDeviceGetLimit`], [cuCtxSetLimit](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g0651954dfb9788173e60a9af7201e65a).
275 ///
276 /// # Parameters
277 ///
278 /// - `limit`: Limit to set.
279 /// - `value`: Size of limit.
280 pub fn cudaDeviceSetLimit(limit: cudaLimit, value: size_t) -> cudaError_t;
281}
282unsafe extern "C" {
283 /// Return resource limits.
284 ///
285 /// Returns in \*pValue the current size of limit. The following [`cudaLimit`] values are supported.
286 ///
287 /// * [`cudaLimit::cudaLimitStackSize`] is the stack size in bytes of each GPU thread.
288 /// * [`cudaLimit::cudaLimitPrintfFifoSize`] is the size in bytes of the shared FIFO used by the printf() device system call.
289 /// * [`cudaLimit::cudaLimitMallocHeapSize`] is the size in bytes of the heap used by the malloc() and free() device system calls.
290 /// * [`cudaLimit::cudaLimitDevRuntimeSyncDepth`] is the maximum grid depth at which a thread can isssue the device runtime call [`cudaDeviceSynchronize`] to wait on child grid launches to complete. This functionality is removed for devices of compute capability >= 9.0, and hence
291 /// will return error [cudaErrorUnsupportedLimit](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c3b950b6f8668f7282fae25bfcefd13a) on such devices.
292 /// * [`cudaLimit::cudaLimitDevRuntimePendingLaunchCount`] is the maximum number of outstanding device runtime launches.
293 /// * [`cudaLimit::cudaLimitMaxL2FetchGranularity`] is the L2 cache fetch granularity.
294 /// * [`cudaLimit::cudaLimitPersistingL2CacheSize`] is the persisting L2 cache size in bytes.
295 ///
296 /// Note:
297 ///
298 /// * Note that this function may also return error codes from previous, asynchronous launches.
299 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
300 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
301 ///
302 /// **See also:**
303 ///
304 /// [`cudaDeviceSetLimit`], [cuCtxGetLimit](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g9f2d47d1745752aa16da7ed0d111b6a8).
305 ///
306 /// # Parameters
307 ///
308 /// - `pValue`: Returned size of the limit.
309 /// - `limit`: Limit to query.
310 pub fn cudaDeviceGetLimit(pValue: *mut size_t, limit: cudaLimit) -> cudaError_t;
311}
312unsafe extern "C" {
313 /// Returns the maximum number of elements allocatable in a 1D linear texture for a given element size.
314 ///
315 /// Returns in maxWidthInElements the maximum number of elements allocatable in a 1D linear texture for given format descriptor fmtDesc.
316 ///
317 /// Note:
318 ///
319 /// * Note that this function may also return error codes from previous, asynchronous launches.
320 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
321 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
322 ///
323 /// **See also:**
324 ///
325 /// [cuDeviceGetTexture1DLinearMaxWidth](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gb41b3a675bae9932bffa1c0ae969b1e0).
326 ///
327 /// # Parameters
328 ///
329 /// - `maxWidthInElements`: Returns maximum number of texture elements allocatable for given fmtDesc.
330 /// - `fmtDesc`: Texture format description.
331 pub fn cudaDeviceGetTexture1DLinearMaxWidth(
332 maxWidthInElements: *mut size_t,
333 fmtDesc: *const cudaChannelFormatDesc,
334 device: ::core::ffi::c_int,
335 ) -> cudaError_t;
336}
337unsafe extern "C" {
338 /// Returns the preferred cache configuration for the current device.
339 ///
340 /// 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
341 /// if possible, but it is free to choose a different configuration if required to execute functions.
342 ///
343 /// This will return a pCacheConfig of [cudaFuncCachePreferNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b3b4b8c65376ce1ca107be413e15981bc) on devices where the size of the L1 cache and shared memory are fixed.
344 ///
345 /// The supported cache configurations are:
346 ///
347 /// * [cudaFuncCachePreferNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b3b4b8c65376ce1ca107be413e15981bc): no preference for shared memory or L1 (default)
348 /// * [cudaFuncCachePreferShared](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b84725d25c531f9bafc61ae329afe5b2b): prefer larger shared memory and smaller L1 cache
349 /// * [cudaFuncCachePreferL1](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b8ecb48ccbc2230c81528a2c7c695100e): prefer larger L1 cache and smaller shared memory
350 /// * [cudaFuncCachePreferEqual](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49bd151ac8d667150c601de4b9542887a3b): prefer equal size L1 cache and shared memory
351 ///
352 /// Note:
353 ///
354 /// * Note that this function may also return error codes from previous, asynchronous launches.
355 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
356 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
357 ///
358 /// **See also:**
359 ///
360 /// [`cudaDeviceSetCacheConfig`], [cudaFuncSetCacheConfig ( C API)](https://docs.nvidia.com/cuda/cuda-runtime-api/execution-control.html#group__CUDART__EXECUTION_1g6699ca1943ac2655effa0d571b2f4f15 "Sets the preferred cache configuration for a device function."), [cudaFuncSetCacheConfig ( C++ API)](https://docs.nvidia.com/cuda/cuda-runtime-api/high-level-api.html#group__CUDART__HIGHLEVEL_1g7d9cc996fe45b6260ebb086caff1c685 "\[C++ API\] Sets the preferred cache configuration for a device function"), [cuCtxGetCacheConfig](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g40b6b141698f76744dea6e39b9a25360).
361 ///
362 /// # Parameters
363 ///
364 /// - `pCacheConfig`: Returned cache configuration.
365 pub fn cudaDeviceGetCacheConfig(pCacheConfig: *mut cudaFuncCache) -> cudaError_t;
366}
367unsafe extern "C" {
368 /// Returns numerical values that correspond to the least and greatest stream priorities.
369 ///
370 /// Returns in \*leastPriority and \*greatestPriority the numerical values that correspond to the least and greatest stream priorities respectively. Stream priorities follow a
371 /// convention where lower numbers imply greater priorities. The range of meaningful stream priorities is given by \[\*greatestPriority, \*leastPriority\]. If the user attempts to create a stream with a priority value that is outside the meaningful range as specified by
372 /// 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.
373 ///
374 /// This function will return '0' in both \*leastPriority and \*greatestPriority if the current context's device does not support stream priorities (see [`cudaDeviceGetAttribute`]).
375 ///
376 /// Note:
377 ///
378 /// * Note that this function may also return error codes from previous, asynchronous launches.
379 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
380 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
381 ///
382 /// **See also:**
383 ///
384 /// [`cudaStreamCreateWithPriority`], [`cudaStreamGetPriority`], [cuCtxGetStreamPriorityRange](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g137920ab61a71be6ce67605b9f294091).
385 ///
386 /// # Parameters
387 ///
388 /// - `leastPriority`: Pointer to an int in which the numerical value for least stream priority is returned.
389 /// - `greatestPriority`: Pointer to an int in which the numerical value for greatest stream priority is returned.
390 pub fn cudaDeviceGetStreamPriorityRange(
391 leastPriority: *mut ::core::ffi::c_int,
392 greatestPriority: *mut ::core::ffi::c_int,
393 ) -> cudaError_t;
394}
395unsafe extern "C" {
396 /// Sets the preferred cache configuration for the current device.
397 ///
398 /// 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
399 /// if possible, but it is free to choose a different configuration if required to execute the function. Any function preference
400 /// set via [cudaFuncSetCacheConfig ( C API)](https://docs.nvidia.com/cuda/cuda-runtime-api/execution-control.html#group__CUDART__EXECUTION_1g6699ca1943ac2655effa0d571b2f4f15 "Sets the preferred cache configuration for a device function.") or [cudaFuncSetCacheConfig ( C++ API)](https://docs.nvidia.com/cuda/cuda-runtime-api/high-level-api.html#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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b3b4b8c65376ce1ca107be413e15981bc) will cause subsequent kernel launches to prefer to not change the cache configuration unless required to launch the kernel.
401 ///
402 /// This setting does nothing on devices where the size of the L1 cache and shared memory are fixed.
403 ///
404 /// Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization
405 /// point.
406 ///
407 /// The supported cache configurations are:
408 ///
409 /// * [cudaFuncCachePreferNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b3b4b8c65376ce1ca107be413e15981bc): no preference for shared memory or L1 (default)
410 /// * [cudaFuncCachePreferShared](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b84725d25c531f9bafc61ae329afe5b2b): prefer larger shared memory and smaller L1 cache
411 /// * [cudaFuncCachePreferL1](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49b8ecb48ccbc2230c81528a2c7c695100e): prefer larger L1 cache and smaller shared memory
412 /// * [cudaFuncCachePreferEqual](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggb980f35ed69ee7991704de29a13de49bd151ac8d667150c601de4b9542887a3b): prefer equal size L1 cache and shared memory
413 ///
414 /// Note:
415 ///
416 /// * Note that this function may also return error codes from previous, asynchronous launches.
417 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
418 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
419 ///
420 /// **See also:**
421 ///
422 /// [`cudaDeviceGetCacheConfig`], [cudaFuncSetCacheConfig ( C API)](https://docs.nvidia.com/cuda/cuda-runtime-api/execution-control.html#group__CUDART__EXECUTION_1g6699ca1943ac2655effa0d571b2f4f15 "Sets the preferred cache configuration for a device function."), [cudaFuncSetCacheConfig ( C++ API)](https://docs.nvidia.com/cuda/cuda-runtime-api/high-level-api.html#group__CUDART__HIGHLEVEL_1g7d9cc996fe45b6260ebb086caff1c685 "\[C++ API\] Sets the preferred cache configuration for a device function"), [cuCtxSetCacheConfig](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g54699acf7e2ef27279d013ca2095f4a3).
423 ///
424 /// # Parameters
425 ///
426 /// - `cacheConfig`: Requested cache configuration.
427 pub fn cudaDeviceSetCacheConfig(cacheConfig: cudaFuncCache) -> cudaError_t;
428}
429unsafe extern "C" {
430 /// Returns a handle to a compute device.
431 ///
432 /// Returns in \*device a device ordinal given a PCI bus ID string.
433 ///
434 /// Note:
435 ///
436 /// * Note that this function may also return error codes from previous, asynchronous launches.
437 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
438 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
439 ///
440 /// **See also:**
441 ///
442 /// [`cudaDeviceGetPCIBusId`], [cuDeviceGetByPCIBusId](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ga89cd3fa06334ba7853ed1232c5ebe2a).
443 ///
444 /// # Parameters
445 ///
446 /// - `device`: Returned device ordinal.
447 /// - `pciBusId`: String in one of the following forms: \[domain\]:\[bus\]:\[device\].\[function\] \[domain\]:\[bus\]:\[device\] \[bus\]:\[device\].\[function\]
448 /// where domain, bus, device, and function are all hexadecimal values.
449 pub fn cudaDeviceGetByPCIBusId(
450 device: *mut ::core::ffi::c_int,
451 pciBusId: *const ::core::ffi::c_char,
452 ) -> cudaError_t;
453}
454unsafe extern "C" {
455 /// Returns a PCI Bus Id string for the device.
456 ///
457 /// 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.
458 ///
459 /// Note:
460 ///
461 /// * Note that this function may also return error codes from previous, asynchronous launches.
462 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
463 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
464 ///
465 /// **See also:**
466 ///
467 /// [`cudaDeviceGetByPCIBusId`], [cuDeviceGetPCIBusId](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g85295e7d9745ab8f0aa80dd1e172acfc).
468 ///
469 /// # Parameters
470 ///
471 /// - `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.
472 /// - `len`: Maximum length of string to store in name.
473 /// - `device`: Device to get identifier string for.
474 pub fn cudaDeviceGetPCIBusId(
475 pciBusId: *mut ::core::ffi::c_char,
476 len: ::core::ffi::c_int,
477 device: ::core::ffi::c_int,
478 ) -> cudaError_t;
479}
480unsafe extern "C" {
481 /// Gets an interprocess handle for a previously allocated event.
482 ///
483 /// Takes as input a previously allocated event. This event must have been created with the `cudaEventInterprocess` and `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.
484 ///
485 /// 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.
486 ///
487 /// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
488 /// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
489 /// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
490 ///
491 /// Note:
492 ///
493 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
494 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
495 ///
496 /// **See also:**
497 ///
498 /// [`cudaEventCreate`], [`cudaEventDestroy`], [`cudaEventSynchronize`], [`cudaEventQuery`], [`cudaStreamWaitEvent`], [`cudaIpcOpenEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcOpenMemHandle`], [`cudaIpcCloseMemHandle`], [cuIpcGetEventHandle](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gea02eadd12483de5305878b13288a86c).
499 ///
500 /// # Parameters
501 ///
502 /// - `handle`: Pointer to a user allocated cudaIpcEventHandle in which to return the opaque event handle.
503 /// - `event`: Event allocated with `cudaEventInterprocess` and `cudaEventDisableTiming` flags.
504 pub fn cudaIpcGetEventHandle(
505 handle: *mut cudaIpcEventHandle_t,
506 event: cudaEvent_t,
507 ) -> cudaError_t;
508}
509unsafe extern "C" {
510 /// Opens an interprocess event handle for use in the current process.
511 ///
512 /// Opens an interprocess event handle exported from another process with [`cudaIpcGetEventHandle`]. This function returns a `cudaEvent_t` that behaves like a locally created event with the `cudaEventDisableTiming` flag specified. This event must be freed with [`cudaEventDestroy`].
513 ///
514 /// Performing operations on the imported event after the exported event has been freed with [`cudaEventDestroy`] will result in undefined behavior.
515 ///
516 /// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
517 /// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
518 /// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
519 ///
520 /// Note:
521 ///
522 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
523 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
524 ///
525 /// **See also:**
526 ///
527 /// [`cudaEventCreate`], [`cudaEventDestroy`], [`cudaEventSynchronize`], [`cudaEventQuery`], [`cudaStreamWaitEvent`], [`cudaIpcGetEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcOpenMemHandle`], [`cudaIpcCloseMemHandle`], [cuIpcOpenEventHandle](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf1d525918b6c643b99ca8c8e42e36c2e).
528 ///
529 /// # Parameters
530 ///
531 /// - `event`: Returns the imported event.
532 /// - `handle`: Interprocess handle to open.
533 pub fn cudaIpcOpenEventHandle(
534 event: *mut cudaEvent_t,
535 handle: cudaIpcEventHandle_t,
536 ) -> cudaError_t;
537}
538unsafe extern "C" {
539 /// Gets an interprocess memory handle for an existing device memory allocation.
540 ///
541 /// 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
542 /// without adverse effects.
543 ///
544 /// 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.
545 ///
546 /// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
547 /// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
548 /// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
549 ///
550 /// Note:
551 ///
552 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
553 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
554 ///
555 /// **See also:**
556 ///
557 /// [`cudaMalloc`], [`cudaFree`], [`cudaIpcGetEventHandle`], [`cudaIpcOpenEventHandle`], [`cudaIpcOpenMemHandle`], [`cudaIpcCloseMemHandle`], [cuIpcGetMemHandle](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g6f1b5be767b275f016523b2ac49ebec1).
558 ///
559 /// # Parameters
560 ///
561 /// - `handle`: Pointer to user allocated cudaIpcMemHandle to return the handle in.
562 /// - `devPtr`: Base pointer to previously allocated device memory.
563 pub fn cudaIpcGetMemHandle(
564 handle: *mut cudaIpcMemHandle_t,
565 devPtr: *mut ::core::ffi::c_void,
566 ) -> cudaError_t;
567}
568unsafe extern "C" {
569 /// Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process.
570 ///
571 /// 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` flag. [`cudaDeviceCanAccessPeer`] can determine if a mapping is possible.
572 ///
573 /// [`cudaIpcOpenMemHandle`] can open handles to devices that may not be visible in the process calling the API.
574 ///
575 /// Contexts that may open cudaIpcMemHandles are restricted in the following way. cudaIpcMemHandles from each device in a given
576 /// process may only be opened by one context per device per other process.
577 ///
578 /// If the memory handle has already been opened by the current context, the reference count on the handle is incremented by 1
579 /// and the existing device pointer is returned.
580 ///
581 /// Memory returned from [`cudaIpcOpenMemHandle`] must be freed with [`cudaIpcCloseMemHandle`].
582 ///
583 /// Calling [`cudaFree`] on an exported memory region before calling [`cudaIpcCloseMemHandle`] in the importing context will result in undefined behavior.
584 ///
585 /// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
586 /// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
587 /// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
588 ///
589 /// Note:
590 ///
591 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
592 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
593 /// * No guarantees are made about the address returned in \*devPtr. In particular, multiple processes may not receive the same address for the same handle.
594 ///
595 /// **See also:**
596 ///
597 /// [`cudaMalloc`], [`cudaFree`], [`cudaIpcGetEventHandle`], [`cudaIpcOpenEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcCloseMemHandle`], [`cudaDeviceEnablePeerAccess`], [`cudaDeviceCanAccessPeer`], [cuIpcOpenMemHandle](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ga8bd126fcff919a0c996b7640f197b79).
598 ///
599 /// # Parameters
600 ///
601 /// - `devPtr`: Returned device pointer.
602 /// - `handle`: cudaIpcMemHandle to open.
603 /// - `flags`: Flags for this operation. Must be specified as `cudaIpcMemLazyEnablePeerAccess`.
604 pub fn cudaIpcOpenMemHandle(
605 devPtr: *mut *mut ::core::ffi::c_void,
606 handle: cudaIpcMemHandle_t,
607 flags: ::core::ffi::c_uint,
608 ) -> cudaError_t;
609}
610unsafe extern "C" {
611 /// Attempts to close memory mapped with cudaIpcOpenMemHandle.
612 ///
613 /// 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
614 /// well as imported mappings in other processes will be unaffected.
615 ///
616 /// Any resources used to enable peer access will be freed if this is the last mapping using them.
617 ///
618 /// IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC
619 /// functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users
620 /// can test their device for IPC functionality by calling [`cudaDeviceGetAttribute`] with [cudaDevAttrIpcEventSupport](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd0ab012a7c597ffbe86090ee2f9e1758c)
621 ///
622 /// Note:
623 ///
624 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
625 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
626 ///
627 /// **See also:**
628 ///
629 /// [`cudaMalloc`], [`cudaFree`], [`cudaIpcGetEventHandle`], [`cudaIpcOpenEventHandle`], [`cudaIpcGetMemHandle`], [`cudaIpcOpenMemHandle`], [cuIpcCloseMemHandle](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gd6f5d5bcf6376c6853b64635b0157b9e).
630 ///
631 /// # Parameters
632 ///
633 /// - `devPtr`: Device pointer returned by [`cudaIpcOpenMemHandle`].
634 pub fn cudaIpcCloseMemHandle(devPtr: *mut ::core::ffi::c_void) -> cudaError_t;
635}
636unsafe extern "C" {
637 /// Blocks until remote writes are visible to the specified scope.
638 ///
639 /// Blocks until remote writes to the target context via mappings created through GPUDirect RDMA APIs, like nvidia_p2p_get_pages
640 /// (see <https://docs.nvidia.com/cuda/gpudirect-rdma> for more information), are visible to the specified scope.
641 ///
642 /// If the scope equals or lies within the scope indicated by [cudaDevAttrGPUDirectRDMAWritesOrdering](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
643 /// between the two enums, with smaller scopes having smaller values.
644 ///
645 /// Users may query support for this API via [cudaDevAttrGPUDirectRDMAFlushWritesOptions](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd7b3462e13705248606f39fb5381446ee).
646 ///
647 /// Note:
648 ///
649 /// * Note that this function may also return error codes from previous, asynchronous launches.
650 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
651 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
652 ///
653 /// **See also:**
654 ///
655 /// [cuFlushGPUDirectRDMAWrites](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g265e3c82ef0f0fe035f85c4c45a8fbdf).
656 ///
657 /// # Parameters
658 ///
659 /// - `target`: The target of the operation, see cudaFlushGPUDirectRDMAWritesTarget.
660 /// - `scope`: The scope of the operation, see cudaFlushGPUDirectRDMAWritesScope.
661 pub fn cudaDeviceFlushGPUDirectRDMAWrites(
662 target: cudaFlushGPUDirectRDMAWritesTarget,
663 scope: cudaFlushGPUDirectRDMAWritesScope,
664 ) -> cudaError_t;
665}
666unsafe extern "C" {
667 /// Registers a callback function to receive async notifications.
668 ///
669 /// Registers callbackFunc to receive async notifications.
670 ///
671 /// 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.
672 ///
673 /// The callback function being registered should be designed to return quickly (~10ms). Any long running tasks should be queued
674 /// for execution on an application thread.
675 ///
676 /// Callbacks may not call cudaDeviceRegisterAsyncNotification or cudaDeviceUnregisterAsyncNotification. Doing so will result
677 /// in [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3). Async notification callbacks execute in an undefined order and may be serialized.
678 ///
679 /// Returns in \*callback a handle representing the registered callback instance.
680 ///
681 /// Note:
682 ///
683 /// Note that this function may also return error codes from previous, asynchronous launches.
684 ///
685 /// **See also:**
686 ///
687 /// [`cudaDeviceUnregisterAsyncNotification`].
688 ///
689 /// # Parameters
690 ///
691 /// - `device`: The device on which to register the callback.
692 /// - `callbackFunc`: The function to register as a callback.
693 /// - `userData`: A generic pointer to user data. This is passed into the callback function.
694 /// - `callback`: A handle representing the registered callback instance.
695 pub fn cudaDeviceRegisterAsyncNotification(
696 device: ::core::ffi::c_int,
697 callbackFunc: cudaAsyncCallback,
698 userData: *mut ::core::ffi::c_void,
699 callback: *mut cudaAsyncCallbackHandle_t,
700 ) -> cudaError_t;
701}
702unsafe extern "C" {
703 /// Unregisters an async notification callback.
704 ///
705 /// Unregisters callback so that the corresponding callback function will stop receiving async notifications.
706 ///
707 /// Note:
708 ///
709 /// Note that this function may also return error codes from previous, asynchronous launches.
710 ///
711 /// **See also:**
712 ///
713 /// [`cudaDeviceRegisterAsyncNotification`].
714 ///
715 /// # Parameters
716 ///
717 /// - `device`: The device from which to remove callback.
718 /// - `callback`: The callback instance to unregister from receiving async notifications.
719 pub fn cudaDeviceUnregisterAsyncNotification(
720 device: ::core::ffi::c_int,
721 callback: cudaAsyncCallbackHandle_t,
722 ) -> cudaError_t;
723}
724unsafe extern "C" {
725 /// Returns the shared memory configuration for the current device.
726 ///
727 /// pConfig
728 ///
729 /// [`cudaDeviceSetSharedMemConfig`]
730 ///
731 /// [`cudaDeviceGetSharedMemConfig`]
732 ///
733 /// The returned bank configurations can be either:
734 ///
735 /// * cudaSharedMemBankSizeFourByte - shared memory bank width is four bytes.
736 /// * cudaSharedMemBankSizeEightByte - shared memory bank width is eight bytes.
737 ///
738 /// Note:
739 ///
740 /// * Note that this function may also return error codes from previous, asynchronous launches.
741 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
742 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
743 ///
744 /// **See also:**
745 ///
746 /// [`cudaDeviceSetCacheConfig`], [`cudaDeviceGetCacheConfig`], [`cudaDeviceSetSharedMemConfig`], [`cudaFuncSetCacheConfig`], [cuCtxGetSharedMemConfig](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX__DEPRECATED.html#group__CUDA__CTX__DEPRECATED_1gfac1414497a1a2a40bba474c6b5bf194).
747 ///
748 /// # Parameters
749 ///
750 /// - `pConfig`: Returned cache configuration.
751 #[deprecated]
752 pub fn cudaDeviceGetSharedMemConfig(
753 pConfig: *mut cudaSharedMemConfig,
754 ) -> cudaError_t;
755}
756unsafe extern "C" {
757 /// Sets the shared memory configuration for the current device.
758 ///
759 /// [`cudaFuncSetSharedMemConfig`]
760 ///
761 /// Changing the shared memory configuration between launches may introduce a device side synchronization point.
762 ///
763 /// Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major
764 /// effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what
765 /// kinds of accesses to shared memory will result in bank conflicts.
766 ///
767 /// This function will do nothing on devices with fixed shared memory bank size.
768 ///
769 /// The supported bank configurations are:
770 ///
771 /// * cudaSharedMemBankSizeDefault: set bank width the device default (currently, four bytes)
772 /// * cudaSharedMemBankSizeFourByte: set shared memory bank width to be four bytes natively.
773 /// * cudaSharedMemBankSizeEightByte: set shared memory bank width to be eight bytes natively.
774 ///
775 /// Note:
776 ///
777 /// * Note that this function may also return error codes from previous, asynchronous launches.
778 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
779 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
780 ///
781 /// **See also:**
782 ///
783 /// [`cudaDeviceSetCacheConfig`], [`cudaDeviceGetCacheConfig`], [`cudaDeviceGetSharedMemConfig`], [`cudaFuncSetCacheConfig`], [cuCtxSetSharedMemConfig](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX__DEPRECATED.html#group__CUDA__CTX__DEPRECATED_1gb1fef6f9fd5c252245214f85ae01ec23).
784 ///
785 /// # Parameters
786 ///
787 /// - `config`: Requested cache configuration.
788 #[deprecated]
789 pub fn cudaDeviceSetSharedMemConfig(config: cudaSharedMemConfig) -> cudaError_t;
790}
791unsafe extern "C" {
792 /// Returns the last error from a runtime call.
793 ///
794 /// Returns the last error that has been produced by any of the runtime calls in the same instance of the CUDA Runtime library
795 /// in the host thread and resets it to [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591).
796 ///
797 /// Note: Multiple instances of the CUDA Runtime library can be present in an application when using a library that statically
798 /// links the CUDA Runtime.
799 ///
800 /// Note:
801 ///
802 /// * Note that this function may also return error codes from previous, asynchronous launches.
803 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
804 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
805 ///
806 /// **See also:**
807 ///
808 /// [`cudaPeekAtLastError`], [`cudaGetErrorName`], [`cudaGetErrorString`], `cudaError`.
809 pub fn cudaGetLastError() -> cudaError_t;
810}
811unsafe extern "C" {
812 /// Returns the last error from a runtime call.
813 ///
814 /// Returns the last error that has been produced by any of the runtime calls in the same instance of the CUDA Runtime library
815 /// in the host thread. This call does not reset the error to [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) like [`cudaGetLastError`].
816 ///
817 /// Note: Multiple instances of the CUDA Runtime library can be present in an application when using a library that statically
818 /// links the CUDA Runtime.
819 ///
820 /// Note:
821 ///
822 /// * Note that this function may also return error codes from previous, asynchronous launches.
823 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
824 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
825 ///
826 /// **See also:**
827 ///
828 /// [`cudaGetLastError`], [`cudaGetErrorName`], [`cudaGetErrorString`], `cudaError`.
829 pub fn cudaPeekAtLastError() -> cudaError_t;
830}
831unsafe extern "C" {
832 /// Returns the string representation of an error code enum name.
833 ///
834 /// Returns a string containing the name of an error code in the enum. If the error code is not recognized, "unrecognized error
835 /// code" is returned.
836 ///
837 /// **See also:**
838 ///
839 /// [`cudaGetErrorString`], [`cudaGetLastError`], [`cudaPeekAtLastError`], `cudaError`, [cuGetErrorName](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__ERROR.html#group__CUDA__ERROR_1g2c4ac087113652bb3d1f95bf2513c468).
840 ///
841 /// # Parameters
842 ///
843 /// - `error`: Error code to convert to string.
844 pub fn cudaGetErrorName(error: cudaError_t) -> *const ::core::ffi::c_char;
845}
846unsafe extern "C" {
847 /// Returns the description string for an error code.
848 ///
849 /// Returns the description string for an error code. If the error code is not recognized, "unrecognized error code" is returned.
850 ///
851 /// **See also:**
852 ///
853 /// [`cudaGetErrorName`], [`cudaGetLastError`], [`cudaPeekAtLastError`], `cudaError`, [cuGetErrorString](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__ERROR.html#group__CUDA__ERROR_1g72758fcaf05b5c7fac5c25ead9445ada).
854 ///
855 /// # Parameters
856 ///
857 /// - `error`: Error code to convert to string.
858 pub fn cudaGetErrorString(error: cudaError_t) -> *const ::core::ffi::c_char;
859}
860unsafe extern "C" {
861 /// Returns the number of compute-capable devices.
862 ///
863 /// Returns in \*count the number of devices with compute capability greater or equal to 2.0 that are available for execution.
864 ///
865 /// Note:
866 ///
867 /// * Note that this function may also return error codes from previous, asynchronous launches.
868 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
869 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
870 ///
871 /// **See also:**
872 ///
873 /// [`cudaGetDevice`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cudaInitDevice`], [cuDeviceGetCount](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g52b5ce05cb8c5fb6831b2c0ff2887c74).
874 ///
875 /// # Parameters
876 ///
877 /// - `count`: Returns the number of devices with compute capability greater or equal to 2.0.
878 pub fn cudaGetDeviceCount(count: *mut ::core::ffi::c_int) -> cudaError_t;
879}
880unsafe extern "C" {
881 /// Returns information about the compute-device.
882 ///
883 /// Returns in \*prop the properties of device dev.
884 ///
885 /// Note:
886 ///
887 /// * Note that this function may also return error codes from previous, asynchronous launches.
888 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
889 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
890 ///
891 /// **See also:**
892 ///
893 /// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaChooseDevice`], [`cudaDeviceGetAttribute`], [`cudaInitDevice`], [cuDeviceGetAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g9c3e1414f0ad901d3278a4d6645fc266), [cuDeviceGetName](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gef75aa30df95446a845f2a7b9fffbb7f).
894 ///
895 /// # Parameters
896 ///
897 /// - `prop`: Properties for the specified device.
898 /// - `device`: Device number to get properties for.
899 pub fn cudaGetDeviceProperties(
900 prop: *mut cudaDeviceProp,
901 device: ::core::ffi::c_int,
902 ) -> cudaError_t;
903}
904unsafe extern "C" {
905 /// Returns information about the device.
906 ///
907 /// Returns in \*value the integer value of the attribute attr on device device.
908 ///
909 /// Note:
910 ///
911 /// * Note that this function may also return error codes from previous, asynchronous launches.
912 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
913 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
914 ///
915 /// **See also:**
916 ///
917 /// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaChooseDevice`], [`cudaGetDeviceProperties`], [`cudaInitDevice`], [cuDeviceGetAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g9c3e1414f0ad901d3278a4d6645fc266).
918 ///
919 /// # Parameters
920 ///
921 /// - `value`: Returned device attribute value.
922 /// - `attr`: Device attribute to query.
923 /// - `device`: Device number to query.
924 pub fn cudaDeviceGetAttribute(
925 value: *mut ::core::ffi::c_int,
926 attr: cudaDeviceAttr,
927 device: ::core::ffi::c_int,
928 ) -> cudaError_t;
929}
930unsafe extern "C" {
931 /// Queries details about atomic operations supported between the device and host.
932 ///
933 /// Returns in \*capabilities the details about requested atomic \*operations over the link between dev and the host. The allocated size of \*operations and \*capabilities must be count.
934 ///
935 /// For each [`cudaAtomicOperation`] in \*operations, the corresponding result in \*capabilities will be a bitmask indicating which of `cudaAtomicOperationCapability` the link supports natively.
936 ///
937 /// Returns [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a) if dev is not valid.
938 ///
939 /// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if \*capabilities or \*operations is NULL, if count is 0, or if any of \*operations is not valid.
940 ///
941 /// Note:
942 ///
943 /// Note that this function may also return error codes from previous, asynchronous launches.
944 ///
945 /// **See also:**
946 ///
947 /// [`cudaDeviceGetAttribute`], [`cudaDeviceGetP2PAtomicCapabilities`], cuDeviceGeHostAtomicCapabilities.
948 ///
949 /// # Parameters
950 ///
951 /// - `capabilities`: Returned capability details of each requested operation.
952 /// - `operations`: Requested operations.
953 /// - `count`: Count of requested operations and size of capabilities.
954 pub fn cudaDeviceGetHostAtomicCapabilities(
955 capabilities: *mut ::core::ffi::c_uint,
956 operations: *const cudaAtomicOperation,
957 count: ::core::ffi::c_uint,
958 device: ::core::ffi::c_int,
959 ) -> cudaError_t;
960}
961unsafe extern "C" {
962 /// Returns the default mempool of a device.
963 ///
964 /// The default mempool of a device contains device memory from that device.
965 ///
966 /// Note:
967 ///
968 /// * Note that this function may also return error codes from previous, asynchronous launches.
969 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
970 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
971 ///
972 /// **See also:**
973 ///
974 /// [cuDeviceGetDefaultMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gc8bca3c97a78816303b8aa5773b741f2), [`cudaMallocAsync`], [`cudaMemPoolTrimTo`], [`cudaMemPoolGetAttribute`], [`cudaDeviceSetMemPool`], [`cudaMemPoolSetAttribute`], [`cudaMemPoolSetAccess`].
975 pub fn cudaDeviceGetDefaultMemPool(
976 memPool: *mut cudaMemPool_t,
977 device: ::core::ffi::c_int,
978 ) -> cudaError_t;
979}
980unsafe extern "C" {
981 /// Sets the current memory pool of a device.
982 ///
983 /// The memory pool must be local to the specified device. Unless a mempool is specified in the [`cudaMallocAsync`] call, [`cudaMallocAsync`] allocates from the current mempool of the provided stream's device. By default, a device's current memory pool is its default
984 /// memory pool.
985 ///
986 /// Note:
987 ///
988 /// Use [`cudaMallocFromPoolAsync`] to specify asynchronous allocations from a device different than the one the stream runs on.
989 ///
990 /// Note:
991 ///
992 /// * Note that this function may also return error codes from previous, asynchronous launches.
993 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
994 ///
995 /// **See also:**
996 ///
997 /// [cuDeviceSetMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g4f2f276b84d9c2eaefdc76d6274db4a0), [`cudaDeviceGetMemPool`], [`cudaDeviceGetDefaultMemPool`], [`cudaMemPoolCreate`], [`cudaMemPoolDestroy`], [`cudaMallocFromPoolAsync`].
998 pub fn cudaDeviceSetMemPool(
999 device: ::core::ffi::c_int,
1000 memPool: cudaMemPool_t,
1001 ) -> cudaError_t;
1002}
1003unsafe extern "C" {
1004 /// Gets the current mempool for a device.
1005 ///
1006 /// 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
1007 /// have been set with [cuDeviceSetMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g4f2f276b84d9c2eaefdc76d6274db4a0) or [`cudaDeviceSetMemPool`].
1008 ///
1009 /// Note:
1010 ///
1011 /// * Note that this function may also return error codes from previous, asynchronous launches.
1012 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1013 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1014 ///
1015 /// **See also:**
1016 ///
1017 /// [cuDeviceGetMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gdf186e9559d53a5eb18e572d48c1121b), [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceSetMemPool`].
1018 pub fn cudaDeviceGetMemPool(
1019 memPool: *mut cudaMemPool_t,
1020 device: ::core::ffi::c_int,
1021 ) -> cudaError_t;
1022}
1023unsafe extern "C" {
1024 /// Return NvSciSync attributes that this device can support.
1025 ///
1026 /// 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.
1027 ///
1028 /// If NvSciSyncAttrKey_RequiredPerm field in nvSciSyncAttrList is already set this API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
1029 ///
1030 /// The applications should set nvSciSyncAttrList to a valid NvSciSyncAttrList failing which this API will return cudaErrorInvalidHandle.
1031 ///
1032 /// The flags controls how applications intends to use the NvSciSync created from the nvSciSyncAttrList. The valid flags are:
1033 ///
1034 /// * `cudaNvSciSyncAttrSignal`, specifies that the applications intends to signal an NvSciSync on this CUDA device.
1035 /// * `cudaNvSciSyncAttrWait`, specifies that the applications intends to wait on an NvSciSync on this CUDA device.
1036 ///
1037 /// At least one of these flags must be set, failing which the API returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
1038 /// specific attributes in the same nvSciSyncAttrList.
1039 ///
1040 /// Note that this API updates the input nvSciSyncAttrList with values equivalent to the following public attribute key-values: NvSciSyncAttrKey_RequiredPerm is set to
1041 ///
1042 /// * NvSciSyncAccessPerm_SignalOnly if `cudaNvSciSyncAttrSignal` is set in flags.
1043 /// * NvSciSyncAccessPerm_WaitOnly if `cudaNvSciSyncAttrWait` is set in flags.
1044 /// * NvSciSyncAccessPerm_WaitSignal if both `cudaNvSciSyncAttrWait` and `cudaNvSciSyncAttrSignal` are set in flags. NvSciSyncAttrKey_PrimitiveInfo is set to
1045 /// * NvSciSyncAttrValPrimitiveType_SysmemSemaphore on any valid device.
1046 /// * NvSciSyncAttrValPrimitiveType_Syncpoint if device is a Tegra device.
1047 /// * NvSciSyncAttrValPrimitiveType_SysmemSemaphorePayload64b if device is GA10X+. NvSciSyncAttrKey_GpuId is set to the same UUID that is returned in [cudaDeviceProp.uuid](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_1626c20637498c7be1381db55a6261308) from cudaDeviceGetProperties for this device.
1048 ///
1049 /// [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591), [cudaErrorDeviceUninitialized](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00389e95927732f0d5a68151c72296581504), [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c), cudaErrorInvalidHandle, [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a), [cudaErrorNotSupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d846fd9f2e8ba5e2fb4f1695b7ab6164), [cudaErrorMemoryAllocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f210f50ae7f17f655e0504929606add9)
1050 ///
1051 /// **See also:**
1052 ///
1053 /// [`cudaImportExternalSemaphore`], [`cudaDestroyExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
1054 ///
1055 /// # Parameters
1056 ///
1057 /// - `nvSciSyncAttrList`: Return NvSciSync attributes supported.
1058 /// - `device`: Valid CUDA Device to get NvSciSync attributes for.
1059 /// - `flags`: flags describing NvSciSync usage.
1060 pub fn cudaDeviceGetNvSciSyncAttributes(
1061 nvSciSyncAttrList: *mut ::core::ffi::c_void,
1062 device: ::core::ffi::c_int,
1063 flags: ::core::ffi::c_int,
1064 ) -> cudaError_t;
1065}
1066unsafe extern "C" {
1067 /// Queries attributes of the link between two devices.
1068 ///
1069 /// Returns in \*value the value of the requested attribute attrib of the link between srcDevice and dstDevice. The supported attributes are:
1070 ///
1071 /// * [cudaDevP2PAttrPerformanceRank](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1bdca8430f659738ac2ebfbfc4e0899d3b): A relative value indicating the performance of the link between two devices. Lower value means better performance (0 being
1072 /// the value used for most performant link).
1073 /// * [cudaDevP2PAttrAccessSupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1b0fa6e51b6472b6ea6ea0cd27fea05a3c): 1 if peer access is enabled.
1074 /// * [cudaDevP2PAttrNativeAtomicSupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1b8513982962e4439fa60f2a24348be587): 1 if all native atomic operations over the link are supported.
1075 /// * [cudaDevP2PAttrCudaArrayAccessSupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1bc11dffbfb7a6d8872dfaeca4b971c11e): 1 if accessing CUDA arrays over the link is supported.
1076 /// * [cudaDevP2PAttrOnlyPartialNativeAtomicSupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2f597e2acceab33f60bd61c41fea0c1be2a84f673603b20a1a3c41f2ab96621f): 1 if some CUDA-valid atomic operations over the link are supported. Information about specific operations can be retrieved
1077 /// with [`cudaDeviceGetP2PAtomicCapabilities`].
1078 ///
1079 /// Returns [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a) if srcDevice or dstDevice are not valid or if they represent the same device.
1080 ///
1081 /// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if attrib is not valid or if value is a null pointer.
1082 ///
1083 /// Note:
1084 ///
1085 /// * Note that this function may also return error codes from previous, asynchronous launches.
1086 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1087 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1088 ///
1089 /// **See also:**
1090 ///
1091 /// [`cudaDeviceEnablePeerAccess`], [`cudaDeviceDisablePeerAccess`], [`cudaDeviceCanAccessPeer`], [cuDeviceGetP2PAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g4c55c60508f8eba4546b51f2ee545393) [`cudaDeviceGetP2PAtomicCapabilities`].
1092 ///
1093 /// # Parameters
1094 ///
1095 /// - `value`: Returned value of the requested attribute.
1096 /// - `srcDevice`: The source device of the target link.
1097 /// - `dstDevice`: The destination device of the target link.
1098 pub fn cudaDeviceGetP2PAttribute(
1099 value: *mut ::core::ffi::c_int,
1100 attr: cudaDeviceP2PAttr,
1101 srcDevice: ::core::ffi::c_int,
1102 dstDevice: ::core::ffi::c_int,
1103 ) -> cudaError_t;
1104}
1105unsafe extern "C" {
1106 /// Queries details about atomic operations supported between two devices.
1107 ///
1108 /// Returns in \*capabilities the details about requested atomic \*operations over the link between srcDevice and dstDevice. The allocated size of \*operations and \*capabilities must be count.
1109 ///
1110 /// For each [`cudaAtomicOperation`] in \*operations, the corresponding result in \*capabilities will be a bitmask indicating which of `cudaAtomicOperationCapability` the link supports natively.
1111 ///
1112 /// Returns [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a) if srcDevice or dstDevice are not valid or if they represent the same device.
1113 ///
1114 /// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if \*capabilities or \*operations is NULL, if count is 0, or if any of \*operations is not valid.
1115 ///
1116 /// Note:
1117 ///
1118 /// Note that this function may also return error codes from previous, asynchronous launches.
1119 ///
1120 /// **See also:**
1121 ///
1122 /// [`cudaDeviceGetP2PAttribute`], [cuDeviceGetP2PAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g4c55c60508f8eba4546b51f2ee545393), [cuDeviceGetP2PAtomicCapabilities](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1gfd989876c8fd3291b520c0b561d5282d).
1123 ///
1124 /// # Parameters
1125 ///
1126 /// - `capabilities`: Returned capability details of each requested operation.
1127 /// - `operations`: Requested operations.
1128 /// - `count`: Count of requested operations and size of capabilities.
1129 /// - `srcDevice`: The source device of the target link.
1130 /// - `dstDevice`: The destination device of the target link.
1131 pub fn cudaDeviceGetP2PAtomicCapabilities(
1132 capabilities: *mut ::core::ffi::c_uint,
1133 operations: *const cudaAtomicOperation,
1134 count: ::core::ffi::c_uint,
1135 srcDevice: ::core::ffi::c_int,
1136 dstDevice: ::core::ffi::c_int,
1137 ) -> cudaError_t;
1138}
1139unsafe extern "C" {
1140 /// Select compute-device which best matches criteria.
1141 ///
1142 /// Returns in \*device the device which has properties that best match \*prop.
1143 ///
1144 /// Note:
1145 ///
1146 /// * Note that this function may also return error codes from previous, asynchronous launches.
1147 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1148 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1149 ///
1150 /// **See also:**
1151 ///
1152 /// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaInitDevice`].
1153 ///
1154 /// # Parameters
1155 ///
1156 /// - `device`: Device with best match.
1157 /// - `prop`: Desired device properties.
1158 pub fn cudaChooseDevice(
1159 device: *mut ::core::ffi::c_int,
1160 prop: *const cudaDeviceProp,
1161 ) -> cudaError_t;
1162}
1163unsafe extern "C" {
1164 /// Initialize device to be used for GPU executions.
1165 ///
1166 /// 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.
1167 ///
1168 /// When `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`].
1169 ///
1170 /// This function will return an error if the device is in [`cudaComputeMode::cudaComputeModeExclusiveProcess`] and is occupied by another process or if the device is in [`cudaComputeMode::cudaComputeModeProhibited`].
1171 ///
1172 /// Note:
1173 ///
1174 /// * Note that this function may also return error codes from previous, asynchronous launches.
1175 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1176 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1177 ///
1178 /// **See also:**
1179 ///
1180 /// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cudaSetDevice`].
1181 ///
1182 /// # Parameters
1183 ///
1184 /// - `device`: Device on which the runtime will initialize itself.
1185 /// - `deviceFlags`: Parameters for device operation.
1186 /// - `flags`: Flags for controlling the device initialization.
1187 pub fn cudaInitDevice(
1188 device: ::core::ffi::c_int,
1189 deviceFlags: ::core::ffi::c_uint,
1190 flags: ::core::ffi::c_uint,
1191 ) -> cudaError_t;
1192}
1193unsafe extern "C" {
1194 /// Set device to be used for GPU executions.
1195 ///
1196 /// Sets device as the current device for the calling host thread. Valid device id's are 0 to ([`cudaGetDeviceCount`] - 1).
1197 ///
1198 /// Any device memory subsequently allocated from this host thread using [`cudaMalloc`], [`cudaMallocPitch`] or [`cudaMallocArray`] will be physically resident on device. Any host memory allocated from this host thread using [`cudaMallocHost`] or [`cudaHostAlloc`] or [`cudaHostRegister`] will have its lifetime associated with device. Any streams or events created from this host thread will be associated with device. Any kernels launched from this host thread using the <<<>>> operator or [`cudaLaunchKernel`] will be executed on device.
1199 ///
1200 /// This call may be made from any host thread, to any device, and at any time. This function will do no synchronization with
1201 /// the previous or new device, and should only take significant time when it initializes the runtime's context state. This call
1202 /// will bind the primary context of the specified device to the calling thread and all the subsequent memory allocations, stream
1203 /// and event creations, and kernel launches will be associated with the primary context. This function will also immediately
1204 /// initialize the runtime state on the primary context, and the context will be current on device immediately. This function will return an error if the device is in [`cudaComputeMode::cudaComputeModeExclusiveProcess`] and is occupied by another process or if the device is in [`cudaComputeMode::cudaComputeModeProhibited`].
1205 ///
1206 /// It is not required to call [`cudaInitDevice`] before using this function.
1207 ///
1208 /// Note:
1209 ///
1210 /// * Note that this function may also return error codes from previous, asynchronous launches.
1211 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1212 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1213 ///
1214 /// **See also:**
1215 ///
1216 /// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [`cudaInitDevice`], [cuCtxSetCurrent](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1gbe562ee6258b4fcc272ca6478ca2a2f7).
1217 ///
1218 /// # Parameters
1219 ///
1220 /// - `device`: Device on which the active host thread should execute the device code.
1221 pub fn cudaSetDevice(device: ::core::ffi::c_int) -> cudaError_t;
1222}
1223unsafe extern "C" {
1224 /// Returns which device is currently being used.
1225 ///
1226 /// Returns in \*device the current device for the calling host thread.
1227 ///
1228 /// Note:
1229 ///
1230 /// * Note that this function may also return error codes from previous, asynchronous launches.
1231 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1232 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1233 ///
1234 /// **See also:**
1235 ///
1236 /// [`cudaGetDeviceCount`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaChooseDevice`], [cuCtxGetCurrent](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g8f13165846b73750693640fb3e8380d0).
1237 ///
1238 /// # Parameters
1239 ///
1240 /// - `device`: Returns the device on which the active host thread executes the device code.
1241 pub fn cudaGetDevice(device: *mut ::core::ffi::c_int) -> cudaError_t;
1242}
1243unsafe extern "C" {
1244 /// Set a list of devices that can be used for CUDA.
1245 ///
1246 /// 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.
1247 /// 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
1248 /// the available CUDA devices in the system. If a specified device ID in the list does not exist, this function will return [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
1249 ///
1250 /// Note:
1251 ///
1252 /// * Note that this function may also return error codes from previous, asynchronous launches.
1253 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1254 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1255 ///
1256 /// **See also:**
1257 ///
1258 /// [`cudaGetDeviceCount`], [`cudaSetDevice`], [`cudaGetDeviceProperties`], [`cudaSetDeviceFlags`], [`cudaChooseDevice`].
1259 ///
1260 /// # Parameters
1261 ///
1262 /// - `device_arr`: List of devices to try.
1263 /// - `len`: Number of devices in specified list.
1264 pub fn cudaSetValidDevices(
1265 device_arr: *mut ::core::ffi::c_int,
1266 len: ::core::ffi::c_int,
1267 ) -> cudaError_t;
1268}
1269unsafe extern "C" {
1270 /// Sets flags to be used for device executions.
1271 ///
1272 /// Records flags as the flags for the current device. If the current device has been set and that device has already been initialized, the
1273 /// previous flags are overwritten. If the current device has not been initialized, it is initialized with the provided flags.
1274 /// If no device has been made current to the calling thread, a default device is selected and initialized with the provided flags.
1275 ///
1276 /// 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.
1277 ///
1278 /// * `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
1279 /// and actively spin on the processor. Additionally, on Tegra devices, `cudaDeviceScheduleAuto` uses a heuristic based on the power profile of the platform and may choose `cudaDeviceScheduleBlockingSync` for low-powered devices.
1280 /// * `cudaDeviceScheduleSpin`: Instruct CUDA to actively spin when waiting for results from the device. This can decrease latency when waiting for the
1281 /// device, but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread.
1282 /// * `cudaDeviceScheduleYield`: Instruct CUDA to yield its thread when waiting for results from the device. This can increase latency when waiting for the
1283 /// device, but can increase the performance of CPU threads performing work in parallel with the device.
1284 /// * `cudaDeviceScheduleBlockingSync`: Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the device to finish work.
1285 /// * `cudaDeviceBlockingSync`: Instruct CUDA to block the CPU thread on a synchronization primitive when waiting for the device to finish work.
1286 ///
1287 /// [Deprecated:](https://docs.nvidia.com/cuda/cuda-runtime-api/deprecated.html#deprecated) This flag was deprecated as of CUDA 4.0 and replaced with `cudaDeviceScheduleBlockingSync`.
1288 /// * `cudaDeviceMapHost`: This flag enables allocating pinned host memory that is accessible to the device. It is implicit for the runtime but may
1289 /// be absent if a context is created using the driver API. If this flag is not set, [`cudaHostGetDevicePointer`] will always return a failure code.
1290 /// * `cudaDeviceLmemResizeToMax`: Instruct CUDA to not reduce local memory after resizing local memory for a kernel. This can prevent thrashing by local memory
1291 /// allocations when launching many kernels with high local memory usage at the cost of potentially increased memory usage.
1292 ///
1293 /// [Deprecated:](https://docs.nvidia.com/cuda/cuda-runtime-api/deprecated.html#deprecated) This flag is deprecated and the behavior enabled by this flag is now the default and cannot be disabled.
1294 /// * `cudaDeviceSyncMemops`: Ensures that synchronous memory operations initiated on this context will always synchronize. See further documentation
1295 /// in the section titled "API Synchronization behavior" to learn more about cases when synchronous memory operations can exhibit
1296 /// asynchronous behavior.
1297 ///
1298 /// Note:
1299 ///
1300 /// * Note that this function may also return error codes from previous, asynchronous launches.
1301 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1302 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1303 ///
1304 /// **See also:**
1305 ///
1306 /// [`cudaGetDeviceFlags`], [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaSetDevice`], [`cudaSetValidDevices`], [`cudaInitDevice`], [`cudaChooseDevice`], [cuDevicePrimaryCtxSetFlags](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__PRIMARY__CTX.html#group__CUDA__PRIMARY__CTX_1gd779a84f17acdad0d9143d9fe719cfdf).
1307 ///
1308 /// # Parameters
1309 ///
1310 /// - `flags`: Parameters for device operation.
1311 pub fn cudaSetDeviceFlags(flags: ::core::ffi::c_uint) -> cudaError_t;
1312}
1313unsafe extern "C" {
1314 /// Gets the flags for the current device.
1315 ///
1316 /// 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.
1317 /// If there is no current device, the flags for the first device are returned, which may be the default flags. Compare to the
1318 /// behavior of [`cudaSetDeviceFlags`].
1319 ///
1320 /// Typically, the flags returned should match the behavior that will be seen if the calling thread uses a device after this call,
1321 /// without any change to the flags or current device inbetween by this or another thread. Note that if the device is not initialized,
1322 /// it is possible for another thread to change the flags for the current device before it is initialized. Additionally, when
1323 /// using exclusive mode, if this thread has not requested a specific device, it may use a device other than the first device,
1324 /// contrary to the assumption made by this function.
1325 ///
1326 /// If a context has been created via the driver API and is current to the calling thread, the flags for that context are always
1327 /// returned.
1328 ///
1329 /// Flags returned by this function may specifically include `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
1330 /// driver API in which case the flag is not implicit and may be unset.
1331 ///
1332 /// Note:
1333 ///
1334 /// * Note that this function may also return error codes from previous, asynchronous launches.
1335 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1336 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1337 ///
1338 /// **See also:**
1339 ///
1340 /// [`cudaGetDevice`], [`cudaGetDeviceProperties`], [`cudaSetDevice`], [`cudaSetDeviceFlags`], [`cudaInitDevice`], [cuCtxGetFlags](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1gf81eef983c1e3b2ef4f166d7a930c86d), [cuDevicePrimaryCtxGetState](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__PRIMARY__CTX.html#group__CUDA__PRIMARY__CTX_1g65f3e018721b6d90aa05cfb56250f469).
1341 ///
1342 /// # Parameters
1343 ///
1344 /// - `flags`: Pointer to store the device flags.
1345 pub fn cudaGetDeviceFlags(flags: *mut ::core::ffi::c_uint) -> cudaError_t;
1346}
1347unsafe extern "C" {
1348 /// Create an asynchronous stream.
1349 ///
1350 /// Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the
1351 /// calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized
1352 /// before creating a stream on it.
1353 ///
1354 /// Note:
1355 ///
1356 /// * Note that this function may also return error codes from previous, asynchronous launches.
1357 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1358 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1359 ///
1360 /// **See also:**
1361 ///
1362 /// [`cudaStreamCreateWithPriority`], [`cudaStreamCreateWithFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetFlags`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaSetDevice`], [`cudaStreamDestroy`], [cuStreamCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1ga581f0c5833e21ded8b5a56594e243f4).
1363 ///
1364 /// # Parameters
1365 ///
1366 /// - `pStream`: Pointer to new stream identifier.
1367 pub fn cudaStreamCreate(pStream: *mut cudaStream_t) -> cudaError_t;
1368}
1369unsafe extern "C" {
1370 /// Create an asynchronous stream.
1371 ///
1372 /// Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the
1373 /// calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized
1374 /// before creating a stream on it. The flags argument determines the behaviors of the stream. Valid values for flags are
1375 ///
1376 /// * [`cudaStreamDefault`]: Default stream creation flag.
1377 /// * [`cudaStreamNonBlocking`]: Specifies that work running in the created stream may run concurrently with work in stream 0 (the NULL stream), and that
1378 /// the created stream should perform no implicit synchronization with stream 0.
1379 ///
1380 /// Note:
1381 ///
1382 /// * Note that this function may also return error codes from previous, asynchronous launches.
1383 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1384 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1385 ///
1386 /// **See also:**
1387 ///
1388 /// [`cudaStreamCreate`], [`cudaStreamCreateWithPriority`], [`cudaStreamGetFlags`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaSetDevice`], [`cudaStreamDestroy`], [cuStreamCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1ga581f0c5833e21ded8b5a56594e243f4).
1389 ///
1390 /// # Parameters
1391 ///
1392 /// - `pStream`: Pointer to new stream identifier.
1393 /// - `flags`: Parameters for stream creation.
1394 pub fn cudaStreamCreateWithFlags(
1395 pStream: *mut cudaStream_t,
1396 flags: ::core::ffi::c_uint,
1397 ) -> cudaError_t;
1398}
1399unsafe extern "C" {
1400 /// Create an asynchronous stream with the specified priority.
1401 ///
1402 /// 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
1403 /// host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before
1404 /// creating a stream on it. This affects the scheduling priority of work in the stream. Priorities provide a hint to preferentially
1405 /// run work with higher priority when possible, but do not preempt already-running work or provide any other functional guarantee
1406 /// on execution order.
1407 ///
1408 /// priority follows a convention where lower numbers represent higher priorities. '0' represents default priority. The range of meaningful
1409 /// 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.
1410 ///
1411 /// Note:
1412 ///
1413 /// * Note that this function may also return error codes from previous, asynchronous launches.
1414 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1415 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1416 /// * Stream priorities are supported only on GPUs with compute capability 3.5 or higher.
1417 /// * In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream
1418 /// priorities have no effect on host-to-device and device-to-host memory operations.
1419 ///
1420 /// **See also:**
1421 ///
1422 /// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaDeviceGetStreamPriorityRange`], [`cudaStreamGetPriority`], [`cudaStreamQuery`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaStreamSynchronize`], [`cudaSetDevice`], [`cudaStreamDestroy`], [cuStreamCreateWithPriority](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g95c1a8c7c3dacb13091692dd9c7f7471).
1423 ///
1424 /// # Parameters
1425 ///
1426 /// - `pStream`: Pointer to new stream identifier.
1427 /// - `flags`: Flags for stream creation. See [`cudaStreamCreateWithFlags`] for a list of valid flags that can be passed.
1428 /// - `priority`: Priority of the stream. Lower numbers represent higher priorities. See [`cudaDeviceGetStreamPriorityRange`] for more information about the meaningful stream priorities that can be passed.
1429 pub fn cudaStreamCreateWithPriority(
1430 pStream: *mut cudaStream_t,
1431 flags: ::core::ffi::c_uint,
1432 priority: ::core::ffi::c_int,
1433 ) -> cudaError_t;
1434}
1435unsafe extern "C" {
1436 /// Query the priority of a stream.
1437 ///
1438 /// 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.
1439 ///
1440 /// Note:
1441 ///
1442 /// * Note that this function may also return error codes from previous, asynchronous launches.
1443 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1444 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1445 ///
1446 /// **See also:**
1447 ///
1448 /// [`cudaStreamCreateWithPriority`], [`cudaDeviceGetStreamPriorityRange`], [`cudaStreamGetFlags`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [cuStreamGetPriority](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g5bd5cb26915a2ecf1921807339488484).
1449 ///
1450 /// # Parameters
1451 ///
1452 /// - `hStream`: Handle to the stream to be queried.
1453 /// - `priority`: Pointer to a signed integer in which the stream's priority is returned.
1454 pub fn cudaStreamGetPriority(
1455 hStream: cudaStream_t,
1456 priority: *mut ::core::ffi::c_int,
1457 ) -> cudaError_t;
1458}
1459unsafe extern "C" {
1460 /// Query the flags of a stream.
1461 ///
1462 /// Query the flags of a stream. The flags are returned in flags. See [`cudaStreamCreateWithFlags`] for a list of valid flags.
1463 ///
1464 /// Note:
1465 ///
1466 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
1467 /// * Note that this function may also return error codes from previous, asynchronous launches.
1468 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1469 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1470 ///
1471 /// **See also:**
1472 ///
1473 /// [`cudaStreamCreateWithPriority`], [`cudaStreamCreateWithFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetDevice`], [cuStreamGetFlags](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g4d39786855a6bed01215c1907fbbfbb7).
1474 ///
1475 /// # Parameters
1476 ///
1477 /// - `hStream`: Handle to the stream to be queried.
1478 /// - `flags`: Pointer to an unsigned integer in which the stream's flags are returned.
1479 pub fn cudaStreamGetFlags(
1480 hStream: cudaStream_t,
1481 flags: *mut ::core::ffi::c_uint,
1482 ) -> cudaError_t;
1483}
1484unsafe extern "C" {
1485 /// Query the Id of a stream.
1486 ///
1487 /// Query the Id of a stream. The Id is returned in streamId. The Id is unique for the life of the program.
1488 ///
1489 /// The stream handle hStream can refer to any of the following:
1490 ///
1491 /// * a stream created via any of the CUDA runtime APIs such as [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`] and [`cudaStreamCreateWithPriority`], or their driver API equivalents such as [cuStreamCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1ga581f0c5833e21ded8b5a56594e243f4) or [cuStreamCreateWithPriority](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g95c1a8c7c3dacb13091692dd9c7f7471). Passing an invalid handle will result in undefined behavior.
1492 /// * any of the special streams such as the NULL stream, `cudaStreamLegacy` and `cudaStreamPerThread` respectively. The driver API equivalents of these are also accepted which are NULL, [CU_STREAM_LEGACY](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1ga53e8210837f039dd6434a3a4c3324aa) and [CU_STREAM_PER_THREAD](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1g02e40b82600f62c42ed29abb150f857c).
1493 ///
1494 /// Note:
1495 ///
1496 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
1497 /// * Note that this function may also return error codes from previous, asynchronous launches.
1498 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1499 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1500 ///
1501 /// **See also:**
1502 ///
1503 /// [`cudaStreamCreateWithPriority`], [`cudaStreamCreateWithFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetFlags`], [cuStreamGetId](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g5dafd2b6f48caeb13d5110a7f21e60e3).
1504 ///
1505 /// # Parameters
1506 ///
1507 /// - `hStream`: Handle to the stream to be queried.
1508 /// - `streamId`: Pointer to an unsigned long long in which the stream Id is returned.
1509 pub fn cudaStreamGetId(
1510 hStream: cudaStream_t,
1511 streamId: *mut ::core::ffi::c_ulonglong,
1512 ) -> cudaError_t;
1513}
1514unsafe extern "C" {
1515 /// Query the device of a stream.
1516 ///
1517 /// Returns in \*device the device of the stream.
1518 ///
1519 /// Note:
1520 ///
1521 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
1522 /// * Note that this function may also return error codes from previous, asynchronous launches.
1523 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1524 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1525 ///
1526 /// **See also:**
1527 ///
1528 /// [`cudaSetDevice`], [`cudaGetDevice`], [`cudaStreamCreate`], [`cudaStreamGetPriority`], [`cudaStreamGetFlags`], [cuStreamGetId](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g5dafd2b6f48caeb13d5110a7f21e60e3).
1529 ///
1530 /// # Parameters
1531 ///
1532 /// - `hStream`: Handle to the stream to be queried.
1533 /// - `device`: Returns the device to which the stream belongs.
1534 pub fn cudaStreamGetDevice(
1535 hStream: cudaStream_t,
1536 device: *mut ::core::ffi::c_int,
1537 ) -> cudaError_t;
1538}
1539unsafe extern "C" {
1540 /// Resets all persisting lines in cache to normal status.
1541 ///
1542 /// Resets all persisting lines in cache to normal status. Takes effect on function return.
1543 ///
1544 /// Note:
1545 ///
1546 /// Note that this function may also return error codes from previous, asynchronous launches.
1547 ///
1548 /// **See also:**
1549 ///
1550 /// [`cudaAccessPolicyWindow`].
1551 pub fn cudaCtxResetPersistingL2Cache() -> cudaError_t;
1552}
1553unsafe extern "C" {
1554 /// Copies attributes from source stream to destination stream.
1555 ///
1556 /// Copies attributes from source stream src to destination stream dst. Both streams must have the same context.
1557 ///
1558 /// Note:
1559 ///
1560 /// Note that this function may also return error codes from previous, asynchronous launches.
1561 ///
1562 /// **See also:**
1563 ///
1564 /// [`cudaAccessPolicyWindow`].
1565 ///
1566 /// # Parameters
1567 ///
1568 /// - `dst`: Destination stream.
1569 /// - `src`: Source stream For attributes see cudaStreamAttrID.
1570 pub fn cudaStreamCopyAttributes(dst: cudaStream_t, src: cudaStream_t) -> cudaError_t;
1571}
1572unsafe extern "C" {
1573 /// Queries stream attribute.
1574 ///
1575 /// Queries attribute attr from hStream and stores it in corresponding member of value_out.
1576 ///
1577 /// Note:
1578 ///
1579 /// Note that this function may also return error codes from previous, asynchronous launches.
1580 ///
1581 /// **See also:**
1582 ///
1583 /// [`cudaAccessPolicyWindow`].
1584 pub fn cudaStreamGetAttribute(
1585 hStream: cudaStream_t,
1586 attr: cudaLaunchAttributeID,
1587 value_out: *mut cudaLaunchAttributeValue,
1588 ) -> cudaError_t;
1589}
1590unsafe extern "C" {
1591 /// Sets stream attribute.
1592 ///
1593 /// 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
1594 /// work.
1595 ///
1596 /// Note:
1597 ///
1598 /// Note that this function may also return error codes from previous, asynchronous launches.
1599 ///
1600 /// **See also:**
1601 ///
1602 /// [`cudaAccessPolicyWindow`].
1603 pub fn cudaStreamSetAttribute(
1604 hStream: cudaStream_t,
1605 attr: cudaLaunchAttributeID,
1606 value: *const cudaLaunchAttributeValue,
1607 ) -> cudaError_t;
1608}
1609unsafe extern "C" {
1610 /// Destroys and cleans up an asynchronous stream.
1611 ///
1612 /// Destroys and cleans up the asynchronous stream specified by stream.
1613 ///
1614 /// 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.
1615 ///
1616 /// Note:
1617 ///
1618 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
1619 /// * Note that this function may also return error codes from previous, asynchronous launches.
1620 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1621 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1622 /// * Use of the handle after this call is undefined behavior.
1623 ///
1624 /// **See also:**
1625 ///
1626 /// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamWaitEvent`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [cuStreamDestroy](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g244c8833de4596bcd31a06cdf21ee758).
1627 ///
1628 /// # Parameters
1629 ///
1630 /// - `stream`: Stream identifier.
1631 pub fn cudaStreamDestroy(stream: cudaStream_t) -> cudaError_t;
1632}
1633unsafe extern "C" {
1634 /// Make a compute stream wait on an event.
1635 ///
1636 /// 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.
1637 /// event may be from a different device than stream.
1638 ///
1639 /// flags include:
1640 ///
1641 /// * `cudaEventWaitDefault`: Default event creation flag.
1642 /// * `cudaEventWaitExternal`: Event is captured in the graph as an external event node when performing stream capture.
1643 ///
1644 /// Note:
1645 ///
1646 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
1647 /// * Note that this function may also return error codes from previous, asynchronous launches.
1648 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1649 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1650 ///
1651 /// **See also:**
1652 ///
1653 /// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [cuStreamWaitEvent](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g6a898b652dfc6aa1d5c8d97062618b2f).
1654 ///
1655 /// # Parameters
1656 ///
1657 /// - `stream`: Stream to wait.
1658 /// - `event`: Event to wait on.
1659 /// - `flags`: Parameters for the operation(See above).
1660 pub fn cudaStreamWaitEvent(
1661 stream: cudaStream_t,
1662 event: cudaEvent_t,
1663 flags: ::core::ffi::c_uint,
1664 ) -> cudaError_t;
1665}
1666/// Type of stream callback functions.
1667pub type cudaStreamCallback_t = ::core::option::Option<
1668 unsafe extern "C" fn(
1669 stream: cudaStream_t,
1670 status: cudaError_t,
1671 userData: *mut ::core::ffi::c_void,
1672 ),
1673>;
1674unsafe extern "C" {
1675 /// Add a callback to a compute stream.
1676 ///
1677 /// Note:
1678 ///
1679 /// This function is slated for eventual deprecation and removal. If you do not require the callback to execute in case of a device
1680 /// error, consider using [`cudaLaunchHostFunc`]. Additionally, this function is not supported with [`cudaStreamBeginCapture`] and [`cudaStreamEndCapture`], unlike [`cudaLaunchHostFunc`].
1681 ///
1682 /// Adds a callback to be called on the host after all currently enqueued items in the stream have completed. For each cudaStreamAddCallback
1683 /// call, a callback will be executed exactly once. The callback will block later work in the stream until it is finished.
1684 ///
1685 /// The callback may be passed [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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`.
1686 ///
1687 /// Callbacks must not make any CUDA API calls. Attempting to use CUDA APIs may result in [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3). Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not
1688 /// mandated to run earlier. Callbacks without a mandated order (in independent streams) execute in undefined order and may be
1689 /// serialized.
1690 ///
1691 /// For the purposes of Unified Memory, callback execution makes a number of guarantees:
1692 ///
1693 /// * The callback stream is considered idle for the duration of the callback. Thus, for example, a callback may always use memory
1694 /// attached to the callback stream.
1695 /// * The start of execution of a callback has the same effect as synchronizing an event recorded in the same stream immediately
1696 /// prior to the callback. It thus synchronizes streams which have been "joined" prior to the callback.
1697 /// * Adding device work to any stream does not have the effect of making the stream active until all preceding callbacks have executed.
1698 /// Thus, for example, a callback might use global attached memory even if work has been added to another stream, if it has been
1699 /// properly ordered with an event.
1700 /// * Completion of a callback does not cause a stream to become active except as described above. The callback stream will remain
1701 /// idle if no device work follows the callback, and will remain idle across consecutive callbacks without device work in between.
1702 /// Thus, for example, stream synchronization can be done by signaling from a callback at the end of the stream.
1703 ///
1704 /// Note:
1705 ///
1706 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
1707 /// * Note that this function may also return error codes from previous, asynchronous launches.
1708 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1709 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1710 ///
1711 /// **See also:**
1712 ///
1713 /// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamDestroy`], [`cudaMallocManaged`], [`cudaStreamAttachMemAsync`], [`cudaLaunchHostFunc`], [cuStreamAddCallback](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g613d97a277d7640f4cb1c03bd51c2483).
1714 ///
1715 /// # Parameters
1716 ///
1717 /// - `stream`: Stream to add callback to.
1718 /// - `callback`: The function to call once preceding stream operations are complete.
1719 /// - `userData`: User specified data to be passed to the callback function.
1720 /// - `flags`: Reserved for future use, must be 0.
1721 pub fn cudaStreamAddCallback(
1722 stream: cudaStream_t,
1723 callback: cudaStreamCallback_t,
1724 userData: *mut ::core::ffi::c_void,
1725 flags: ::core::ffi::c_uint,
1726 ) -> cudaError_t;
1727}
1728unsafe extern "C" {
1729 /// Waits for stream tasks to complete.
1730 ///
1731 /// Blocks until stream has completed all operations. If the `cudaDeviceScheduleBlockingSync` flag was set for this device, the host thread will block until the stream is finished with all of its tasks.
1732 ///
1733 /// Note:
1734 ///
1735 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
1736 /// * Note that this function may also return error codes from previous, asynchronous launches.
1737 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1738 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1739 ///
1740 /// **See also:**
1741 ///
1742 /// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamQuery`], [`cudaStreamWaitEvent`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [cuStreamSynchronize](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g15e49dd91ec15991eb7c0a741beb7dad).
1743 ///
1744 /// # Parameters
1745 ///
1746 /// - `stream`: Stream identifier.
1747 pub fn cudaStreamSynchronize(stream: cudaStream_t) -> cudaError_t;
1748}
1749unsafe extern "C" {
1750 /// Queries an asynchronous stream for completion status.
1751 ///
1752 /// Returns [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) if all operations in stream have completed, or [cudaErrorNotReady](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038285d0c852ab65b8925505e1065563f6d) if not.
1753 ///
1754 /// For the purposes of Unified Memory, a return value of [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) is equivalent to having called [`cudaStreamSynchronize`].
1755 ///
1756 /// Note:
1757 ///
1758 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
1759 /// * Note that this function may also return error codes from previous, asynchronous launches.
1760 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
1761 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
1762 ///
1763 /// **See also:**
1764 ///
1765 /// [`cudaStreamCreate`], [`cudaStreamCreateWithFlags`], [`cudaStreamWaitEvent`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`], [`cudaStreamDestroy`], [cuStreamQuery](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__STREAM.html#group__CUDA__STREAM_1g1b0d24bbe97fa68e4bc511fb6adfeb0b).
1766 ///
1767 /// # Parameters
1768 ///
1769 /// - `stream`: Stream identifier.
1770 pub fn cudaStreamQuery(stream: cudaStream_t) -> cudaError_t;
1771}
1772unsafe extern "C" {
1773 /// # Parameters
1774 ///
1775 /// - `stream`: Stream in which to enqueue the attach operation.
1776 /// - `devPtr`: Pointer to memory (must be a pointer to managed memory or to a valid host-accessible region of system-allocated memory).
1777 /// - `length`: Length of memory (defaults to zero).
1778 /// - `flags`: Must be one of `cudaMemAttachGlobal`, `cudaMemAttachHost` or `cudaMemAttachSingle` (defaults to `cudaMemAttachSingle`).
1779 pub fn cudaStreamAttachMemAsync(
1780 stream: cudaStream_t,
1781 devPtr: *mut ::core::ffi::c_void,
1782 length: size_t,
1783 flags: ::core::ffi::c_uint,
1784 ) -> cudaError_t;
1785}
1786unsafe extern "C" {
1787 /// Begins graph capture on a stream.
1788 ///
1789 /// 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
1790 /// into a graph, which will be returned via [`cudaStreamEndCapture`]. Capture may not be initiated if stream is `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
1791 /// in capture mode. The capture mode may be queried via [`cudaStreamIsCapturing`]. A unique id representing the capture sequence may be queried via [`cudaStreamGetCaptureInfo`].
1792 ///
1793 /// If mode is not cudaStreamCaptureModeRelaxed, [`cudaStreamEndCapture`] must be called on this stream from the same thread.
1794 ///
1795 /// Note:
1796 ///
1797 /// Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface
1798 /// reference is undefined behavior. This restriction does not apply to texture and surface objects.
1799 ///
1800 /// Note:
1801 ///
1802 /// Note that this function may also return error codes from previous, asynchronous launches.
1803 ///
1804 /// **See also:**
1805 ///
1806 /// [`cudaStreamCreate`], [`cudaStreamIsCapturing`], [`cudaStreamEndCapture`], [`cudaThreadExchangeStreamCaptureMode`].
1807 ///
1808 /// # Parameters
1809 ///
1810 /// - `stream`: Stream in which to initiate capture.
1811 /// - `mode`: Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see
1812 /// [`cudaThreadExchangeStreamCaptureMode`].
1813 pub fn cudaStreamBeginCapture(
1814 stream: cudaStream_t,
1815 mode: cudaStreamCaptureMode,
1816 ) -> cudaError_t;
1817}
1818/// Callback function invoked when node parameter mismatches are detected while recapturing to an existing graph. Parameter struct
1819/// pointers are only valid within the callback.
1820pub type cudaGraphRecaptureCallback_t = ::core::option::Option<
1821 unsafe extern "C" fn(
1822 data: *mut ::core::ffi::c_void,
1823 node: cudaGraphNode_t,
1824 originalParams: *const cudaGraphNodeParams,
1825 recaptureParams: *const cudaGraphNodeParams,
1826 status: cudaGraphRecaptureStatus,
1827 ) -> cudaError_t,
1828>;
1829#[repr(C)]
1830#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
1831pub struct cudaGraphRecaptureCallbackData {
1832 pub callbackFunc: cudaGraphRecaptureCallback_t,
1833 pub userData: *mut ::core::ffi::c_void,
1834}
1835impl Default for cudaGraphRecaptureCallbackData {
1836 fn default() -> Self {
1837 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
1838 unsafe {
1839 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1840 s.assume_init()
1841 }
1842 }
1843}
1844unsafe extern "C" {
1845 /// Begin graph capture on a stream to an existing graph.
1846 ///
1847 /// Begin graph capture on stream to the existing graph. The node creation order while recapturing the graph must be identical to the original graph. The recapture will fail immediately
1848 /// for: \* Topology mismatches between the existing graph and the recaptured graph \* Parameter mismatches for memory allocation
1849 /// or free nodes
1850 ///
1851 /// Any other node parameter mismatches during recapture can be configured to call the function provided in callbackFunc. The recapture will fail immediately if the callback returns anything other than cudaSuccess.
1852 ///
1853 /// If the recapture fails for any reason, the graph will be in an undefined state and should be destroyed.
1854 ///
1855 /// See cudaStreamBeginCapture for additional detail on beginning the capture.
1856 ///
1857 /// Note:
1858 ///
1859 /// Any user objects associated with graph will be released prior to the recapture.
1860 ///
1861 /// Note:
1862 ///
1863 /// Note that this function may also return error codes from previous, asynchronous launches.
1864 ///
1865 /// **See also:**
1866 ///
1867 /// [`cudaStreamCreate`], [`cudaStreamBeginCapture`], [`cudaStreamIsCapturing`], [`cudaStreamEndCapture`], [`cudaThreadExchangeStreamCaptureMode`].
1868 ///
1869 /// # Parameters
1870 ///
1871 /// - `stream`: Stream in which to initiate capture.
1872 /// - `mode`: Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see
1873 /// [`cudaThreadExchangeStreamCaptureMode`].
1874 /// - `graph`: Existing CUDA graph to be captured into.
1875 /// - `callbackData`: Optional struct of callback data that will be invoked for all parameter mismatches from the original graph.
1876 pub fn cudaStreamBeginRecaptureToGraph(
1877 stream: cudaStream_t,
1878 mode: cudaStreamCaptureMode,
1879 graph: cudaGraph_t,
1880 callbackData: *mut cudaGraphRecaptureCallbackData,
1881 ) -> cudaError_t;
1882}
1883unsafe extern "C" {
1884 /// Begins graph capture on a stream to an existing graph.
1885 ///
1886 /// 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
1887 /// into graph, which will be returned via [`cudaStreamEndCapture`].
1888 ///
1889 /// Capture may not be initiated if stream is `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
1890 /// in capture mode. The capture mode may be queried via [`cudaStreamIsCapturing`]. A unique id representing the capture sequence may be queried via [`cudaStreamGetCaptureInfo`].
1891 ///
1892 /// If mode is not cudaStreamCaptureModeRelaxed, [`cudaStreamEndCapture`] must be called on this stream from the same thread.
1893 ///
1894 /// Note:
1895 ///
1896 /// Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface
1897 /// reference is undefined behavior. This restriction does not apply to texture and surface objects.
1898 ///
1899 /// Note:
1900 ///
1901 /// Note that this function may also return error codes from previous, asynchronous launches.
1902 ///
1903 /// **See also:**
1904 ///
1905 /// [`cudaStreamCreate`], [`cudaStreamIsCapturing`], [`cudaStreamEndCapture`], [`cudaThreadExchangeStreamCaptureMode`].
1906 ///
1907 /// # Parameters
1908 ///
1909 /// - `stream`: Stream in which to initiate capture.
1910 /// - `graph`: Graph to capture into.
1911 /// - `dependencies`: Dependencies of the first node captured in the stream. Can be NULL if numDependencies is 0.
1912 /// - `dependencyData`: Optional array of data associated with each dependency.
1913 /// - `numDependencies`: Number of dependencies.
1914 /// - `mode`: Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see
1915 /// [`cudaThreadExchangeStreamCaptureMode`].
1916 pub fn cudaStreamBeginCaptureToGraph(
1917 stream: cudaStream_t,
1918 graph: cudaGraph_t,
1919 dependencies: *const cudaGraphNode_t,
1920 dependencyData: *const cudaGraphEdgeData,
1921 numDependencies: size_t,
1922 mode: cudaStreamCaptureMode,
1923 ) -> cudaError_t;
1924}
1925unsafe extern "C" {
1926 /// Swaps the stream capture interaction mode for a thread.
1927 ///
1928 /// 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
1929 /// are encouraged to use this API in a push-pop fashion:
1930 ///
1931 /// ```text
1932 /// cudaStreamCaptureMode mode = desiredMode;
1933 /// cudaThreadExchangeStreamCaptureMode(&mode);
1934 /// ...
1935 /// cudaThreadExchangeStreamCaptureMode(&mode); // restore previous mode
1936 /// ```
1937 ///
1938 /// 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
1939 /// of operations captured via [`cudaStreamBeginCapture`] depended on the allocation being replayed whenever the graph is launched, the captured graph would be invalid.
1940 ///
1941 /// 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`].
1942 ///
1943 /// A thread's mode is one of the following:
1944 ///
1945 /// * 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.
1946 /// * 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.
1947 /// * cudaStreamCaptureModeRelaxed: The local thread is not prohibited from potentially unsafe API calls. Note that the thread is still prohibited from API calls
1948 /// which necessarily conflict with stream capture, for example, attempting [`cudaEventQuery`] on an event that was last recorded inside a capture sequence.
1949 ///
1950 /// Note:
1951 ///
1952 /// Note that this function may also return error codes from previous, asynchronous launches.
1953 ///
1954 /// **See also:**
1955 ///
1956 /// [`cudaStreamBeginCapture`].
1957 ///
1958 /// # Parameters
1959 ///
1960 /// - `mode`: Pointer to mode value to swap with the current mode.
1961 pub fn cudaThreadExchangeStreamCaptureMode(
1962 mode: *mut cudaStreamCaptureMode,
1963 ) -> cudaError_t;
1964}
1965unsafe extern "C" {
1966 /// Ends capture on a stream, returning the captured graph.
1967 ///
1968 /// 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.
1969 ///
1970 /// If the mode argument to [`cudaStreamBeginCapture`] was not cudaStreamCaptureModeRelaxed, this call must be from the same thread as [`cudaStreamBeginCapture`].
1971 ///
1972 /// Note:
1973 ///
1974 /// Note that this function may also return error codes from previous, asynchronous launches.
1975 ///
1976 /// **See also:**
1977 ///
1978 /// [`cudaStreamCreate`], [`cudaStreamBeginCapture`], [`cudaStreamIsCapturing`], [`cudaGraphDestroy`].
1979 ///
1980 /// # Parameters
1981 ///
1982 /// - `stream`: Stream to query.
1983 /// - `pGraph`: The captured graph.
1984 pub fn cudaStreamEndCapture(
1985 stream: cudaStream_t,
1986 pGraph: *mut cudaGraph_t,
1987 ) -> cudaError_t;
1988}
1989unsafe extern "C" {
1990 /// Returns a stream's capture status.
1991 ///
1992 /// Return the capture status of stream via pCaptureStatus. After a successful call, \*pCaptureStatus will contain one of the following:
1993 ///
1994 /// * [cudaStreamCaptureStatusNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg0ec4aacc66fe76c145252d12b189e233dbbe6269245e62cd99e6c95206008e50): The stream is not capturing.
1995 /// * [cudaStreamCaptureStatusActive](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg0ec4aacc66fe76c145252d12b189e233b165b0917377d0d7283ca5ac8013568b): The stream is capturing.
1996 /// * [cudaStreamCaptureStatusInvalidated](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg0ec4aacc66fe76c145252d12b189e2334c61e87e6268a6f9b6c928c574c12c76): The stream was capturing but an error has invalidated the capture sequence. The capture sequence must be terminated with
1997 /// [`cudaStreamEndCapture`] on the stream where it was initiated in order to continue using stream.
1998 ///
1999 /// Note that, if this is called on `cudaStreamLegacy` (the "null stream") while a blocking stream on the same device is capturing, it will return [cudaErrorStreamCaptureImplicit](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038cf775033deb76dbde57b8df7bd9244e7) and \*pCaptureStatus is unspecified after the call. The blocking stream capture is not invalidated.
2000 ///
2001 /// When a blocking stream is capturing, the legacy stream is in an unusable state until the blocking stream capture is terminated.
2002 /// The legacy stream is not supported for stream capture, but attempted use would have an implicit dependency on the capturing
2003 /// stream(s).
2004 ///
2005 /// Note:
2006 ///
2007 /// Note that this function may also return error codes from previous, asynchronous launches.
2008 ///
2009 /// **See also:**
2010 ///
2011 /// [`cudaStreamCreate`], [`cudaStreamBeginCapture`], [`cudaStreamEndCapture`].
2012 ///
2013 /// # Parameters
2014 ///
2015 /// - `stream`: Stream to query.
2016 /// - `pCaptureStatus`: Returns the stream's capture status.
2017 pub fn cudaStreamIsCapturing(
2018 stream: cudaStream_t,
2019 pCaptureStatus: *mut cudaStreamCaptureStatus,
2020 ) -> cudaError_t;
2021}
2022unsafe extern "C" {
2023 /// Query a stream's capture state.
2024 ///
2025 /// Query stream state related to stream capture.
2026 ///
2027 /// If called on `cudaStreamLegacy` (the "null stream") while a stream not created with [`cudaStreamNonBlocking`] is capturing, returns [cudaErrorStreamCaptureImplicit](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038cf775033deb76dbde57b8df7bd9244e7).
2028 ///
2029 /// Valid data (other than capture status) is returned only if both of the following are true:
2030 ///
2031 /// * the call returns cudaSuccess
2032 /// * the returned capture status is [cudaStreamCaptureStatusActive](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg0ec4aacc66fe76c145252d12b189e233b165b0917377d0d7283ca5ac8013568b)
2033 ///
2034 /// If edgeData_out is non-NULL then dependencies_out must be as well. If dependencies_out is non-NULL and edgeData_out is NULL, but there is non-zero edge data for one or more of the current stream dependencies, the call will return [cudaErrorLossyQuery](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d484d9d8e8f269cf93d4c111b646f908).
2035 ///
2036 /// Note:
2037 ///
2038 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
2039 /// * Note that this function may also return error codes from previous, asynchronous launches.
2040 ///
2041 /// **See also:**
2042 ///
2043 /// [`cudaStreamBeginCapture`], [`cudaStreamIsCapturing`], [`cudaStreamUpdateCaptureDependencies`].
2044 ///
2045 /// # Parameters
2046 ///
2047 /// - `stream`: The stream to query.
2048 /// - `captureStatus_out`: Location to return the capture status of the stream; required.
2049 /// - `id_out`: Optional location to return an id for the capture sequence, which is unique over the lifetime of the process.
2050 /// - `graph_out`: Optional location to return the graph being captured into. All operations other than destroy and node removal are permitted
2051 /// on the graph while the capture sequence is in progress. This API does not transfer ownership of the graph, which is transferred
2052 /// 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
2053 /// from the original stream at [`cudaStreamEndCapture`] due to direct actions on the graph do not trigger [cudaErrorStreamCaptureUnjoined](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce9e4b4b58c1abf9faa1ce8b1079076d).
2054 /// - `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
2055 /// set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call
2056 /// which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they
2057 /// or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream)
2058 /// without copying.
2059 /// - `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.
2060 /// - `numDependencies_out`: Optional location to store the size of the array returned in dependencies_out.
2061 pub fn cudaStreamGetCaptureInfo(
2062 stream: cudaStream_t,
2063 captureStatus_out: *mut cudaStreamCaptureStatus,
2064 id_out: *mut ::core::ffi::c_ulonglong,
2065 graph_out: *mut cudaGraph_t,
2066 dependencies_out: *mut *const cudaGraphNode_t,
2067 edgeData_out: *mut *const cudaGraphEdgeData,
2068 numDependencies_out: *mut size_t,
2069 ) -> cudaError_t;
2070}
2071unsafe extern "C" {
2072 /// Update the set of dependencies in a capturing stream.
2073 ///
2074 /// Modifies the dependency set of a capturing stream. The dependency set is the set of nodes that the next captured node in the
2075 /// stream will depend on.
2076 ///
2077 /// Valid flags are [`cudaStreamUpdateCaptureDependenciesFlags::cudaStreamAddCaptureDependencies`] and [`cudaStreamUpdateCaptureDependenciesFlags::cudaStreamSetCaptureDependencies`]. These control whether the set passed to the API is added to the existing set or replaces it. A flags value of 0 defaults
2078 /// to [`cudaStreamUpdateCaptureDependenciesFlags::cudaStreamAddCaptureDependencies`].
2079 ///
2080 /// Nodes that are removed from the dependency set via this API do not result in [cudaErrorStreamCaptureUnjoined](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce9e4b4b58c1abf9faa1ce8b1079076d) if they are unreachable from the stream at [`cudaStreamEndCapture`].
2081 ///
2082 /// Returns [cudaErrorIllegalState](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00380604022302a2ed15d31bc33546b2e963) if the stream is not capturing.
2083 ///
2084 /// Note:
2085 ///
2086 /// Note that this function may also return error codes from previous, asynchronous launches.
2087 ///
2088 /// **See also:**
2089 ///
2090 /// [`cudaStreamBeginCapture`], [`cudaStreamGetCaptureInfo`],.
2091 ///
2092 /// # Parameters
2093 ///
2094 /// - `stream`: The stream to update.
2095 /// - `dependencies`: The set of dependencies to add.
2096 /// - `dependencyData`: Optional array of data associated with each dependency.
2097 /// - `numDependencies`: The size of the dependencies array.
2098 /// - `flags`: See above.
2099 pub fn cudaStreamUpdateCaptureDependencies(
2100 stream: cudaStream_t,
2101 dependencies: *mut cudaGraphNode_t,
2102 dependencyData: *const cudaGraphEdgeData,
2103 numDependencies: size_t,
2104 flags: ::core::ffi::c_uint,
2105 ) -> cudaError_t;
2106}
2107unsafe extern "C" {
2108 /// # Parameters
2109 ///
2110 /// - `event`: Newly created event.
2111 pub fn cudaEventCreate(event: *mut cudaEvent_t) -> cudaError_t;
2112}
2113unsafe extern "C" {
2114 /// Creates an event object with the specified flags.
2115 ///
2116 /// Creates an event object for the current device with the specified flags. Valid flags include:
2117 ///
2118 /// * `cudaEventDefault`: Default event creation flag.
2119 /// * `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.
2120 /// * `cudaEventDisableTiming`: Specifies that the created event does not need to record timing data. Events created with this flag specified and the `cudaEventBlockingSync` flag not specified will provide the best performance when used with [`cudaStreamWaitEvent`] and [`cudaEventQuery`].
2121 /// * `cudaEventInterprocess`: Specifies that the created event may be used as an interprocess event by [`cudaIpcGetEventHandle`]. `cudaEventInterprocess` must be specified along with `cudaEventDisableTiming`.
2122 ///
2123 /// Note:
2124 ///
2125 /// * Note that this function may also return error codes from previous, asynchronous launches.
2126 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2127 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2128 ///
2129 /// **See also:**
2130 ///
2131 /// cudaEventCreate ( C API), [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [cuEventCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g450687e75f3ff992fe01662a43d9d3db).
2132 ///
2133 /// # Parameters
2134 ///
2135 /// - `event`: Newly created event.
2136 /// - `flags`: Flags for new event.
2137 pub fn cudaEventCreateWithFlags(
2138 event: *mut cudaEvent_t,
2139 flags: ::core::ffi::c_uint,
2140 ) -> cudaError_t;
2141}
2142unsafe extern "C" {
2143 /// Records an event.
2144 ///
2145 /// 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.
2146 ///
2147 /// [`cudaEventRecord`] can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as [`cudaStreamWaitEvent`] use the most recently captured state at the time of the API call, and are not affected by later calls to [`cudaEventRecord`]. Before the first call to [`cudaEventRecord`], an event represents an empty set of work, so for example [`cudaEventQuery`] would return [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591).
2148 ///
2149 /// Note:
2150 ///
2151 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
2152 /// * Note that this function may also return error codes from previous, asynchronous launches.
2153 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2154 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2155 /// * Returns [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
2156 ///
2157 /// **See also:**
2158 ///
2159 /// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [`cudaEventRecordWithFlags`], [cuEventRecord](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g95424d3be52c4eb95d83861b70fb89d1).
2160 ///
2161 /// # Parameters
2162 ///
2163 /// - `event`: Event to record.
2164 /// - `stream`: Stream in which to record event.
2165 pub fn cudaEventRecord(event: cudaEvent_t, stream: cudaStream_t) -> cudaError_t;
2166}
2167unsafe extern "C" {
2168 /// Records an event.
2169 ///
2170 /// 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.
2171 ///
2172 /// [`cudaEventRecordWithFlags`] can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as [`cudaStreamWaitEvent`] use the most recently captured state at the time of the API call, and are not affected by later calls to [`cudaEventRecordWithFlags`]. Before the first call to [`cudaEventRecordWithFlags`], an event represents an empty set of work, so for example [`cudaEventQuery`] would return [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591).
2173 ///
2174 /// flags include:
2175 ///
2176 /// * [`cudaEventRecordDefault`]: Default event creation flag.
2177 /// * [`cudaEventRecordExternal`]: Event is captured in the graph as an external event node when performing stream capture.
2178 ///
2179 /// Note:
2180 ///
2181 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
2182 /// * Note that this function may also return error codes from previous, asynchronous launches.
2183 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2184 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2185 /// * Returns [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
2186 ///
2187 /// **See also:**
2188 ///
2189 /// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [`cudaStreamWaitEvent`], [`cudaEventRecord`], [cuEventRecord](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g95424d3be52c4eb95d83861b70fb89d1),.
2190 ///
2191 /// # Parameters
2192 ///
2193 /// - `event`: Event to record.
2194 /// - `stream`: Stream in which to record event.
2195 /// - `flags`: Parameters for the operation(See above).
2196 pub fn cudaEventRecordWithFlags(
2197 event: cudaEvent_t,
2198 stream: cudaStream_t,
2199 flags: ::core::ffi::c_uint,
2200 ) -> cudaError_t;
2201}
2202unsafe extern "C" {
2203 /// Queries an event's status.
2204 ///
2205 /// Queries the status of all work currently captured by event. See [`cudaEventRecord`] for details on what is captured by an event.
2206 ///
2207 /// Returns [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) if all captured work has been completed, or [cudaErrorNotReady](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038285d0c852ab65b8925505e1065563f6d) if any captured work is incomplete.
2208 ///
2209 /// For the purposes of Unified Memory, a return value of [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) is equivalent to having called [`cudaEventSynchronize`].
2210 ///
2211 /// Note:
2212 ///
2213 /// * Note that this function may also return error codes from previous, asynchronous launches.
2214 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2215 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2216 /// * Returns [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
2217 ///
2218 /// **See also:**
2219 ///
2220 /// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventRecord`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [cuEventQuery](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g6f0704d755066b0ee705749ae911deef).
2221 ///
2222 /// # Parameters
2223 ///
2224 /// - `event`: Event to query.
2225 pub fn cudaEventQuery(event: cudaEvent_t) -> cudaError_t;
2226}
2227unsafe extern "C" {
2228 /// Waits for an event to complete.
2229 ///
2230 /// Waits until the completion of all work currently captured in event. See [`cudaEventRecord`] for details on what is captured by an event.
2231 ///
2232 /// Waiting for an event that was created with the `cudaEventBlockingSync` flag will cause the calling CPU thread to block until the event has been completed by the device. If the `cudaEventBlockingSync` flag has not been set, then the CPU thread will busy-wait until the event has been completed by the device.
2233 ///
2234 /// Note:
2235 ///
2236 /// * Note that this function may also return error codes from previous, asynchronous launches.
2237 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2238 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2239 /// * Returns [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
2240 ///
2241 /// **See also:**
2242 ///
2243 /// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventRecord`], [`cudaEventQuery`], [`cudaEventDestroy`], [`cudaEventElapsedTime`], [cuEventSynchronize](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g9e520d34e51af7f5375610bca4add99c).
2244 ///
2245 /// # Parameters
2246 ///
2247 /// - `event`: Event to wait for.
2248 pub fn cudaEventSynchronize(event: cudaEvent_t) -> cudaError_t;
2249}
2250unsafe extern "C" {
2251 /// Destroys an event object.
2252 ///
2253 /// Destroys the event specified by event.
2254 ///
2255 /// An event may be destroyed before it is complete (i.e., while [`cudaEventQuery`] would return [cudaErrorNotReady](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
2256 /// asynchronously at completion.
2257 ///
2258 /// Note:
2259 ///
2260 /// * Note that this function may also return error codes from previous, asynchronous launches.
2261 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2262 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2263 /// * Use of the handle after this call is undefined behavior.
2264 /// * Returns [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
2265 ///
2266 /// **See also:**
2267 ///
2268 /// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventRecord`], [`cudaEventElapsedTime`], [cuEventDestroy](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g593ec73a8ec5a5fc031311d3e4dca1ef).
2269 ///
2270 /// # Parameters
2271 ///
2272 /// - `event`: Event to destroy.
2273 pub fn cudaEventDestroy(event: cudaEvent_t) -> cudaError_t;
2274}
2275unsafe extern "C" {
2276 /// Computes the elapsed time between events.
2277 ///
2278 /// Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). Note this API
2279 /// is not guaranteed to return the latest errors for pending work. As such this API is intended to serve as a elapsed time calculation
2280 /// only and polling for completion on the events to be compared should be done with [`cudaEventQuery`] instead.
2281 ///
2282 /// If either event was last recorded in a non-NULL stream, the resulting time may be greater than expected (even if both used
2283 /// 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
2284 /// events. Any number of other different stream operations could execute in between the two measured events, thus altering the
2285 /// timing in a significant way.
2286 ///
2287 /// If [`cudaEventRecord`] has not been called on either event, then [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038285d0c852ab65b8925505e1065563f6d) on at least one of the events), [cudaErrorNotReady](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038285d0c852ab65b8925505e1065563f6d) is returned. If either event was created with the `cudaEventDisableTiming` flag, then this function will return [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273).
2288 ///
2289 /// Note:
2290 ///
2291 /// * Note that this function may also return error codes from previous, asynchronous launches.
2292 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2293 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2294 /// * Returns [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) in the event of being passed NULL as the input event.
2295 ///
2296 /// **See also:**
2297 ///
2298 /// cudaEventCreate ( C API), [`cudaEventCreateWithFlags`], [`cudaEventQuery`], [`cudaEventSynchronize`], [`cudaEventDestroy`], [`cudaEventRecord`], [cuEventElapsedTime](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1gdfb1178807353bbcaa9e245da497cf97).
2299 ///
2300 /// # Parameters
2301 ///
2302 /// - `ms`: Time between start and end in ms.
2303 /// - `start`: Starting event.
2304 /// - `end`: Ending event.
2305 pub fn cudaEventElapsedTime(
2306 ms: *mut f32,
2307 start: cudaEvent_t,
2308 end: cudaEvent_t,
2309 ) -> cudaError_t;
2310}
2311unsafe extern "C" {
2312 /// Imports an external memory object.
2313 ///
2314 /// Imports an externally allocated memory object and returns a handle to that in extMem_out.
2315 ///
2316 /// The properties of the handle being imported must be described in memHandleDesc. The [`cudaExternalMemoryHandleDesc`] structure is defined as follows:
2317 ///
2318 /// ```text
2319 /// typedef struct cudaExternalMemoryHandleDesc_st {
2320 /// cudaExternalMemoryHandleType type;
2321 /// union {
2322 /// int fd;
2323 /// struct {
2324 /// void *handle;
2325 /// const void *name;
2326 /// } win32;
2327 /// const void *nvSciBufObject;
2328 /// } handle;
2329 /// unsigned long long size;
2330 /// unsigned int flags;
2331 /// } cudaExternalMemoryHandleDesc;
2332 /// ```
2333 ///
2334 /// where [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) specifies the type of handle being imported. [`cudaExternalMemoryHandleType`] is defined as:
2335 ///
2336 /// ```text
2337 /// typedef enum cudaExternalMemoryHandleType_enum {
2338 /// cudaExternalMemoryHandleTypeOpaqueFd = 1,
2339 /// cudaExternalMemoryHandleTypeOpaqueWin32 = 2,
2340 /// cudaExternalMemoryHandleTypeOpaqueWin32Kmt = 3,
2341 /// cudaExternalMemoryHandleTypeD3D12Heap = 4,
2342 /// cudaExternalMemoryHandleTypeD3D12Resource = 5,
2343 /// cudaExternalMemoryHandleTypeD3D11Resource = 6,
2344 /// cudaExternalMemoryHandleTypeD3D11ResourceKmt = 7,
2345 /// cudaExternalMemoryHandleTypeNvSciBuf = 8
2346 /// } cudaExternalMemoryHandleType;
2347 /// ```
2348 ///
2349 /// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeOpaqueFd`], then cudaExternalMemoryHandleDesc::handle::fd must be a valid file descriptor referencing a memory object. Ownership of
2350 /// the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any operations
2351 /// on the file descriptor after it is imported results in undefined behavior.
2352 ///
2353 /// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeOpaqueWin32`], then exactly one of cudaExternalMemoryHandleDesc::handle::win32::handle and cudaExternalMemoryHandleDesc::handle::win32::name
2354 /// must not be NULL. If cudaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared
2355 /// NT handle that references a memory object. Ownership of this handle is not transferred to CUDA after the import operation,
2356 /// so the application must release the handle using the appropriate system call. If cudaExternalMemoryHandleDesc::handle::win32::name
2357 /// is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a memory object.
2358 ///
2359 /// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeOpaqueWin32Kmt`], then cudaExternalMemoryHandleDesc::handle::win32::handle must be non-NULL and cudaExternalMemoryHandleDesc::handle::win32::name
2360 /// must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying
2361 /// object, and thus will be invalid when all references to the memory object are destroyed.
2362 ///
2363 /// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D12Heap`], then exactly one of cudaExternalMemoryHandleDesc::handle::win32::handle and cudaExternalMemoryHandleDesc::handle::win32::name
2364 /// must not be NULL. If cudaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared
2365 /// NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Heap object. This handle holds a
2366 /// reference to the underlying object. If cudaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point to
2367 /// a NULL-terminated array of UTF-16 characters that refers to a ID3D12Heap object.
2368 ///
2369 /// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D12Resource`], then exactly one of cudaExternalMemoryHandleDesc::handle::win32::handle and cudaExternalMemoryHandleDesc::handle::win32::name
2370 /// must not be NULL. If cudaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared
2371 /// NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Resource object. This handle holds
2372 /// a reference to the underlying object. If cudaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point
2373 /// to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Resource object.
2374 ///
2375 /// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11Resource`],then exactly one of cudaExternalMemoryHandleDesc::handle::win32::handle and cudaExternalMemoryHandleDesc::handle::win32::name
2376 /// must not be NULL. If cudaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared
2377 /// NT handle that is returned by IDXGIResource1::CreateSharedHandle when referring to a ID3D11Resource object. If cudaExternalMemoryHandleDesc::handle::win32::name
2378 /// is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D11Resource object.
2379 ///
2380 /// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11ResourceKmt`], then cudaExternalMemoryHandleDesc::handle::win32::handle must be non-NULL and cudaExternalMemoryHandleDesc::handle::win32::name
2381 /// must be NULL. The handle specified must be a valid shared KMT handle that is returned by IDXGIResource::GetSharedHandle when
2382 /// referring to a ID3D11Resource object.
2383 ///
2384 /// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeNvSciBuf`], then cudaExternalMemoryHandleDesc::handle::nvSciBufObject must be NON-NULL and reference a valid NvSciBuf object. If the
2385 /// 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` and `cudaExternalSemaphoreSignalSkipNvSciBufMemSync` for memory synchronization.
2386 ///
2387 /// The size of the memory object must be specified in [cudaExternalMemoryHandleDesc::size](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_1362086a22da90ac8fba1ca294e65548e).
2388 ///
2389 /// Specifying the flag `cudaExternalMemoryDedicated` in [cudaExternalMemoryHandleDesc::flags](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_174412d3d2777ebc856aea0b9158aaafa) indicates that the resource is a dedicated resource. The definition of what a dedicated resource is outside the scope of
2390 /// this extension. This flag must be set if [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is one of the following: [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D12Resource`][`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11Resource`][`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeD3D11ResourceKmt`]
2391 ///
2392 /// Note:
2393 ///
2394 /// * Note that this function may also return error codes from previous, asynchronous launches.
2395 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2396 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2397 /// * If the Vulkan memory imported into CUDA is mapped on the CPU then the application must use vkInvalidateMappedMemoryRanges/vkFlushMappedMemoryRanges
2398 /// as well as appropriate Vulkan pipeline barriers to maintain coherence between CPU and GPU. For more information on these APIs,
2399 /// please refer to "Synchronization and Cache Control" chapter from Vulkan specification.
2400 ///
2401 /// **See also:**
2402 ///
2403 /// [`cudaDestroyExternalMemory`], [`cudaExternalMemoryGetMappedBuffer`], [`cudaExternalMemoryGetMappedMipmappedArray`].
2404 ///
2405 /// # Parameters
2406 ///
2407 /// - `extMem_out`: Returned handle to an external memory object.
2408 /// - `memHandleDesc`: Memory import handle descriptor.
2409 pub fn cudaImportExternalMemory(
2410 extMem_out: *mut cudaExternalMemory_t,
2411 memHandleDesc: *const cudaExternalMemoryHandleDesc,
2412 ) -> cudaError_t;
2413}
2414unsafe extern "C" {
2415 /// Maps a buffer onto an imported memory object.
2416 ///
2417 /// Maps a buffer onto an imported memory object and returns a device pointer in devPtr.
2418 ///
2419 /// The properties of the buffer being mapped must be described in bufferDesc. The [`cudaExternalMemoryBufferDesc`] structure is defined as follows:
2420 ///
2421 /// ```text
2422 /// typedef struct cudaExternalMemoryBufferDesc_st {
2423 /// unsigned long long offset;
2424 /// unsigned long long size;
2425 /// unsigned int flags;
2426 /// } cudaExternalMemoryBufferDesc;
2427 /// ```
2428 ///
2429 /// where [cudaExternalMemoryBufferDesc::offset](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryBufferDesc.html#structcudaExternalMemoryBufferDesc_1034839893ecb4e103f82498888157ba6) is the offset in the memory object where the buffer's base address is. [cudaExternalMemoryBufferDesc::size](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryBufferDesc.html#structcudaExternalMemoryBufferDesc_156bdddff67c72329350ed4fa4f2cd746) is the size of the buffer. [cudaExternalMemoryBufferDesc::flags](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryBufferDesc.html#structcudaExternalMemoryBufferDesc_10a7888cacfea49ab9b30ae7e9ab47d32) must be zero.
2430 ///
2431 /// The offset and size have to be suitably aligned to match the requirements of the external API. Mapping two buffers whose ranges
2432 /// overlap may or may not result in the same virtual address being returned for the overlapped portion. In such cases, the application
2433 /// must ensure that all accesses to that region from the GPU are volatile. Otherwise writes made via one address are not guaranteed
2434 /// to be visible via the other address, even if they're issued by the same thread. It is recommended that applications map the
2435 /// combined range instead of mapping separate buffers and then apply the appropriate offsets to the returned pointer to derive
2436 /// the individual buffers.
2437 ///
2438 /// The returned pointer devPtr must be freed using [`cudaFree`].
2439 ///
2440 /// Note:
2441 ///
2442 /// * Note that this function may also return error codes from previous, asynchronous launches.
2443 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2444 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2445 ///
2446 /// **See also:**
2447 ///
2448 /// [`cudaImportExternalMemory`], [`cudaDestroyExternalMemory`], [`cudaExternalMemoryGetMappedMipmappedArray`].
2449 ///
2450 /// # Parameters
2451 ///
2452 /// - `devPtr`: Returned device pointer to buffer.
2453 /// - `extMem`: Handle to external memory object.
2454 /// - `bufferDesc`: Buffer descriptor.
2455 pub fn cudaExternalMemoryGetMappedBuffer(
2456 devPtr: *mut *mut ::core::ffi::c_void,
2457 extMem: cudaExternalMemory_t,
2458 bufferDesc: *const cudaExternalMemoryBufferDesc,
2459 ) -> cudaError_t;
2460}
2461unsafe extern "C" {
2462 /// Maps a CUDA mipmapped array onto an external memory object.
2463 ///
2464 /// Maps a CUDA mipmapped array onto an external object and returns a handle to it in mipmap.
2465 ///
2466 /// The properties of the CUDA mipmapped array being mapped must be described in mipmapDesc. The structure [`cudaExternalMemoryMipmappedArrayDesc`] is defined as follows:
2467 ///
2468 /// ```text
2469 /// typedef struct cudaExternalMemoryMipmappedArrayDesc_st {
2470 /// unsigned long long offset;
2471 /// cudaChannelFormatDesc formatDesc;
2472 /// cudaExtent extent;
2473 /// unsigned int flags;
2474 /// unsigned int numLevels;
2475 /// } cudaExternalMemoryMipmappedArrayDesc;
2476 /// ```
2477 ///
2478 /// where [cudaExternalMemoryMipmappedArrayDesc::offset](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_12f9441c3c6e3100f1517ccaf668ffd83) is the offset in the memory object where the base level of the mipmap chain is. [cudaExternalMemoryMipmappedArrayDesc::formatDesc](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_142333e3049cc4a40213b086be45927e1) describes the format of the data. [cudaExternalMemoryMipmappedArrayDesc::extent](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_1cba41d5152a8458ac72a24e65ee0f3ac) specifies the dimensions of the base level of the mipmap chain. [cudaExternalMemoryMipmappedArrayDesc::flags](https://docs.nvidia.com/cuda/cuda-runtime-api/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` must be specified in [cudaExternalMemoryMipmappedArrayDesc::flags](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_1de6d5579b7f13034ea82e06012c8758f). [cudaExternalMemoryMipmappedArrayDesc::numLevels](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_14a939b3d6c1fca916dd78679049f36eb) specifies the total number of levels in the mipmap chain.
2479 ///
2480 /// The returned CUDA mipmapped array must be freed using [`cudaFreeMipmappedArray`].
2481 ///
2482 /// Note:
2483 ///
2484 /// * Note that this function may also return error codes from previous, asynchronous launches.
2485 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2486 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2487 ///
2488 /// **See also:**
2489 ///
2490 /// [`cudaImportExternalMemory`], [`cudaDestroyExternalMemory`], [`cudaExternalMemoryGetMappedBuffer`]
2491 ///
2492 /// Note:
2493 ///
2494 /// If [cudaExternalMemoryHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryHandleDesc.html#structcudaExternalMemoryHandleDesc_18d2b65d3b597280eb9be66ee34c7ee52) is [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeNvSciBuf`], then [cudaExternalMemoryMipmappedArrayDesc::numLevels](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalMemoryMipmappedArrayDesc.html#structcudaExternalMemoryMipmappedArrayDesc_14a939b3d6c1fca916dd78679049f36eb) must not be greater than 1.
2495 ///
2496 /// # Parameters
2497 ///
2498 /// - `mipmap`: Returned CUDA mipmapped array.
2499 /// - `extMem`: Handle to external memory object.
2500 /// - `mipmapDesc`: CUDA array descriptor.
2501 pub fn cudaExternalMemoryGetMappedMipmappedArray(
2502 mipmap: *mut cudaMipmappedArray_t,
2503 extMem: cudaExternalMemory_t,
2504 mipmapDesc: *const cudaExternalMemoryMipmappedArrayDesc,
2505 ) -> cudaError_t;
2506}
2507unsafe extern "C" {
2508 /// Destroys an external memory object.
2509 ///
2510 /// Destroys the specified external memory object. Any existing buffers and CUDA mipmapped arrays mapped onto this object must
2511 /// no longer be used and must be explicitly freed using [`cudaFree`] and [`cudaFreeMipmappedArray`] respectively.
2512 ///
2513 /// Note:
2514 ///
2515 /// * Note that this function may also return error codes from previous, asynchronous launches.
2516 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2517 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2518 /// * Use of the handle after this call is undefined behavior.
2519 ///
2520 /// **See also:**
2521 ///
2522 /// [`cudaImportExternalMemory`], [`cudaExternalMemoryGetMappedBuffer`], [`cudaExternalMemoryGetMappedMipmappedArray`].
2523 ///
2524 /// # Parameters
2525 ///
2526 /// - `extMem`: External memory object to be destroyed.
2527 pub fn cudaDestroyExternalMemory(extMem: cudaExternalMemory_t) -> cudaError_t;
2528}
2529unsafe extern "C" {
2530 /// Imports an external semaphore.
2531 ///
2532 /// Imports an externally allocated synchronization object and returns a handle to that in extSem_out.
2533 ///
2534 /// The properties of the handle being imported must be described in semHandleDesc. The [`cudaExternalSemaphoreHandleDesc`] is defined as follows:
2535 ///
2536 /// ```text
2537 /// typedef struct cudaExternalSemaphoreHandleDesc_st {
2538 /// cudaExternalSemaphoreHandleType type;
2539 /// union {
2540 /// int fd;
2541 /// struct {
2542 /// void *handle;
2543 /// const void *name;
2544 /// } win32;
2545 /// const void* NvSciSyncObj;
2546 /// } handle;
2547 /// unsigned int flags;
2548 /// } cudaExternalSemaphoreHandleDesc;
2549 /// ```
2550 ///
2551 /// where [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) specifies the type of handle being imported. [`cudaExternalSemaphoreHandleType`] is defined as:
2552 ///
2553 /// ```text
2554 /// typedef enum cudaExternalSemaphoreHandleType_enum {
2555 /// cudaExternalSemaphoreHandleTypeOpaqueFd = 1,
2556 /// cudaExternalSemaphoreHandleTypeOpaqueWin32 = 2,
2557 /// cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt = 3,
2558 /// cudaExternalSemaphoreHandleTypeD3D12Fence = 4,
2559 /// cudaExternalSemaphoreHandleTypeD3D11Fence = 5,
2560 /// cudaExternalSemaphoreHandleTypeNvSciSync = 6,
2561 /// cudaExternalSemaphoreHandleTypeKeyedMutex = 7,
2562 /// cudaExternalSemaphoreHandleTypeKeyedMutexKmt = 8,
2563 /// cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd = 9,
2564 /// cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 = 10
2565 /// } cudaExternalSemaphoreHandleType;
2566 /// ```
2567 ///
2568 /// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueFd`], then cudaExternalSemaphoreHandleDesc::handle::fd must be a valid file descriptor referencing a synchronization object. Ownership
2569 /// of the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any operations
2570 /// on the file descriptor after it is imported results in undefined behavior.
2571 ///
2572 /// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32`], then exactly one of cudaExternalSemaphoreHandleDesc::handle::win32::handle and cudaExternalSemaphoreHandleDesc::handle::win32::name
2573 /// must not be NULL. If cudaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared
2574 /// NT handle that references a synchronization object. Ownership of this handle is not transferred to CUDA after the import operation,
2575 /// so the application must release the handle using the appropriate system call. If cudaExternalSemaphoreHandleDesc::handle::win32::name
2576 /// is not NULL, then it must name a valid synchronization object.
2577 ///
2578 /// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt`], then cudaExternalSemaphoreHandleDesc::handle::win32::handle must be non-NULL and cudaExternalSemaphoreHandleDesc::handle::win32::name
2579 /// must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying
2580 /// object, and thus will be invalid when all references to the synchronization object are destroyed.
2581 ///
2582 /// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D12Fence`], then exactly one of cudaExternalSemaphoreHandleDesc::handle::win32::handle and cudaExternalSemaphoreHandleDesc::handle::win32::name
2583 /// must not be NULL. If cudaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared
2584 /// NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Fence object. This handle holds a
2585 /// reference to the underlying object. If cudaExternalSemaphoreHandleDesc::handle::win32::name is not NULL, then it must name
2586 /// a valid synchronization object that refers to a valid ID3D12Fence object.
2587 ///
2588 /// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D11Fence`], then exactly one of cudaExternalSemaphoreHandleDesc::handle::win32::handle and cudaExternalSemaphoreHandleDesc::handle::win32::name
2589 /// must not be NULL. If cudaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared
2590 /// NT handle that is returned by ID3D11Fence::CreateSharedHandle. If cudaExternalSemaphoreHandleDesc::handle::win32::name is
2591 /// not NULL, then it must name a valid synchronization object that refers to a valid ID3D11Fence object.
2592 ///
2593 /// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`], then cudaExternalSemaphoreHandleDesc::handle::nvSciSyncObj represents a valid NvSciSyncObj.
2594 ///
2595 /// [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutex`], then exactly one of cudaExternalSemaphoreHandleDesc::handle::win32::handle and cudaExternalSemaphoreHandleDesc::handle::win32::name
2596 /// must not be NULL. If cudaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it represent a valid shared
2597 /// NT handle that is returned by IDXGIResource1::CreateSharedHandle when referring to a IDXGIKeyedMutex object.
2598 ///
2599 /// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutexKmt`], then cudaExternalSemaphoreHandleDesc::handle::win32::handle must be non-NULL and cudaExternalSemaphoreHandleDesc::handle::win32::name
2600 /// must be NULL. The handle specified must represent a valid KMT handle that is returned by IDXGIResource::GetSharedHandle when
2601 /// referring to a IDXGIKeyedMutex object.
2602 ///
2603 /// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd`], then cudaExternalSemaphoreHandleDesc::handle::fd must be a valid file descriptor referencing a synchronization object. Ownership
2604 /// of the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any operations
2605 /// on the file descriptor after it is imported results in undefined behavior.
2606 ///
2607 /// If [cudaExternalSemaphoreHandleDesc::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaExternalSemaphoreHandleDesc.html#structcudaExternalSemaphoreHandleDesc_1e925b19e386170fb3cccf58cfab0fd9c) is [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32`], then exactly one of cudaExternalSemaphoreHandleDesc::handle::win32::handle and cudaExternalSemaphoreHandleDesc::handle::win32::name
2608 /// must not be NULL. If cudaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared
2609 /// NT handle that references a synchronization object. Ownership of this handle is not transferred to CUDA after the import operation,
2610 /// so the application must release the handle using the appropriate system call. If cudaExternalSemaphoreHandleDesc::handle::win32::name
2611 /// is not NULL, then it must name a valid synchronization object.
2612 ///
2613 /// Note:
2614 ///
2615 /// * Note that this function may also return error codes from previous, asynchronous launches.
2616 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2617 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2618 ///
2619 /// **See also:**
2620 ///
2621 /// [`cudaDestroyExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
2622 ///
2623 /// # Parameters
2624 ///
2625 /// - `extSem_out`: Returned handle to an external semaphore.
2626 /// - `semHandleDesc`: Semaphore import handle descriptor.
2627 pub fn cudaImportExternalSemaphore(
2628 extSem_out: *mut cudaExternalSemaphore_t,
2629 semHandleDesc: *const cudaExternalSemaphoreHandleDesc,
2630 ) -> cudaError_t;
2631}
2632unsafe extern "C" {
2633 /// Signals a set of external semaphore objects.
2634 ///
2635 /// Enqueues a signal operation on a set of externally allocated semaphore object in the specified stream. The operations will
2636 /// be executed when all prior operations in the stream complete.
2637 ///
2638 /// The exact semantics of signaling a semaphore depends on the type of the object.
2639 ///
2640 /// If the semaphore object is any one of the following types: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueFd`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt`] then signaling the semaphore will set it to the signaled state.
2641 ///
2642 /// If the semaphore object is any one of the following types: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D12Fence`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D11Fence`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32`] then the semaphore will be set to the value specified in cudaExternalSemaphoreSignalParams::params::fence::value.
2643 ///
2644 /// If the semaphore object is of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`] this API sets cudaExternalSemaphoreSignalParams::params::nvSciSync::fence to a value that can be used by subsequent waiters
2645 /// 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,
2646 /// signaling such an external semaphore object causes appropriate memory synchronization operations to be performed over all
2647 /// the external memory objects that are imported as [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeNvSciBuf`]. This ensures that any subsequent accesses made by other importers of the same set of NvSciBuf memory object(s) are coherent.
2648 /// These operations can be skipped by specifying the flag `cudaExternalSemaphoreSignalSkipNvSciBufMemSync`, which can be used as a performance optimization when data coherency is not required. But specifying this flag in scenarios
2649 /// where data coherency is required results in undefined behavior. Also, for semaphore object of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`], if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in [`cudaDeviceGetNvSciSyncAttributes`] to cudaNvSciSyncAttrSignal, this API will return cudaErrorNotSupported.
2650 ///
2651 /// cudaExternalSemaphoreSignalParams::params::nvSciSync::fence associated with semaphore object of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`] can be deterministic. For this the NvSciSyncAttrList used to create the semaphore object must have value of NvSciSyncAttrKey_RequireDeterministicFences
2652 /// key set to true. Deterministic fences allow users to enqueue a wait over the semaphore object even before corresponding signal
2653 /// is enqueued. For such a semaphore object, CUDA guarantees that each signal operation will increment the fence value by '1'.
2654 /// Users are expected to track count of signals enqueued on the semaphore object and insert waits accordingly. When such a semaphore
2655 /// object is signaled from multiple streams, due to concurrent stream execution, it is possible that the order in which the semaphore
2656 /// gets signaled is indeterministic. This could lead to waiters of the semaphore getting unblocked incorrectly. Users are expected
2657 /// to handle such situations, either by not using the same semaphore object with deterministic fence support enabled in different
2658 /// streams or by adding explicit dependency amongst such streams so that the semaphore is signaled in order. cudaExternalSemaphoreSignalParams::params::nvSciSync::fence
2659 /// associated with semaphore object of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`] can be timestamp enabled. For this the NvSciSyncAttrList used to create the object must have the value of NvSciSyncAttrKey_WaiterRequireTimestamps
2660 /// key set to true. Timestamps are emitted asynchronously by the GPU and CUDA saves the GPU timestamp in the corresponding NvSciSyncFence
2661 /// at the time of signal on GPU. Users are expected to convert GPU clocks to CPU clocks using appropriate scaling functions.
2662 /// Users are expected to wait for the completion of the fence before extracting timestamp using appropriate NvSciSync APIs. Users
2663 /// are expected to ensure that there is only one outstanding timestamp enabled fence per CUDA-NvSciSync object at any point of
2664 /// time, failing which leads to undefined behavior. Extracting the timestamp before the corresponding fence is signalled could
2665 /// lead to undefined behavior. Timestamp extracted via appropriate NvSciSync API would be in microseconds.
2666 ///
2667 /// If the semaphore object is any one of the following types: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutex`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutexKmt`], then the keyed mutex will be released with the key specified in cudaExternalSemaphoreSignalParams::params::keyedmutex::key.
2668 ///
2669 /// Note:
2670 ///
2671 /// * Note that this function may also return error codes from previous, asynchronous launches.
2672 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2673 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2674 ///
2675 /// **See also:**
2676 ///
2677 /// [`cudaImportExternalSemaphore`], [`cudaDestroyExternalSemaphore`], [`cudaWaitExternalSemaphoresAsync`].
2678 ///
2679 /// # Parameters
2680 ///
2681 /// - `extSemArray`: Set of external semaphores to be signaled.
2682 /// - `paramsArray`: Array of semaphore parameters.
2683 /// - `numExtSems`: Number of semaphores to signal.
2684 /// - `stream`: Stream to enqueue the signal operations in.
2685 pub fn cudaSignalExternalSemaphoresAsync(
2686 extSemArray: *const cudaExternalSemaphore_t,
2687 paramsArray: *const cudaExternalSemaphoreSignalParams,
2688 numExtSems: ::core::ffi::c_uint,
2689 stream: cudaStream_t,
2690 ) -> cudaError_t;
2691}
2692unsafe extern "C" {
2693 /// Waits on a set of external semaphore objects.
2694 ///
2695 /// Enqueues a wait operation on a set of externally allocated semaphore object in the specified stream. The operations will be
2696 /// executed when all prior operations in the stream complete.
2697 ///
2698 /// The exact semantics of waiting on a semaphore depends on the type of the object.
2699 ///
2700 /// If the semaphore object is any one of the following types: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueFd`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt`] then waiting on the semaphore will wait until the semaphore reaches the signaled state. The semaphore will then be reset
2701 /// to the unsignaled state. Therefore for every signal operation, there can only be one wait operation.
2702 ///
2703 /// If the semaphore object is any one of the following types: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D12Fence`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeD3D11Fence`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32`] then waiting on the semaphore will wait until the value of the semaphore is greater than or equal to cudaExternalSemaphoreWaitParams::params::fence::value.
2704 ///
2705 /// If the semaphore object is of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`] then, waiting on the semaphore will wait until the cudaExternalSemaphoreSignalParams::params::nvSciSync::fence is signaled
2706 /// by the signaler of the NvSciSyncObj that was associated with this semaphore object. By default, waiting on such an external
2707 /// semaphore object causes appropriate memory synchronization operations to be performed over all external memory objects that
2708 /// are imported as [`cudaExternalMemoryHandleType::cudaExternalMemoryHandleTypeNvSciBuf`]. This ensures that any subsequent accesses made by other importers of the same set of NvSciBuf memory object(s) are coherent.
2709 /// These operations can be skipped by specifying the flag `cudaExternalSemaphoreWaitSkipNvSciBufMemSync`, which can be used as a performance optimization when data coherency is not required. But specifying this flag in scenarios
2710 /// where data coherency is required results in undefined behavior. Also, for semaphore object of the type [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeNvSciSync`], if the NvSciSyncAttrList used to create the NvSciSyncObj had not set the flags in [`cudaDeviceGetNvSciSyncAttributes`] to cudaNvSciSyncAttrWait, this API will return cudaErrorNotSupported.
2711 ///
2712 /// If the semaphore object is any one of the following types: [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutex`], [`cudaExternalSemaphoreHandleType::cudaExternalSemaphoreHandleTypeKeyedMutexKmt`], then the keyed mutex will be acquired when it is released with the key specified in cudaExternalSemaphoreSignalParams::params::keyedmutex::key
2713 /// or until the timeout specified by cudaExternalSemaphoreSignalParams::params::keyedmutex::timeoutMs has lapsed. The timeout
2714 /// interval can either be a finite value specified in milliseconds or an infinite value. In case an infinite value is specified
2715 /// the timeout never elapses. The windows INFINITE macro must be used to specify infinite timeout
2716 ///
2717 /// Note:
2718 ///
2719 /// * Note that this function may also return error codes from previous, asynchronous launches.
2720 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2721 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2722 ///
2723 /// **See also:**
2724 ///
2725 /// [`cudaImportExternalSemaphore`], [`cudaDestroyExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`].
2726 ///
2727 /// # Parameters
2728 ///
2729 /// - `extSemArray`: External semaphores to be waited on.
2730 /// - `paramsArray`: Array of semaphore parameters.
2731 /// - `numExtSems`: Number of semaphores to wait on.
2732 /// - `stream`: Stream to enqueue the wait operations in.
2733 pub fn cudaWaitExternalSemaphoresAsync(
2734 extSemArray: *const cudaExternalSemaphore_t,
2735 paramsArray: *const cudaExternalSemaphoreWaitParams,
2736 numExtSems: ::core::ffi::c_uint,
2737 stream: cudaStream_t,
2738 ) -> cudaError_t;
2739}
2740unsafe extern "C" {
2741 /// Destroys an external semaphore.
2742 ///
2743 /// Destroys an external semaphore object and releases any references to the underlying resource. Any outstanding signals or waits
2744 /// must have completed before the semaphore is destroyed.
2745 ///
2746 /// Note:
2747 ///
2748 /// * Note that this function may also return error codes from previous, asynchronous launches.
2749 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2750 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2751 /// * Use of the handle after this call is undefined behavior.
2752 ///
2753 /// **See also:**
2754 ///
2755 /// [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
2756 ///
2757 /// # Parameters
2758 ///
2759 /// - `extSem`: External semaphore to be destroyed.
2760 pub fn cudaDestroyExternalSemaphore(extSem: cudaExternalSemaphore_t) -> cudaError_t;
2761}
2762unsafe extern "C" {
2763 /// # Parameters
2764 ///
2765 /// - `func`: Device function symbol.
2766 /// - `gridDim`: Grid dimentions.
2767 /// - `blockDim`: Block dimentions.
2768 /// - `args`: Arguments.
2769 /// - `sharedMem`: Shared memory (defaults to 0).
2770 /// - `stream`: Stream identifier (defaults to NULL).
2771 pub fn cudaLaunchKernel(
2772 func: *const ::core::ffi::c_void,
2773 gridDim: dim3,
2774 blockDim: dim3,
2775 args: *mut *mut ::core::ffi::c_void,
2776 sharedMem: size_t,
2777 stream: cudaStream_t,
2778 ) -> cudaError_t;
2779}
2780unsafe extern "C" {
2781 /// Launches a CUDA function with launch-time configuration.
2782 ///
2783 /// Note that the functionally equivalent variadic template [cudaLaunchKernelEx](https://docs.nvidia.com/cuda/cuda-runtime-api/high-level-api.html#group__CUDART__HIGHLEVEL_1g81f2b11c6726c7b2f3fc54fc718eaf1c "Launches a CUDA function with launch-time configuration.") is available for C++11 and newer.
2784 ///
2785 /// 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.
2786 ///
2787 /// config->dynamicSmemBytes sets the amount of dynamic shared memory that will be available to each thread block.
2788 ///
2789 /// config->stream specifies a stream the invocation is associated to.
2790 ///
2791 /// Configuration beyond grid and block dimensions, dynamic shared memory size, and stream can be provided with the following
2792 /// two fields of config:
2793 ///
2794 /// config->attrs is an array of config->numAttrs contiguous [`cudaLaunchAttribute`] elements. The value of this pointer is not considered if config->numAttrs is zero. However, in that case, it is recommended to set the pointer to NULL. config->numAttrs is the number of attributes populating the first config->numAttrs positions of the config->attrs array.
2795 ///
2796 /// 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.
2797 ///
2798 /// N.B. This function is so named to avoid unintentionally invoking the templated version, cudaLaunchKernelEx, for kernels taking a single void\*\* or void\* parameter.
2799 ///
2800 /// Note:
2801 ///
2802 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
2803 /// * Note that this function may also return error codes from previous, asynchronous launches.
2804 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2805 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2806 /// * The API can also be used with a kernel `cudaKernel_t` by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
2807 /// * Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type
2808 /// that can be reliably passed to a different runtime instance is `cudaKernel_t`
2809 ///
2810 /// **See also:**
2811 ///
2812 /// [cudaLaunchKernelEx](https://docs.nvidia.com/cuda/cuda-runtime-api/high-level-api.html#group__CUDART__HIGHLEVEL_1g81f2b11c6726c7b2f3fc54fc718eaf1c "Launches a CUDA function with launch-time configuration.")(const [`cudaLaunchConfig_t`] \*config, void (\*kernel)(ExpTypes...), ActTypes &&... args) "cudaLaunchKernelEx (C++ API)", [cuLaunchKernelEx](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC_1gb9c891eb6bb8f4089758e64c9c976db9).
2813 ///
2814 /// # Parameters
2815 ///
2816 /// - `config`: Launch configuration.
2817 /// - `func`: Kernel to launch.
2818 /// - `args`: Array of pointers to kernel parameters.
2819 pub fn cudaLaunchKernelExC(
2820 config: *const cudaLaunchConfig_t,
2821 func: *const ::core::ffi::c_void,
2822 args: *mut *mut ::core::ffi::c_void,
2823 ) -> cudaError_t;
2824}
2825unsafe extern "C" {
2826 /// # Parameters
2827 ///
2828 /// - `func`: Device function symbol.
2829 /// - `gridDim`: Grid dimentions.
2830 /// - `blockDim`: Block dimentions.
2831 /// - `args`: Arguments.
2832 /// - `sharedMem`: Shared memory (defaults to 0).
2833 /// - `stream`: Stream identifier (defaults to NULL).
2834 pub fn cudaLaunchCooperativeKernel(
2835 func: *const ::core::ffi::c_void,
2836 gridDim: dim3,
2837 blockDim: dim3,
2838 args: *mut *mut ::core::ffi::c_void,
2839 sharedMem: size_t,
2840 stream: cudaStream_t,
2841 ) -> cudaError_t;
2842}
2843unsafe extern "C" {
2844 /// # Parameters
2845 ///
2846 /// - `func`: device function pointer.
2847 /// - `cacheConfig`: Requested cache configuration.
2848 pub fn cudaFuncSetCacheConfig(
2849 func: *const ::core::ffi::c_void,
2850 cacheConfig: cudaFuncCache,
2851 ) -> cudaError_t;
2852}
2853unsafe extern "C" {
2854 /// # Parameters
2855 ///
2856 /// - `attr`: Return pointer to function's attributes.
2857 pub fn cudaFuncGetAttributes(
2858 attr: *mut cudaFuncAttributes,
2859 func: *const ::core::ffi::c_void,
2860 ) -> cudaError_t;
2861}
2862unsafe extern "C" {
2863 /// # Parameters
2864 ///
2865 /// - `attr`: Attribute to set.
2866 /// - `value`: Value to set.
2867 pub fn cudaFuncSetAttribute(
2868 func: *const ::core::ffi::c_void,
2869 attr: cudaFuncAttribute,
2870 value: ::core::ffi::c_int,
2871 ) -> cudaError_t;
2872}
2873unsafe extern "C" {
2874 /// # Parameters
2875 ///
2876 /// - `name`: The returned name of the function.
2877 /// - `func`: The function pointer to retrieve name for.
2878 pub fn cudaFuncGetName(
2879 name: *mut *const ::core::ffi::c_char,
2880 func: *const ::core::ffi::c_void,
2881 ) -> cudaError_t;
2882}
2883unsafe extern "C" {
2884 /// Returns the offset and size of a kernel parameter in the device-side parameter layout.
2885 ///
2886 /// 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
2887 /// via [cudaGraphKernelNodeSetParam()](https://docs.nvidia.com/cuda/cuda-runtime-api/graph-management.html#group__CUDART__GRAPH_1g9171bc40a4f9be650b3fe867e8bfb549 "Updates the kernel parameters of the given kernel node.") and `cudaGraphKernelNodeUpdatesApply`. paramIndex must be less than the number of parameters that func takes.
2888 ///
2889 /// Note:
2890 ///
2891 /// * Note that this function may also return error codes from previous, asynchronous launches.
2892 /// * The API can also be used with a kernel `cudaKernel_t` by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
2893 /// * Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type
2894 /// that can be reliably passed to a different runtime instance is `cudaKernel_t`.
2895 ///
2896 /// # Parameters
2897 ///
2898 /// - `func`: The function to query.
2899 /// - `paramIndex`: The parameter index to query.
2900 /// - `paramOffset`: The offset into the device-side parameter layout at which the parameter resides.
2901 /// - `paramSize`: The size of the parameter in the device-side parameter layout.
2902 pub fn cudaFuncGetParamInfo(
2903 func: *const ::core::ffi::c_void,
2904 paramIndex: size_t,
2905 paramOffset: *mut size_t,
2906 paramSize: *mut size_t,
2907 ) -> cudaError_t;
2908}
2909unsafe extern "C" {
2910 /// Returns the number of parameters used by the function.
2911 ///
2912 /// Queries the number of kernel parameters used by func and returns it in paramCount.
2913 ///
2914 /// Note:
2915 ///
2916 /// * Note that this function may also return error codes from previous, asynchronous launches.
2917 /// * The API can also be used with a kernel `cudaKernel_t` by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
2918 /// * Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type
2919 /// that can be reliably passed to a different runtime instance is `cudaKernel_t`.
2920 ///
2921 /// # Parameters
2922 ///
2923 /// - `func`: The function to query.
2924 /// - `paramCount`: Returns the number of parameters used by the function.
2925 pub fn cudaFuncGetParamCount(
2926 func: *const ::core::ffi::c_void,
2927 paramCount: *mut size_t,
2928 ) -> cudaError_t;
2929}
2930unsafe extern "C" {
2931 /// Enqueues a host function call in a stream.
2932 ///
2933 /// Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work
2934 /// added after it.
2935 ///
2936 /// The host function must not make any CUDA API calls. Attempting to use a CUDA API may result in [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3), but this is not required. The host function must not perform any synchronization that may depend on outstanding CUDA work
2937 /// not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined
2938 /// order and may be serialized.
2939 ///
2940 /// For the purposes of Unified Memory, execution makes a number of guarantees:
2941 ///
2942 /// * The stream is considered idle for the duration of the function's execution. Thus, for example, the function may always use
2943 /// memory attached to the stream it was enqueued in.
2944 /// * The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately
2945 /// prior to the function. It thus synchronizes streams which have been "joined" prior to the function.
2946 /// * Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and
2947 /// stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added
2948 /// to another stream, if the work has been ordered behind the function call with an event.
2949 /// * Completion of the function does not cause a stream to become active except as described above. The stream will remain idle
2950 /// if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without
2951 /// device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end
2952 /// of the stream.
2953 ///
2954 /// Note that, in constrast to [cuStreamAddCallback](https://docs.nvidia.com/cuda/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.
2955 ///
2956 /// Note:
2957 ///
2958 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
2959 /// * Note that this function may also return error codes from previous, asynchronous launches.
2960 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
2961 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
2962 ///
2963 /// **See also:**
2964 ///
2965 /// [`cudaStreamCreate`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamDestroy`], [`cudaMallocManaged`], [`cudaStreamAttachMemAsync`], [`cudaStreamAddCallback`], [cuLaunchHostFunc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC_1gab95a78143bae7f21eebb978f91e7f3f).
2966 ///
2967 /// # Parameters
2968 ///
2969 /// - `userData`: User-specified data to be passed to the function.
2970 pub fn cudaLaunchHostFunc(
2971 stream: cudaStream_t,
2972 fn_: cudaHostFn_t,
2973 userData: *mut ::core::ffi::c_void,
2974 ) -> cudaError_t;
2975}
2976unsafe extern "C" {
2977 /// Enqueues a host function call in a stream.
2978 ///
2979 /// Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work
2980 /// added after it.
2981 ///
2982 /// The host function must not make any CUDA API calls. Attempting to use a CUDA API may result in [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3), but this is not required. The host function must not perform any synchronization that may depend on outstanding CUDA work
2983 /// not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined
2984 /// order and may be serialized.
2985 ///
2986 /// For the purposes of Unified Memory, execution makes a number of guarantees:
2987 ///
2988 /// * The stream is considered idle for the duration of the function's execution. Thus, for example, the function may always use
2989 /// memory attached to the stream it was enqueued in.
2990 /// * The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately
2991 /// prior to the function. It thus synchronizes streams which have been "joined" prior to the function.
2992 /// * Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and
2993 /// stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added
2994 /// to another stream, if the work has been ordered behind the function call with an event.
2995 /// * Completion of the function does not cause a stream to become active except as described above. The stream will remain idle
2996 /// if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without
2997 /// device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end
2998 /// of the stream.
2999 ///
3000 /// Note that, in constrast to [cuStreamAddCallback](https://docs.nvidia.com/cuda/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.
3001 ///
3002 /// Note:
3003 ///
3004 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
3005 /// * Note that this function may also return error codes from previous, asynchronous launches.
3006 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3007 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3008 ///
3009 /// **See also:**
3010 ///
3011 /// [`cudaStreamCreate`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamWaitEvent`], [`cudaStreamDestroy`], [`cudaMallocManaged`], [`cudaStreamAttachMemAsync`], [`cudaStreamAddCallback`], [cuLaunchHostFunc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC_1gab95a78143bae7f21eebb978f91e7f3f).
3012 ///
3013 /// # Parameters
3014 ///
3015 /// - `userData`: User-specified data to be passed to the function.
3016 /// - `syncMode`: Sync mode for the host function.
3017 pub fn cudaLaunchHostFunc_v2(
3018 stream: cudaStream_t,
3019 fn_: cudaHostFn_t,
3020 userData: *mut ::core::ffi::c_void,
3021 syncMode: ::core::ffi::c_uint,
3022 ) -> cudaError_t;
3023}
3024unsafe extern "C" {
3025 /// Sets the shared memory configuration for a device function.
3026 ///
3027 /// Any per-function setting of shared memory bank size set via [`cudaFuncSetSharedMemConfig`] will override the device wide setting set by [`cudaDeviceSetSharedMemConfig`].
3028 ///
3029 /// Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major
3030 /// effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what
3031 /// kinds of accesses to shared memory will result in bank conflicts.
3032 ///
3033 /// This function will do nothing on devices with fixed shared memory bank size.
3034 ///
3035 /// For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N>
3036 ///
3037 /// The supported bank configurations are:
3038 ///
3039 /// * cudaSharedMemBankSizeDefault: use the device's shared memory configuration when launching this function.
3040 /// * cudaSharedMemBankSizeFourByte: set shared memory bank width to be four bytes natively when launching this function.
3041 /// * cudaSharedMemBankSizeEightByte: set shared memory bank width to be eight bytes natively when launching this function.
3042 ///
3043 /// Note:
3044 ///
3045 /// * Note that this function may also return error codes from previous, asynchronous launches.
3046 /// * Use of a string naming a function as the func parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.
3047 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3048 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3049 ///
3050 /// **See also:**
3051 ///
3052 /// [`cudaDeviceSetSharedMemConfig`], [`cudaDeviceGetSharedMemConfig`], [`cudaDeviceSetCacheConfig`], [`cudaDeviceGetCacheConfig`], [`cudaFuncSetCacheConfig`], [cuFuncSetSharedMemConfig](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EXEC__DEPRECATED.html#group__CUDA__EXEC__DEPRECATED_1g3fe2417a78a7b5554a694c40355b54ce).
3053 ///
3054 /// # Parameters
3055 ///
3056 /// - `func`: Device function symbol.
3057 /// - `config`: Requested shared memory configuration.
3058 #[deprecated]
3059 pub fn cudaFuncSetSharedMemConfig(
3060 func: *const ::core::ffi::c_void,
3061 config: cudaSharedMemConfig,
3062 ) -> cudaError_t;
3063}
3064unsafe extern "C" {
3065 /// # Parameters
3066 ///
3067 /// - `numBlocks`: Returned occupancy.
3068 /// - `func`: Kernel function for which occupancy is calulated.
3069 /// - `blockSize`: Block size the kernel is intended to be launched with.
3070 /// - `dynamicSMemSize`: Per-block dynamic shared memory usage intended, in bytes.
3071 pub fn cudaOccupancyMaxActiveBlocksPerMultiprocessor(
3072 numBlocks: *mut ::core::ffi::c_int,
3073 func: *const ::core::ffi::c_void,
3074 blockSize: ::core::ffi::c_int,
3075 dynamicSMemSize: size_t,
3076 ) -> cudaError_t;
3077}
3078unsafe extern "C" {
3079 /// # Parameters
3080 ///
3081 /// - `dynamicSmemSize`: Returned maximum dynamic shared memory.
3082 /// - `func`: Kernel function for which occupancy is calculated.
3083 /// - `numBlocks`: Number of blocks to fit on SM.
3084 /// - `blockSize`: Size of the block.
3085 pub fn cudaOccupancyAvailableDynamicSMemPerBlock(
3086 dynamicSmemSize: *mut size_t,
3087 func: *const ::core::ffi::c_void,
3088 numBlocks: ::core::ffi::c_int,
3089 blockSize: ::core::ffi::c_int,
3090 ) -> cudaError_t;
3091}
3092unsafe extern "C" {
3093 /// # Parameters
3094 ///
3095 /// - `numBlocks`: Returned occupancy.
3096 /// - `func`: Kernel function for which occupancy is calulated.
3097 /// - `blockSize`: Block size the kernel is intended to be launched with.
3098 /// - `dynamicSMemSize`: Per-block dynamic shared memory usage intended, in bytes.
3099 /// - `flags`: Requested behavior for the occupancy calculator.
3100 pub fn cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
3101 numBlocks: *mut ::core::ffi::c_int,
3102 func: *const ::core::ffi::c_void,
3103 blockSize: ::core::ffi::c_int,
3104 dynamicSMemSize: size_t,
3105 flags: ::core::ffi::c_uint,
3106 ) -> cudaError_t;
3107}
3108unsafe extern "C" {
3109 /// # Parameters
3110 ///
3111 /// - `clusterSize`: Returned maximum cluster size that can be launched for the given kernel function and launch configuration.
3112 /// - `func`: Kernel function for which maximum cluster size is calculated.
3113 pub fn cudaOccupancyMaxPotentialClusterSize(
3114 clusterSize: *mut ::core::ffi::c_int,
3115 func: *const ::core::ffi::c_void,
3116 launchConfig: *const cudaLaunchConfig_t,
3117 ) -> cudaError_t;
3118}
3119unsafe extern "C" {
3120 /// # Parameters
3121 ///
3122 /// - `numClusters`: Returned maximum number of clusters that could co-exist on the target device.
3123 /// - `func`: Kernel function for which maximum number of clusters are calculated.
3124 pub fn cudaOccupancyMaxActiveClusters(
3125 numClusters: *mut ::core::ffi::c_int,
3126 func: *const ::core::ffi::c_void,
3127 launchConfig: *const cudaLaunchConfig_t,
3128 ) -> cudaError_t;
3129}
3130unsafe extern "C" {
3131 /// # Parameters
3132 ///
3133 /// - `devPtr`: Pointer to allocated device memory.
3134 /// - `size`: Requested allocation size in bytes.
3135 /// - `flags`: Must be either `cudaMemAttachGlobal` or `cudaMemAttachHost` (defaults to `cudaMemAttachGlobal`).
3136 pub fn cudaMallocManaged(
3137 devPtr: *mut *mut ::core::ffi::c_void,
3138 size: size_t,
3139 flags: ::core::ffi::c_uint,
3140 ) -> cudaError_t;
3141}
3142unsafe extern "C" {
3143 /// Allocate memory on the device.
3144 ///
3145 /// 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.
3146 /// [`cudaMalloc`] returns [cudaErrorMemoryAllocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f210f50ae7f17f655e0504929606add9) in case of failure.
3147 ///
3148 /// The device version of [`cudaFree`] cannot be used with a \*devPtr allocated using the host API, and vice versa.
3149 ///
3150 /// Note:
3151 ///
3152 /// * Note that this function may also return error codes from previous, asynchronous launches.
3153 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3154 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3155 ///
3156 /// **See also:**
3157 ///
3158 /// [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [cuMemAlloc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gb82d2a09844a58dd9e744dc31e8aa467).
3159 ///
3160 /// # Parameters
3161 ///
3162 /// - `devPtr`: Pointer to allocated device memory.
3163 /// - `size`: Requested allocation size in bytes.
3164 pub fn cudaMalloc(
3165 devPtr: *mut *mut ::core::ffi::c_void,
3166 size: size_t,
3167 ) -> cudaError_t;
3168}
3169unsafe extern "C" {
3170 /// # Parameters
3171 ///
3172 /// - `ptr`: Device pointer to allocated memory.
3173 /// - `size`: Requested allocation size in bytes.
3174 pub fn cudaMallocHost(
3175 ptr: *mut *mut ::core::ffi::c_void,
3176 size: size_t,
3177 ) -> cudaError_t;
3178}
3179unsafe extern "C" {
3180 /// Allocates pitched memory on the device.
3181 ///
3182 /// 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
3183 /// row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. The pitch returned
3184 /// 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
3185 /// an array element of type T, the address is computed as:
3186 ///
3187 /// ```text
3188 /// T* pElement = (T*)((char*)BaseAddress + Row * pitch) + Column;
3189 /// ```
3190 ///
3191 /// 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
3192 /// copies between different regions of device memory (whether linear memory or CUDA arrays).
3193 ///
3194 /// Note:
3195 ///
3196 /// * Note that this function may also return error codes from previous, asynchronous launches.
3197 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3198 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3199 ///
3200 /// **See also:**
3201 ///
3202 /// [`cudaMalloc`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [cuMemAllocPitch](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gcbe9b033f6c4de80f63cc6e58ed9a45a).
3203 ///
3204 /// # Parameters
3205 ///
3206 /// - `devPtr`: Pointer to allocated pitched device memory.
3207 /// - `pitch`: Pitch for allocation.
3208 /// - `width`: Requested pitched allocation width (in bytes).
3209 /// - `height`: Requested pitched allocation height.
3210 pub fn cudaMallocPitch(
3211 devPtr: *mut *mut ::core::ffi::c_void,
3212 pitch: *mut size_t,
3213 width: size_t,
3214 height: size_t,
3215 ) -> cudaError_t;
3216}
3217unsafe extern "C" {
3218 /// Allocate an array on the device.
3219 ///
3220 /// Allocates a CUDA array according to the [`cudaChannelFormatDesc`] structure desc and returns a handle to the new CUDA array in \*array.
3221 ///
3222 /// The [`cudaChannelFormatDesc`] is defined as:
3223 ///
3224 /// ```text
3225 /// struct cudaChannelFormatDesc {
3226 /// int x, y, z, w;
3227 /// enum cudaChannelFormatKind
3228 /// f;
3229 /// };
3230 /// ```
3231 ///
3232 /// [`cudaChannelFormatKind`]
3233 ///
3234 /// [`cudaChannelFormatKind::cudaChannelFormatKindSigned`]
3235 ///
3236 /// [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`]
3237 ///
3238 /// [`cudaChannelFormatKind::cudaChannelFormatKindFloat`]
3239 ///
3240 /// The flags parameter enables different options to be specified that affect the allocation, as follows.
3241 ///
3242 /// * `cudaArrayDefault`: This flag's value is defined to be 0 and provides default array allocation
3243 /// * `cudaArraySurfaceLoadStore`: Allocates an array that can be read from or written to using a surface reference
3244 /// * `cudaArrayTextureGather`: This flag indicates that texture gather operations will be performed on the array.
3245 /// * `cudaArraySparse`: Allocates a CUDA array without physical backing memory. The subregions within this sparse array can later be mapped onto
3246 /// a physical memory allocation by calling [cuMemMapArrayAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). The physical backing memory must be allocated via [cuMemCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
3247 /// * `cudaArrayDeferredMapping`: Allocates a CUDA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation
3248 /// by calling [cuMemMapArrayAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). The physical backing memory must be allocated via [cuMemCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
3249 ///
3250 /// width and height must meet certain size requirements. See [`cudaMalloc3DArray`] for more details.
3251 ///
3252 /// Note:
3253 ///
3254 /// * Note that this function may also return error codes from previous, asynchronous launches.
3255 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3256 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3257 ///
3258 /// **See also:**
3259 ///
3260 /// [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [cuArrayCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4192ff387a81c3bd5ed8c391ed62ca24).
3261 ///
3262 /// # Parameters
3263 ///
3264 /// - `array`: Pointer to allocated array in device memory.
3265 /// - `desc`: Requested channel format.
3266 /// - `width`: Requested array allocation width.
3267 /// - `height`: Requested array allocation height.
3268 /// - `flags`: Requested properties of allocated array.
3269 pub fn cudaMallocArray(
3270 array: *mut cudaArray_t,
3271 desc: *const cudaChannelFormatDesc,
3272 width: size_t,
3273 height: size_t,
3274 flags: ::core::ffi::c_uint,
3275 ) -> cudaError_t;
3276}
3277unsafe extern "C" {
3278 /// Frees memory on the device.
3279 ///
3280 /// Frees the memory space pointed to by devPtr, which must have been returned by a previous call to one of the following memory allocation APIs - [`cudaMalloc`], [`cudaMallocPitch`], cudaMallocManaged(), [`cudaMallocAsync`], [`cudaMallocFromPoolAsync`].
3281 ///
3282 /// Note - This API will not perform any implicit synchronization when the pointer was allocated with [`cudaMallocAsync`] or [`cudaMallocFromPoolAsync`]. Callers must ensure that all accesses to these pointer have completed before invoking [`cudaFree`]. For best performance and memory reuse, users should use [`cudaFreeAsync`] to free memory allocated via the stream ordered memory allocator. For all other pointers, this API may perform implicit synchronization.
3283 ///
3284 /// 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.
3285 ///
3286 /// The device version of [`cudaFree`] cannot be used with a \*devPtr allocated using the host API, and vice versa.
3287 ///
3288 /// Note:
3289 ///
3290 /// * Note that this function may also return error codes from previous, asynchronous launches.
3291 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3292 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3293 ///
3294 /// **See also:**
3295 ///
3296 /// [`cudaMalloc`], [`cudaMallocPitch`], [`cudaMallocManaged`], [`cudaMallocArray`], [`cudaFreeArray`], [`cudaMallocAsync`], [`cudaMallocFromPoolAsync`]cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaFreeAsync`].
3297 ///
3298 /// # Parameters
3299 ///
3300 /// - `devPtr`: Device pointer to memory to free.
3301 pub fn cudaFree(devPtr: *mut ::core::ffi::c_void) -> cudaError_t;
3302}
3303unsafe extern "C" {
3304 /// Frees page-locked memory.
3305 ///
3306 /// Frees the memory space pointed to by hostPtr, which must have been returned by a previous call to cudaMallocHost() or [`cudaHostAlloc`].
3307 ///
3308 /// Note:
3309 ///
3310 /// * Note that this function may also return error codes from previous, asynchronous launches.
3311 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3312 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3313 ///
3314 /// **See also:**
3315 ///
3316 /// [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaHostAlloc`], [cuMemFreeHost](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g62e0fdbe181dab6b1c90fa1a51c7b92c).
3317 ///
3318 /// # Parameters
3319 ///
3320 /// - `ptr`: Pointer to memory to free.
3321 pub fn cudaFreeHost(ptr: *mut ::core::ffi::c_void) -> cudaError_t;
3322}
3323unsafe extern "C" {
3324 /// Frees an array on the device.
3325 ///
3326 /// Frees the CUDA array array, which must have been returned by a previous call to [`cudaMallocArray`]. If devPtr is 0, no operation is performed.
3327 ///
3328 /// Note:
3329 ///
3330 /// * Note that this function may also return error codes from previous, asynchronous launches.
3331 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3332 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3333 ///
3334 /// **See also:**
3335 ///
3336 /// [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [cuArrayDestroy](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g982878affbbc023de84874faac838b0b).
3337 ///
3338 /// # Parameters
3339 ///
3340 /// - `array`: Pointer to array to free.
3341 pub fn cudaFreeArray(array: cudaArray_t) -> cudaError_t;
3342}
3343unsafe extern "C" {
3344 /// Frees a mipmapped array on the device.
3345 ///
3346 /// 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.
3347 ///
3348 /// Note:
3349 ///
3350 /// * Note that this function may also return error codes from previous, asynchronous launches.
3351 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3352 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3353 ///
3354 /// **See also:**
3355 ///
3356 /// [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaMallocArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], [cuMipmappedArrayDestroy](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ge0d7c768b6a6963c4d4bde5bbc74f0ad).
3357 ///
3358 /// # Parameters
3359 ///
3360 /// - `mipmappedArray`: Pointer to mipmapped array to free.
3361 pub fn cudaFreeMipmappedArray(mipmappedArray: cudaMipmappedArray_t) -> cudaError_t;
3362}
3363unsafe extern "C" {
3364 /// Allocates page-locked memory on the host.
3365 ///
3366 /// Allocates size bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated
3367 /// 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
3368 /// memory obtained with functions such as malloc(). Allocating excessive amounts of pinned memory may degrade system performance,
3369 /// since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly
3370 /// to allocate staging areas for data exchange between host and device.
3371 ///
3372 /// The flags parameter enables different options to be specified that affect the allocation, as follows.
3373 ///
3374 /// * [`cudaHostAllocDefault`]: This flag's value is defined to be 0 and causes [`cudaHostAlloc`] to emulate cudaMallocHost().
3375 /// * [`cudaHostAllocPortable`]: The memory returned by this call will be considered as pinned memory by all CUDA contexts, not just the one that performed
3376 /// the allocation.
3377 /// * [`cudaHostAllocMapped`]: Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling [`cudaHostGetDevicePointer`].
3378 /// * [`cudaHostAllocWriteCombined`]: Allocates the memory as write-combined (WC). WC memory can be transferred across the PCI Express bus more quickly on some
3379 /// system configurations, but cannot be read efficiently by most CPUs. WC memory is a good option for buffers that will be written
3380 /// by the CPU and read by the device via mapped pinned memory or host->device transfers.
3381 ///
3382 /// All of these flags are orthogonal to one another: a developer may allocate memory that is portable, mapped and/or write-combined
3383 /// with no restrictions.
3384 ///
3385 /// In order for the [`cudaHostAllocMapped`] flag to have any effect, the CUDA context must support the `cudaDeviceMapHost` flag, which can be checked via [`cudaGetDeviceFlags`]. The `cudaDeviceMapHost` flag is implicitly set for contexts created via the runtime API.
3386 ///
3387 /// The [`cudaHostAllocMapped`] flag may be specified on CUDA contexts for devices that do not support mapped pinned memory. The failure is deferred to [`cudaHostGetDevicePointer`] because the memory may be mapped into other CUDA contexts via the [`cudaHostAllocPortable`] flag.
3388 ///
3389 /// Memory allocated by this function must be freed with [`cudaFreeHost`].
3390 ///
3391 /// Note:
3392 ///
3393 /// * Note that this function may also return error codes from previous, asynchronous launches.
3394 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3395 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3396 ///
3397 /// **See also:**
3398 ///
3399 /// [`cudaSetDeviceFlags`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaGetDeviceFlags`], [cuMemHostAlloc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g572ca4011bfcb25034888a14d4e035b9).
3400 ///
3401 /// # Parameters
3402 ///
3403 /// - `pHost`: Device pointer to allocated memory.
3404 /// - `size`: Requested allocation size in bytes.
3405 /// - `flags`: Requested properties of allocated memory.
3406 pub fn cudaHostAlloc(
3407 pHost: *mut *mut ::core::ffi::c_void,
3408 size: size_t,
3409 flags: ::core::ffi::c_uint,
3410 ) -> cudaError_t;
3411}
3412unsafe extern "C" {
3413 /// Registers an existing host memory range for use by CUDA.
3414 ///
3415 /// 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
3416 /// memory that has not been registered. Page-locking excessive amounts of memory may degrade system performance, since it reduces
3417 /// the amount of memory available to the system for paging. As a result, this function is best used sparingly to register staging
3418 /// areas for data exchange between host and device.
3419 ///
3420 /// On systems where pageableMemoryAccessUsesHostPageTables is true, [`cudaHostRegister`] will not page-lock the memory range specified by ptr but only populate unpopulated pages.
3421 ///
3422 /// [`cudaHostRegister`] is supported only on I/O coherent devices that have a non-zero value for the device attribute [cudaDevAttrHostRegisterSupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd6ea4a004a336c3c95b6ff06ec6269e29).
3423 ///
3424 /// The flags parameter enables different options to be specified that affect the allocation, as follows.
3425 ///
3426 /// * [`cudaHostRegisterDefault`]: On a system with unified virtual addressing, the memory will be both mapped and portable. On a system with no unified virtual
3427 /// addressing, the memory will be neither mapped nor portable.
3428 ///
3429 /// * [`cudaHostRegisterPortable`]: The memory returned by this call will be considered as pinned memory by all CUDA contexts, not just the one that performed
3430 /// the allocation.
3431 ///
3432 /// * [`cudaHostRegisterMapped`]: Maps the allocation into the CUDA address space. The device pointer to the memory may be obtained by calling [`cudaHostGetDevicePointer`].
3433 ///
3434 /// * [`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,
3435 /// and it will marked as non cache-coherent and contiguous.
3436 ///
3437 /// * [`cudaHostRegisterReadOnly`]: The passed memory pointer is treated as pointing to memory that is considered read-only by the device. On platforms without
3438 /// [cudaDevAttrPageableMemoryAccessUsesHostPageTables](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
3439 /// queried from the device attribute [cudaDevAttrHostRegisterReadOnlySupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
3440 ///
3441 /// All of these flags are orthogonal to one another: a developer may page-lock memory that is portable or mapped with no restrictions.
3442 ///
3443 /// The CUDA context must have been created with the cudaMapHost flag in order for the [`cudaHostRegisterMapped`] flag to have any effect.
3444 ///
3445 /// The [`cudaHostRegisterMapped`] flag may be specified on CUDA contexts for devices that do not support mapped pinned memory. The failure is deferred to [`cudaHostGetDevicePointer`] because the memory may be mapped into other CUDA contexts via the [`cudaHostRegisterPortable`] flag.
3446 ///
3447 /// For devices that have a non-zero value for the device attribute [cudaDevAttrCanUseHostPointerForRegisteredMem](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
3448 /// 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
3449 /// to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that
3450 /// such devices should access the memory using only of the two pointers and not both.
3451 ///
3452 /// The memory page-locked by this function must be unregistered with [`cudaHostUnregister`].
3453 ///
3454 /// Note:
3455 ///
3456 /// * Note that this function may also return error codes from previous, asynchronous launches.
3457 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3458 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3459 ///
3460 /// **See also:**
3461 ///
3462 /// [`cudaHostUnregister`], [`cudaHostGetFlags`], [`cudaHostGetDevicePointer`], [cuMemHostRegister](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf0a9fe11544326dabd743b7aa6b54223).
3463 ///
3464 /// # Parameters
3465 ///
3466 /// - `ptr`: Host pointer to memory to page-lock.
3467 /// - `size`: Size in bytes of the address range to page-lock in bytes.
3468 /// - `flags`: Flags for allocation request.
3469 pub fn cudaHostRegister(
3470 ptr: *mut ::core::ffi::c_void,
3471 size: size_t,
3472 flags: ::core::ffi::c_uint,
3473 ) -> cudaError_t;
3474}
3475unsafe extern "C" {
3476 /// Unregisters a memory range that was registered with cudaHostRegister.
3477 ///
3478 /// Unmaps the memory range whose base address is specified by ptr, and makes it pageable again.
3479 ///
3480 /// The base address must be the same one specified to [`cudaHostRegister`].
3481 ///
3482 /// Note:
3483 ///
3484 /// * Note that this function may also return error codes from previous, asynchronous launches.
3485 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3486 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3487 ///
3488 /// **See also:**
3489 ///
3490 /// [`cudaHostUnregister`], [cuMemHostUnregister](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g63f450c8125359be87b7623b1c0b2a14).
3491 ///
3492 /// # Parameters
3493 ///
3494 /// - `ptr`: Host pointer to memory to unregister.
3495 pub fn cudaHostUnregister(ptr: *mut ::core::ffi::c_void) -> cudaError_t;
3496}
3497unsafe extern "C" {
3498 /// Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister.
3499 ///
3500 /// Passes back the device pointer corresponding to the mapped, pinned host buffer allocated by [`cudaHostAlloc`] or registered by [`cudaHostRegister`].
3501 ///
3502 /// [`cudaHostGetDevicePointer`] will fail if the `cudaDeviceMapHost` flag was not specified before deferred context creation occurred, or if called on a device that does not support mapped,
3503 /// pinned memory.
3504 ///
3505 /// For devices that have a non-zero value for the device attribute [cudaDevAttrCanUseHostPointerForRegisteredMem](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
3506 /// 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
3507 /// to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that
3508 /// such devices should access the memory using only of the two pointers and not both.
3509 ///
3510 /// flags provides for future releases. For now, it must be set to 0.
3511 ///
3512 /// Note:
3513 ///
3514 /// * Note that this function may also return error codes from previous, asynchronous launches.
3515 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3516 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3517 ///
3518 /// **See also:**
3519 ///
3520 /// [`cudaSetDeviceFlags`], [`cudaHostAlloc`], [cuMemHostGetDevicePointer](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g57a39e5cba26af4d06be67fc77cc62f0).
3521 ///
3522 /// # Parameters
3523 ///
3524 /// - `pDevice`: Returned device pointer for mapped memory.
3525 /// - `pHost`: Requested host pointer mapping.
3526 /// - `flags`: Flags for extensions (must be 0 for now).
3527 pub fn cudaHostGetDevicePointer(
3528 pDevice: *mut *mut ::core::ffi::c_void,
3529 pHost: *mut ::core::ffi::c_void,
3530 flags: ::core::ffi::c_uint,
3531 ) -> cudaError_t;
3532}
3533unsafe extern "C" {
3534 /// Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc.
3535 ///
3536 /// [`cudaHostGetFlags`] will fail if the input pointer does not reside in an address range allocated by [`cudaHostAlloc`].
3537 ///
3538 /// Note:
3539 ///
3540 /// * Note that this function may also return error codes from previous, asynchronous launches.
3541 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3542 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3543 ///
3544 /// **See also:**
3545 ///
3546 /// [`cudaHostAlloc`], [cuMemHostGetFlags](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g42066246915fcb0400df2a17a851b35f).
3547 ///
3548 /// # Parameters
3549 ///
3550 /// - `pFlags`: Returned flags word.
3551 /// - `pHost`: Host pointer.
3552 pub fn cudaHostGetFlags(
3553 pFlags: *mut ::core::ffi::c_uint,
3554 pHost: *mut ::core::ffi::c_void,
3555 ) -> cudaError_t;
3556}
3557unsafe extern "C" {
3558 /// Allocates logical 1D, 2D, or 3D memory objects on the device.
3559 ///
3560 /// Allocates at least width \* height \* depth bytes of linear memory on the device and returns a [`cudaPitchedPtr`] in which ptr is a pointer to the allocated memory. The function may pad the allocation to ensure hardware alignment requirements are met.
3561 /// The pitch returned in the pitch field of pitchedDevPtr is the width in bytes of the allocation.
3562 ///
3563 /// The returned [`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.
3564 ///
3565 /// 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
3566 /// involving 2D or 3D objects (whether linear memory or CUDA arrays).
3567 ///
3568 /// Note:
3569 ///
3570 /// * Note that this function may also return error codes from previous, asynchronous launches.
3571 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3572 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3573 ///
3574 /// **See also:**
3575 ///
3576 /// [`cudaMallocPitch`], [`cudaFree`], [`cudaMemcpy3D`], [`cudaMemset3D`], [`cudaMalloc3DArray`], [`cudaMallocArray`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], `make_cudaPitchedPtr`, `make_cudaExtent`, [cuMemAllocPitch](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gcbe9b033f6c4de80f63cc6e58ed9a45a).
3577 ///
3578 /// # Parameters
3579 ///
3580 /// - `pitchedDevPtr`: Pointer to allocated pitched device memory.
3581 /// - `extent`: Requested allocation size (width field in bytes).
3582 pub fn cudaMalloc3D(
3583 pitchedDevPtr: *mut cudaPitchedPtr,
3584 extent: cudaExtent,
3585 ) -> cudaError_t;
3586}
3587unsafe extern "C" {
3588 /// Allocate an array on the device.
3589 ///
3590 /// Allocates a CUDA array according to the [`cudaChannelFormatDesc`] structure desc and returns a handle to the new CUDA array in \*array.
3591 ///
3592 /// The [`cudaChannelFormatDesc`] is defined as:
3593 ///
3594 /// ```text
3595 /// struct cudaChannelFormatDesc {
3596 /// int x, y, z, w;
3597 /// enum cudaChannelFormatKind
3598 /// f;
3599 /// };
3600 /// ```
3601 ///
3602 /// [`cudaChannelFormatKind`]
3603 ///
3604 /// [`cudaChannelFormatKind::cudaChannelFormatKindSigned`]
3605 ///
3606 /// [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`]
3607 ///
3608 /// [`cudaChannelFormatKind::cudaChannelFormatKindFloat`]
3609 ///
3610 /// [`cudaMalloc3DArray`] can allocate the following:
3611 ///
3612 /// * A 1D array is allocated if the height and depth extents are both zero.
3613 /// * A 2D array is allocated if only the depth extent is zero.
3614 /// * A 3D array is allocated if all three extents are non-zero.
3615 /// * A 1D layered CUDA array is allocated if only the height extent is zero and the cudaArrayLayered flag is set. Each layer is
3616 /// a 1D array. The number of layers is determined by the depth extent.
3617 /// * A 2D layered CUDA array is allocated if all three extents are non-zero and the cudaArrayLayered flag is set. Each layer is
3618 /// a 2D array. The number of layers is determined by the depth extent.
3619 /// * A cubemap CUDA array is allocated if all three extents are non-zero and the cudaArrayCubemap flag is set. Width must be equal
3620 /// to height, and depth must be six. A cubemap is a special type of 2D layered CUDA array, where the six layers represent the
3621 /// six faces of a cube. The order of the six layers in memory is the same as that listed in `cudaGraphicsCubeFace`.
3622 /// * A cubemap layered CUDA array is allocated if all three extents are non-zero, and both, cudaArrayCubemap and cudaArrayLayered
3623 /// 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
3624 /// type of 2D layered CUDA array that consists of a collection of cubemaps. The first six layers represent the first cubemap,
3625 /// the next six layers form the second cubemap, and so on.
3626 ///
3627 /// The flags parameter enables different options to be specified that affect the allocation, as follows.
3628 ///
3629 /// * `cudaArrayDefault`: This flag's value is defined to be 0 and provides default array allocation
3630 /// * `cudaArrayLayered`: Allocates a layered CUDA array, with the depth extent indicating the number of layers
3631 /// * `cudaArrayCubemap`: Allocates a cubemap CUDA array. Width must be equal to height, and depth must be six. If the cudaArrayLayered flag is also
3632 /// set, depth must be a multiple of six.
3633 /// * `cudaArraySurfaceLoadStore`: Allocates a CUDA array that could be read from or written to using a surface reference.
3634 /// * `cudaArrayTextureGather`: This flag indicates that texture gather operations will be performed on the CUDA array. Texture gather can only be performed
3635 /// on 2D CUDA arrays.
3636 /// * `cudaArraySparse`: Allocates a CUDA array without physical backing memory. The subregions within this sparse array can later be mapped onto
3637 /// a physical memory allocation by calling [cuMemMapArrayAsync](https://docs.nvidia.com/cuda/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
3638 /// via [cuMemCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
3639 /// * `cudaArrayDeferredMapping`: Allocates a CUDA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation
3640 /// by calling [cuMemMapArrayAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). The physical backing memory must be allocated via [cuMemCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
3641 ///
3642 /// The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified
3643 /// in elements.
3644 ///
3645 /// Note that 2D CUDA arrays have different size requirements if the `cudaArrayTextureGather` flag is set. In that case, the valid range for (width, height, depth) is ((1,maxTexture2DGather\[0\]), (1,maxTexture2DGather\[1\]),
3646 /// 0).
3647 ///
3648 /// | 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)} |
3649 /// | --- | --- | --- |
3650 /// | 1D | { (1,maxTexture1D), 0, 0 } | { (1,maxSurface1D), 0, 0 } |
3651 /// | 2D | { (1,maxTexture2D\[0\]), (1,maxTexture2D\[1\]), 0 } | { (1,maxSurface2D\[0\]), (1,maxSurface2D\[1\]), 0 } |
3652 /// | 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\]) } |
3653 /// | 1D Layered | { (1,maxTexture1DLayered\[0\]), 0, (1,maxTexture1DLayered\[1\]) } | { (1,maxSurface1DLayered\[0\]), 0, (1,maxSurface1DLayered\[1\]) } |
3654 /// | 2D Layered | { (1,maxTexture2DLayered\[0\]), (1,maxTexture2DLayered\[1\]), (1,maxTexture2DLayered\[2\]) } | { (1,maxSurface2DLayered\[0\]), (1,maxSurface2DLayered\[1\]), (1,maxSurface2DLayered\[2\]) } |
3655 /// | Cubemap | { (1,maxTextureCubemap), (1,maxTextureCubemap), 6 } | { (1,maxSurfaceCubemap), (1,maxSurfaceCubemap), 6 } |
3656 /// | Cubemap Layered | { (1,maxTextureCubemapLayered\[0\]), (1,maxTextureCubemapLayered\[0\]), (1,maxTextureCubemapLayered\[1\]) } | { (1,maxSurfaceCubemapLayered\[0\]), (1,maxSurfaceCubemapLayered\[0\]), (1,maxSurfaceCubemapLayered\[1\]) } |
3657 ///
3658 /// Note:
3659 ///
3660 /// * Note that this function may also return error codes from previous, asynchronous launches.
3661 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3662 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3663 ///
3664 /// **See also:**
3665 ///
3666 /// [`cudaMalloc3D`], [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], `make_cudaExtent`, [cuArray3DCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gc2322c70b38c2984536c90ed118bb1d7).
3667 ///
3668 /// # Parameters
3669 ///
3670 /// - `array`: Pointer to allocated array in device memory.
3671 /// - `desc`: Requested channel format.
3672 /// - `extent`: Requested allocation size (width field in elements).
3673 /// - `flags`: Flags for extensions.
3674 pub fn cudaMalloc3DArray(
3675 array: *mut cudaArray_t,
3676 desc: *const cudaChannelFormatDesc,
3677 extent: cudaExtent,
3678 flags: ::core::ffi::c_uint,
3679 ) -> cudaError_t;
3680}
3681unsafe extern "C" {
3682 /// Allocate a mipmapped array on the device.
3683 ///
3684 /// Allocates a CUDA mipmapped array according to the [`cudaChannelFormatDesc`] structure desc and returns a handle to the new CUDA mipmapped array in \*mipmappedArray. numLevels specifies the number of mipmap levels to be allocated. This value is clamped to the range \[1, 1 + floor(log2(max(width, height,
3685 /// depth)))\].
3686 ///
3687 /// The [`cudaChannelFormatDesc`] is defined as:
3688 ///
3689 /// ```text
3690 /// struct cudaChannelFormatDesc {
3691 /// int x, y, z, w;
3692 /// enum cudaChannelFormatKind
3693 /// f;
3694 /// };
3695 /// ```
3696 ///
3697 /// [`cudaChannelFormatKind`]
3698 ///
3699 /// [`cudaChannelFormatKind::cudaChannelFormatKindSigned`]
3700 ///
3701 /// [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`]
3702 ///
3703 /// [`cudaChannelFormatKind::cudaChannelFormatKindFloat`]
3704 ///
3705 /// [`cudaMallocMipmappedArray`] can allocate the following:
3706 ///
3707 /// * A 1D mipmapped array is allocated if the height and depth extents are both zero.
3708 /// * A 2D mipmapped array is allocated if only the depth extent is zero.
3709 /// * A 3D mipmapped array is allocated if all three extents are non-zero.
3710 /// * A 1D layered CUDA mipmapped array is allocated if only the height extent is zero and the cudaArrayLayered flag is set. Each
3711 /// layer is a 1D mipmapped array. The number of layers is determined by the depth extent.
3712 /// * A 2D layered CUDA mipmapped array is allocated if all three extents are non-zero and the cudaArrayLayered flag is set. Each
3713 /// layer is a 2D mipmapped array. The number of layers is determined by the depth extent.
3714 /// * A cubemap CUDA mipmapped array is allocated if all three extents are non-zero and the cudaArrayCubemap flag is set. Width
3715 /// 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`.
3716 /// * A cubemap layered CUDA mipmapped array is allocated if all three extents are non-zero, and both, cudaArrayCubemap and cudaArrayLayered
3717 /// flags are set. Width must be equal to height, and depth must be a multiple of six. A cubemap layered CUDA mipmapped array
3718 /// is a special type of 2D layered CUDA mipmapped array that consists of a collection of cubemap mipmapped arrays. The first
3719 /// six layers represent the first cubemap mipmapped array, the next six layers form the second cubemap mipmapped array, and so
3720 /// on.
3721 ///
3722 /// The flags parameter enables different options to be specified that affect the allocation, as follows.
3723 ///
3724 /// * `cudaArrayDefault`: This flag's value is defined to be 0 and provides default mipmapped array allocation
3725 /// * `cudaArrayLayered`: Allocates a layered CUDA mipmapped array, with the depth extent indicating the number of layers
3726 /// * `cudaArrayCubemap`: Allocates a cubemap CUDA mipmapped array. Width must be equal to height, and depth must be six. If the cudaArrayLayered
3727 /// flag is also set, depth must be a multiple of six.
3728 /// * `cudaArraySurfaceLoadStore`: This flag indicates that individual mipmap levels of the CUDA mipmapped array will be read from or written to using a surface
3729 /// reference.
3730 /// * `cudaArrayTextureGather`: This flag indicates that texture gather operations will be performed on the CUDA array. Texture gather can only be performed
3731 /// on 2D CUDA mipmapped arrays, and the gather operations are performed only on the most detailed mipmap level.
3732 /// * `cudaArraySparse`: Allocates a CUDA mipmapped array without physical backing memory. The subregions within this sparse array can later be mapped
3733 /// onto a physical memory allocation by calling [cuMemMapArrayAsync](https://docs.nvidia.com/cuda/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
3734 /// be allocated via [cuMemCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
3735 /// * `cudaArrayDeferredMapping`: Allocates a CUDA mipmapped array without physical backing memory. The entire array can later be mapped onto a physical memory
3736 /// allocation by calling [cuMemMapArrayAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab). The physical backing memory must be allocated via [cuMemCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g899d69a862bba36449789c64b430dc7c).
3737 ///
3738 /// The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified
3739 /// in elements.
3740 ///
3741 /// | 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)} |
3742 /// | --- | --- | --- |
3743 /// | 1D | { (1,maxTexture1DMipmap), 0, 0 } | { (1,maxSurface1D), 0, 0 } |
3744 /// | 2D | { (1,maxTexture2DMipmap\[0\]), (1,maxTexture2DMipmap\[1\]), 0 } | { (1,maxSurface2D\[0\]), (1,maxSurface2D\[1\]), 0 } |
3745 /// | 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\]) } |
3746 /// | 1D Layered | { (1,maxTexture1DLayered\[0\]), 0, (1,maxTexture1DLayered\[1\]) } | { (1,maxSurface1DLayered\[0\]), 0, (1,maxSurface1DLayered\[1\]) } |
3747 /// | 2D Layered | { (1,maxTexture2DLayered\[0\]), (1,maxTexture2DLayered\[1\]), (1,maxTexture2DLayered\[2\]) } | { (1,maxSurface2DLayered\[0\]), (1,maxSurface2DLayered\[1\]), (1,maxSurface2DLayered\[2\]) } |
3748 /// | Cubemap | { (1,maxTextureCubemap), (1,maxTextureCubemap), 6 } | { (1,maxSurfaceCubemap), (1,maxSurfaceCubemap), 6 } |
3749 /// | Cubemap Layered | { (1,maxTextureCubemapLayered\[0\]), (1,maxTextureCubemapLayered\[0\]), (1,maxTextureCubemapLayered\[1\]) } | { (1,maxSurfaceCubemapLayered\[0\]), (1,maxSurfaceCubemapLayered\[0\]), (1,maxSurfaceCubemapLayered\[1\]) } |
3750 ///
3751 /// Note:
3752 ///
3753 /// * Note that this function may also return error codes from previous, asynchronous launches.
3754 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3755 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3756 ///
3757 /// **See also:**
3758 ///
3759 /// [`cudaMalloc3D`], [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], `make_cudaExtent`, [cuMipmappedArrayCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ga5d2e311c7f9b0bc6d130af824a40bd3).
3760 ///
3761 /// # Parameters
3762 ///
3763 /// - `mipmappedArray`: Pointer to allocated mipmapped array in device memory.
3764 /// - `desc`: Requested channel format.
3765 /// - `extent`: Requested allocation size (width field in elements).
3766 /// - `numLevels`: Number of mipmap levels to allocate.
3767 /// - `flags`: Flags for extensions.
3768 pub fn cudaMallocMipmappedArray(
3769 mipmappedArray: *mut cudaMipmappedArray_t,
3770 desc: *const cudaChannelFormatDesc,
3771 extent: cudaExtent,
3772 numLevels: ::core::ffi::c_uint,
3773 flags: ::core::ffi::c_uint,
3774 ) -> cudaError_t;
3775}
3776unsafe extern "C" {
3777 /// Gets a mipmap level of a CUDA mipmapped array.
3778 ///
3779 /// Returns in \*levelArray a CUDA array that represents a single mipmap level of the CUDA mipmapped array mipmappedArray.
3780 ///
3781 /// If level is greater than the maximum number of levels in this mipmapped array, [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
3782 ///
3783 /// If mipmappedArray is NULL, [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) is returned.
3784 ///
3785 /// Note:
3786 ///
3787 /// * Note that this function may also return error codes from previous, asynchronous launches.
3788 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3789 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3790 ///
3791 /// **See also:**
3792 ///
3793 /// [`cudaMalloc3D`], [`cudaMalloc`], [`cudaMallocPitch`], [`cudaFree`], [`cudaFreeArray`], cudaMallocHost ( C API), [`cudaFreeHost`], [`cudaHostAlloc`], `make_cudaExtent`, [cuMipmappedArrayGetLevel](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g82f276659f05be14820e99346b0f86b7).
3794 ///
3795 /// # Parameters
3796 ///
3797 /// - `levelArray`: Returned mipmap level CUDA array.
3798 /// - `mipmappedArray`: CUDA mipmapped array.
3799 /// - `level`: Mipmap level.
3800 pub fn cudaGetMipmappedArrayLevel(
3801 levelArray: *mut cudaArray_t,
3802 mipmappedArray: cudaMipmappedArray_const_t,
3803 level: ::core::ffi::c_uint,
3804 ) -> cudaError_t;
3805}
3806unsafe extern "C" {
3807 /// Copies data between 3D objects.
3808 ///
3809 /// ```text
3810 /// struct cudaExtent {
3811 /// size_t width;
3812 /// size_t height;
3813 /// size_t depth;
3814 /// };
3815 /// struct cudaExtent
3816 /// make_cudaExtent(size_t w, size_t h, size_t d);
3817 ///
3818 /// struct cudaPos {
3819 /// size_t x;
3820 /// size_t y;
3821 /// size_t z;
3822 /// };
3823 /// struct cudaPos
3824 /// make_cudaPos(size_t x, size_t y, size_t z);
3825 ///
3826 /// struct cudaMemcpy3DParms {
3827 /// cudaArray_t
3828 /// srcArray;
3829 /// struct cudaPos
3830 /// srcPos;
3831 /// struct cudaPitchedPtr
3832 /// srcPtr;
3833 /// cudaArray_t
3834 /// dstArray;
3835 /// struct cudaPos
3836 /// dstPos;
3837 /// struct cudaPitchedPtr
3838 /// dstPtr;
3839 /// struct cudaExtent
3840 /// extent;
3841 /// enum cudaMemcpyKind
3842 /// kind;
3843 /// };
3844 /// ```
3845 ///
3846 /// [`cudaMemcpy3D`] copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a CUDA
3847 /// array. The source, destination, extent, and kind of copy performed is specified by the [`cudaMemcpy3DParms`] struct which should be initialized to zero before use:
3848 ///
3849 /// ```text
3850 /// cudaMemcpy3DParms myParms = {0};
3851 /// ```
3852 ///
3853 /// 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.
3854 ///
3855 /// 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
3856 /// element for a host or device pointer is assumed to be **unsigned char**.
3857 ///
3858 /// The extent field defines the dimensions of the transferred area in elements. If a CUDA array is participating in the copy, the extent
3859 /// is defined in terms of that array's elements. If no CUDA array is participating in the copy then the extents are defined in
3860 /// elements of **unsigned char**.
3861 ///
3862 /// The kind field defines the direction of the copy. It must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. For [`cudaMemcpyKind::cudaMemcpyHostToHost`] or [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] passed as kind and cudaArray type passed as source or destination, if the kind implies cudaArray type to be present on the
3863 /// host, [`cudaMemcpy3D`] will disregard that implication and silently correct the kind based on the fact that cudaArray type can only be present on
3864 /// the device.
3865 ///
3866 /// If the source and destination are both arrays, [`cudaMemcpy3D`] will return an error if they do not have the same element size.
3867 ///
3868 /// The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined
3869 /// behavior will result.
3870 ///
3871 /// 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.
3872 ///
3873 /// [`cudaMemcpy3D`] returns an error if the pitch of srcPtr or dstPtr exceeds the maximum allowed. The pitch of a [`cudaPitchedPtr`] allocated with [`cudaMalloc3D`] will always be valid.
3874 ///
3875 /// Note:
3876 ///
3877 /// * Note that this function may also return error codes from previous, asynchronous launches.
3878 /// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
3879 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3880 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3881 ///
3882 /// **See also:**
3883 ///
3884 /// [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaMemset3D`], [`cudaMemcpy3DAsync`], [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], `make_cudaExtent`, `make_cudaPos`, [cuMemcpy3D](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4b5238975579f002c0199a3800ca44df).
3885 ///
3886 /// # Parameters
3887 ///
3888 /// - `p`: 3D memory copy parameters.
3889 pub fn cudaMemcpy3D(p: *const cudaMemcpy3DParms) -> cudaError_t;
3890}
3891unsafe extern "C" {
3892 /// Copies memory between devices.
3893 ///
3894 /// Perform a 3D memory copy according to the parameters specified in p. See the definition of the [`cudaMemcpy3DPeerParms`] structure for documentation of its parameters.
3895 ///
3896 /// Note that this function is synchronous with respect to the host only if the source or destination of the transfer is host
3897 /// memory. Note also that this copy is serialized with respect to all pending and future asynchronous work in to the current
3898 /// device, the copy's source device, and the copy's destination device (use [`cudaMemcpy3DPeerAsync`] to avoid this synchronization).
3899 ///
3900 /// Note:
3901 ///
3902 /// * Note that this function may also return error codes from previous, asynchronous launches.
3903 /// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
3904 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3905 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3906 ///
3907 /// **See also:**
3908 ///
3909 /// [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpyPeerAsync`], [`cudaMemcpy3DPeerAsync`], [cuMemcpy3DPeer](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g11466fd70cde9329a4e16eb1f258c433).
3910 ///
3911 /// # Parameters
3912 ///
3913 /// - `p`: Parameters for the memory copy.
3914 pub fn cudaMemcpy3DPeer(p: *const cudaMemcpy3DPeerParms) -> cudaError_t;
3915}
3916unsafe extern "C" {
3917 /// Copies data between 3D objects.
3918 ///
3919 /// ```text
3920 /// struct cudaExtent {
3921 /// size_t width;
3922 /// size_t height;
3923 /// size_t depth;
3924 /// };
3925 /// struct cudaExtent
3926 /// make_cudaExtent(size_t w, size_t h, size_t d);
3927 ///
3928 /// struct cudaPos {
3929 /// size_t x;
3930 /// size_t y;
3931 /// size_t z;
3932 /// };
3933 /// struct cudaPos
3934 /// make_cudaPos(size_t x, size_t y, size_t z);
3935 ///
3936 /// struct cudaMemcpy3DParms {
3937 /// cudaArray_t
3938 /// srcArray;
3939 /// struct cudaPos
3940 /// srcPos;
3941 /// struct cudaPitchedPtr
3942 /// srcPtr;
3943 /// cudaArray_t
3944 /// dstArray;
3945 /// struct cudaPos
3946 /// dstPos;
3947 /// struct cudaPitchedPtr
3948 /// dstPtr;
3949 /// struct cudaExtent
3950 /// extent;
3951 /// enum cudaMemcpyKind
3952 /// kind;
3953 /// };
3954 /// ```
3955 ///
3956 /// [`cudaMemcpy3DAsync`] copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a CUDA
3957 /// array. The source, destination, extent, and kind of copy performed is specified by the [`cudaMemcpy3DParms`] struct which should be initialized to zero before use:
3958 ///
3959 /// ```text
3960 /// cudaMemcpy3DParms myParms = {0};
3961 /// ```
3962 ///
3963 /// 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.
3964 ///
3965 /// 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
3966 /// 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.
3967 ///
3968 /// The extent field defines the dimensions of the transferred area in elements. If a CUDA array is participating in the copy, the extent
3969 /// is defined in terms of that array's elements. If no CUDA array is participating in the copy then the extents are defined in
3970 /// elements of **unsigned char**.
3971 ///
3972 /// The kind field defines the direction of the copy. It must be one of [cudaMemcpyHostToHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg18fa99055ee694244a270e4d5101e95bdeec295de8a74ac2a74f98ffb6c5d7c7), [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. For [`cudaMemcpyKind::cudaMemcpyHostToHost`] or [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] passed as kind and cudaArray type passed as source or destination, if the kind implies cudaArray type to be present on the
3973 /// host, [`cudaMemcpy3DAsync`] will disregard that implication and silently correct the kind based on the fact that cudaArray type can only be present on
3974 /// the device.
3975 ///
3976 /// If the source and destination are both arrays, [`cudaMemcpy3DAsync`] will return an error if they do not have the same element size.
3977 ///
3978 /// The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined
3979 /// behavior will result.
3980 ///
3981 /// 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.
3982 ///
3983 /// [`cudaMemcpy3DAsync`] returns an error if the pitch of srcPtr or dstPtr exceeds the maximum allowed. The pitch of a [`cudaPitchedPtr`] allocated with [`cudaMalloc3D`] will always be valid.
3984 ///
3985 /// [`cudaMemcpy3DAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be
3986 /// associated to a stream by passing a non-zero stream argument. If kind is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and stream is non-zero, the copy may overlap with operations in other streams.
3987 ///
3988 /// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
3989 ///
3990 /// Note:
3991 ///
3992 /// * Note that this function may also return error codes from previous, asynchronous launches.
3993 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
3994 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
3995 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
3996 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
3997 ///
3998 /// **See also:**
3999 ///
4000 /// [`cudaMalloc3D`], [`cudaMalloc3DArray`], [`cudaMemset3D`], [`cudaMemcpy3D`], [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], :[`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], `make_cudaExtent`, `make_cudaPos`, [cuMemcpy3DAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g79f4f3fde6ae0f529568d881d9e11987).
4001 ///
4002 /// # Parameters
4003 ///
4004 /// - `p`: 3D memory copy parameters.
4005 /// - `stream`: Stream identifier.
4006 pub fn cudaMemcpy3DAsync(
4007 p: *const cudaMemcpy3DParms,
4008 stream: cudaStream_t,
4009 ) -> cudaError_t;
4010}
4011unsafe extern "C" {
4012 /// Copies memory between devices asynchronously.
4013 ///
4014 /// Perform a 3D memory copy according to the parameters specified in p. See the definition of the [`cudaMemcpy3DPeerParms`] structure for documentation of its parameters.
4015 ///
4016 /// Note:
4017 ///
4018 /// * Note that this function may also return error codes from previous, asynchronous launches.
4019 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
4020 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
4021 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4022 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4023 ///
4024 /// **See also:**
4025 ///
4026 /// [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpyPeerAsync`], [`cudaMemcpy3DPeerAsync`], [cuMemcpy3DPeerAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gc4e4bfd9f627d3aa3695979e058f1bb8).
4027 ///
4028 /// # Parameters
4029 ///
4030 /// - `p`: Parameters for the memory copy.
4031 /// - `stream`: Stream identifier.
4032 pub fn cudaMemcpy3DPeerAsync(
4033 p: *const cudaMemcpy3DPeerParms,
4034 stream: cudaStream_t,
4035 ) -> cudaError_t;
4036}
4037unsafe extern "C" {
4038 /// Gets free and total device memory.
4039 ///
4040 /// Returns in \*total the total amount of memory available to the current context. Returns in \*free the amount of memory on the device that is free according to the OS. CUDA is not guaranteed to be able to allocate all of
4041 /// the memory that the OS reports as free. In a multi-tenet situation, free estimate returned is prone to race condition where
4042 /// a new allocation/free done by a different process or a different thread in the same process between the time when free memory
4043 /// was estimated and reported, will result in deviation in free value reported and actual free memory.
4044 ///
4045 /// The integrated GPU on Tegra shares memory with CPU and other component of the SoC. The free and total values returned by the
4046 /// API excludes the SWAP memory space maintained by the OS on some platforms. The OS may move some of the memory pages into swap
4047 /// area as the GPU or CPU allocate or access memory. See Tegra app note on how to calculate total and free memory on Tegra.
4048 ///
4049 /// Note:
4050 ///
4051 /// * Note that this function may also return error codes from previous, asynchronous launches.
4052 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4053 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4054 ///
4055 /// **See also:**
4056 ///
4057 /// [cuMemGetInfo](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g808f555540d0143a331cc42aa98835c0).
4058 ///
4059 /// # Parameters
4060 ///
4061 /// - `free`: Returned free memory in bytes.
4062 /// - `total`: Returned total memory in bytes.
4063 pub fn cudaMemGetInfo(free: *mut size_t, total: *mut size_t) -> cudaError_t;
4064}
4065unsafe extern "C" {
4066 /// Gets info about the specified cudaArray.
4067 ///
4068 /// Returns in \*desc, \*extent and \*flags respectively, the type, shape and flags of array.
4069 ///
4070 /// Any of \*desc, \*extent and \*flags may be specified as NULL.
4071 ///
4072 /// Note:
4073 ///
4074 /// * Note that this function may also return error codes from previous, asynchronous launches.
4075 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4076 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4077 ///
4078 /// **See also:**
4079 ///
4080 /// [cuArrayGetDescriptor](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g661fe823dbd37bf11f82a71bd4762acf), [cuArray3DGetDescriptor](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gb58549f2f3f390b9e0e7c8f3acd53857).
4081 ///
4082 /// # Parameters
4083 ///
4084 /// - `desc`: Returned array type.
4085 /// - `extent`: Returned array shape. 2D arrays will have depth of zero.
4086 /// - `flags`: Returned array flags.
4087 /// - `array`: The cudaArray to get info for.
4088 pub fn cudaArrayGetInfo(
4089 desc: *mut cudaChannelFormatDesc,
4090 extent: *mut cudaExtent,
4091 flags: *mut ::core::ffi::c_uint,
4092 array: cudaArray_t,
4093 ) -> cudaError_t;
4094}
4095unsafe extern "C" {
4096 /// Gets a CUDA array plane from a CUDA array.
4097 ///
4098 /// Returns in pPlaneArray a CUDA array that represents a single format plane of the CUDA array hArray.
4099 ///
4100 /// If planeIdx is greater than the maximum number of planes in this array or if the array does not have a multi-planar format e.g: [`cudaChannelFormatKind::cudaChannelFormatKindNV12`], then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
4101 ///
4102 /// Note that if the hArray has format [`cudaChannelFormatKind::cudaChannelFormatKindNV12`], then passing in 0 for planeIdx returns a CUDA array of the same size as hArray but with one 8-bit channel and [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`] as its format kind. If 1 is passed for planeIdx, then the returned CUDA array has half the height and width of hArray with two 8-bit channels and [`cudaChannelFormatKind::cudaChannelFormatKindUnsigned`] as its format kind.
4103 ///
4104 /// Note:
4105 ///
4106 /// Note that this function may also return error codes from previous, asynchronous launches.
4107 ///
4108 /// **See also:**
4109 ///
4110 /// [cuArrayGetPlane](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ge66ce245a1e3802f9ccc3583cec6b71f).
4111 ///
4112 /// # Parameters
4113 ///
4114 /// - `pPlaneArray`: Returned CUDA array referenced by the planeIdx.
4115 /// - `hArray`: CUDA array.
4116 /// - `planeIdx`: Plane index.
4117 pub fn cudaArrayGetPlane(
4118 pPlaneArray: *mut cudaArray_t,
4119 hArray: cudaArray_t,
4120 planeIdx: ::core::ffi::c_uint,
4121 ) -> cudaError_t;
4122}
4123unsafe extern "C" {
4124 /// Returns the memory requirements of a CUDA array.
4125 ///
4126 /// Returns the memory requirements of a CUDA array in memoryRequirements If the CUDA array is not allocated with flag `cudaArrayDeferredMapping`[cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
4127 ///
4128 /// The returned value in [cudaArrayMemoryRequirements::size](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArrayMemoryRequirements.html#structcudaArrayMemoryRequirements_1cff0bc12daa05c6c40892a2187befd87) represents the total size of the CUDA array. The returned value in [cudaArrayMemoryRequirements::alignment](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArrayMemoryRequirements.html#structcudaArrayMemoryRequirements_137898b13b500d39e4a43d0ee04cf0ef3) represents the alignment necessary for mapping the CUDA array.
4129 ///
4130 /// **See also:**
4131 ///
4132 /// [`cudaMipmappedArrayGetMemoryRequirements`].
4133 ///
4134 /// # Parameters
4135 ///
4136 /// - `memoryRequirements`: Pointer to `cudaArrayMemoryRequirements`.
4137 /// - `array`: CUDA array to get the memory requirements of.
4138 /// - `device`: Device to get the memory requirements for.
4139 pub fn cudaArrayGetMemoryRequirements(
4140 memoryRequirements: *mut cudaArrayMemoryRequirements,
4141 array: cudaArray_t,
4142 device: ::core::ffi::c_int,
4143 ) -> cudaError_t;
4144}
4145unsafe extern "C" {
4146 /// Returns the memory requirements of a CUDA mipmapped array.
4147 ///
4148 /// Returns the memory requirements of a CUDA mipmapped array in memoryRequirements If the CUDA mipmapped array is not allocated with flag `cudaArrayDeferredMapping`[cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
4149 ///
4150 /// The returned value in [cudaArrayMemoryRequirements::size](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArrayMemoryRequirements.html#structcudaArrayMemoryRequirements_1cff0bc12daa05c6c40892a2187befd87) represents the total size of the CUDA mipmapped array. The returned value in [cudaArrayMemoryRequirements::alignment](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArrayMemoryRequirements.html#structcudaArrayMemoryRequirements_137898b13b500d39e4a43d0ee04cf0ef3) represents the alignment necessary for mapping the CUDA mipmapped array.
4151 ///
4152 /// **See also:**
4153 ///
4154 /// [`cudaArrayGetMemoryRequirements`].
4155 ///
4156 /// # Parameters
4157 ///
4158 /// - `memoryRequirements`: Pointer to `cudaArrayMemoryRequirements`.
4159 /// - `mipmap`: CUDA mipmapped array to get the memory requirements of.
4160 /// - `device`: Device to get the memory requirements for.
4161 pub fn cudaMipmappedArrayGetMemoryRequirements(
4162 memoryRequirements: *mut cudaArrayMemoryRequirements,
4163 mipmap: cudaMipmappedArray_t,
4164 device: ::core::ffi::c_int,
4165 ) -> cudaError_t;
4166}
4167unsafe extern "C" {
4168 /// Returns the layout properties of a sparse CUDA array.
4169 ///
4170 /// Returns the layout properties of a sparse CUDA array in sparseProperties. If the CUDA array is not allocated with flag `cudaArraySparse`[cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
4171 ///
4172 /// If the returned value in [cudaArraySparseProperties::flags](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArraySparseProperties.html#structcudaArraySparseProperties_144c8728469d60e511aceb4ba7086c164) contains `cudaArraySparsePropertiesSingleMipTail`, then [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArraySparseProperties.html#structcudaArraySparseProperties_122cfa4ad83195f0e9585303c988bb886) represents the total size of the array. Otherwise, it will be zero. Also, the returned value in [cudaArraySparseProperties::miptailFirstLevel](https://docs.nvidia.com/cuda/cuda-runtime-api/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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
4173 ///
4174 /// **See also:**
4175 ///
4176 /// [`cudaMipmappedArrayGetSparseProperties`], [cuMemMapArrayAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab).
4177 ///
4178 /// # Parameters
4179 ///
4180 /// - `sparseProperties`: Pointer to return the `cudaArraySparseProperties`.
4181 /// - `array`: The CUDA array to get the sparse properties of.
4182 pub fn cudaArrayGetSparseProperties(
4183 sparseProperties: *mut cudaArraySparseProperties,
4184 array: cudaArray_t,
4185 ) -> cudaError_t;
4186}
4187unsafe extern "C" {
4188 /// Returns the layout properties of a sparse CUDA mipmapped array.
4189 ///
4190 /// Returns the sparse array layout properties in sparseProperties. If the CUDA mipmapped array is not allocated with flag `cudaArraySparse`[cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) will be returned.
4191 ///
4192 /// For non-layered CUDA mipmapped arrays, [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/cuda-runtime-api/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
4193 /// than that of the tile. For layered CUDA mipmapped arrays, if [cudaArraySparseProperties::flags](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArraySparseProperties.html#structcudaArraySparseProperties_144c8728469d60e511aceb4ba7086c164) contains `cudaArraySparsePropertiesSingleMipTail`, then [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArraySparseProperties.html#structcudaArraySparseProperties_122cfa4ad83195f0e9585303c988bb886) specifies the size of the mip tail of all layers combined. Otherwise, [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArraySparseProperties.html#structcudaArraySparseProperties_122cfa4ad83195f0e9585303c988bb886) specifies mip tail size per layer. The returned value of [cudaArraySparseProperties::miptailFirstLevel](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArraySparseProperties.html#structcudaArraySparseProperties_1b6909e5db55b866477b6cc16fb02f9d3) is valid only if [cudaArraySparseProperties::miptailSize](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaArraySparseProperties.html#structcudaArraySparseProperties_122cfa4ad83195f0e9585303c988bb886) is non-zero.
4194 ///
4195 /// **See also:**
4196 ///
4197 /// [`cudaArrayGetSparseProperties`], [cuMemMapArrayAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA_1g5dc41a62a9feb68f2e943b438c83e5ab).
4198 ///
4199 /// # Parameters
4200 ///
4201 /// - `sparseProperties`: Pointer to return `cudaArraySparseProperties`.
4202 /// - `mipmap`: The CUDA mipmapped array to get the sparse properties of.
4203 pub fn cudaMipmappedArrayGetSparseProperties(
4204 sparseProperties: *mut cudaArraySparseProperties,
4205 mipmap: cudaMipmappedArray_t,
4206 ) -> cudaError_t;
4207}
4208unsafe extern "C" {
4209 /// Copies data between host and device.
4210 ///
4211 /// Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. Calling [`cudaMemcpy`] with dst and src pointers that do not match the direction of the copy results in an undefined behavior.
4212 ///
4213 /// Note:
4214 ///
4215 /// * Note that this function may also return error codes from previous, asynchronous launches.
4216 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4217 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4218 /// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
4219 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4220 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4221 /// will return CUDA_ERROR_INVALID_VALUE.
4222 ///
4223 /// **See also:**
4224 ///
4225 /// [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpyDtoH](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g3480368ee0208a98f75019c9a8450893), [cuMemcpyHtoD](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4d32266788c440b0220b1a9ba5795169), [cuMemcpyDtoD](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g1725774abf8b51b91945f3336b778c8b), [cuMemcpy](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g8d0ff510f26d4b87bd3a51e731e7f698).
4226 ///
4227 /// # Parameters
4228 ///
4229 /// - `dst`: Destination memory address.
4230 /// - `src`: Source memory address.
4231 /// - `count`: Size in bytes to copy.
4232 /// - `kind`: Type of transfer.
4233 pub fn cudaMemcpy(
4234 dst: *mut ::core::ffi::c_void,
4235 src: *const ::core::ffi::c_void,
4236 count: size_t,
4237 kind: cudaMemcpyKind,
4238 ) -> cudaError_t;
4239}
4240unsafe extern "C" {
4241 /// Copies memory between two devices.
4242 ///
4243 /// 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.
4244 ///
4245 /// Note that this function is asynchronous with respect to the host, but serialized with respect all pending and future asynchronous
4246 /// work in to the current device, srcDevice, and dstDevice (use [`cudaMemcpyPeerAsync`] to avoid this synchronization).
4247 ///
4248 /// Note:
4249 ///
4250 /// * Note that this function may also return error codes from previous, asynchronous launches.
4251 /// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
4252 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4253 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4254 ///
4255 /// **See also:**
4256 ///
4257 /// [`cudaMemcpy`], [`cudaMemcpyAsync`], [`cudaMemcpyPeerAsync`], [`cudaMemcpy3DPeerAsync`], [cuMemcpyPeer](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ge1f5c7771544fee150ada8853c7cbf4a).
4258 ///
4259 /// # Parameters
4260 ///
4261 /// - `dst`: Destination device pointer.
4262 /// - `dstDevice`: Destination device.
4263 /// - `src`: Source device pointer.
4264 /// - `srcDevice`: Source device.
4265 /// - `count`: Size of memory copy in bytes.
4266 pub fn cudaMemcpyPeer(
4267 dst: *mut ::core::ffi::c_void,
4268 dstDevice: ::core::ffi::c_int,
4269 src: *const ::core::ffi::c_void,
4270 srcDevice: ::core::ffi::c_int,
4271 count: size_t,
4272 ) -> cudaError_t;
4273}
4274unsafe extern "C" {
4275 /// Copies data between host and device.
4276 ///
4277 /// Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. dpitch and spitch are the widths in memory in bytes of the 2D arrays pointed to by dst and src, including any padding added to the end of each row. The memory areas may not overlap. width must not exceed either dpitch or spitch. Calling [`cudaMemcpy2D`] with dst and src pointers that do not match the direction of the copy results in an undefined behavior. [`cudaMemcpy2D`] returns an error if dpitch or spitch exceeds the maximum allowed.
4278 ///
4279 /// Note:
4280 ///
4281 /// * Note that this function may also return error codes from previous, asynchronous launches.
4282 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4283 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4284 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4285 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4286 /// will return CUDA_ERROR_INVALID_VALUE.
4287 ///
4288 /// **See also:**
4289 ///
4290 /// [`cudaMemcpy`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpy2D](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g27f885b30c34cc20a663a671dbf6fc27), [cuMemcpy2DUnaligned](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g2fa285d47fd7020e596bfeab3deb651b).
4291 ///
4292 /// # Parameters
4293 ///
4294 /// - `dst`: Destination memory address.
4295 /// - `dpitch`: Pitch of destination memory.
4296 /// - `src`: Source memory address.
4297 /// - `spitch`: Pitch of source memory.
4298 /// - `width`: Width of matrix transfer (columns in bytes).
4299 /// - `height`: Height of matrix transfer (rows).
4300 /// - `kind`: Type of transfer.
4301 pub fn cudaMemcpy2D(
4302 dst: *mut ::core::ffi::c_void,
4303 dpitch: size_t,
4304 src: *const ::core::ffi::c_void,
4305 spitch: size_t,
4306 width: size_t,
4307 height: size_t,
4308 kind: cudaMemcpyKind,
4309 ) -> cudaError_t;
4310}
4311unsafe extern "C" {
4312 /// Copies data between host and device.
4313 ///
4314 /// Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the CUDA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. spitch is the width in memory in bytes of the 2D array pointed to by src, including any padding added to the end of each row. wOffset + width must not exceed the width of the CUDA array dst. width must not exceed spitch. [`cudaMemcpy2DToArray`] returns an error if spitch exceeds the maximum allowed.
4315 ///
4316 /// Note:
4317 ///
4318 /// * Note that this function may also return error codes from previous, asynchronous launches.
4319 /// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
4320 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4321 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4322 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4323 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4324 /// will return CUDA_ERROR_INVALID_VALUE.
4325 ///
4326 /// **See also:**
4327 ///
4328 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpy2D](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g27f885b30c34cc20a663a671dbf6fc27), [cuMemcpy2DUnaligned](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g2fa285d47fd7020e596bfeab3deb651b).
4329 ///
4330 /// # Parameters
4331 ///
4332 /// - `dst`: Destination memory address.
4333 /// - `wOffset`: Destination starting X offset (columns in bytes).
4334 /// - `hOffset`: Destination starting Y offset (rows).
4335 /// - `src`: Source memory address.
4336 /// - `spitch`: Pitch of source memory.
4337 /// - `width`: Width of matrix transfer (columns in bytes).
4338 /// - `height`: Height of matrix transfer (rows).
4339 /// - `kind`: Type of transfer.
4340 pub fn cudaMemcpy2DToArray(
4341 dst: cudaArray_t,
4342 wOffset: size_t,
4343 hOffset: size_t,
4344 src: *const ::core::ffi::c_void,
4345 spitch: size_t,
4346 width: size_t,
4347 height: size_t,
4348 kind: cudaMemcpyKind,
4349 ) -> cudaError_t;
4350}
4351unsafe extern "C" {
4352 /// Copies data between host and device.
4353 ///
4354 /// Copies a matrix (height rows of width bytes each) from the CUDA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. dpitch is the width in memory in bytes of the 2D array pointed to by dst, including any padding added to the end of each row. wOffset + width must not exceed the width of the CUDA array src. width must not exceed dpitch. [`cudaMemcpy2DFromArray`] returns an error if dpitch exceeds the maximum allowed.
4355 ///
4356 /// Note:
4357 ///
4358 /// * Note that this function may also return error codes from previous, asynchronous launches.
4359 /// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
4360 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4361 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4362 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4363 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4364 /// will return CUDA_ERROR_INVALID_VALUE.
4365 ///
4366 /// **See also:**
4367 ///
4368 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpy2D](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g27f885b30c34cc20a663a671dbf6fc27), [cuMemcpy2DUnaligned](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g2fa285d47fd7020e596bfeab3deb651b).
4369 ///
4370 /// # Parameters
4371 ///
4372 /// - `dst`: Destination memory address.
4373 /// - `dpitch`: Pitch of destination memory.
4374 /// - `src`: Source memory address.
4375 /// - `wOffset`: Source starting X offset (columns in bytes).
4376 /// - `hOffset`: Source starting Y offset (rows).
4377 /// - `width`: Width of matrix transfer (columns in bytes).
4378 /// - `height`: Height of matrix transfer (rows).
4379 /// - `kind`: Type of transfer.
4380 pub fn cudaMemcpy2DFromArray(
4381 dst: *mut ::core::ffi::c_void,
4382 dpitch: size_t,
4383 src: cudaArray_const_t,
4384 wOffset: size_t,
4385 hOffset: size_t,
4386 width: size_t,
4387 height: size_t,
4388 kind: cudaMemcpyKind,
4389 ) -> cudaError_t;
4390}
4391unsafe extern "C" {
4392 /// Copies data between host and device.
4393 ///
4394 /// Copies a matrix (height rows of width bytes each) from the CUDA array src starting at hOffsetSrc rows and wOffsetSrc bytes from the upper left corner to the CUDA array dst starting at hOffsetDst rows and wOffsetDst bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. wOffsetDst + width must not exceed the width of the CUDA array dst. wOffsetSrc + width must not exceed the width of the CUDA array src.
4395 ///
4396 /// Note:
4397 ///
4398 /// * Note that this function may also return error codes from previous, asynchronous launches.
4399 /// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
4400 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4401 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4402 ///
4403 /// **See also:**
4404 ///
4405 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpy2D](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g27f885b30c34cc20a663a671dbf6fc27), [cuMemcpy2DUnaligned](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g2fa285d47fd7020e596bfeab3deb651b).
4406 ///
4407 /// # Parameters
4408 ///
4409 /// - `dst`: Destination memory address.
4410 /// - `wOffsetDst`: Destination starting X offset (columns in bytes).
4411 /// - `hOffsetDst`: Destination starting Y offset (rows).
4412 /// - `src`: Source memory address.
4413 /// - `wOffsetSrc`: Source starting X offset (columns in bytes).
4414 /// - `hOffsetSrc`: Source starting Y offset (rows).
4415 /// - `width`: Width of matrix transfer (columns in bytes).
4416 /// - `height`: Height of matrix transfer (rows).
4417 /// - `kind`: Type of transfer.
4418 pub fn cudaMemcpy2DArrayToArray(
4419 dst: cudaArray_t,
4420 wOffsetDst: size_t,
4421 hOffsetDst: size_t,
4422 src: cudaArray_const_t,
4423 wOffsetSrc: size_t,
4424 hOffsetSrc: size_t,
4425 width: size_t,
4426 height: size_t,
4427 kind: cudaMemcpyKind,
4428 ) -> cudaError_t;
4429}
4430unsafe extern "C" {
4431 /// # Parameters
4432 ///
4433 /// - `symbol`: Device symbol reference.
4434 /// - `src`: Source memory address.
4435 /// - `count`: Size in bytes to copy.
4436 /// - `offset`: Offset from start of symbol in bytes.
4437 /// - `kind`: Type of transfer.
4438 pub fn cudaMemcpyToSymbol(
4439 symbol: *const ::core::ffi::c_void,
4440 src: *const ::core::ffi::c_void,
4441 count: size_t,
4442 offset: size_t,
4443 kind: cudaMemcpyKind,
4444 ) -> cudaError_t;
4445}
4446unsafe extern "C" {
4447 /// # Parameters
4448 ///
4449 /// - `dst`: Destination memory address.
4450 /// - `symbol`: Device symbol reference.
4451 /// - `count`: Size in bytes to copy.
4452 /// - `offset`: Offset from start of symbol in bytes.
4453 /// - `kind`: Type of transfer.
4454 pub fn cudaMemcpyFromSymbol(
4455 dst: *mut ::core::ffi::c_void,
4456 symbol: *const ::core::ffi::c_void,
4457 count: size_t,
4458 offset: size_t,
4459 kind: cudaMemcpyKind,
4460 ) -> cudaError_t;
4461}
4462unsafe extern "C" {
4463 /// # Parameters
4464 ///
4465 /// - `dst`: Destination memory address.
4466 /// - `src`: Source memory address.
4467 /// - `count`: Size in bytes to copy.
4468 /// - `kind`: Type of transfer.
4469 /// - `stream`: Stream identifier.
4470 pub fn cudaMemcpyAsync(
4471 dst: *mut ::core::ffi::c_void,
4472 src: *const ::core::ffi::c_void,
4473 count: size_t,
4474 kind: cudaMemcpyKind,
4475 stream: cudaStream_t,
4476 ) -> cudaError_t;
4477}
4478unsafe extern "C" {
4479 /// Copies memory between two devices asynchronously.
4480 ///
4481 /// 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.
4482 ///
4483 /// Note that this function is asynchronous with respect to the host and all work on other devices.
4484 ///
4485 /// Note:
4486 ///
4487 /// * Note that this function may also return error codes from previous, asynchronous launches.
4488 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
4489 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
4490 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4491 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4492 ///
4493 /// **See also:**
4494 ///
4495 /// [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpy3DPeerAsync`], [cuMemcpyPeerAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g82fcecb38018e64b98616a8ac30112f2).
4496 ///
4497 /// # Parameters
4498 ///
4499 /// - `dst`: Destination device pointer.
4500 /// - `dstDevice`: Destination device.
4501 /// - `src`: Source device pointer.
4502 /// - `srcDevice`: Source device.
4503 /// - `count`: Size of memory copy in bytes.
4504 /// - `stream`: Stream identifier.
4505 pub fn cudaMemcpyPeerAsync(
4506 dst: *mut ::core::ffi::c_void,
4507 dstDevice: ::core::ffi::c_int,
4508 src: *const ::core::ffi::c_void,
4509 srcDevice: ::core::ffi::c_int,
4510 count: size_t,
4511 stream: cudaStream_t,
4512 ) -> cudaError_t;
4513}
4514unsafe extern "C" {
4515 /// # Parameters
4516 ///
4517 /// - `dsts`: Array of destination pointers.
4518 /// - `srcs`: Array of memcpy source pointers.
4519 /// - `sizes`: Array of sizes for memcpy operations.
4520 /// - `count`: Size of dsts, srcs and sizes arrays.
4521 /// - `attrs`: Array of memcpy attributes.
4522 /// - `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\]
4523 /// - 1. Also attrs\[numAttrs-1\] will apply to copies starting from attrsIdxs\[numAttrs-1\] through count - 1.
4524 /// - `numAttrs`: Size of attrs and attrsIdxs arrays.
4525 pub fn cudaMemcpyBatchAsync(
4526 dsts: *const *mut ::core::ffi::c_void,
4527 srcs: *const *const ::core::ffi::c_void,
4528 sizes: *const size_t,
4529 count: size_t,
4530 attrs: *mut cudaMemcpyAttributes,
4531 attrsIdxs: *mut size_t,
4532 numAttrs: size_t,
4533 stream: cudaStream_t,
4534 ) -> cudaError_t;
4535}
4536unsafe extern "C" {
4537 /// Performs a batch of 3D memory copies asynchronously.
4538 ///
4539 /// Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a batch are not guaranteed
4540 /// to execute in any specific order. Note that this means specifying any dependent copies within a batch will result in undefined
4541 /// behavior.
4542 ///
4543 /// 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
4544 /// for the copy as specified in cudaMemcpy3DBatchOp::src and cudaMemcpy3DBatchOp::dst respectively. The source and destination
4545 /// 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.
4546 /// The width, height and depth of a copy are specified in elements and must not be zero. For pointer-to-pointer copies, the element
4547 /// size is considered to be 1. For pointer to CUDA array or vice versa copies, the element size is determined by the CUDA array.
4548 /// For CUDA array to CUDA array copies, the element size of the two CUDA arrays must match.
4549 ///
4550 /// For a given operand, if cudaMemcpy3DOperand::type is specified as [cudaMemcpyOperandTypePointer](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggda2d93832ded1a29fd7cb28a6261ee6c395369a66615a9cacf1a734334859a67), then cudaMemcpy3DOperand::op::ptr will be used. The cudaMemcpy3DOperand::op::ptr::ptr field must contain the pointer where
4551 /// the copy should begin. The cudaMemcpy3DOperand::op::ptr::rowLength field specifies the length of each row in elements and
4552 /// must either be zero or be greater than or equal to the width of the copy specified in cudaMemcpy3DBatchOp::extent::width.
4553 /// The cudaMemcpy3DOperand::op::ptr::layerHeight field specifies the height of each layer and must either be zero or be greater
4554 /// than or equal to the height of the copy specified in cudaMemcpy3DBatchOp::extent::height. When either of these values is zero,
4555 /// that aspect of the operand is considered to be tightly packed according to the copy extent. For managed memory pointers on
4556 /// devices where [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09) is true or system-allocated pageable memory on devices where [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f) is true, the cudaMemcpy3DOperand::op::ptr::locHint field can be used to hint the location of the operand.
4557 ///
4558 /// If an operand's type is specified as [cudaMemcpyOperandTypeArray](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggda2d93832ded1a29fd7cb28a6261ee6c468b9e5daeac88a1cddc387310cb2952), then cudaMemcpy3DOperand::op::array will be used. The cudaMemcpy3DOperand::op::array::array field specifies the CUDA array
4559 /// and cudaMemcpy3DOperand::op::array::offset specifies the 3D offset into that array where the copy begins.
4560 ///
4561 /// The [cudaMemcpyAttributes::srcAccessOrder](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemcpyAttributes.html#structcudaMemcpyAttributes_10d466b9b554cfd529fa0d0344c0c391a) indicates the source access ordering to be observed for copies associated with the attribute. If the source access order
4562 /// is set to [cudaMemcpySrcAccessOrderStream](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg1a0bf7e313a2ef3dcabacefcf8a013b5b0c0860266a1fe9e640296317e8e32ae), then the source will be accessed in stream order. If the source access order is set to [cudaMemcpySrcAccessOrderDuringApiCall](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
4563 /// API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations
4564 /// in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source
4565 /// variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to
4566 /// synchronize the stream after the API call. If the source access order is set to [cudaMemcpySrcAccessOrderAny](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
4567 /// API call returns. This flag is suited for host pointers allocated outside CUDA (ex., via malloc) when it's known that no prior
4568 /// operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain
4569 /// platforms. Each memcopy operation in opList must have a valid srcAccessOrder setting, otherwise this API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
4570 ///
4571 /// The [cudaMemcpyAttributes::flags](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemcpyAttributes.html#structcudaMemcpyAttributes_1f18d7011fefaecb0fa72cbdbf8aad0fb) field can be used to specify certain flags for copies. Setting the [cudaMemcpyFlagPreferOverlapWithCompute](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gge21aa0690949b1d1e5360e4edcf75dcffef0e1bac799cb33d1ee092124ced948) flag indicates that the associated copies should preferably overlap with any compute work. Note that this flag is a hint
4572 /// and can be ignored depending on the platform and other parameters of the copy.
4573 ///
4574 /// Note:
4575 ///
4576 /// * Note that this function may also return error codes from previous, asynchronous launches.
4577 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
4578 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4579 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4580 /// will return CUDA_ERROR_INVALID_VALUE.
4581 ///
4582 /// # Parameters
4583 ///
4584 /// - `numOps`: Total number of memcpy operations.
4585 /// - `opList`: Array of size numOps containing the actual memcpy operations.
4586 /// - `flags`: Flags for future use, must be zero now.
4587 pub fn cudaMemcpy3DBatchAsync(
4588 numOps: size_t,
4589 opList: *mut cudaMemcpy3DBatchOp,
4590 flags: ::core::ffi::c_ulonglong,
4591 stream: cudaStream_t,
4592 ) -> cudaError_t;
4593}
4594unsafe extern "C" {
4595 /// Performs asynchronous memory copy operation with the specified attributes.
4596 ///
4597 /// 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.
4598 ///
4599 /// For more information regarding the attributes, please refer to `cudaMemcpyAttributes` and it's usage desciption [`cudaMemcpyBatchAsync`]
4600 ///
4601 /// Note:
4602 ///
4603 /// * Note that this function may also return error codes from previous, asynchronous launches.
4604 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
4605 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4606 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4607 /// will return CUDA_ERROR_INVALID_VALUE.
4608 ///
4609 /// **See also:**
4610 ///
4611 /// [`cudaMemcpyBatchAsync`]
4612 ///
4613 /// # Parameters
4614 ///
4615 /// - `dst`: Destination device pointer.
4616 /// - `src`: Source device pointer.
4617 /// - `size`: Number of bytes to copy.
4618 /// - `attr`: Attributes for the copy.
4619 pub fn cudaMemcpyWithAttributesAsync(
4620 dst: *mut ::core::ffi::c_void,
4621 src: *const ::core::ffi::c_void,
4622 size: size_t,
4623 attr: *mut cudaMemcpyAttributes,
4624 stream: cudaStream_t,
4625 ) -> cudaError_t;
4626}
4627unsafe extern "C" {
4628 /// Performs 3D asynchronous memory copy with the specified attributes.
4629 ///
4630 /// Performs the copy operation specified in op. flags specifies the flags for the copy and hStream specifies the stream to enqueue the operation in.
4631 ///
4632 /// For more information regarding the operation, please refer to cudaMemcpy3DBatchOp and it's usage desciption [`cudaMemcpy3DBatchAsync`]
4633 ///
4634 /// Note:
4635 ///
4636 /// * Note that this function may also return error codes from previous, asynchronous launches.
4637 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
4638 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4639 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4640 /// will return CUDA_ERROR_INVALID_VALUE.
4641 ///
4642 /// **See also:**
4643 ///
4644 /// [`cudaMemcpy3DBatchAsync`].
4645 ///
4646 /// # Parameters
4647 ///
4648 /// - `op`: Operation to perform.
4649 /// - `flags`: Flags for the copy, must be zero now.
4650 pub fn cudaMemcpy3DWithAttributesAsync(
4651 op: *mut cudaMemcpy3DBatchOp,
4652 flags: ::core::ffi::c_ulonglong,
4653 stream: cudaStream_t,
4654 ) -> cudaError_t;
4655}
4656unsafe extern "C" {
4657 /// Copies data between host and device.
4658 ///
4659 /// Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. dpitch and spitch are the widths in memory in bytes of the 2D arrays pointed to by dst and src, including any padding added to the end of each row. The memory areas may not overlap. width must not exceed either dpitch or spitch.
4660 ///
4661 /// 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.
4662 ///
4663 /// [`cudaMemcpy2DAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be
4664 /// associated to a stream by passing a non-zero stream argument. If kind is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and stream is non-zero, the copy may overlap with operations in other streams.
4665 ///
4666 /// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
4667 ///
4668 /// Note:
4669 ///
4670 /// * Note that this function may also return error codes from previous, asynchronous launches.
4671 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
4672 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
4673 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4674 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4675 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4676 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4677 /// will return CUDA_ERROR_INVALID_VALUE.
4678 ///
4679 /// **See also:**
4680 ///
4681 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpy2DAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
4682 ///
4683 /// # Parameters
4684 ///
4685 /// - `dst`: Destination memory address.
4686 /// - `dpitch`: Pitch of destination memory.
4687 /// - `src`: Source memory address.
4688 /// - `spitch`: Pitch of source memory.
4689 /// - `width`: Width of matrix transfer (columns in bytes).
4690 /// - `height`: Height of matrix transfer (rows).
4691 /// - `kind`: Type of transfer.
4692 /// - `stream`: Stream identifier.
4693 pub fn cudaMemcpy2DAsync(
4694 dst: *mut ::core::ffi::c_void,
4695 dpitch: size_t,
4696 src: *const ::core::ffi::c_void,
4697 spitch: size_t,
4698 width: size_t,
4699 height: size_t,
4700 kind: cudaMemcpyKind,
4701 stream: cudaStream_t,
4702 ) -> cudaError_t;
4703}
4704unsafe extern "C" {
4705 /// Copies data between host and device.
4706 ///
4707 /// Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the CUDA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. spitch is the width in memory in bytes of the 2D array pointed to by src, including any padding added to the end of each row. wOffset + width must not exceed the width of the CUDA array dst. width must not exceed spitch. [`cudaMemcpy2DToArrayAsync`] returns an error if spitch exceeds the maximum allowed.
4708 ///
4709 /// [`cudaMemcpy2DToArrayAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be
4710 /// associated to a stream by passing a non-zero stream argument. If kind is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and stream is non-zero, the copy may overlap with operations in other streams.
4711 ///
4712 /// Note:
4713 ///
4714 /// * Note that this function may also return error codes from previous, asynchronous launches.
4715 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
4716 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
4717 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4718 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4719 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4720 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4721 /// will return CUDA_ERROR_INVALID_VALUE.
4722 ///
4723 /// **See also:**
4724 ///
4725 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`],
4726 ///
4727 /// [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpy2DAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
4728 ///
4729 /// # Parameters
4730 ///
4731 /// - `dst`: Destination memory address.
4732 /// - `wOffset`: Destination starting X offset (columns in bytes).
4733 /// - `hOffset`: Destination starting Y offset (rows).
4734 /// - `src`: Source memory address.
4735 /// - `spitch`: Pitch of source memory.
4736 /// - `width`: Width of matrix transfer (columns in bytes).
4737 /// - `height`: Height of matrix transfer (rows).
4738 /// - `kind`: Type of transfer.
4739 /// - `stream`: Stream identifier.
4740 pub fn cudaMemcpy2DToArrayAsync(
4741 dst: cudaArray_t,
4742 wOffset: size_t,
4743 hOffset: size_t,
4744 src: *const ::core::ffi::c_void,
4745 spitch: size_t,
4746 width: size_t,
4747 height: size_t,
4748 kind: cudaMemcpyKind,
4749 stream: cudaStream_t,
4750 ) -> cudaError_t;
4751}
4752unsafe extern "C" {
4753 /// Copies data between host and device.
4754 ///
4755 /// Copies a matrix (height rows of width bytes each) from the CUDA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. dpitch is the width in memory in bytes of the 2D array pointed to by dst, including any padding added to the end of each row. wOffset + width must not exceed the width of the CUDA array src. width must not exceed dpitch. [`cudaMemcpy2DFromArrayAsync`] returns an error if dpitch exceeds the maximum allowed.
4756 ///
4757 /// [`cudaMemcpy2DFromArrayAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be
4758 /// associated to a stream by passing a non-zero stream argument. If kind is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and stream is non-zero, the copy may overlap with operations in other streams.
4759 ///
4760 /// Note:
4761 ///
4762 /// * Note that this function may also return error codes from previous, asynchronous launches.
4763 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
4764 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
4765 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4766 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4767 /// * Memory regions requested must be either entirely registered with CUDA, or in the case of host pageable transfers, not registered
4768 /// at all. Memory regions spanning over allocations that are both registered and not registered with CUDA are not supported and
4769 /// will return CUDA_ERROR_INVALID_VALUE.
4770 ///
4771 /// **See also:**
4772 ///
4773 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`],
4774 ///
4775 /// [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpy2DAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
4776 ///
4777 /// # Parameters
4778 ///
4779 /// - `dst`: Destination memory address.
4780 /// - `dpitch`: Pitch of destination memory.
4781 /// - `src`: Source memory address.
4782 /// - `wOffset`: Source starting X offset (columns in bytes).
4783 /// - `hOffset`: Source starting Y offset (rows).
4784 /// - `width`: Width of matrix transfer (columns in bytes).
4785 /// - `height`: Height of matrix transfer (rows).
4786 /// - `kind`: Type of transfer.
4787 /// - `stream`: Stream identifier.
4788 pub fn cudaMemcpy2DFromArrayAsync(
4789 dst: *mut ::core::ffi::c_void,
4790 dpitch: size_t,
4791 src: cudaArray_const_t,
4792 wOffset: size_t,
4793 hOffset: size_t,
4794 width: size_t,
4795 height: size_t,
4796 kind: cudaMemcpyKind,
4797 stream: cudaStream_t,
4798 ) -> cudaError_t;
4799}
4800unsafe extern "C" {
4801 /// # Parameters
4802 ///
4803 /// - `symbol`: Device symbol reference.
4804 /// - `src`: Source memory address.
4805 /// - `count`: Size in bytes to copy.
4806 /// - `offset`: Offset from start of symbol in bytes.
4807 /// - `kind`: Type of transfer.
4808 /// - `stream`: Stream identifier.
4809 pub fn cudaMemcpyToSymbolAsync(
4810 symbol: *const ::core::ffi::c_void,
4811 src: *const ::core::ffi::c_void,
4812 count: size_t,
4813 offset: size_t,
4814 kind: cudaMemcpyKind,
4815 stream: cudaStream_t,
4816 ) -> cudaError_t;
4817}
4818unsafe extern "C" {
4819 /// # Parameters
4820 ///
4821 /// - `dst`: Destination memory address.
4822 /// - `symbol`: Device symbol reference.
4823 /// - `count`: Size in bytes to copy.
4824 /// - `offset`: Offset from start of symbol in bytes.
4825 /// - `kind`: Type of transfer.
4826 /// - `stream`: Stream identifier.
4827 pub fn cudaMemcpyFromSymbolAsync(
4828 dst: *mut ::core::ffi::c_void,
4829 symbol: *const ::core::ffi::c_void,
4830 count: size_t,
4831 offset: size_t,
4832 kind: cudaMemcpyKind,
4833 stream: cudaStream_t,
4834 ) -> cudaError_t;
4835}
4836unsafe extern "C" {
4837 /// Initializes or sets device memory to a value.
4838 ///
4839 /// Fills the first count bytes of the memory area pointed to by devPtr with the constant byte value value.
4840 ///
4841 /// Note that this function is asynchronous with respect to the host unless devPtr refers to pinned host memory.
4842 ///
4843 /// Note:
4844 ///
4845 /// * Note that this function may also return error codes from previous, asynchronous launches.
4846 /// * See also [memset synchronization details](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memset).
4847 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4848 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4849 ///
4850 /// **See also:**
4851 ///
4852 /// [cuMemsetD8](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g6e582bf866e9e2fb014297bfaf354d7b), [cuMemsetD16](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g7d805e610054392a4d11e8a8bf5eb35c), [cuMemsetD32](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g983e8d8759acd1b64326317481fbf132).
4853 ///
4854 /// # Parameters
4855 ///
4856 /// - `devPtr`: Pointer to device memory.
4857 /// - `value`: Value to set for each byte of specified memory.
4858 /// - `count`: Size in bytes to set.
4859 pub fn cudaMemset(
4860 devPtr: *mut ::core::ffi::c_void,
4861 value: ::core::ffi::c_int,
4862 count: size_t,
4863 ) -> cudaError_t;
4864}
4865unsafe extern "C" {
4866 /// Initializes or sets device memory to a value.
4867 ///
4868 /// 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
4869 /// back by [`cudaMallocPitch`].
4870 ///
4871 /// Note that this function is asynchronous with respect to the host unless devPtr refers to pinned host memory.
4872 ///
4873 /// Note:
4874 ///
4875 /// * Note that this function may also return error codes from previous, asynchronous launches.
4876 /// * See also [memset synchronization details](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memset).
4877 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4878 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4879 ///
4880 /// **See also:**
4881 ///
4882 /// [`cudaMemset`], [`cudaMemset3D`], [`cudaMemsetAsync`], [`cudaMemset2DAsync`], [`cudaMemset3DAsync`], [cuMemsetD2D8](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1ge88b13e646e2be6ba0e0475ef5205974), [cuMemsetD2D16](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g7f561a15a66144fa9f6ab5350edc8a30), [cuMemsetD2D32](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g74b359b2d026bfeb7c795b5038d07523).
4883 ///
4884 /// # Parameters
4885 ///
4886 /// - `devPtr`: Pointer to 2D device memory.
4887 /// - `pitch`: Pitch in bytes of 2D device memory(Unused if height is 1).
4888 /// - `value`: Value to set for each byte of specified memory.
4889 /// - `width`: Width of matrix set (columns in bytes).
4890 /// - `height`: Height of matrix set (rows).
4891 pub fn cudaMemset2D(
4892 devPtr: *mut ::core::ffi::c_void,
4893 pitch: size_t,
4894 value: ::core::ffi::c_int,
4895 width: size_t,
4896 height: size_t,
4897 ) -> cudaError_t;
4898}
4899unsafe extern "C" {
4900 /// Initializes or sets device memory to a value.
4901 ///
4902 /// 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.
4903 ///
4904 /// The extents of the initialized region are specified as a width in bytes, a height in rows, and a depth in slices.
4905 ///
4906 /// 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.
4907 ///
4908 /// This function performs fastest when the pitchedDevPtr has been allocated by [`cudaMalloc3D`].
4909 ///
4910 /// Note that this function is asynchronous with respect to the host unless pitchedDevPtr refers to pinned host memory.
4911 ///
4912 /// Note:
4913 ///
4914 /// * Note that this function may also return error codes from previous, asynchronous launches.
4915 /// * See also [memset synchronization details](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memset).
4916 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4917 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4918 ///
4919 /// **See also:**
4920 ///
4921 /// [`cudaMemset`], [`cudaMemset2D`], [`cudaMemsetAsync`], [`cudaMemset2DAsync`], [`cudaMemset3DAsync`], [`cudaMalloc3D`], `make_cudaPitchedPtr`, `make_cudaExtent`.
4922 ///
4923 /// # Parameters
4924 ///
4925 /// - `pitchedDevPtr`: Pointer to pitched device memory.
4926 /// - `value`: Value to set for each byte of specified memory.
4927 /// - `extent`: Size parameters for where to set device memory (width field in bytes).
4928 pub fn cudaMemset3D(
4929 pitchedDevPtr: cudaPitchedPtr,
4930 value: ::core::ffi::c_int,
4931 extent: cudaExtent,
4932 ) -> cudaError_t;
4933}
4934unsafe extern "C" {
4935 /// Initializes or sets device memory to a value.
4936 ///
4937 /// Fills the first count bytes of the memory area pointed to by devPtr with the constant byte value value.
4938 ///
4939 /// [`cudaMemsetAsync`] is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally
4940 /// 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.
4941 ///
4942 /// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
4943 ///
4944 /// Note:
4945 ///
4946 /// * Note that this function may also return error codes from previous, asynchronous launches.
4947 /// * See also [memset synchronization details](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memset).
4948 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
4949 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4950 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4951 ///
4952 /// **See also:**
4953 ///
4954 /// [`cudaMemset`], [`cudaMemset2D`], [`cudaMemset3D`], [`cudaMemset2DAsync`], [`cudaMemset3DAsync`], [cuMemsetD8Async](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gaef08a7ccd61112f94e82f2b30d43627), [cuMemsetD16Async](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf731438877dd8ec875e4c43d848c878c), [cuMemsetD32Async](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g58229da5d30f1c0cdf667b320ec2c0f5).
4955 ///
4956 /// # Parameters
4957 ///
4958 /// - `devPtr`: Pointer to device memory.
4959 /// - `value`: Value to set for each byte of specified memory.
4960 /// - `count`: Size in bytes to set.
4961 /// - `stream`: Stream identifier.
4962 pub fn cudaMemsetAsync(
4963 devPtr: *mut ::core::ffi::c_void,
4964 value: ::core::ffi::c_int,
4965 count: size_t,
4966 stream: cudaStream_t,
4967 ) -> cudaError_t;
4968}
4969unsafe extern "C" {
4970 /// Initializes or sets device memory to a value.
4971 ///
4972 /// 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
4973 /// back by [`cudaMallocPitch`].
4974 ///
4975 /// [`cudaMemset2DAsync`] is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally
4976 /// 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.
4977 ///
4978 /// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
4979 ///
4980 /// Note:
4981 ///
4982 /// * Note that this function may also return error codes from previous, asynchronous launches.
4983 /// * See also [memset synchronization details](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memset).
4984 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
4985 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
4986 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
4987 ///
4988 /// **See also:**
4989 ///
4990 /// [`cudaMemset`], [`cudaMemset2D`], [`cudaMemset3D`], [`cudaMemsetAsync`], [`cudaMemset3DAsync`], [cuMemsetD2D8Async](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g3f7b6924a3e49c3265b328f534102e97), [cuMemsetD2D16Async](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g64ee197befac3d74d9fefedcf6ef6b10), [cuMemsetD2D32Async](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g8a78d3147ac93fac955052c815d9ea3c).
4991 ///
4992 /// # Parameters
4993 ///
4994 /// - `devPtr`: Pointer to 2D device memory.
4995 /// - `pitch`: Pitch in bytes of 2D device memory(Unused if height is 1).
4996 /// - `value`: Value to set for each byte of specified memory.
4997 /// - `width`: Width of matrix set (columns in bytes).
4998 /// - `height`: Height of matrix set (rows).
4999 /// - `stream`: Stream identifier.
5000 pub fn cudaMemset2DAsync(
5001 devPtr: *mut ::core::ffi::c_void,
5002 pitch: size_t,
5003 value: ::core::ffi::c_int,
5004 width: size_t,
5005 height: size_t,
5006 stream: cudaStream_t,
5007 ) -> cudaError_t;
5008}
5009unsafe extern "C" {
5010 /// Initializes or sets device memory to a value.
5011 ///
5012 /// 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.
5013 ///
5014 /// The extents of the initialized region are specified as a width in bytes, a height in rows, and a depth in slices.
5015 ///
5016 /// 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.
5017 ///
5018 /// This function performs fastest when the pitchedDevPtr has been allocated by [`cudaMalloc3D`].
5019 ///
5020 /// [`cudaMemset3DAsync`] is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally
5021 /// 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.
5022 ///
5023 /// The device version of this function only handles device to device copies and cannot be given local or shared pointers.
5024 ///
5025 /// Note:
5026 ///
5027 /// * Note that this function may also return error codes from previous, asynchronous launches.
5028 /// * See also [memset synchronization details](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memset).
5029 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
5030 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5031 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5032 ///
5033 /// **See also:**
5034 ///
5035 /// [`cudaMemset`], [`cudaMemset2D`], [`cudaMemset3D`], [`cudaMemsetAsync`], [`cudaMemset2DAsync`], [`cudaMalloc3D`], `make_cudaPitchedPtr`, `make_cudaExtent`.
5036 ///
5037 /// # Parameters
5038 ///
5039 /// - `pitchedDevPtr`: Pointer to pitched device memory.
5040 /// - `value`: Value to set for each byte of specified memory.
5041 /// - `extent`: Size parameters for where to set device memory (width field in bytes).
5042 /// - `stream`: Stream identifier.
5043 pub fn cudaMemset3DAsync(
5044 pitchedDevPtr: cudaPitchedPtr,
5045 value: ::core::ffi::c_int,
5046 extent: cudaExtent,
5047 stream: cudaStream_t,
5048 ) -> cudaError_t;
5049}
5050unsafe extern "C" {
5051 /// # Parameters
5052 ///
5053 /// - `devPtr`: Return device pointer associated with symbol.
5054 /// - `symbol`: Device symbol reference.
5055 pub fn cudaGetSymbolAddress(
5056 devPtr: *mut *mut ::core::ffi::c_void,
5057 symbol: *const ::core::ffi::c_void,
5058 ) -> cudaError_t;
5059}
5060unsafe extern "C" {
5061 /// # Parameters
5062 ///
5063 /// - `size`: Size of object associated with symbol.
5064 /// - `symbol`: Device symbol reference.
5065 pub fn cudaGetSymbolSize(
5066 size: *mut size_t,
5067 symbol: *const ::core::ffi::c_void,
5068 ) -> cudaError_t;
5069}
5070unsafe extern "C" {
5071 /// Prefetches memory to the specified destination location.
5072 ///
5073 /// Prefetches memory to the specified destination location. devPtr is the base device pointer of the memory to be prefetched and location specifies the destination location. count specifies the number of bytes to copy. stream is the stream in which the operation is enqueued. The memory range must refer to managed memory allocated via [`cudaMallocManaged`] or declared via __managed__ variables, or it may also refer to memory allocated from a managed memory pool, or it may also
5074 /// refer to system-allocated memory on systems with non-zero cudaDevAttrPageableMemoryAccess.
5075 ///
5076 /// Specifying [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) for [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) will prefetch memory to GPU specified by device ordinal [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) as [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) will prefetch data to host memory. Applications can request prefetching memory to a specific host NUMA node by specifying
5077 /// [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) for [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) and a valid host NUMA node id in [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0a3925690e32332c940cb726ef56a4258) for [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0). Note when [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is etiher [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) OR [cudaMemLocationTypeHostNumaCurrent](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0a3925690e32332c940cb726ef56a4258), [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) will be ignored.
5078 ///
5079 /// The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU
5080 /// page size before the prefetch operation is enqueued in the stream.
5081 ///
5082 /// If no physical memory has been allocated for this region, then this memory region will be populated and mapped on the destination
5083 /// device. If there's insufficient memory to prefetch the desired region, the Unified Memory driver may evict pages from other
5084 /// [`cudaMallocManaged`] allocations to host memory in order to make room. Device memory allocated using [`cudaMalloc`] or [`cudaMallocArray`] will not be evicted.
5085 ///
5086 /// By default, any mappings to the previous location of the migrated pages are removed and mappings for the new location are
5087 /// only setup on the destination location. The exact behavior however also depends on the settings applied to this memory range
5088 /// via [cuMemAdvise](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1gaac8924b2f5a2a93f8775fb81c1a643f) as described below:
5089 ///
5090 /// If [cudaMemAdviseSetReadMostly](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
5091 /// If however the destination location is a host NUMA node, then any pages of that subset that are already in another host NUMA
5092 /// node will be transferred to the destination.
5093 ///
5094 /// If [cudaMemAdviseSetPreferredLocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
5095 ///
5096 /// If [cudaMemAdviseSetAccessedBy](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5097 /// to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared.
5098 ///
5099 /// Note that this API is not required for functionality and only serves to improve performance by allowing the application to
5100 /// migrate data to a suitable location before it is accessed. Memory accesses to this range are always coherent and are allowed
5101 /// even when the data is actively being migrated.
5102 ///
5103 /// Note that this function is asynchronous with respect to the host and all work on other devices.
5104 ///
5105 /// Note:
5106 ///
5107 /// * Note that this function may also return error codes from previous, asynchronous launches.
5108 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
5109 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
5110 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5111 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5112 ///
5113 /// **See also:**
5114 ///
5115 /// [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpy3DPeerAsync`], [`cudaMemAdvise`], [cuMemPrefetchAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1g45c0e085febc3be8fabf5c526355b6a3).
5116 ///
5117 /// # Parameters
5118 ///
5119 /// - `devPtr`: Pointer to be prefetched.
5120 /// - `count`: Size in bytes.
5121 /// - `location`: location to prefetch to.
5122 /// - `flags`: flags for future use, must be zero now.
5123 /// - `stream`: Stream to enqueue prefetch operation.
5124 pub fn cudaMemPrefetchAsync(
5125 devPtr: *const ::core::ffi::c_void,
5126 count: size_t,
5127 location: cudaMemLocation,
5128 flags: ::core::ffi::c_uint,
5129 stream: cudaStream_t,
5130 ) -> cudaError_t;
5131}
5132unsafe extern "C" {
5133 /// # Parameters
5134 ///
5135 /// - `dptrs`: Array of pointers to be prefetched.
5136 /// - `sizes`: Array of sizes for memory prefetch operations.
5137 /// - `count`: Size of dptrs and sizes arrays.
5138 /// - `prefetchLocs`: Array of locations to prefetch to.
5139 /// - `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
5140 /// prefetchLocIdxs\[k+1\] - 1. Also prefetchLocs\[numPrefetchLocs - 1\] will apply to prefetches starting from prefetchLocIdxs\[numPrefetchLocs
5141 /// - 1\] through count - 1.
5142 /// - `numPrefetchLocs`: Size of prefetchLocs and prefetchLocIdxs arrays.
5143 /// - `flags`: Flags reserved for future use. Must be zero.
5144 pub fn cudaMemPrefetchBatchAsync(
5145 dptrs: *mut *mut ::core::ffi::c_void,
5146 sizes: *mut size_t,
5147 count: size_t,
5148 prefetchLocs: *mut cudaMemLocation,
5149 prefetchLocIdxs: *mut size_t,
5150 numPrefetchLocs: size_t,
5151 flags: ::core::ffi::c_ulonglong,
5152 stream: cudaStream_t,
5153 ) -> cudaError_t;
5154}
5155unsafe extern "C" {
5156 /// Performs a batch of memory discards asynchronously.
5157 ///
5158 /// Performs a batch of memory discards. The batch as a whole executes in stream order but operations within a batch are not guaranteed
5159 /// to execute in any specific order. All devices in the system must have a non-zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09) otherwise the API will return an error.
5160 ///
5161 /// Discarding a memory range informs the driver that the contents of that range are no longer useful. Discarding memory ranges
5162 /// allows the driver to optimize certain data migrations and can also help reduce memory pressure. This operation can be undone
5163 /// on any part of the range by either writing to it or prefetching it via [`cudaMemPrefetchAsync`] or [`cudaMemPrefetchBatchAsync`]. Reading from a discarded range, without a subsequent write or prefetch to that part of the range, will return an indeterminate
5164 /// value. Note that any reads, writes or prefetches to any part of the memory range that occur simultaneously with the discard
5165 /// operation result in undefined behavior.
5166 ///
5167 /// Performs memory discard on address ranges specified in dptrs and sizes. Both arrays must be of the same length as specified by count. Each memory range specified must refer to managed memory allocated via [`cudaMallocManaged`] or declared via __managed__ variables or it may also refer to system-allocated memory when all devices have a non-zero value
5168 /// for [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f).
5169 ///
5170 /// # Parameters
5171 ///
5172 /// - `dptrs`: Array of pointers to be discarded.
5173 /// - `sizes`: Array of sizes for memory discard operations.
5174 /// - `count`: Size of dptrs and sizes arrays.
5175 /// - `flags`: Flags reserved for future use. Must be zero.
5176 pub fn cudaMemDiscardBatchAsync(
5177 dptrs: *mut *mut ::core::ffi::c_void,
5178 sizes: *mut size_t,
5179 count: size_t,
5180 flags: ::core::ffi::c_ulonglong,
5181 stream: cudaStream_t,
5182 ) -> cudaError_t;
5183}
5184unsafe extern "C" {
5185 /// # Parameters
5186 ///
5187 /// - `dptrs`: Array of pointers to be discarded.
5188 /// - `sizes`: Array of sizes for memory discard operations.
5189 /// - `count`: Size of dptrs and sizes arrays.
5190 /// - `prefetchLocs`: Array of locations to prefetch to.
5191 /// - `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\]
5192 /// through prefetchLocIdxs\[k+1\] - 1. Also prefetchLocs\[numPrefetchLocs - 1\] will apply to copies starting from prefetchLocIdxs\[numPrefetchLocs
5193 /// - 1\] through count - 1.
5194 /// - `numPrefetchLocs`: Size of prefetchLocs and prefetchLocIdxs arrays.
5195 /// - `flags`: Flags reserved for future use. Must be zero.
5196 pub fn cudaMemDiscardAndPrefetchBatchAsync(
5197 dptrs: *mut *mut ::core::ffi::c_void,
5198 sizes: *mut size_t,
5199 count: size_t,
5200 prefetchLocs: *mut cudaMemLocation,
5201 prefetchLocIdxs: *mut size_t,
5202 numPrefetchLocs: size_t,
5203 flags: ::core::ffi::c_ulonglong,
5204 stream: cudaStream_t,
5205 ) -> cudaError_t;
5206}
5207unsafe extern "C" {
5208 /// Advise about the usage of a given memory range.
5209 ///
5210 /// 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
5211 /// to CPU page size before the advice is applied. The memory range must refer to managed memory allocated via [`cudaMallocManaged`] or declared via __managed__ variables. The memory range could also refer to system-allocated pageable memory provided it
5212 /// 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
5213 /// returned.
5214 ///
5215 /// The advice parameter can take the following values:
5216 ///
5217 /// * [cudaMemAdviseSetReadMostly](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5218 /// processor to this region will create a read-only copy of at least the accessed pages in that processor's memory. Additionally,
5219 /// 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
5220 /// 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
5221 /// host NUMA node. If any processor writes to this region, all copies of the corresponding page will be invalidated except for
5222 /// the one where the write occurred. If the writing processor is the CPU and the preferred location of the page is a host NUMA
5223 /// 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
5224 /// CPU or a GPU that has a non-zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09). Also, if a context is created on a device that does not have the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5225 /// pageable memory, then the accessing device must have a non-zero value for the device attribute [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5226 /// the device attribute [cudaDevAttrPageableMemoryAccessUsesHostPageTables](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc228cf8983c97d0e035da72a71494eaa), then setting this advice will not create a read-only copy when that device accesses this memory region.
5227 ///
5228 /// * cudaMemAdviceUnsetReadMostly: Undoes the effect of [cudaMemAdviseSetReadMostly](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857441d911811beda174627f403142d5ff0) and also prevents the Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated
5229 /// copies of the data will be collapsed into a single copy. The location for the collapsed copy will be the preferred location
5230 /// if the page has a preferred location and one of the read-duplicated copies was resident at that location. Otherwise, the location
5231 /// chosen is arbitrary. Note: The location argument is ignored for this advice.
5232 ///
5233 /// * [cudaMemAdviseSetPreferredLocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857a4a2bc3c7d218dcd9a1b425b432759eb): This advice sets the preferred location for the data to be the memory belonging to location. When [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5), [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/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,
5234 /// applications must set [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) to [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) and [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must specify the NUMA ID of the host NUMA node. If [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is set to [cudaMemLocationTypeHostNumaCurrent](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0a3925690e32332c940cb726ef56a4258), [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/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](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is a [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), then [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must be a valid device ordinal and the device must have a non-zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09). Setting the preferred location does not cause data to migrate to that location immediately. Instead, it guides the migration
5235 /// policy when a fault occurs on that memory region. If the data is already in its preferred location and the faulting processor
5236 /// can establish a mapping without requiring the data to be migrated, then data migration will be avoided. On the other hand,
5237 /// if the data is not in its preferred location or if a direct mapping cannot be established, then it will be migrated to the
5238 /// processor accessing it. It is important to note that setting the preferred location does not prevent data prefetching done
5239 /// using [`cudaMemPrefetchAsync`]. Having a preferred location can override the page thrash detection and resolution logic in the Unified Memory driver. Normally,
5240 /// if a page is detected to be constantly thrashing between for example host and device memory, the page may eventually be pinned
5241 /// to host memory by the Unified Memory driver. But if the preferred location is set as device memory, then the page will continue
5242 /// to thrash indefinitely. If [cudaMemAdviseSetReadMostly](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5243 /// 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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857441d911811beda174627f403142d5ff0). If the memory region refers to valid system-allocated pageable memory, and [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) then [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must be a valid device that has a non-zero alue for the device attribute [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f).
5244 ///
5245 /// * [cudaMemAdviseUnsetPreferredLocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857537caa36d8dddd3cedee0b2de7b74322): Undoes the effect of [cudaMemAdviseSetPreferredLocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c857a4a2bc3c7d218dcd9a1b425b432759eb) and changes the preferred location to none. The location argument is ignored for this advice.
5246 ///
5247 /// * [cudaMemAdviseSetAccessedBy](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggc314a8b14091f7e02a7ad15dcb36c85750a22279bce0dc29956ad4f257084623): This advice implies that the data will be accessed by processor location. The [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) must be either [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) with [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) representing a valid device ordinal or [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) and [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) will be ignored. All other location types are invalid. If [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) is a GPU, then the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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,
5248 /// it causes the data to always be mapped in the specified processor's page tables, as long as the location of the data permits
5249 /// a mapping to be established. If the data gets migrated for any reason, the mappings are updated accordingly. This advice is
5250 /// recommended in scenarios where data locality is not important, but avoiding faults is. Consider for example a system containing
5251 /// multiple GPUs with peer-to-peer access enabled, where the data located on one GPU is occasionally accessed by peer GPUs. In
5252 /// such scenarios, migrating data over to the other GPUs is not as important because the accesses are infrequent and the overhead
5253 /// of migration may be too high. But preventing faults can still help improve performance, and so having a mapping set up in
5254 /// advance is useful. Note that on CPU access of this data, the data may be migrated to host memory because the CPU typically
5255 /// cannot access device memory directly. Any GPU that had the [cudaMemAdviseSetAccessedBy](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5256 /// 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](https://docs.nvidia.com/cuda/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](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) then device in [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must have a non-zero value for the device attribute [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f). Additionally, if [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) has a non-zero value for the device attribute [cudaDevAttrPageableMemoryAccessUsesHostPageTables](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc228cf8983c97d0e035da72a71494eaa), then this call has no effect.
5257 ///
5258 /// * [CU_MEM_ADVISE_UNSET_ACCESSED_BY](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1ggcfe2ed2d4567745dd4ad41034136fff3f8118635c5f39d76432654ec13a726a5): Undoes the effect of [cudaMemAdviseSetAccessedBy](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5259 /// pageable memory, and [cudaMemLocation::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_16df2243c9f48e48ad92306df676b2fe0) is [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) then device in [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) must have a non-zero value for the device attribute [cudaDevAttrPageableMemoryAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cddc80992427a92713e699953a6d249d6f). Additionally, if [cudaMemLocation::id](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemLocation.html#structcudaMemLocation_11c914cd5c3cc7323b4fde9756458efb0) has a non-zero value for the device attribute [cudaDevAttrPageableMemoryAccessUsesHostPageTables](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc228cf8983c97d0e035da72a71494eaa), then this call has no effect.
5260 ///
5261 /// Note:
5262 ///
5263 /// * Note that this function may also return error codes from previous, asynchronous launches.
5264 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
5265 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
5266 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5267 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5268 ///
5269 /// **See also:**
5270 ///
5271 /// [`cudaMemcpy`], [`cudaMemcpyPeer`], [`cudaMemcpyAsync`], [`cudaMemcpy3DPeerAsync`], [`cudaMemPrefetchAsync`], [cuMemAdvise](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1gaac8924b2f5a2a93f8775fb81c1a643f).
5272 ///
5273 /// # Parameters
5274 ///
5275 /// - `devPtr`: Pointer to memory to set the advice for.
5276 /// - `count`: Size in bytes of the memory range.
5277 /// - `advice`: Advice to be applied for the specified memory range.
5278 /// - `location`: location to apply the advice for.
5279 pub fn cudaMemAdvise(
5280 devPtr: *const ::core::ffi::c_void,
5281 count: size_t,
5282 advice: cudaMemoryAdvise,
5283 location: cudaMemLocation,
5284 ) -> cudaError_t;
5285}
5286unsafe extern "C" {
5287 /// Query an attribute of a given memory range.
5288 ///
5289 /// Query an attribute about the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via [`cudaMallocManaged`] or declared via __managed__ variables.
5290 ///
5291 /// The attribute parameter can take the following values:
5292 ///
5293 /// * [cudaMemRangeAttributeReadMostly](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
5294 /// * [cudaMemRangeAttributePreferredLocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5295 /// location, or it will be cudaCpuDeviceId if all pages in the memory range have the CPU as their preferred location, or it will
5296 /// be cudaInvalidDeviceId if either all the pages don't have the same preferred location or some of the pages don't have a preferred
5297 /// location at all. Note that the actual location of the pages in the memory range at the time of the query may be different
5298 /// from the preferred location.
5299 /// * [cudaMemRangeAttributeAccessedBy](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5300 /// for that entire memory range. If any device does not have that advice set for the entire memory range, that device will not
5301 /// be included. If data is larger than the number of devices that have that advice set for that memory range, cudaInvalidDeviceId will be returned
5302 /// 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
5303 /// }. 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
5304 /// the array. There is no guarantee on which specific devices will be returned, however.
5305 /// * [cudaMemRangeAttributeLastPrefetchLocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5306 /// 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
5307 /// respectively. If any page in the memory range was never explicitly prefetched or if all pages were not prefetched to the same
5308 /// location, cudaInvalidDeviceId will be returned. Note that this simply returns the last location that the applicaton requested
5309 /// to prefetch the memory range to. It gives no indication as to whether the prefetch operation to that location has completed
5310 /// or even begun.
5311 /// * [cudaMemRangeAttributePreferredLocationType](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a379f2a7a75f029a9066e3cfea932c4870da): If this attribute is specified, data will be interpreted as a `cudaMemLocationType`, and dataSize must be sizeof(cudaMemLocationType). The `cudaMemLocationType` returned will be [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) if all pages in the memory range have the same GPU as their preferred location, or `cudaMemLocationType` will be [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) if all pages in the memory range have the CPU as their preferred location, or or it will be [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5312 /// 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.
5313 /// 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
5314 /// location type.
5315 /// + [cudaMemRangeAttributePreferredLocationId](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a379f2a7a75f029a9066e3cfea932c4870da) query for the same address range returns [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), it will be a valid device ordinal or if it returns [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
5316 /// * [cudaMemRangeAttributeLastPrefetchLocationType](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a379f68f9fab3cfdeb75d08e8b129bdd6762): If this attribute is specified, data will be interpreted as a `cudaMemLocationType`, and dataSize must be sizeof(cudaMemLocationType). The result returned will be the last location type to which all pages in the memory
5317 /// range were prefetched explicitly via [cuMemPrefetchAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1g45c0e085febc3be8fabf5c526355b6a3). The `cudaMemLocationType` returned will be [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) if the last prefetch location was the GPU or [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) if it was the CPU or [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5318 /// or if all pages were not prefetched to the same location, [CUmemLocationType](https://docs.nvidia.com/cuda/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
5319 /// prefetch the memory range to. It gives no indication as to whether the prefetch operation to that location has completed or
5320 /// even begun.
5321 /// + [cudaMemRangeAttributeLastPrefetchLocationId](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a379f68f9fab3cfdeb75d08e8b129bdd6762) query for the same address range returns [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), it will be a valid device ordinal or if it returns [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
5322 ///
5323 /// Note:
5324 ///
5325 /// * Note that this function may also return error codes from previous, asynchronous launches.
5326 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
5327 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
5328 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5329 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5330 ///
5331 /// **See also:**
5332 ///
5333 /// [`cudaMemRangeGetAttributes`], [`cudaMemPrefetchAsync`], [`cudaMemAdvise`], [cuMemRangeGetAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1g1c92408a7d0d8875e19b1a58af56f67d).
5334 ///
5335 /// # Parameters
5336 ///
5337 /// - `data`: A pointers to a memory location where the result of each attribute query will be written to.
5338 /// - `dataSize`: Array containing the size of data.
5339 /// - `attribute`: The attribute to query.
5340 /// - `devPtr`: Start of the range to query.
5341 /// - `count`: Size of the range to query.
5342 pub fn cudaMemRangeGetAttribute(
5343 data: *mut ::core::ffi::c_void,
5344 dataSize: size_t,
5345 attribute: cudaMemRangeAttribute,
5346 devPtr: *const ::core::ffi::c_void,
5347 count: size_t,
5348 ) -> cudaError_t;
5349}
5350unsafe extern "C" {
5351 /// Query attributes of a given memory range.
5352 ///
5353 /// Query attributes of the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via [`cudaMallocManaged`] or declared via __managed__ variables. The attributes array will be interpreted to have numAttributes entries. The dataSizes array will also be interpreted to have numAttributes entries. The results of the query will be stored in data.
5354 ///
5355 /// The list of supported attributes are given below. Please refer to [`cudaMemRangeGetAttribute`] for attribute descriptions and restrictions.
5356 ///
5357 /// * [cudaMemRangeAttributeReadMostly](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3794afd2109d3b8be3e1dd0fdfeed1275ee)
5358 /// * [cudaMemRangeAttributePreferredLocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a37946c596738ff234fa4c82859349e698f7)
5359 /// * [cudaMemRangeAttributeAccessedBy](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3790cbc6164d35671ca02e1b0813a8b7b20)
5360 /// * [cudaMemRangeAttributeLastPrefetchLocation](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggdfcc848da2b9f49661333f861ad1a3794e9e1521833d7ff0a4dcfbd2f6304592)
5361 /// * :: cudaMemRangeAttributePreferredLocationType
5362 /// * :: cudaMemRangeAttributePreferredLocationId
5363 /// * :: cudaMemRangeAttributeLastPrefetchLocationType
5364 /// * :: cudaMemRangeAttributeLastPrefetchLocationId
5365 ///
5366 /// Note:
5367 ///
5368 /// * Note that this function may also return error codes from previous, asynchronous launches.
5369 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5370 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5371 ///
5372 /// **See also:**
5373 ///
5374 /// [`cudaMemRangeGetAttribute`], [`cudaMemAdvise`], [`cudaMemPrefetchAsync`], [cuMemRangeGetAttributes](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1gc7ce142e60f8613cfb7d722b87dc9d12).
5375 ///
5376 /// # Parameters
5377 ///
5378 /// - `data`: A two-dimensional array containing pointers to memory locations where the result of each attribute query will be written
5379 /// ```text
5380 /// to.
5381 /// ```
5382 /// - `dataSizes`: Array containing the sizes of each result.
5383 /// - `attributes`: An array of attributes to query (numAttributes and the number of attributes in this array should match).
5384 /// - `numAttributes`: Number of attributes to query.
5385 /// - `devPtr`: Start of the range to query.
5386 /// - `count`: Size of the range to query.
5387 pub fn cudaMemRangeGetAttributes(
5388 data: *mut *mut ::core::ffi::c_void,
5389 dataSizes: *mut size_t,
5390 attributes: *mut cudaMemRangeAttribute,
5391 numAttributes: size_t,
5392 devPtr: *const ::core::ffi::c_void,
5393 count: size_t,
5394 ) -> cudaError_t;
5395}
5396unsafe extern "C" {
5397 /// Copies data between host and device.
5398 ///
5399 /// count
5400 ///
5401 /// src
5402 ///
5403 /// dst
5404 ///
5405 /// hOffset
5406 ///
5407 /// wOffset
5408 ///
5409 /// kind
5410 ///
5411 /// [`cudaMemcpyKind::cudaMemcpyHostToHost`]
5412 ///
5413 /// [`cudaMemcpyKind::cudaMemcpyHostToDevice`]
5414 ///
5415 /// [`cudaMemcpyKind::cudaMemcpyDeviceToHost`]
5416 ///
5417 /// [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`]
5418 ///
5419 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5420 ///
5421 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5422 ///
5423 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5424 ///
5425 /// Note:
5426 ///
5427 /// * Note that this function may also return error codes from previous, asynchronous launches.
5428 /// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
5429 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5430 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5431 ///
5432 /// **See also:**
5433 ///
5434 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpyHtoA](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g57d3d780d165ecc0e3b3ce08e141cd89), [cuMemcpyDtoA](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gad6827247af91600b56ce6e2ddb802e1).
5435 ///
5436 /// # Parameters
5437 ///
5438 /// - `dst`: Destination memory address.
5439 /// - `wOffset`: Destination starting X offset (columns in bytes).
5440 /// - `hOffset`: Destination starting Y offset (rows).
5441 /// - `src`: Source memory address.
5442 /// - `count`: Size in bytes to copy.
5443 /// - `kind`: Type of transfer.
5444 #[deprecated]
5445 pub fn cudaMemcpyToArray(
5446 dst: cudaArray_t,
5447 wOffset: size_t,
5448 hOffset: size_t,
5449 src: *const ::core::ffi::c_void,
5450 count: size_t,
5451 kind: cudaMemcpyKind,
5452 ) -> cudaError_t;
5453}
5454unsafe extern "C" {
5455 /// Copies data between host and device.
5456 ///
5457 /// count
5458 ///
5459 /// src
5460 ///
5461 /// hOffset
5462 ///
5463 /// wOffset
5464 ///
5465 /// dst
5466 ///
5467 /// kind
5468 ///
5469 /// [`cudaMemcpyKind::cudaMemcpyHostToHost`]
5470 ///
5471 /// [`cudaMemcpyKind::cudaMemcpyHostToDevice`]
5472 ///
5473 /// [`cudaMemcpyKind::cudaMemcpyDeviceToHost`]
5474 ///
5475 /// [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`]
5476 ///
5477 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5478 ///
5479 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5480 ///
5481 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5482 ///
5483 /// Note:
5484 ///
5485 /// * Note that this function may also return error codes from previous, asynchronous launches.
5486 /// * This function exhibits [synchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-sync) behavior for most use cases.
5487 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5488 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5489 ///
5490 /// **See also:**
5491 ///
5492 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpyAtoH](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf7ad1edb2539cccc352c6b8b76f657f4), [cuMemcpyAtoD](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g825b3f037f7f51382cae991bae8173fd).
5493 ///
5494 /// # Parameters
5495 ///
5496 /// - `dst`: Destination memory address.
5497 /// - `src`: Source memory address.
5498 /// - `wOffset`: Source starting X offset (columns in bytes).
5499 /// - `hOffset`: Source starting Y offset (rows).
5500 /// - `count`: Size in bytes to copy.
5501 /// - `kind`: Type of transfer.
5502 #[deprecated]
5503 pub fn cudaMemcpyFromArray(
5504 dst: *mut ::core::ffi::c_void,
5505 src: cudaArray_const_t,
5506 wOffset: size_t,
5507 hOffset: size_t,
5508 count: size_t,
5509 kind: cudaMemcpyKind,
5510 ) -> cudaError_t;
5511}
5512unsafe extern "C" {
5513 /// Copies data between host and device.
5514 ///
5515 /// count
5516 ///
5517 /// src
5518 ///
5519 /// hOffsetSrc
5520 ///
5521 /// wOffsetSrc
5522 ///
5523 /// dst
5524 ///
5525 /// hOffsetDst
5526 ///
5527 /// wOffsetDst
5528 ///
5529 /// kind
5530 ///
5531 /// [`cudaMemcpyKind::cudaMemcpyHostToHost`]
5532 ///
5533 /// [`cudaMemcpyKind::cudaMemcpyHostToDevice`]
5534 ///
5535 /// [`cudaMemcpyKind::cudaMemcpyDeviceToHost`]
5536 ///
5537 /// [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`]
5538 ///
5539 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5540 ///
5541 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5542 ///
5543 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5544 ///
5545 /// Note:
5546 ///
5547 /// * Note that this function may also return error codes from previous, asynchronous launches.
5548 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5549 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5550 ///
5551 /// **See also:**
5552 ///
5553 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpyAtoA](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gf81b218c984a31436ec9e23a85fb604a).
5554 ///
5555 /// # Parameters
5556 ///
5557 /// - `dst`: Destination memory address.
5558 /// - `wOffsetDst`: Destination starting X offset (columns in bytes).
5559 /// - `hOffsetDst`: Destination starting Y offset (rows).
5560 /// - `src`: Source memory address.
5561 /// - `wOffsetSrc`: Source starting X offset (columns in bytes).
5562 /// - `hOffsetSrc`: Source starting Y offset (rows).
5563 /// - `count`: Size in bytes to copy.
5564 /// - `kind`: Type of transfer.
5565 #[deprecated]
5566 pub fn cudaMemcpyArrayToArray(
5567 dst: cudaArray_t,
5568 wOffsetDst: size_t,
5569 hOffsetDst: size_t,
5570 src: cudaArray_const_t,
5571 wOffsetSrc: size_t,
5572 hOffsetSrc: size_t,
5573 count: size_t,
5574 kind: cudaMemcpyKind,
5575 ) -> cudaError_t;
5576}
5577unsafe extern "C" {
5578 /// Copies data between host and device.
5579 ///
5580 /// count
5581 ///
5582 /// src
5583 ///
5584 /// dst
5585 ///
5586 /// hOffset
5587 ///
5588 /// wOffset
5589 ///
5590 /// kind
5591 ///
5592 /// [`cudaMemcpyKind::cudaMemcpyHostToHost`]
5593 ///
5594 /// [`cudaMemcpyKind::cudaMemcpyHostToDevice`]
5595 ///
5596 /// [`cudaMemcpyKind::cudaMemcpyDeviceToHost`]
5597 ///
5598 /// [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`]
5599 ///
5600 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5601 ///
5602 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5603 ///
5604 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5605 ///
5606 /// [`cudaMemcpyToArrayAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be
5607 /// associated to a stream by passing a non-zero stream argument. If kind is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and stream is non-zero, the copy may overlap with operations in other streams.
5608 ///
5609 /// Note:
5610 ///
5611 /// * Note that this function may also return error codes from previous, asynchronous launches.
5612 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
5613 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
5614 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5615 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5616 ///
5617 /// **See also:**
5618 ///
5619 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpyFromArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpyHtoAAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gb5c4863f64f132b4bc2661818b3fd188), [cuMemcpy2DAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
5620 ///
5621 /// # Parameters
5622 ///
5623 /// - `dst`: Destination memory address.
5624 /// - `wOffset`: Destination starting X offset (columns in bytes).
5625 /// - `hOffset`: Destination starting Y offset (rows).
5626 /// - `src`: Source memory address.
5627 /// - `count`: Size in bytes to copy.
5628 /// - `kind`: Type of transfer.
5629 /// - `stream`: Stream identifier.
5630 #[deprecated]
5631 pub fn cudaMemcpyToArrayAsync(
5632 dst: cudaArray_t,
5633 wOffset: size_t,
5634 hOffset: size_t,
5635 src: *const ::core::ffi::c_void,
5636 count: size_t,
5637 kind: cudaMemcpyKind,
5638 stream: cudaStream_t,
5639 ) -> cudaError_t;
5640}
5641unsafe extern "C" {
5642 /// Copies data between host and device.
5643 ///
5644 /// count
5645 ///
5646 /// src
5647 ///
5648 /// hOffset
5649 ///
5650 /// wOffset
5651 ///
5652 /// dst
5653 ///
5654 /// kind
5655 ///
5656 /// [`cudaMemcpyKind::cudaMemcpyHostToHost`]
5657 ///
5658 /// [`cudaMemcpyKind::cudaMemcpyHostToDevice`]
5659 ///
5660 /// [`cudaMemcpyKind::cudaMemcpyDeviceToHost`]
5661 ///
5662 /// [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`]
5663 ///
5664 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5665 ///
5666 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5667 ///
5668 /// [`cudaMemcpyKind::cudaMemcpyDefault`]
5669 ///
5670 /// [`cudaMemcpyFromArrayAsync`] is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be
5671 /// associated to a stream by passing a non-zero stream argument. If kind is [`cudaMemcpyKind::cudaMemcpyHostToDevice`] or [`cudaMemcpyKind::cudaMemcpyDeviceToHost`] and stream is non-zero, the copy may overlap with operations in other streams.
5672 ///
5673 /// Note:
5674 ///
5675 /// * Note that this function may also return error codes from previous, asynchronous launches.
5676 /// * This function exhibits [asynchronous](https://docs.nvidia.com/cuda/cuda-runtime-api/api-sync-behavior.html#api-sync-behavior__memcpy-async) behavior for most use cases.
5677 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
5678 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5679 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5680 ///
5681 /// **See also:**
5682 ///
5683 /// [`cudaMemcpy`], [`cudaMemcpy2D`], [`cudaMemcpyToArray`], [`cudaMemcpy2DToArray`], [`cudaMemcpyFromArray`], [`cudaMemcpy2DFromArray`], [`cudaMemcpyArrayToArray`], [`cudaMemcpy2DArrayToArray`], [`cudaMemcpyToSymbol`], [`cudaMemcpyFromSymbol`], [`cudaMemcpyAsync`], [`cudaMemcpy2DAsync`], [`cudaMemcpyToArrayAsync`], [`cudaMemcpy2DToArrayAsync`], [`cudaMemcpy2DFromArrayAsync`], [`cudaMemcpyToSymbolAsync`], [`cudaMemcpyFromSymbolAsync`], [cuMemcpyAtoHAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g64cbd2e60436699aebdd0bdbf14d0f01), [cuMemcpy2DAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1g4acf155faeb969d9d21f5433d3d0f274).
5684 ///
5685 /// # Parameters
5686 ///
5687 /// - `dst`: Destination memory address.
5688 /// - `src`: Source memory address.
5689 /// - `wOffset`: Source starting X offset (columns in bytes).
5690 /// - `hOffset`: Source starting Y offset (rows).
5691 /// - `count`: Size in bytes to copy.
5692 /// - `kind`: Type of transfer.
5693 /// - `stream`: Stream identifier.
5694 #[deprecated]
5695 pub fn cudaMemcpyFromArrayAsync(
5696 dst: *mut ::core::ffi::c_void,
5697 src: cudaArray_const_t,
5698 wOffset: size_t,
5699 hOffset: size_t,
5700 count: size_t,
5701 kind: cudaMemcpyKind,
5702 stream: cudaStream_t,
5703 ) -> cudaError_t;
5704}
5705unsafe extern "C" {
5706 /// # Parameters
5707 ///
5708 /// - `devPtr`: Returned device pointer.
5709 /// - `size`: Number of bytes to allocate.
5710 /// - `hStream`: The stream establishing the stream ordering contract and the memory pool to allocate from.
5711 pub fn cudaMallocAsync(
5712 devPtr: *mut *mut ::core::ffi::c_void,
5713 size: size_t,
5714 hStream: cudaStream_t,
5715 ) -> cudaError_t;
5716}
5717unsafe extern "C" {
5718 /// Frees memory with stream ordered semantics.
5719 ///
5720 /// 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
5721 /// from any subsequent work launched on the GPU or querying its pointer attributes results in undefined behavior.
5722 ///
5723 /// Note:
5724 ///
5725 /// During stream capture, this function results in the creation of a free node and must therefore be passed the address of a
5726 /// graph allocation.
5727 ///
5728 /// Note:
5729 ///
5730 /// * Note that this function may also return error codes from previous, asynchronous launches.
5731 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
5732 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
5733 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5734 ///
5735 /// **See also:**
5736 ///
5737 /// [cuMemFreeAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g41acf4131f672a2a75cd93d3241f10cf), [`cudaMallocAsync`]
5738 ///
5739 /// # Parameters
5740 ///
5741 /// - `hStream`: The stream establishing the stream ordering promise.
5742 pub fn cudaFreeAsync(
5743 devPtr: *mut ::core::ffi::c_void,
5744 hStream: cudaStream_t,
5745 ) -> cudaError_t;
5746}
5747unsafe extern "C" {
5748 /// Tries to release memory back to the OS.
5749 ///
5750 /// Releases memory back to the OS until the pool contains fewer than minBytesToKeep reserved bytes, or there is no more memory
5751 /// that the allocator can safely release. The allocator cannot release OS allocations that back outstanding asynchronous allocations.
5752 /// The OS allocations may happen at different granularity from the user allocations.
5753 ///
5754 /// Note:
5755 ///
5756 /// * : Allocations that have not been freed count as outstanding.
5757 /// * : Allocations that have been asynchronously freed but whose completion has not been observed on the host (eg. by a synchronize)
5758 /// can count as outstanding.
5759 ///
5760 /// Note:
5761 ///
5762 /// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5763 ///
5764 /// **See also:**
5765 ///
5766 /// [cuMemPoolTrimTo](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g9c7e267e3460945b0ca76c48314bb669), [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`].
5767 ///
5768 /// # Parameters
5769 ///
5770 /// - `minBytesToKeep`: If the pool has less than minBytesToKeep reserved, the TrimTo operation is a no-op. Otherwise the pool will be guaranteed
5771 /// to have at least minBytesToKeep bytes reserved after the operation.
5772 pub fn cudaMemPoolTrimTo(
5773 memPool: cudaMemPool_t,
5774 minBytesToKeep: size_t,
5775 ) -> cudaError_t;
5776}
5777unsafe extern "C" {
5778 /// Sets attributes of a memory pool.
5779 ///
5780 /// Supported attributes are:
5781 ///
5782 /// * [cudaMemPoolAttrReleaseThreshold](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
5783 /// When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory
5784 /// back to the OS on the next call to stream, event or context synchronize. (default 0)
5785 /// * [cudaMemPoolReuseFollowEventDependencies](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03d75287b5752ea45a3d98b9a339f797ce): (value type = int) Allow [`cudaMallocAsync`] to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on
5786 /// the free action exists. CUDA events and null stream interactions can create the required stream ordered dependencies. (default
5787 /// enabled)
5788 /// * [cudaMemPoolReuseAllowOpportunistic](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03858390d544051a61033a05e1a4005d01): (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default
5789 /// enabled)
5790 /// * [cudaMemPoolReuseAllowInternalDependencies](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a031a545a7d23c103583900e784360f9d2a): (value type = int) Allow [`cudaMallocAsync`] to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released
5791 /// by [`cudaFreeAsync`] (default enabled).
5792 /// * [cudaMemPoolAttrReservedMemHigh](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5793 /// pool. It is illegal to set this attribute to a non-zero value.
5794 /// * [cudaMemPoolAttrUsedMemHigh](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5795 /// pool. It is illegal to set this attribute to a non-zero value.
5796 ///
5797 /// Note:
5798 ///
5799 /// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5800 ///
5801 /// **See also:**
5802 ///
5803 /// [cuMemPoolSetAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g223e786cb217709235a06e41bccaec00), [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`].
5804 ///
5805 /// # Parameters
5806 ///
5807 /// - `attr`: The attribute to modify.
5808 /// - `value`: Pointer to the value to assign.
5809 pub fn cudaMemPoolSetAttribute(
5810 memPool: cudaMemPool_t,
5811 attr: cudaMemPoolAttr,
5812 value: *mut ::core::ffi::c_void,
5813 ) -> cudaError_t;
5814}
5815unsafe extern "C" {
5816 /// Gets attributes of a memory pool.
5817 ///
5818 /// Supported attributes are:
5819 ///
5820 /// * [cudaMemPoolAttrReleaseThreshold](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
5821 /// When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory
5822 /// back to the OS on the next call to stream, event or context synchronize. (default 0)
5823 /// * [cudaMemPoolReuseFollowEventDependencies](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03d75287b5752ea45a3d98b9a339f797ce): (value type = int) Allow [`cudaMallocAsync`] to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on
5824 /// the free action exists. CUDA events and null stream interactions can create the required stream ordered dependencies. (default
5825 /// enabled)
5826 /// * [cudaMemPoolReuseAllowOpportunistic](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03858390d544051a61033a05e1a4005d01): (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default
5827 /// enabled)
5828 /// * [cudaMemPoolReuseAllowInternalDependencies](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a031a545a7d23c103583900e784360f9d2a): (value type = int) Allow [`cudaMallocAsync`] to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released
5829 /// by [`cudaFreeAsync`] (default enabled).
5830 /// * [cudaMemPoolAttrReservedMemCurrent](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03accd25158875da327b34d1ee63847b02): (value type = cuuint64_t) Amount of backing memory currently allocated for the mempool.
5831 /// * [cudaMemPoolAttrReservedMemHigh](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a035cd74d683873f75a8b4bd27b7511d9fc): (value type = cuuint64_t) High watermark of backing memory allocated for the mempool since the last time it was reset.
5832 /// * [cudaMemPoolAttrUsedMemCurrent](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03627447991490641c9fcacbfe7b54c5a4): (value type = cuuint64_t) Amount of memory from the pool that is currently in use by the application.
5833 /// * [cudaMemPoolAttrUsedMemHigh](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5834 /// the last time it was reset.
5835 ///
5836 /// The following properties can be also be queried on imported and default pools:
5837 ///
5838 /// * [cudaMemPoolAttrAllocationType](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03eedb98c7c000df951f3d36501a829311): (value type = cudaMemAllocationType) The allocation type of the mempool
5839 /// * [cudaMemPoolAttrExportHandleTypes](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a0364fa069d99766b22111d97e9d3d37e1b): (value type = cudaMemAllocationHandleType) Available export handle types for the mempool. For imported pools this value
5840 /// is always cudaMemHandleTypeNone as an imported pool cannot be re-exported
5841 /// * [cudaMemPoolAttrLocationId](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a035867500cd6840751dbeca2d5ff4c638d): (value type = int) The location id for the mempool. If the location type for this pool is cudaMemLocationTypeInvisible then
5842 /// ID will be cudaInvalidDeviceId.
5843 /// * [cudaMemPoolAttrLocationType](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a03e53307bbf1d2af20fe4411ae7deba1fe): (value type = cudaMemLocationType) The location type for the mempool. For imported memory pools where the device is not
5844 /// directly visible to the importing process or pools imported via fabric handles across nodes this will be cudaMemlocataionTypeInvisible.
5845 /// * [cudaMemPoolAttrMaxPoolSize](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
5846 /// cuMemPoolCreate due to alignment requirements. A value of 0 indicates no maximum size. For cudaMemAllocationTypeManaged and
5847 /// IPC imported pools this value will be system dependent.
5848 /// * [cudaMemPoolAttrHwDecompressEnabled](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb088e985dfbf286005a684095501a032c3f8c11ad000a47eca679c2f33ce53b): (value type = int) Indicates whether the pool has hardware compresssion enabled
5849 ///
5850 /// Note:
5851 ///
5852 /// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
5853 ///
5854 /// **See also:**
5855 ///
5856 /// [cuMemPoolGetAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gd45ea7c43e4a1add4b971d06fa72eda4), [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`].
5857 ///
5858 /// # Parameters
5859 ///
5860 /// - `attr`: The attribute to get.
5861 /// - `value`: Retrieved value.
5862 pub fn cudaMemPoolGetAttribute(
5863 memPool: cudaMemPool_t,
5864 attr: cudaMemPoolAttr,
5865 value: *mut ::core::ffi::c_void,
5866 ) -> cudaError_t;
5867}
5868unsafe extern "C" {
5869 /// Controls visibility of pools between devices.
5870 ///
5871 /// **See also:**
5872 ///
5873 /// [cuMemPoolSetAccess](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gff3ce33e252443f4b087b94e42913406), [`cudaMemPoolGetAccess`], [`cudaMallocAsync`], [`cudaFreeAsync`].
5874 ///
5875 /// # Parameters
5876 ///
5877 /// - `count`: Number of descriptors in the map array.
5878 pub fn cudaMemPoolSetAccess(
5879 memPool: cudaMemPool_t,
5880 descList: *const cudaMemAccessDesc,
5881 count: size_t,
5882 ) -> cudaError_t;
5883}
5884unsafe extern "C" {
5885 /// Returns the accessibility of a pool from a device.
5886 ///
5887 /// Returns the accessibility of the pool's memory from the specified location.
5888 ///
5889 /// **See also:**
5890 ///
5891 /// [cuMemPoolGetAccess](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g838f28fd535a1cbd06c5f7fe0edbdcc7), [`cudaMemPoolSetAccess`].
5892 ///
5893 /// # Parameters
5894 ///
5895 /// - `flags`: the accessibility of the pool from the specified location.
5896 /// - `memPool`: the pool being queried.
5897 /// - `location`: the location accessing the pool.
5898 pub fn cudaMemPoolGetAccess(
5899 flags: *mut cudaMemAccessFlags,
5900 memPool: cudaMemPool_t,
5901 location: *mut cudaMemLocation,
5902 ) -> cudaError_t;
5903}
5904unsafe extern "C" {
5905 /// Creates a memory pool.
5906 ///
5907 /// 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.
5908 ///
5909 /// To create a memory pool for host memory not targeting a specific NUMA node, applications must set set cudaMemPoolProps::cudaMemLocation::type
5910 /// to [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5). cudaMemPoolProps::cudaMemLocation::id is ignored for such pools. Pools created with the type [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) are not IPC capable and [cudaMemPoolProps::handleTypes](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemPoolProps.html#structcudaMemPoolProps_14cf896bffe71384e374c4d2decca9a53) must be 0, any other values will result in [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c). To create a memory pool targeting a specific host NUMA node, applications must set cudaMemPoolProps::cudaMemLocation::type
5911 /// to [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) and cudaMemPoolProps::cudaMemLocation::id must specify the NUMA ID of the host memory node. Specifying [cudaMemLocationTypeHostNumaCurrent](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0a3925690e32332c940cb726ef56a4258) as the cudaMemPoolProps::cudaMemLocation::type will result in [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0) or [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5), their default accessibility will be from the host CPU. Applications can control the maximum size of the pool by specifying
5912 /// a non-zero value for [cudaMemPoolProps::maxSize](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemPoolProps.html#structcudaMemPoolProps_12d90e82afb8d577a2aee847d082e145d). If set to 0, the maximum size of the pool will default to a system dependent value.
5913 ///
5914 /// Applications that intend to use [CU_MEM_HANDLE_TYPE_FABRIC](https://docs.nvidia.com/cuda/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
5915 /// under /proc/devices (2) have at least one IMEX channel file accessible by the user launching the application.
5916 ///
5917 /// When exporter and importer CUDA processes have been granted access to the same IMEX channel, they can securely share memory.
5918 ///
5919 /// The IMEX channel security model works on a per user basis. Which means all processes under a user can share memory if the
5920 /// user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX channel is required for each
5921 /// user.
5922 ///
5923 /// These channel files exist in /dev/nvidia-caps-imex-channels/channel\* and can be created using standard OS native calls like
5924 /// mknod on Linux. For example: To create channel0 with the major number from /proc/devices users can execute the following command:
5925 /// `mknod /dev/nvidia-caps-imex-channels/channel0 c <major number>=""> 0`
5926 ///
5927 /// To create a managed memory pool, applications must set `cudaMemPoolProps`:cudaMemAllocationType to [`cudaMemAllocationType::cudaMemAllocationTypeManaged`]. `cudaMemAllocationHandleType` must also be set to [cudaMemHandleTypeNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggabde707dfb8a602b917e0b177f77f365fed45251c1591431e1b9da28c1a04191) since IPC is not supported. For managed memory pools, cudaMemPoolProps::cudaMemLocation will be treated as the preferred
5928 /// location for all allocations created from the pool. An application can also set [cudaMemLocationTypeNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f053b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location. [cudaMemPoolProps::maxSize](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaMemPoolProps.html#structcudaMemPoolProps_12d90e82afb8d577a2aee847d082e145d) must be set to zero for managed memory pools. [cudaMemPoolProps::usage](https://docs.nvidia.com/cuda/cuda-runtime-api/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
5929 /// have non-zero concurrentManagedAccess. If not, this call returns [cudaErrorNotSupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d846fd9f2e8ba5e2fb4f1695b7ab6164)
5930 ///
5931 /// Note:
5932 ///
5933 /// Specifying [cudaMemHandleTypeNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggabde707dfb8a602b917e0b177f77f365fed45251c1591431e1b9da28c1a04191) creates a memory pool that will not support IPC.
5934 ///
5935 /// **See also:**
5936 ///
5937 /// [cuMemPoolCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g8aa4c143dbc20293659cd883232b95f2), [`cudaDeviceSetMemPool`], [`cudaMallocFromPoolAsync`], [`cudaMemPoolExportToShareableHandle`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`].
5938 pub fn cudaMemPoolCreate(
5939 memPool: *mut cudaMemPool_t,
5940 poolProps: *const cudaMemPoolProps,
5941 ) -> cudaError_t;
5942}
5943unsafe extern "C" {
5944 /// Destroys the specified memory pool.
5945 ///
5946 /// 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
5947 /// once there are no more outstanding allocations.
5948 ///
5949 /// Destroying the current mempool of a device sets the default mempool of that device as the current mempool for that device.
5950 ///
5951 /// Note:
5952 ///
5953 /// A device's default memory pool cannot be destroyed.
5954 ///
5955 /// **See also:**
5956 ///
5957 /// [cuMemPoolDestroy](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1ge0e211115e5ad1c79250b9dd425b77f7), [`cudaFreeAsync`], [`cudaDeviceSetMemPool`], [`cudaDeviceGetDefaultMemPool`], [`cudaDeviceGetMemPool`], [`cudaMemPoolCreate`].
5958 pub fn cudaMemPoolDestroy(memPool: cudaMemPool_t) -> cudaError_t;
5959}
5960unsafe extern "C" {
5961 /// Returns the default memory pool for a given location and allocation type.
5962 ///
5963 /// The memory location can be of one of [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5), or [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0). The allocation type can be one of [`cudaMemAllocationType::cudaMemAllocationTypePinned`] or [`cudaMemAllocationType::cudaMemAllocationTypeManaged`]. When the allocation type is [`cudaMemAllocationType::cudaMemAllocationTypeManaged`], the location type can also be [cudaMemLocationTypeNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f053b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location for the managed memory pool. In all other cases, the call return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c)
5964 ///
5965 /// **See also:**
5966 ///
5967 /// [cuMemAllocAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g13413273e84a641bce1929eae9e6501f), [cuMemPoolTrimTo](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g9c7e267e3460945b0ca76c48314bb669), [cuMemPoolGetAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gd45ea7c43e4a1add4b971d06fa72eda4), [cuMemPoolSetAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g223e786cb217709235a06e41bccaec00), [cuMemPoolSetAccess](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gff3ce33e252443f4b087b94e42913406), [cuMemGetMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g5283d28ee187477e1a2b06fd731ec575), [cuMemPoolCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g8aa4c143dbc20293659cd883232b95f2).
5968 pub fn cudaMemGetDefaultMemPool(
5969 memPool: *mut cudaMemPool_t,
5970 location: *mut cudaMemLocation,
5971 type_: cudaMemAllocationType,
5972 ) -> cudaError_t;
5973}
5974unsafe extern "C" {
5975 /// Gets the current memory pool for a given memory location and allocation type.
5976 ///
5977 /// The memory location can be of one of [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5), or [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0). The allocation type can be one of [`cudaMemAllocationType::cudaMemAllocationTypePinned`] or [`cudaMemAllocationType::cudaMemAllocationTypeManaged`]. When the allocation type is [`cudaMemAllocationType::cudaMemAllocationTypeManaged`], the location type can also be [cudaMemLocationTypeNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f053b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location for the managed memory pool. In all other cases, the call return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c)
5978 ///
5979 /// 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
5980 /// for a device that can be obtained via cudaMemGetDefaultMemPool Otherwise the returned pool must have been set with [`cudaDeviceSetMemPool`].
5981 ///
5982 /// **See also:**
5983 ///
5984 /// [cuDeviceGetDefaultMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gc8bca3c97a78816303b8aa5773b741f2), [cuMemPoolCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g8aa4c143dbc20293659cd883232b95f2), [cuDeviceSetMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1g4f2f276b84d9c2eaefdc76d6274db4a0), [cuMemSetMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g779e76c810c5f088210ea907730e17c9).
5985 pub fn cudaMemGetMemPool(
5986 memPool: *mut cudaMemPool_t,
5987 location: *mut cudaMemLocation,
5988 type_: cudaMemAllocationType,
5989 ) -> cudaError_t;
5990}
5991unsafe extern "C" {
5992 /// Sets the current memory pool for a memory location and allocation type.
5993 ///
5994 /// The memory location can be of one of [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4), [cudaMemLocationTypeHost](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f01ec97ff5f3c715e4b18e39dabf9e31c5) or [cudaMemLocationTypeHostNuma](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f024dc63fb938dee27b41e3842da35d2d0). The allocation type can be one of [`cudaMemAllocationType::cudaMemAllocationTypePinned`] or [`cudaMemAllocationType::cudaMemAllocationTypeManaged`]. When the allocation type is [`cudaMemAllocationType::cudaMemAllocationTypeManaged`], the location type can also be [cudaMemLocationTypeNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f053b6266fa56e0b7efe6a0b78ed8e8f49) to indicate no preferred location for the managed memory pool. In all other cases, the call return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c)
5995 ///
5996 /// When a memory pool is set as the current memory pool, the location parameter should be the same as the location of the pool.
5997 /// If the location type or index don't match, the call returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c). The type of memory pool should also match the parameter allocType. Else the call returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c). By default, a memory location's current memory pool is its default memory pool. If the location type is [cudaMemLocationTypeDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2279aa08666f329f3ba4afe397fa60f0e479b8710f3c5270117ee9d8cf5868d4) and the allocation type is [`cudaMemAllocationType::cudaMemAllocationTypePinned`], then this API is the equivalent of calling [`cudaDeviceSetMemPool`] with the location id as the device. For further details on the implications, please refer to the documentation for [`cudaDeviceSetMemPool`].
5998 ///
5999 /// Note:
6000 ///
6001 /// Use [`cudaMallocFromPoolAsync`] to specify asynchronous allocations from a device different than the one the stream runs on.
6002 ///
6003 /// **See also:**
6004 ///
6005 /// [cuDeviceGetDefaultMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gc8bca3c97a78816303b8aa5773b741f2), [cuDeviceGetMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE.html#group__CUDA__DEVICE_1gdf186e9559d53a5eb18e572d48c1121b), [cuMemGetMemPool](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g5283d28ee187477e1a2b06fd731ec575), [cuMemPoolCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g8aa4c143dbc20293659cd883232b95f2), [cuMemPoolDestroy](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1ge0e211115e5ad1c79250b9dd425b77f7), [cuMemAllocFromPoolAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gf1dd6e1e2e8f767a5e0ea63f38ff260b).
6006 pub fn cudaMemSetMemPool(
6007 location: *mut cudaMemLocation,
6008 type_: cudaMemAllocationType,
6009 memPool: cudaMemPool_t,
6010 ) -> cudaError_t;
6011}
6012unsafe extern "C" {
6013 /// Allocates memory from a specified pool with stream ordered semantics.
6014 ///
6015 /// Inserts an allocation operation into hStream. A pointer to the allocated memory is returned immediately in \*dptr. The allocation must not be accessed until the allocation
6016 /// operation completes. The allocation comes from the specified memory pool.
6017 ///
6018 /// Note:
6019 ///
6020 /// * The specified memory pool may be from a device different than that of the specified hStream.
6021 ///
6022 /// * Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize,
6023 /// and CUDA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream
6024 /// runs.
6025 ///
6026 /// Note:
6027 ///
6028 /// During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned
6029 /// by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters.
6030 ///
6031 /// **See also:**
6032 ///
6033 /// [cuMemAllocFromPoolAsync](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gf1dd6e1e2e8f767a5e0ea63f38ff260b), [cudaMallocAsync ( C++ API)](https://docs.nvidia.com/cuda/cuda-runtime-api/high-level-api.html#group__CUDART__HIGHLEVEL_1ga31efcffc48981621feddd98d71a0feb "Allocate from a pool."), [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaDeviceGetDefaultMemPool`], [`cudaMemPoolCreate`], [`cudaMemPoolSetAccess`], [`cudaMemPoolSetAttribute`].
6034 ///
6035 /// # Parameters
6036 ///
6037 /// - `ptr`: Returned device pointer.
6038 /// - `memPool`: The pool to allocate from.
6039 /// - `stream`: The stream establishing the stream ordering semantic.
6040 pub fn cudaMallocFromPoolAsync(
6041 ptr: *mut *mut ::core::ffi::c_void,
6042 size: size_t,
6043 memPool: cudaMemPool_t,
6044 stream: cudaStream_t,
6045 ) -> cudaError_t;
6046}
6047unsafe extern "C" {
6048 /// Exports a memory pool to the requested handle type.
6049 ///
6050 /// Given an IPC capable mempool, create an OS handle to share the pool with another process. A recipient process can convert
6051 /// 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
6052 /// type.
6053 ///
6054 /// Note:
6055 ///
6056 /// : To create an IPC capable mempool, create a mempool with a CUmemAllocationHandleType other than cudaMemHandleTypeNone.
6057 ///
6058 /// **See also:**
6059 ///
6060 /// [cuMemPoolExportToShareableHandle](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g79ed285fdfffb76932871fb96fbba8f8), [`cudaMemPoolImportFromShareableHandle`], [`cudaMemPoolExportPointer`], [`cudaMemPoolImportPointer`].
6061 ///
6062 /// # Parameters
6063 ///
6064 /// - `handleType`: the type of handle to create.
6065 /// - `flags`: must be 0.
6066 pub fn cudaMemPoolExportToShareableHandle(
6067 shareableHandle: *mut ::core::ffi::c_void,
6068 memPool: cudaMemPool_t,
6069 handleType: cudaMemAllocationHandleType,
6070 flags: ::core::ffi::c_uint,
6071 ) -> cudaError_t;
6072}
6073unsafe extern "C" {
6074 /// imports a memory pool from a shared handle.
6075 ///
6076 /// Specific allocations can be imported from the imported pool with [`cudaMemPoolImportPointer`].
6077 ///
6078 /// Note:
6079 ///
6080 /// Imported memory pools do not support creating new allocations. As such imported memory pools may not be used in [`cudaDeviceSetMemPool`] or [`cudaMallocFromPoolAsync`] calls.
6081 ///
6082 /// **See also:**
6083 ///
6084 /// [cuMemPoolImportFromShareableHandle](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g02b4f18dd8a1c45b7f302800e90cec5b), [`cudaMemPoolExportToShareableHandle`], [`cudaMemPoolExportPointer`], [`cudaMemPoolImportPointer`].
6085 ///
6086 /// # Parameters
6087 ///
6088 /// - `handleType`: The type of handle being imported.
6089 /// - `flags`: must be 0.
6090 pub fn cudaMemPoolImportFromShareableHandle(
6091 memPool: *mut cudaMemPool_t,
6092 shareableHandle: *mut ::core::ffi::c_void,
6093 handleType: cudaMemAllocationHandleType,
6094 flags: ::core::ffi::c_uint,
6095 ) -> cudaError_t;
6096}
6097unsafe extern "C" {
6098 /// Export data to share a memory pool allocation between processes.
6099 ///
6100 /// Constructs shareData_out for sharing a specific allocation from an already shared memory pool. The recipient process can import the allocation with
6101 /// the [`cudaMemPoolImportPointer`] api. The data is not a handle and may be shared through any IPC mechanism.
6102 ///
6103 /// **See also:**
6104 ///
6105 /// [cuMemPoolExportPointer](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1gfe89f0478d26edaa91eb8a2e0349329d), [`cudaMemPoolExportToShareableHandle`], [`cudaMemPoolImportFromShareableHandle`], [`cudaMemPoolImportPointer`].
6106 ///
6107 /// # Parameters
6108 ///
6109 /// - `ptr`: pointer to memory being exported.
6110 pub fn cudaMemPoolExportPointer(
6111 exportData: *mut cudaMemPoolPtrExportData,
6112 ptr: *mut ::core::ffi::c_void,
6113 ) -> cudaError_t;
6114}
6115unsafe extern "C" {
6116 /// Import a memory pool allocation from another process.
6117 ///
6118 /// Returns in ptr_out a pointer to the imported memory. The imported memory must not be accessed before the allocation operation completes in the
6119 /// exporting process. The imported memory must be freed from all importing processes before being freed in the exporting process.
6120 /// 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.
6121 ///
6122 /// Note:
6123 ///
6124 /// 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`].
6125 ///
6126 /// **See also:**
6127 ///
6128 /// [cuMemPoolImportPointer](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MALLOC__ASYNC.html#group__CUDA__MALLOC__ASYNC_1g2620bb972ed5edcce312d3689454acbd), [`cudaMemPoolExportToShareableHandle`], [`cudaMemPoolImportFromShareableHandle`], [`cudaMemPoolExportPointer`].
6129 pub fn cudaMemPoolImportPointer(
6130 ptr: *mut *mut ::core::ffi::c_void,
6131 memPool: cudaMemPool_t,
6132 exportData: *mut cudaMemPoolPtrExportData,
6133 ) -> cudaError_t;
6134}
6135unsafe extern "C" {
6136 /// Returns attributes about a specified pointer.
6137 ///
6138 /// Returns in \*attributes the attributes of the pointer ptr. If pointer was not allocated in, mapped by or registered with context supporting unified addressing [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
6139 ///
6140 /// Note:
6141 ///
6142 /// In CUDA 11.0 forward passing host pointer will return [`cudaMemoryType::cudaMemoryTypeUnregistered`] in [cudaPointerAttributes::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaPointerAttributes.html#structcudaPointerAttributes_191ef95dac597cc710558dabbc8b9ae38) and call will return [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591).
6143 ///
6144 /// The [`cudaPointerAttributes`] structure is defined as:
6145 ///
6146 /// ```text
6147 /// struct cudaPointerAttributes {
6148 /// enum cudaMemoryType
6149 /// type;
6150 /// int device;
6151 /// void *devicePointer;
6152 /// void *hostPointer;
6153 /// }
6154 /// ```
6155 ///
6156 /// * [cudaPointerAttributes::type](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaPointerAttributes.html#structcudaPointerAttributes_191ef95dac597cc710558dabbc8b9ae38) identifies type of memory. It can be [`cudaMemoryType::cudaMemoryTypeUnregistered`] for unregistered host memory, [`cudaMemoryType::cudaMemoryTypeHost`] for registered host memory, [`cudaMemoryType::cudaMemoryTypeDevice`] for device memory or [`cudaMemoryType::cudaMemoryTypeManaged`] for managed memory.
6157 ///
6158 /// * [device](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaPointerAttributes.html#structcudaPointerAttributes_120015540684b0c85e0debf64923bedec) is the device against which ptr was allocated. If ptr has memory type [`cudaMemoryType::cudaMemoryTypeDevice`] then this identifies the device on which the memory referred to by ptr physically resides. If ptr has memory type [`cudaMemoryType::cudaMemoryTypeHost`] then this identifies the device which was current when the allocation was made (and if that device is deinitialized then
6159 /// this allocation will vanish with that device's state).
6160 ///
6161 /// * [devicePointer](https://docs.nvidia.com/cuda/cuda-runtime-api/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.
6162 ///
6163 /// * [hostPointer](https://docs.nvidia.com/cuda/cuda-runtime-api/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.
6164 ///
6165 /// Note:
6166 ///
6167 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6168 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6169 ///
6170 /// **See also:**
6171 ///
6172 /// [`cudaGetDeviceCount`], [`cudaGetDevice`], [`cudaSetDevice`], [`cudaChooseDevice`], [`cudaInitDevice`], [cuPointerGetAttributes](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1gf65e9ea532e311dd049166e4894955ad).
6173 ///
6174 /// # Parameters
6175 ///
6176 /// - `attributes`: Attributes for the specified pointer.
6177 /// - `ptr`: Pointer to get attributes for.
6178 pub fn cudaPointerGetAttributes(
6179 attributes: *mut cudaPointerAttributes,
6180 ptr: *const ::core::ffi::c_void,
6181 ) -> cudaError_t;
6182}
6183unsafe extern "C" {
6184 /// Queries if a device may directly access a peer device's memory.
6185 ///
6186 /// 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`].
6187 ///
6188 /// Note:
6189 ///
6190 /// * Note that this function may also return error codes from previous, asynchronous launches.
6191 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6192 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6193 ///
6194 /// **See also:**
6195 ///
6196 /// [`cudaDeviceEnablePeerAccess`], [`cudaDeviceDisablePeerAccess`], [cuDeviceCanAccessPeer](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g496bdaae1f632ebfb695b99d2c40f19e).
6197 ///
6198 /// # Parameters
6199 ///
6200 /// - `canAccessPeer`: Returned access capability.
6201 /// - `device`: Device from which allocations on peerDevice are to be directly accessed.
6202 /// - `peerDevice`: Device on which the allocations to be directly accessed by device reside.
6203 pub fn cudaDeviceCanAccessPeer(
6204 canAccessPeer: *mut ::core::ffi::c_int,
6205 device: ::core::ffi::c_int,
6206 peerDevice: ::core::ffi::c_int,
6207 ) -> cudaError_t;
6208}
6209unsafe extern "C" {
6210 /// Enables direct access to memory allocations on a peer device.
6211 ///
6212 /// On success, all allocations from peerDevice will immediately be accessible by the current device. They will remain accessible until access is explicitly disabled using
6213 /// [`cudaDeviceDisablePeerAccess`] or either device is reset using [`cudaDeviceReset`].
6214 ///
6215 /// 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.
6216 ///
6217 /// Note that there are both device-wide and system-wide limitations per system configuration, as noted in the CUDA Programming
6218 /// Guide under the section "Peer-to-Peer Memory Access".
6219 ///
6220 /// Returns [cudaErrorInvalidDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038938c6e8b96ecde62e3ab5137156f739a) if [`cudaDeviceCanAccessPeer`] indicates that the current device cannot directly access memory from peerDevice.
6221 ///
6222 /// Returns [cudaErrorPeerAccessAlreadyEnabled](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00380bc28e8217afa14b95f907631cb84f33) if direct access of peerDevice from the current device has already been enabled.
6223 ///
6224 /// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if flags is not 0.
6225 ///
6226 /// Note:
6227 ///
6228 /// * Note that this function may also return error codes from previous, asynchronous launches.
6229 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6230 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6231 ///
6232 /// **See also:**
6233 ///
6234 /// [`cudaDeviceCanAccessPeer`], [`cudaDeviceDisablePeerAccess`], [cuCtxEnablePeerAccess](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g0889ec6728e61c05ed359551d67b3f5a).
6235 ///
6236 /// # Parameters
6237 ///
6238 /// - `peerDevice`: Peer device to enable direct access to from the current device.
6239 /// - `flags`: Reserved for future use and must be set to 0.
6240 pub fn cudaDeviceEnablePeerAccess(
6241 peerDevice: ::core::ffi::c_int,
6242 flags: ::core::ffi::c_uint,
6243 ) -> cudaError_t;
6244}
6245unsafe extern "C" {
6246 /// Disables direct access to memory allocations on a peer device.
6247 ///
6248 /// Returns [cudaErrorPeerAccessNotEnabled](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038821b54bce59b87db6efc2ea59a867bf7) if direct access to memory on peerDevice has not yet been enabled from the current device.
6249 ///
6250 /// Note:
6251 ///
6252 /// * Note that this function may also return error codes from previous, asynchronous launches.
6253 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6254 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6255 ///
6256 /// **See also:**
6257 ///
6258 /// [`cudaDeviceCanAccessPeer`], [`cudaDeviceEnablePeerAccess`], [cuCtxDisablePeerAccess](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__PEER__ACCESS.html#group__CUDA__PEER__ACCESS_1g5b4b6936ea868d4954ce4d841a3b4810).
6259 ///
6260 /// # Parameters
6261 ///
6262 /// - `peerDevice`: Peer device to disable direct access to.
6263 pub fn cudaDeviceDisablePeerAccess(peerDevice: ::core::ffi::c_int) -> cudaError_t;
6264}
6265unsafe extern "C" {
6266 /// Unregisters a graphics resource for access by CUDA.
6267 ///
6268 /// Unregisters the graphics resource resource so it is not accessible by CUDA unless registered again.
6269 ///
6270 /// If resource is invalid then [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) is returned.
6271 ///
6272 /// Note:
6273 ///
6274 /// * Note that this function may also return error codes from previous, asynchronous launches.
6275 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6276 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6277 /// * Use of the handle after this call is undefined behavior.
6278 ///
6279 /// **See also:**
6280 ///
6281 /// `cudaGraphicsD3D9RegisterResource`, `cudaGraphicsD3D10RegisterResource`, `cudaGraphicsD3D11RegisterResource`, `cudaGraphicsGLRegisterBuffer`, `cudaGraphicsGLRegisterImage`, [cuGraphicsUnregisterResource](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1ga7e5e97b74eaa13dfa6582e853e4c96d).
6282 ///
6283 /// # Parameters
6284 ///
6285 /// - `resource`: Resource to unregister.
6286 pub fn cudaGraphicsUnregisterResource(
6287 resource: cudaGraphicsResource_t,
6288 ) -> cudaError_t;
6289}
6290unsafe extern "C" {
6291 /// Set usage flags for mapping a graphics resource.
6292 ///
6293 /// Set flags for mapping the graphics resource resource.
6294 ///
6295 /// Changes to flags will take effect the next time resource is mapped. The flags argument may be any of the following:
6296 ///
6297 /// * [cudaGraphicsMapFlagsNone](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
6298 /// * [cudaGraphicsMapFlagsReadOnly](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg2c3c3a69caaf333d29d0b38b75de5ffde34096084cfafea1399b5682efd8b74c): Specifies that CUDA will not write to resource.
6299 /// * [cudaGraphicsMapFlagsWriteDiscard](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
6300 ///
6301 /// If resource is presently mapped for access by CUDA then [cudaErrorUnknown](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. If flags is not one of the above values then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
6302 ///
6303 /// Note:
6304 ///
6305 /// * Note that this function may also return error codes from previous, asynchronous launches.
6306 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6307 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6308 ///
6309 /// **See also:**
6310 ///
6311 /// [`cudaGraphicsMapResources`], [cuGraphicsResourceSetMapFlags](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1gfe96aa7747f8b11d44a6fa6a851e1b39).
6312 ///
6313 /// # Parameters
6314 ///
6315 /// - `resource`: Registered resource to set flags for.
6316 /// - `flags`: Parameters for resource mapping.
6317 pub fn cudaGraphicsResourceSetMapFlags(
6318 resource: cudaGraphicsResource_t,
6319 flags: ::core::ffi::c_uint,
6320 ) -> cudaError_t;
6321}
6322unsafe extern "C" {
6323 /// Map graphics resources for access by CUDA.
6324 ///
6325 /// Maps the count graphics resources in resources for access by CUDA.
6326 ///
6327 /// 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
6328 /// undefined.
6329 ///
6330 /// This function provides the synchronization guarantee that any graphics calls issued before [`cudaGraphicsMapResources`] will complete before any subsequent CUDA work issued in stream begins.
6331 ///
6332 /// If resources contains any duplicate entries then [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) is returned. If any of resources are presently mapped for access by CUDA then [cudaErrorUnknown](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned.
6333 ///
6334 /// Note:
6335 ///
6336 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
6337 /// * Note that this function may also return error codes from previous, asynchronous launches.
6338 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6339 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6340 ///
6341 /// **See also:**
6342 ///
6343 /// [`cudaGraphicsResourceGetMappedPointer`], [`cudaGraphicsSubResourceGetMappedArray`], [`cudaGraphicsUnmapResources`], [cuGraphicsMapResources](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1gffcfd8e78d82cc4f6dd987e8bce4edb0).
6344 ///
6345 /// # Parameters
6346 ///
6347 /// - `count`: Number of resources to map.
6348 /// - `resources`: Resources to map for CUDA.
6349 /// - `stream`: Stream for synchronization.
6350 pub fn cudaGraphicsMapResources(
6351 count: ::core::ffi::c_int,
6352 resources: *mut cudaGraphicsResource_t,
6353 stream: cudaStream_t,
6354 ) -> cudaError_t;
6355}
6356unsafe extern "C" {
6357 /// Unmap graphics resources.
6358 ///
6359 /// Unmaps the count graphics resources in resources.
6360 ///
6361 /// Once unmapped, the resources in resources may not be accessed by CUDA until they are mapped again.
6362 ///
6363 /// This function provides the synchronization guarantee that any CUDA work issued in stream before [`cudaGraphicsUnmapResources`] will complete before any subsequently issued graphics work begins.
6364 ///
6365 /// If resources contains any duplicate entries then [cudaErrorInvalidResourceHandle](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038c4673247aee4d1ab8d07871f376e0273) is returned. If any of resources are not presently mapped for access by CUDA then [cudaErrorUnknown](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned.
6366 ///
6367 /// Note:
6368 ///
6369 /// * This function uses standard [default stream](https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html#stream-sync-behavior__default-stream) semantics.
6370 /// * Note that this function may also return error codes from previous, asynchronous launches.
6371 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6372 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6373 ///
6374 /// **See also:**
6375 ///
6376 /// [`cudaGraphicsMapResources`], [cuGraphicsUnmapResources](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1g8e9ff25d071375a0df1cb5aee924af32).
6377 ///
6378 /// # Parameters
6379 ///
6380 /// - `count`: Number of resources to unmap.
6381 /// - `resources`: Resources to unmap.
6382 /// - `stream`: Stream for synchronization.
6383 pub fn cudaGraphicsUnmapResources(
6384 count: ::core::ffi::c_int,
6385 resources: *mut cudaGraphicsResource_t,
6386 stream: cudaStream_t,
6387 ) -> cudaError_t;
6388}
6389unsafe extern "C" {
6390 /// Get an device pointer through which to access a mapped graphics resource.
6391 ///
6392 /// 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.
6393 ///
6394 /// If resource is not a buffer then it cannot be accessed via a pointer and [cudaErrorUnknown](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. If resource is not mapped then [cudaErrorUnknown](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. \*
6395 ///
6396 /// Note:
6397 ///
6398 /// * Note that this function may also return error codes from previous, asynchronous launches.
6399 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6400 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6401 ///
6402 /// **See also:**
6403 ///
6404 /// [`cudaGraphicsMapResources`], [`cudaGraphicsSubResourceGetMappedArray`], [cuGraphicsResourceGetMappedPointer](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1g8a634cf4150d399f0018061580592457).
6405 ///
6406 /// # Parameters
6407 ///
6408 /// - `devPtr`: Returned pointer through which resource may be accessed.
6409 /// - `size`: Returned size of the buffer accessible starting at \*devPtr.
6410 /// - `resource`: Mapped resource to access.
6411 pub fn cudaGraphicsResourceGetMappedPointer(
6412 devPtr: *mut *mut ::core::ffi::c_void,
6413 size: *mut size_t,
6414 resource: cudaGraphicsResource_t,
6415 ) -> cudaError_t;
6416}
6417unsafe extern "C" {
6418 /// Get an array through which to access a subresource of a mapped graphics resource.
6419 ///
6420 /// 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.
6421 ///
6422 /// If resource is not a texture then it cannot be accessed via an array and [cudaErrorUnknown](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. If arrayIndex is not a valid array index for resource then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned. If mipLevel is not a valid mipmap level for resource then [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned. If resource is not mapped then [cudaErrorUnknown](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned.
6423 ///
6424 /// Note:
6425 ///
6426 /// * Note that this function may also return error codes from previous, asynchronous launches.
6427 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6428 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6429 ///
6430 /// **See also:**
6431 ///
6432 /// [`cudaGraphicsResourceGetMappedPointer`], [cuGraphicsSubResourceGetMappedArray](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1g61c55e987e54558cce547240d6123078).
6433 ///
6434 /// # Parameters
6435 ///
6436 /// - `array`: Returned array through which a subresource of resource may be accessed.
6437 /// - `resource`: Mapped resource to access.
6438 /// - `arrayIndex`: Array index for array textures or cubemap face index as defined by `cudaGraphicsCubeFace` for cubemap textures for the subresource to access.
6439 /// - `mipLevel`: Mipmap level for the subresource to access.
6440 pub fn cudaGraphicsSubResourceGetMappedArray(
6441 array: *mut cudaArray_t,
6442 resource: cudaGraphicsResource_t,
6443 arrayIndex: ::core::ffi::c_uint,
6444 mipLevel: ::core::ffi::c_uint,
6445 ) -> cudaError_t;
6446}
6447unsafe extern "C" {
6448 /// Get a mipmapped array through which to access a mapped graphics resource.
6449 ///
6450 /// 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.
6451 ///
6452 /// If resource is not a texture then it cannot be accessed via an array and [cudaErrorUnknown](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned. If resource is not mapped then [cudaErrorUnknown](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00382e491daacef266c7b3e3c1e140a6133c) is returned.
6453 ///
6454 /// Note:
6455 ///
6456 /// * Note that this function may also return error codes from previous, asynchronous launches.
6457 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6458 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6459 ///
6460 /// **See also:**
6461 ///
6462 /// [`cudaGraphicsResourceGetMappedPointer`], [cuGraphicsResourceGetMappedMipmappedArray](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GRAPHICS.html#group__CUDA__GRAPHICS_1g37680bbe89c7fe5c613563eaab9d14c1).
6463 ///
6464 /// # Parameters
6465 ///
6466 /// - `mipmappedArray`: Returned mipmapped array through which resource may be accessed.
6467 /// - `resource`: Mapped resource to access.
6468 pub fn cudaGraphicsResourceGetMappedMipmappedArray(
6469 mipmappedArray: *mut cudaMipmappedArray_t,
6470 resource: cudaGraphicsResource_t,
6471 ) -> cudaError_t;
6472}
6473unsafe extern "C" {
6474 /// Get the channel descriptor of an array.
6475 ///
6476 /// Returns in \*desc the channel descriptor of the CUDA array array.
6477 ///
6478 /// Note:
6479 ///
6480 /// * Note that this function may also return error codes from previous, asynchronous launches.
6481 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6482 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6483 ///
6484 /// **See also:**
6485 ///
6486 /// cudaCreateChannelDesc ( C API), [`cudaCreateTextureObject`], [`cudaCreateSurfaceObject`].
6487 ///
6488 /// # Parameters
6489 ///
6490 /// - `desc`: Channel format.
6491 /// - `array`: Memory array on device.
6492 pub fn cudaGetChannelDesc(
6493 desc: *mut cudaChannelFormatDesc,
6494 array: cudaArray_const_t,
6495 ) -> cudaError_t;
6496}
6497unsafe extern "C" {
6498 /// # Parameters
6499 ///
6500 /// - `x`: X component.
6501 /// - `y`: Y component.
6502 /// - `z`: Z component.
6503 /// - `w`: W component.
6504 /// - `f`: Channel format.
6505 pub fn cudaCreateChannelDesc(
6506 x: ::core::ffi::c_int,
6507 y: ::core::ffi::c_int,
6508 z: ::core::ffi::c_int,
6509 w: ::core::ffi::c_int,
6510 f: cudaChannelFormatKind,
6511 ) -> cudaChannelFormatDesc;
6512}
6513unsafe extern "C" {
6514 /// Creates a texture object.
6515 ///
6516 /// 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.
6517 ///
6518 /// Texture objects are only supported on devices of compute capability 3.0 or higher. Additionally, a texture object is an opaque
6519 /// value, and, as such, should only be accessed through CUDA API calls.
6520 ///
6521 /// The [`cudaResourceDesc`] structure is defined as:
6522 ///
6523 /// ```text
6524 /// struct cudaResourceDesc {
6525 /// enum cudaResourceType
6526 /// resType;
6527 ///
6528 /// union {
6529 /// struct {
6530 /// cudaArray_t
6531 /// array;
6532 /// } array;
6533 /// struct {
6534 /// cudaMipmappedArray_t
6535 /// mipmap;
6536 /// } mipmap;
6537 /// struct {
6538 /// void *devPtr;
6539 /// struct cudaChannelFormatDesc
6540 /// desc;
6541 /// size_t sizeInBytes;
6542 /// } linear;
6543 /// struct {
6544 /// void *devPtr;
6545 /// struct cudaChannelFormatDesc
6546 /// desc;
6547 /// size_t width;
6548 /// size_t height;
6549 /// size_t pitchInBytes;
6550 /// } pitch2D;
6551 /// } res;
6552 /// };
6553 /// ```
6554 ///
6555 /// * [cudaResourceDesc::resType](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) specifies the type of resource to texture from. CUresourceType is defined as:
6556 ///
6557 /// ```text
6558 /// enum cudaResourceType {
6559 /// cudaResourceTypeArray = 0x00,
6560 /// cudaResourceTypeMipmappedArray = 0x01,
6561 /// cudaResourceTypeLinear = 0x02,
6562 /// cudaResourceTypePitch2D = 0x03
6563 /// };
6564 /// ```
6565 ///
6566 /// If [cudaResourceDesc::resType](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is set to [`cudaResourceType::cudaResourceTypeArray`], cudaResourceDesc::res::array::array must be set to a valid CUDA array handle.
6567 ///
6568 /// If [cudaResourceDesc::resType](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is set to [`cudaResourceType::cudaResourceTypeMipmappedArray`], cudaResourceDesc::res::mipmap::mipmap must be set to a valid CUDA mipmapped array handle and [cudaTextureDesc::normalizedCoords](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_14244ae4f85cd69ff050fdc681be4cd35) must be set to true.
6569 ///
6570 /// If [cudaResourceDesc::resType](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is set to [`cudaResourceType::cudaResourceTypeLinear`], cudaResourceDesc::res::linear::devPtr must be set to a valid device pointer, that is aligned to [cudaDeviceProp::textureAlignment](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_1500248658a996f51752e1ab1769f8a88). cudaResourceDesc::res::linear::desc describes the format and the number of components per array element. cudaResourceDesc::res::linear::sizeInBytes
6571 /// 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)).
6572 ///
6573 /// If [cudaResourceDesc::resType](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is set to [`cudaResourceType::cudaResourceTypePitch2D`], cudaResourceDesc::res::pitch2D::devPtr must be set to a valid device pointer, that is aligned to [cudaDeviceProp::textureAlignment](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_1500248658a996f51752e1ab1769f8a88). cudaResourceDesc::res::pitch2D::desc describes the format and the number of components per array element. cudaResourceDesc::res::pitch2D::width
6574 /// and cudaResourceDesc::res::pitch2D::height specify the width and height of the array in elements, and cannot exceed [cudaDeviceProp::maxTexture2DLinear](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_1757a4245a175441c2a1535ef9c9524a4)\[0\] and [cudaDeviceProp::maxTexture2DLinear](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_1757a4245a175441c2a1535ef9c9524a4)\[1\] respectively. cudaResourceDesc::res::pitch2D::pitchInBytes specifies the pitch between two rows in bytes and has to be
6575 /// aligned to [cudaDeviceProp::texturePitchAlignment](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_13a3f10d2833bdc82ceb370a449aafeec). Pitch cannot exceed [cudaDeviceProp::maxTexture2DLinear](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_1757a4245a175441c2a1535ef9c9524a4)\[2\].
6576 ///
6577 /// The [`cudaTextureDesc`] struct is defined as
6578 ///
6579 /// ```text
6580 /// struct cudaTextureDesc {
6581 /// enum cudaTextureAddressMode
6582 /// addressMode\[3\];
6583 /// enum cudaTextureFilterMode
6584 /// filterMode;
6585 /// enum cudaTextureReadMode
6586 /// readMode;
6587 /// int sRGB;
6588 /// float borderColor\[4\];
6589 /// int normalizedCoords;
6590 /// unsigned int maxAnisotropy;
6591 /// enum cudaTextureFilterMode
6592 /// mipmapFilterMode;
6593 /// float mipmapLevelBias;
6594 /// float minMipmapLevelClamp;
6595 /// float maxMipmapLevelClamp;
6596 /// int disableTrilinearOptimization;
6597 /// int seamlessCubemap;
6598 /// };
6599 /// ```
6600 ///
6601 /// * [cudaTextureDesc::addressMode](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1444fd48870cf61180673e0ed0abb4a1c) specifies the addressing mode for each dimension of the texture data. [`cudaTextureAddressMode`] is defined as:
6602 ///
6603 /// ```text
6604 /// enum cudaTextureAddressMode {
6605 /// cudaAddressModeWrap = 0,
6606 /// cudaAddressModeClamp = 1,
6607 /// cudaAddressModeMirror = 2,
6608 /// cudaAddressModeBorder = 3
6609 /// };
6610 /// ```
6611 ///
6612 /// This is ignored if [cudaResourceDesc::resType](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is [`cudaResourceType::cudaResourceTypeLinear`]. Also, if [cudaTextureDesc::normalizedCoords](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_14244ae4f85cd69ff050fdc681be4cd35) is set to zero, [`cudaTextureAddressMode::cudaAddressModeWrap`] and [`cudaTextureAddressMode::cudaAddressModeMirror`] won't be supported and will be switched to [`cudaTextureAddressMode::cudaAddressModeClamp`].
6613 ///
6614 /// * [cudaTextureDesc::filterMode](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1c61993bf71d0cdec670ad92e567ba582) specifies the filtering mode to be used when fetching from the texture. [`cudaTextureFilterMode`] is defined as:
6615 ///
6616 /// ```text
6617 /// enum cudaTextureFilterMode {
6618 /// cudaFilterModePoint = 0,
6619 /// cudaFilterModeLinear = 1
6620 /// };
6621 /// ```
6622 ///
6623 /// This is ignored if [cudaResourceDesc::resType](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) is [`cudaResourceType::cudaResourceTypeLinear`].
6624 ///
6625 /// * [cudaTextureDesc::readMode](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1279c5b27ef0194711344dc402228af94) specifies whether integer data should be converted to floating point or not. [`cudaTextureReadMode`] is defined as:
6626 ///
6627 /// ```text
6628 /// enum cudaTextureReadMode {
6629 /// cudaReadModeElementType = 0,
6630 /// cudaReadModeNormalizedFloat = 1
6631 /// };
6632 /// ```
6633 ///
6634 /// Note that this applies only to 8-bit and 16-bit integer formats. 32-bit integer format would not be promoted, regardless
6635 /// of whether or not this [cudaTextureDesc::readMode](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1279c5b27ef0194711344dc402228af94) is set [`cudaTextureReadMode::cudaReadModeNormalizedFloat`] is specified.
6636 ///
6637 /// * [cudaTextureDesc::sRGB](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1173e8d365c55f50e9eb586c282af30ca) specifies whether sRGB to linear conversion should be performed during texture fetch.
6638 ///
6639 /// * [cudaTextureDesc::borderColor](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e) specifies the float values of color. where: [cudaTextureDesc::borderColor](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e)\[0\] contains value of 'R', [cudaTextureDesc::borderColor](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e)\[1\] contains value of 'G', [cudaTextureDesc::borderColor](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e)\[2\] contains value of 'B', [cudaTextureDesc::borderColor](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_18a99cc6b95b3629dc204393576ebae9e)\[3\] contains value of 'A' Note that application using integer border color values will need to <reinterpret_cast> these values
6640 /// to float. The values are set only when the addressing mode specified by [cudaTextureDesc::addressMode](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1444fd48870cf61180673e0ed0abb4a1c) is cudaAddressModeBorder.
6641 ///
6642 /// * [cudaTextureDesc::normalizedCoords](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_14244ae4f85cd69ff050fdc681be4cd35) specifies whether the texture coordinates will be normalized or not.
6643 ///
6644 /// * [cudaTextureDesc::maxAnisotropy](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_14fadc6bfa59fe7f8f076d58e407381e5) specifies the maximum anistropy ratio to be used when doing anisotropic filtering. This value will be clamped to the range
6645 /// \[1,16\].
6646 ///
6647 /// * [cudaTextureDesc::mipmapFilterMode](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1bbdaf1bc430ac931a12ffa7d3f8809ce) specifies the filter mode when the calculated mipmap level lies between two defined mipmap levels.
6648 ///
6649 /// * [cudaTextureDesc::mipmapLevelBias](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_139f79ca1c9fd8f476597df0d3a8ed34c) specifies the offset to be applied to the calculated mipmap level.
6650 ///
6651 /// * [cudaTextureDesc::minMipmapLevelClamp](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1928642b629ae8fd8d2adc198979b6840) specifies the lower end of the mipmap level range to clamp access to.
6652 ///
6653 /// * [cudaTextureDesc::maxMipmapLevelClamp](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_19cb54762bd472fb9bd58fed7f22e64c2) specifies the upper end of the mipmap level range to clamp access to.
6654 ///
6655 /// * [cudaTextureDesc::disableTrilinearOptimization](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_17a70376ee9551c40991b587b48dbd728) specifies whether the trilinear filtering optimizations will be disabled.
6656 ///
6657 /// * [cudaTextureDesc::seamlessCubemap](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1d2d887e7ecfead1ed118743bc9dce779) specifies whether seamless cube map filtering is enabled. This flag can only be specified if the underlying resource is a
6658 /// CUDA array or a CUDA mipmapped array that was created with the flag `cudaArrayCubemap`. When seamless cube map filtering is enabled, texture address modes specified by [cudaTextureDesc::addressMode](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1444fd48870cf61180673e0ed0abb4a1c) are ignored. Instead, if the [cudaTextureDesc::filterMode](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1c61993bf71d0cdec670ad92e567ba582) is set to [`cudaTextureFilterMode::cudaFilterModePoint`] the address mode [`cudaTextureAddressMode::cudaAddressModeClamp`] will be applied for all dimensions. If the [cudaTextureDesc::filterMode](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1c61993bf71d0cdec670ad92e567ba582) is set to [`cudaTextureFilterMode::cudaFilterModeLinear`] seamless cube map filtering will be performed when sampling along the cube face borders.
6659 ///
6660 /// The [`cudaResourceViewDesc`] struct is defined as
6661 ///
6662 /// ```text
6663 /// struct cudaResourceViewDesc {
6664 /// enum cudaResourceViewFormat
6665 /// format;
6666 /// size_t width;
6667 /// size_t height;
6668 /// size_t depth;
6669 /// unsigned int firstMipmapLevel;
6670 /// unsigned int lastMipmapLevel;
6671 /// unsigned int firstLayer;
6672 /// unsigned int lastLayer;
6673 /// };
6674 /// ```
6675 ///
6676 /// * [cudaResourceViewDesc::format](https://docs.nvidia.com/cuda/cuda-runtime-api/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
6677 /// a change in size of the texture data. If the resource view format is a block compressed format, then the underlying CUDA array
6678 /// or CUDA mipmapped array has to have a 32-bit unsigned integer format with 2 or 4 channels, depending on the block compressed
6679 /// format. For ex., BC1 and BC4 require the underlying CUDA array to have a 32-bit unsigned int with 2 channels. The other BC
6680 /// formats require the underlying resource to have the same 32-bit unsigned int format but with 4 channels.
6681 ///
6682 /// * [cudaResourceViewDesc::width](https://docs.nvidia.com/cuda/cuda-runtime-api/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
6683 /// be 4 times the original width of the resource. For non block compressed formats, this value has to be equal to that of the
6684 /// original resource.
6685 ///
6686 /// * [cudaResourceViewDesc::height](https://docs.nvidia.com/cuda/cuda-runtime-api/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
6687 /// be 4 times the original height of the resource. For non block compressed formats, this value has to be equal to that of the
6688 /// original resource.
6689 ///
6690 /// * [cudaResourceViewDesc::depth](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceViewDesc.html#structcudaResourceViewDesc_17f76b4084ffdcb7f88e4149b586a990d) specifies the new depth of the texture data. This value has to be equal to that of the original resource.
6691 ///
6692 /// * [cudaResourceViewDesc::firstMipmapLevel](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceViewDesc.html#structcudaResourceViewDesc_1f63fa90d2bf6c66f3865bf13006edded) specifies the most detailed mipmap level. This will be the new mipmap level zero. For non-mipmapped resources, this value
6693 /// has to be zero.[cudaTextureDesc::minMipmapLevelClamp](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaTextureDesc.html#structcudaTextureDesc_1928642b629ae8fd8d2adc198979b6840) and [cudaTextureDesc::maxMipmapLevelClamp](https://docs.nvidia.com/cuda/cuda-runtime-api/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,
6694 /// then the actual minimum mipmap level clamp will be 3.2.
6695 ///
6696 /// * [cudaResourceViewDesc::lastMipmapLevel](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceViewDesc.html#structcudaResourceViewDesc_1469d25794fec5471648d0d9e42790431) specifies the least detailed mipmap level. For non-mipmapped resources, this value has to be zero.
6697 ///
6698 /// * [cudaResourceViewDesc::firstLayer](https://docs.nvidia.com/cuda/cuda-runtime-api/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
6699 /// has to be zero.
6700 ///
6701 /// * [cudaResourceViewDesc::lastLayer](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceViewDesc.html#structcudaResourceViewDesc_16d96c5b3df0bce3d945d4ea99666226f) specifies the last layer index for layered textures. For non-layered resources, this value has to be zero.
6702 ///
6703 /// Note:
6704 ///
6705 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6706 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6707 ///
6708 /// **See also:**
6709 ///
6710 /// [`cudaDestroyTextureObject`], [cuTexObjectCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1g1f6dd0f9cbf56db725b1f45aa0a7218a).
6711 ///
6712 /// # Parameters
6713 ///
6714 /// - `pTexObject`: Texture object to create.
6715 /// - `pResDesc`: Resource descriptor.
6716 /// - `pTexDesc`: Texture descriptor.
6717 /// - `pResViewDesc`: Resource view descriptor.
6718 pub fn cudaCreateTextureObject(
6719 pTexObject: *mut cudaTextureObject_t,
6720 pResDesc: *const cudaResourceDesc,
6721 pTexDesc: *const cudaTextureDesc,
6722 pResViewDesc: *const cudaResourceViewDesc,
6723 ) -> cudaError_t;
6724}
6725unsafe extern "C" {
6726 /// Destroys a texture object.
6727 ///
6728 /// Destroys the texture object specified by texObject.
6729 ///
6730 /// Note:
6731 ///
6732 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6733 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6734 /// * Use of the handle after this call is undefined behavior.
6735 ///
6736 /// **See also:**
6737 ///
6738 /// [`cudaCreateTextureObject`], [cuTexObjectDestroy](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1gcd522ba5e2d1852aff8c0388f66247fd).
6739 ///
6740 /// # Parameters
6741 ///
6742 /// - `texObject`: Texture object to destroy.
6743 pub fn cudaDestroyTextureObject(texObject: cudaTextureObject_t) -> cudaError_t;
6744}
6745unsafe extern "C" {
6746 /// Returns a texture object's resource descriptor.
6747 ///
6748 /// Returns the resource descriptor for the texture object specified by texObject.
6749 ///
6750 /// Note:
6751 ///
6752 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6753 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6754 ///
6755 /// **See also:**
6756 ///
6757 /// [`cudaCreateTextureObject`], [cuTexObjectGetResourceDesc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1g0cc8eb2fa1e584d2b04d631586d0921f).
6758 ///
6759 /// # Parameters
6760 ///
6761 /// - `pResDesc`: Resource descriptor.
6762 /// - `texObject`: Texture object.
6763 pub fn cudaGetTextureObjectResourceDesc(
6764 pResDesc: *mut cudaResourceDesc,
6765 texObject: cudaTextureObject_t,
6766 ) -> cudaError_t;
6767}
6768unsafe extern "C" {
6769 /// Returns a texture object's texture descriptor.
6770 ///
6771 /// Returns the texture descriptor for the texture object specified by texObject.
6772 ///
6773 /// Note:
6774 ///
6775 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6776 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6777 ///
6778 /// **See also:**
6779 ///
6780 /// [`cudaCreateTextureObject`], [cuTexObjectGetTextureDesc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1g688de37b844df7313c8fce30fc912645).
6781 ///
6782 /// # Parameters
6783 ///
6784 /// - `pTexDesc`: Texture descriptor.
6785 /// - `texObject`: Texture object.
6786 pub fn cudaGetTextureObjectTextureDesc(
6787 pTexDesc: *mut cudaTextureDesc,
6788 texObject: cudaTextureObject_t,
6789 ) -> cudaError_t;
6790}
6791unsafe extern "C" {
6792 /// Returns a texture object's resource view descriptor.
6793 ///
6794 /// Returns the resource view descriptor for the texture object specified by texObject. If no resource view was specified, [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) is returned.
6795 ///
6796 /// Note:
6797 ///
6798 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6799 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6800 ///
6801 /// **See also:**
6802 ///
6803 /// [`cudaCreateTextureObject`], [cuTexObjectGetResourceViewDesc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TEXOBJECT.html#group__CUDA__TEXOBJECT_1g185fa4c933a1c3a7b6aebe3e4291a37b).
6804 ///
6805 /// # Parameters
6806 ///
6807 /// - `pResViewDesc`: Resource view descriptor.
6808 /// - `texObject`: Texture object.
6809 pub fn cudaGetTextureObjectResourceViewDesc(
6810 pResViewDesc: *mut cudaResourceViewDesc,
6811 texObject: cudaTextureObject_t,
6812 ) -> cudaError_t;
6813}
6814unsafe extern "C" {
6815 /// Creates a surface object.
6816 ///
6817 /// Creates a surface object and returns it in pSurfObject. pResDesc describes the data to perform surface load/stores on. [cudaResourceDesc::resType](https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaResourceDesc.html#structcudaResourceDesc_1aac8b3bb1d63bd25d8e9af7ee0b9a580) must be [`cudaResourceType::cudaResourceTypeArray`] and cudaResourceDesc::res::array::array must be set to a valid CUDA array handle.
6818 ///
6819 /// Surface objects are only supported on devices of compute capability 3.0 or higher. Additionally, a surface object is an opaque
6820 /// value, and, as such, should only be accessed through CUDA API calls.
6821 ///
6822 /// Note:
6823 ///
6824 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6825 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6826 ///
6827 /// **See also:**
6828 ///
6829 /// [`cudaDestroySurfaceObject`], [cuSurfObjectCreate](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__SURFOBJECT.html#group__CUDA__SURFOBJECT_1g6bc972c90c9590c9f720b2754e6d079d).
6830 ///
6831 /// # Parameters
6832 ///
6833 /// - `pSurfObject`: Surface object to create.
6834 /// - `pResDesc`: Resource descriptor.
6835 pub fn cudaCreateSurfaceObject(
6836 pSurfObject: *mut cudaSurfaceObject_t,
6837 pResDesc: *const cudaResourceDesc,
6838 ) -> cudaError_t;
6839}
6840unsafe extern "C" {
6841 /// Destroys a surface object.
6842 ///
6843 /// Destroys the surface object specified by surfObject.
6844 ///
6845 /// Note:
6846 ///
6847 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6848 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6849 /// * Use of the handle after this call is undefined behavior.
6850 ///
6851 /// **See also:**
6852 ///
6853 /// [`cudaCreateSurfaceObject`], [cuSurfObjectDestroy](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__SURFOBJECT.html#group__CUDA__SURFOBJECT_1g4c4ec48d203d1e0bb71750ddc4d7aef3).
6854 ///
6855 /// # Parameters
6856 ///
6857 /// - `surfObject`: Surface object to destroy.
6858 pub fn cudaDestroySurfaceObject(surfObject: cudaSurfaceObject_t) -> cudaError_t;
6859}
6860unsafe extern "C" {
6861 /// Returns a surface object's resource descriptor Returns the resource descriptor for the surface object specified by surfObject.
6862 ///
6863 /// Note:
6864 ///
6865 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6866 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6867 ///
6868 /// **See also:**
6869 ///
6870 /// [`cudaCreateSurfaceObject`], [cuSurfObjectGetResourceDesc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__SURFOBJECT.html#group__CUDA__SURFOBJECT_1g2472b7ea0b7e74600ed3d6c244b7ba21).
6871 ///
6872 /// # Parameters
6873 ///
6874 /// - `pResDesc`: Resource descriptor.
6875 /// - `surfObject`: Surface object.
6876 pub fn cudaGetSurfaceObjectResourceDesc(
6877 pResDesc: *mut cudaResourceDesc,
6878 surfObject: cudaSurfaceObject_t,
6879 ) -> cudaError_t;
6880}
6881unsafe extern "C" {
6882 /// Returns the latest version of CUDA supported by the driver.
6883 ///
6884 /// Returns in \*driverVersion the latest version of CUDA supported by the driver. The version is returned as (1000 major + 10 minor). For example, CUDA
6885 /// 9.2 would be represented by 9020. If no driver is installed, then 0 is returned as the driver version.
6886 ///
6887 /// This function automatically returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if driverVersion is NULL.
6888 ///
6889 /// Note:
6890 ///
6891 /// * Note that this function may also return error codes from previous, asynchronous launches.
6892 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6893 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6894 ///
6895 /// **See also:**
6896 ///
6897 /// [`cudaRuntimeGetVersion`], [cuDriverGetVersion](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VERSION.html#group__CUDA__VERSION_1g8b7a10395392e049006e61bcdc8ebe71).
6898 ///
6899 /// # Parameters
6900 ///
6901 /// - `driverVersion`: Returns the CUDA driver version.
6902 pub fn cudaDriverGetVersion(driverVersion: *mut ::core::ffi::c_int) -> cudaError_t;
6903}
6904unsafe extern "C" {
6905 /// Returns the CUDA Runtime version.
6906 ///
6907 /// Returns in \*runtimeVersion the version number of the current CUDA Runtime instance. The version is returned as (1000 major + 10 minor). For example,
6908 /// CUDA 9.2 would be represented by 9020.
6909 ///
6910 /// As of CUDA 12.0, this function no longer initializes CUDA. The purpose of this API is solely to return a compile-time constant
6911 /// stating the CUDA Toolkit version in the above format.
6912 ///
6913 /// This function automatically returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if the runtimeVersion argument is NULL.
6914 ///
6915 /// Note:
6916 ///
6917 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
6918 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
6919 ///
6920 /// **See also:**
6921 ///
6922 /// [`cudaDriverGetVersion`], [cuDriverGetVersion](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VERSION.html#group__CUDA__VERSION_1g8b7a10395392e049006e61bcdc8ebe71).
6923 ///
6924 /// # Parameters
6925 ///
6926 /// - `runtimeVersion`: Returns the CUDA Runtime version.
6927 pub fn cudaRuntimeGetVersion(runtimeVersion: *mut ::core::ffi::c_int) -> cudaError_t;
6928}
6929/// Type of public error reporting callback functions.
6930pub type cudaLogsCallback_t = ::core::option::Option<
6931 unsafe extern "C" fn(
6932 data: *mut ::core::ffi::c_void,
6933 logLevel: cudaLogLevel,
6934 message: *mut ::core::ffi::c_char,
6935 length: size_t,
6936 ),
6937>;
6938unsafe extern "C" {
6939 /// Register a callback function to receive error log messages.
6940 ///
6941 /// # Parameters
6942 ///
6943 /// - `callbackFunc`: The function to register as a callback.
6944 /// - `userData`: A generic pointer to user data. This is passed into the callback function.
6945 /// - `callback_out`: Optional location to store the callback handle after it is registered.
6946 pub fn cudaLogsRegisterCallback(
6947 callbackFunc: cudaLogsCallback_t,
6948 userData: *mut ::core::ffi::c_void,
6949 callback_out: *mut cudaLogsCallbackHandle,
6950 ) -> cudaError_t;
6951}
6952unsafe extern "C" {
6953 /// Unregister a log message callback.
6954 ///
6955 /// # Parameters
6956 ///
6957 /// - `callback`: The callback instance to unregister from receiving log messages.
6958 pub fn cudaLogsUnregisterCallback(callback: cudaLogsCallbackHandle) -> cudaError_t;
6959}
6960unsafe extern "C" {
6961 /// Sets log iterator to point to the end of log buffer, where the next message would be written.
6962 ///
6963 /// # Parameters
6964 ///
6965 /// - `iterator_out`: Location to store an iterator to the current tail of the logs.
6966 /// - `flags`: Reserved for future use, must be 0.
6967 pub fn cudaLogsCurrent(
6968 iterator_out: *mut cudaLogIterator,
6969 flags: ::core::ffi::c_uint,
6970 ) -> cudaError_t;
6971}
6972unsafe extern "C" {
6973 /// Dump accumulated driver logs into a file.
6974 ///
6975 /// Logs generated by the driver are stored in an internal buffer and can be copied out using this API. This API dumps all driver
6976 /// logs starting from iterator into pathToFile provided.
6977 ///
6978 /// Note:
6979 ///
6980 /// * iterator is auto-advancing. Dumping logs will update the value of iterator to receive the next generated log.
6981 /// * The driver reserves limited memory for storing logs. The oldest logs may be overwritten and become unrecoverable. An indication
6982 /// will appear in the destination outupt if the logs have been truncated. Call dump after each failed API to mitigate this risk.
6983 ///
6984 /// # Parameters
6985 ///
6986 /// - `iterator`: Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
6987 /// - `pathToFile`: Path to output file for dumping logs.
6988 /// - `flags`: Reserved for future use, must be 0.
6989 pub fn cudaLogsDumpToFile(
6990 iterator: *mut cudaLogIterator,
6991 pathToFile: *const ::core::ffi::c_char,
6992 flags: ::core::ffi::c_uint,
6993 ) -> cudaError_t;
6994}
6995unsafe extern "C" {
6996 /// Dump accumulated driver logs into a buffer.
6997 ///
6998 /// Logs generated by the driver are stored in an internal buffer and can be copied out using this API. This API dumps driver
6999 /// 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
7000 /// \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](https://docs.nvidia.com/cuda/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](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1ggc6c391505e117393cc2558fff6bfc2e990696c86fcee1f536a1ec7d25867feeb).
7001 ///
7002 /// Note:
7003 ///
7004 /// * iterator is auto-advancing. Dumping logs will update the value of iterator to receive the next generated log.
7005 /// * The driver reserves limited memory for storing logs. The maximum size of the buffer is 25600 bytes. The oldest logs may be
7006 /// overwritten and become unrecoverable. An indication will appear in the destination outupt if the logs have been truncated.
7007 /// Call dump after each failed API to mitigate this risk.
7008 /// * 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
7009 /// 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.
7010 ///
7011 /// # Parameters
7012 ///
7013 /// - `iterator`: Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
7014 /// - `buffer`: Pointer to dump logs.
7015 /// - `size`: See description.
7016 /// - `flags`: Reserved for future use, must be 0.
7017 pub fn cudaLogsDumpToMemory(
7018 iterator: *mut cudaLogIterator,
7019 buffer: *mut ::core::ffi::c_char,
7020 size: *mut size_t,
7021 flags: ::core::ffi::c_uint,
7022 ) -> cudaError_t;
7023}
7024unsafe extern "C" {
7025 /// Creates a graph.
7026 ///
7027 /// Creates an empty graph, which is returned via pGraph.
7028 ///
7029 /// Note:
7030 ///
7031 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7032 /// * Note that this function may also return error codes from previous, asynchronous launches.
7033 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7034 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7035 ///
7036 /// **See also:**
7037 ///
7038 /// [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`], [`cudaGraphInstantiate`], [`cudaGraphDestroy`], [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphClone`].
7039 ///
7040 /// # Parameters
7041 ///
7042 /// - `pGraph`: Returns newly created graph.
7043 /// - `flags`: Graph creation flags, must be 0.
7044 pub fn cudaGraphCreate(
7045 pGraph: *mut cudaGraph_t,
7046 flags: ::core::ffi::c_uint,
7047 ) -> cudaError_t;
7048}
7049unsafe extern "C" {
7050 /// Creates a kernel execution node and adds it to a graph.
7051 ///
7052 /// 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.
7053 ///
7054 /// The [`cudaKernelNodeParams`] structure is defined as:
7055 ///
7056 /// ```text
7057 /// struct cudaKernelNodeParams
7058 /// {
7059 /// void* func;
7060 /// dim3 gridDim;
7061 /// dim3 blockDim;
7062 /// unsigned int sharedMemBytes;
7063 /// void **kernelParams;
7064 /// void **extra;
7065 /// };
7066 /// ```
7067 ///
7068 /// 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.
7069 ///
7070 /// sharedMem sets the amount of dynamic shared memory that will be available to each thread block.
7071 ///
7072 /// Kernel parameters to func can be specified in one of two ways:
7073 ///
7074 /// 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
7075 /// their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel's image.
7076 ///
7077 /// 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.
7078 /// 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
7079 /// by the corresponding value. The list must be terminated with either NULL or CU_LAUNCH_PARAM_END.
7080 ///
7081 /// * [CU_LAUNCH_PARAM_END](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1gd5c11cff5adfa5a69d66829399653532), which indicates the end of the extra array;
7082 /// * [CU_LAUNCH_PARAM_BUFFER_POINTER](https://docs.nvidia.com/cuda/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;
7083 /// * [CU_LAUNCH_PARAM_BUFFER_SIZE](https://docs.nvidia.com/cuda/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](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1g36d10d0b40c51372877578a2cffd6acd);
7084 ///
7085 /// The error [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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).
7086 ///
7087 /// The kernelParams or extra array, as well as the argument values it points to, are copied during this call.
7088 ///
7089 /// Note:
7090 ///
7091 /// Kernels launched using graphs must not use texture and surface references. Reading or writing through any texture or surface
7092 /// reference is undefined behavior. This restriction does not apply to texture and surface objects.
7093 ///
7094 /// Note:
7095 ///
7096 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7097 /// * Note that this function may also return error codes from previous, asynchronous launches.
7098 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7099 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7100 /// * The API can also be used with a kernel `cudaKernel_t` by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
7101 /// * Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type
7102 /// that can be reliably passed to a different runtime instance is `cudaKernel_t`
7103 ///
7104 /// **See also:**
7105 ///
7106 /// [`cudaGraphAddNode`], [`cudaLaunchKernel`], [`cudaGraphKernelNodeGetParams`], [`cudaGraphKernelNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
7107 ///
7108 /// # Parameters
7109 ///
7110 /// - `pGraphNode`: Returns newly created node.
7111 /// - `graph`: Graph to which to add the node.
7112 /// - `pDependencies`: Dependencies of the node.
7113 /// - `numDependencies`: Number of dependencies.
7114 /// - `pNodeParams`: Parameters for the GPU execution node.
7115 pub fn cudaGraphAddKernelNode(
7116 pGraphNode: *mut cudaGraphNode_t,
7117 graph: cudaGraph_t,
7118 pDependencies: *const cudaGraphNode_t,
7119 numDependencies: size_t,
7120 pNodeParams: *const cudaKernelNodeParams,
7121 ) -> cudaError_t;
7122}
7123unsafe extern "C" {
7124 /// Returns a kernel node's parameters.
7125 ///
7126 /// 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
7127 /// or its parameters are modified, and should not be modified directly. Use [`cudaGraphKernelNodeSetParams`] to update the parameters of this node.
7128 ///
7129 /// The params will contain either kernelParams or extra, according to which of these was most recently set on the node.
7130 ///
7131 /// Note:
7132 ///
7133 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7134 /// * Note that this function may also return error codes from previous, asynchronous launches.
7135 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7136 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7137 ///
7138 /// **See also:**
7139 ///
7140 /// [`cudaGraphNodeGetParams`], [`cudaLaunchKernel`], [`cudaGraphAddKernelNode`], [`cudaGraphKernelNodeSetParams`].
7141 ///
7142 /// # Parameters
7143 ///
7144 /// - `node`: Node to get the parameters for.
7145 /// - `pNodeParams`: Pointer to return the parameters.
7146 pub fn cudaGraphKernelNodeGetParams(
7147 node: cudaGraphNode_t,
7148 pNodeParams: *mut cudaKernelNodeParams,
7149 ) -> cudaError_t;
7150}
7151unsafe extern "C" {
7152 /// Sets a kernel node's parameters.
7153 ///
7154 /// Sets the parameters of kernel node node to pNodeParams.
7155 ///
7156 /// Note:
7157 ///
7158 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7159 /// * Note that this function may also return error codes from previous, asynchronous launches.
7160 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7161 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7162 /// * The API can also be used with a kernel `cudaKernel_t` by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
7163 /// * Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type
7164 /// that can be reliably passed to a different runtime instance is `cudaKernel_t`
7165 ///
7166 /// **See also:**
7167 ///
7168 /// [`cudaGraphNodeSetParams`], [`cudaLaunchKernel`], [`cudaGraphAddKernelNode`], [`cudaGraphKernelNodeGetParams`].
7169 ///
7170 /// # Parameters
7171 ///
7172 /// - `node`: Node to set the parameters for.
7173 /// - `pNodeParams`: Parameters to copy.
7174 pub fn cudaGraphKernelNodeSetParams(
7175 node: cudaGraphNode_t,
7176 pNodeParams: *const cudaKernelNodeParams,
7177 ) -> cudaError_t;
7178}
7179unsafe extern "C" {
7180 /// Copies attributes from source node to destination node.
7181 ///
7182 /// Copies attributes from source node hSrc to destination node hDst. Both node must have the same context.
7183 ///
7184 /// Note:
7185 ///
7186 /// Note that this function may also return error codes from previous, asynchronous launches.
7187 ///
7188 /// **See also:**
7189 ///
7190 /// [`cudaAccessPolicyWindow`].
7191 ///
7192 /// # Parameters
7193 ///
7194 /// - `hDst`: Destination node.
7195 /// - `hSrc`: Source node For list of attributes see cudaKernelNodeAttrID.
7196 pub fn cudaGraphKernelNodeCopyAttributes(
7197 hDst: cudaGraphNode_t,
7198 hSrc: cudaGraphNode_t,
7199 ) -> cudaError_t;
7200}
7201unsafe extern "C" {
7202 /// Queries node attribute.
7203 ///
7204 /// Queries attribute attr from node hNode and stores it in corresponding member of value_out.
7205 ///
7206 /// Note:
7207 ///
7208 /// Note that this function may also return error codes from previous, asynchronous launches.
7209 ///
7210 /// **See also:**
7211 ///
7212 /// [`cudaAccessPolicyWindow`].
7213 pub fn cudaGraphKernelNodeGetAttribute(
7214 hNode: cudaGraphNode_t,
7215 attr: cudaLaunchAttributeID,
7216 value_out: *mut cudaLaunchAttributeValue,
7217 ) -> cudaError_t;
7218}
7219unsafe extern "C" {
7220 /// Sets node attribute.
7221 ///
7222 /// Sets attribute attr on node hNode from corresponding attribute of value.
7223 ///
7224 /// Note:
7225 ///
7226 /// Note that this function may also return error codes from previous, asynchronous launches.
7227 ///
7228 /// **See also:**
7229 ///
7230 /// [`cudaAccessPolicyWindow`].
7231 pub fn cudaGraphKernelNodeSetAttribute(
7232 hNode: cudaGraphNode_t,
7233 attr: cudaLaunchAttributeID,
7234 value: *const cudaLaunchAttributeValue,
7235 ) -> cudaError_t;
7236}
7237unsafe extern "C" {
7238 /// Creates a memcpy node and adds it to a graph.
7239 ///
7240 /// 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.
7241 ///
7242 /// 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.
7243 ///
7244 /// Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device
7245 /// which has a zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09).
7246 ///
7247 /// Note:
7248 ///
7249 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7250 /// * Note that this function may also return error codes from previous, asynchronous launches.
7251 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7252 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7253 ///
7254 /// **See also:**
7255 ///
7256 /// [`cudaGraphAddNode`], [`cudaMemcpy3D`], [`cudaGraphAddMemcpyNodeToSymbol`], [`cudaGraphAddMemcpyNodeFromSymbol`], [`cudaGraphAddMemcpyNode1D`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemsetNode`].
7257 ///
7258 /// # Parameters
7259 ///
7260 /// - `pGraphNode`: Returns newly created node.
7261 /// - `graph`: Graph to which to add the node.
7262 /// - `pDependencies`: Dependencies of the node.
7263 /// - `numDependencies`: Number of dependencies.
7264 /// - `pCopyParams`: Parameters for the memory copy.
7265 pub fn cudaGraphAddMemcpyNode(
7266 pGraphNode: *mut cudaGraphNode_t,
7267 graph: cudaGraph_t,
7268 pDependencies: *const cudaGraphNode_t,
7269 numDependencies: size_t,
7270 pCopyParams: *const cudaMemcpy3DParms,
7271 ) -> cudaError_t;
7272}
7273unsafe extern "C" {
7274 /// # Parameters
7275 ///
7276 /// - `pGraphNode`: Returns newly created node.
7277 /// - `graph`: Graph to which to add the node.
7278 /// - `pDependencies`: Dependencies of the node.
7279 /// - `numDependencies`: Number of dependencies.
7280 /// - `symbol`: Device symbol address.
7281 /// - `src`: Source memory address.
7282 /// - `count`: Size in bytes to copy.
7283 /// - `offset`: Offset from start of symbol in bytes.
7284 /// - `kind`: Type of transfer.
7285 pub fn cudaGraphAddMemcpyNodeToSymbol(
7286 pGraphNode: *mut cudaGraphNode_t,
7287 graph: cudaGraph_t,
7288 pDependencies: *const cudaGraphNode_t,
7289 numDependencies: size_t,
7290 symbol: *const ::core::ffi::c_void,
7291 src: *const ::core::ffi::c_void,
7292 count: size_t,
7293 offset: size_t,
7294 kind: cudaMemcpyKind,
7295 ) -> cudaError_t;
7296}
7297unsafe extern "C" {
7298 /// # Parameters
7299 ///
7300 /// - `pGraphNode`: Returns newly created node.
7301 /// - `graph`: Graph to which to add the node.
7302 /// - `pDependencies`: Dependencies of the node.
7303 /// - `numDependencies`: Number of dependencies.
7304 /// - `dst`: Destination memory address.
7305 /// - `symbol`: Device symbol address.
7306 /// - `count`: Size in bytes to copy.
7307 /// - `offset`: Offset from start of symbol in bytes.
7308 /// - `kind`: Type of transfer.
7309 pub fn cudaGraphAddMemcpyNodeFromSymbol(
7310 pGraphNode: *mut cudaGraphNode_t,
7311 graph: cudaGraph_t,
7312 pDependencies: *const cudaGraphNode_t,
7313 numDependencies: size_t,
7314 dst: *mut ::core::ffi::c_void,
7315 symbol: *const ::core::ffi::c_void,
7316 count: size_t,
7317 offset: size_t,
7318 kind: cudaMemcpyKind,
7319 ) -> cudaError_t;
7320}
7321unsafe extern "C" {
7322 /// Creates a 1D memcpy node and adds it to a graph.
7323 ///
7324 /// 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.
7325 ///
7326 /// When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that
7327 /// do not match the direction of the copy results in an undefined behavior.
7328 ///
7329 /// Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device
7330 /// which has a zero value for the device attribute [cudaDevAttrConcurrentManagedAccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc88178f29891f2c18fe67361cc80de09).
7331 ///
7332 /// Note:
7333 ///
7334 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7335 /// * Note that this function may also return error codes from previous, asynchronous launches.
7336 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7337 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7338 ///
7339 /// **See also:**
7340 ///
7341 /// [`cudaMemcpy`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParams1D`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemsetNode`].
7342 ///
7343 /// # Parameters
7344 ///
7345 /// - `pGraphNode`: Returns newly created node.
7346 /// - `graph`: Graph to which to add the node.
7347 /// - `pDependencies`: Dependencies of the node.
7348 /// - `numDependencies`: Number of dependencies.
7349 /// - `dst`: Destination memory address.
7350 /// - `src`: Source memory address.
7351 /// - `count`: Size in bytes to copy.
7352 /// - `kind`: Type of transfer.
7353 pub fn cudaGraphAddMemcpyNode1D(
7354 pGraphNode: *mut cudaGraphNode_t,
7355 graph: cudaGraph_t,
7356 pDependencies: *const cudaGraphNode_t,
7357 numDependencies: size_t,
7358 dst: *mut ::core::ffi::c_void,
7359 src: *const ::core::ffi::c_void,
7360 count: size_t,
7361 kind: cudaMemcpyKind,
7362 ) -> cudaError_t;
7363}
7364unsafe extern "C" {
7365 /// Returns a memcpy node's parameters.
7366 ///
7367 /// Returns the parameters of memcpy node node in pNodeParams.
7368 ///
7369 /// Note:
7370 ///
7371 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7372 /// * Note that this function may also return error codes from previous, asynchronous launches.
7373 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7374 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7375 ///
7376 /// **See also:**
7377 ///
7378 /// [`cudaGraphNodeGetParams`], [`cudaMemcpy3D`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeSetParams`].
7379 ///
7380 /// # Parameters
7381 ///
7382 /// - `node`: Node to get the parameters for.
7383 /// - `pNodeParams`: Pointer to return the parameters.
7384 pub fn cudaGraphMemcpyNodeGetParams(
7385 node: cudaGraphNode_t,
7386 pNodeParams: *mut cudaMemcpy3DParms,
7387 ) -> cudaError_t;
7388}
7389unsafe extern "C" {
7390 /// Sets a memcpy node's parameters.
7391 ///
7392 /// Sets the parameters of memcpy node node to pNodeParams.
7393 ///
7394 /// Note:
7395 ///
7396 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7397 /// * Note that this function may also return error codes from previous, asynchronous launches.
7398 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7399 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7400 ///
7401 /// **See also:**
7402 ///
7403 /// [`cudaGraphNodeSetParams`], [`cudaMemcpy3D`], [`cudaGraphMemcpyNodeSetParamsToSymbol`], [`cudaGraphMemcpyNodeSetParamsFromSymbol`], [`cudaGraphMemcpyNodeSetParams1D`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`].
7404 ///
7405 /// # Parameters
7406 ///
7407 /// - `node`: Node to set the parameters for.
7408 /// - `pNodeParams`: Parameters to copy.
7409 pub fn cudaGraphMemcpyNodeSetParams(
7410 node: cudaGraphNode_t,
7411 pNodeParams: *const cudaMemcpy3DParms,
7412 ) -> cudaError_t;
7413}
7414unsafe extern "C" {
7415 /// # Parameters
7416 ///
7417 /// - `node`: Node to set the parameters for.
7418 /// - `symbol`: Device symbol address.
7419 /// - `src`: Source memory address.
7420 /// - `count`: Size in bytes to copy.
7421 /// - `offset`: Offset from start of symbol in bytes.
7422 /// - `kind`: Type of transfer.
7423 pub fn cudaGraphMemcpyNodeSetParamsToSymbol(
7424 node: cudaGraphNode_t,
7425 symbol: *const ::core::ffi::c_void,
7426 src: *const ::core::ffi::c_void,
7427 count: size_t,
7428 offset: size_t,
7429 kind: cudaMemcpyKind,
7430 ) -> cudaError_t;
7431}
7432unsafe extern "C" {
7433 /// # Parameters
7434 ///
7435 /// - `node`: Node to set the parameters for.
7436 /// - `dst`: Destination memory address.
7437 /// - `symbol`: Device symbol address.
7438 /// - `count`: Size in bytes to copy.
7439 /// - `offset`: Offset from start of symbol in bytes.
7440 /// - `kind`: Type of transfer.
7441 pub fn cudaGraphMemcpyNodeSetParamsFromSymbol(
7442 node: cudaGraphNode_t,
7443 dst: *mut ::core::ffi::c_void,
7444 symbol: *const ::core::ffi::c_void,
7445 count: size_t,
7446 offset: size_t,
7447 kind: cudaMemcpyKind,
7448 ) -> cudaError_t;
7449}
7450unsafe extern "C" {
7451 /// Sets a memcpy node's parameters to perform a 1-dimensional copy.
7452 ///
7453 /// Sets the parameters of memcpy node node to the copy described by the provided parameters.
7454 ///
7455 /// When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of [`cudaMemcpyKind::cudaMemcpyHostToHost`], [`cudaMemcpyKind::cudaMemcpyHostToDevice`], [`cudaMemcpyKind::cudaMemcpyDeviceToHost`], [`cudaMemcpyKind::cudaMemcpyDeviceToDevice`], or [`cudaMemcpyKind::cudaMemcpyDefault`]. Passing [`cudaMemcpyKind::cudaMemcpyDefault`] is recommended, in which case the type of transfer is inferred from the pointer values. However, [`cudaMemcpyKind::cudaMemcpyDefault`] is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that
7456 /// do not match the direction of the copy results in an undefined behavior.
7457 ///
7458 /// Note:
7459 ///
7460 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7461 /// * Note that this function may also return error codes from previous, asynchronous launches.
7462 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7463 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7464 ///
7465 /// **See also:**
7466 ///
7467 /// [`cudaMemcpy`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeGetParams`].
7468 ///
7469 /// # Parameters
7470 ///
7471 /// - `node`: Node to set the parameters for.
7472 /// - `dst`: Destination memory address.
7473 /// - `src`: Source memory address.
7474 /// - `count`: Size in bytes to copy.
7475 /// - `kind`: Type of transfer.
7476 pub fn cudaGraphMemcpyNodeSetParams1D(
7477 node: cudaGraphNode_t,
7478 dst: *mut ::core::ffi::c_void,
7479 src: *const ::core::ffi::c_void,
7480 count: size_t,
7481 kind: cudaMemcpyKind,
7482 ) -> cudaError_t;
7483}
7484unsafe extern "C" {
7485 /// Creates a memset node and adds it to a graph.
7486 ///
7487 /// 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.
7488 ///
7489 /// The element size must be 1, 2, or 4 bytes. When the graph is launched, the node will perform the memset described by pMemsetParams.
7490 ///
7491 /// Note:
7492 ///
7493 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7494 /// * Note that this function may also return error codes from previous, asynchronous launches.
7495 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7496 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7497 ///
7498 /// **See also:**
7499 ///
7500 /// [`cudaGraphAddNode`], [`cudaMemset2D`], [`cudaGraphMemsetNodeGetParams`], [`cudaGraphMemsetNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`].
7501 ///
7502 /// # Parameters
7503 ///
7504 /// - `pGraphNode`: Returns newly created node.
7505 /// - `graph`: Graph to which to add the node.
7506 /// - `pDependencies`: Dependencies of the node.
7507 /// - `numDependencies`: Number of dependencies.
7508 /// - `pMemsetParams`: Parameters for the memory set.
7509 pub fn cudaGraphAddMemsetNode(
7510 pGraphNode: *mut cudaGraphNode_t,
7511 graph: cudaGraph_t,
7512 pDependencies: *const cudaGraphNode_t,
7513 numDependencies: size_t,
7514 pMemsetParams: *const cudaMemsetParams,
7515 ) -> cudaError_t;
7516}
7517unsafe extern "C" {
7518 /// Returns a memset node's parameters.
7519 ///
7520 /// Returns the parameters of memset node node in pNodeParams.
7521 ///
7522 /// Note:
7523 ///
7524 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7525 /// * Note that this function may also return error codes from previous, asynchronous launches.
7526 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7527 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7528 ///
7529 /// **See also:**
7530 ///
7531 /// [`cudaGraphNodeGetParams`], [`cudaMemset2D`], [`cudaGraphAddMemsetNode`], [`cudaGraphMemsetNodeSetParams`].
7532 ///
7533 /// # Parameters
7534 ///
7535 /// - `node`: Node to get the parameters for.
7536 /// - `pNodeParams`: Pointer to return the parameters.
7537 pub fn cudaGraphMemsetNodeGetParams(
7538 node: cudaGraphNode_t,
7539 pNodeParams: *mut cudaMemsetParams,
7540 ) -> cudaError_t;
7541}
7542unsafe extern "C" {
7543 /// Sets a memset node's parameters.
7544 ///
7545 /// Sets the parameters of memset node node to pNodeParams.
7546 ///
7547 /// Note:
7548 ///
7549 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7550 /// * Note that this function may also return error codes from previous, asynchronous launches.
7551 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7552 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7553 ///
7554 /// **See also:**
7555 ///
7556 /// [`cudaGraphNodeSetParams`], [`cudaMemset2D`], [`cudaGraphAddMemsetNode`], [`cudaGraphMemsetNodeGetParams`].
7557 ///
7558 /// # Parameters
7559 ///
7560 /// - `node`: Node to set the parameters for.
7561 /// - `pNodeParams`: Parameters to copy.
7562 pub fn cudaGraphMemsetNodeSetParams(
7563 node: cudaGraphNode_t,
7564 pNodeParams: *const cudaMemsetParams,
7565 ) -> cudaError_t;
7566}
7567unsafe extern "C" {
7568 /// Creates a host execution node and adds it to a graph.
7569 ///
7570 /// 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.
7571 ///
7572 /// When the graph is launched, the node will invoke the specified CPU function. Host nodes are not supported under MPS with pre-Volta
7573 /// GPUs.
7574 ///
7575 /// Note:
7576 ///
7577 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7578 /// * Note that this function may also return error codes from previous, asynchronous launches.
7579 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7580 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7581 ///
7582 /// **See also:**
7583 ///
7584 /// [`cudaGraphAddNode`], [`cudaLaunchHostFunc`], [`cudaGraphHostNodeGetParams`], [`cudaGraphHostNodeSetParams`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
7585 ///
7586 /// # Parameters
7587 ///
7588 /// - `pGraphNode`: Returns newly created node.
7589 /// - `graph`: Graph to which to add the node.
7590 /// - `pDependencies`: Dependencies of the node.
7591 /// - `numDependencies`: Number of dependencies.
7592 /// - `pNodeParams`: Parameters for the host node.
7593 pub fn cudaGraphAddHostNode(
7594 pGraphNode: *mut cudaGraphNode_t,
7595 graph: cudaGraph_t,
7596 pDependencies: *const cudaGraphNode_t,
7597 numDependencies: size_t,
7598 pNodeParams: *const cudaHostNodeParams,
7599 ) -> cudaError_t;
7600}
7601unsafe extern "C" {
7602 /// Returns a host node's parameters.
7603 ///
7604 /// Returns the parameters of host node node in pNodeParams.
7605 ///
7606 /// Note:
7607 ///
7608 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7609 /// * Note that this function may also return error codes from previous, asynchronous launches.
7610 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7611 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7612 ///
7613 /// **See also:**
7614 ///
7615 /// [`cudaGraphNodeGetParams`], [`cudaLaunchHostFunc`], [`cudaGraphAddHostNode`], [`cudaGraphHostNodeSetParams`].
7616 ///
7617 /// # Parameters
7618 ///
7619 /// - `node`: Node to get the parameters for.
7620 /// - `pNodeParams`: Pointer to return the parameters.
7621 pub fn cudaGraphHostNodeGetParams(
7622 node: cudaGraphNode_t,
7623 pNodeParams: *mut cudaHostNodeParams,
7624 ) -> cudaError_t;
7625}
7626unsafe extern "C" {
7627 /// Sets a host node's parameters.
7628 ///
7629 /// Sets the parameters of host node node to nodeParams.
7630 ///
7631 /// Note:
7632 ///
7633 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7634 /// * Note that this function may also return error codes from previous, asynchronous launches.
7635 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7636 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7637 ///
7638 /// **See also:**
7639 ///
7640 /// [`cudaGraphNodeSetParams`], [`cudaLaunchHostFunc`], [`cudaGraphAddHostNode`], [`cudaGraphHostNodeGetParams`].
7641 ///
7642 /// # Parameters
7643 ///
7644 /// - `node`: Node to set the parameters for.
7645 /// - `pNodeParams`: Parameters to copy.
7646 pub fn cudaGraphHostNodeSetParams(
7647 node: cudaGraphNode_t,
7648 pNodeParams: *const cudaHostNodeParams,
7649 ) -> cudaError_t;
7650}
7651unsafe extern "C" {
7652 /// Creates a child graph node and adds it to a graph.
7653 ///
7654 /// 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.
7655 ///
7656 /// If childGraph contains allocation nodes, free nodes, or conditional nodes, this call will return an error.
7657 ///
7658 /// The node executes an embedded child graph. The child graph is cloned in this call.
7659 ///
7660 /// Note:
7661 ///
7662 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7663 /// * Note that this function may also return error codes from previous, asynchronous launches.
7664 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7665 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7666 ///
7667 /// **See also:**
7668 ///
7669 /// [`cudaGraphAddNode`], [`cudaGraphChildGraphNodeGetGraph`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`], [`cudaGraphClone`].
7670 ///
7671 /// # Parameters
7672 ///
7673 /// - `pGraphNode`: Returns newly created node.
7674 /// - `graph`: Graph to which to add the node.
7675 /// - `pDependencies`: Dependencies of the node.
7676 /// - `numDependencies`: Number of dependencies.
7677 /// - `childGraph`: The graph to clone into this node.
7678 pub fn cudaGraphAddChildGraphNode(
7679 pGraphNode: *mut cudaGraphNode_t,
7680 graph: cudaGraph_t,
7681 pDependencies: *const cudaGraphNode_t,
7682 numDependencies: size_t,
7683 childGraph: cudaGraph_t,
7684 ) -> cudaError_t;
7685}
7686unsafe extern "C" {
7687 /// Gets a handle to the embedded graph of a child graph node.
7688 ///
7689 /// 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
7690 /// reflected in the node, and the node retains ownership of the graph.
7691 ///
7692 /// Allocation and free nodes cannot be added to the returned graph. Attempting to do so will return an error.
7693 ///
7694 /// Note:
7695 ///
7696 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7697 /// * Note that this function may also return error codes from previous, asynchronous launches.
7698 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7699 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7700 ///
7701 /// **See also:**
7702 ///
7703 /// [`cudaGraphAddChildGraphNode`], [`cudaGraphNodeFindInClone`].
7704 ///
7705 /// # Parameters
7706 ///
7707 /// - `node`: Node to get the embedded graph for.
7708 /// - `pGraph`: Location to store a handle to the graph.
7709 pub fn cudaGraphChildGraphNodeGetGraph(
7710 node: cudaGraphNode_t,
7711 pGraph: *mut cudaGraph_t,
7712 ) -> cudaError_t;
7713}
7714unsafe extern "C" {
7715 /// Creates an empty node and adds it to a graph.
7716 ///
7717 /// 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.
7718 ///
7719 /// An empty node performs no operation during execution, but can be used for transitive ordering. For example, a phased execution
7720 /// graph with 2 groups of n nodes with a barrier between them can be represented using an empty node and 2\*n dependency edges,
7721 /// rather than no empty node and n^2 dependency edges.
7722 ///
7723 /// Note:
7724 ///
7725 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7726 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7727 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7728 ///
7729 /// **See also:**
7730 ///
7731 /// [`cudaGraphAddNode`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
7732 ///
7733 /// # Parameters
7734 ///
7735 /// - `pGraphNode`: Returns newly created node.
7736 /// - `graph`: Graph to which to add the node.
7737 /// - `pDependencies`: Dependencies of the node.
7738 /// - `numDependencies`: Number of dependencies.
7739 pub fn cudaGraphAddEmptyNode(
7740 pGraphNode: *mut cudaGraphNode_t,
7741 graph: cudaGraph_t,
7742 pDependencies: *const cudaGraphNode_t,
7743 numDependencies: size_t,
7744 ) -> cudaError_t;
7745}
7746unsafe extern "C" {
7747 /// Creates an event record node and adds it to a graph.
7748 ///
7749 /// 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.
7750 ///
7751 /// Each launch of the graph will record event to capture execution of the node's dependencies.
7752 ///
7753 /// These nodes may not be used in loops or conditionals.
7754 ///
7755 /// Note:
7756 ///
7757 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7758 /// * Note that this function may also return error codes from previous, asynchronous launches.
7759 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7760 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7761 ///
7762 /// **See also:**
7763 ///
7764 /// [`cudaGraphAddNode`], [`cudaGraphAddEventWaitNode`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
7765 ///
7766 /// # Parameters
7767 ///
7768 /// - `numDependencies`: Number of dependencies.
7769 /// - `event`: Event for the node.
7770 pub fn cudaGraphAddEventRecordNode(
7771 pGraphNode: *mut cudaGraphNode_t,
7772 graph: cudaGraph_t,
7773 pDependencies: *const cudaGraphNode_t,
7774 numDependencies: size_t,
7775 event: cudaEvent_t,
7776 ) -> cudaError_t;
7777}
7778unsafe extern "C" {
7779 /// Returns the event associated with an event record node.
7780 ///
7781 /// Returns the event of event record node hNode in event_out.
7782 ///
7783 /// Note:
7784 ///
7785 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7786 /// * Note that this function may also return error codes from previous, asynchronous launches.
7787 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7788 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7789 ///
7790 /// **See also:**
7791 ///
7792 /// [`cudaGraphAddEventRecordNode`], [`cudaGraphEventRecordNodeSetEvent`], [`cudaGraphEventWaitNodeGetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`].
7793 ///
7794 /// # Parameters
7795 ///
7796 /// - `event_out`: Pointer to return the event.
7797 pub fn cudaGraphEventRecordNodeGetEvent(
7798 node: cudaGraphNode_t,
7799 event_out: *mut cudaEvent_t,
7800 ) -> cudaError_t;
7801}
7802unsafe extern "C" {
7803 /// Sets an event record node's event.
7804 ///
7805 /// Sets the event of event record node hNode to event.
7806 ///
7807 /// Note:
7808 ///
7809 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7810 /// * Note that this function may also return error codes from previous, asynchronous launches.
7811 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7812 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7813 ///
7814 /// **See also:**
7815 ///
7816 /// [`cudaGraphNodeSetParams`], [`cudaGraphAddEventRecordNode`], [`cudaGraphEventRecordNodeGetEvent`], [`cudaGraphEventWaitNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`].
7817 ///
7818 /// # Parameters
7819 ///
7820 /// - `event`: Event to use.
7821 pub fn cudaGraphEventRecordNodeSetEvent(
7822 node: cudaGraphNode_t,
7823 event: cudaEvent_t,
7824 ) -> cudaError_t;
7825}
7826unsafe extern "C" {
7827 /// Creates an event wait node and adds it to a graph.
7828 ///
7829 /// 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.
7830 ///
7831 /// The graph node will wait for all work captured in event. See [cuEventRecord()](https://docs.nvidia.com/cuda/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.
7832 /// event may be from a different context or device than the launch stream.
7833 ///
7834 /// These nodes may not be used in loops or conditionals.
7835 ///
7836 /// Note:
7837 ///
7838 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7839 /// * Note that this function may also return error codes from previous, asynchronous launches.
7840 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7841 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7842 ///
7843 /// **See also:**
7844 ///
7845 /// [`cudaGraphAddNode`], [`cudaGraphAddEventRecordNode`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
7846 ///
7847 /// # Parameters
7848 ///
7849 /// - `numDependencies`: Number of dependencies.
7850 /// - `event`: Event for the node.
7851 pub fn cudaGraphAddEventWaitNode(
7852 pGraphNode: *mut cudaGraphNode_t,
7853 graph: cudaGraph_t,
7854 pDependencies: *const cudaGraphNode_t,
7855 numDependencies: size_t,
7856 event: cudaEvent_t,
7857 ) -> cudaError_t;
7858}
7859unsafe extern "C" {
7860 /// Returns the event associated with an event wait node.
7861 ///
7862 /// Returns the event of event wait node hNode in event_out.
7863 ///
7864 /// Note:
7865 ///
7866 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7867 /// * Note that this function may also return error codes from previous, asynchronous launches.
7868 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7869 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7870 ///
7871 /// **See also:**
7872 ///
7873 /// [`cudaGraphAddEventWaitNode`], [`cudaGraphEventWaitNodeSetEvent`], [`cudaGraphEventRecordNodeGetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`].
7874 ///
7875 /// # Parameters
7876 ///
7877 /// - `event_out`: Pointer to return the event.
7878 pub fn cudaGraphEventWaitNodeGetEvent(
7879 node: cudaGraphNode_t,
7880 event_out: *mut cudaEvent_t,
7881 ) -> cudaError_t;
7882}
7883unsafe extern "C" {
7884 /// Sets an event wait node's event.
7885 ///
7886 /// Sets the event of event wait node hNode to event.
7887 ///
7888 /// Note:
7889 ///
7890 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7891 /// * Note that this function may also return error codes from previous, asynchronous launches.
7892 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7893 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7894 ///
7895 /// **See also:**
7896 ///
7897 /// [`cudaGraphNodeSetParams`], [`cudaGraphAddEventWaitNode`], [`cudaGraphEventWaitNodeGetEvent`], [`cudaGraphEventRecordNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`].
7898 ///
7899 /// # Parameters
7900 ///
7901 /// - `event`: Event to use.
7902 pub fn cudaGraphEventWaitNodeSetEvent(
7903 node: cudaGraphNode_t,
7904 event: cudaEvent_t,
7905 ) -> cudaError_t;
7906}
7907unsafe extern "C" {
7908 /// Creates an external semaphore signal node and adds it to a graph.
7909 ///
7910 /// 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.
7911 ///
7912 /// Performs a signal operation on a set of externally allocated semaphore objects when the node is launched. The operation(s)
7913 /// will occur after all of the node's dependencies have completed.
7914 ///
7915 /// Note:
7916 ///
7917 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7918 /// * Note that this function may also return error codes from previous, asynchronous launches.
7919 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7920 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7921 ///
7922 /// **See also:**
7923 ///
7924 /// [`cudaGraphAddNode`], [`cudaGraphExternalSemaphoresSignalNodeGetParams`], [`cudaGraphExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
7925 ///
7926 /// # Parameters
7927 ///
7928 /// - `pGraphNode`: Returns newly created node.
7929 /// - `graph`: Graph to which to add the node.
7930 /// - `pDependencies`: Dependencies of the node.
7931 /// - `numDependencies`: Number of dependencies.
7932 /// - `nodeParams`: Parameters for the node.
7933 pub fn cudaGraphAddExternalSemaphoresSignalNode(
7934 pGraphNode: *mut cudaGraphNode_t,
7935 graph: cudaGraph_t,
7936 pDependencies: *const cudaGraphNode_t,
7937 numDependencies: size_t,
7938 nodeParams: *const cudaExternalSemaphoreSignalNodeParams,
7939 ) -> cudaError_t;
7940}
7941unsafe extern "C" {
7942 /// Returns an external semaphore signal node's parameters.
7943 ///
7944 /// 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
7945 /// not be modified directly. Use [`cudaGraphExternalSemaphoresSignalNodeSetParams`] to update the parameters of this node.
7946 ///
7947 /// Note:
7948 ///
7949 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7950 /// * Note that this function may also return error codes from previous, asynchronous launches.
7951 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7952 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7953 ///
7954 /// **See also:**
7955 ///
7956 /// [`cudaGraphNodeGetParams`], [`cudaLaunchKernel`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphExternalSemaphoresSignalNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
7957 ///
7958 /// # Parameters
7959 ///
7960 /// - `hNode`: Node to get the parameters for.
7961 /// - `params_out`: Pointer to return the parameters.
7962 pub fn cudaGraphExternalSemaphoresSignalNodeGetParams(
7963 hNode: cudaGraphNode_t,
7964 params_out: *mut cudaExternalSemaphoreSignalNodeParams,
7965 ) -> cudaError_t;
7966}
7967unsafe extern "C" {
7968 /// Sets an external semaphore signal node's parameters.
7969 ///
7970 /// Sets the parameters of an external semaphore signal node hNode to nodeParams.
7971 ///
7972 /// Note:
7973 ///
7974 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
7975 /// * Note that this function may also return error codes from previous, asynchronous launches.
7976 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
7977 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
7978 ///
7979 /// **See also:**
7980 ///
7981 /// [`cudaGraphNodeSetParams`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphExternalSemaphoresSignalNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
7982 ///
7983 /// # Parameters
7984 ///
7985 /// - `hNode`: Node to set the parameters for.
7986 /// - `nodeParams`: Parameters to copy.
7987 pub fn cudaGraphExternalSemaphoresSignalNodeSetParams(
7988 hNode: cudaGraphNode_t,
7989 nodeParams: *const cudaExternalSemaphoreSignalNodeParams,
7990 ) -> cudaError_t;
7991}
7992unsafe extern "C" {
7993 /// Creates an external semaphore wait node and adds it to a graph.
7994 ///
7995 /// 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.
7996 ///
7997 /// Performs a wait operation on a set of externally allocated semaphore objects when the node is launched. The node's dependencies
7998 /// will not be launched until the wait operation has completed.
7999 ///
8000 /// Note:
8001 ///
8002 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8003 /// * Note that this function may also return error codes from previous, asynchronous launches.
8004 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8005 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8006 ///
8007 /// **See also:**
8008 ///
8009 /// [`cudaGraphAddNode`], [`cudaGraphExternalSemaphoresWaitNodeGetParams`], [`cudaGraphExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
8010 ///
8011 /// # Parameters
8012 ///
8013 /// - `pGraphNode`: Returns newly created node.
8014 /// - `graph`: Graph to which to add the node.
8015 /// - `pDependencies`: Dependencies of the node.
8016 /// - `numDependencies`: Number of dependencies.
8017 /// - `nodeParams`: Parameters for the node.
8018 pub fn cudaGraphAddExternalSemaphoresWaitNode(
8019 pGraphNode: *mut cudaGraphNode_t,
8020 graph: cudaGraph_t,
8021 pDependencies: *const cudaGraphNode_t,
8022 numDependencies: size_t,
8023 nodeParams: *const cudaExternalSemaphoreWaitNodeParams,
8024 ) -> cudaError_t;
8025}
8026unsafe extern "C" {
8027 /// Returns an external semaphore wait node's parameters.
8028 ///
8029 /// 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
8030 /// not be modified directly. Use [`cudaGraphExternalSemaphoresSignalNodeSetParams`] to update the parameters of this node.
8031 ///
8032 /// Note:
8033 ///
8034 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8035 /// * Note that this function may also return error codes from previous, asynchronous launches.
8036 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8037 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8038 ///
8039 /// **See also:**
8040 ///
8041 /// [`cudaGraphNodeGetParams`], [`cudaLaunchKernel`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphExternalSemaphoresWaitNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
8042 ///
8043 /// # Parameters
8044 ///
8045 /// - `hNode`: Node to get the parameters for.
8046 /// - `params_out`: Pointer to return the parameters.
8047 pub fn cudaGraphExternalSemaphoresWaitNodeGetParams(
8048 hNode: cudaGraphNode_t,
8049 params_out: *mut cudaExternalSemaphoreWaitNodeParams,
8050 ) -> cudaError_t;
8051}
8052unsafe extern "C" {
8053 /// Sets an external semaphore wait node's parameters.
8054 ///
8055 /// Sets the parameters of an external semaphore wait node hNode to nodeParams.
8056 ///
8057 /// Note:
8058 ///
8059 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8060 /// * Note that this function may also return error codes from previous, asynchronous launches.
8061 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8062 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8063 ///
8064 /// **See also:**
8065 ///
8066 /// [`cudaGraphNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphExternalSemaphoresWaitNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`].
8067 ///
8068 /// # Parameters
8069 ///
8070 /// - `hNode`: Node to set the parameters for.
8071 /// - `nodeParams`: Parameters to copy.
8072 pub fn cudaGraphExternalSemaphoresWaitNodeSetParams(
8073 hNode: cudaGraphNode_t,
8074 nodeParams: *const cudaExternalSemaphoreWaitNodeParams,
8075 ) -> cudaError_t;
8076}
8077unsafe extern "C" {
8078 /// Creates an allocation node and adds it to a graph.
8079 ///
8080 /// 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.
8081 ///
8082 /// 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.
8083 ///
8084 /// 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
8085 /// be freed outside the owning graph, and they can only be freed once in the owning graph.
8086 ///
8087 /// 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
8088 /// after the allocation node, but also by stream operations ordered after the graph's execution but before the allocation is
8089 /// freed.
8090 ///
8091 /// Allocations which are not freed in the same graph can be freed by:
8092 ///
8093 /// * passing the allocation to cudaMemFreeAsync or cudaMemFree;
8094 /// * launching a graph with a free node for that allocation; or
8095 /// * specifying [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f) during instantiation, which makes each launch behave as though it called cudaMemFreeAsync for every unfreed allocation.
8096 ///
8097 /// It is not possible to free an allocation in both the owning graph and another graph. If the allocation is freed in the same
8098 /// graph, a free node cannot be added to another graph. If the allocation is freed in another graph, a free node can no longer
8099 /// be added to the owning graph.
8100 ///
8101 /// The following restrictions apply to graphs which contain allocation and/or memory free nodes:
8102 ///
8103 /// * Nodes and edges of the graph cannot be deleted.
8104 /// * The graph can only be used in a child node if the ownership is moved to the parent.
8105 /// * Only one instantiation of the graph may exist at any point in time.
8106 /// * The graph cannot be cloned.
8107 ///
8108 /// Note:
8109 ///
8110 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8111 /// * Note that this function may also return error codes from previous, asynchronous launches.
8112 ///
8113 /// **See also:**
8114 ///
8115 /// [`cudaGraphAddNode`], [`cudaGraphAddMemFreeNode`], [`cudaGraphMemAllocNodeGetParams`], [`cudaDeviceGraphMemTrim`], [`cudaDeviceGetGraphMemAttribute`], [`cudaDeviceSetGraphMemAttribute`], [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
8116 ///
8117 /// # Parameters
8118 ///
8119 /// - `pGraphNode`: Returns newly created node.
8120 /// - `graph`: Graph to which to add the node.
8121 /// - `pDependencies`: Dependencies of the node.
8122 /// - `numDependencies`: Number of dependencies.
8123 /// - `nodeParams`: Parameters for the node.
8124 pub fn cudaGraphAddMemAllocNode(
8125 pGraphNode: *mut cudaGraphNode_t,
8126 graph: cudaGraph_t,
8127 pDependencies: *const cudaGraphNode_t,
8128 numDependencies: size_t,
8129 nodeParams: *mut cudaMemAllocNodeParams,
8130 ) -> cudaError_t;
8131}
8132unsafe extern "C" {
8133 /// Returns a memory alloc node's parameters.
8134 ///
8135 /// 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.
8136 ///
8137 /// Note:
8138 ///
8139 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8140 /// * Note that this function may also return error codes from previous, asynchronous launches.
8141 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8142 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8143 ///
8144 /// **See also:**
8145 ///
8146 /// [`cudaGraphNodeGetParams`], [`cudaGraphAddMemAllocNode`], [`cudaGraphMemFreeNodeGetParams`].
8147 ///
8148 /// # Parameters
8149 ///
8150 /// - `node`: Node to get the parameters for.
8151 /// - `params_out`: Pointer to return the parameters.
8152 pub fn cudaGraphMemAllocNodeGetParams(
8153 node: cudaGraphNode_t,
8154 params_out: *mut cudaMemAllocNodeParams,
8155 ) -> cudaError_t;
8156}
8157unsafe extern "C" {
8158 /// Creates a memory free node and adds it to a graph.
8159 ///
8160 /// 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.
8161 ///
8162 /// [`cudaGraphAddMemFreeNode`] will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if the user attempts to free:
8163 ///
8164 /// * an allocation twice in the same graph.
8165 /// * an address that was not returned by an allocation node.
8166 /// * an invalid address.
8167 ///
8168 /// The following restrictions apply to graphs which contain allocation and/or memory free nodes:
8169 ///
8170 /// * Nodes and edges of the graph cannot be deleted.
8171 /// * The graph can only be used in a child node if the ownership is moved to the parent.
8172 /// * Only one instantiation of the graph may exist at any point in time.
8173 /// * The graph cannot be cloned.
8174 ///
8175 /// Note:
8176 ///
8177 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8178 /// * Note that this function may also return error codes from previous, asynchronous launches.
8179 ///
8180 /// **See also:**
8181 ///
8182 /// [`cudaGraphAddNode`], [`cudaGraphAddMemAllocNode`], [`cudaGraphMemFreeNodeGetParams`], [`cudaDeviceGraphMemTrim`], [`cudaDeviceGetGraphMemAttribute`], [`cudaDeviceSetGraphMemAttribute`], [`cudaMallocAsync`], [`cudaFreeAsync`], [`cudaGraphCreate`], [`cudaGraphDestroyNode`], [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddEventRecordNode`], [`cudaGraphAddEventWaitNode`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
8183 ///
8184 /// # Parameters
8185 ///
8186 /// - `pGraphNode`: Returns newly created node.
8187 /// - `graph`: Graph to which to add the node.
8188 /// - `pDependencies`: Dependencies of the node.
8189 /// - `numDependencies`: Number of dependencies.
8190 /// - `dptr`: Address of memory to free.
8191 pub fn cudaGraphAddMemFreeNode(
8192 pGraphNode: *mut cudaGraphNode_t,
8193 graph: cudaGraph_t,
8194 pDependencies: *const cudaGraphNode_t,
8195 numDependencies: size_t,
8196 dptr: *mut ::core::ffi::c_void,
8197 ) -> cudaError_t;
8198}
8199unsafe extern "C" {
8200 /// Returns a memory free node's parameters.
8201 ///
8202 /// Returns the address of a memory free node hNode in dptr_out.
8203 ///
8204 /// Note:
8205 ///
8206 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8207 /// * Note that this function may also return error codes from previous, asynchronous launches.
8208 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8209 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8210 ///
8211 /// **See also:**
8212 ///
8213 /// [`cudaGraphNodeGetParams`], [`cudaGraphAddMemFreeNode`], [`cudaGraphMemFreeNodeGetParams`].
8214 ///
8215 /// # Parameters
8216 ///
8217 /// - `node`: Node to get the parameters for.
8218 /// - `dptr_out`: Pointer to return the device address.
8219 pub fn cudaGraphMemFreeNodeGetParams(
8220 node: cudaGraphNode_t,
8221 dptr_out: *mut ::core::ffi::c_void,
8222 ) -> cudaError_t;
8223}
8224unsafe extern "C" {
8225 /// Free unused memory that was cached on the specified device for use with graphs back to the OS.
8226 ///
8227 /// Blocks which are not in use by a graph that is either currently executing or scheduled to execute are freed back to the operating
8228 /// system.
8229 ///
8230 /// Note:
8231 ///
8232 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8233 /// * Note that this function may also return error codes from previous, asynchronous launches.
8234 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8235 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8236 ///
8237 /// **See also:**
8238 ///
8239 /// [`cudaGraphAddMemAllocNode`], [`cudaGraphAddMemFreeNode`], [`cudaDeviceGetGraphMemAttribute`], [`cudaDeviceSetGraphMemAttribute`], [`cudaMallocAsync`], [`cudaFreeAsync`].
8240 ///
8241 /// # Parameters
8242 ///
8243 /// - `device`: The device for which cached memory should be freed.
8244 pub fn cudaDeviceGraphMemTrim(device: ::core::ffi::c_int) -> cudaError_t;
8245}
8246unsafe extern "C" {
8247 /// Query asynchronous allocation attributes related to graphs.
8248 ///
8249 /// Valid attributes are:
8250 ///
8251 /// * [cudaGraphMemAttrUsedMemCurrent](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba6872828f088bcae83289bdc6bf9e9cf32): Amount of memory, in bytes, currently associated with graphs
8252 /// * [cudaGraphMemAttrUsedMemHigh](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
8253 /// reset to zero.
8254 /// * [cudaGraphMemAttrReservedMemCurrent](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba68634b0b4cf96510b19cc684052505a43): Amount of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
8255 /// * [cudaGraphMemAttrReservedMemHigh](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba611955e0833a2fab17aeb4a6026c6f542): High watermark of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
8256 ///
8257 /// Note:
8258 ///
8259 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8260 /// * Note that this function may also return error codes from previous, asynchronous launches.
8261 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8262 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8263 ///
8264 /// **See also:**
8265 ///
8266 /// [`cudaDeviceSetGraphMemAttribute`], [`cudaGraphAddMemAllocNode`], [`cudaGraphAddMemFreeNode`], [`cudaDeviceGraphMemTrim`], [`cudaMallocAsync`], [`cudaFreeAsync`].
8267 ///
8268 /// # Parameters
8269 ///
8270 /// - `device`: Specifies the scope of the query.
8271 /// - `attr`: attribute to get.
8272 /// - `value`: retrieved value.
8273 pub fn cudaDeviceGetGraphMemAttribute(
8274 device: ::core::ffi::c_int,
8275 attr: cudaGraphMemAttributeType,
8276 value: *mut ::core::ffi::c_void,
8277 ) -> cudaError_t;
8278}
8279unsafe extern "C" {
8280 /// Set asynchronous allocation attributes related to graphs.
8281 ///
8282 /// Valid attributes are:
8283 ///
8284 /// * [cudaGraphMemAttrUsedMemHigh](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
8285 /// reset to zero.
8286 /// * [cudaGraphMemAttrReservedMemHigh](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg4764cb94cff3171bdc738dd11a4c2ba611955e0833a2fab17aeb4a6026c6f542): High watermark of memory, in bytes, currently allocated for use by the CUDA graphs asynchronous allocator.
8287 ///
8288 /// Note:
8289 ///
8290 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8291 /// * Note that this function may also return error codes from previous, asynchronous launches.
8292 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8293 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8294 ///
8295 /// **See also:**
8296 ///
8297 /// [`cudaDeviceGetGraphMemAttribute`], [`cudaGraphAddMemAllocNode`], [`cudaGraphAddMemFreeNode`], [`cudaDeviceGraphMemTrim`], [`cudaMallocAsync`], [`cudaFreeAsync`].
8298 ///
8299 /// # Parameters
8300 ///
8301 /// - `device`: Specifies the scope of the query.
8302 /// - `attr`: attribute to get.
8303 /// - `value`: pointer to value to set.
8304 pub fn cudaDeviceSetGraphMemAttribute(
8305 device: ::core::ffi::c_int,
8306 attr: cudaGraphMemAttributeType,
8307 value: *mut ::core::ffi::c_void,
8308 ) -> cudaError_t;
8309}
8310unsafe extern "C" {
8311 /// Clones a graph.
8312 ///
8313 /// 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
8314 /// clone.
8315 ///
8316 /// Child graph nodes in the original graph are recursively copied into the clone.
8317 ///
8318 /// Note:
8319 ///
8320 /// : Cloning is not supported for graphs which contain memory allocation nodes, memory free nodes, or conditional nodes.
8321 ///
8322 /// Note:
8323 ///
8324 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8325 /// * Note that this function may also return error codes from previous, asynchronous launches.
8326 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8327 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8328 ///
8329 /// **See also:**
8330 ///
8331 /// [`cudaGraphCreate`], [`cudaGraphNodeFindInClone`].
8332 ///
8333 /// # Parameters
8334 ///
8335 /// - `pGraphClone`: Returns newly created cloned graph.
8336 /// - `originalGraph`: Graph to clone.
8337 pub fn cudaGraphClone(
8338 pGraphClone: *mut cudaGraph_t,
8339 originalGraph: cudaGraph_t,
8340 ) -> cudaError_t;
8341}
8342unsafe extern "C" {
8343 /// Finds a cloned version of a node.
8344 ///
8345 /// This function returns the node in clonedGraph corresponding to originalNode in the original graph.
8346 ///
8347 /// 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.
8348 ///
8349 /// Note:
8350 ///
8351 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8352 /// * Note that this function may also return error codes from previous, asynchronous launches.
8353 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8354 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8355 ///
8356 /// **See also:**
8357 ///
8358 /// [`cudaGraphClone`].
8359 ///
8360 /// # Parameters
8361 ///
8362 /// - `pNode`: Returns handle to the cloned node.
8363 /// - `originalNode`: Handle to the original node.
8364 /// - `clonedGraph`: Cloned graph to query.
8365 pub fn cudaGraphNodeFindInClone(
8366 pNode: *mut cudaGraphNode_t,
8367 originalNode: cudaGraphNode_t,
8368 clonedGraph: cudaGraph_t,
8369 ) -> cudaError_t;
8370}
8371unsafe extern "C" {
8372 /// Returns a node's type.
8373 ///
8374 /// Returns the node type of node in pType.
8375 ///
8376 /// Note:
8377 ///
8378 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8379 /// * Note that this function may also return error codes from previous, asynchronous launches.
8380 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8381 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8382 ///
8383 /// **See also:**
8384 ///
8385 /// [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphChildGraphNodeGetGraph`], [`cudaGraphKernelNodeGetParams`], [`cudaGraphKernelNodeSetParams`], [`cudaGraphHostNodeGetParams`], [`cudaGraphHostNodeSetParams`], [`cudaGraphMemcpyNodeGetParams`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemsetNodeGetParams`], [`cudaGraphMemsetNodeSetParams`].
8386 ///
8387 /// # Parameters
8388 ///
8389 /// - `node`: Node to query.
8390 /// - `pType`: Pointer to return the node type.
8391 pub fn cudaGraphNodeGetType(
8392 node: cudaGraphNode_t,
8393 pType: *mut cudaGraphNodeType,
8394 ) -> cudaError_t;
8395}
8396unsafe extern "C" {
8397 /// Returns the graph that contains a given graph node.
8398 ///
8399 /// Returns the graph that contains hNode in \*phGraph. If hNode is in a child graph, the child graph it is in is returned.
8400 ///
8401 /// **See also:**
8402 ///
8403 /// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`]cudaGraphNodeGetLocalId [`cudaGraphNodeGetToolsId`]cudaGraphGetId [`cudaGraphExecGetId`].
8404 ///
8405 /// # Parameters
8406 ///
8407 /// - `hNode`: Node to query.
8408 /// - `phGraph`: Pointer to return the containing graph.
8409 pub fn cudaGraphNodeGetContainingGraph(
8410 hNode: cudaGraphNode_t,
8411 phGraph: *mut cudaGraph_t,
8412 ) -> cudaError_t;
8413}
8414unsafe extern "C" {
8415 /// Returns the node id of a given graph node.
8416 ///
8417 /// 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.
8418 ///
8419 /// **See also:**
8420 ///
8421 /// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`]cudaGraphNodeGetContainingGraph [`cudaGraphNodeGetToolsId`]cudaGraphGetId [`cudaGraphExecGetId`].
8422 ///
8423 /// # Parameters
8424 ///
8425 /// - `hNode`: Node to query.
8426 /// - `nodeId`: Pointer to return the nodeId.
8427 pub fn cudaGraphNodeGetLocalId(
8428 hNode: cudaGraphNode_t,
8429 nodeId: *mut ::core::ffi::c_uint,
8430 ) -> cudaError_t;
8431}
8432unsafe extern "C" {
8433 /// Returns an id used by tools to identify a given node.
8434 ///
8435 /// **See also:**
8436 ///
8437 /// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`]cudaGraphNodeGetContainingGraph [`cudaGraphNodeGetLocalId`]cudaGraphGetId [`cudaGraphExecGetId`].
8438 ///
8439 /// # Parameters
8440 ///
8441 /// - `hNode`: Node to query.
8442 pub fn cudaGraphNodeGetToolsId(
8443 hNode: cudaGraphNode_t,
8444 toolsNodeId: *mut ::core::ffi::c_ulonglong,
8445 ) -> cudaError_t;
8446}
8447unsafe extern "C" {
8448 /// Returns the id of a given graph.
8449 ///
8450 /// Returns the id of hGraph in \*graphId. The value in \*graphId matches that referenced by [`cudaGraphDebugDotPrint`].
8451 ///
8452 /// **See also:**
8453 ///
8454 /// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`]cudaGraphNodeGetContainingGraph [`cudaGraphNodeGetLocalId`]cudaGraphNodeGetToolsId [`cudaGraphExecGetId`].
8455 ///
8456 /// # Parameters
8457 ///
8458 /// - `hGraph`: Graph to query.
8459 pub fn cudaGraphGetId(
8460 hGraph: cudaGraph_t,
8461 graphID: *mut ::core::ffi::c_uint,
8462 ) -> cudaError_t;
8463}
8464unsafe extern "C" {
8465 /// Returns the id of a given graph exec.
8466 ///
8467 /// Returns the id of hGraphExec in \*graphId. The value in \*graphId matches that referenced by [`cudaGraphDebugDotPrint`].
8468 ///
8469 /// **See also:**
8470 ///
8471 /// [`cudaGraphGetNodes`], [`cudaGraphDebugDotPrint`]cudaGraphNodeGetContainingGraph [`cudaGraphNodeGetLocalId`]cudaGraphNodeGetToolsId [`cudaGraphGetId`].
8472 ///
8473 /// # Parameters
8474 ///
8475 /// - `hGraphExec`: Graph to query.
8476 pub fn cudaGraphExecGetId(
8477 hGraphExec: cudaGraphExec_t,
8478 graphID: *mut ::core::ffi::c_uint,
8479 ) -> cudaError_t;
8480}
8481unsafe extern "C" {
8482 /// Returns a graph's nodes.
8483 ///
8484 /// 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.
8485 ///
8486 /// Note:
8487 ///
8488 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8489 /// * Note that this function may also return error codes from previous, asynchronous launches.
8490 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8491 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8492 ///
8493 /// **See also:**
8494 ///
8495 /// [`cudaGraphCreate`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetType`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
8496 ///
8497 /// # Parameters
8498 ///
8499 /// - `graph`: Graph to query.
8500 /// - `nodes`: Pointer to return the nodes.
8501 /// - `numNodes`: See description.
8502 pub fn cudaGraphGetNodes(
8503 graph: cudaGraph_t,
8504 nodes: *mut cudaGraphNode_t,
8505 numNodes: *mut size_t,
8506 ) -> cudaError_t;
8507}
8508unsafe extern "C" {
8509 /// Returns a graph's root nodes.
8510 ///
8511 /// 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.
8512 ///
8513 /// Note:
8514 ///
8515 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8516 /// * Note that this function may also return error codes from previous, asynchronous launches.
8517 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8518 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8519 ///
8520 /// **See also:**
8521 ///
8522 /// [`cudaGraphCreate`], [`cudaGraphGetNodes`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetType`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
8523 ///
8524 /// # Parameters
8525 ///
8526 /// - `graph`: Graph to query.
8527 /// - `pRootNodes`: Pointer to return the root nodes.
8528 /// - `pNumRootNodes`: See description.
8529 pub fn cudaGraphGetRootNodes(
8530 graph: cudaGraph_t,
8531 pRootNodes: *mut cudaGraphNode_t,
8532 pNumRootNodes: *mut size_t,
8533 ) -> cudaError_t;
8534}
8535unsafe extern "C" {
8536 /// Returns a graph's dependency edges.
8537 ///
8538 /// Returns a list of graph's dependency edges. Edges are returned via corresponding indices in from, to and edgeData; that is, the node in to\[i\] has a dependency on the node in from\[i\] with data edgeData\[i\]. from and to may both be NULL, in which case this function only returns the number of edges in numEdges. Otherwise, numEdges entries will be filled in. If numEdges is higher than the actual number of edges, the remaining entries in from and to will be set to NULL, and the number of edges actually returned will be written to numEdges. edgeData may alone be NULL, in which case the edges must all have default (zeroed) edge data. Attempting a losst query via NULL edgeData will result in [cudaErrorLossyQuery](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d484d9d8e8f269cf93d4c111b646f908). If edgeData is non-NULL then from and to must be as well.
8539 ///
8540 /// Note:
8541 ///
8542 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8543 /// * Note that this function may also return error codes from previous, asynchronous launches.
8544 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8545 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8546 ///
8547 /// **See also:**
8548 ///
8549 /// [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphAddDependencies`], [`cudaGraphRemoveDependencies`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
8550 ///
8551 /// # Parameters
8552 ///
8553 /// - `graph`: Graph to get the edges from.
8554 /// - `from`: Location to return edge endpoints.
8555 /// - `to`: Location to return edge endpoints.
8556 /// - `edgeData`: Optional location to return edge data.
8557 /// - `numEdges`: See description.
8558 pub fn cudaGraphGetEdges(
8559 graph: cudaGraph_t,
8560 from: *mut cudaGraphNode_t,
8561 to: *mut cudaGraphNode_t,
8562 edgeData: *mut cudaGraphEdgeData,
8563 numEdges: *mut size_t,
8564 ) -> cudaError_t;
8565}
8566unsafe extern "C" {
8567 /// Returns a node's dependencies.
8568 ///
8569 /// 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.
8570 ///
8571 /// Note that if an edge has non-zero (non-default) edge data and edgeData is NULL, this API will return [cudaErrorLossyQuery](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d484d9d8e8f269cf93d4c111b646f908). If edgeData is non-NULL, then pDependencies must be as well.
8572 ///
8573 /// Note:
8574 ///
8575 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8576 /// * Note that this function may also return error codes from previous, asynchronous launches.
8577 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8578 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8579 ///
8580 /// **See also:**
8581 ///
8582 /// [`cudaGraphNodeGetDependentNodes`], [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphAddDependencies`], [`cudaGraphRemoveDependencies`].
8583 ///
8584 /// # Parameters
8585 ///
8586 /// - `node`: Node to query.
8587 /// - `pDependencies`: Pointer to return the dependencies.
8588 /// - `edgeData`: Optional array to return edge data for each dependency.
8589 /// - `pNumDependencies`: See description.
8590 pub fn cudaGraphNodeGetDependencies(
8591 node: cudaGraphNode_t,
8592 pDependencies: *mut cudaGraphNode_t,
8593 edgeData: *mut cudaGraphEdgeData,
8594 pNumDependencies: *mut size_t,
8595 ) -> cudaError_t;
8596}
8597unsafe extern "C" {
8598 /// Returns a node's dependent nodes.
8599 ///
8600 /// 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.
8601 ///
8602 /// Note that if an edge has non-zero (non-default) edge data and edgeData is NULL, this API will return [cudaErrorLossyQuery](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038d484d9d8e8f269cf93d4c111b646f908). If edgeData is non-NULL, then pDependentNodes must be as well.
8603 ///
8604 /// Note:
8605 ///
8606 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8607 /// * Note that this function may also return error codes from previous, asynchronous launches.
8608 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8609 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8610 ///
8611 /// **See also:**
8612 ///
8613 /// [`cudaGraphNodeGetDependencies`], [`cudaGraphGetNodes`], [`cudaGraphGetRootNodes`], [`cudaGraphGetEdges`], [`cudaGraphAddDependencies`], [`cudaGraphRemoveDependencies`].
8614 ///
8615 /// # Parameters
8616 ///
8617 /// - `node`: Node to query.
8618 /// - `pDependentNodes`: Pointer to return the dependent nodes.
8619 /// - `edgeData`: Optional pointer to return edge data for dependent nodes.
8620 /// - `pNumDependentNodes`: See description.
8621 pub fn cudaGraphNodeGetDependentNodes(
8622 node: cudaGraphNode_t,
8623 pDependentNodes: *mut cudaGraphNode_t,
8624 edgeData: *mut cudaGraphEdgeData,
8625 pNumDependentNodes: *mut size_t,
8626 ) -> cudaError_t;
8627}
8628unsafe extern "C" {
8629 /// Adds dependency edges to a graph.
8630 ///
8631 /// 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.
8632 ///
8633 /// If numDependencies is 0, elements in pFrom and pTo will be ignored. Specifying an existing dependency will return an error.
8634 ///
8635 /// Note:
8636 ///
8637 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8638 /// * Note that this function may also return error codes from previous, asynchronous launches.
8639 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8640 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8641 ///
8642 /// **See also:**
8643 ///
8644 /// [`cudaGraphRemoveDependencies`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
8645 ///
8646 /// # Parameters
8647 ///
8648 /// - `graph`: Graph to which dependencies are added.
8649 /// - `from`: Array of nodes that provide the dependencies.
8650 /// - `to`: Array of dependent nodes.
8651 /// - `edgeData`: Optional array of edge data. If NULL, default (zeroed) edge data is assumed.
8652 /// - `numDependencies`: Number of dependencies to be added.
8653 pub fn cudaGraphAddDependencies(
8654 graph: cudaGraph_t,
8655 from: *const cudaGraphNode_t,
8656 to: *const cudaGraphNode_t,
8657 edgeData: *const cudaGraphEdgeData,
8658 numDependencies: size_t,
8659 ) -> cudaError_t;
8660}
8661unsafe extern "C" {
8662 /// Removes dependency edges from a graph.
8663 ///
8664 /// 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.
8665 ///
8666 /// 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.
8667 ///
8668 /// Note:
8669 ///
8670 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8671 /// * Note that this function may also return error codes from previous, asynchronous launches.
8672 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8673 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8674 ///
8675 /// **See also:**
8676 ///
8677 /// [`cudaGraphAddDependencies`], [`cudaGraphGetEdges`], [`cudaGraphNodeGetDependencies`], [`cudaGraphNodeGetDependentNodes`].
8678 ///
8679 /// # Parameters
8680 ///
8681 /// - `graph`: Graph from which to remove dependencies.
8682 /// - `from`: Array of nodes that provide the dependencies.
8683 /// - `to`: Array of dependent nodes.
8684 /// - `edgeData`: Optional array of edge data. If NULL, edge data is assumed to be default (zeroed).
8685 /// - `numDependencies`: Number of dependencies to be removed.
8686 pub fn cudaGraphRemoveDependencies(
8687 graph: cudaGraph_t,
8688 from: *const cudaGraphNode_t,
8689 to: *const cudaGraphNode_t,
8690 edgeData: *const cudaGraphEdgeData,
8691 numDependencies: size_t,
8692 ) -> cudaError_t;
8693}
8694unsafe extern "C" {
8695 /// Remove a node from the graph.
8696 ///
8697 /// Removes node from its graph. This operation also severs any dependencies of other nodes on node and vice versa.
8698 ///
8699 /// Dependencies cannot be removed from graphs which contain allocation or free nodes. Any attempt to do so will return an error.
8700 ///
8701 /// Note:
8702 ///
8703 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8704 /// * Note that this function may also return error codes from previous, asynchronous launches.
8705 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8706 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8707 /// * Use of the handle after this call is undefined behavior.
8708 ///
8709 /// **See also:**
8710 ///
8711 /// [`cudaGraphAddChildGraphNode`], [`cudaGraphAddEmptyNode`], [`cudaGraphAddKernelNode`], [`cudaGraphAddHostNode`], [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemsetNode`].
8712 ///
8713 /// # Parameters
8714 ///
8715 /// - `node`: Node to remove.
8716 pub fn cudaGraphDestroyNode(node: cudaGraphNode_t) -> cudaError_t;
8717}
8718unsafe extern "C" {
8719 /// # Parameters
8720 ///
8721 /// - `pGraphExec`: Returns instantiated graph.
8722 /// - `graph`: Graph to instantiate.
8723 pub fn cudaGraphInstantiate(
8724 pGraphExec: *mut cudaGraphExec_t,
8725 graph: cudaGraph_t,
8726 flags: ::core::ffi::c_ulonglong,
8727 ) -> cudaError_t;
8728}
8729unsafe extern "C" {
8730 /// Creates an executable graph from a graph.
8731 ///
8732 /// Instantiates graph as an executable graph. The graph is validated for any structural constraints or intra-node constraints which were not previously
8733 /// validated. If instantiation is successful, a handle to the instantiated graph is returned in pGraphExec.
8734 ///
8735 /// The flags parameter controls the behavior of instantiation and subsequent graph launches. Valid flags are:
8736 ///
8737 /// * [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f), which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before
8738 /// the graph is relaunched.
8739 ///
8740 /// * [cudaGraphInstantiateFlagDeviceLaunch](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090043fee5a1234b9f5d4ef329a660e6e3f5a), which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can
8741 /// be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing.
8742 /// This flag cannot be used in conjunction with [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f).
8743 ///
8744 /// * [cudaGraphInstantiateFlagUseNodePriority](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
8745 /// during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream
8746 /// capture.
8747 ///
8748 /// 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
8749 /// 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.
8750 ///
8751 /// If graph contains kernels which call device-side [`cudaGraphLaunch`] from multiple devices, this will result in an error.
8752 ///
8753 /// Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:
8754 ///
8755 /// * The graph's nodes must reside on a single device.
8756 /// * The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes.
8757 /// * The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are
8758 /// outlined below.
8759 /// * Kernel nodes:
8760 /// + Use of CUDA Dynamic Parallelism is not permitted.
8761 /// + Cooperative launches are permitted as long as MPS is not in use.
8762 /// * Memcpy nodes:
8763 /// + Only copies involving device memory and/or pinned device-mapped host memory are permitted.
8764 /// + Copies involving CUDA arrays are not permitted.
8765 /// + Both operands must be accessible from the current device, and the current device must match the device of other nodes in the
8766 /// ```text
8767 /// graph.
8768 ///
8769 /// ```
8770 /// Note:
8771 ///
8772 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8773 /// * Note that this function may also return error codes from previous, asynchronous launches.
8774 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8775 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8776 ///
8777 /// **See also:**
8778 ///
8779 /// [`cudaGraphInstantiate`], [`cudaGraphCreate`], [`cudaGraphUpload`], [`cudaGraphLaunch`], [`cudaGraphExecDestroy`].
8780 ///
8781 /// # Parameters
8782 ///
8783 /// - `pGraphExec`: Returns instantiated graph.
8784 /// - `graph`: Graph to instantiate.
8785 /// - `flags`: Flags to control instantiation. See [CUgraphInstantiate_flags](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1g070bf5517d3a7915667c256eefce4956).
8786 pub fn cudaGraphInstantiateWithFlags(
8787 pGraphExec: *mut cudaGraphExec_t,
8788 graph: cudaGraph_t,
8789 flags: ::core::ffi::c_ulonglong,
8790 ) -> cudaError_t;
8791}
8792unsafe extern "C" {
8793 /// Creates an executable graph from a graph.
8794 ///
8795 /// 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.
8796 /// If instantiation is successful, a handle to the instantiated graph is returned in pGraphExec.
8797 ///
8798 /// instantiateParams controls the behavior of instantiation and subsequent graph launches, as well as returning more detailed information in the
8799 /// event of an error. `cudaGraphInstantiateParams` is defined as:
8800 ///
8801 /// ```text
8802 /// typedef struct {
8803 /// unsigned long long flags;
8804 /// cudaStream_t uploadStream;
8805 /// cudaGraphNode_t errNode_out;
8806 /// cudaGraphInstantiateResult result_out;
8807 /// } cudaGraphInstantiateParams;
8808 /// ```
8809 ///
8810 /// The flags field controls the behavior of instantiation and subsequent graph launches. Valid flags are:
8811 ///
8812 /// * [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f), which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before
8813 /// the graph is relaunched.
8814 ///
8815 /// * [cudaGraphInstantiateFlagUpload](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d09004565872dd74cc9d97125bf43740345238), which will perform an upload of the graph into uploadStream once the graph has been instantiated.
8816 ///
8817 /// * [cudaGraphInstantiateFlagDeviceLaunch](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090043fee5a1234b9f5d4ef329a660e6e3f5a), which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can
8818 /// be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing.
8819 /// This flag cannot be used in conjunction with [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f).
8820 ///
8821 /// * [cudaGraphInstantiateFlagUseNodePriority](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
8822 /// during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream
8823 /// capture.
8824 ///
8825 /// 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
8826 /// 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.
8827 ///
8828 /// If graph contains kernels which call device-side [`cudaGraphLaunch`] from multiple devices, this will result in an error.
8829 ///
8830 /// Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:
8831 ///
8832 /// * The graph's nodes must reside on a single device.
8833 /// * The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes.
8834 /// * The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are
8835 /// outlined below.
8836 /// * Kernel nodes:
8837 /// + Use of CUDA Dynamic Parallelism is not permitted.
8838 /// + Cooperative launches are permitted as long as MPS is not in use.
8839 /// * Memcpy nodes:
8840 /// + Only copies involving device memory and/or pinned device-mapped host memory are permitted.
8841 /// + Copies involving CUDA arrays are not permitted.
8842 /// + Both operands must be accessible from the current device, and the current device must match the device of other nodes in the
8843 /// ```text
8844 /// graph.
8845 ///
8846 /// ```
8847 /// 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:
8848 ///
8849 /// * [cudaGraphInstantiateError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
8850 /// * [cudaGraphInstantiateInvalidStructure](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3faefd09000966e3b9d6ca5bcf7b2b9d1f6436346e713fc9ddf43408e9b63da0), if the graph structure is invalid. errNode_out will be set to one of the offending nodes.
8851 /// * [cudaGraphInstantiateNodeOperationNotSupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
8852 /// unsupported operations, such as use of CUDA dynamic parallelism within a kernel node. errNode_out will be set to this node.
8853 /// * [cudaGraphInstantiateMultipleDevicesNotSupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
8854 /// 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.
8855 ///
8856 /// If instantiation is successful, result_out will be set to [cudaGraphInstantiateSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3faefd09000966e3b9d6ca5bcf7b2b9d6b92d94f90110623dafb5fe8081f6f45), and hErrNode_out will be set to NULL.
8857 ///
8858 /// Note:
8859 ///
8860 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8861 /// * Note that this function may also return error codes from previous, asynchronous launches.
8862 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8863 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8864 ///
8865 /// **See also:**
8866 ///
8867 /// [`cudaGraphCreate`], [`cudaGraphInstantiate`], [`cudaGraphInstantiateWithFlags`], [`cudaGraphExecDestroy`].
8868 ///
8869 /// # Parameters
8870 ///
8871 /// - `pGraphExec`: Returns instantiated graph.
8872 /// - `graph`: Graph to instantiate.
8873 /// - `instantiateParams`: Instantiation parameters.
8874 pub fn cudaGraphInstantiateWithParams(
8875 pGraphExec: *mut cudaGraphExec_t,
8876 graph: cudaGraph_t,
8877 instantiateParams: *mut cudaGraphInstantiateParams,
8878 ) -> cudaError_t;
8879}
8880unsafe extern "C" {
8881 /// Query the instantiation flags of an executable graph.
8882 ///
8883 /// Returns the flags that were passed to instantiation for the given executable graph. [cudaGraphInstantiateFlagUpload](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d09004565872dd74cc9d97125bf43740345238) will not be returned by this API as it does not affect the resulting executable graph.
8884 ///
8885 /// Note:
8886 ///
8887 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8888 /// * Note that this function may also return error codes from previous, asynchronous launches.
8889 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8890 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8891 ///
8892 /// **See also:**
8893 ///
8894 /// [`cudaGraphInstantiate`], [`cudaGraphInstantiateWithFlags`], [`cudaGraphInstantiateWithParams`].
8895 ///
8896 /// # Parameters
8897 ///
8898 /// - `graphExec`: The executable graph to query.
8899 /// - `flags`: Returns the instantiation flags.
8900 pub fn cudaGraphExecGetFlags(
8901 graphExec: cudaGraphExec_t,
8902 flags: *mut ::core::ffi::c_ulonglong,
8903 ) -> cudaError_t;
8904}
8905unsafe extern "C" {
8906 /// Sets the parameters for a kernel node in the given graphExec.
8907 ///
8908 /// 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.
8909 ///
8910 /// node must not have been removed from the original graph. All nodeParams fields may change, but the following restrictions apply to func updates:
8911 ///
8912 /// * The owning device of the function cannot change.
8913 /// * A node whose function originally did not use CUDA dynamic parallelism cannot be updated to a function which uses CDP
8914 /// * A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side
8915 /// update calls.
8916 /// * 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
8917 /// present at instantiation, these updates cannot be performed at all.
8918 ///
8919 /// 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.
8920 ///
8921 /// 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
8922 /// it is being updated from the device will result in undefined behavior.
8923 ///
8924 /// Note:
8925 ///
8926 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8927 /// * Note that this function may also return error codes from previous, asynchronous launches.
8928 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8929 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8930 /// * The API can also be used with a kernel `cudaKernel_t` by querying the handle using [`cudaLibraryGetKernel`] or [`cudaGetKernel`] and then passing it to the API by casting to void\*. The symbol entryFuncAddr passed to [`cudaGetKernel`] should be a symbol that is registered with the same CUDA Runtime instance.
8931 /// * Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type
8932 /// that can be reliably passed to a different runtime instance is `cudaKernel_t`
8933 ///
8934 /// **See also:**
8935 ///
8936 /// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddKernelNode`], [`cudaGraphKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
8937 ///
8938 /// # Parameters
8939 ///
8940 /// - `hGraphExec`: The executable graph in which to set the specified node.
8941 /// - `node`: kernel node from the graph from which graphExec was instantiated.
8942 /// - `pNodeParams`: Updated Parameters to set.
8943 pub fn cudaGraphExecKernelNodeSetParams(
8944 hGraphExec: cudaGraphExec_t,
8945 node: cudaGraphNode_t,
8946 pNodeParams: *const cudaKernelNodeParams,
8947 ) -> cudaError_t;
8948}
8949unsafe extern "C" {
8950 /// Sets the parameters for a memcpy node in the given graphExec.
8951 ///
8952 /// 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.
8953 ///
8954 /// 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
8955 /// operands and the memory operands in pNodeParams must be 1-dimensional. Zero-length operations are not supported.
8956 ///
8957 /// 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.
8958 ///
8959 /// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if the memory operands' mappings changed or either the original or new memory operands are multidimensional.
8960 ///
8961 /// Note:
8962 ///
8963 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
8964 /// * Note that this function may also return error codes from previous, asynchronous launches.
8965 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
8966 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
8967 ///
8968 /// **See also:**
8969 ///
8970 /// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddMemcpyNode`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParamsToSymbol`], [`cudaGraphExecMemcpyNodeSetParamsFromSymbol`], [`cudaGraphExecMemcpyNodeSetParams1D`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
8971 ///
8972 /// # Parameters
8973 ///
8974 /// - `hGraphExec`: The executable graph in which to set the specified node.
8975 /// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
8976 /// - `pNodeParams`: Updated Parameters to set.
8977 pub fn cudaGraphExecMemcpyNodeSetParams(
8978 hGraphExec: cudaGraphExec_t,
8979 node: cudaGraphNode_t,
8980 pNodeParams: *const cudaMemcpy3DParms,
8981 ) -> cudaError_t;
8982}
8983unsafe extern "C" {
8984 /// # Parameters
8985 ///
8986 /// - `hGraphExec`: The executable graph in which to set the specified node.
8987 /// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
8988 /// - `symbol`: Device symbol address.
8989 /// - `src`: Source memory address.
8990 /// - `count`: Size in bytes to copy.
8991 /// - `offset`: Offset from start of symbol in bytes.
8992 /// - `kind`: Type of transfer.
8993 pub fn cudaGraphExecMemcpyNodeSetParamsToSymbol(
8994 hGraphExec: cudaGraphExec_t,
8995 node: cudaGraphNode_t,
8996 symbol: *const ::core::ffi::c_void,
8997 src: *const ::core::ffi::c_void,
8998 count: size_t,
8999 offset: size_t,
9000 kind: cudaMemcpyKind,
9001 ) -> cudaError_t;
9002}
9003unsafe extern "C" {
9004 /// # Parameters
9005 ///
9006 /// - `hGraphExec`: The executable graph in which to set the specified node.
9007 /// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
9008 /// - `dst`: Destination memory address.
9009 /// - `symbol`: Device symbol address.
9010 /// - `count`: Size in bytes to copy.
9011 /// - `offset`: Offset from start of symbol in bytes.
9012 /// - `kind`: Type of transfer.
9013 pub fn cudaGraphExecMemcpyNodeSetParamsFromSymbol(
9014 hGraphExec: cudaGraphExec_t,
9015 node: cudaGraphNode_t,
9016 dst: *mut ::core::ffi::c_void,
9017 symbol: *const ::core::ffi::c_void,
9018 count: size_t,
9019 offset: size_t,
9020 kind: cudaMemcpyKind,
9021 ) -> cudaError_t;
9022}
9023unsafe extern "C" {
9024 /// Sets the parameters for a memcpy node in the given graphExec to perform a 1-dimensional copy.
9025 ///
9026 /// 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.
9027 ///
9028 /// src and dst must be allocated from the same contexts as the original source and destination memory. The instantiation-time memory operands
9029 /// must be 1-dimensional. Zero-length operations are not supported.
9030 ///
9031 /// 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.
9032 ///
9033 /// Returns [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c) if the memory operands' mappings changed or the original memory operands are multidimensional.
9034 ///
9035 /// Note:
9036 ///
9037 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9038 /// * Note that this function may also return error codes from previous, asynchronous launches.
9039 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9040 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9041 ///
9042 /// **See also:**
9043 ///
9044 /// [`cudaGraphAddMemcpyNode`], [`cudaGraphAddMemcpyNode1D`], [`cudaGraphMemcpyNodeSetParams`], [`cudaGraphMemcpyNodeSetParams1D`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
9045 ///
9046 /// # Parameters
9047 ///
9048 /// - `hGraphExec`: The executable graph in which to set the specified node.
9049 /// - `node`: Memcpy node from the graph which was used to instantiate graphExec.
9050 /// - `dst`: Destination memory address.
9051 /// - `src`: Source memory address.
9052 /// - `count`: Size in bytes to copy.
9053 /// - `kind`: Type of transfer.
9054 pub fn cudaGraphExecMemcpyNodeSetParams1D(
9055 hGraphExec: cudaGraphExec_t,
9056 node: cudaGraphNode_t,
9057 dst: *mut ::core::ffi::c_void,
9058 src: *const ::core::ffi::c_void,
9059 count: size_t,
9060 kind: cudaMemcpyKind,
9061 ) -> cudaError_t;
9062}
9063unsafe extern "C" {
9064 /// Sets the parameters for a memset node in the given graphExec.
9065 ///
9066 /// 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.
9067 ///
9068 /// Zero sized operations are not supported.
9069 ///
9070 /// 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
9071 /// mapping as the original destination pointer.
9072 ///
9073 /// Both the value and pointer address may be updated. Changing other aspects of the memset (width, height, element size or pitch)
9074 /// may cause the update to be rejected. Specifically, for 2d memsets, all dimension changes are rejected. For 1d memsets, changes
9075 /// in height are explicitly rejected and other changes are opportunistically allowed if the resulting work maps onto the work
9076 /// resources already allocated for the node.
9077 ///
9078 /// 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.
9079 ///
9080 /// Note:
9081 ///
9082 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9083 /// * Note that this function may also return error codes from previous, asynchronous launches.
9084 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9085 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9086 ///
9087 /// **See also:**
9088 ///
9089 /// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddMemsetNode`], [`cudaGraphMemsetNodeSetParams`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
9090 ///
9091 /// # Parameters
9092 ///
9093 /// - `hGraphExec`: The executable graph in which to set the specified node.
9094 /// - `node`: Memset node from the graph which was used to instantiate graphExec.
9095 /// - `pNodeParams`: Updated Parameters to set.
9096 pub fn cudaGraphExecMemsetNodeSetParams(
9097 hGraphExec: cudaGraphExec_t,
9098 node: cudaGraphNode_t,
9099 pNodeParams: *const cudaMemsetParams,
9100 ) -> cudaError_t;
9101}
9102unsafe extern "C" {
9103 /// Sets the parameters for a host node in the given graphExec.
9104 ///
9105 /// 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.
9106 ///
9107 /// 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.
9108 ///
9109 /// Note:
9110 ///
9111 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9112 /// * Note that this function may also return error codes from previous, asynchronous launches.
9113 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9114 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9115 ///
9116 /// **See also:**
9117 ///
9118 /// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddHostNode`], [`cudaGraphHostNodeSetParams`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
9119 ///
9120 /// # Parameters
9121 ///
9122 /// - `hGraphExec`: The executable graph in which to set the specified node.
9123 /// - `node`: Host node from the graph which was used to instantiate graphExec.
9124 /// - `pNodeParams`: Updated Parameters to set.
9125 pub fn cudaGraphExecHostNodeSetParams(
9126 hGraphExec: cudaGraphExec_t,
9127 node: cudaGraphNode_t,
9128 pNodeParams: *const cudaHostNodeParams,
9129 ) -> cudaError_t;
9130}
9131unsafe extern "C" {
9132 /// Updates node parameters in the child graph node in the given graphExec.
9133 ///
9134 /// 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.
9135 ///
9136 /// 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.
9137 ///
9138 /// 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
9139 /// contained within the top level child graph will also be updated.
9140 ///
9141 /// Note:
9142 ///
9143 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9144 /// * Note that this function may also return error codes from previous, asynchronous launches.
9145 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9146 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9147 ///
9148 /// **See also:**
9149 ///
9150 /// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddChildGraphNode`], [`cudaGraphChildGraphNodeGetGraph`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
9151 ///
9152 /// # Parameters
9153 ///
9154 /// - `hGraphExec`: The executable graph in which to set the specified node.
9155 /// - `node`: Host node from the graph which was used to instantiate graphExec.
9156 /// - `childGraph`: The graph supplying the updated parameters.
9157 pub fn cudaGraphExecChildGraphNodeSetParams(
9158 hGraphExec: cudaGraphExec_t,
9159 node: cudaGraphNode_t,
9160 childGraph: cudaGraph_t,
9161 ) -> cudaError_t;
9162}
9163unsafe extern "C" {
9164 /// Sets the event for an event record node in the given graphExec.
9165 ///
9166 /// 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.
9167 ///
9168 /// 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.
9169 ///
9170 /// Note:
9171 ///
9172 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9173 /// * Note that this function may also return error codes from previous, asynchronous launches.
9174 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9175 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9176 ///
9177 /// **See also:**
9178 ///
9179 /// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddEventRecordNode`], [`cudaGraphEventRecordNodeGetEvent`], [`cudaGraphEventWaitNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
9180 ///
9181 /// # Parameters
9182 ///
9183 /// - `hGraphExec`: The executable graph in which to set the specified node.
9184 /// - `hNode`: Event record node from the graph from which graphExec was instantiated.
9185 /// - `event`: Updated event to use.
9186 pub fn cudaGraphExecEventRecordNodeSetEvent(
9187 hGraphExec: cudaGraphExec_t,
9188 hNode: cudaGraphNode_t,
9189 event: cudaEvent_t,
9190 ) -> cudaError_t;
9191}
9192unsafe extern "C" {
9193 /// Sets the event for an event wait node in the given graphExec.
9194 ///
9195 /// 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.
9196 ///
9197 /// 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.
9198 ///
9199 /// Note:
9200 ///
9201 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9202 /// * Note that this function may also return error codes from previous, asynchronous launches.
9203 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9204 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9205 ///
9206 /// **See also:**
9207 ///
9208 /// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddEventWaitNode`], [`cudaGraphEventWaitNodeGetEvent`], [`cudaGraphEventRecordNodeSetEvent`], [`cudaEventRecordWithFlags`], [`cudaStreamWaitEvent`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
9209 ///
9210 /// # Parameters
9211 ///
9212 /// - `hGraphExec`: The executable graph in which to set the specified node.
9213 /// - `hNode`: Event wait node from the graph from which graphExec was instantiated.
9214 /// - `event`: Updated event to use.
9215 pub fn cudaGraphExecEventWaitNodeSetEvent(
9216 hGraphExec: cudaGraphExec_t,
9217 hNode: cudaGraphNode_t,
9218 event: cudaEvent_t,
9219 ) -> cudaError_t;
9220}
9221unsafe extern "C" {
9222 /// Sets the parameters for an external semaphore signal node in the given graphExec.
9223 ///
9224 /// 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.
9225 ///
9226 /// hNode must not have been removed from the original graph.
9227 ///
9228 /// 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.
9229 ///
9230 /// Changing nodeParams->numExtSems is not supported.
9231 ///
9232 /// Note:
9233 ///
9234 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9235 /// * Note that this function may also return error codes from previous, asynchronous launches.
9236 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9237 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9238 ///
9239 /// **See also:**
9240 ///
9241 /// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddExternalSemaphoresSignalNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresWaitNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
9242 ///
9243 /// # Parameters
9244 ///
9245 /// - `hGraphExec`: The executable graph in which to set the specified node.
9246 /// - `hNode`: semaphore signal node from the graph from which graphExec was instantiated.
9247 /// - `nodeParams`: Updated Parameters to set.
9248 pub fn cudaGraphExecExternalSemaphoresSignalNodeSetParams(
9249 hGraphExec: cudaGraphExec_t,
9250 hNode: cudaGraphNode_t,
9251 nodeParams: *const cudaExternalSemaphoreSignalNodeParams,
9252 ) -> cudaError_t;
9253}
9254unsafe extern "C" {
9255 /// Sets the parameters for an external semaphore wait node in the given graphExec.
9256 ///
9257 /// 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.
9258 ///
9259 /// hNode must not have been removed from the original graph.
9260 ///
9261 /// 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.
9262 ///
9263 /// Changing nodeParams->numExtSems is not supported.
9264 ///
9265 /// Note:
9266 ///
9267 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9268 /// * Note that this function may also return error codes from previous, asynchronous launches.
9269 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9270 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9271 ///
9272 /// **See also:**
9273 ///
9274 /// [`cudaGraphExecNodeSetParams`], [`cudaGraphAddExternalSemaphoresWaitNode`], [`cudaImportExternalSemaphore`], [`cudaSignalExternalSemaphoresAsync`], [`cudaWaitExternalSemaphoresAsync`], [`cudaGraphExecKernelNodeSetParams`], [`cudaGraphExecMemcpyNodeSetParams`], [`cudaGraphExecMemsetNodeSetParams`], [`cudaGraphExecHostNodeSetParams`], [`cudaGraphExecChildGraphNodeSetParams`], [`cudaGraphExecEventRecordNodeSetEvent`], [`cudaGraphExecEventWaitNodeSetEvent`], [`cudaGraphExecExternalSemaphoresSignalNodeSetParams`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`]
9275 ///
9276 /// # Parameters
9277 ///
9278 /// - `hGraphExec`: The executable graph in which to set the specified node.
9279 /// - `hNode`: semaphore wait node from the graph from which graphExec was instantiated.
9280 /// - `nodeParams`: Updated Parameters to set.
9281 pub fn cudaGraphExecExternalSemaphoresWaitNodeSetParams(
9282 hGraphExec: cudaGraphExec_t,
9283 hNode: cudaGraphNode_t,
9284 nodeParams: *const cudaExternalSemaphoreWaitNodeParams,
9285 ) -> cudaError_t;
9286}
9287unsafe extern "C" {
9288 /// Enables or disables the specified node in the given graphExec.
9289 ///
9290 /// Sets hNode to be either enabled or disabled. Disabled nodes are functionally equivalent to empty nodes until they are reenabled. Existing
9291 /// node parameters are not affected by disabling/enabling the node.
9292 ///
9293 /// The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
9294 ///
9295 /// hNode must not have been removed from the original graph.
9296 ///
9297 /// 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.
9298 ///
9299 /// Note:
9300 ///
9301 /// Currently only kernel, memset and memcpy nodes are supported.
9302 ///
9303 /// Note:
9304 ///
9305 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9306 /// * Note that this function may also return error codes from previous, asynchronous launches.
9307 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9308 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9309 ///
9310 /// **See also:**
9311 ///
9312 /// [`cudaGraphNodeGetEnabled`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`] [`cudaGraphLaunch`].
9313 ///
9314 /// # Parameters
9315 ///
9316 /// - `hGraphExec`: The executable graph in which to set the specified node.
9317 /// - `hNode`: Node from the graph from which graphExec was instantiated.
9318 /// - `isEnabled`: Node is enabled if != 0, otherwise the node is disabled.
9319 pub fn cudaGraphNodeSetEnabled(
9320 hGraphExec: cudaGraphExec_t,
9321 hNode: cudaGraphNode_t,
9322 isEnabled: ::core::ffi::c_uint,
9323 ) -> cudaError_t;
9324}
9325unsafe extern "C" {
9326 /// Query whether a node in the given graphExec is enabled.
9327 ///
9328 /// Sets isEnabled to 1 if hNode is enabled, or 0 if hNode is disabled.
9329 ///
9330 /// The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
9331 ///
9332 /// hNode must not have been removed from the original graph.
9333 ///
9334 /// Note:
9335 ///
9336 /// Currently only kernel, memset and memcpy nodes are supported.
9337 ///
9338 /// Note:
9339 ///
9340 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9341 /// * Note that this function may also return error codes from previous, asynchronous launches.
9342 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9343 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9344 ///
9345 /// **See also:**
9346 ///
9347 /// [`cudaGraphNodeSetEnabled`], [`cudaGraphExecUpdate`], [`cudaGraphInstantiate`] [`cudaGraphLaunch`].
9348 ///
9349 /// # Parameters
9350 ///
9351 /// - `hGraphExec`: The executable graph in which to set the specified node.
9352 /// - `hNode`: Node from the graph from which graphExec was instantiated.
9353 /// - `isEnabled`: Location to return the enabled status of the node.
9354 pub fn cudaGraphNodeGetEnabled(
9355 hGraphExec: cudaGraphExec_t,
9356 hNode: cudaGraphNode_t,
9357 isEnabled: *mut ::core::ffi::c_uint,
9358 ) -> cudaError_t;
9359}
9360unsafe extern "C" {
9361 /// Check whether an executable graph can be updated with a graph and perform the update if possible.
9362 ///
9363 /// Updates the node parameters in the instantiated graph specified by hGraphExec with the node parameters in a topologically identical graph specified by hGraph.
9364 ///
9365 /// Limitations:
9366 ///
9367 /// * Kernel nodes:
9368 /// + The owning context of the function cannot change.
9369 /// + A node whose function originally did not use CUDA dynamic parallelism cannot be updated to a function which uses CDP.
9370 /// + A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side
9371 /// update calls.
9372 /// + A cooperative node cannot be updated to a non-cooperative node, and vice-versa.
9373 /// + If the graph was instantiated with cudaGraphInstantiateFlagUseNodePriority, the priority attribute cannot change. Equality
9374 /// is checked on the originally requested priority values, before they are clamped to the device's supported range.
9375 /// + 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
9376 /// present at instantiation, these updates cannot be performed at all.
9377 /// + Neither hGraph nor hGraphExec may contain device-updatable kernel nodes.
9378 /// * Memset and memcpy nodes:
9379 /// + The CUDA device(s) to which the operand(s) was allocated/mapped cannot change.
9380 /// + The source/destination memory must be allocated from the same contexts as the original source/destination memory.
9381 /// + For 2d memsets, only address and assigned value may be updated.
9382 /// + For 1d memsets, updating dimensions is also allowed, but may fail if the resulting operation doesn't map onto the work resources
9383 /// already allocated for the node.
9384 /// * Additional memcpy node restrictions:
9385 /// + Changing either the source or destination memory type(i.e. CU_MEMORYTYPE_DEVICE, CU_MEMORYTYPE_ARRAY, etc.) is not supported.
9386 /// * Conditional nodes:
9387 /// + Changing node parameters is not supported.
9388 /// + Changing parameters of nodes within the conditional body graph is subject to the rules above.
9389 /// + Conditional handle flags and default values are updated as part of the graph update.
9390 ///
9391 /// Note: The API may add further restrictions in future releases. The return code should always be checked.
9392 ///
9393 /// cudaGraphExecUpdate sets the result member of resultInfo to cudaGraphExecUpdateErrorTopologyChanged under the following conditions:
9394 ///
9395 /// * The count of nodes directly in hGraphExec and hGraph differ, in which case resultInfo->errorNode is set to NULL.
9396 /// * hGraph has more exit nodes than hGraph, in which case resultInfo->errorNode is set to one of the exit nodes in hGraph.
9397 /// * 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.
9398 /// * 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
9399 /// a dependency does not match when the nodes are already paired based on other edges examined in the graph.
9400 ///
9401 /// cudaGraphExecUpdate sets the result member of resultInfo to:
9402 ///
9403 /// * cudaGraphExecUpdateError if passed an invalid value.
9404 /// * cudaGraphExecUpdateErrorTopologyChanged if the graph topology changed
9405 /// * cudaGraphExecUpdateErrorNodeTypeChanged if the type of a node changed, in which case hErrorNode_out is set to the node from hGraph.
9406 /// * cudaGraphExecUpdateErrorFunctionChanged if the function of a kernel node changed (CUDA driver < 11.2)
9407 /// * cudaGraphExecUpdateErrorUnsupportedFunctionChange if the func field of a kernel changed in an unsupported way(see note above),
9408 /// in which case hErrorNode_out is set to the node from hGraph
9409 /// * cudaGraphExecUpdateErrorParametersChanged if any parameters to a node changed in a way that is not supported, in which case
9410 /// hErrorNode_out is set to the node from hGraph
9411 /// * cudaGraphExecUpdateErrorAttributesChanged if any attributes of a node changed in a way that is not supported, in which case
9412 /// hErrorNode_out is set to the node from hGraph
9413 /// * cudaGraphExecUpdateErrorNotSupported if something about a node is unsupported, like the node's type or configuration, in which
9414 /// case hErrorNode_out is set to the node from hGraph
9415 ///
9416 /// 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.
9417 ///
9418 /// cudaGraphExecUpdate returns cudaSuccess when the updated was performed successfully. It returns cudaErrorGraphExecUpdateFailure
9419 /// if the graph update was not performed because it included changes which violated constraints specific to instantiated graph
9420 /// update.
9421 ///
9422 /// Note:
9423 ///
9424 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9425 /// * Note that this function may also return error codes from previous, asynchronous launches.
9426 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9427 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9428 ///
9429 /// **See also:**
9430 ///
9431 /// [`cudaGraphInstantiate`]
9432 ///
9433 /// # Parameters
9434 ///
9435 /// - `hGraphExec`: The instantiated graph to be updated.
9436 /// - `hGraph`: The graph containing the updated parameters.
9437 /// - `resultInfo`: the error info structure.
9438 pub fn cudaGraphExecUpdate(
9439 hGraphExec: cudaGraphExec_t,
9440 hGraph: cudaGraph_t,
9441 resultInfo: *mut cudaGraphExecUpdateResultInfo,
9442 ) -> cudaError_t;
9443}
9444unsafe extern "C" {
9445 /// Uploads an executable graph in a stream.
9446 ///
9447 /// 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.
9448 ///
9449 /// Note:
9450 ///
9451 /// * Note that this function may also return error codes from previous, asynchronous launches.
9452 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9453 ///
9454 /// **See also:**
9455 ///
9456 /// [`cudaGraphInstantiate`], [`cudaGraphLaunch`], [`cudaGraphExecDestroy`].
9457 pub fn cudaGraphUpload(
9458 graphExec: cudaGraphExec_t,
9459 stream: cudaStream_t,
9460 ) -> cudaError_t;
9461}
9462unsafe extern "C" {
9463 /// Launches an executable graph in a stream.
9464 ///
9465 /// 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.
9466 ///
9467 /// If any allocations created by graphExec remain unfreed (from a previous launch) and graphExec was not instantiated with [cudaGraphInstantiateFlagAutoFreeOnLaunch](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg638577f2b0f6a98b5e6a0e6a72d090044258c8d3adc203f97e73e92810e1785f), the launch will fail with [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
9468 ///
9469 /// Note:
9470 ///
9471 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9472 /// * Note that this function may also return error codes from previous, asynchronous launches.
9473 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9474 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9475 ///
9476 /// **See also:**
9477 ///
9478 /// [`cudaGraphInstantiate`], [`cudaGraphUpload`], [`cudaGraphExecDestroy`].
9479 ///
9480 /// # Parameters
9481 ///
9482 /// - `graphExec`: Executable graph to launch.
9483 /// - `stream`: Stream in which to launch the graph.
9484 pub fn cudaGraphLaunch(
9485 graphExec: cudaGraphExec_t,
9486 stream: cudaStream_t,
9487 ) -> cudaError_t;
9488}
9489unsafe extern "C" {
9490 /// Destroys an executable graph.
9491 ///
9492 /// Destroys the executable graph specified by graphExec.
9493 ///
9494 /// Note:
9495 ///
9496 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9497 /// * Note that this function may also return error codes from previous, asynchronous launches.
9498 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9499 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9500 /// * Use of the handle after this call is undefined behavior.
9501 ///
9502 /// **See also:**
9503 ///
9504 /// [`cudaGraphInstantiate`], [`cudaGraphUpload`], [`cudaGraphLaunch`].
9505 ///
9506 /// # Parameters
9507 ///
9508 /// - `graphExec`: Executable graph to destroy.
9509 pub fn cudaGraphExecDestroy(graphExec: cudaGraphExec_t) -> cudaError_t;
9510}
9511unsafe extern "C" {
9512 /// Destroys a graph.
9513 ///
9514 /// Destroys the graph specified by graph, as well as all of its nodes.
9515 ///
9516 /// Note:
9517 ///
9518 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9519 /// * Note that this function may also return error codes from previous, asynchronous launches.
9520 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9521 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9522 /// * Use of the handle after this call is undefined behavior.
9523 ///
9524 /// **See also:**
9525 ///
9526 /// [`cudaGraphCreate`].
9527 ///
9528 /// # Parameters
9529 ///
9530 /// - `graph`: Graph to destroy.
9531 pub fn cudaGraphDestroy(graph: cudaGraph_t) -> cudaError_t;
9532}
9533unsafe extern "C" {
9534 /// Write a DOT file describing graph structure.
9535 ///
9536 /// 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
9537 /// and memcpy direction. flags can be specified to write more detailed information about each node type such as parameter values, kernel attributes, node
9538 /// and function handles.
9539 ///
9540 /// # Parameters
9541 ///
9542 /// - `graph`: The graph to create a DOT file from.
9543 /// - `path`: The path to write the DOT file to.
9544 /// - `flags`: Flags from cudaGraphDebugDotFlags for specifying which additional node information to write.
9545 pub fn cudaGraphDebugDotPrint(
9546 graph: cudaGraph_t,
9547 path: *const ::core::ffi::c_char,
9548 flags: ::core::ffi::c_uint,
9549 ) -> cudaError_t;
9550}
9551unsafe extern "C" {
9552 /// Create a user object.
9553 ///
9554 /// Create a user object with the specified destructor callback and initial reference count. The initial references are owned
9555 /// by the caller.
9556 ///
9557 /// Destructor callbacks cannot make CUDA API calls and should avoid blocking behavior, as they are executed by a shared internal
9558 /// thread. Another thread may be signaled to perform such actions, if it does not block forward progress of tasks scheduled through
9559 /// CUDA.
9560 ///
9561 /// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
9562 ///
9563 /// **See also:**
9564 ///
9565 /// [`cudaUserObjectRetain`], [`cudaUserObjectRelease`], [`cudaGraphRetainUserObject`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`].
9566 ///
9567 /// # Parameters
9568 ///
9569 /// - `object_out`: Location to return the user object handle.
9570 /// - `ptr`: The pointer to pass to the destroy function.
9571 /// - `destroy`: Callback to free the user object when it is no longer in use.
9572 /// - `initialRefcount`: The initial refcount to create the object with, typically 1. The initial references are owned by the calling thread.
9573 /// - `flags`: Currently it is required to pass [cudaUserObjectNoDestructorSync](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
9574 /// synchronization of the callback should signal its completion manually.
9575 pub fn cudaUserObjectCreate(
9576 object_out: *mut cudaUserObject_t,
9577 ptr: *mut ::core::ffi::c_void,
9578 destroy: cudaHostFn_t,
9579 initialRefcount: ::core::ffi::c_uint,
9580 flags: ::core::ffi::c_uint,
9581 ) -> cudaError_t;
9582}
9583unsafe extern "C" {
9584 /// Retain a reference to a user object.
9585 ///
9586 /// Retains new references to a user object. The new references are owned by the caller.
9587 ///
9588 /// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
9589 ///
9590 /// **See also:**
9591 ///
9592 /// [`cudaUserObjectCreate`], [`cudaUserObjectRelease`], [`cudaGraphRetainUserObject`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`].
9593 ///
9594 /// # Parameters
9595 ///
9596 /// - `object`: The object to retain.
9597 /// - `count`: The number of references to retain, typically 1. Must be nonzero and not larger than INT_MAX.
9598 pub fn cudaUserObjectRetain(
9599 object: cudaUserObject_t,
9600 count: ::core::ffi::c_uint,
9601 ) -> cudaError_t;
9602}
9603unsafe extern "C" {
9604 /// Release a reference to a user object.
9605 ///
9606 /// Releases user object references owned by the caller. The object's destructor is invoked if the reference count reaches zero.
9607 ///
9608 /// It is undefined behavior to release references not owned by the caller, or to use a user object handle after all references
9609 /// are released.
9610 ///
9611 /// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
9612 ///
9613 /// **See also:**
9614 ///
9615 /// [`cudaUserObjectCreate`], [`cudaUserObjectRetain`], [`cudaGraphRetainUserObject`], [`cudaGraphReleaseUserObject`], [`cudaGraphCreate`].
9616 ///
9617 /// # Parameters
9618 ///
9619 /// - `object`: The object to release.
9620 /// - `count`: The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.
9621 pub fn cudaUserObjectRelease(
9622 object: cudaUserObject_t,
9623 count: ::core::ffi::c_uint,
9624 ) -> cudaError_t;
9625}
9626unsafe extern "C" {
9627 /// Retain a reference to a user object from a graph.
9628 ///
9629 /// Creates or moves user object references that will be owned by a CUDA graph.
9630 ///
9631 /// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
9632 ///
9633 /// **See also:**
9634 ///
9635 /// [`cudaUserObjectCreate`] transfers references from the calling thread, rather than create new references. Pass 0 to create new references.
9636 pub fn cudaGraphRetainUserObject(
9637 graph: cudaGraph_t,
9638 object: cudaUserObject_t,
9639 count: ::core::ffi::c_uint,
9640 flags: ::core::ffi::c_uint,
9641 ) -> cudaError_t;
9642}
9643unsafe extern "C" {
9644 /// Release a user object reference from a graph.
9645 ///
9646 /// Releases user object references owned by a graph.
9647 ///
9648 /// See CUDA User Objects in the CUDA C++ Programming Guide for more information on user objects.
9649 ///
9650 /// **See also:**
9651 ///
9652 /// [`cudaUserObjectCreate`][`cudaUserObjectRetain`], [`cudaUserObjectRelease`], [`cudaGraphRetainUserObject`], [`cudaGraphCreate`].
9653 ///
9654 /// # Parameters
9655 ///
9656 /// - `graph`: The graph that will release the reference.
9657 /// - `object`: The user object to release a reference for.
9658 /// - `count`: The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.
9659 pub fn cudaGraphReleaseUserObject(
9660 graph: cudaGraph_t,
9661 object: cudaUserObject_t,
9662 count: ::core::ffi::c_uint,
9663 ) -> cudaError_t;
9664}
9665unsafe extern "C" {
9666 /// Adds a node of arbitrary type to a graph.
9667 ///
9668 /// 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.
9669 ///
9670 /// 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
9671 /// to ensure all bytes are initialized.
9672 ///
9673 /// Note that for some node types, nodeParams may contain "out parameters" which are modified during the call, such as nodeParams->alloc.dptr.
9674 ///
9675 /// A handle to the new node will be returned in phGraphNode.
9676 ///
9677 /// Note:
9678 ///
9679 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9680 /// * Note that this function may also return error codes from previous, asynchronous launches.
9681 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9682 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9683 ///
9684 /// **See also:**
9685 ///
9686 /// [`cudaGraphCreate`], [`cudaGraphNodeSetParams`], [`cudaGraphExecNodeSetParams`].
9687 ///
9688 /// # Parameters
9689 ///
9690 /// - `pGraphNode`: Returns newly created node.
9691 /// - `graph`: Graph to which to add the node.
9692 /// - `pDependencies`: Dependencies of the node.
9693 /// - `dependencyData`: Optional edge data for the dependencies. If NULL, the data is assumed to be default (zeroed) for all dependencies.
9694 /// - `numDependencies`: Number of dependencies.
9695 /// - `nodeParams`: Specification of the node.
9696 pub fn cudaGraphAddNode(
9697 pGraphNode: *mut cudaGraphNode_t,
9698 graph: cudaGraph_t,
9699 pDependencies: *const cudaGraphNode_t,
9700 dependencyData: *const cudaGraphEdgeData,
9701 numDependencies: size_t,
9702 nodeParams: *mut cudaGraphNodeParams,
9703 ) -> cudaError_t;
9704}
9705unsafe extern "C" {
9706 /// Update a graph node's parameters.
9707 ///
9708 /// 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.
9709 ///
9710 /// Modifying parameters is not supported for node types cudaGraphNodeTypeMemAlloc and cudaGraphNodeTypeMemFree.
9711 ///
9712 /// Note:
9713 ///
9714 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9715 /// * Note that this function may also return error codes from previous, asynchronous launches.
9716 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9717 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9718 ///
9719 /// **See also:**
9720 ///
9721 /// [`cudaGraphNodeGetParams`], [`cudaGraphAddNode`], [`cudaGraphExecNodeSetParams`].
9722 ///
9723 /// # Parameters
9724 ///
9725 /// - `node`: Node to set the parameters for.
9726 /// - `nodeParams`: Parameters to copy.
9727 pub fn cudaGraphNodeSetParams(
9728 node: cudaGraphNode_t,
9729 nodeParams: *mut cudaGraphNodeParams,
9730 ) -> cudaError_t;
9731}
9732unsafe extern "C" {
9733 /// Returns a graph node's parameters.
9734 ///
9735 /// Returns the parameters of graph node node in \*nodeParams.
9736 ///
9737 /// 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
9738 /// pointed to from \*nodeParams must not be modified.
9739 ///
9740 /// The returned parameters are a description of the node, but may not be identical to the struct provided at creation and may
9741 /// not be suitable for direct creation of identical nodes. This is because parameters may be partially unspecified and filled
9742 /// in by the driver at creation, may reference non-copyable handles, or may describe ownership semantics or other parameters
9743 /// that govern behavior of node creation but are not part of the final functional descriptor.
9744 ///
9745 /// Note:
9746 ///
9747 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9748 /// * Note that this function may also return error codes from previous, asynchronous launches.
9749 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9750 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9751 ///
9752 /// **See also:**
9753 ///
9754 /// [`cudaGraphNodeGetParams`], [`cudaGraphNodeSetParams`], [`cudaGraphAddNode`], [`cudaGraphExecNodeSetParams`].
9755 ///
9756 /// # Parameters
9757 ///
9758 /// - `node`: Node to get the parameters for.
9759 /// - `nodeParams`: Pointer to return the parameters.
9760 pub fn cudaGraphNodeGetParams(
9761 node: cudaGraphNode_t,
9762 nodeParams: *mut cudaGraphNodeParams,
9763 ) -> cudaError_t;
9764}
9765unsafe extern "C" {
9766 /// Update a graph node's parameters in an instantiated graph.
9767 ///
9768 /// 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.
9769 ///
9770 /// 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.
9771 ///
9772 /// Allowed changes to parameters on executable graphs are as follows:
9773 ///
9774 /// | Node type | Allowed changes |
9775 /// | --- | --- |
9776 /// | kernel | See [`cudaGraphExecKernelNodeSetParams`] |
9777 /// | memcpy | Addresses for 1-dimensional copies if allocated in same context; see [`cudaGraphExecMemcpyNodeSetParams`] |
9778 /// | memset | Addresses for 1-dimensional memsets if allocated in same context; see [`cudaGraphExecMemsetNodeSetParams`] |
9779 /// | host | Unrestricted |
9780 /// | child graph | Topology must match and restrictions apply recursively; see [`cudaGraphExecUpdate`] |
9781 /// | event wait | Unrestricted |
9782 /// | event record | Unrestricted |
9783 /// | external semaphore signal | Number of semaphore operations cannot change |
9784 /// | external semaphore wait | Number of semaphore operations cannot change |
9785 /// | memory allocation | API unsupported |
9786 /// | memory free | API unsupported |
9787 ///
9788 /// Note:
9789 ///
9790 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9791 /// * Note that this function may also return error codes from previous, asynchronous launches.
9792 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9793 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9794 ///
9795 /// **See also:**
9796 ///
9797 /// [`cudaGraphAddNode`], [`cudaGraphNodeSetParams`]
9798 ///
9799 /// # Parameters
9800 ///
9801 /// - `graphExec`: The executable graph in which to update the specified node.
9802 /// - `node`: Corresponding node from the graph from which graphExec was instantiated.
9803 /// - `nodeParams`: Updated Parameters to set.
9804 pub fn cudaGraphExecNodeSetParams(
9805 graphExec: cudaGraphExec_t,
9806 node: cudaGraphNode_t,
9807 nodeParams: *mut cudaGraphNodeParams,
9808 ) -> cudaError_t;
9809}
9810unsafe extern "C" {
9811 /// Create a conditional handle.
9812 ///
9813 /// Creates a conditional handle associated with hGraph.
9814 ///
9815 /// The conditional handle must be associated with a conditional node in this graph or one of its children.
9816 ///
9817 /// Handles not associated with a conditional node may cause graph instantiation to fail.
9818 ///
9819 /// Note:
9820 ///
9821 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9822 /// * Note that this function may also return error codes from previous, asynchronous launches.
9823 ///
9824 /// **See also:**
9825 ///
9826 /// [cuGraphAddNode](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GRAPH.html#group__CUDA__GRAPH_1ge01208e62f72a53367a2af903bf17d23),.
9827 ///
9828 /// # Parameters
9829 ///
9830 /// - `pHandle_out`: Pointer used to return the handle to the caller.
9831 /// - `graph`: Graph which will contain the conditional node using this handle.
9832 /// - `defaultLaunchValue`: Optional initial value for the conditional variable. Applied at the beginning of each graph execution if cudaGraphCondAssignDefault
9833 /// is set in flags.
9834 /// - `flags`: Currently must be cudaGraphCondAssignDefault or 0.
9835 pub fn cudaGraphConditionalHandleCreate(
9836 pHandle_out: *mut cudaGraphConditionalHandle,
9837 graph: cudaGraph_t,
9838 defaultLaunchValue: ::core::ffi::c_uint,
9839 flags: ::core::ffi::c_uint,
9840 ) -> cudaError_t;
9841}
9842unsafe extern "C" {
9843 /// Create a conditional handle.
9844 ///
9845 /// Creates a conditional handle associated with hGraph.
9846 ///
9847 /// The conditional handle must be associated with a conditional node in this graph or one of its children.
9848 ///
9849 /// Handles not associated with a conditional node may cause graph instantiation to fail.
9850 ///
9851 /// Note:
9852 ///
9853 /// * Graph objects are not threadsafe. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/graphs-thread-safety.html#graphs-thread-safety).
9854 /// * Note that this function may also return error codes from previous, asynchronous launches.
9855 ///
9856 /// **See also:**
9857 ///
9858 /// [cuGraphAddNode](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GRAPH.html#group__CUDA__GRAPH_1ge01208e62f72a53367a2af903bf17d23),.
9859 ///
9860 /// # Parameters
9861 ///
9862 /// - `pHandle_out`: Pointer used to return the handle to the caller.
9863 /// - `graph`: Graph which will contain the conditional node using this handle.
9864 /// - `ctx`: Execution context for the handle and associated conditional node. If NULL, current context will be used.
9865 /// - `defaultLaunchValue`: Optional initial value for the conditional variable. Applied at the beginning of each graph execution if cudaGraphCondAssignDefault
9866 /// is set in flags.
9867 /// - `flags`: Currently must be cudaGraphCondAssignDefault or 0.
9868 pub fn cudaGraphConditionalHandleCreate_v2(
9869 pHandle_out: *mut cudaGraphConditionalHandle,
9870 graph: cudaGraph_t,
9871 ctx: cudaExecutionContext_t,
9872 defaultLaunchValue: ::core::ffi::c_uint,
9873 flags: ::core::ffi::c_uint,
9874 ) -> cudaError_t;
9875}
9876unsafe extern "C" {
9877 /// Returns the requested driver API function pointer.
9878 ///
9879 /// Returns in \*\*funcPtr the address of the CUDA driver function for the requested flags.
9880 ///
9881 /// For a requested driver symbol, if the CUDA version in which the driver symbol was introduced is less than or equal to the
9882 /// CUDA runtime version, the API will return the function pointer to the corresponding versioned driver function.
9883 ///
9884 /// The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in
9885 /// the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example,
9886 /// cudaTypedefs.h consists of function pointer typedefs for driver APIs defined in cuda.h.
9887 ///
9888 /// The API will return [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) and set the returned funcPtr if the requested driver function is valid and supported on the platform.
9889 ///
9890 /// The API will return [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
9891 /// CUDA runtime version or if the driver symbol is invalid.
9892 ///
9893 /// It will also set the optional driverStatus to one of the values in `cudaDriverEntryPointQueryResult` with the following meanings:
9894 ///
9895 /// * [cudaDriverEntryPointSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1f675c627fcf7d85babf3566ef9b9ae15d) - The requested symbol was succesfully found based on input arguments and pfn is valid
9896 /// * [cudaDriverEntryPointSymbolNotFound](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1fe498f752ad230907d91c997be955565b) - The requested symbol was not found
9897 /// * [cudaDriverEntryPointVersionNotSufficent](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1fc5e673dbc3e97f620e20ae5aeb0b7426) - The requested symbol was found but is not supported by the current runtime version (CUDART_VERSION)
9898 ///
9899 /// The requested flags can be:
9900 ///
9901 /// * [cudaEnableDefault](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61a9c0bcf076678d03418b7922a39bb1d5): This is the default mode. This is equivalent to [cudaEnablePerThreadDefaultStream](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
9902 /// is defined; [cudaEnableLegacyStream](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61e37885317cc9edcece9b5069b1494e1b) otherwise.
9903 /// * [cudaEnableLegacyStream](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61e37885317cc9edcece9b5069b1494e1b): This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding
9904 /// per-thread versions.
9905 /// * [cudaEnablePerThreadDefaultStream](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd611bd1da9af3fbaa465a199706ef94328f): This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread
9906 /// versions. If a per-thread version is not found, the API will return the legacy version of the driver function.
9907 ///
9908 /// Note:
9909 ///
9910 /// Note:
9911 ///
9912 /// * Version mixing among CUDA-defined types and driver API versions is strongly discouraged and doing so can result in an undefined
9913 /// behavior. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/version-mixing-rules.html#version-mixing-rules).
9914 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9915 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9916 ///
9917 /// **See also:**
9918 ///
9919 /// [cuGetProcAddress](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DRIVER__ENTRY__POINT.html#group__CUDA__DRIVER__ENTRY__POINT_1gcae5adad00590572ab35b2508c2d6e0d).
9920 ///
9921 /// # Parameters
9922 ///
9923 /// - `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
9924 /// driver symbol, [cuMemAlloc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MEM.html#group__CUDA__MEM_1gb82d2a09844a58dd9e744dc31e8aa467) or cuMemAlloc_v2.
9925 /// - `funcPtr`: Location to return the function pointer to the requested driver function.
9926 /// - `flags`: Flags to specify search options.
9927 /// - `driverStatus`: Optional location to store the status of finding the symbol from the driver. See `cudaDriverEntryPointQueryResult` for possible values.
9928 #[deprecated]
9929 pub fn cudaGetDriverEntryPoint(
9930 symbol: *const ::core::ffi::c_char,
9931 funcPtr: *mut *mut ::core::ffi::c_void,
9932 flags: ::core::ffi::c_ulonglong,
9933 driverStatus: *mut cudaDriverEntryPointQueryResult,
9934 ) -> cudaError_t;
9935}
9936unsafe extern "C" {
9937 /// Returns the requested driver API function pointer by CUDA version.
9938 ///
9939 /// Returns in \*\*funcPtr the address of the CUDA driver function for the requested flags and CUDA driver version.
9940 ///
9941 /// The CUDA version is specified as (1000 \* major + 10 \* minor), so CUDA 11.2 should be specified as 11020. For a requested driver
9942 /// symbol, if the specified CUDA version is greater than or equal to the CUDA version in which the driver symbol was introduced,
9943 /// this API will return the function pointer to the corresponding versioned function. If the specified CUDA version is greater
9944 /// than the driver version, the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
9945 ///
9946 /// The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in
9947 /// the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example,
9948 /// cudaTypedefs.h consists of function pointer typedefs for driver APIs defined in cuda.h.
9949 ///
9950 /// For the case where the CUDA version requested is greater than the CUDA Toolkit installed, there may not be an appropriate
9951 /// function pointer typedef in the corresponding header file and may need a custom typedef to match the driver function signature
9952 /// returned. This can be done by getting the typedefs from a later toolkit or creating appropriately matching custom function
9953 /// typedefs.
9954 ///
9955 /// The API will return [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e355f04607d824883b4a50662830d591) and set the returned funcPtr if the requested driver function is valid and supported on the platform.
9956 ///
9957 /// The API will return [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
9958 /// requested version or if the driver symbol is invalid.
9959 ///
9960 /// It will also set the optional driverStatus to one of the values in `cudaDriverEntryPointQueryResult` with the following meanings:
9961 ///
9962 /// * [cudaDriverEntryPointSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1f675c627fcf7d85babf3566ef9b9ae15d) - The requested symbol was succesfully found based on input arguments and pfn is valid
9963 /// * [cudaDriverEntryPointSymbolNotFound](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1fe498f752ad230907d91c997be955565b) - The requested symbol was not found
9964 /// * [cudaDriverEntryPointVersionNotSufficent](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggeb22957eedf779d624069585c25f1d1fc5e673dbc3e97f620e20ae5aeb0b7426) - The requested symbol was found but is not supported by the specified version cudaVersion
9965 ///
9966 /// The requested flags can be:
9967 ///
9968 /// * [cudaEnableDefault](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61a9c0bcf076678d03418b7922a39bb1d5): This is the default mode. This is equivalent to [cudaEnablePerThreadDefaultStream](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
9969 /// is defined; [cudaEnableLegacyStream](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61e37885317cc9edcece9b5069b1494e1b) otherwise.
9970 /// * [cudaEnableLegacyStream](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd61e37885317cc9edcece9b5069b1494e1b): This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding
9971 /// per-thread versions.
9972 /// * [cudaEnablePerThreadDefaultStream](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggf2f2b7ea8f2f705095200807ac5dfd611bd1da9af3fbaa465a199706ef94328f): This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread
9973 /// versions. If a per-thread version is not found, the API will return the legacy version of the driver function.
9974 ///
9975 /// Note:
9976 ///
9977 /// * Version mixing among CUDA-defined types and driver API versions is strongly discouraged and doing so can result in an undefined
9978 /// behavior. [More here](https://docs.nvidia.com/cuda/cuda-runtime-api/version-mixing-rules.html#version-mixing-rules).
9979 /// * Note that this function may also return [cudaErrorInitializationError](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038ce7993a88ecf2c57b8102d55d997a18c), [cudaErrorInsufficientDriver](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038f5e52d1774934b77ba55d2aa2c063067) or [cudaErrorNoDevice](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038e942e4cbbd2bef6e92e293253f055613) if this call tries to initialize internal CUDA RT state.
9980 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
9981 ///
9982 /// **See also:**
9983 ///
9984 /// [cuGetProcAddress](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DRIVER__ENTRY__POINT.html#group__CUDA__DRIVER__ENTRY__POINT_1gcae5adad00590572ab35b2508c2d6e0d).
9985 ///
9986 /// # Parameters
9987 ///
9988 /// - `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.
9989 /// - `funcPtr`: Location to return the function pointer to the requested driver function.
9990 /// - `cudaVersion`: The CUDA version to look for the requested driver symbol.
9991 /// - `flags`: Flags to specify search options.
9992 /// - `driverStatus`: Optional location to store the status of finding the symbol from the driver. See `cudaDriverEntryPointQueryResult` for possible values.
9993 pub fn cudaGetDriverEntryPointByVersion(
9994 symbol: *const ::core::ffi::c_char,
9995 funcPtr: *mut *mut ::core::ffi::c_void,
9996 cudaVersion: ::core::ffi::c_uint,
9997 flags: ::core::ffi::c_ulonglong,
9998 driverStatus: *mut cudaDriverEntryPointQueryResult,
9999 ) -> cudaError_t;
10000}
10001unsafe extern "C" {
10002 /// Load a library with specified code and options.
10003 ///
10004 /// Takes a pointer code and loads the corresponding library library based on the application defined library loading mode:
10005 ///
10006 /// * 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
10007 /// is unloaded with [`cudaLibraryUnload`].
10008 /// * 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,
10009 /// such as a kernel launch.
10010 ///
10011 /// These environment variables are described in the CUDA programming guide under the "CUDA environment variables" section.
10012 ///
10013 /// 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
10014 /// 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.
10015 ///
10016 /// 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.
10017 ///
10018 /// 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.
10019 ///
10020 /// **See also:**
10021 ///
10022 /// [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [cuLibraryLoadData](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g957f12ff5af4166f43c89d17cfb0a74d).
10023 ///
10024 /// # Parameters
10025 ///
10026 /// - `library`: Returned library.
10027 /// - `code`: Code to load.
10028 /// - `jitOptions`: Options for JIT.
10029 /// - `jitOptionsValues`: Option values for JIT.
10030 /// - `numJitOptions`: Number of options.
10031 /// - `libraryOptions`: Options for loading.
10032 /// - `libraryOptionValues`: Option values for loading.
10033 /// - `numLibraryOptions`: Number of options for loading.
10034 pub fn cudaLibraryLoadData(
10035 library: *mut cudaLibrary_t,
10036 code: *const ::core::ffi::c_void,
10037 jitOptions: *mut cudaJitOption,
10038 jitOptionsValues: *mut *mut ::core::ffi::c_void,
10039 numJitOptions: ::core::ffi::c_uint,
10040 libraryOptions: *mut cudaLibraryOption,
10041 libraryOptionValues: *mut *mut ::core::ffi::c_void,
10042 numLibraryOptions: ::core::ffi::c_uint,
10043 ) -> cudaError_t;
10044}
10045unsafe extern "C" {
10046 /// Load a library with specified file and options.
10047 ///
10048 /// Takes a pointer code and loads the corresponding library library based on the application defined library loading mode:
10049 ///
10050 /// * 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
10051 /// is unloaded with [`cudaLibraryUnload`].
10052 /// * 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,
10053 /// such as a kernel launch.
10054 ///
10055 /// These environment variables are described in the CUDA programming guide under the "CUDA environment variables" section.
10056 ///
10057 /// 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
10058 /// 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.
10059 ///
10060 /// 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.
10061 ///
10062 /// 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.
10063 ///
10064 /// **See also:**
10065 ///
10066 /// [`cudaLibraryLoadData`], [`cudaLibraryUnload`], [cuLibraryLoadFromFile](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g88cff489fab37c7fd1985ceb61023205).
10067 ///
10068 /// # Parameters
10069 ///
10070 /// - `library`: Returned library.
10071 /// - `fileName`: File to load from.
10072 /// - `jitOptions`: Options for JIT.
10073 /// - `jitOptionsValues`: Option values for JIT.
10074 /// - `numJitOptions`: Number of options.
10075 /// - `libraryOptions`: Options for loading.
10076 /// - `libraryOptionValues`: Option values for loading.
10077 /// - `numLibraryOptions`: Number of options for loading.
10078 pub fn cudaLibraryLoadFromFile(
10079 library: *mut cudaLibrary_t,
10080 fileName: *const ::core::ffi::c_char,
10081 jitOptions: *mut cudaJitOption,
10082 jitOptionsValues: *mut *mut ::core::ffi::c_void,
10083 numJitOptions: ::core::ffi::c_uint,
10084 libraryOptions: *mut cudaLibraryOption,
10085 libraryOptionValues: *mut *mut ::core::ffi::c_void,
10086 numLibraryOptions: ::core::ffi::c_uint,
10087 ) -> cudaError_t;
10088}
10089unsafe extern "C" {
10090 /// Unloads a library.
10091 ///
10092 /// Unloads the library specified with library
10093 ///
10094 /// **See also:**
10095 ///
10096 /// [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [cuLibraryUnload](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g24969cb24138171edf465bc8669d5914).
10097 ///
10098 /// # Parameters
10099 ///
10100 /// - `library`: Library to unload.
10101 pub fn cudaLibraryUnload(library: cudaLibrary_t) -> cudaError_t;
10102}
10103unsafe extern "C" {
10104 /// Returns a kernel handle.
10105 ///
10106 /// Returns in pKernel the handle of the kernel with name name located in library library. If kernel handle is not found, the call returns [cudaErrorSymbolNotFound](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00389d51ecb21a3081d01e078d136c137593).
10107 ///
10108 /// **See also:**
10109 ///
10110 /// [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [cuLibraryGetKernel](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g15336d865f5abd63e3dc6004d5bc037a).
10111 ///
10112 /// # Parameters
10113 ///
10114 /// - `pKernel`: Returned kernel handle.
10115 /// - `library`: Library to retrieve kernel from.
10116 /// - `name`: Name of kernel to retrieve.
10117 pub fn cudaLibraryGetKernel(
10118 pKernel: *mut cudaKernel_t,
10119 library: cudaLibrary_t,
10120 name: *const ::core::ffi::c_char,
10121 ) -> cudaError_t;
10122}
10123unsafe extern "C" {
10124 /// # Parameters
10125 ///
10126 /// - `dptr`: Returned global device pointer for the requested library.
10127 /// - `bytes`: Returned global size in bytes.
10128 /// - `library`: Library to retrieve global from.
10129 /// - `name`: Name of global to retrieve.
10130 pub fn cudaLibraryGetGlobal(
10131 dptr: *mut *mut ::core::ffi::c_void,
10132 bytes: *mut size_t,
10133 library: cudaLibrary_t,
10134 name: *const ::core::ffi::c_char,
10135 ) -> cudaError_t;
10136}
10137unsafe extern "C" {
10138 /// # Parameters
10139 ///
10140 /// - `dptr`: Returned pointer to the managed memory.
10141 /// - `bytes`: Returned memory size in bytes.
10142 /// - `library`: Library to retrieve managed memory from.
10143 /// - `name`: Name of managed memory to retrieve.
10144 pub fn cudaLibraryGetManaged(
10145 dptr: *mut *mut ::core::ffi::c_void,
10146 bytes: *mut size_t,
10147 library: cudaLibrary_t,
10148 name: *const ::core::ffi::c_char,
10149 ) -> cudaError_t;
10150}
10151unsafe extern "C" {
10152 /// # Parameters
10153 ///
10154 /// - `fptr`: Returned pointer to a unified function.
10155 /// - `library`: Library to retrieve function pointer memory from.
10156 /// - `symbol`: Name of function pointer to retrieve.
10157 pub fn cudaLibraryGetUnifiedFunction(
10158 fptr: *mut *mut ::core::ffi::c_void,
10159 library: cudaLibrary_t,
10160 symbol: *const ::core::ffi::c_char,
10161 ) -> cudaError_t;
10162}
10163unsafe extern "C" {
10164 /// Returns the number of kernels within a library.
10165 ///
10166 /// Returns in count the number of kernels in lib.
10167 ///
10168 /// **See also:**
10169 ///
10170 /// [`cudaLibraryEnumerateKernels`], [`cudaLibraryLoadFromFile`], [`cudaLibraryLoadData`], [cuLibraryGetKernelCount](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g142732b1c9afaa662f21cae9a558d2d4).
10171 ///
10172 /// # Parameters
10173 ///
10174 /// - `count`: Number of kernels found within the library.
10175 /// - `lib`: Library to query.
10176 pub fn cudaLibraryGetKernelCount(
10177 count: *mut ::core::ffi::c_uint,
10178 lib: cudaLibrary_t,
10179 ) -> cudaError_t;
10180}
10181unsafe extern "C" {
10182 /// Retrieve the kernel handles within a library.
10183 ///
10184 /// Returns in kernels a maximum number of numKernels kernel handles within lib. The returned kernel handle becomes invalid when the library is unloaded.
10185 ///
10186 /// **See also:**
10187 ///
10188 /// [`cudaLibraryGetKernelCount`], [cuLibraryEnumerateKernels](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1ga8ae2f42ab3a8fe789ac2dced8219608).
10189 ///
10190 /// # Parameters
10191 ///
10192 /// - `kernels`: Buffer where the kernel handles are returned to.
10193 /// - `numKernels`: Maximum number of kernel handles may be returned to the buffer.
10194 /// - `lib`: Library to query from.
10195 pub fn cudaLibraryEnumerateKernels(
10196 kernels: *mut cudaKernel_t,
10197 numKernels: ::core::ffi::c_uint,
10198 lib: cudaLibrary_t,
10199 ) -> cudaError_t;
10200}
10201unsafe extern "C" {
10202 /// Sets information about a kernel.
10203 ///
10204 /// This call sets the value of a specified attribute attr on the kernel kernel for the requested device device to an integer value specified by value. This function returns [cudaSuccess](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
10205 /// can have values set. Attempting to set a value on a read-only attribute will result in an error ([cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c))
10206 ///
10207 /// Note that attributes set using [`cudaFuncSetAttribute`] will override the attribute set by this API irrespective of whether the call to [`cudaFuncSetAttribute`] is made before or after this API call. Because of this and the stricter locking requirements mentioned below it is suggested
10208 /// 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.
10209 ///
10210 /// Valid values for attr are:
10211 ///
10212 /// * [cudaFuncAttributeMaxDynamicSharedMemorySize](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbe9d5a5aea324596d0e686f7c416f71c26) - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute
10213 /// sharedSizeBytes cannot exceed the device attribute [cudaDevAttrMaxSharedMemoryPerBlockOptin](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cd024f669ca60d8ff7b3126dbfc61fd925). The maximal size of requestable dynamic shared memory may differ by GPU architecture.
10214 /// * [cudaFuncAttributePreferredSharedMemoryCarveout](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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,
10215 /// in percent of the total shared memory. See [cudaDevAttrMaxSharedMemoryPerMultiprocessor](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg49e2f8c2c0bd6fe264f2fc970912e5cdc478150b5ec1689a2944aaf7e25a5685). This is only a hint, and the driver can choose a different ratio if required to execute the function.
10216 /// * [cudaFuncAttributeRequiredClusterWidth](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
10217 /// of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime.
10218 /// Setting it at runtime will return cudaErrorNotPermitted.
10219 /// * [cudaFuncAttributeRequiredClusterHeight](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
10220 /// validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at
10221 /// runtime. Setting it at runtime will return cudaErrorNotPermitted.
10222 /// * [cudaFuncAttributeRequiredClusterDepth](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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
10223 /// of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime.
10224 /// Setting it at runtime will return cudaErrorNotPermitted.
10225 /// * [cudaFuncAttributeNonPortableClusterSizeAllowed](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbe7c8c14bf3a2b16ea255c98439d5c54c6): Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed.
10226 /// * [cudaFuncAttributeClusterSchedulingPolicyPreference](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1ggc6c537b33d22c871a103f0fda8ac8bbe6f047d04c6fa955aa5d4719e2f510cee): The block scheduling policy of a function. The value type is cudaClusterSchedulingPolicy.
10227 ///
10228 /// Note:
10229 ///
10230 /// The API has stricter locking requirements in comparison to its legacy counterpart [`cudaFuncSetAttribute`] due to device-wide semantics. If multiple threads are trying to set the same attribute on the same device simultaneously,
10231 /// the attribute setting will depend on the interleavings chosen by the OS scheduler and memory consistency.
10232 ///
10233 /// **See also:**
10234 ///
10235 /// [`cudaLibraryLoadData`], [`cudaLibraryLoadFromFile`], [`cudaLibraryUnload`], [`cudaLibraryGetKernel`], [`cudaLaunchKernel`], [`cudaFuncSetAttribute`], [cuKernelSetAttribute](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__LIBRARY.html#group__CUDA__LIBRARY_1g1093ade718915249de3b14320d567067).
10236 ///
10237 /// # Parameters
10238 ///
10239 /// - `kernel`: Kernel to set attribute of.
10240 /// - `attr`: Attribute requested.
10241 /// - `value`: Value to set.
10242 /// - `device`: Device to set attribute of.
10243 pub fn cudaKernelSetAttributeForDevice(
10244 kernel: cudaKernel_t,
10245 attr: cudaFuncAttribute,
10246 value: ::core::ffi::c_int,
10247 device: ::core::ffi::c_int,
10248 ) -> cudaError_t;
10249}
10250unsafe extern "C" {
10251 /// Get device resources.
10252 ///
10253 /// Get the type resources available to the device. This may often be the starting point for further partitioning or configuring of resources.
10254 ///
10255 /// Note: The API is not supported on 32-bit platforms.
10256 ///
10257 /// Note:
10258 ///
10259 /// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10260 ///
10261 /// **See also:**
10262 ///
10263 /// [cuDeviceGetDevResource](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g6115d21604653f4eafb257f725538ab6), [`cudaExecutionCtxGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`].
10264 ///
10265 /// # Parameters
10266 ///
10267 /// - `device`: Device to get resource for.
10268 /// - `resource`: Output pointer to a [`cudaDevResource`] structure.
10269 pub fn cudaDeviceGetDevResource(
10270 device: ::core::ffi::c_int,
10271 resource: *mut cudaDevResource,
10272 type_: cudaDevResourceType,
10273 ) -> cudaError_t;
10274}
10275unsafe extern "C" {
10276 /// Splits cudaDevResourceTypeSm resources.
10277 ///
10278 /// 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.
10279 ///
10280 /// 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
10281 /// context with that descriptor.
10282 ///
10283 /// When creating the groups, the API will take into account the performance and functional characteristics of the input resource,
10284 /// and guarantee a split that will create a disjoint set of symmetrical partitions. This may lead to fewer groups created than
10285 /// 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
10286 /// with [`cudaDeviceGetDevResource`], or [`cudaExecutionCtxGetDevResource`] for [`cudaDevResourceType::cudaDevResourceTypeSm`], using the minSmPartitionSize and smCoscheduledAlignment fields to determine minimum partition size and alignment granularity, respectively.
10287 ///
10288 /// 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.
10289 ///
10290 /// The following flags are supported:
10291 ///
10292 /// * cudaDevSmResourceSplitIgnoreSmCoscheduling : Lower the minimum SM count and alignment, and treat each SM independent of its hierarchy. This allows more fine grained
10293 /// partitions but at the cost of advanced features (such as large clusters on compute capability 9.0+).
10294 /// * cudaDevSmResourceSplitMaxPotentialClusterSize : Compute Capability 9.0+ only. Attempt to create groups that may allow for maximally sized thread clusters. This can be
10295 /// queried post green context creation using [`cudaOccupancyMaxPotentialClusterSize`] and launch configuration (config), return the maximum cluster size in *clusterSize.").
10296 ///
10297 /// A successful API call must either have:
10298 ///
10299 /// * 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.
10300 /// * 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.
10301 ///
10302 /// Note: The API is not supported on 32-bit platforms.
10303 ///
10304 /// Note:
10305 ///
10306 /// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10307 ///
10308 /// **See also:**
10309 ///
10310 /// [cuDevSmResourceSplitByCount](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1gf8359c74d7286ac32e5db253240d9a6c), [`cudaDeviceGetDevResource`], [`cudaExecutionCtxGetDevResource`], [`cudaDevResourceGenerateDesc`].
10311 ///
10312 /// # Parameters
10313 ///
10314 /// - `result`: Output array of [`cudaDevResource`] resources. Can be NULL to query the number of groups.
10315 /// - `nbGroups`: This is a pointer, specifying the number of groups that would be or should be created as described below.
10316 /// - `input`: Input SM resource to be split. Must be a valid [`cudaDevSmResource`] resource.
10317 /// - `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.
10318 /// - `flags`: Flags specifying how these partitions are used or which constraints to abide by when splitting the input. Zero is valid
10319 /// for default behavior.
10320 /// - `minCount`: Minimum number of SMs required.
10321 pub fn cudaDevSmResourceSplitByCount(
10322 result: *mut cudaDevResource,
10323 nbGroups: *mut ::core::ffi::c_uint,
10324 input: *const cudaDevResource,
10325 remaining: *mut cudaDevResource,
10326 flags: ::core::ffi::c_uint,
10327 minCount: ::core::ffi::c_uint,
10328 ) -> cudaError_t;
10329}
10330unsafe extern "C" {
10331 /// Splits a cudaDevResourceTypeSm resource into structured groups.
10332 ///
10333 /// This API will split a resource of [`cudaDevResourceType::cudaDevResourceTypeSm`] into nbGroups structured device resource groups (the result array), as well as an optional remainder, according to a set of requirements specified in the groupParams array. The term “structured” is a trait that specifies the result has SMs that are co-scheduled together. This co-scheduling can be specified via the coscheduledSmCount field of the groupParams structure, while the smCount will specify how many SMs are required in total for that result. The remainder is always “unstructured”, it does not have
10334 /// any set guarantees with respect to co-scheduling and those properties will need to either be queried via the occupancy set
10335 /// of APIs or further split into structured groups by this API.
10336 ///
10337 /// 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
10338 /// 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
10339 /// create a result entry with, but allowed for discovery purposes when the result is NULL.
10340 ///
10341 /// 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.
10342 ///
10343 /// For a valid call:
10344 ///
10345 /// * result should point to a [`cudaDevResource`] array of size nbGroups, or alternatively, may be NULL, if the developer wishes for only the groupParams entries to be updated
10346 ///
10347 /// * input should be a valid [`cudaDevResourceType::cudaDevResourceTypeSm`] resource that originates from querying the execution context, or device.
10348 ///
10349 /// * The remainder group may be NULL.
10350 ///
10351 /// * There are no API flags at this time, so the value passed in should be 0.
10352 ///
10353 /// * A [`cudaDevSmResourceGroupParams`] array of size nbGroups. Each entry must be zero-initialized.
10354 /// + 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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038727a029e221467a4372a957c009fe8d3) will be returned.
10355 /// + coscheduledSmCount: allows grouping SMs together in order to be able to launch clusters on Compute Architecture 9.0+. The default value may be
10356 /// queried from the device’s [`cudaDevResourceType::cudaDevResourceTypeSm`] resource (8 on Compute Architecture 9.0+ and 2 otherwise). The maximum is 32 on Compute Architecture 9.0+ and 2 otherwise.
10357 /// + 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.
10358 /// + flags:
10359 /// - 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
10360 /// group behave similar to the remainder group for example.
10361 ///
10362 /// **Example params and their effect:**
10363 ///
10364 /// A groupParams array element is defined in the following order:
10365 ///
10366 /// ```text
10367 /// { .smCount, .coscheduledSmCount, .preferredCoscheduledSmCount, .flags, \/\* .reserved \*\/ }
10368 /// ```
10369 ///
10370 /// ```text
10371 /// // Example 1
10372 /// // Will discover how many SMs there are, that are co-scheduled in groups of smCoscheduledAlignment.
10373 /// // The rest is placed in the optional remainder.
10374 /// cudaDevSmResourceGroupParams params { 0, 0, 0, 0 };
10375 /// ```
10376 ///
10377 /// ```text
10378 /// // Example 2
10379 /// // Assuming the device has 10+ SMs, the result will have 10 SMs that are co-scheduled in groups of 2 SMs.
10380 /// // The rest is placed in the optional remainder.
10381 /// cudaDevSmResourceGroupParams params { 10, 2, 0, 0};
10382 /// // Setting the coscheduledSmCount to 2 guarantees that we can always have a valid result
10383 /// // as long as the SM count is less than or equal to the input resource SM count.
10384 /// ```
10385 ///
10386 /// ```text
10387 /// // Example 3
10388 /// // A single piece is split-off, but instead of assigning the rest to the remainder, a second group contains everything else
10389 /// // This assumes the device has 10+ SMs (8 of which are coscheduled in groups of 4),
10390 /// // otherwise the second group could end up with 0 SMs, which is not allowed.
10391 /// cudaDevSmResourceGroupParams params { {8, 4, 0, 0}, {0, 2, 0, cudaDevSmResourceGroupBackfill } }
10392 /// ```
10393 ///
10394 /// The difference between a catch-all param group as the last entry and the remainder is in two aspects:
10395 ///
10396 /// * The remainder may be NULL / _TYPE_INVALID (if there are no SMs remaining), while a result group must always be valid.
10397 /// * The remainder does not have a structure, while the result group will always need to adhere to a structure of coscheduledSmCount
10398 /// (even if its just 2), and therefore must always have enough coscheduled SMs to cover that requirement (even with the cudaDevSmResourceGroupBackfill flag enabled).
10399 ///
10400 /// Splitting an input into N groups, can be accomplished by repeatedly splitting off 1 group and re-splitting the remainder (a
10401 /// bisect operation). However, it's recommended to accomplish this with a single call wherever possible.
10402 ///
10403 /// Note:
10404 ///
10405 /// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10406 ///
10407 /// **See also:**
10408 ///
10409 /// [cuDevSmResourceSplit](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1gc739e0a0b57766ee10437c89909865f3), [`cudaDeviceGetDevResource`], [`cudaExecutionCtxGetDevResource`], [`cudaDevResourceGenerateDesc`].
10410 ///
10411 /// # Parameters
10412 ///
10413 /// - `result`: Output array of [`cudaDevResource`] resources. Can be NULL, alongside an smCount of 0, for discovery purpose.
10414 /// - `nbGroups`: Specifies the number of groups in result and groupParams.
10415 /// - `input`: Input SM resource to be split. Must be a valid cudaDevResourceTypeSm resource.
10416 /// - `remainder`: If splitting the input resource leaves any SMs, the remainder is placed in here.
10417 /// - `flags`: Flags specifying how the API should behave. The value should be 0 for now.
10418 /// - `groupParams`: Description of how the SMs should be split and assigned to the corresponding result entry.
10419 pub fn cudaDevSmResourceSplit(
10420 result: *mut cudaDevResource,
10421 nbGroups: ::core::ffi::c_uint,
10422 input: *const cudaDevResource,
10423 remainder: *mut cudaDevResource,
10424 flags: ::core::ffi::c_uint,
10425 groupParams: *mut cudaDevSmResourceGroupParams,
10426 ) -> cudaError_t;
10427}
10428unsafe extern "C" {
10429 /// Generate a resource descriptor.
10430 ///
10431 /// 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.
10432 ///
10433 /// A successful API call must have:
10434 ///
10435 /// * 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](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038727a029e221467a4372a957c009fe8d3) is returned. If multiple resources are provided in resources and they are of type [`cudaDevResourceType::cudaDevResourceTypeSm`], they must be outputs (whether result or remaining) from the same split API instance and have the same smCoscheduledAlignment values, otherwise [cudaErrorInvalidResourceConfiguration](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038727a029e221467a4372a957c009fe8d3) is returned.
10436 ///
10437 /// Note: The API is not supported on 32-bit platforms.
10438 ///
10439 /// Note:
10440 ///
10441 /// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10442 ///
10443 /// **See also:**
10444 ///
10445 /// [cuDevResourceGenerateDesc](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g1ea7743fd633d2e2dd92eb1c84c4fbc5), [`cudaDeviceGetDevResource`], [`cudaExecutionCtxGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaGreenCtxCreate`].
10446 ///
10447 /// # Parameters
10448 ///
10449 /// - `phDesc`: Output descriptor.
10450 /// - `resources`: Array of resources to be included in the descriptor.
10451 /// - `nbResources`: Number of resources passed in resources.
10452 pub fn cudaDevResourceGenerateDesc(
10453 phDesc: *mut cudaDevResourceDesc_t,
10454 resources: *mut cudaDevResource,
10455 nbResources: ::core::ffi::c_uint,
10456 ) -> cudaError_t;
10457}
10458unsafe extern "C" {
10459 /// Creates a green context with a specified set of resources.
10460 ///
10461 /// This API creates a green context with the resources specified in the descriptor desc and returns it in the handle represented by phCtx.
10462 ///
10463 /// This API retains the device’s primary context for the lifetime of the green context. The primary context will be released
10464 /// when the green context is destroyed. To avoid the overhead of repeated initialization and teardown, it is recommended to explicitly
10465 /// 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
10466 /// green context creation and destruction.
10467 ///
10468 /// The API does not create a default stream for the green context. Developers are expected to create streams explicitly using
10469 /// [`cudaExecutionCtxStreamCreate`] to submit work to the green context.
10470 ///
10471 /// Note: The API is not supported on 32-bit platforms.
10472 ///
10473 /// Note:
10474 ///
10475 /// Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10476 ///
10477 /// **See also:**
10478 ///
10479 /// [`cudaDeviceGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`], [`cudaExecutionCtxGetDevResource`], [`cudaExecutionCtxDestroy`], [`cudaInitDevice`], [`cudaExecutionCtxStreamCreate`].
10480 ///
10481 /// # Parameters
10482 ///
10483 /// - `phCtx`: Pointer for the output handle to the green context.
10484 /// - `desc`: Descriptor generated via [`cudaDevResourceGenerateDesc`] which contains the set of resources to be used.
10485 /// - `device`: Device on which to create the green context.
10486 /// - `flags`: Green context creation flags. Must be 0, currently reserved for future use.
10487 pub fn cudaGreenCtxCreate(
10488 phCtx: *mut cudaExecutionContext_t,
10489 desc: cudaDevResourceDesc_t,
10490 device: ::core::ffi::c_int,
10491 flags: ::core::ffi::c_uint,
10492 ) -> cudaError_t;
10493}
10494unsafe extern "C" {
10495 /// Destroy a execution context.
10496 ///
10497 /// 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.
10498 ///
10499 /// If ctx is a green context, any resources provisioned for it (that were initially available via the resource descriptor) are released
10500 /// as well.
10501 ///
10502 /// 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
10503 /// [cudaErrorStreamDetached](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e0038dac625035f38851dbb8e21a4b556c141) with the exception of the following APIs:
10504 ///
10505 /// * [`cudaStreamDestroy`]. Note this is only supported on CUDA drivers 13.1 and above.
10506 ///
10507 /// Additionally, the API will invalidate all active captures on these streams.
10508 ///
10509 /// Passing in a ctx that was not explicitly created via CUDA Runtime APIs is not allowed and will result in undefined behavior.
10510 ///
10511 /// Note:
10512 ///
10513 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10514 /// * The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit
10515 /// context-based programming without relying on thread-local state. If no context is specified, the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
10516 ///
10517 /// **See also:**
10518 ///
10519 /// [`cudaGreenCtxCreate`].
10520 ///
10521 /// # Parameters
10522 ///
10523 /// - `ctx`: Execution context to destroy (required parameter, see note below).
10524 pub fn cudaExecutionCtxDestroy(ctx: cudaExecutionContext_t) -> cudaError_t;
10525}
10526unsafe extern "C" {
10527 /// Get context resources.
10528 ///
10529 /// Get the type resources available to context represented by ctx.
10530 ///
10531 /// Note: The API is not supported on 32-bit platforms.
10532 ///
10533 /// Note:
10534 ///
10535 /// * Note that this function may also return error codes from previous, asynchronous launches.
10536 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10537 /// * The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit
10538 /// context-based programming without relying on thread-local state. If no context is specified, the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
10539 ///
10540 /// **See also:**
10541 ///
10542 /// [`cudaDeviceGetDevResource`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`], [`cudaGreenCtxCreate`].
10543 ///
10544 /// # Parameters
10545 ///
10546 /// - `ctx`: Execution context to get resource for (required parameter, see note below).
10547 /// - `resource`: Output pointer to a [`cudaDevResource`] structure.
10548 pub fn cudaExecutionCtxGetDevResource(
10549 ctx: cudaExecutionContext_t,
10550 resource: *mut cudaDevResource,
10551 type_: cudaDevResourceType,
10552 ) -> cudaError_t;
10553}
10554unsafe extern "C" {
10555 /// Returns the device handle for the execution context.
10556 ///
10557 /// Returns in \*device the handle of the specified execution context's device. The execution context should not be NULL.
10558 ///
10559 /// Note:
10560 ///
10561 /// * Note that this function may also return error codes from previous, asynchronous launches.
10562 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10563 /// * The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit
10564 /// context-based programming without relying on thread-local state. If no context is specified, the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
10565 ///
10566 /// **See also:**
10567 ///
10568 /// [`cudaGreenCtxCreate`], [`cudaExecutionCtxDestroy`], [cuCtxGetDevice](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g4e84b109eba36cdaaade167f34ae881e).
10569 ///
10570 /// # Parameters
10571 ///
10572 /// - `device`: Returned device handle for the specified execution context.
10573 /// - `ctx`: Execution context for which to obtain the device (required parameter, see note below).
10574 pub fn cudaExecutionCtxGetDevice(
10575 device: *mut ::core::ffi::c_int,
10576 ctx: cudaExecutionContext_t,
10577 ) -> cudaError_t;
10578}
10579unsafe extern "C" {
10580 /// Returns the unique Id associated with the execution context supplied.
10581 ///
10582 /// 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
10583 /// CUDA. The execution context should not be NULL.
10584 ///
10585 /// Note:
10586 ///
10587 /// * Note that this function may also return error codes from previous, asynchronous launches.
10588 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10589 /// * The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit
10590 /// context-based programming without relying on thread-local state. If no context is specified, the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
10591 ///
10592 /// **See also:**
10593 ///
10594 /// [`cudaGreenCtxCreate`], [`cudaExecutionCtxDestroy`], [`cudaExecutionCtxGetDevice`], [cuCtxGetId](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g32f492cd6c3f90af0d6935b294392db5).
10595 ///
10596 /// # Parameters
10597 ///
10598 /// - `ctx`: Context for which to obtain the Id (required parameter, see note below).
10599 /// - `ctxId`: Pointer to store the Id of the context.
10600 pub fn cudaExecutionCtxGetId(
10601 ctx: cudaExecutionContext_t,
10602 ctxId: *mut ::core::ffi::c_ulonglong,
10603 ) -> cudaError_t;
10604}
10605unsafe extern "C" {
10606 /// Creates a stream and initializes it for the given execution context.
10607 ///
10608 /// 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.
10609 ///
10610 /// The supported values for flags are:
10611 ///
10612 /// * [`cudaStreamDefault`]: Default stream creation flag. This would be [`cudaStreamNonBlocking`] for streams created on a green context.
10613 /// * [`cudaStreamNonBlocking`]: Specifies that work running in the created stream may run concurrently with work in stream 0 (the NULL stream), and that
10614 /// the created stream should perform no implicit synchronization with stream 0
10615 ///
10616 /// Specifying priority affects the scheduling priority of work in the stream. Priorities provide a hint to preferentially run work with higher priority
10617 /// 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
10618 /// 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.
10619 ///
10620 /// Note:
10621 ///
10622 /// * Note that this function may also return error codes from previous, asynchronous launches.
10623 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10624 /// * The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit
10625 /// context-based programming without relying on thread-local state. If no context is specified, the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
10626 /// * In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream
10627 /// priorities have no effect on host-to-device and device-to-host memory operations.
10628 ///
10629 /// **See also:**
10630 ///
10631 /// [`cudaStreamDestroy`], [`cudaGreenCtxCreate`], [`cudaDeviceGetStreamPriorityRange`], [`cudaStreamGetFlags`], [`cudaStreamGetPriority`], [`cudaStreamGetDevice`], [`cudaStreamGetDevResource`], [`cudaLaunchKernel`], [`cudaEventRecord`], [`cudaStreamWaitEvent`], [`cudaStreamQuery`], [`cudaStreamSynchronize`], [`cudaStreamAddCallback`].
10632 ///
10633 /// # Parameters
10634 ///
10635 /// - `phStream`: Returned stream handle.
10636 /// - `ctx`: Execution context to initialize the stream with (required parameter, see note below).
10637 /// - `flags`: Flags for stream creation.
10638 /// - `priority`: Stream priority.
10639 pub fn cudaExecutionCtxStreamCreate(
10640 phStream: *mut cudaStream_t,
10641 ctx: cudaExecutionContext_t,
10642 flags: ::core::ffi::c_uint,
10643 priority: ::core::ffi::c_int,
10644 ) -> cudaError_t;
10645}
10646unsafe extern "C" {
10647 /// Block for the specified execution context's tasks to complete.
10648 ///
10649 /// Blocks until the specified execution context has completed all preceding requested tasks. If the specified execution context
10650 /// is the device (primary) context obtained via [`cudaDeviceGetExecutionCtx`], green contexts that have been created on the device will also be synchronized.
10651 ///
10652 /// The API returns an error if one of the preceding tasks failed.
10653 ///
10654 /// Note:
10655 ///
10656 /// * Note that this function may also return error codes from previous, asynchronous launches.
10657 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10658 /// * The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit
10659 /// context-based programming without relying on thread-local state. If no context is specified, the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
10660 ///
10661 /// **See also:**
10662 ///
10663 /// [`cudaGreenCtxCreate`], [`cudaExecutionCtxDestroy`], [`cudaDeviceSynchronize`], [cuCtxSynchronize_v2](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1g7c57ec88e825af32ef8cc1754d69eca5).
10664 ///
10665 /// # Parameters
10666 ///
10667 /// - `ctx`: Execution context to synchronize (required parameter, see note below).
10668 pub fn cudaExecutionCtxSynchronize(ctx: cudaExecutionContext_t) -> cudaError_t;
10669}
10670unsafe extern "C" {
10671 /// Get stream resources.
10672 ///
10673 /// Get the type resources available to the hStream and store them in resource.
10674 ///
10675 /// Note: The API will return [cudaErrorInvalidResourceType](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00384954cdb4893fda9f1a30251a018c32fe) is type is cudaDevResourceTypeWorkqueueConfig or cudaDevResourceTypeWorkqueue.
10676 ///
10677 /// Note:
10678 ///
10679 /// * Note that this function may also return error codes from previous, asynchronous launches.
10680 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10681 ///
10682 /// **See also:**
10683 ///
10684 /// [`cudaGreenCtxCreate`], [`cudaExecutionCtxStreamCreate`], [`cudaStreamCreate`], [`cudaDevSmResourceSplit`], [`cudaDevResourceGenerateDesc`], [cuStreamGetDevResource](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g25acc306a4e2ba88d1eb8b7bd2b2b578).
10685 ///
10686 /// # Parameters
10687 ///
10688 /// - `hStream`: Stream to get resource for.
10689 /// - `resource`: Output pointer to a [`cudaDevResource`] structure.
10690 pub fn cudaStreamGetDevResource(
10691 hStream: cudaStream_t,
10692 resource: *mut cudaDevResource,
10693 type_: cudaDevResourceType,
10694 ) -> cudaError_t;
10695}
10696unsafe extern "C" {
10697 /// Records an event for the specified execution context.
10698 ///
10699 /// 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.
10700 ///
10701 /// Note:
10702 ///
10703 /// The API will return [cudaErrorStreamCaptureUnsupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
10704 ///
10705 /// Note:
10706 ///
10707 /// * Note that this function may also return error codes from previous, asynchronous launches.
10708 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10709 /// * The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit
10710 /// context-based programming without relying on thread-local state. If no context is specified, the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
10711 ///
10712 /// **See also:**
10713 ///
10714 /// [`cudaEventRecord`], [`cudaExecutionCtxWaitEvent`], [cuCtxRecordEvent](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1gf3ee63561a7a371fa9d4dc0e31f94afd), [cuGreenCtxRecordEvent](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g9dd087071cc217ad7ebda6df96d2ee40).
10715 ///
10716 /// # Parameters
10717 ///
10718 /// - `ctx`: Execution context to record event for (required parameter, see note below).
10719 /// - `event`: Event to record.
10720 pub fn cudaExecutionCtxRecordEvent(
10721 ctx: cudaExecutionContext_t,
10722 event: cudaEvent_t,
10723 ) -> cudaError_t;
10724}
10725unsafe extern "C" {
10726 /// Make an execution context wait on an event.
10727 ///
10728 /// 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.
10729 ///
10730 /// Note:
10731 ///
10732 /// * event may be from a different execution context or device than ctx.
10733 /// * The API will return [cudaErrorStreamCaptureUnsupported](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#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.
10734 ///
10735 /// Note:
10736 ///
10737 /// * Note that this function may also return error codes from previous, asynchronous launches.
10738 /// * Note that as specified by [`cudaStreamAddCallback`] no CUDA function may be called from callback. [cudaErrorNotPermitted](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e003867b6095ab719b21659a400b553963eb3) may, but is not guaranteed to, be returned as a diagnostic in such case.
10739 /// * The context parameter is required and the API ignores the context that is current to the calling thread. This enables explicit
10740 /// context-based programming without relying on thread-local state. If no context is specified, the API will return [cudaErrorInvalidValue](https://docs.nvidia.com/cuda/cuda-runtime-api/types.html#group__CUDART__TYPES_1gg3f51e3575c2178246db0a94a430e00383e8aef5398ee38e28ed41e357b48917c).
10741 ///
10742 /// **See also:**
10743 ///
10744 /// [`cudaExecutionCtxRecordEvent`], [`cudaStreamWaitEvent`], [cuCtxWaitEvent](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html#group__CUDA__CTX_1gcf64e420275a8141b1f12bfce3f478f9), [cuGreenCtxWaitEvent](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__GREEN__CONTEXTS.html#group__CUDA__GREEN__CONTEXTS_1g6b26172117084fd024f1396fb66a8ffd).
10745 ///
10746 /// # Parameters
10747 ///
10748 /// - `ctx`: Execution context to wait for (required parameter, see note below).
10749 /// - `event`: Event to wait on.
10750 pub fn cudaExecutionCtxWaitEvent(
10751 ctx: cudaExecutionContext_t,
10752 event: cudaEvent_t,
10753 ) -> cudaError_t;
10754}
10755unsafe extern "C" {
10756 /// Returns the execution context for a device.
10757 ///
10758 /// Returns in ctx the execution context for the specified device. This is the device's primary context. The returned context can then be passed
10759 /// to APIs that take in a cudaExecutionContext_t enabling explicit context-based programming without relying on thread-local
10760 /// state.
10761 ///
10762 /// Passing the returned execution context to [`cudaExecutionCtxDestroy`] is not allowed and will result in undefined behavior.
10763 ///
10764 /// **See also:**
10765 ///
10766 /// [`cudaExecutionCtxGetDevice`], [`cudaExecutionCtxGetId`].
10767 ///
10768 /// # Parameters
10769 ///
10770 /// - `ctx`: Returns the device execution context.
10771 /// - `device`: Device to get the execution context for.
10772 pub fn cudaDeviceGetExecutionCtx(
10773 ctx: *mut cudaExecutionContext_t,
10774 device: ::core::ffi::c_int,
10775 ) -> cudaError_t;
10776}
10777unsafe extern "C" {
10778 pub fn cudaGetExportTable(
10779 ppExportTable: *mut *const ::core::ffi::c_void,
10780 pExportTableId: *const cudaUUID_t,
10781 ) -> cudaError_t;
10782}
10783unsafe extern "C" {
10784 /// Get pointer to device entry function that matches entry function symbolPtr.
10785 ///
10786 /// Returns in functionPtr the device entry function corresponding to the symbol symbolPtr.
10787 ///
10788 /// # Parameters
10789 ///
10790 /// - `functionPtr`: Returns the device entry function.
10791 /// - `symbolPtr`: Pointer to device entry function to search for.
10792 pub fn cudaGetFuncBySymbol(
10793 functionPtr: *mut cudaFunction_t,
10794 symbolPtr: *const ::core::ffi::c_void,
10795 ) -> cudaError_t;
10796}
10797unsafe extern "C" {
10798 /// # Parameters
10799 ///
10800 /// - `kernelPtr`: Returns the device kernel.
10801 pub fn cudaGetKernel(
10802 kernelPtr: *mut cudaKernel_t,
10803 entryFuncAddr: *const ::core::ffi::c_void,
10804 ) -> cudaError_t;
10805}