nvidia-libmathdx-cu13 0.2.3.14.post1__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,441 @@
1
+ // Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ //
3
+ // NVIDIA CORPORATION and its licensors retain all intellectual property
4
+ // and proprietary rights in and to this software, related documentation
5
+ // and any modifications thereto. Any use, reproduction, disclosure or
6
+ // distribution of this software and related documentation without an express
7
+ // license agreement from NVIDIA CORPORATION is strictly prohibited.
8
+
9
+ // libmathdx's API is subject to change.
10
+ // Please contact Math-Libs-Feedback@nvidia.com for usage feedback.
11
+
12
+ #ifndef MATHDX_LIBCOMMONDX_H
13
+ #define MATHDX_LIBCOMMONDX_H
14
+
15
+ #include <stddef.h>
16
+
17
+ #if defined(__cplusplus)
18
+ extern "C" {
19
+ #endif /* __cplusplus */
20
+
21
+ #ifndef LIBMATHDX_API
22
+ #if __GNUC__ >= 4
23
+ #define LIBMATHDX_API __attribute__((visibility("default")))
24
+ #else
25
+ #define LIBMATHDX_API
26
+ #endif
27
+ #endif
28
+
29
+ #ifndef LIBMATHDX_CALL
30
+ #ifdef _WIN32
31
+ #define LIBMATHDX_CALL __stdcall
32
+ #else
33
+ #define LIBMATHDX_CALL
34
+ #endif
35
+ #endif
36
+
37
+ #ifdef __cplusplus
38
+ #ifndef LIBMATHDX_API_NOEXCEPT
39
+ #define LIBMATHDX_API_NOEXCEPT noexcept
40
+ #endif
41
+ #else
42
+ #define LIBMATHDX_API_NOEXCEPT
43
+ #endif
44
+
45
+ /**
46
+ * @brief A handle to some compiled code.
47
+ *
48
+ * Compiled code generally contains one or more device function, and is specified by
49
+ * the code type (e.g. SASS, PTX, LTO - \ref commondxCodeContainer_t) and the compute capability
50
+ * (in the form of an integer, e.g. 800 for CC 8.0).
51
+ *
52
+ * Compiled code can be genrated by a call to \ref cublasdxFinalizeCode,
53
+ * \ref cufftdxFinalizeCode or \ref cusolverdxFinalizeCode.
54
+ */
55
+ typedef long long int commondxCode;
56
+
57
+ /**
58
+ * @brief The set of value types supported by the library.
59
+ *
60
+ * Note that, for complex numbers, this combines real and imaginary part,
61
+ * and that all complex numbers are overaligned on their size.
62
+ */
63
+ typedef enum commondxValueType_t {
64
+ /** Equivalent to __nv_fp8_e5m2. Size: 1B, alignment: 1B */
65
+ COMMONDX_R_8F_E5M2 = 0,
66
+ /** Equivalent to 2x__nv_fp8_e5m2. Size: 2B, alignment: 2B (overaligned) */
67
+ COMMONDX_C_8F_E5M2 = 1,
68
+ /** Equivalent to __nv_fp8_e4m3. Size: 1B, alignment: 1B */
69
+ COMMONDX_R_8F_E4M3 = 2,
70
+ /** Equivalent to 2x__nv_fp8_e4m3. Size: 2B, alignment: 2B (overaligned) */
71
+ COMMONDX_C_8F_E4M3 = 3,
72
+ /** Equivalent to __nv_bfloat16. Size: 2B, alignment: 2B */
73
+ COMMONDX_R_16BF = 4,
74
+ /** Equivalent to 2x__nv_bfloat16. Size: 4B, alignment: 4B (overaligned) */
75
+ COMMONDX_C_16BF = 5,
76
+ /** Equivalent to __half2. Size: 4B, alignment: 4B */
77
+ COMMONDX_R_16F2 = 6,
78
+ /** Equivalent to __half. Size: 2B, alignment: 2B */
79
+ COMMONDX_R_16F = 7,
80
+ /** Equivalent to 2x__half. Size: 4B, alignment: 4B (overaligned) */
81
+ COMMONDX_C_16F = 8,
82
+ /** Equivalent to 2x__half2. Size: 8B, alignment: 8B (overaligned) */
83
+ COMMONDX_C_16F2 = 9,
84
+ /** Equivalent to tf32. Size: 4B, alignment: 4B */
85
+ COMMONDX_R_32TF = 10,
86
+ /** Equivalent to 2xtf32. Size: 8B, alignment: 8B (overaligned) */
87
+ COMMONDX_C_32TF = 11,
88
+ /** Equivalent to float. Size: 4B, alignment: 4B */
89
+ COMMONDX_R_32F = 12,
90
+ /** Equivalent to 2xfloat. Size: 8B, alignment: 8B (overaligned) */
91
+ COMMONDX_C_32F = 13,
92
+ /** Equivalent to double. Size: 8B, alignment: 8B */
93
+ COMMONDX_R_64F = 14,
94
+ /** Equivalent to 2xdouble. Size: 16B, alignment: 16B (overaligned) */
95
+ COMMONDX_C_64F = 15,
96
+ /** Equivalent to int8_t. Size 1B, alignment: 1B */
97
+ COMMONDX_R_8I = 16,
98
+ /** Equivalent to 2xint8_t. Size 2B, alignment: 2B (overaligned) */
99
+ COMMONDX_C_8I = 17,
100
+ /** Equivalent to int16_t. Size 2B, alignment: 2B */
101
+ COMMONDX_R_16I = 18,
102
+ /** Equivalent to 2xint16_t. Size 4B, alignment: 4B (overaligned) */
103
+ COMMONDX_C_16I = 19,
104
+ /** Equivalent to int32_t. Size 4B, alignment: 4B */
105
+ COMMONDX_R_32I = 20,
106
+ /** Equivalent to 2xint32_t. Size 8B, alignment: 8B (overaligned)*/
107
+ COMMONDX_C_32I = 21,
108
+ /** Equivalent to int64_t. Size 8B, alignment: 8B */
109
+ COMMONDX_R_64I = 22,
110
+ /** Equivalent to 2xint64_t. Size 16B, alignment: 16B (overaligned) */
111
+ COMMONDX_C_64I = 23,
112
+ /** Equivalent to uint8_t. Size 1B, alignment: 1B */
113
+ COMMONDX_R_8UI = 24,
114
+ /** Equivalent to 2xuint8_t. Size 2B, alignment: 2B (overaligned) */
115
+ COMMONDX_C_8UI = 25,
116
+ /** Equivalent to uint16_t. Size 2B, alignment: 2B */
117
+ COMMONDX_R_16UI = 26,
118
+ /** Equivalent to 2xuint16_t. Size 4B, alignment: 4B (overaligned) */
119
+ COMMONDX_C_16UI = 27,
120
+ /** Equivalent to uint32_t. Size 4B, alignment: 4B */
121
+ COMMONDX_R_32UI = 28,
122
+ /** Equivalent to 2xuint32_t. Size 8B, alignment: 8B (overaligned)*/
123
+ COMMONDX_C_32UI = 29,
124
+ /** Equivalent to uint64_t. Size 8B, alignment: 8B */
125
+ COMMONDX_R_64UI = 30,
126
+ /** Equivalent to 2xuint64_t. Size 16B, alignment: 16B (overaligned) */
127
+ COMMONDX_C_64UI = 31,
128
+ } commondxValueType;
129
+
130
+ /**
131
+ * @brief The set of status values that can be returned by APIs defined in the library
132
+ */
133
+ typedef enum commondxStatusType_t {
134
+ /** Success */
135
+ COMMONDX_SUCCESS = 0,
136
+ /** One of the input values is not in the allowed range or is otherwise invalid */
137
+ COMMONDX_INVALID_VALUE = 1,
138
+ /** Library internal error */
139
+ COMMONDX_INTERNAL_ERROR = 2,
140
+ /** Compilation did not complete successfully */
141
+ COMMONDX_COMPILATION_ERROR = 3,
142
+ /** Library dependency error */
143
+ COMMONDX_CUFFT_ERROR = 4,
144
+ } commondxStatusType;
145
+
146
+ /**
147
+ * @brief The set of precisions supported by the library
148
+ *
149
+ * For the actual input and output value types, see \ref commondxValueType_t
150
+ */
151
+ typedef enum commondxPrecision_t {
152
+ /** Equivalent to __nv_fp8_e5m2 */
153
+ COMMONDX_PRECISION_F8_E5M2 = 0,
154
+ /** Equivalent to __nv_fp8_e4m3 */
155
+ COMMONDX_PRECISION_F8_E4M3 = 1,
156
+ /** Equivalent to __nv_bfloat16 */
157
+ COMMONDX_PRECISION_BF16 = 2,
158
+ /** Equivalent to __half */
159
+ COMMONDX_PRECISION_F16 = 3,
160
+ /** Equivalent to tfloat32 */
161
+ COMMONDX_PRECISION_TF32 = 4,
162
+ /** Equivalent to float */
163
+ COMMONDX_PRECISION_F32 = 5,
164
+ /** Equivalent to double */
165
+ COMMONDX_PRECISION_F64 = 6,
166
+ /** Equivalent to int8_t */
167
+ COMMONDX_PRECISION_I8 = 7,
168
+ /** Equivalent to int16_t */
169
+ COMMONDX_PRECISION_I16 = 8,
170
+ /** Equivalent to int32_t */
171
+ COMMONDX_PRECISION_I32 = 9,
172
+ /** Equivalent to int64_t */
173
+ COMMONDX_PRECISION_I64 = 10,
174
+ /** Equivalent to uint8_t */
175
+ COMMONDX_PRECISION_UI8 = 11,
176
+ /** Equivalent to uint16_t */
177
+ COMMONDX_PRECISION_UI16 = 12,
178
+ /** Equivalent to uint32_t */
179
+ COMMONDX_PRECISION_UI32 = 13,
180
+ /** Equivalent to uint64_t */
181
+ COMMONDX_PRECISION_UI64 = 14,
182
+ } commondxPrecision;
183
+
184
+ /**
185
+ * @brief Options to tweak code generation
186
+ */
187
+ typedef enum commondxOption_t {
188
+ /**
189
+ * Symbol to wrap the device function in (default is autogenerated).
190
+ * Associated value must be A C-string.
191
+ */
192
+ COMMONDX_OPTION_SYMBOL_NAME = 0,
193
+ /**
194
+ * Target SM.
195
+ * Associated value must be an integer, e.g. 800 for SM80.
196
+ * See \ref commondxSetCodeOptionInt64
197
+ */
198
+ COMMONDX_OPTION_TARGET_SM = 1,
199
+ /**
200
+ * Code container type (e.g. PTX, LTO, Cubin (SASS), FATBIN).
201
+ * Associated value must be a value of \ref commondxCodeContainer_t
202
+ */
203
+ COMMONDX_OPTION_CODE_CONTAINER = 2,
204
+ /**
205
+ * Code ISA (e.g. 12.3 for LTO).
206
+ * Associated value must be an integer, e.g. 12030 for 12.3
207
+ */
208
+ COMMONDX_OPTION_CODE_ISA = 3,
209
+ /**
210
+ * Extra arguments passed to NVRTC.
211
+ * Must be one or more C-string. See \ref commondxSetCodeOptionStr
212
+ * and \ref commondxSetCodeOptionStrs .
213
+ */
214
+ COMMONDX_OPTION_EXTRA_NVTRC_ARGS = 4,
215
+ } commondxOption;
216
+
217
+ /**
218
+ * @brief The set of execution modes supported by the library
219
+ */
220
+ typedef enum commondxExecution_t {
221
+ /**
222
+ * Thread APIs.
223
+ * All threads are independant, divergent control flow is allowed.
224
+ */
225
+ COMMONDX_EXECUTION_THREAD = 0,
226
+ /**
227
+ * Block APIs.
228
+ * All threads in the block cooperate, and all must call the device function.
229
+ */
230
+ COMMONDX_EXECUTION_BLOCK = 1,
231
+ } commondxExecution;
232
+
233
+ /**
234
+ * @brief The set of device code container types supported by the library.
235
+ * See \ref commondxOption_t::COMMONDX_OPTION_CODE_CONTAINER
236
+ */
237
+ typedef enum commondxCodeContainer_t {
238
+ /**
239
+ * `.ltoir`, aka `-dlto -ltoir` with NVCC and NVRTC
240
+ */
241
+ COMMONDX_CODE_CONTAINER_LTOIR = 0,
242
+ /**
243
+ * `.fatbin`, aka `-fatbin` with NVCC
244
+ */
245
+ COMMONDX_CODE_CONTAINER_FATBIN = 1,
246
+ } commondxCodeContainer;
247
+
248
+ /**
249
+ * @brief Creates a code handle.
250
+ *
251
+ * @param[out] code A pointer to the output code handle.
252
+ * @return `COMMONDX_SUCCESS` on success, or an error.
253
+ */
254
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxCreateCode(commondxCode* code) LIBMATHDX_API_NOEXCEPT;
255
+
256
+ /**
257
+ * @brief Set an option on a code handle
258
+ *
259
+ * @param[in] code A code handle from \ref commondxCreateCode
260
+ * @param[in] option The option to set the code to
261
+ * @param[in] value A corresponding value for the selected option
262
+ * @return `COMMONDX_SUCCESS` on success, or an error.
263
+ */
264
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxSetCodeOptionInt64(commondxCode code,
265
+ commondxOption option,
266
+ long long int value) LIBMATHDX_API_NOEXCEPT;
267
+
268
+ /**
269
+ * @brief Set a C-string option on a code handle.
270
+ *
271
+ * @param[in] code A code handle from \ref commondxCreateCode.
272
+ * @param[in] option The option to set the code to.
273
+ * @param[in] value A C-string. Cannot be `NULL`.
274
+ * @return `COMMONDX_SUCCESS` on success, or an error.
275
+ */
276
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxSetCodeOptionStr(commondxCode code,
277
+ commondxOption option,
278
+ const char* value) LIBMATHDX_API_NOEXCEPT;
279
+
280
+ /**
281
+ * @brief Set one or more C-string option on a code handle.
282
+ *
283
+ * @param[in] code A code handle from \ref commondxCreateCode.
284
+ * @param[in] option The option to set the code to.
285
+ * @param[in] count The number of C-strings to set.
286
+ * @param[in] values A pointer to an array of `count` C-strings.
287
+ * @return `COMMONDX_SUCCESS` on success, or an error.
288
+ */
289
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxSetCodeOptionStrs(commondxCode code,
290
+ commondxOption option,
291
+ size_t count,
292
+ const char** values) LIBMATHDX_API_NOEXCEPT;
293
+
294
+ /**
295
+ * @brief Get option from a code handle
296
+ *
297
+ * @param[in] code A code handle from \ref commondxCreateCode
298
+ * @param[in] option The option to get
299
+ * @param[out] value The option value.
300
+ * @return `COMMONDX_SUCCESS` on success, or an error.
301
+ */
302
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxGetCodeOptionInt64(commondxCode code,
303
+ commondxOption option,
304
+ long long int* value) LIBMATHDX_API_NOEXCEPT;
305
+
306
+ /**
307
+ * @brief Get options (as an array) from a code handle, with one option per output code
308
+ *
309
+ * @param[in] code A code handle from \ref commondxCreateCode
310
+ * @param[in] option The option to get
311
+ * @param[in] size The array size, as result from \ref commondxGetCodeNumLTOIRs
312
+ * @param[out] array A pointer to the beginning of the output array. Must be a pointer to a buffer of at least `size`
313
+ * elements.
314
+ * @return `COMMONDX_SUCCESS` on success, or an error.
315
+ */
316
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL
317
+ commondxGetCodeOptionsInt64s(commondxCode code, commondxOption option, size_t size, long long int* array)
318
+ LIBMATHDX_API_NOEXCEPT;
319
+
320
+ /**
321
+ * @brief Extract the LTOIR size, in bytes.
322
+ *
323
+ * @param[in] code A code handle from \ref commondxCreateCode
324
+ * @param[out] size The LTOIR size, in bytes.
325
+ * @return `COMMONDX_SUCCESS` on success, or an error.
326
+ */
327
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxGetCodeLTOIRSize(commondxCode code,
328
+ size_t* size) LIBMATHDX_API_NOEXCEPT;
329
+
330
+ /**
331
+ * @brief Extract the LTOIR.
332
+ *
333
+ * @param[in] code A code handle from \ref commondxCreateCode
334
+ * @param[in] size The LTOIR size, as returned by \ref commondxGetCodeLTOIRSize
335
+ * @param[out] out The LTOIR. Must be a pointer to a buffer of at least size byte.
336
+ * @return `COMMONDX_SUCCESS` on success, or an error.
337
+ */
338
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxGetCodeLTOIR(commondxCode code,
339
+ size_t size,
340
+ void* out) LIBMATHDX_API_NOEXCEPT;
341
+
342
+ /**
343
+ * @brief Returns the number the LTOIR chunks.
344
+ *
345
+ * Some code produce more than one LTOIR.
346
+ * In this case, this function must be used to retreive the number of LTOIR's.
347
+ *
348
+ * @param[in] code A code handle from \ref commondxCreateCode
349
+ * @param[out] size The number of LTOIR chunks.
350
+ * @return `COMMONDX_SUCCESS` on success, or an error.
351
+ */
352
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxGetCodeNumLTOIRs(commondxCode code,
353
+ size_t* size) LIBMATHDX_API_NOEXCEPT;
354
+
355
+ /**
356
+ * @brief Returns the size of all LTOIR chunks.
357
+ *
358
+ * @param[in] code A code handle from \ref commondxCreateCode
359
+ * @param[in] size The number of LTOIR chunks, as returned by \ref commondxGetCodeNumLTOIRs
360
+ * @param[out] out On output, `out[i]` is the size, in byte, of the ith LTOIR chunk.
361
+ * @return `COMMONDX_SUCCESS` on success, or an error.
362
+ */
363
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxGetCodeLTOIRSizes(commondxCode code,
364
+ size_t size,
365
+ size_t* out) LIBMATHDX_API_NOEXCEPT;
366
+
367
+ /**
368
+ * @brief Returns all LTOIR chunks.
369
+ *
370
+ * @param[in] code A code handle from \ref commondxCreateCode
371
+ * @param[in] size The number of LTOIR chunks, as returned by \ref commondxGetCodeNumLTOIRs
372
+ * @param[out] out On output, `out[i]` is filled with the ith LTOIR chunk. `out[i]` must point to a buffer
373
+ * of at least `size[i]` bytes, with `size` the output of \ref commondxGetCodeLTOIRSizes
374
+ * @return `COMMONDX_SUCCESS` on success, or an error.
375
+ */
376
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxGetCodeLTOIRs(commondxCode code,
377
+ size_t size,
378
+ void** out) LIBMATHDX_API_NOEXCEPT;
379
+
380
+ /**
381
+ * @brief Destroys a code handle.
382
+ *
383
+ * @param[in] code A code handle from \ref commondxCreateCode
384
+ * @return `COMMONDX_SUCCESS` on success, or an error.
385
+ */
386
+ LIBMATHDX_API commondxStatusType LIBMATHDX_CALL commondxDestroyCode(commondxCode code) LIBMATHDX_API_NOEXCEPT;
387
+
388
+ /**
389
+ * @brief Convert a status enum to a human readable C-string
390
+ *
391
+ * @param[in] status The status enum to convert
392
+ * @return A short C-string describing the enum. This C-string should be not free'ed by the caller.
393
+ */
394
+ LIBMATHDX_API const char* LIBMATHDX_CALL commondxStatusToStr(commondxStatusType status) LIBMATHDX_API_NOEXCEPT;
395
+
396
+ /**
397
+ * @brief Convert a precision enum to a human readable C-string
398
+ *
399
+ * @param[in] precision The precision enum to convert
400
+ * @return The C-string
401
+ */
402
+ LIBMATHDX_API const char* LIBMATHDX_CALL commondxPrecisionToStr(commondxPrecision precision) LIBMATHDX_API_NOEXCEPT;
403
+
404
+ /**
405
+ * @brief Convert a value type enum to a human readable C-string
406
+ *
407
+ * @param[in] value_type The value type enum to convert
408
+ * @return The C-string
409
+ */
410
+ LIBMATHDX_API const char* LIBMATHDX_CALL commondxValueTypeToStr(commondxValueType value_type) LIBMATHDX_API_NOEXCEPT;
411
+
412
+ /**
413
+ * @brief Convert an option enum to a human readable C-string
414
+ *
415
+ * @param[in] option The option enum to convert
416
+ * @return The C-string
417
+ */
418
+ LIBMATHDX_API const char* LIBMATHDX_CALL commondxOptionToStr(commondxOption option) LIBMATHDX_API_NOEXCEPT;
419
+
420
+ /**
421
+ * @brief Convert an execution enum to a human readable C-string
422
+ *
423
+ * @param[in] execution The execution enum to convert
424
+ * @return The C-string
425
+ */
426
+ LIBMATHDX_API const char* LIBMATHDX_CALL commondxExecutionToStr(commondxExecution execution) LIBMATHDX_API_NOEXCEPT;
427
+
428
+ /**
429
+ * @brief Convert a code container type enum to a human readable C-string
430
+ *
431
+ * @param[in] container The code container type enum to convert
432
+ * @return The C-string
433
+ */
434
+ LIBMATHDX_API const char* LIBMATHDX_CALL commondxCodeContainerToStr(commondxCodeContainer container)
435
+ LIBMATHDX_API_NOEXCEPT;
436
+
437
+ #if defined(__cplusplus)
438
+ } // extern "C"
439
+ #endif /* __cplusplus */
440
+
441
+ #endif // MATHDX_LIBCOMMONDX_H