singe_cutensor_sys/mg_20600.rs
1/* automatically generated by rust-bindgen 0.72.1 */
2
3#[repr(u32)]
4#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
5pub enum cutensorComputeType_t {
6 CUTENSOR_COMPUTE_16F = 1,
7 CUTENSOR_COMPUTE_16BF = 1024,
8 CUTENSOR_COMPUTE_TF32 = 4096,
9 CUTENSOR_COMPUTE_3XTF32 = 8192,
10 CUTENSOR_COMPUTE_32F = 4,
11 CUTENSOR_COMPUTE_64F = 16,
12 CUTENSOR_COMPUTE_8U = 64,
13 CUTENSOR_COMPUTE_8I = 256,
14 CUTENSOR_COMPUTE_32U = 128,
15 CUTENSOR_COMPUTE_32I = 512,
16}
17/// Enumerated device codes for host-side tensors.
18#[repr(i32)]
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 cutensorMgHostDevice_t {
32 /// The memory is located on the host in regular memory.
33 CUTENSOR_MG_DEVICE_HOST = -1,
34 /// The memory is located on the host in pinned memory.
35 CUTENSOR_MG_DEVICE_HOST_PINNED = -2,
36}
37#[repr(C)]
38#[derive(Debug, Copy, Clone)]
39pub struct cutensorMgHandle_s {
40 _unused: [u8; 0],
41}
42/// Encodes the devices that participate in operations.
43///
44/// The handle contains information about each device that participates in operations as well as host threads to orchestrate host-to-device operations.
45pub type cutensorMgHandle_t = *mut cutensorMgHandle_s;
46#[repr(C)]
47#[derive(Debug, Copy, Clone)]
48pub struct cutensorMgTensorDescriptor_s {
49 _unused: [u8; 0],
50}
51/// Represents a tensor that may be distributed.
52///
53/// The tensor is laid out in a block-cyclic fashion across devices. It may either be fully located on the host, or distributed across multiple devices.
54pub type cutensorMgTensorDescriptor_t = *mut cutensorMgTensorDescriptor_s;
55#[repr(C)]
56#[derive(Debug, Copy, Clone)]
57pub struct cutensorMgCopyDescriptor_s {
58 _unused: [u8; 0],
59}
60/// Describes the copy of a tensor from one data layout to another.
61///
62/// It may describe the full Cartesian product of copy from and to host, single device, and multiple devices, as well as permutations and layout changes.
63pub type cutensorMgCopyDescriptor_t = *mut cutensorMgCopyDescriptor_s;
64#[repr(C)]
65#[derive(Debug, Copy, Clone)]
66pub struct cutensorMgCopyPlan_s {
67 _unused: [u8; 0],
68}
69/// Describes a specific way to implement the copy operation.
70///
71/// It encodes blockings and other implementation details, and may be reused to reduce planning overhead.
72pub type cutensorMgCopyPlan_t = *mut cutensorMgCopyPlan_s;
73#[repr(C)]
74#[derive(Debug, Copy, Clone)]
75pub struct cutensorMgContractionDescriptor_s {
76 _unused: [u8; 0],
77}
78/// Describes the contraction of two tensors into a third tensor with an optional source.
79///
80/// Only supports device-side tensors.
81pub type cutensorMgContractionDescriptor_t = *mut cutensorMgContractionDescriptor_s;
82#[repr(C)]
83#[derive(Debug, Copy, Clone)]
84pub struct cutensorMgContractionFind_s {
85 _unused: [u8; 0],
86}
87/// Describes the algorithmic details of implementing a tensor contraction.
88pub type cutensorMgContractionFind_t = *mut cutensorMgContractionFind_s;
89#[repr(C)]
90#[derive(Debug, Copy, Clone)]
91pub struct cutensorMgContractionPlan_s {
92 _unused: [u8; 0],
93}
94/// Describes a specific way to implement a contraction operation.
95///
96/// It encodes blockings, permutations and other implementation details, and may be reused to reduce planning overhead.
97pub type cutensorMgContractionPlan_t = *mut cutensorMgContractionPlan_s;
98/// Represents the selected algorithm when planning for a contraction operation.
99#[repr(i32)]
100#[derive(
101 Debug,
102 Copy,
103 Clone,
104 Hash,
105 PartialOrd,
106 Ord,
107 PartialEq,
108 Eq,
109 TryFromPrimitive,
110 IntoPrimitive,
111)]
112pub enum cutensorMgAlgo_t {
113 /// Lets the internal heuristic choose.
114 CUTENSORMG_ALGO_DEFAULT = -1,
115}
116#[repr(u32)]
117#[derive(
118 Debug,
119 Copy,
120 Clone,
121 Hash,
122 PartialOrd,
123 Ord,
124 PartialEq,
125 Eq,
126 TryFromPrimitive,
127 IntoPrimitive,
128)]
129pub enum cutensorMgContractionFindAttribute_t {
130 CUTENSORMG_CONTRACTION_FIND_ATTRIBUTE_MAX = 65535,
131}
132unsafe extern "C" {
133 /// Create a library handle.
134 ///
135 /// The handle contains information about the devices that should be participating in calculations. All devices that hold any tensor data or participate in any of cuTENSORMg’s operations should also be included in the handle. Each device may only occur once in the list. It is advisable that all devices are identical (i.e., have the same peak performance) to avoid load-balancing issues, and are connected via NVLink to avoid costly device-host-device transfers. This call will enable peering between all devices that have been passed to it, if possible.
136 ///
137 /// Remark
138 ///
139 /// blocking, no reentrant, and thread-safe.
140 ///
141 /// # Parameters
142 ///
143 /// - `handle`: The resulting library handle.
144 /// - `numDevices`: The number of devices participating in all subsequent computations.
145 /// - `devices`: The devices that participate in all computations.
146 ///
147 /// # Return value
148 ///
149 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
150 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
151 pub fn cutensorMgCreate(
152 handle: *mut cutensorMgHandle_t,
153 numDevices: u32,
154 devices: *const i32,
155 ) -> cutensorStatus_t;
156}
157unsafe extern "C" {
158 /// Destroy a library handle.
159 ///
160 /// All outstanding operations must be completed before calling this function. Frees all associated resources. Any descriptors or plans created with the handle become invalid and may only be destructed.
161 ///
162 /// Remark
163 ///
164 /// blocking, no reentrant, and thread-safe.
165 ///
166 /// # Return value
167 ///
168 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
169 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
170 pub fn cutensorMgDestroy(handle: cutensorMgHandle_t) -> cutensorStatus_t;
171}
172unsafe extern "C" {
173 /// Create a tensor descriptor.
174 ///
175 /// A tensor descriptor fully specifies the data layout of a (potentially) distributed tensor. It does so mainly through five pieces of data: The extent, the element stride, the block size, the block stride, and the device count.
176 ///
177 /// The extent describes the total size of each tensor mode. For example, an 9 by 9 matrix would have an extent of 9 and 9.
178 ///
179 /// The block size describes how the data is blocked. For example, with a block size of 4 by 2, there would be three blocks in the first and five blocks in the second mode.
180 ///
181 /// | | | |
182 /// | --- | --- | --- |
183 /// | 4 x 2 | 4 x 2 | 1 x 2 |
184 /// | 4 x 2 | 4 x 2 | 1 x 2 |
185 /// | 4 x 2 | 4 x 2 | 1 x 2 |
186 /// | 4 x 2 | 4 x 2 | 1 x 2 |
187 /// | 4 x 1 | 4 x 1 | 1 x 1 |
188 ///
189 /// The device count then describes how many devices the blocks are distributed across in that mode. A device count of 2 by 2, for example, would mean that the blocks are distributed across two devices in each mode, i.e., four devices total. The devices are aranged first along the first and then the second mode as follows:
190 ///
191 /// | | |
192 /// | --- | --- |
193 /// | Dev. 0 | Dev. 2 |
194 /// | Dev. 1 | Dev. 3 |
195 ///
196 /// In particular, device 0 would own the first, and third block in the first dimension, the first, third, and fifth block in the second dimension (so a total of six blocks), device 1 would own the first and third block in the first dimension, and the second and fourth block in the second dimension (four blocks total), device 2 would own the second block in the first dimension, and the first, third, and fifth block in the second dimension (for a total of three blocks), and, finally, device 3 would own the second block in the first dimension and the second and fourth block in the second dimension (for a total of two blocks).
197 ///
198 /// | | | |
199 /// | --- | --- | --- |
200 /// | Dev. 0 | Dev. 2 | Dev. 0 |
201 /// | Dev. 1 | Dev. 3 | Dev. 1 |
202 /// | Dev. 0 | Dev. 2 | Dev. 0 |
203 /// | Dev. 1 | Dev. 3 | Dev. 1 |
204 /// | Dev. 0 | Dev. 2 | Dev. 0 |
205 ///
206 /// The element stride and block stride then describe how the blocks are laid out on the individual devices, i.e. the distance between elements and blocks in that mode. Finally, the devices array describes which device the blocks are mapped to. Here, it is permissible to specify [`cutensorMgHostDevice_t::CUTENSOR_MG_DEVICE_HOST`] to express that those blocks are located on the host. A tensor must either be located fully on-device or fully on-host.
207 ///
208 /// Tensors may also be replicated, where the same tensor data is distributed across devices, or a mixture of replicated and distributed. Replication is expressed by setting numDevices to a value that is a multiple of the product of deviceCounts. At that point, the devices tensor is assumed to have an extra final mode across which the tensor is replicated. Replicated tensors can be used everywhere except as outputs for contractions. . Particularly, passing replicated tensors can unlock new optimizations that . are advantageous for problems that benefit from reduced communication.
209 ///
210 /// ```text
211 /// For instance, with devices = {0,1,2,3, 4,5,6,7} the tensor would be replicated
212 /// ``` as follows:
213 ///
214 /// | | | |
215 /// | --- | --- | --- |
216 /// | Dev. 0 & 4 | Dev. 2 & 6 | Dev. 0 & 4 |
217 /// | Dev. 1 & 5 | Dev. 3 & 7 | Dev. 1 & 5 |
218 /// | Dev. 0 & 4 | Dev. 2 & 6 | Dev. 0 & 4 |
219 /// | Dev. 1 & 5 | Dev. 3 & 7 | Dev. 1 & 5 |
220 /// | Dev. 0 & 4 | Dev. 2 & 6 | Dev. 0 & 4 |
221 ///
222 /// Remark
223 ///
224 /// non-blocking, no reentrant, and thread-safe.
225 ///
226 /// # Parameters
227 ///
228 /// - `handle`: The library handle.
229 /// - `desc`: The resulting tensor descriptor.
230 /// - `numModes`: The number of modes.
231 /// - `extent`: The extent of the tensor in each mode (array of size `numModes`).
232 /// - `elementStride`: The offset (in linear memory) between two adjacent elements in each mode (array of size `numModes`), may be `NULL` for a dense tensor.
233 /// - `blockSize`: The size of a block in each mode (array of size `numModes`), may be `NULL` for an unblocked tensor (i.e., each mode only has a single block that is equal to its extent).
234 /// - `blockStride`: The offset (in linear memory) between two adjacent blocks in each mode (array of size `numModes`), may be `NULL` for a dense block-interleaved layout.
235 /// - `deviceCount`: The number of devices that each mode is distributed across in a block-cyclic fashion (array of size `numModes`), may be `NULL` for a non-distributed tensor.
236 /// - `numDevices`: The total number of devices that the tensor is distributed across (i.e., the product of all elements in `deviceCount` times how many devices it is replicated across).
237 /// - `devices`: The devices that the blocks are distributed across, in column-major order, i.e., stride 1 first (array of size `numDevices`).
238 ///
239 /// # Return value
240 ///
241 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
242 /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: This layout or data type is not supported.
243 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
244 pub fn cutensorMgCreateTensorDescriptor(
245 handle: cutensorMgHandle_t,
246 desc: *mut cutensorMgTensorDescriptor_t,
247 numModes: u32,
248 extent: *const i64,
249 elementStride: *const i64,
250 blockSize: *const i64,
251 blockStride: *const i64,
252 deviceCount: *const i32,
253 numDevices: u32,
254 devices: *const i32,
255 type_: cudaDataType_t,
256 ) -> cutensorStatus_t;
257}
258unsafe extern "C" {
259 /// Destroy a tensor descriptor.
260 ///
261 /// Remark
262 ///
263 /// non-blocking, no reentrant, and thread-safe.
264 ///
265 /// # Return value
266 ///
267 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
268 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
269 pub fn cutensorMgDestroyTensorDescriptor(
270 desc: cutensorMgTensorDescriptor_t,
271 ) -> cutensorStatus_t;
272}
273unsafe extern "C" {
274 /// Create a copy descriptor.
275 ///
276 /// A copy descriptor encodes the source and the destination for a copy operation. The copy operation supports tensors on host, single, or multiple devices. It also supports layout changes and mode permutations. The only restriction is that the extents of the corresponding modes (in the input and output tensors) must match.
277 ///
278 /// Remark
279 ///
280 /// non-blocking, no reentrant, and thread-safe.
281 ///
282 /// # Parameters
283 ///
284 /// - `handle`: The library handle.
285 /// - `desc`: The resulting copy descriptor.
286 /// - `descDst`: The destination tensor descriptor.
287 /// - `modesDst`: The destination tensor modes.
288 /// - `descSrc`: The source tensor descriptor.
289 /// - `modesSrc`: The source tensor modes.
290 ///
291 /// # Return value
292 ///
293 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
294 /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: This tensor layout or precision combination is not supported.
295 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
296 pub fn cutensorMgCreateCopyDescriptor(
297 handle: cutensorMgHandle_t,
298 desc: *mut cutensorMgCopyDescriptor_t,
299 descDst: cutensorMgTensorDescriptor_t,
300 modesDst: *const i32,
301 descSrc: cutensorMgTensorDescriptor_t,
302 modesSrc: *const i32,
303 ) -> cutensorStatus_t;
304}
305unsafe extern "C" {
306 /// Destroy a copy descriptor and free all its previously-allocated resources.
307 ///
308 /// Remark
309 ///
310 /// non-blocking, no reentrant, and thread-safe.
311 ///
312 /// # Return value
313 ///
314 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
315 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
316 pub fn cutensorMgDestroyCopyDescriptor(
317 desc: cutensorMgCopyDescriptor_t,
318 ) -> cutensorStatus_t;
319}
320unsafe extern "C" {
321 /// Computes the workspace that is needed for the copy.
322 ///
323 /// The function calculates the minimum workspace required for the copy operation to succeed. It returns the device workspace size in the same order as the devices are passed to the library handle.
324 ///
325 /// Remark
326 ///
327 /// non-blocking, no reentrant, and thread-safe.
328 ///
329 /// # Parameters
330 ///
331 /// - `handle`: The library handle.
332 /// - `desc`: The copy descriptor.
333 /// - `deviceWorkspaceSize`: The workspace size in bytes, for each device in the handle.
334 /// - `hostWorkspaceSize`: The workspace size in bytes for pinned host memory.
335 ///
336 /// # Return value
337 ///
338 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
339 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
340 pub fn cutensorMgCopyGetWorkspace(
341 handle: cutensorMgHandle_t,
342 desc: cutensorMgCopyDescriptor_t,
343 deviceWorkspaceSize: *mut i64,
344 hostWorkspaceSize: *mut i64,
345 ) -> cutensorStatus_t;
346}
347unsafe extern "C" {
348 /// Create a copy plan.
349 ///
350 /// A copy plan implements the copy operation expressed through the copy descriptor. It contains all the information needed to execute a copy operation. Planning may fail if insufficient workspace is provided.
351 ///
352 /// Remark
353 ///
354 /// non-blocking, no reentrant, and thread-safe.
355 ///
356 /// # Parameters
357 ///
358 /// - `handle`: The library handle.
359 /// - `plan`: The resulting copy plan.
360 /// - `desc`: The copy descriptor.
361 /// - `deviceWorkspaceSize`: The amount of workspace that will be provided, for each device in the handle.
362 /// - `hostWorkspaceSize`: The amount of pinned host workspace that will be provided.
363 ///
364 /// # Return value
365 ///
366 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
367 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
368 pub fn cutensorMgCreateCopyPlan(
369 handle: cutensorMgHandle_t,
370 plan: *mut cutensorMgCopyPlan_t,
371 desc: cutensorMgCopyDescriptor_t,
372 deviceWorkspaceSize: *const i64,
373 hostWorkspaceSize: i64,
374 ) -> cutensorStatus_t;
375}
376unsafe extern "C" {
377 /// Destroy a copy plan.
378 ///
379 /// When called, all outstanding operations must be completed. Frees all associated resources.
380 ///
381 /// Remark
382 ///
383 /// non-blocking, no reentrant, and thread-safe.
384 ///
385 /// # Return value
386 ///
387 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
388 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
389 pub fn cutensorMgDestroyCopyPlan(plan: cutensorMgCopyPlan_t) -> cutensorStatus_t;
390}
391unsafe extern "C" {
392 /// Execute a copy operation.
393 ///
394 /// Executes a copy operation according to the given plan. It receives the source and destination pointers in the order prescribed by the `devices` parameter of the respective tensor descriptor and the device workspace and streams in the order prescribed by the `devices` parameter of the handle. If host transfers are involved in the execution the function will block until those host transfers have been completed. The function is thread safe as long as concurrent threads use different library handles.
395 ///
396 /// Remark
397 ///
398 /// calls asynchronous functions, conditionally blocking, no reentrant, and conditionally thread-safe.
399 ///
400 /// # Parameters
401 ///
402 /// - `handle`: The library handle.
403 /// - `plan`: The copy plan.
404 /// - `ptrDst`: The destination tensor pointers.
405 /// - `ptrSrc`: The source tensor pointers.
406 /// - `deviceWorkspace`: The device workspace.
407 /// - `hostWorkspace`: The host pinned memory workspace.
408 /// - `streams`: The execution streams.
409 ///
410 /// # Return value
411 ///
412 /// - [`cutensorStatus_t::CUTENSOR_STATUS_CUDA_ERROR`]: An issue interacting with the CUDA runtime occurred.
413 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
414 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
415 pub fn cutensorMgCopy(
416 handle: cutensorMgHandle_t,
417 plan: cutensorMgCopyPlan_t,
418 ptrDst: *mut *mut ::core::ffi::c_void,
419 ptrSrc: *mut *const ::core::ffi::c_void,
420 deviceWorkspace: *mut *mut ::core::ffi::c_void,
421 hostWorkspace: *mut ::core::ffi::c_void,
422 streams: *mut cudaStream_t,
423 ) -> cutensorStatus_t;
424}
425unsafe extern "C" {
426 /// Create a contraction find.
427 ///
428 /// The contraction find contains all the algorithmic options to execute a tensor contraction. For now, its only parameter is an algorithm, which currently only has one default value. It may gain additional options in the future.
429 ///
430 /// Remark
431 ///
432 /// non-blocking, no reentrant, and thread-safe.
433 ///
434 /// # Parameters
435 ///
436 /// - `handle`: The library handle.
437 /// - `find`: The resulting find.
438 /// - `algo`: The desired algorithm.
439 ///
440 /// # Return value
441 ///
442 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
443 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
444 pub fn cutensorMgCreateContractionFind(
445 handle: cutensorMgHandle_t,
446 find: *mut cutensorMgContractionFind_t,
447 algo: cutensorMgAlgo_t,
448 ) -> cutensorStatus_t;
449}
450unsafe extern "C" {
451 /// Destroy a contraction find.
452 ///
453 /// Remark
454 ///
455 /// non-blocking, no reentrant, and thread-safe.
456 ///
457 /// # Return value
458 ///
459 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
460 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
461 pub fn cutensorMgDestroyContractionFind(
462 find: cutensorMgContractionFind_t,
463 ) -> cutensorStatus_t;
464}
465unsafe extern "C" {
466 pub fn cutensorMgContractionFindSetAttribute(
467 handle: cutensorMgHandle_t,
468 find: cutensorMgContractionFind_t,
469 attr: cutensorMgContractionFindAttribute_t,
470 value: *const ::core::ffi::c_void,
471 size: i64,
472 ) -> cutensorStatus_t;
473}
474unsafe extern "C" {
475 /// Create a contraction descriptor.
476 ///
477 /// A contraction descriptor encodes the operands for a contraction operation of the form:
478 /// $$
479 /// D = \alpha \mathcal{A} \mathcal{B} + \beta \mathcal{C}
480 /// $$.
481 /// The contraction operation presently supports tensors that are either on one or multiple devices, but does not support tensors stored on the host (for now). It uses the einstein notation, i.e., modes shared between only modesA and modesB are contracted. Currently, descC and descD as well as modesC and modesD must be identical. The compute type represents the lowest precision that may be used in the course of the calculation.
482 ///
483 /// Remark
484 ///
485 /// non-blocking, no reentrant, and thread-safe.
486 ///
487 /// # Parameters
488 ///
489 /// - `handle`: The library handle.
490 /// - `desc`: The resulting tensor contraction descriptor.
491 /// - `descA`: The tensor descriptor for operand A.
492 /// - `modesA`: The modes for operand A.
493 /// - `descB`: The tensor descriptor for operand B.
494 /// - `modesB`: The modes for operand B.
495 /// - `descC`: The tensor descriptor for operand C.
496 /// - `modesC`: The modes for operand C.
497 /// - `descD`: The tensor descriptor for operand D.
498 /// - `modesD`: The modes for operand D.
499 /// - `compute`: The compute type for the operation.
500 ///
501 /// # Return value
502 ///
503 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
504 /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: This tensor layout or precision combination is not supported.
505 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
506 pub fn cutensorMgCreateContractionDescriptor(
507 handle: cutensorMgHandle_t,
508 desc: *mut cutensorMgContractionDescriptor_t,
509 descA: cutensorMgTensorDescriptor_t,
510 modesA: *const i32,
511 descB: cutensorMgTensorDescriptor_t,
512 modesB: *const i32,
513 descC: cutensorMgTensorDescriptor_t,
514 modesC: *const i32,
515 descD: cutensorMgTensorDescriptor_t,
516 modesD: *const i32,
517 compute: cutensorComputeType_t,
518 ) -> cutensorStatus_t;
519}
520unsafe extern "C" {
521 /// Destroy a contraction descriptor.
522 ///
523 /// Remark
524 ///
525 /// non-blocking, no reentrant, and thread-safe.
526 ///
527 /// # Return value
528 ///
529 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
530 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
531 pub fn cutensorMgDestroyContractionDescriptor(
532 desc: cutensorMgContractionDescriptor_t,
533 ) -> cutensorStatus_t;
534}
535unsafe extern "C" {
536 /// Computes the workspace that is needed for the contraction.
537 ///
538 /// The function calculates the workspace required for the contraction operation to succeed. It takes a workspace preference, which can tune how much workspace is needed. It returns the device workspace size in the same order as the devices are passed to the library handle.
539 ///
540 /// Remark
541 ///
542 /// non-blocking, no reentrant, and thread-safe.
543 ///
544 /// # Parameters
545 ///
546 /// - `handle`: The library handle.
547 /// - `desc`: The contraction descriptor.
548 /// - `find`: The contraction find.
549 /// - `preference`: The workspace preference.
550 /// - `deviceWorkspaceSize`: The amount of workspace in bytes, for each device in the handle.
551 /// - `hostWorkspaceSize`: The amount of pinned host memory in bytes.
552 ///
553 /// # Return value
554 ///
555 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
556 /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: This tensor layout or precision combination is not supported.
557 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
558 pub fn cutensorMgContractionGetWorkspace(
559 handle: cutensorMgHandle_t,
560 desc: cutensorMgContractionDescriptor_t,
561 find: cutensorMgContractionFind_t,
562 preference: cutensorWorksizePreference_t,
563 deviceWorkspaceSize: *mut i64,
564 hostWorkspaceSize: *mut i64,
565 ) -> cutensorStatus_t;
566}
567unsafe extern "C" {
568 /// Create a contraction plan.
569 ///
570 /// A contraction plan implements the contraction operation expressed through the contraction descriptor in accordance to the options specified in the contraction find. It contains all the information needed to execute a contraction operation. Planning may fail if insufficient workspace is provided.
571 ///
572 /// Remark
573 ///
574 /// non-blocking, no reentrant, and thread-safe.
575 ///
576 /// # Parameters
577 ///
578 /// - `handle`: The library handle.
579 /// - `plan`: The resulting contraction plan.
580 /// - `desc`: The contraction descriptor.
581 /// - `find`: The contraction find.
582 /// - `deviceWorkspaceSize`: The amount of workspace in bytes, for each device in the handle.
583 /// - `hostWorkspaceSize`: The amount of pinned host memory in bytes.
584 ///
585 /// # Return value
586 ///
587 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
588 /// - [`cutensorStatus_t::CUTENSOR_STATUS_NOT_SUPPORTED`]: This tensor layout or precision combination is not supported.
589 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
590 pub fn cutensorMgCreateContractionPlan(
591 handle: cutensorMgHandle_t,
592 plan: *mut cutensorMgContractionPlan_t,
593 desc: cutensorMgContractionDescriptor_t,
594 find: cutensorMgContractionFind_t,
595 deviceWorkspaceSize: *const i64,
596 hostWorkspaceSize: i64,
597 ) -> cutensorStatus_t;
598}
599unsafe extern "C" {
600 /// Destroy a contraction plan.
601 ///
602 /// When called, all outstanding operations must be completed. Frees all associated resources.
603 ///
604 /// Remark
605 ///
606 /// non-blocking, no reentrant, and thread-safe.
607 ///
608 /// # Return value
609 ///
610 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
611 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
612 pub fn cutensorMgDestroyContractionPlan(
613 plan: cutensorMgContractionPlan_t,
614 ) -> cutensorStatus_t;
615}
616unsafe extern "C" {
617 /// Execute a contraction operation.
618 ///
619 /// Executes a contraction operation according to the provided plan. It receives all the operands as arrays of pointers that are ordered according to their tensor descriptors’ `devices` parameter. The device workspace and streams are ordered according to the library handle’s `devices` parameter. The function is thread safe as long as concurrent threads use different library handles.
620 ///
621 /// Remark
622 ///
623 /// calls asynchronous functions, non-blocking, no reentrant, and conditionally thread-safe.
624 ///
625 /// # Parameters
626 ///
627 /// - `handle`: The library handle.
628 /// - `plan`: The copy plan.
629 /// - `alpha`: The alpha scaling factor (host pointer).
630 /// - `ptrA`: The A operand tensor pointers.
631 /// - `ptrB`: The B operand tensor pointers.
632 /// - `beta`: The beta scaling factor (host pointer).
633 /// - `ptrC`: The operand C tensor pointers.
634 /// - `ptrD`: The operand D tensor pointers.
635 /// - `deviceWorkspace`: The device workspace.
636 /// - `hostWorkspace`: The host pinned memory workspace.
637 /// - `streams`: The execution streams.
638 ///
639 /// # Return value
640 ///
641 /// - [`cutensorStatus_t::CUTENSOR_STATUS_CUDA_ERROR`]: An issue interacting with the CUDA runtime occurred.
642 /// - [`cutensorStatus_t::CUTENSOR_STATUS_INVALID_VALUE`]: Some input parameters were invalid.
643 /// - [`cutensorStatus_t::CUTENSOR_STATUS_SUCCESS`]: The operation completed successfully.
644 pub fn cutensorMgContraction(
645 handle: cutensorMgHandle_t,
646 plan: cutensorMgContractionPlan_t,
647 alpha: *const ::core::ffi::c_void,
648 ptrA: *mut *const ::core::ffi::c_void,
649 ptrB: *mut *const ::core::ffi::c_void,
650 beta: *const ::core::ffi::c_void,
651 ptrC: *mut *const ::core::ffi::c_void,
652 ptrD: *mut *mut ::core::ffi::c_void,
653 deviceWorkspace: *mut *mut ::core::ffi::c_void,
654 hostWorkspace: *mut ::core::ffi::c_void,
655 streams: *mut cudaStream_t,
656 ) -> cutensorStatus_t;
657}