1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//! Extended launch configuration types for `cuLaunchKernelEx` (CUDA 12.0+).
//!
//! Thread block cluster launch attributes, launch configuration, and related
//! types for the modern CUDA 12.x kernel launch API.
use CUstream;
// =========================================================================
// CuLaunchAttributeId — attribute discriminant
// =========================================================================
/// Attribute identifier for `CuLaunchAttribute`.
///
/// Controls which extended kernel launch feature is configured.
/// Used with `cuLaunchKernelEx` (CUDA 12.0+).
// =========================================================================
// CuLaunchAttributeClusterDim — cluster geometry
// =========================================================================
/// Cluster dimension for thread block clusters (sm_90+).
///
/// Specifies how many thread blocks form one cluster in each dimension.
/// Used inside [`CuLaunchAttributeValue`] when the attribute id is
/// [`CuLaunchAttributeId::ClusterDimension`].
// =========================================================================
// CuLaunchAttributeValue — attribute value union
// =========================================================================
/// Value union for `CuLaunchAttribute`.
///
/// # Safety
///
/// This is a C union — callers must only read the field that matches
/// the accompanying [`CuLaunchAttributeId`] discriminant.
/// Padding ensures the union is always 64 bytes, matching the CUDA ABI.
pub union CuLaunchAttributeValue
// Manual Clone/Copy for the union (derive cannot handle unions with non-Copy
// fields, but all union fields here are effectively POD).
// `Copy` is declared first so that the `Clone` impl can delegate to it.
// =========================================================================
// CuLaunchAttribute — single attribute entry
// =========================================================================
/// A single extended kernel launch attribute (id + value pair).
///
/// Used in the `attrs` array of [`CuLaunchConfig`].
// =========================================================================
// CuLaunchConfig — full launch configuration
// =========================================================================
/// Extended kernel launch configuration for `cuLaunchKernelEx` (CUDA 12.0+).
///
/// Supersedes the individual parameters of `cuLaunchKernel` and adds
/// support for thread block clusters, launch priorities, and other
/// CUDA 12.x features.
///
/// # Example
///
/// ```rust
/// use oxicuda_driver::ffi::{
/// CuLaunchConfig, CuLaunchAttribute, CuLaunchAttributeId,
/// CuLaunchAttributeValue, CuLaunchAttributeClusterDim, CUstream,
/// };
///
/// // Build a cluster-launch config for a 2×1×1 cluster.
/// let cluster_attr = CuLaunchAttribute {
/// id: CuLaunchAttributeId::ClusterDimension,
/// pad: [0u8; 4],
/// value: CuLaunchAttributeValue {
/// cluster_dim: CuLaunchAttributeClusterDim { x: 2, y: 1, z: 1 },
/// },
/// };
/// let _config = CuLaunchConfig {
/// grid_dim_x: 8,
/// grid_dim_y: 1,
/// grid_dim_z: 1,
/// block_dim_x: 256,
/// block_dim_y: 1,
/// block_dim_z: 1,
/// shared_mem_bytes: 0,
/// stream: CUstream::default(),
/// attrs: std::ptr::null(),
/// num_attrs: 0,
/// };
/// ```
// SAFETY: CuLaunchConfig is a plain data structure mirroring the CUDA ABI.
// The raw pointer `attrs` must be valid for the lifetime of the config, but
// the struct itself is Send + Sync because no interior mutation occurs.
unsafe
unsafe