Skip to main content

baracuda_cuda_sys/
functions.rs

1//! C function-pointer aliases for the CUDA Driver API.
2//!
3//! Each `PFN_*` alias is the signature of the corresponding driver function
4//! as it appears in `cuda.h`. The [`Driver`](crate::Driver) struct caches
5//! a lazily-resolved function pointer per symbol.
6
7#![allow(non_camel_case_types)]
8
9use core::ffi::{c_char, c_int, c_uint, c_void};
10
11use crate::status::CUresult;
12use crate::types::{
13    CUcontext, CUdevice, CUdeviceptr, CUevent, CUfunction, CUgraph, CUgraphExec, CUgraphNode,
14    CUmodule, CUstream,
15};
16
17// ---- bootstrap -------------------------------------------------------------
18
19/// CUDA 11.3+ driver entry-point resolver. We resolve every *other* symbol
20/// through this function so we pick the correct `_ptsz` / `_v2` / `_v3`
21/// variant for the installed driver and the process's stream-mode choice.
22pub type PFN_cuGetProcAddress = unsafe extern "C" fn(
23    symbol: *const c_char,
24    pfn: *mut *mut c_void,
25    cuda_version: c_int,
26    flags: u64,
27) -> CUresult;
28
29// ---- initialization & version ---------------------------------------------
30
31pub type PFN_cuInit = unsafe extern "C" fn(flags: c_uint) -> CUresult;
32pub type PFN_cuDriverGetVersion = unsafe extern "C" fn(version: *mut c_int) -> CUresult;
33
34// ---- errors ---------------------------------------------------------------
35
36pub type PFN_cuGetErrorName =
37    unsafe extern "C" fn(error: CUresult, out: *mut *const c_char) -> CUresult;
38pub type PFN_cuGetErrorString =
39    unsafe extern "C" fn(error: CUresult, out: *mut *const c_char) -> CUresult;
40
41// ---- device management ----------------------------------------------------
42
43pub type PFN_cuDeviceGetCount = unsafe extern "C" fn(count: *mut c_int) -> CUresult;
44pub type PFN_cuDeviceGet = unsafe extern "C" fn(device: *mut CUdevice, ordinal: c_int) -> CUresult;
45pub type PFN_cuDeviceGetName =
46    unsafe extern "C" fn(name: *mut c_char, len: c_int, dev: CUdevice) -> CUresult;
47pub type PFN_cuDeviceGetAttribute =
48    unsafe extern "C" fn(out: *mut c_int, attr: c_int, dev: CUdevice) -> CUresult;
49pub type PFN_cuDeviceTotalMem = unsafe extern "C" fn(bytes: *mut usize, dev: CUdevice) -> CUresult;
50
51// ---- context management ---------------------------------------------------
52
53pub type PFN_cuCtxCreate =
54    unsafe extern "C" fn(ctx: *mut CUcontext, flags: c_uint, dev: CUdevice) -> CUresult;
55pub type PFN_cuCtxDestroy = unsafe extern "C" fn(ctx: CUcontext) -> CUresult;
56pub type PFN_cuCtxGetCurrent = unsafe extern "C" fn(ctx: *mut CUcontext) -> CUresult;
57pub type PFN_cuCtxSetCurrent = unsafe extern "C" fn(ctx: CUcontext) -> CUresult;
58pub type PFN_cuCtxPushCurrent = unsafe extern "C" fn(ctx: CUcontext) -> CUresult;
59pub type PFN_cuCtxPopCurrent = unsafe extern "C" fn(ctx: *mut CUcontext) -> CUresult;
60pub type PFN_cuCtxSynchronize = unsafe extern "C" fn() -> CUresult;
61
62// ---- primary context ------------------------------------------------------
63
64pub type PFN_cuDevicePrimaryCtxRetain =
65    unsafe extern "C" fn(ctx: *mut CUcontext, dev: CUdevice) -> CUresult;
66pub type PFN_cuDevicePrimaryCtxRelease = unsafe extern "C" fn(dev: CUdevice) -> CUresult;
67pub type PFN_cuDevicePrimaryCtxReset = unsafe extern "C" fn(dev: CUdevice) -> CUresult;
68
69// ---- memory management ----------------------------------------------------
70
71pub type PFN_cuMemAlloc = unsafe extern "C" fn(dptr: *mut CUdeviceptr, bytes: usize) -> CUresult;
72pub type PFN_cuMemFree = unsafe extern "C" fn(dptr: CUdeviceptr) -> CUresult;
73
74pub type PFN_cuMemcpyHtoD =
75    unsafe extern "C" fn(dst: CUdeviceptr, src: *const c_void, bytes: usize) -> CUresult;
76pub type PFN_cuMemcpyDtoH =
77    unsafe extern "C" fn(dst: *mut c_void, src: CUdeviceptr, bytes: usize) -> CUresult;
78pub type PFN_cuMemcpyDtoD =
79    unsafe extern "C" fn(dst: CUdeviceptr, src: CUdeviceptr, bytes: usize) -> CUresult;
80
81pub type PFN_cuMemcpyHtoDAsync = unsafe extern "C" fn(
82    dst: CUdeviceptr,
83    src: *const c_void,
84    bytes: usize,
85    stream: CUstream,
86) -> CUresult;
87pub type PFN_cuMemcpyDtoHAsync = unsafe extern "C" fn(
88    dst: *mut c_void,
89    src: CUdeviceptr,
90    bytes: usize,
91    stream: CUstream,
92) -> CUresult;
93
94pub type PFN_cuMemsetD8 =
95    unsafe extern "C" fn(dst: CUdeviceptr, value: u8, count: usize) -> CUresult;
96pub type PFN_cuMemsetD32 =
97    unsafe extern "C" fn(dst: CUdeviceptr, value: u32, count: usize) -> CUresult;
98
99// ---- stream management ----------------------------------------------------
100
101pub type PFN_cuStreamCreate =
102    unsafe extern "C" fn(stream: *mut CUstream, flags: c_uint) -> CUresult;
103pub type PFN_cuStreamDestroy = unsafe extern "C" fn(stream: CUstream) -> CUresult;
104pub type PFN_cuStreamSynchronize = unsafe extern "C" fn(stream: CUstream) -> CUresult;
105pub type PFN_cuStreamQuery = unsafe extern "C" fn(stream: CUstream) -> CUresult;
106pub type PFN_cuStreamWaitEvent =
107    unsafe extern "C" fn(stream: CUstream, event: CUevent, flags: c_uint) -> CUresult;
108
109// ---- event management -----------------------------------------------------
110
111pub type PFN_cuEventCreate = unsafe extern "C" fn(event: *mut CUevent, flags: c_uint) -> CUresult;
112pub type PFN_cuEventDestroy = unsafe extern "C" fn(event: CUevent) -> CUresult;
113pub type PFN_cuEventRecord = unsafe extern "C" fn(event: CUevent, stream: CUstream) -> CUresult;
114pub type PFN_cuEventSynchronize = unsafe extern "C" fn(event: CUevent) -> CUresult;
115pub type PFN_cuEventQuery = unsafe extern "C" fn(event: CUevent) -> CUresult;
116pub type PFN_cuEventElapsedTime =
117    unsafe extern "C" fn(ms: *mut f32, start: CUevent, end: CUevent) -> CUresult;
118
119// ---- module loading & kernel launch --------------------------------------
120
121pub type PFN_cuModuleLoadData =
122    unsafe extern "C" fn(module: *mut CUmodule, image: *const c_void) -> CUresult;
123pub type PFN_cuModuleUnload = unsafe extern "C" fn(module: CUmodule) -> CUresult;
124pub type PFN_cuModuleGetFunction =
125    unsafe extern "C" fn(func: *mut CUfunction, module: CUmodule, name: *const c_char) -> CUresult;
126
127pub type PFN_cuLaunchKernel = unsafe extern "C" fn(
128    func: CUfunction,
129    grid_dim_x: c_uint,
130    grid_dim_y: c_uint,
131    grid_dim_z: c_uint,
132    block_dim_x: c_uint,
133    block_dim_y: c_uint,
134    block_dim_z: c_uint,
135    shared_mem_bytes: c_uint,
136    stream: CUstream,
137    kernel_params: *mut *mut c_void,
138    extra: *mut *mut c_void,
139) -> CUresult;
140
141// ---- stream capture / graphs ---------------------------------------------
142
143pub type PFN_cuStreamBeginCapture =
144    unsafe extern "C" fn(stream: CUstream, mode: c_uint) -> CUresult;
145pub type PFN_cuStreamEndCapture =
146    unsafe extern "C" fn(stream: CUstream, graph: *mut CUgraph) -> CUresult;
147pub type PFN_cuStreamIsCapturing =
148    unsafe extern "C" fn(stream: CUstream, status: *mut c_uint) -> CUresult;
149pub type PFN_cuGraphCreate = unsafe extern "C" fn(graph: *mut CUgraph, flags: c_uint) -> CUresult;
150pub type PFN_cuGraphDestroy = unsafe extern "C" fn(graph: CUgraph) -> CUresult;
151pub type PFN_cuGraphInstantiateWithFlags =
152    unsafe extern "C" fn(graph_exec: *mut CUgraphExec, graph: CUgraph, flags: u64) -> CUresult;
153pub type PFN_cuGraphLaunch =
154    unsafe extern "C" fn(graph_exec: CUgraphExec, stream: CUstream) -> CUresult;
155pub type PFN_cuGraphExecDestroy = unsafe extern "C" fn(graph_exec: CUgraphExec) -> CUresult;
156pub type PFN_cuGraphGetNodes = unsafe extern "C" fn(
157    graph: CUgraph,
158    nodes: *mut *mut c_void,
159    num_nodes: *mut usize,
160) -> CUresult;
161
162// ---- stream-ordered memory allocation (CUDA 11.2+) ----------------------
163
164pub type PFN_cuMemAllocAsync =
165    unsafe extern "C" fn(dptr: *mut CUdeviceptr, bytes: usize, stream: CUstream) -> CUresult;
166pub type PFN_cuMemFreeAsync = unsafe extern "C" fn(dptr: CUdeviceptr, stream: CUstream) -> CUresult;
167
168// ---- Wave 1: occupancy, unified memory, peer, pointer attrs --------------
169
170pub type PFN_cuOccupancyMaxActiveBlocksPerMultiprocessor = unsafe extern "C" fn(
171    num_blocks: *mut c_int,
172    func: CUfunction,
173    block_size: c_int,
174    dynamic_smem_bytes: usize,
175) -> CUresult;
176
177pub type PFN_cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags =
178    unsafe extern "C" fn(
179        num_blocks: *mut c_int,
180        func: CUfunction,
181        block_size: c_int,
182        dynamic_smem_bytes: usize,
183        flags: c_uint,
184    ) -> CUresult;
185
186/// Signature of the `block_size_to_dynamic_smem_size` callback.
187pub type CUoccupancyB2DSize = Option<unsafe extern "C" fn(block_size: c_int) -> usize>;
188
189pub type PFN_cuOccupancyMaxPotentialBlockSize = unsafe extern "C" fn(
190    min_grid_size: *mut c_int,
191    block_size: *mut c_int,
192    func: CUfunction,
193    block_size_to_dynamic_smem_size: CUoccupancyB2DSize,
194    dynamic_smem_bytes: usize,
195    block_size_limit: c_int,
196) -> CUresult;
197
198pub type PFN_cuOccupancyAvailableDynamicSMemPerBlock = unsafe extern "C" fn(
199    dynamic_smem_size: *mut usize,
200    func: CUfunction,
201    num_blocks: c_int,
202    block_size: c_int,
203) -> CUresult;
204
205pub type PFN_cuMemAllocManaged =
206    unsafe extern "C" fn(dptr: *mut CUdeviceptr, bytes: usize, flags: c_uint) -> CUresult;
207
208pub type PFN_cuMemAdvise = unsafe extern "C" fn(
209    devptr: CUdeviceptr,
210    count: usize,
211    advice: c_int,
212    device: CUdevice,
213) -> CUresult;
214
215pub type PFN_cuMemPrefetchAsync = unsafe extern "C" fn(
216    devptr: CUdeviceptr,
217    count: usize,
218    dst_device: CUdevice,
219    stream: CUstream,
220) -> CUresult;
221
222pub type PFN_cuMemGetInfo = unsafe extern "C" fn(free: *mut usize, total: *mut usize) -> CUresult;
223
224// ---- context queries -----------------------------------------------------
225
226pub type PFN_cuCtxGetDevice = unsafe extern "C" fn(device: *mut CUdevice) -> CUresult;
227pub type PFN_cuCtxGetApiVersion =
228    unsafe extern "C" fn(ctx: CUcontext, version: *mut c_uint) -> CUresult;
229pub type PFN_cuCtxGetFlags = unsafe extern "C" fn(flags: *mut c_uint) -> CUresult;
230pub type PFN_cuCtxGetLimit = unsafe extern "C" fn(pvalue: *mut usize, limit: c_uint) -> CUresult;
231pub type PFN_cuCtxSetLimit = unsafe extern "C" fn(limit: c_uint, value: usize) -> CUresult;
232pub type PFN_cuCtxGetCacheConfig = unsafe extern "C" fn(pconfig: *mut c_uint) -> CUresult;
233pub type PFN_cuCtxSetCacheConfig = unsafe extern "C" fn(config: c_uint) -> CUresult;
234pub type PFN_cuCtxGetStreamPriorityRange =
235    unsafe extern "C" fn(least_priority: *mut c_int, greatest_priority: *mut c_int) -> CUresult;
236
237// ---- peer access ---------------------------------------------------------
238
239pub type PFN_cuDeviceCanAccessPeer = unsafe extern "C" fn(
240    can_access_peer: *mut c_int,
241    dev: CUdevice,
242    peer_dev: CUdevice,
243) -> CUresult;
244pub type PFN_cuCtxEnablePeerAccess =
245    unsafe extern "C" fn(peer_context: CUcontext, flags: c_uint) -> CUresult;
246pub type PFN_cuCtxDisablePeerAccess = unsafe extern "C" fn(peer_context: CUcontext) -> CUresult;
247
248// ---- pointer attributes --------------------------------------------------
249
250pub type PFN_cuPointerGetAttribute =
251    unsafe extern "C" fn(data: *mut c_void, attribute: c_int, ptr: CUdeviceptr) -> CUresult;
252
253// ---- stream priority/flags + host func -----------------------------------
254
255pub type PFN_cuStreamCreateWithPriority =
256    unsafe extern "C" fn(stream: *mut CUstream, flags: c_uint, priority: c_int) -> CUresult;
257pub type PFN_cuStreamGetPriority =
258    unsafe extern "C" fn(stream: CUstream, priority: *mut c_int) -> CUresult;
259pub type PFN_cuStreamGetFlags =
260    unsafe extern "C" fn(stream: CUstream, flags: *mut c_uint) -> CUresult;
261pub type PFN_cuStreamGetCtx =
262    unsafe extern "C" fn(stream: CUstream, pctx: *mut CUcontext) -> CUresult;
263pub type CUhostFn = Option<unsafe extern "C" fn(user_data: *mut c_void)>;
264pub type PFN_cuLaunchHostFunc =
265    unsafe extern "C" fn(stream: CUstream, fn_ptr: CUhostFn, user_data: *mut c_void) -> CUresult;
266
267// ---- event flags ---------------------------------------------------------
268
269pub type PFN_cuEventRecordWithFlags =
270    unsafe extern "C" fn(event: CUevent, stream: CUstream, flags: c_uint) -> CUresult;
271
272// ---- primary context state ----------------------------------------------
273
274pub type PFN_cuDevicePrimaryCtxGetState =
275    unsafe extern "C" fn(dev: CUdevice, flags: *mut c_uint, active: *mut c_int) -> CUresult;
276pub type PFN_cuDevicePrimaryCtxSetFlags =
277    unsafe extern "C" fn(dev: CUdevice, flags: c_uint) -> CUresult;
278
279// ---- Wave 2: kernel attrs, module globals, module load with JIT options --
280
281pub type PFN_cuFuncGetAttribute =
282    unsafe extern "C" fn(pi: *mut c_int, attrib: c_int, hfunc: CUfunction) -> CUresult;
283pub type PFN_cuFuncSetAttribute =
284    unsafe extern "C" fn(hfunc: CUfunction, attrib: c_int, value: c_int) -> CUresult;
285
286pub type PFN_cuModuleGetGlobal = unsafe extern "C" fn(
287    dptr: *mut CUdeviceptr,
288    bytes: *mut usize,
289    module: CUmodule,
290    name: *const c_char,
291) -> CUresult;
292
293/// `cuModuleLoadDataEx` — load a PTX/cubin image with JIT compiler options.
294/// `options` is an array of `CUjit_option` (i32) values; `option_values` is
295/// a parallel array of `void*` whose interpretation depends on the option.
296pub type PFN_cuModuleLoadDataEx = unsafe extern "C" fn(
297    module: *mut CUmodule,
298    image: *const c_void,
299    num_options: c_uint,
300    options: *mut c_int,
301    option_values: *mut *mut c_void,
302) -> CUresult;
303
304// ---- Wave 4: 2D allocation + memcpy --------------------------------------
305
306pub type PFN_cuMemAllocPitch = unsafe extern "C" fn(
307    dptr: *mut CUdeviceptr,
308    pitch: *mut usize,
309    width_in_bytes: usize,
310    height: usize,
311    element_size_bytes: c_uint,
312) -> CUresult;
313
314pub type PFN_cuMemcpy2D =
315    unsafe extern "C" fn(p_copy: *const crate::types::CUDA_MEMCPY2D) -> CUresult;
316pub type PFN_cuMemcpy2DAsync =
317    unsafe extern "C" fn(p_copy: *const crate::types::CUDA_MEMCPY2D, stream: CUstream) -> CUresult;
318
319// ---- Wave 3: cuLaunchKernelEx + Library Management -----------------------
320
321use crate::types::CUlaunchConfig;
322use crate::{CUkernel, CUlibrary};
323
324pub type PFN_cuLaunchKernelEx = unsafe extern "C" fn(
325    config: *const CUlaunchConfig,
326    f: CUfunction,
327    kernel_params: *mut *mut c_void,
328    extra: *mut *mut c_void,
329) -> CUresult;
330
331/// `cuLibraryLoadData` — context-independent module load (CUDA 12.0+).
332///
333/// The "JIT options" and "library options" are each a parallel pair of
334/// `CUjit_option` / `CUlibraryOption` arrays with matching `void**` values.
335/// For v0.1 we only expose the no-options call shape (pass `0` / `null` for
336/// counts and arrays).
337pub type PFN_cuLibraryLoadData = unsafe extern "C" fn(
338    library: *mut CUlibrary,
339    code: *const c_void,
340    jit_options: *mut c_int,
341    jit_option_values: *mut *mut c_void,
342    num_jit_options: c_uint,
343    library_options: *mut c_int,
344    library_option_values: *mut *mut c_void,
345    num_library_options: c_uint,
346) -> CUresult;
347
348pub type PFN_cuLibraryUnload = unsafe extern "C" fn(library: CUlibrary) -> CUresult;
349
350pub type PFN_cuLibraryGetKernel = unsafe extern "C" fn(
351    kernel: *mut CUkernel,
352    library: CUlibrary,
353    name: *const c_char,
354) -> CUresult;
355
356pub type PFN_cuLibraryGetGlobal = unsafe extern "C" fn(
357    dptr: *mut CUdeviceptr,
358    bytes: *mut usize,
359    library: CUlibrary,
360    name: *const c_char,
361) -> CUresult;
362
363pub type PFN_cuKernelGetFunction =
364    unsafe extern "C" fn(pfunc: *mut CUfunction, kernel: CUkernel) -> CUresult;
365
366// ---- Wave 5: explicit graph node construction ----------------------------
367
368/// `cuGraphAddKernelNode_v2` — v2 shape, matches our
369/// [`crate::types::CUDA_KERNEL_NODE_PARAMS`] layout (with `kern` + `ctx`
370/// trailing fields). Pinned to `_v2` via [`has_version_suffix`] routing.
371pub type PFN_cuGraphAddKernelNode = unsafe extern "C" fn(
372    graph_node: *mut CUgraphNode,
373    graph: CUgraph,
374    dependencies: *const CUgraphNode,
375    num_dependencies: usize,
376    node_params: *const crate::types::CUDA_KERNEL_NODE_PARAMS,
377) -> CUresult;
378
379pub type PFN_cuGraphAddEmptyNode = unsafe extern "C" fn(
380    graph_node: *mut CUgraphNode,
381    graph: CUgraph,
382    dependencies: *const CUgraphNode,
383    num_dependencies: usize,
384) -> CUresult;
385
386/// `cuGraphAddMemsetNode` — always took a trailing `CUcontext` since CUDA
387/// 10 (memsets can target any context, unlike kernel nodes).
388pub type PFN_cuGraphAddMemsetNode = unsafe extern "C" fn(
389    graph_node: *mut CUgraphNode,
390    graph: CUgraph,
391    dependencies: *const CUgraphNode,
392    num_dependencies: usize,
393    memset_params: *const crate::types::CUDA_MEMSET_NODE_PARAMS,
394    ctx: CUcontext,
395) -> CUresult;
396
397pub type PFN_cuGraphDestroyNode = unsafe extern "C" fn(node: CUgraphNode) -> CUresult;
398
399pub type PFN_cuGraphClone =
400    unsafe extern "C" fn(clone: *mut CUgraph, original: CUgraph) -> CUresult;
401
402// ---- Wave 6: arrays, textures, surfaces ----------------------------------
403
404use crate::types::{
405    CUarray, CUsurfObject, CUtexObject, CUDA_ARRAY_DESCRIPTOR, CUDA_RESOURCE_DESC,
406    CUDA_TEXTURE_DESC,
407};
408
409pub type PFN_cuArrayCreate =
410    unsafe extern "C" fn(array: *mut CUarray, desc: *const CUDA_ARRAY_DESCRIPTOR) -> CUresult;
411
412pub type PFN_cuArrayDestroy = unsafe extern "C" fn(array: CUarray) -> CUresult;
413
414pub type PFN_cuTexObjectCreate = unsafe extern "C" fn(
415    tex: *mut CUtexObject,
416    res_desc: *const CUDA_RESOURCE_DESC,
417    tex_desc: *const CUDA_TEXTURE_DESC,
418    res_view_desc: *const c_void,
419) -> CUresult;
420
421pub type PFN_cuTexObjectDestroy = unsafe extern "C" fn(tex: CUtexObject) -> CUresult;
422
423pub type PFN_cuSurfObjectCreate =
424    unsafe extern "C" fn(surf: *mut CUsurfObject, res_desc: *const CUDA_RESOURCE_DESC) -> CUresult;
425
426pub type PFN_cuSurfObjectDestroy = unsafe extern "C" fn(surf: CUsurfObject) -> CUresult;
427
428// ---- Wave 7: virtual memory management (VMM) ----------------------------
429
430use crate::types::{CUmemAccessDesc, CUmemAllocationProp, CUmemGenericAllocationHandle};
431
432pub type PFN_cuMemAddressReserve = unsafe extern "C" fn(
433    ptr: *mut CUdeviceptr,
434    size: usize,
435    alignment: usize,
436    addr: CUdeviceptr,
437    flags: u64,
438) -> CUresult;
439
440pub type PFN_cuMemAddressFree = unsafe extern "C" fn(ptr: CUdeviceptr, size: usize) -> CUresult;
441
442pub type PFN_cuMemCreate = unsafe extern "C" fn(
443    handle: *mut CUmemGenericAllocationHandle,
444    size: usize,
445    prop: *const CUmemAllocationProp,
446    flags: u64,
447) -> CUresult;
448
449pub type PFN_cuMemRelease = unsafe extern "C" fn(handle: CUmemGenericAllocationHandle) -> CUresult;
450
451pub type PFN_cuMemMap = unsafe extern "C" fn(
452    ptr: CUdeviceptr,
453    size: usize,
454    offset: usize,
455    handle: CUmemGenericAllocationHandle,
456    flags: u64,
457) -> CUresult;
458
459pub type PFN_cuMemUnmap = unsafe extern "C" fn(ptr: CUdeviceptr, size: usize) -> CUresult;
460
461pub type PFN_cuMemSetAccess = unsafe extern "C" fn(
462    ptr: CUdeviceptr,
463    size: usize,
464    desc: *const CUmemAccessDesc,
465    count: usize,
466) -> CUresult;
467
468pub type PFN_cuMemGetAllocationGranularity = unsafe extern "C" fn(
469    granularity: *mut usize,
470    prop: *const CUmemAllocationProp,
471    option: c_int,
472) -> CUresult;
473
474// ---- Wave 8: memory pools -----------------------------------------------
475
476use crate::types::{CUmemPoolProps, CUmemPoolPtrExportData, CUmemoryPool};
477
478pub type PFN_cuMemPoolCreate =
479    unsafe extern "C" fn(pool: *mut CUmemoryPool, props: *const CUmemPoolProps) -> CUresult;
480
481pub type PFN_cuMemPoolDestroy = unsafe extern "C" fn(pool: CUmemoryPool) -> CUresult;
482
483pub type PFN_cuMemPoolSetAttribute =
484    unsafe extern "C" fn(pool: CUmemoryPool, attr: c_int, value: *mut c_void) -> CUresult;
485
486pub type PFN_cuMemPoolGetAttribute =
487    unsafe extern "C" fn(pool: CUmemoryPool, attr: c_int, value: *mut c_void) -> CUresult;
488
489pub type PFN_cuMemPoolTrimTo =
490    unsafe extern "C" fn(pool: CUmemoryPool, min_bytes_to_keep: usize) -> CUresult;
491
492pub type PFN_cuMemPoolSetAccess =
493    unsafe extern "C" fn(pool: CUmemoryPool, map: *const CUmemAccessDesc, count: usize) -> CUresult;
494
495pub type PFN_cuMemPoolGetAccess = unsafe extern "C" fn(
496    flags: *mut c_int,
497    pool: CUmemoryPool,
498    location: *mut crate::types::CUmemLocation,
499) -> CUresult;
500
501pub type PFN_cuMemAllocFromPoolAsync = unsafe extern "C" fn(
502    dptr: *mut CUdeviceptr,
503    bytes: usize,
504    pool: CUmemoryPool,
505    stream: CUstream,
506) -> CUresult;
507
508pub type PFN_cuDeviceGetDefaultMemPool =
509    unsafe extern "C" fn(pool: *mut CUmemoryPool, dev: CUdevice) -> CUresult;
510
511pub type PFN_cuDeviceGetMemPool =
512    unsafe extern "C" fn(pool: *mut CUmemoryPool, dev: CUdevice) -> CUresult;
513
514pub type PFN_cuDeviceSetMemPool =
515    unsafe extern "C" fn(dev: CUdevice, pool: CUmemoryPool) -> CUresult;
516
517pub type PFN_cuMemPoolExportToShareableHandle = unsafe extern "C" fn(
518    handle_out: *mut c_void,
519    pool: CUmemoryPool,
520    handle_type: c_int,
521    flags: u64,
522) -> CUresult;
523
524pub type PFN_cuMemPoolImportFromShareableHandle = unsafe extern "C" fn(
525    pool_out: *mut CUmemoryPool,
526    handle: *mut c_void,
527    handle_type: c_int,
528    flags: u64,
529) -> CUresult;
530
531pub type PFN_cuMemPoolExportPointer =
532    unsafe extern "C" fn(share_data_out: *mut CUmemPoolPtrExportData, ptr: CUdeviceptr) -> CUresult;
533
534pub type PFN_cuMemPoolImportPointer = unsafe extern "C" fn(
535    ptr_out: *mut CUdeviceptr,
536    pool: CUmemoryPool,
537    share_data: *mut CUmemPoolPtrExportData,
538) -> CUresult;
539
540// ---- Wave 9: external memory / semaphore interop ------------------------
541
542use crate::types::{
543    CUexternalMemory, CUexternalSemaphore, CUDA_EXTERNAL_MEMORY_BUFFER_DESC,
544    CUDA_EXTERNAL_MEMORY_HANDLE_DESC, CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC,
545    CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS, CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS,
546};
547
548pub type PFN_cuImportExternalMemory = unsafe extern "C" fn(
549    mem_out: *mut CUexternalMemory,
550    mem_handle_desc: *const CUDA_EXTERNAL_MEMORY_HANDLE_DESC,
551) -> CUresult;
552
553pub type PFN_cuDestroyExternalMemory = unsafe extern "C" fn(mem: CUexternalMemory) -> CUresult;
554
555pub type PFN_cuExternalMemoryGetMappedBuffer = unsafe extern "C" fn(
556    dptr: *mut CUdeviceptr,
557    mem: CUexternalMemory,
558    buf_desc: *const CUDA_EXTERNAL_MEMORY_BUFFER_DESC,
559) -> CUresult;
560
561/// Mipmapped-array variant — descriptor points at `CUDA_ARRAY3D_DESCRIPTOR`,
562/// which baracuda v0.1 does not yet expose. Provided at sys level for
563/// forward compat; a safe wrapper lands with Wave 10 (3D arrays).
564pub type PFN_cuExternalMemoryGetMappedMipmappedArray = unsafe extern "C" fn(
565    mipmap: *mut c_void,
566    mem: CUexternalMemory,
567    mipmap_desc: *const c_void,
568) -> CUresult;
569
570pub type PFN_cuImportExternalSemaphore = unsafe extern "C" fn(
571    sem_out: *mut CUexternalSemaphore,
572    sem_handle_desc: *const CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC,
573) -> CUresult;
574
575pub type PFN_cuDestroyExternalSemaphore =
576    unsafe extern "C" fn(sem: CUexternalSemaphore) -> CUresult;
577
578pub type PFN_cuSignalExternalSemaphoresAsync = unsafe extern "C" fn(
579    ext_sem_array: *const CUexternalSemaphore,
580    params_array: *const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS,
581    num_ext_sems: c_uint,
582    stream: CUstream,
583) -> CUresult;
584
585pub type PFN_cuWaitExternalSemaphoresAsync = unsafe extern "C" fn(
586    ext_sem_array: *const CUexternalSemaphore,
587    params_array: *const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS,
588    num_ext_sems: c_uint,
589    stream: CUstream,
590) -> CUresult;
591
592// ---- Wave 10: 3D memcpy + 3D arrays + mipmapped arrays ------------------
593
594use crate::types::{CUmipmappedArray, CUDA_ARRAY3D_DESCRIPTOR, CUDA_MEMCPY3D};
595
596pub type PFN_cuArray3DCreate = unsafe extern "C" fn(
597    array: *mut crate::types::CUarray,
598    desc: *const CUDA_ARRAY3D_DESCRIPTOR,
599) -> CUresult;
600
601pub type PFN_cuArray3DGetDescriptor = unsafe extern "C" fn(
602    desc: *mut CUDA_ARRAY3D_DESCRIPTOR,
603    array: crate::types::CUarray,
604) -> CUresult;
605
606pub type PFN_cuMemcpy3D = unsafe extern "C" fn(p_copy: *const CUDA_MEMCPY3D) -> CUresult;
607
608pub type PFN_cuMemcpy3DAsync =
609    unsafe extern "C" fn(p_copy: *const CUDA_MEMCPY3D, stream: CUstream) -> CUresult;
610
611pub type PFN_cuMipmappedArrayCreate = unsafe extern "C" fn(
612    mipmap: *mut CUmipmappedArray,
613    desc: *const CUDA_ARRAY3D_DESCRIPTOR,
614    num_mipmap_levels: c_uint,
615) -> CUresult;
616
617pub type PFN_cuMipmappedArrayDestroy = unsafe extern "C" fn(mipmap: CUmipmappedArray) -> CUresult;
618
619pub type PFN_cuMipmappedArrayGetLevel = unsafe extern "C" fn(
620    level_array: *mut crate::types::CUarray,
621    mipmap: CUmipmappedArray,
622    level: c_uint,
623) -> CUresult;
624
625// ---- Wave 11: pinned host memory ----------------------------------------
626
627pub type PFN_cuMemAllocHost =
628    unsafe extern "C" fn(pp: *mut *mut c_void, bytesize: usize) -> CUresult;
629
630pub type PFN_cuMemFreeHost = unsafe extern "C" fn(p: *mut c_void) -> CUresult;
631
632pub type PFN_cuMemHostAlloc =
633    unsafe extern "C" fn(pp: *mut *mut c_void, bytesize: usize, flags: c_uint) -> CUresult;
634
635pub type PFN_cuMemHostRegister =
636    unsafe extern "C" fn(p: *mut c_void, bytesize: usize, flags: c_uint) -> CUresult;
637
638pub type PFN_cuMemHostUnregister = unsafe extern "C" fn(p: *mut c_void) -> CUresult;
639
640pub type PFN_cuMemHostGetDevicePointer =
641    unsafe extern "C" fn(pdptr: *mut CUdeviceptr, p: *mut c_void, flags: c_uint) -> CUresult;
642
643pub type PFN_cuMemHostGetFlags =
644    unsafe extern "C" fn(flags: *mut c_uint, p: *mut c_void) -> CUresult;
645
646// ---- Wave 12: full graph node builders + edit ---------------------------
647
648use crate::types::{CUDA_HOST_NODE_PARAMS, CUDA_KERNEL_NODE_PARAMS, CUDA_MEMSET_NODE_PARAMS};
649
650pub type PFN_cuGraphAddMemcpyNode = unsafe extern "C" fn(
651    graph_node: *mut crate::types::CUgraphNode,
652    graph: CUgraph,
653    dependencies: *const crate::types::CUgraphNode,
654    num_dependencies: usize,
655    copy_params: *const crate::types::CUDA_MEMCPY3D,
656    ctx: CUcontext,
657) -> CUresult;
658
659pub type PFN_cuGraphAddHostNode = unsafe extern "C" fn(
660    graph_node: *mut crate::types::CUgraphNode,
661    graph: CUgraph,
662    dependencies: *const crate::types::CUgraphNode,
663    num_dependencies: usize,
664    node_params: *const CUDA_HOST_NODE_PARAMS,
665) -> CUresult;
666
667pub type PFN_cuGraphAddChildGraphNode = unsafe extern "C" fn(
668    graph_node: *mut crate::types::CUgraphNode,
669    graph: CUgraph,
670    dependencies: *const crate::types::CUgraphNode,
671    num_dependencies: usize,
672    child_graph: CUgraph,
673) -> CUresult;
674
675pub type PFN_cuGraphAddEventRecordNode = unsafe extern "C" fn(
676    graph_node: *mut crate::types::CUgraphNode,
677    graph: CUgraph,
678    dependencies: *const crate::types::CUgraphNode,
679    num_dependencies: usize,
680    event: CUevent,
681) -> CUresult;
682
683pub type PFN_cuGraphAddEventWaitNode = unsafe extern "C" fn(
684    graph_node: *mut crate::types::CUgraphNode,
685    graph: CUgraph,
686    dependencies: *const crate::types::CUgraphNode,
687    num_dependencies: usize,
688    event: CUevent,
689) -> CUresult;
690
691pub type PFN_cuGraphAddExternalSemaphoresSignalNode = unsafe extern "C" fn(
692    graph_node: *mut crate::types::CUgraphNode,
693    graph: CUgraph,
694    dependencies: *const crate::types::CUgraphNode,
695    num_dependencies: usize,
696    node_params: *const c_void,
697) -> CUresult;
698
699pub type PFN_cuGraphAddExternalSemaphoresWaitNode = unsafe extern "C" fn(
700    graph_node: *mut crate::types::CUgraphNode,
701    graph: CUgraph,
702    dependencies: *const crate::types::CUgraphNode,
703    num_dependencies: usize,
704    node_params: *const c_void,
705) -> CUresult;
706
707pub type PFN_cuGraphKernelNodeGetParams = unsafe extern "C" fn(
708    node: crate::types::CUgraphNode,
709    params: *mut CUDA_KERNEL_NODE_PARAMS,
710) -> CUresult;
711
712pub type PFN_cuGraphKernelNodeSetParams = unsafe extern "C" fn(
713    node: crate::types::CUgraphNode,
714    params: *const CUDA_KERNEL_NODE_PARAMS,
715) -> CUresult;
716
717pub type PFN_cuGraphMemcpyNodeGetParams = unsafe extern "C" fn(
718    node: crate::types::CUgraphNode,
719    params: *mut crate::types::CUDA_MEMCPY3D,
720) -> CUresult;
721
722pub type PFN_cuGraphMemcpyNodeSetParams = unsafe extern "C" fn(
723    node: crate::types::CUgraphNode,
724    params: *const crate::types::CUDA_MEMCPY3D,
725) -> CUresult;
726
727pub type PFN_cuGraphMemsetNodeGetParams = unsafe extern "C" fn(
728    node: crate::types::CUgraphNode,
729    params: *mut CUDA_MEMSET_NODE_PARAMS,
730) -> CUresult;
731
732pub type PFN_cuGraphMemsetNodeSetParams = unsafe extern "C" fn(
733    node: crate::types::CUgraphNode,
734    params: *const CUDA_MEMSET_NODE_PARAMS,
735) -> CUresult;
736
737pub type PFN_cuGraphNodeGetType =
738    unsafe extern "C" fn(node: crate::types::CUgraphNode, type_: *mut c_int) -> CUresult;
739
740pub type PFN_cuGraphNodeGetDependencies = unsafe extern "C" fn(
741    node: crate::types::CUgraphNode,
742    dependencies: *mut crate::types::CUgraphNode,
743    num_dependencies: *mut usize,
744) -> CUresult;
745
746pub type PFN_cuGraphNodeGetDependentNodes = unsafe extern "C" fn(
747    node: crate::types::CUgraphNode,
748    dependent_nodes: *mut crate::types::CUgraphNode,
749    num_dependent_nodes: *mut usize,
750) -> CUresult;
751
752pub type PFN_cuGraphGetEdges = unsafe extern "C" fn(
753    graph: CUgraph,
754    from: *mut crate::types::CUgraphNode,
755    to: *mut crate::types::CUgraphNode,
756    num_edges: *mut usize,
757) -> CUresult;
758
759pub type PFN_cuGraphAddDependencies = unsafe extern "C" fn(
760    graph: CUgraph,
761    from: *const crate::types::CUgraphNode,
762    to: *const crate::types::CUgraphNode,
763    num_dependencies: usize,
764) -> CUresult;
765
766pub type PFN_cuGraphRemoveDependencies = unsafe extern "C" fn(
767    graph: CUgraph,
768    from: *const crate::types::CUgraphNode,
769    to: *const crate::types::CUgraphNode,
770    num_dependencies: usize,
771) -> CUresult;
772
773pub type PFN_cuGraphExecKernelNodeSetParams = unsafe extern "C" fn(
774    graph_exec: CUgraphExec,
775    node: crate::types::CUgraphNode,
776    params: *const CUDA_KERNEL_NODE_PARAMS,
777) -> CUresult;
778
779pub type PFN_cuGraphExecMemcpyNodeSetParams = unsafe extern "C" fn(
780    graph_exec: CUgraphExec,
781    node: crate::types::CUgraphNode,
782    params: *const crate::types::CUDA_MEMCPY3D,
783    ctx: CUcontext,
784) -> CUresult;
785
786pub type PFN_cuGraphExecMemsetNodeSetParams = unsafe extern "C" fn(
787    graph_exec: CUgraphExec,
788    node: crate::types::CUgraphNode,
789    params: *const CUDA_MEMSET_NODE_PARAMS,
790    ctx: CUcontext,
791) -> CUresult;
792
793pub type PFN_cuGraphExecHostNodeSetParams = unsafe extern "C" fn(
794    graph_exec: CUgraphExec,
795    node: crate::types::CUgraphNode,
796    params: *const CUDA_HOST_NODE_PARAMS,
797) -> CUresult;
798
799// ---- Wave 13: stream extras ---------------------------------------------
800
801pub type PFN_cuStreamGetId =
802    unsafe extern "C" fn(stream: CUstream, stream_id: *mut u64) -> CUresult;
803
804pub type PFN_cuStreamCopyAttributes =
805    unsafe extern "C" fn(dst: CUstream, src: CUstream) -> CUresult;
806
807/// `CUstreamAttrValue` is a union up to 48 bytes (access-policy window is
808/// the largest member). Treat as opaque at this layer; the safe wrapper
809/// exposes only the narrow cases that matter in practice.
810pub type PFN_cuStreamGetAttribute =
811    unsafe extern "C" fn(stream: CUstream, attr: c_int, value_out: *mut c_void) -> CUresult;
812
813pub type PFN_cuStreamSetAttribute =
814    unsafe extern "C" fn(stream: CUstream, attr: c_int, value: *const c_void) -> CUresult;
815
816pub type PFN_cuStreamAttachMemAsync = unsafe extern "C" fn(
817    stream: CUstream,
818    dptr: CUdeviceptr,
819    length: usize,
820    flags: c_uint,
821) -> CUresult;
822
823pub type PFN_cuStreamGetCaptureInfo = unsafe extern "C" fn(
824    stream: CUstream,
825    capture_status: *mut c_int,
826    id: *mut u64,
827    graph: *mut CUgraph,
828    dependencies: *mut *const crate::types::CUgraphNode,
829    num_dependencies: *mut usize,
830) -> CUresult;
831
832pub type PFN_cuStreamUpdateCaptureDependencies = unsafe extern "C" fn(
833    stream: CUstream,
834    dependencies: *mut crate::types::CUgraphNode,
835    num_dependencies: usize,
836    flags: c_uint,
837) -> CUresult;
838
839// ---- Wave 14: misc memcpy variants --------------------------------------
840
841pub type PFN_cuMemcpyDtoDAsync = unsafe extern "C" fn(
842    dst: CUdeviceptr,
843    src: CUdeviceptr,
844    bytes: usize,
845    stream: CUstream,
846) -> CUresult;
847
848pub type PFN_cuMemcpyPeer = unsafe extern "C" fn(
849    dst: CUdeviceptr,
850    dst_ctx: CUcontext,
851    src: CUdeviceptr,
852    src_ctx: CUcontext,
853    bytes: usize,
854) -> CUresult;
855
856pub type PFN_cuMemcpyPeerAsync = unsafe extern "C" fn(
857    dst: CUdeviceptr,
858    dst_ctx: CUcontext,
859    src: CUdeviceptr,
860    src_ctx: CUcontext,
861    bytes: usize,
862    stream: CUstream,
863) -> CUresult;
864
865pub type PFN_cuMemcpy =
866    unsafe extern "C" fn(dst: CUdeviceptr, src: CUdeviceptr, bytes: usize) -> CUresult;
867
868pub type PFN_cuMemcpyAsync = unsafe extern "C" fn(
869    dst: CUdeviceptr,
870    src: CUdeviceptr,
871    bytes: usize,
872    stream: CUstream,
873) -> CUresult;
874
875// Array 1-D copies (the index / offset is into the array's linear byte space).
876pub type PFN_cuMemcpyAtoH = unsafe extern "C" fn(
877    dst_host: *mut c_void,
878    src_array: crate::types::CUarray,
879    src_offset: usize,
880    bytes: usize,
881) -> CUresult;
882
883pub type PFN_cuMemcpyHtoA = unsafe extern "C" fn(
884    dst_array: crate::types::CUarray,
885    dst_offset: usize,
886    src_host: *const c_void,
887    bytes: usize,
888) -> CUresult;
889
890pub type PFN_cuMemcpyAtoD = unsafe extern "C" fn(
891    dst_device: CUdeviceptr,
892    src_array: crate::types::CUarray,
893    src_offset: usize,
894    bytes: usize,
895) -> CUresult;
896
897pub type PFN_cuMemcpyDtoA = unsafe extern "C" fn(
898    dst_array: crate::types::CUarray,
899    dst_offset: usize,
900    src_device: CUdeviceptr,
901    bytes: usize,
902) -> CUresult;
903
904pub type PFN_cuMemcpyAtoA = unsafe extern "C" fn(
905    dst_array: crate::types::CUarray,
906    dst_offset: usize,
907    src_array: crate::types::CUarray,
908    src_offset: usize,
909    bytes: usize,
910) -> CUresult;
911
912pub type PFN_cuMemsetD16 =
913    unsafe extern "C" fn(dst: CUdeviceptr, value: u16, count: usize) -> CUresult;
914
915pub type PFN_cuMemsetD8Async =
916    unsafe extern "C" fn(dst: CUdeviceptr, value: u8, count: usize, stream: CUstream) -> CUresult;
917
918pub type PFN_cuMemsetD16Async =
919    unsafe extern "C" fn(dst: CUdeviceptr, value: u16, count: usize, stream: CUstream) -> CUresult;
920
921pub type PFN_cuMemsetD32Async =
922    unsafe extern "C" fn(dst: CUdeviceptr, value: u32, count: usize, stream: CUstream) -> CUresult;
923
924pub type PFN_cuMemsetD2D8 = unsafe extern "C" fn(
925    dst: CUdeviceptr,
926    pitch: usize,
927    value: u8,
928    width: usize,
929    height: usize,
930) -> CUresult;
931
932pub type PFN_cuMemsetD2D16 = unsafe extern "C" fn(
933    dst: CUdeviceptr,
934    pitch: usize,
935    value: u16,
936    width: usize,
937    height: usize,
938) -> CUresult;
939
940pub type PFN_cuMemsetD2D32 = unsafe extern "C" fn(
941    dst: CUdeviceptr,
942    pitch: usize,
943    value: u32,
944    width: usize,
945    height: usize,
946) -> CUresult;
947
948// ---- Wave 15: range + pointer attrs batch -------------------------------
949
950pub type PFN_cuMemRangeGetAttribute = unsafe extern "C" fn(
951    data: *mut c_void,
952    data_size: usize,
953    attribute: c_int,
954    devptr: CUdeviceptr,
955    count: usize,
956) -> CUresult;
957
958pub type PFN_cuMemRangeGetAttributes = unsafe extern "C" fn(
959    data: *mut *mut c_void,
960    data_sizes: *mut usize,
961    attributes: *mut c_int,
962    num_attributes: usize,
963    devptr: CUdeviceptr,
964    count: usize,
965) -> CUresult;
966
967pub type PFN_cuPointerGetAttributes = unsafe extern "C" fn(
968    num_attributes: c_uint,
969    attributes: *mut c_int,
970    data: *mut *mut c_void,
971    ptr: CUdeviceptr,
972) -> CUresult;
973
974pub type PFN_cuPointerSetAttribute =
975    unsafe extern "C" fn(value: *const c_void, attribute: c_int, ptr: CUdeviceptr) -> CUresult;
976
977// ---- Wave 16: tensor maps (Hopper TMA) ----------------------------------
978
979use crate::types::CUtensorMap;
980
981pub type PFN_cuTensorMapEncodeTiled = unsafe extern "C" fn(
982    tensor_map: *mut CUtensorMap,
983    tensor_data_type: c_int,
984    tensor_rank: c_uint,
985    global_address: *mut c_void,
986    global_dim: *const u64,
987    global_strides: *const u64,
988    box_dim: *const u32,
989    element_strides: *const u32,
990    interleave: c_int,
991    swizzle: c_int,
992    l2_promotion: c_int,
993    oob_fill: c_int,
994) -> CUresult;
995
996pub type PFN_cuTensorMapEncodeIm2col = unsafe extern "C" fn(
997    tensor_map: *mut CUtensorMap,
998    tensor_data_type: c_int,
999    tensor_rank: c_uint,
1000    global_address: *mut c_void,
1001    global_dim: *const u64,
1002    global_strides: *const u64,
1003    pixel_box_lower_corner: *const c_int,
1004    pixel_box_upper_corner: *const c_int,
1005    channels_per_pixel: c_uint,
1006    pixels_per_column: c_uint,
1007    element_strides: *const u32,
1008    interleave: c_int,
1009    swizzle: c_int,
1010    l2_promotion: c_int,
1011    oob_fill: c_int,
1012) -> CUresult;
1013
1014pub type PFN_cuTensorMapReplaceAddress =
1015    unsafe extern "C" fn(tensor_map: *mut CUtensorMap, global_address: *mut c_void) -> CUresult;
1016
1017// ---- Wave 17: green contexts (CUDA 12.4+) -------------------------------
1018
1019use crate::types::{CUdevResource, CUdevResourceDesc, CUgreenCtx};
1020
1021pub type PFN_cuDeviceGetDevResource =
1022    unsafe extern "C" fn(device: CUdevice, resource: *mut CUdevResource, type_: c_int) -> CUresult;
1023
1024pub type PFN_cuDevSmResourceSplitByCount = unsafe extern "C" fn(
1025    result: *mut CUdevResource,
1026    nb_groups: *mut c_uint,
1027    input: *const CUdevResource,
1028    remaining: *mut CUdevResource,
1029    use_flags: c_uint,
1030    min_count: c_uint,
1031) -> CUresult;
1032
1033pub type PFN_cuDevResourceGenerateDesc = unsafe extern "C" fn(
1034    desc_out: *mut CUdevResourceDesc,
1035    resources: *mut CUdevResource,
1036    nb_resources: c_uint,
1037) -> CUresult;
1038
1039pub type PFN_cuGreenCtxCreate = unsafe extern "C" fn(
1040    green_ctx: *mut CUgreenCtx,
1041    desc: CUdevResourceDesc,
1042    dev: CUdevice,
1043    flags: c_uint,
1044) -> CUresult;
1045
1046pub type PFN_cuGreenCtxDestroy = unsafe extern "C" fn(green_ctx: CUgreenCtx) -> CUresult;
1047
1048pub type PFN_cuCtxFromGreenCtx =
1049    unsafe extern "C" fn(out_ctx: *mut CUcontext, green_ctx: CUgreenCtx) -> CUresult;
1050
1051pub type PFN_cuGreenCtxGetDevResource = unsafe extern "C" fn(
1052    green_ctx: CUgreenCtx,
1053    resource: *mut CUdevResource,
1054    type_: c_int,
1055) -> CUresult;
1056
1057pub type PFN_cuGreenCtxStreamCreate = unsafe extern "C" fn(
1058    stream_out: *mut CUstream,
1059    green_ctx: CUgreenCtx,
1060    flags: c_uint,
1061    priority: c_int,
1062) -> CUresult;
1063
1064// ---- Wave 18: multicast objects -----------------------------------------
1065
1066use crate::types::CUmulticastObjectProp;
1067
1068pub type PFN_cuMulticastCreate = unsafe extern "C" fn(
1069    mc_handle: *mut CUmemGenericAllocationHandle,
1070    prop: *const CUmulticastObjectProp,
1071) -> CUresult;
1072
1073pub type PFN_cuMulticastAddDevice =
1074    unsafe extern "C" fn(mc_handle: CUmemGenericAllocationHandle, dev: CUdevice) -> CUresult;
1075
1076pub type PFN_cuMulticastBindMem = unsafe extern "C" fn(
1077    mc_handle: CUmemGenericAllocationHandle,
1078    mc_offset: usize,
1079    mem_handle: CUmemGenericAllocationHandle,
1080    mem_offset: usize,
1081    size: usize,
1082    flags: u64,
1083) -> CUresult;
1084
1085pub type PFN_cuMulticastBindAddr = unsafe extern "C" fn(
1086    mc_handle: CUmemGenericAllocationHandle,
1087    mc_offset: usize,
1088    memptr: CUdeviceptr,
1089    size: usize,
1090    flags: u64,
1091) -> CUresult;
1092
1093pub type PFN_cuMulticastUnbind = unsafe extern "C" fn(
1094    mc_handle: CUmemGenericAllocationHandle,
1095    dev: CUdevice,
1096    mc_offset: usize,
1097    size: usize,
1098) -> CUresult;
1099
1100pub type PFN_cuMulticastGetGranularity = unsafe extern "C" fn(
1101    granularity: *mut usize,
1102    prop: *const CUmulticastObjectProp,
1103    option: c_int,
1104) -> CUresult;
1105
1106// ---- Wave 19: conditional + switch graph nodes --------------------------
1107
1108use crate::types::{CUgraphConditionalHandle, CUgraphEdgeData, CUgraphNodeParams};
1109
1110pub type PFN_cuGraphAddNode = unsafe extern "C" fn(
1111    graph_node: *mut crate::types::CUgraphNode,
1112    graph: CUgraph,
1113    dependencies: *const crate::types::CUgraphNode,
1114    dependency_data: *const CUgraphEdgeData,
1115    num_dependencies: usize,
1116    node_params: *mut CUgraphNodeParams,
1117) -> CUresult;
1118
1119pub type PFN_cuGraphNodeSetParams = unsafe extern "C" fn(
1120    node: crate::types::CUgraphNode,
1121    node_params: *mut CUgraphNodeParams,
1122) -> CUresult;
1123
1124pub type PFN_cuGraphConditionalHandleCreate = unsafe extern "C" fn(
1125    handle_out: *mut CUgraphConditionalHandle,
1126    graph: CUgraph,
1127    ctx: CUcontext,
1128    default_launch_value: c_uint,
1129    flags: c_uint,
1130) -> CUresult;
1131
1132// ---- Wave 20: IPC -------------------------------------------------------
1133
1134use crate::types::{CUipcEventHandle, CUipcMemHandle};
1135
1136pub type PFN_cuIpcGetEventHandle =
1137    unsafe extern "C" fn(handle_out: *mut CUipcEventHandle, event: CUevent) -> CUresult;
1138
1139pub type PFN_cuIpcOpenEventHandle =
1140    unsafe extern "C" fn(event_out: *mut CUevent, handle: CUipcEventHandle) -> CUresult;
1141
1142pub type PFN_cuIpcGetMemHandle =
1143    unsafe extern "C" fn(handle_out: *mut CUipcMemHandle, dptr: CUdeviceptr) -> CUresult;
1144
1145pub type PFN_cuIpcOpenMemHandle = unsafe extern "C" fn(
1146    dptr_out: *mut CUdeviceptr,
1147    handle: CUipcMemHandle,
1148    flags: c_uint,
1149) -> CUresult;
1150
1151pub type PFN_cuIpcCloseMemHandle = unsafe extern "C" fn(dptr: CUdeviceptr) -> CUresult;
1152
1153// ---- Wave 21: kernel attrs extension (CUDA 12+) -------------------------
1154
1155pub type PFN_cuKernelGetAttribute =
1156    unsafe extern "C" fn(pi: *mut c_int, attr: c_int, kernel: CUkernel, dev: CUdevice) -> CUresult;
1157
1158pub type PFN_cuKernelSetAttribute =
1159    unsafe extern "C" fn(attr: c_int, val: c_int, kernel: CUkernel, dev: CUdevice) -> CUresult;
1160
1161pub type PFN_cuKernelGetName =
1162    unsafe extern "C" fn(name: *mut *const c_char, kernel: CUkernel) -> CUresult;
1163
1164pub type PFN_cuKernelSetCacheConfig =
1165    unsafe extern "C" fn(kernel: CUkernel, config: c_int, dev: CUdevice) -> CUresult;
1166
1167pub type PFN_cuKernelGetLibrary =
1168    unsafe extern "C" fn(library_out: *mut CUlibrary, kernel: CUkernel) -> CUresult;
1169
1170pub type PFN_cuKernelGetParamInfo = unsafe extern "C" fn(
1171    kernel: CUkernel,
1172    param_index: usize,
1173    param_offset: *mut usize,
1174    param_size: *mut usize,
1175) -> CUresult;
1176
1177// ---- Wave 22: user objects ----------------------------------------------
1178
1179use crate::types::CUuserObject;
1180
1181pub type PFN_cuUserObjectCreate = unsafe extern "C" fn(
1182    object_out: *mut CUuserObject,
1183    ptr: *mut c_void,
1184    destroy: CUhostFn,
1185    initial_refcount: c_uint,
1186    flags: c_uint,
1187) -> CUresult;
1188
1189pub type PFN_cuUserObjectRetain =
1190    unsafe extern "C" fn(object: CUuserObject, count: c_uint) -> CUresult;
1191
1192pub type PFN_cuUserObjectRelease =
1193    unsafe extern "C" fn(object: CUuserObject, count: c_uint) -> CUresult;
1194
1195pub type PFN_cuGraphRetainUserObject = unsafe extern "C" fn(
1196    graph: CUgraph,
1197    object: CUuserObject,
1198    count: c_uint,
1199    flags: c_uint,
1200) -> CUresult;
1201
1202pub type PFN_cuGraphReleaseUserObject =
1203    unsafe extern "C" fn(graph: CUgraph, object: CUuserObject, count: c_uint) -> CUresult;
1204
1205// ---- Wave 23: misc extras -----------------------------------------------
1206
1207use crate::types::{CUlogIterator, CUlogsCallback, CUlogsCallbackHandle};
1208
1209pub type PFN_cuProfilerStart = unsafe extern "C" fn() -> CUresult;
1210pub type PFN_cuProfilerStop = unsafe extern "C" fn() -> CUresult;
1211
1212pub type PFN_cuFuncGetModule =
1213    unsafe extern "C" fn(module_out: *mut CUmodule, func: CUfunction) -> CUresult;
1214
1215pub type PFN_cuFuncGetName =
1216    unsafe extern "C" fn(name: *mut *const c_char, func: CUfunction) -> CUresult;
1217
1218pub type PFN_cuFuncGetParamInfo = unsafe extern "C" fn(
1219    func: CUfunction,
1220    param_index: usize,
1221    param_offset: *mut usize,
1222    param_size: *mut usize,
1223) -> CUresult;
1224
1225pub type PFN_cuGraphDebugDotPrint =
1226    unsafe extern "C" fn(graph: CUgraph, path: *const c_char, flags: c_uint) -> CUresult;
1227
1228pub type PFN_cuCtxGetId = unsafe extern "C" fn(ctx: CUcontext, ctx_id: *mut u64) -> CUresult;
1229
1230pub type PFN_cuModuleGetLoadingMode = unsafe extern "C" fn(mode: *mut c_int) -> CUresult;
1231
1232pub type PFN_cuDeviceGetUuid = unsafe extern "C" fn(uuid: *mut u8, dev: CUdevice) -> CUresult;
1233
1234pub type PFN_cuDeviceGetLuid = unsafe extern "C" fn(
1235    luid: *mut c_char,
1236    device_node_mask: *mut c_uint,
1237    dev: CUdevice,
1238) -> CUresult;
1239
1240pub type PFN_cuLogsRegisterCallback = unsafe extern "C" fn(
1241    callback: CUlogsCallback,
1242    user_data: *mut c_void,
1243    handle_out: *mut CUlogsCallbackHandle,
1244) -> CUresult;
1245
1246pub type PFN_cuLogsUnregisterCallback =
1247    unsafe extern "C" fn(handle: CUlogsCallbackHandle) -> CUresult;
1248
1249pub type PFN_cuLogsCurrent =
1250    unsafe extern "C" fn(iterator_out: *mut CUlogIterator, flags: c_uint) -> CUresult;
1251
1252pub type PFN_cuLogsDumpToFile = unsafe extern "C" fn(
1253    iterator: *mut CUlogIterator,
1254    path: *const c_char,
1255    flags: c_uint,
1256) -> CUresult;
1257
1258pub type PFN_cuLogsDumpToMemory = unsafe extern "C" fn(
1259    iterator: *mut CUlogIterator,
1260    buffer: *mut c_char,
1261    size: *mut usize,
1262    flags: c_uint,
1263) -> CUresult;
1264
1265// ---- Wave 24: graph memory nodes + graph-exec update --------------------
1266
1267use crate::types::{
1268    CUgraphExecUpdateResultInfo, CUDA_BATCH_MEM_OP_NODE_PARAMS, CUDA_MEM_ALLOC_NODE_PARAMS,
1269};
1270
1271pub type PFN_cuGraphAddMemAllocNode = unsafe extern "C" fn(
1272    graph_node: *mut crate::types::CUgraphNode,
1273    graph: CUgraph,
1274    dependencies: *const crate::types::CUgraphNode,
1275    num_dependencies: usize,
1276    node_params: *mut CUDA_MEM_ALLOC_NODE_PARAMS,
1277) -> CUresult;
1278
1279pub type PFN_cuGraphMemAllocNodeGetParams = unsafe extern "C" fn(
1280    node: crate::types::CUgraphNode,
1281    params_out: *mut CUDA_MEM_ALLOC_NODE_PARAMS,
1282) -> CUresult;
1283
1284pub type PFN_cuGraphAddMemFreeNode = unsafe extern "C" fn(
1285    graph_node: *mut crate::types::CUgraphNode,
1286    graph: CUgraph,
1287    dependencies: *const crate::types::CUgraphNode,
1288    num_dependencies: usize,
1289    dptr: CUdeviceptr,
1290) -> CUresult;
1291
1292pub type PFN_cuGraphMemFreeNodeGetParams =
1293    unsafe extern "C" fn(node: crate::types::CUgraphNode, dptr_out: *mut CUdeviceptr) -> CUresult;
1294
1295pub type PFN_cuDeviceGraphMemTrim = unsafe extern "C" fn(dev: CUdevice) -> CUresult;
1296
1297pub type PFN_cuDeviceGetGraphMemAttribute =
1298    unsafe extern "C" fn(dev: CUdevice, attr: c_int, value: *mut c_void) -> CUresult;
1299
1300pub type PFN_cuDeviceSetGraphMemAttribute =
1301    unsafe extern "C" fn(dev: CUdevice, attr: c_int, value: *mut c_void) -> CUresult;
1302
1303pub type PFN_cuGraphAddBatchMemOpNode = unsafe extern "C" fn(
1304    graph_node: *mut crate::types::CUgraphNode,
1305    graph: CUgraph,
1306    dependencies: *const crate::types::CUgraphNode,
1307    num_dependencies: usize,
1308    node_params: *const CUDA_BATCH_MEM_OP_NODE_PARAMS,
1309) -> CUresult;
1310
1311pub type PFN_cuGraphBatchMemOpNodeGetParams = unsafe extern "C" fn(
1312    node: crate::types::CUgraphNode,
1313    node_params_out: *mut CUDA_BATCH_MEM_OP_NODE_PARAMS,
1314) -> CUresult;
1315
1316pub type PFN_cuGraphBatchMemOpNodeSetParams = unsafe extern "C" fn(
1317    node: crate::types::CUgraphNode,
1318    node_params: *const CUDA_BATCH_MEM_OP_NODE_PARAMS,
1319) -> CUresult;
1320
1321pub type PFN_cuGraphExecBatchMemOpNodeSetParams = unsafe extern "C" fn(
1322    graph_exec: CUgraphExec,
1323    node: crate::types::CUgraphNode,
1324    node_params: *const CUDA_BATCH_MEM_OP_NODE_PARAMS,
1325) -> CUresult;
1326
1327pub type PFN_cuGraphExecUpdate = unsafe extern "C" fn(
1328    graph_exec: CUgraphExec,
1329    graph: CUgraph,
1330    result_info: *mut CUgraphExecUpdateResultInfo,
1331) -> CUresult;
1332
1333// ---- Wave 25: stream memory ops -----------------------------------------
1334
1335use crate::types::CUstreamBatchMemOpParams;
1336
1337pub type PFN_cuStreamWriteValue32 = unsafe extern "C" fn(
1338    stream: CUstream,
1339    addr: CUdeviceptr,
1340    value: u32,
1341    flags: c_uint,
1342) -> CUresult;
1343
1344pub type PFN_cuStreamWriteValue64 = unsafe extern "C" fn(
1345    stream: CUstream,
1346    addr: CUdeviceptr,
1347    value: u64,
1348    flags: c_uint,
1349) -> CUresult;
1350
1351pub type PFN_cuStreamWaitValue32 = unsafe extern "C" fn(
1352    stream: CUstream,
1353    addr: CUdeviceptr,
1354    value: u32,
1355    flags: c_uint,
1356) -> CUresult;
1357
1358pub type PFN_cuStreamWaitValue64 = unsafe extern "C" fn(
1359    stream: CUstream,
1360    addr: CUdeviceptr,
1361    value: u64,
1362    flags: c_uint,
1363) -> CUresult;
1364
1365pub type PFN_cuStreamBatchMemOp = unsafe extern "C" fn(
1366    stream: CUstream,
1367    count: c_uint,
1368    param_array: *mut CUstreamBatchMemOpParams,
1369    flags: c_uint,
1370) -> CUresult;
1371
1372// ---- Wave 27: v2 advise/prefetch + VMM reverse lookups ------------------
1373
1374use crate::types::CUmemLocation;
1375
1376/// `cuMemPrefetchAsync_v2` — takes a [`CUmemLocation`] (so you can
1377/// prefetch to any host / NUMA / device destination with one entry point).
1378pub type PFN_cuMemPrefetchAsyncV2 = unsafe extern "C" fn(
1379    dev_ptr: CUdeviceptr,
1380    count: usize,
1381    location: CUmemLocation,
1382    flags: c_uint,
1383    stream: CUstream,
1384) -> CUresult;
1385
1386pub type PFN_cuMemAdviseV2 = unsafe extern "C" fn(
1387    dev_ptr: CUdeviceptr,
1388    count: usize,
1389    advice: c_int,
1390    location: CUmemLocation,
1391) -> CUresult;
1392
1393/// `cuMemMapArrayAsync` — bulk map / unmap sparse tiles of arrays or
1394/// mipmapped arrays into VMM-backed allocations, ordered on `stream`.
1395/// See [`crate::types::CUarrayMapInfo`] for the entry shape.
1396pub type PFN_cuMemMapArrayAsync = unsafe extern "C" fn(
1397    map_info_list: *mut crate::types::CUarrayMapInfo,
1398    count: c_uint,
1399    stream: CUstream,
1400) -> CUresult;
1401
1402pub type PFN_cuMemGetHandleForAddressRange = unsafe extern "C" fn(
1403    handle: *mut c_void,
1404    dptr: CUdeviceptr,
1405    size: usize,
1406    handle_type: c_int,
1407    flags: u64,
1408) -> CUresult;
1409
1410pub type PFN_cuMemRetainAllocationHandle =
1411    unsafe extern "C" fn(handle: *mut CUmemGenericAllocationHandle, addr: *mut c_void) -> CUresult;
1412
1413pub type PFN_cuMemGetAllocationPropertiesFromHandle = unsafe extern "C" fn(
1414    prop: *mut CUmemAllocationProp,
1415    handle: CUmemGenericAllocationHandle,
1416) -> CUresult;
1417
1418pub type PFN_cuMemExportToShareableHandle = unsafe extern "C" fn(
1419    shareable_handle: *mut c_void,
1420    handle: CUmemGenericAllocationHandle,
1421    handle_type: c_int,
1422    flags: u64,
1423) -> CUresult;
1424
1425pub type PFN_cuMemImportFromShareableHandle = unsafe extern "C" fn(
1426    handle: *mut CUmemGenericAllocationHandle,
1427    os_handle: *mut c_void,
1428    sh_handle_type: c_int,
1429) -> CUresult;
1430
1431pub type PFN_cuMemGetAccess = unsafe extern "C" fn(
1432    flags: *mut u64,
1433    location: *const CUmemLocation,
1434    ptr: CUdeviceptr,
1435) -> CUresult;
1436
1437// ---- Wave 28: medium-value consolidated ---------------------------------
1438
1439use crate::types::{CUDA_ARRAY_MEMORY_REQUIREMENTS, CUDA_ARRAY_SPARSE_PROPERTIES};
1440
1441// Array introspection
1442pub type PFN_cuArrayGetDescriptor = unsafe extern "C" fn(
1443    desc: *mut crate::types::CUDA_ARRAY_DESCRIPTOR,
1444    array: crate::types::CUarray,
1445) -> CUresult;
1446
1447pub type PFN_cuArrayGetSparseProperties = unsafe extern "C" fn(
1448    sparse_properties: *mut CUDA_ARRAY_SPARSE_PROPERTIES,
1449    array: crate::types::CUarray,
1450) -> CUresult;
1451
1452pub type PFN_cuMipmappedArrayGetSparseProperties = unsafe extern "C" fn(
1453    sparse_properties: *mut CUDA_ARRAY_SPARSE_PROPERTIES,
1454    mipmap: crate::types::CUmipmappedArray,
1455) -> CUresult;
1456
1457pub type PFN_cuArrayGetMemoryRequirements = unsafe extern "C" fn(
1458    mem_requirements: *mut CUDA_ARRAY_MEMORY_REQUIREMENTS,
1459    array: crate::types::CUarray,
1460    device: CUdevice,
1461) -> CUresult;
1462
1463pub type PFN_cuMipmappedArrayGetMemoryRequirements = unsafe extern "C" fn(
1464    mem_requirements: *mut CUDA_ARRAY_MEMORY_REQUIREMENTS,
1465    mipmap: crate::types::CUmipmappedArray,
1466    device: CUdevice,
1467) -> CUresult;
1468
1469pub type PFN_cuArrayGetPlane = unsafe extern "C" fn(
1470    plane_array_out: *mut crate::types::CUarray,
1471    array: crate::types::CUarray,
1472    plane_idx: c_uint,
1473) -> CUresult;
1474
1475// Context-level events
1476pub type PFN_cuCtxRecordEvent = unsafe extern "C" fn(ctx: CUcontext, event: CUevent) -> CUresult;
1477pub type PFN_cuCtxWaitEvent = unsafe extern "C" fn(ctx: CUcontext, event: CUevent) -> CUresult;
1478
1479// P2P + exec affinity
1480pub type PFN_cuDeviceGetP2PAttribute = unsafe extern "C" fn(
1481    value: *mut c_int,
1482    attr: c_int,
1483    src_device: CUdevice,
1484    dst_device: CUdevice,
1485) -> CUresult;
1486
1487pub type PFN_cuDeviceGetExecAffinitySupport =
1488    unsafe extern "C" fn(pi: *mut c_int, type_: c_int, dev: CUdevice) -> CUresult;
1489
1490// RDMA flush
1491pub type PFN_cuFlushGPUDirectRDMAWrites =
1492    unsafe extern "C" fn(target: c_int, scope: c_int) -> CUresult;
1493
1494// Core dump
1495pub type PFN_cuCoredumpGetAttribute =
1496    unsafe extern "C" fn(attr: c_int, value: *mut c_void, size: *mut usize) -> CUresult;
1497
1498pub type PFN_cuCoredumpGetAttributeGlobal =
1499    unsafe extern "C" fn(attr: c_int, value: *mut c_void, size: *mut usize) -> CUresult;
1500
1501pub type PFN_cuCoredumpSetAttribute =
1502    unsafe extern "C" fn(attr: c_int, value: *mut c_void, size: *mut usize) -> CUresult;
1503
1504pub type PFN_cuCoredumpSetAttributeGlobal =
1505    unsafe extern "C" fn(attr: c_int, value: *mut c_void, size: *mut usize) -> CUresult;
1506
1507// Library extras
1508pub type PFN_cuLibraryGetUnifiedFunction = unsafe extern "C" fn(
1509    fptr: *mut *mut c_void,
1510    library: CUlibrary,
1511    symbol: *const c_char,
1512) -> CUresult;
1513
1514pub type PFN_cuLibraryGetModule =
1515    unsafe extern "C" fn(module_out: *mut CUmodule, library: CUlibrary) -> CUresult;
1516
1517pub type PFN_cuLibraryGetKernelCount =
1518    unsafe extern "C" fn(count: *mut c_uint, lib: CUlibrary) -> CUresult;
1519
1520pub type PFN_cuLibraryEnumerateKernels =
1521    unsafe extern "C" fn(kernels: *mut CUkernel, num_kernels: c_uint, lib: CUlibrary) -> CUresult;
1522
1523pub type PFN_cuLibraryGetManaged = unsafe extern "C" fn(
1524    dptr: *mut CUdeviceptr,
1525    bytes: *mut usize,
1526    library: CUlibrary,
1527    name: *const c_char,
1528) -> CUresult;
1529
1530// ---- Wave 29: graphics interop core + OpenGL ----------------------------
1531
1532use crate::types::{CUgraphicsResource, GLenum, GLuint};
1533
1534pub type PFN_cuGraphicsUnregisterResource =
1535    unsafe extern "C" fn(resource: CUgraphicsResource) -> CUresult;
1536
1537pub type PFN_cuGraphicsMapResources = unsafe extern "C" fn(
1538    count: c_uint,
1539    resources: *mut CUgraphicsResource,
1540    stream: CUstream,
1541) -> CUresult;
1542
1543pub type PFN_cuGraphicsUnmapResources = unsafe extern "C" fn(
1544    count: c_uint,
1545    resources: *mut CUgraphicsResource,
1546    stream: CUstream,
1547) -> CUresult;
1548
1549pub type PFN_cuGraphicsResourceGetMappedPointer = unsafe extern "C" fn(
1550    dev_ptr: *mut CUdeviceptr,
1551    size: *mut usize,
1552    resource: CUgraphicsResource,
1553) -> CUresult;
1554
1555pub type PFN_cuGraphicsResourceGetMappedMipmappedArray = unsafe extern "C" fn(
1556    mipmap_array: *mut crate::types::CUmipmappedArray,
1557    resource: CUgraphicsResource,
1558) -> CUresult;
1559
1560pub type PFN_cuGraphicsSubResourceGetMappedArray = unsafe extern "C" fn(
1561    array: *mut crate::types::CUarray,
1562    resource: CUgraphicsResource,
1563    array_index: c_uint,
1564    mip_level: c_uint,
1565) -> CUresult;
1566
1567pub type PFN_cuGraphicsResourceSetMapFlags =
1568    unsafe extern "C" fn(resource: CUgraphicsResource, flags: c_uint) -> CUresult;
1569
1570// OpenGL-specific
1571
1572pub type PFN_cuGLGetDevices = unsafe extern "C" fn(
1573    cuda_device_count: *mut c_uint,
1574    cuda_devices: *mut CUdevice,
1575    cuda_device_count_in: c_uint,
1576    device_list: c_uint,
1577) -> CUresult;
1578
1579pub type PFN_cuGraphicsGLRegisterBuffer = unsafe extern "C" fn(
1580    resource: *mut CUgraphicsResource,
1581    buffer: GLuint,
1582    flags: c_uint,
1583) -> CUresult;
1584
1585pub type PFN_cuGraphicsGLRegisterImage = unsafe extern "C" fn(
1586    resource: *mut CUgraphicsResource,
1587    image: GLuint,
1588    target: GLenum,
1589    flags: c_uint,
1590) -> CUresult;
1591
1592pub type PFN_cuGLCtxCreate =
1593    unsafe extern "C" fn(ctx: *mut CUcontext, flags: c_uint, device: CUdevice) -> CUresult;
1594
1595pub type PFN_cuGLInit = unsafe extern "C" fn() -> CUresult;
1596
1597// ---- Wave 30: Direct3D 9 / 10 / 11 interop -------------------------------
1598
1599use crate::types::{ID3DDevice, ID3DResource};
1600
1601// Per-API GetDevice / GetDevices / RegisterResource each share a shape.
1602// D3D9 uses `IDirect3DDevice9*`, D3D10 uses `ID3D10Device*`, D3D11 uses
1603// `ID3D11Device*` — all are opaque pointers.
1604
1605pub type PFN_cuD3D9GetDevice =
1606    unsafe extern "C" fn(cuda_device: *mut CUdevice, adapter_name: *const c_char) -> CUresult;
1607
1608pub type PFN_cuD3D9GetDevices = unsafe extern "C" fn(
1609    cuda_device_count: *mut c_uint,
1610    cuda_devices: *mut CUdevice,
1611    cuda_device_count_in: c_uint,
1612    d3d_device: ID3DDevice,
1613    device_list: c_uint,
1614) -> CUresult;
1615
1616pub type PFN_cuGraphicsD3D9RegisterResource = unsafe extern "C" fn(
1617    resource: *mut CUgraphicsResource,
1618    d3d_resource: ID3DResource,
1619    flags: c_uint,
1620) -> CUresult;
1621
1622pub type PFN_cuD3D10GetDevice =
1623    unsafe extern "C" fn(cuda_device: *mut CUdevice, adapter: ID3DDevice) -> CUresult;
1624
1625pub type PFN_cuD3D10GetDevices = unsafe extern "C" fn(
1626    cuda_device_count: *mut c_uint,
1627    cuda_devices: *mut CUdevice,
1628    cuda_device_count_in: c_uint,
1629    d3d_device: ID3DDevice,
1630    device_list: c_uint,
1631) -> CUresult;
1632
1633pub type PFN_cuGraphicsD3D10RegisterResource = unsafe extern "C" fn(
1634    resource: *mut CUgraphicsResource,
1635    d3d_resource: ID3DResource,
1636    flags: c_uint,
1637) -> CUresult;
1638
1639pub type PFN_cuD3D11GetDevice =
1640    unsafe extern "C" fn(cuda_device: *mut CUdevice, adapter: ID3DDevice) -> CUresult;
1641
1642pub type PFN_cuD3D11GetDevices = unsafe extern "C" fn(
1643    cuda_device_count: *mut c_uint,
1644    cuda_devices: *mut CUdevice,
1645    cuda_device_count_in: c_uint,
1646    d3d_device: ID3DDevice,
1647    device_list: c_uint,
1648) -> CUresult;
1649
1650pub type PFN_cuGraphicsD3D11RegisterResource = unsafe extern "C" fn(
1651    resource: *mut CUgraphicsResource,
1652    d3d_resource: ID3DResource,
1653    flags: c_uint,
1654) -> CUresult;
1655
1656// ---- Wave 31: VDPAU + EGL + NvSci (Jetson / automotive) -----------------
1657
1658use crate::types::{
1659    CUeglFrame, EGLImageKHR, EGLStreamKHR, EGLSyncKHR, NvSciSyncAttrList, VdpDevice,
1660    VdpGetProcAddress, VdpOutputSurface, VdpVideoSurface,
1661};
1662
1663// VDPAU
1664pub type PFN_cuVDPAUGetDevice = unsafe extern "C" fn(
1665    device: *mut CUdevice,
1666    vdp_device: VdpDevice,
1667    vdp_get_proc_address: VdpGetProcAddress,
1668) -> CUresult;
1669
1670pub type PFN_cuVDPAUCtxCreate = unsafe extern "C" fn(
1671    ctx: *mut CUcontext,
1672    flags: c_uint,
1673    device: CUdevice,
1674    vdp_device: VdpDevice,
1675    vdp_get_proc_address: VdpGetProcAddress,
1676) -> CUresult;
1677
1678pub type PFN_cuGraphicsVDPAURegisterVideoSurface = unsafe extern "C" fn(
1679    resource: *mut CUgraphicsResource,
1680    vdp_surface: VdpVideoSurface,
1681    flags: c_uint,
1682) -> CUresult;
1683
1684pub type PFN_cuGraphicsVDPAURegisterOutputSurface = unsafe extern "C" fn(
1685    resource: *mut CUgraphicsResource,
1686    vdp_surface: VdpOutputSurface,
1687    flags: c_uint,
1688) -> CUresult;
1689
1690// EGL
1691pub type PFN_cuGraphicsEGLRegisterImage = unsafe extern "C" fn(
1692    resource: *mut CUgraphicsResource,
1693    image: EGLImageKHR,
1694    flags: c_uint,
1695) -> CUresult;
1696
1697pub type PFN_cuGraphicsResourceGetMappedEglFrame = unsafe extern "C" fn(
1698    egl_frame: *mut CUeglFrame,
1699    resource: CUgraphicsResource,
1700    index: c_uint,
1701    mip_level: c_uint,
1702) -> CUresult;
1703
1704pub type PFN_cuEventCreateFromEGLSync =
1705    unsafe extern "C" fn(event_out: *mut CUevent, egl_sync: EGLSyncKHR, flags: c_uint) -> CUresult;
1706
1707pub type PFN_cuEGLStreamConsumerConnect =
1708    unsafe extern "C" fn(connection: *mut c_void, stream: EGLStreamKHR) -> CUresult;
1709
1710pub type PFN_cuEGLStreamConsumerDisconnect =
1711    unsafe extern "C" fn(connection: *mut c_void) -> CUresult;
1712
1713pub type PFN_cuEGLStreamConsumerAcquireFrame = unsafe extern "C" fn(
1714    connection: *mut c_void,
1715    resource: *mut CUgraphicsResource,
1716    stream: *mut CUstream,
1717    timeout: c_uint,
1718) -> CUresult;
1719
1720pub type PFN_cuEGLStreamConsumerReleaseFrame = unsafe extern "C" fn(
1721    connection: *mut c_void,
1722    resource: CUgraphicsResource,
1723    stream: *mut CUstream,
1724) -> CUresult;
1725
1726pub type PFN_cuEGLStreamProducerConnect = unsafe extern "C" fn(
1727    connection: *mut c_void,
1728    stream: EGLStreamKHR,
1729    width: core::ffi::c_int,
1730    height: core::ffi::c_int,
1731) -> CUresult;
1732
1733pub type PFN_cuEGLStreamProducerDisconnect =
1734    unsafe extern "C" fn(connection: *mut c_void) -> CUresult;
1735
1736pub type PFN_cuEGLStreamProducerPresentFrame = unsafe extern "C" fn(
1737    connection: *mut c_void,
1738    egl_frame: CUeglFrame,
1739    stream: *mut CUstream,
1740) -> CUresult;
1741
1742pub type PFN_cuEGLStreamProducerReturnFrame = unsafe extern "C" fn(
1743    connection: *mut c_void,
1744    egl_frame: *mut CUeglFrame,
1745    stream: *mut CUstream,
1746) -> CUresult;
1747
1748// NvSci (Jetson / DRIVE)
1749pub type PFN_cuDeviceGetNvSciSyncAttributes = unsafe extern "C" fn(
1750    nv_sci_sync_attr_list: NvSciSyncAttrList,
1751    dev: CUdevice,
1752    flags: c_int,
1753) -> CUresult;