nvmath-python 0.9.0__cp314-cp314-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.
Files changed (309) hide show
  1. nvmath/__init__.pxd +0 -0
  2. nvmath/__init__.py +45 -0
  3. nvmath/_internal/__init__.py +0 -0
  4. nvmath/_internal/attribute_ifc_factory.py +330 -0
  5. nvmath/_internal/layout.py +70 -0
  6. nvmath/_internal/templates.py +383 -0
  7. nvmath/_utils.py +150 -0
  8. nvmath/bindings/__init__.py +51 -0
  9. nvmath/bindings/_internal/__init__.pxd +0 -0
  10. nvmath/bindings/_internal/__init__.py +0 -0
  11. nvmath/bindings/_internal/cublas.cp314-win_amd64.pyd +0 -0
  12. nvmath/bindings/_internal/cublas.pxd +530 -0
  13. nvmath/bindings/_internal/cublasLt.cp314-win_amd64.pyd +0 -0
  14. nvmath/bindings/_internal/cublasLt.pxd +59 -0
  15. nvmath/bindings/_internal/cublasMp.pxd +52 -0
  16. nvmath/bindings/_internal/cudss.cp314-win_amd64.pyd +0 -0
  17. nvmath/bindings/_internal/cudss.pxd +47 -0
  18. nvmath/bindings/_internal/cufft.cp314-win_amd64.pyd +0 -0
  19. nvmath/bindings/_internal/cufft.pxd +70 -0
  20. nvmath/bindings/_internal/cufftMp.pxd +77 -0
  21. nvmath/bindings/_internal/curand.cp314-win_amd64.pyd +0 -0
  22. nvmath/bindings/_internal/curand.pxd +42 -0
  23. nvmath/bindings/_internal/cusolver.cp314-win_amd64.pyd +0 -0
  24. nvmath/bindings/_internal/cusolver.pxd +15 -0
  25. nvmath/bindings/_internal/cusolverDn.cp314-win_amd64.pyd +0 -0
  26. nvmath/bindings/_internal/cusolverDn.pxd +406 -0
  27. nvmath/bindings/_internal/cusparse.cp314-win_amd64.pyd +0 -0
  28. nvmath/bindings/_internal/cusparse.pxd +277 -0
  29. nvmath/bindings/_internal/cusparseLt.cp314-win_amd64.pyd +0 -0
  30. nvmath/bindings/_internal/cusparseLt.pxd +48 -0
  31. nvmath/bindings/_internal/cutensor.cp314-win_amd64.pyd +0 -0
  32. nvmath/bindings/_internal/cutensor.pxd +58 -0
  33. nvmath/bindings/_internal/mathdx.cp314-win_amd64.pyd +0 -0
  34. nvmath/bindings/_internal/mathdx.pxd +116 -0
  35. nvmath/bindings/_internal/nvshmem.pxd +29 -0
  36. nvmath/bindings/_internal/utils.cp314-win_amd64.pyd +0 -0
  37. nvmath/bindings/_internal/utils.pxd +179 -0
  38. nvmath/bindings/_internal/utils.pyi +10 -0
  39. nvmath/bindings/cublas.cp314-win_amd64.pyd +0 -0
  40. nvmath/bindings/cublas.pxd +558 -0
  41. nvmath/bindings/cublas.pyi +746 -0
  42. nvmath/bindings/cublasLt.cp314-win_amd64.pyd +0 -0
  43. nvmath/bindings/cublasLt.pxd +109 -0
  44. nvmath/bindings/cublasLt.pyi +1337 -0
  45. nvmath/bindings/cublasMp.pxd +85 -0
  46. nvmath/bindings/cublasMp.pyi +219 -0
  47. nvmath/bindings/cudss.cp314-win_amd64.pyd +0 -0
  48. nvmath/bindings/cudss.pxd +86 -0
  49. nvmath/bindings/cudss.pyi +282 -0
  50. nvmath/bindings/cufft.cp314-win_amd64.pyd +0 -0
  51. nvmath/bindings/cufft.pxd +118 -0
  52. nvmath/bindings/cufft.pyi +241 -0
  53. nvmath/bindings/cufftMp.pxd +124 -0
  54. nvmath/bindings/cufftMp.pyi +260 -0
  55. nvmath/bindings/curand.cp314-win_amd64.pyd +0 -0
  56. nvmath/bindings/curand.pxd +71 -0
  57. nvmath/bindings/curand.pyi +159 -0
  58. nvmath/bindings/cusolver.cp314-win_amd64.pyd +0 -0
  59. nvmath/bindings/cusolver.pxd +62 -0
  60. nvmath/bindings/cusolver.pyi +242 -0
  61. nvmath/bindings/cusolverDn.cp314-win_amd64.pyd +0 -0
  62. nvmath/bindings/cusolverDn.pxd +430 -0
  63. nvmath/bindings/cusolverDn.pyi +416 -0
  64. nvmath/bindings/cusparse.cp314-win_amd64.pyd +0 -0
  65. nvmath/bindings/cusparse.pxd +338 -0
  66. nvmath/bindings/cusparse.pyi +659 -0
  67. nvmath/bindings/cusparseLt.cp314-win_amd64.pyd +0 -0
  68. nvmath/bindings/cusparseLt.pxd +99 -0
  69. nvmath/bindings/cusparseLt.pyi +198 -0
  70. nvmath/bindings/cutensor.cp314-win_amd64.pyd +0 -0
  71. nvmath/bindings/cutensor.pxd +98 -0
  72. nvmath/bindings/cutensor.pyi +294 -0
  73. nvmath/bindings/cycublas.cp314-win_amd64.pyd +0 -0
  74. nvmath/bindings/cycublas.pxd +684 -0
  75. nvmath/bindings/cycublasLt.cp314-win_amd64.pyd +0 -0
  76. nvmath/bindings/cycublasLt.pxd +1055 -0
  77. nvmath/bindings/cycublasMp.pxd +183 -0
  78. nvmath/bindings/cycudss.cp314-win_amd64.pyd +0 -0
  79. nvmath/bindings/cycudss.pxd +224 -0
  80. nvmath/bindings/cycufft.cp314-win_amd64.pyd +0 -0
  81. nvmath/bindings/cycufft.pxd +326 -0
  82. nvmath/bindings/cycufftMp.pxd +334 -0
  83. nvmath/bindings/cycurand.cp314-win_amd64.pyd +0 -0
  84. nvmath/bindings/cycurand.pxd +146 -0
  85. nvmath/bindings/cycusolver.cp314-win_amd64.pyd +0 -0
  86. nvmath/bindings/cycusolver.pxd +154 -0
  87. nvmath/bindings/cycusolverDn.cp314-win_amd64.pyd +0 -0
  88. nvmath/bindings/cycusolverDn.pxd +446 -0
  89. nvmath/bindings/cycusparse.cp314-win_amd64.pyd +0 -0
  90. nvmath/bindings/cycusparse.pxd +470 -0
  91. nvmath/bindings/cycusparseLt.cp314-win_amd64.pyd +0 -0
  92. nvmath/bindings/cycusparseLt.pxd +150 -0
  93. nvmath/bindings/cycutensor.cp314-win_amd64.pyd +0 -0
  94. nvmath/bindings/cycutensor.pxd +192 -0
  95. nvmath/bindings/cymathdx.cp314-win_amd64.pyd +0 -0
  96. nvmath/bindings/cymathdx.pxd +552 -0
  97. nvmath/bindings/cynvshmem.pxd +126 -0
  98. nvmath/bindings/mathdx.cp314-win_amd64.pyd +0 -0
  99. nvmath/bindings/mathdx.pxd +182 -0
  100. nvmath/bindings/mathdx.pyi +1244 -0
  101. nvmath/bindings/nvpl/__init__.pxd +0 -0
  102. nvmath/bindings/nvpl/__init__.py +13 -0
  103. nvmath/bindings/nvpl/_internal/__init__.pxd +0 -0
  104. nvmath/bindings/nvpl/_internal/__init__.py +0 -0
  105. nvmath/bindings/nvpl/_internal/blas.cp314-win_amd64.pyd +0 -0
  106. nvmath/bindings/nvpl/_internal/blas.pxd +125 -0
  107. nvmath/bindings/nvpl/_internal/fft.cp314-win_amd64.pyd +0 -0
  108. nvmath/bindings/nvpl/_internal/fft.pxd +36 -0
  109. nvmath/bindings/nvpl/blas.cp314-win_amd64.pyd +0 -0
  110. nvmath/bindings/nvpl/blas.pxd +85 -0
  111. nvmath/bindings/nvpl/blas.pyi +122 -0
  112. nvmath/bindings/nvpl/cyblas.cp314-win_amd64.pyd +0 -0
  113. nvmath/bindings/nvpl/cyblas.pxd +166 -0
  114. nvmath/bindings/nvpl/cyfft.cp314-win_amd64.pyd +0 -0
  115. nvmath/bindings/nvpl/cyfft.pxd +92 -0
  116. nvmath/bindings/nvpl/fft.cp314-win_amd64.pyd +0 -0
  117. nvmath/bindings/nvpl/fft.pxd +100 -0
  118. nvmath/bindings/nvpl/fft.pyi +100 -0
  119. nvmath/bindings/nvshmem.pxd +54 -0
  120. nvmath/bindings/nvshmem.pyi +179 -0
  121. nvmath/device/__init__.py +21 -0
  122. nvmath/device/_deprecated.py +33 -0
  123. nvmath/device/common.py +313 -0
  124. nvmath/device/common_backend.py +131 -0
  125. nvmath/device/common_cuda.py +201 -0
  126. nvmath/device/common_numba.py +310 -0
  127. nvmath/device/common_opaque_tensor.py +201 -0
  128. nvmath/device/cublasdx.py +1805 -0
  129. nvmath/device/cublasdx_backend.py +807 -0
  130. nvmath/device/cublasdx_numba.py +1612 -0
  131. nvmath/device/cufftdx.py +510 -0
  132. nvmath/device/cufftdx_backend.py +196 -0
  133. nvmath/device/cufftdx_numba.py +196 -0
  134. nvmath/device/curand_kernel.py +9147 -0
  135. nvmath/device/cusolverdx.py +2690 -0
  136. nvmath/device/cusolverdx_backend.py +440 -0
  137. nvmath/device/cusolverdx_numba.py +1624 -0
  138. nvmath/device/llvm_array.py +29 -0
  139. nvmath/device/random.py +445 -0
  140. nvmath/device/random_helpers.py +23 -0
  141. nvmath/device/random_states.py +187 -0
  142. nvmath/device/types.py +147 -0
  143. nvmath/device/vector_types_numba.py +203 -0
  144. nvmath/distributed/__init__.py +205 -0
  145. nvmath/distributed/_internal/__init__.py +0 -0
  146. nvmath/distributed/_internal/nvshmem.py +302 -0
  147. nvmath/distributed/_internal/tensor_ifc.py +67 -0
  148. nvmath/distributed/_internal/tensor_ifc_cupy.py +62 -0
  149. nvmath/distributed/_internal/tensor_ifc_host_device.py +165 -0
  150. nvmath/distributed/_internal/tensor_ifc_numpy.py +41 -0
  151. nvmath/distributed/_internal/tensor_ifc_torch.py +141 -0
  152. nvmath/distributed/_internal/tensor_wrapper.py +78 -0
  153. nvmath/distributed/_utils.py +167 -0
  154. nvmath/distributed/distribution.py +770 -0
  155. nvmath/distributed/fft/__init__.py +7 -0
  156. nvmath/distributed/fft/_configuration.py +79 -0
  157. nvmath/distributed/fft/fft.py +2801 -0
  158. nvmath/distributed/linalg/__init__.py +12 -0
  159. nvmath/distributed/linalg/_internal/__init__.py +3 -0
  160. nvmath/distributed/linalg/_internal/epilog_protocol.py +496 -0
  161. nvmath/distributed/linalg/_internal/matmul_desc_ifc.py +28 -0
  162. nvmath/distributed/linalg/advanced/__init__.py +8 -0
  163. nvmath/distributed/linalg/advanced/_configuration.py +166 -0
  164. nvmath/distributed/linalg/advanced/matmulmod.py +2908 -0
  165. nvmath/distributed/process_group.py +408 -0
  166. nvmath/distributed/reshape/__init__.py +6 -0
  167. nvmath/distributed/reshape/_configuration.py +39 -0
  168. nvmath/distributed/reshape/reshape.py +1256 -0
  169. nvmath/fft/__init__.py +7 -0
  170. nvmath/fft/_configuration.py +208 -0
  171. nvmath/fft/_exec_utils.py +109 -0
  172. nvmath/fft/_helpers.py +237 -0
  173. nvmath/fft/fft.py +2903 -0
  174. nvmath/internal/__init__.pxd +3 -0
  175. nvmath/internal/__init__.py +10 -0
  176. nvmath/internal/_bindings.cp314-win_amd64.pyd +0 -0
  177. nvmath/internal/_bindings.pxd +12 -0
  178. nvmath/internal/_device_utils.py +54 -0
  179. nvmath/internal/enum_utils.py +142 -0
  180. nvmath/internal/formatters.py +87 -0
  181. nvmath/internal/mem_limit.py +51 -0
  182. nvmath/internal/memory.cp314-win_amd64.pyd +0 -0
  183. nvmath/internal/memory.pxd +10 -0
  184. nvmath/internal/memory.pyi +46 -0
  185. nvmath/internal/ndbuffer/__init__.pxd +3 -0
  186. nvmath/internal/ndbuffer/__init__.py +7 -0
  187. nvmath/internal/ndbuffer/copy_kernel/args.h +34 -0
  188. nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/array_view.h +52 -0
  189. nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/elementwise.h +68 -0
  190. nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/grid_indexer.h +69 -0
  191. nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/transposed.h +240 -0
  192. nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/type_utils.h +39 -0
  193. nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/utils.h +132 -0
  194. nvmath/internal/ndbuffer/copy_kernel/copy_kernel_impl/vec.h +159 -0
  195. nvmath/internal/ndbuffer/copy_kernel/elementwise.h +53 -0
  196. nvmath/internal/ndbuffer/copy_kernel/transposed.h +58 -0
  197. nvmath/internal/ndbuffer/copy_kernel.cp314-win_amd64.pyd +0 -0
  198. nvmath/internal/ndbuffer/copy_kernel.pxd +9 -0
  199. nvmath/internal/ndbuffer/copy_kernel.pyi +9 -0
  200. nvmath/internal/ndbuffer/data_layout.cp314-win_amd64.pyd +0 -0
  201. nvmath/internal/ndbuffer/data_layout.pxd +72 -0
  202. nvmath/internal/ndbuffer/data_layout.pyi +23 -0
  203. nvmath/internal/ndbuffer/jit.cp314-win_amd64.pyd +0 -0
  204. nvmath/internal/ndbuffer/jit.pxd +7 -0
  205. nvmath/internal/ndbuffer/jit.pyi +6 -0
  206. nvmath/internal/ndbuffer/ndbuffer.cp314-win_amd64.pyd +0 -0
  207. nvmath/internal/ndbuffer/ndbuffer.pxd +36 -0
  208. nvmath/internal/ndbuffer/ndbuffer.pyi +41 -0
  209. nvmath/internal/ndbuffer/package_utils.cp314-win_amd64.pyd +0 -0
  210. nvmath/internal/ndbuffer/package_utils.pxd +11 -0
  211. nvmath/internal/ndbuffer/package_utils.pyi +12 -0
  212. nvmath/internal/package_ifc.py +147 -0
  213. nvmath/internal/package_ifc_cuda.py +49 -0
  214. nvmath/internal/package_ifc_cupy.py +49 -0
  215. nvmath/internal/package_ifc_torch.py +31 -0
  216. nvmath/internal/package_wrapper.py +14 -0
  217. nvmath/internal/tensor_ifc.py +194 -0
  218. nvmath/internal/tensor_ifc_cupy.py +241 -0
  219. nvmath/internal/tensor_ifc_ndbuffer.py +153 -0
  220. nvmath/internal/tensor_ifc_numpy.py +183 -0
  221. nvmath/internal/tensor_ifc_torch.py +176 -0
  222. nvmath/internal/tensor_wrapper.py +157 -0
  223. nvmath/internal/typemaps.py +162 -0
  224. nvmath/internal/utils.py +771 -0
  225. nvmath/linalg/__init__.py +46 -0
  226. nvmath/linalg/_internal/__init__.py +3 -0
  227. nvmath/linalg/_internal/algo_cap_ifc.py +82 -0
  228. nvmath/linalg/_internal/algo_config_ifc.py +43 -0
  229. nvmath/linalg/_internal/batch.py +217 -0
  230. nvmath/linalg/_internal/enum_to_tuples.py +64 -0
  231. nvmath/linalg/_internal/epilog_protocol.py +766 -0
  232. nvmath/linalg/_internal/layout.py +624 -0
  233. nvmath/linalg/_internal/matmul_desc_ifc.py +28 -0
  234. nvmath/linalg/_internal/matmul_pref_ifc.py +27 -0
  235. nvmath/linalg/_internal/matrix_layout_ifc.py +26 -0
  236. nvmath/linalg/_internal/typemaps.py +144 -0
  237. nvmath/linalg/_internal/utils.py +134 -0
  238. nvmath/linalg/advanced/__init__.py +8 -0
  239. nvmath/linalg/advanced/_algorithmmod.py +149 -0
  240. nvmath/linalg/advanced/_configuration.py +349 -0
  241. nvmath/linalg/advanced/helpers/__init__.py +5 -0
  242. nvmath/linalg/advanced/helpers/matmul.py +1348 -0
  243. nvmath/linalg/advanced/matmulmod.py +3937 -0
  244. nvmath/linalg/generic/__init__.py +43 -0
  245. nvmath/linalg/generic/_configuration/__init__.py +37 -0
  246. nvmath/linalg/generic/_configuration/layout.py +263 -0
  247. nvmath/linalg/generic/_configuration/match.py +609 -0
  248. nvmath/linalg/generic/_configuration/qualifiers.py +494 -0
  249. nvmath/linalg/generic/_configuration/wrap.py +217 -0
  250. nvmath/linalg/generic/_dtype.py +15 -0
  251. nvmath/linalg/generic/matmulmod.py +1060 -0
  252. nvmath/memory.py +282 -0
  253. nvmath/sparse/__init__.py +38 -0
  254. nvmath/sparse/_internal/__init__.py +21 -0
  255. nvmath/sparse/_internal/common_utils.py +144 -0
  256. nvmath/sparse/_internal/cudss_config_ifc.py +741 -0
  257. nvmath/sparse/_internal/cudss_data_ifc.py +399 -0
  258. nvmath/sparse/_internal/cudss_utils.py +445 -0
  259. nvmath/sparse/_internal/cusparse_utils.py +382 -0
  260. nvmath/sparse/_internal/sparse_bsc_ifc.py +300 -0
  261. nvmath/sparse/_internal/sparse_bsr_ifc.py +303 -0
  262. nvmath/sparse/_internal/sparse_coo_ifc.py +254 -0
  263. nvmath/sparse/_internal/sparse_csc_ifc.py +266 -0
  264. nvmath/sparse/_internal/sparse_csr_ifc.py +266 -0
  265. nvmath/sparse/_internal/sparse_dia_ifc.py +239 -0
  266. nvmath/sparse/_internal/sparse_format_helpers.py +601 -0
  267. nvmath/sparse/_internal/sparse_tensor_ifc.py +121 -0
  268. nvmath/sparse/_internal/sparse_ust_ifc.py +146 -0
  269. nvmath/sparse/_internal/utils.py +56 -0
  270. nvmath/sparse/advanced/__init__.py +7 -0
  271. nvmath/sparse/advanced/_configuration.py +230 -0
  272. nvmath/sparse/advanced/direct_solver.py +1884 -0
  273. nvmath/sparse/generic/__init__.py +7 -0
  274. nvmath/sparse/generic/_configuration.py +129 -0
  275. nvmath/sparse/generic/_helpers.py +137 -0
  276. nvmath/sparse/generic/_thunks.py +21 -0
  277. nvmath/sparse/generic/matmulmod.py +2426 -0
  278. nvmath/sparse/ust/__init__.py +7 -0
  279. nvmath/sparse/ust/_converters.py +378 -0
  280. nvmath/sparse/ust/_drawer.py +552 -0
  281. nvmath/sparse/ust/_emitter.py +553 -0
  282. nvmath/sparse/ust/_jit.py +212 -0
  283. nvmath/sparse/ust/_kernel.py +346 -0
  284. nvmath/sparse/ust/_semiring.py +71 -0
  285. nvmath/sparse/ust/_utils.py +102 -0
  286. nvmath/sparse/ust/interfaces/__init__.py +0 -0
  287. nvmath/sparse/ust/interfaces/torch_interface.py +476 -0
  288. nvmath/sparse/ust/semiring_ops.py +71 -0
  289. nvmath/sparse/ust/tensor.py +1027 -0
  290. nvmath/sparse/ust/tensor_drawer.py +552 -0
  291. nvmath/sparse/ust/tensor_emitter.py +558 -0
  292. nvmath/sparse/ust/tensor_format.py +935 -0
  293. nvmath/sparse/ust/tensor_jit.py +212 -0
  294. nvmath/sparse/ust/tensor_kernel.py +348 -0
  295. nvmath/sparse/ust/tensor_utils.py +380 -0
  296. nvmath/tensor/__init__.py +6 -0
  297. nvmath/tensor/_configuration.py +95 -0
  298. nvmath/tensor/_internal/__init__.py +3 -0
  299. nvmath/tensor/_internal/cutensor_config_ifc.py +247 -0
  300. nvmath/tensor/_internal/cutensor_utils.py +162 -0
  301. nvmath/tensor/_internal/data.py +43 -0
  302. nvmath/tensor/_internal/einsum_parser.py +444 -0
  303. nvmath/tensor/_internal/typemaps.py +96 -0
  304. nvmath/tensor/contract.py +1861 -0
  305. nvmath_python-0.9.0.dist-info/METADATA +127 -0
  306. nvmath_python-0.9.0.dist-info/RECORD +309 -0
  307. nvmath_python-0.9.0.dist-info/WHEEL +5 -0
  308. nvmath_python-0.9.0.dist-info/licenses/LICENSE +177 -0
  309. nvmath_python-0.9.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,741 @@
1
+ # Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """
6
+ Interface classes to encapsulate low-level calls to get or set configuration information.
7
+ """
8
+
9
+ __all__ = ["FactorizationConfig", "PlanConfig", "SolutionConfig"]
10
+
11
+ import re
12
+ import threading
13
+ from typing import TypeAlias
14
+
15
+ import numpy as np
16
+
17
+ from nvmath.bindings import cudss
18
+ from nvmath.internal import utils
19
+
20
+ ConfigParamEnum: TypeAlias = cudss.ConfigParam
21
+
22
+ # Future-proofing - cuDSS is currently not thread-safe.
23
+ # https://docs.nvidia.com/cuda/cudss/general.html#thread-safety
24
+ _tls = threading.local()
25
+ _tls.size_written = np.empty((1,), dtype=np.uint64)
26
+
27
+
28
+ def _get_scalar_attribute(config_ptr, name, attribute):
29
+ """
30
+ name = cudss enumerator for the attribute.
31
+ attribute = numpy ndarray object into which the value is stored.
32
+ """
33
+ cudss.config_get(config_ptr, name, attribute.ctypes.data, attribute.dtype.itemsize, _tls.size_written.ctypes.data)
34
+ assert _tls.size_written[0] <= attribute.dtype.itemsize, "Internal error."
35
+
36
+
37
+ def _set_scalar_attribute(config_ptr, name, attribute, value):
38
+ """
39
+ name = cudss enumerator for the attribute.
40
+ attribute = numpy ndarray object into which the value is stored.
41
+ value = the value to set the attribute to.
42
+ """
43
+ attribute[0] = value
44
+ cudss.config_set(config_ptr, name, attribute.ctypes.data, attribute.dtype.itemsize)
45
+
46
+
47
+ def _check_valid_solver(config):
48
+ """
49
+ Check if the configuration points to a valid DirectSolver object.
50
+ """
51
+ if not config._solver.valid_state:
52
+ m = re.match(r"<nvmath\..*\.(.*Config) object at (.*)>$", str(config))
53
+ assert m is not None, "Internal error."
54
+ name = m.group(1)
55
+ address = m.group(2)
56
+
57
+ raise RuntimeError(f"The {name} object at {address} cannot be used after its solver object is free'd.")
58
+
59
+
60
+ # TODO: Set user permutation as part of PlanConfig, even though it sets the data object.
61
+ class PlanConfig:
62
+ """
63
+ An interface to configure :meth:`nvmath.sparse.advanced.DirectSolver.plan`. The
64
+ current configuration can also be queried.
65
+ """
66
+
67
+ __slots__ = (
68
+ "_solver",
69
+ "_config_ptr",
70
+ "_host_nthreads",
71
+ "_reordering_alg",
72
+ "_pivot_type",
73
+ "_pivot_threshold",
74
+ "_max_lu_nnz",
75
+ "_use_matching",
76
+ "_matching_alg",
77
+ "_nd_nlevels",
78
+ "_use_superpanels",
79
+ )
80
+
81
+ def __init__(self, solver):
82
+ """
83
+ ctor for internal use only.
84
+ """
85
+ self._solver = solver
86
+ self._config_ptr = self._solver.config_ptr
87
+ assert self._config_ptr is not None, "Internal error"
88
+
89
+ get_dtype = cudss.get_config_param_dtype
90
+
91
+ self._host_nthreads = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HOST_NTHREADS))
92
+ self._reordering_alg = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.REORDERING_ALG))
93
+ self._pivot_type = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.PIVOT_TYPE))
94
+ self._pivot_threshold = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.PIVOT_THRESHOLD))
95
+ self._max_lu_nnz = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.MAX_LU_NNZ))
96
+ self._use_matching = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.USE_MATCHING))
97
+ self._matching_alg = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.MATCHING_ALG))
98
+ self._nd_nlevels = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.ND_NLEVELS))
99
+ self._use_superpanels = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.USE_SUPERPANELS))
100
+
101
+ def _check_valid_solver_wrapper(self, *args, **kwargs):
102
+ _check_valid_solver(self)
103
+
104
+ @property
105
+ @utils.precondition(_check_valid_solver_wrapper)
106
+ def host_nthreads(self):
107
+ """
108
+ Query or set the number of host threads. See the
109
+ `cuDSS documentation
110
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
111
+ for more information.
112
+ """
113
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.HOST_NTHREADS, self._host_nthreads)
114
+
115
+ return self._host_nthreads.item()
116
+
117
+ @host_nthreads.setter
118
+ @utils.precondition(_check_valid_solver_wrapper)
119
+ def host_nthreads(self, nthreads):
120
+ """
121
+ Set the number of host threads. See the
122
+ `cuDSS documentation
123
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
124
+ for more information.
125
+
126
+ Args:
127
+ nthreads: The number of host threads as Python `int`.
128
+
129
+ """
130
+ if not self._solver.multithreading:
131
+ raise ValueError(
132
+ "The number of host threads cannot be set if a multithreading library was not provided during problem \
133
+ specification."
134
+ )
135
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.HOST_NTHREADS, self._host_nthreads, nthreads)
136
+
137
+ @property
138
+ @utils.precondition(_check_valid_solver_wrapper)
139
+ def reordering_algorithm(self):
140
+ """
141
+ Query or set the reordering algorithm used. See
142
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
143
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
144
+ information.
145
+ """
146
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.REORDERING_ALG, self._reordering_alg)
147
+
148
+ return cudss.AlgType(self._reordering_alg.item())
149
+
150
+ @reordering_algorithm.setter
151
+ @utils.precondition(_check_valid_solver_wrapper)
152
+ def reordering_algorithm(self, algorithm):
153
+ """
154
+ Set the reordering algorithm to use. See :class:`nvmath.bindings.cudss.AlgType` and
155
+ the `cuDSS documentation
156
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
157
+ information.
158
+
159
+ Args:
160
+ algorithm: The reordering algorithm of type
161
+ :class:`nvmath.bindings.cudss.AlgType` or Python `int`.
162
+
163
+ """
164
+ algorithm = cudss.AlgType(algorithm)
165
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.REORDERING_ALG, self._reordering_alg, algorithm)
166
+
167
+ @property
168
+ @utils.precondition(_check_valid_solver_wrapper)
169
+ def matching_algorithm(self):
170
+ """
171
+ Query or set the matching algorithm used. See
172
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
173
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
174
+ information.
175
+ """
176
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.MATCHING_ALG, self._matching_alg)
177
+
178
+ return cudss.AlgType(self._matching_alg.item())
179
+
180
+ @matching_algorithm.setter
181
+ @utils.precondition(_check_valid_solver_wrapper)
182
+ def matching_algorithm(self, algorithm):
183
+ """
184
+ Set the matching algorithm to use. See :class:`nvmath.bindings.cudss.AlgType` and
185
+ the `cuDSS documentation
186
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
187
+ information.
188
+
189
+ Args:
190
+ algorithm: The matching algorithm of type
191
+ :class:`nvmath.bindings.cudss.AlgType` or Python `int`.
192
+
193
+ """
194
+ algorithm = cudss.AlgType(algorithm)
195
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.MATCHING_ALG, self._matching_alg, algorithm)
196
+
197
+ @property
198
+ @utils.precondition(_check_valid_solver_wrapper)
199
+ def pivot_type(self):
200
+ """
201
+ Query or set the type of pivoting. See
202
+ :class:`nvmath.bindings.cudss.PivotType` and the `cuDSS documentation
203
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
204
+ for more information.
205
+ """
206
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_TYPE, self._pivot_type)
207
+
208
+ return cudss.PivotType(self._pivot_type.item())
209
+
210
+ @pivot_type.setter
211
+ @utils.precondition(_check_valid_solver_wrapper)
212
+ def pivot_type(self, pivot_type):
213
+ """
214
+ Set the type of pivoting. See :class:`nvmath.bindings.cudss.PivotType` and the
215
+ `cuDSS documentation
216
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
217
+ information.
218
+
219
+ Args:
220
+ pivot_type: The type of pivoting (:class:`nvmath.bindings.cudss.PivotType` or
221
+ Python `int`).
222
+
223
+ """
224
+ pivot_type = cudss.PivotType(pivot_type)
225
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_TYPE, self._pivot_type, pivot_type)
226
+
227
+ @property
228
+ @utils.precondition(_check_valid_solver_wrapper)
229
+ def pivot_threshold(self):
230
+ """
231
+ Query or set the pivot threshold. See the
232
+ `cuDSS documentation
233
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
234
+ for more information.
235
+ """
236
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_THRESHOLD, self._pivot_threshold)
237
+
238
+ return self._pivot_threshold.item()
239
+
240
+ @pivot_threshold.setter
241
+ @utils.precondition(_check_valid_solver_wrapper)
242
+ def pivot_threshold(self, pivot_threshold):
243
+ """
244
+ Set the pivot threshold. See the
245
+ `cuDSS documentation
246
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
247
+ for more information.
248
+
249
+ Args:
250
+ pivot_threshold: The threshold for pivoting (Python `float`).
251
+
252
+ """
253
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_THRESHOLD, self._pivot_threshold, pivot_threshold)
254
+
255
+ @property
256
+ @utils.precondition(_check_valid_solver_wrapper)
257
+ def max_nnz(self):
258
+ """
259
+ Query or set the maximum limit for non-zero factors in the LU decomposition. See the
260
+ `cuDSS documentation
261
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
262
+ for more information.
263
+ """
264
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.MAX_LU_NNZ, self._max_lu_nnz)
265
+
266
+ return self._max_lu_nnz.item()
267
+
268
+ @max_nnz.setter
269
+ @utils.precondition(_check_valid_solver_wrapper)
270
+ def max_nnz(self, max_nnz):
271
+ """
272
+ Set the maximum limit for non-zero factors in the LU decomposition. See the
273
+ `cuDSS documentation
274
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
275
+ for more information.
276
+
277
+ Args:
278
+ max_nnz: The maximum limit for non-zero factors in the LU decomposition
279
+ (Python `int`).
280
+
281
+ """
282
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.MAX_LU_NNZ, self._max_lu_nnz, max_nnz)
283
+
284
+ @property
285
+ @utils.precondition(_check_valid_solver_wrapper)
286
+ def use_matching(self):
287
+ """
288
+ Query or set the option to enable or disable matching. See the
289
+ `cuDSS documentation
290
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
291
+ for more information.
292
+
293
+ .. note::
294
+ Matching is recommended for general sparse matrices as it typically
295
+ reduces pivot perturbations and improves solution accuracy with
296
+ minimal performance impact.
297
+ For symmetric positive definite (SPD) matrices, matching is unnecessary.
298
+ For symmetric indefinite matrices, the benefits of matching is unknown.
299
+
300
+ """
301
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.USE_MATCHING, self._use_matching)
302
+
303
+ return self._use_matching.item()
304
+
305
+ @use_matching.setter
306
+ @utils.precondition(_check_valid_solver_wrapper)
307
+ def use_matching(self, matching_flag):
308
+ """
309
+ Set the option to enable or disable matching. See the
310
+ `cuDSS documentation
311
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
312
+ for more information.
313
+
314
+ Args:
315
+ matching_flag: The flag to enable or disable matching (Python `int`
316
+ or `bool`, 0 to disable).
317
+
318
+ """
319
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.USE_MATCHING, self._use_matching, matching_flag)
320
+
321
+ @property
322
+ @utils.precondition(_check_valid_solver_wrapper)
323
+ def nd_min_levels(self):
324
+ """
325
+ Query or set the minimum number of levels for the nested dissection reordering. See
326
+ the `cuDSS documentation
327
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
328
+ for more information.
329
+ """
330
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.ND_NLEVELS, self._nd_nlevels)
331
+
332
+ return self._nd_nlevels.item()
333
+
334
+ @nd_min_levels.setter
335
+ @utils.precondition(_check_valid_solver_wrapper)
336
+ def nd_min_levels(self, min_levels):
337
+ """
338
+ Set the minimum number of levels for the nested dissection reordering. See the
339
+ `cuDSS documentation
340
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
341
+ for more information.
342
+
343
+ Args:
344
+ min_levels: The minimum number of levels for the nested dissection reordering
345
+ (Python `int`).
346
+
347
+ """
348
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.ND_NLEVELS, self._nd_nlevels, min_levels)
349
+
350
+ @property
351
+ @utils.precondition(_check_valid_solver_wrapper)
352
+ def use_superpanels(self):
353
+ """
354
+ Query or set the option to enable or disable superpanel optimization. See the
355
+ `cuDSS documentation
356
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
357
+ for more information.
358
+ """
359
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.USE_SUPERPANELS, self._use_superpanels)
360
+
361
+ return self._use_superpanels.item()
362
+
363
+ @use_superpanels.setter
364
+ @utils.precondition(_check_valid_solver_wrapper)
365
+ def use_superpanels(self, superpanels_flag):
366
+ """
367
+ Set the option to enable or disable superpanel optimization. See the
368
+ `cuDSS documentation
369
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
370
+ for more information.
371
+
372
+ Args:
373
+ superpanels_flag: The flag to enable or disable superpanel optimization
374
+ (Python `int` or `bool`, 0 to disable).
375
+
376
+ """
377
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.USE_SUPERPANELS, self._use_superpanels, superpanels_flag)
378
+
379
+
380
+ class FactorizationConfig:
381
+ """
382
+ An interface to configure :meth:`nvmath.sparse.advanced.DirectSolver.factorize`. The
383
+ current configuration can also be queried.
384
+ """
385
+
386
+ __slots__ = (
387
+ "_solver",
388
+ "_config_ptr",
389
+ "_factorization_alg",
390
+ "_pivot_epsilon_alg",
391
+ "_pivot_epsilon",
392
+ )
393
+
394
+ def __init__(self, solver):
395
+ """
396
+ ctor for internal use only.
397
+ """
398
+ self._solver = solver
399
+ self._config_ptr = self._solver.config_ptr
400
+ assert self._config_ptr is not None, "Internal error"
401
+
402
+ get_dtype = cudss.get_config_param_dtype
403
+
404
+ self._factorization_alg = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.FACTORIZATION_ALG))
405
+ self._pivot_epsilon_alg = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.PIVOT_EPSILON_ALG))
406
+ self._pivot_epsilon = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.PIVOT_EPSILON))
407
+
408
+ def _check_valid_solver_wrapper(self, *args, **kwargs):
409
+ _check_valid_solver(self)
410
+
411
+ @property
412
+ @utils.precondition(_check_valid_solver_wrapper)
413
+ def factorization_algorithm(self):
414
+ """
415
+ Query or set the factorization algorithm used. See
416
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
417
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
418
+ information.
419
+ """
420
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.FACTORIZATION_ALG, self._factorization_alg)
421
+
422
+ return cudss.AlgType(self._factorization_alg.item())
423
+
424
+ @factorization_algorithm.setter
425
+ @utils.precondition(_check_valid_solver_wrapper)
426
+ def factorization_algorithm(self, algorithm):
427
+ """
428
+ Set the factorization algorithm to use. See :class:`nvmath.bindings.cudss.AlgType`
429
+ and the `cuDSS documentation
430
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
431
+ information.
432
+
433
+ Args:
434
+ algorithm: The factorization algorithm of type
435
+ :class:`nvmath.bindings.cudss.AlgType` or Python `int`.
436
+
437
+ """
438
+ algorithm = cudss.AlgType(algorithm)
439
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.FACTORIZATION_ALG, self._factorization_alg, algorithm)
440
+
441
+ @property
442
+ @utils.precondition(_check_valid_solver_wrapper)
443
+ def pivot_eps_algorithm(self):
444
+ """
445
+ Query or set the algorithm used for pivot epsilon calculation. See
446
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
447
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
448
+ information.
449
+ """
450
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_EPSILON_ALG, self._pivot_epsilon_alg)
451
+
452
+ return cudss.AlgType(self._pivot_epsilon_alg.item())
453
+
454
+ @pivot_eps_algorithm.setter
455
+ @utils.precondition(_check_valid_solver_wrapper)
456
+ def pivot_eps_algorithm(self, algorithm):
457
+ """
458
+ Set the algorithm to use for pivot epsilon calculation. See
459
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
460
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
461
+ information.
462
+
463
+ Args:
464
+ algorithm: The pivot epsilon algorithm of type
465
+ :class:`nvmath.bindings.cudss.AlgType` or Python `int`.
466
+
467
+ """
468
+ algorithm = cudss.AlgType(algorithm)
469
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_EPSILON_ALG, self._pivot_epsilon_alg, algorithm)
470
+
471
+ @property
472
+ @utils.precondition(_check_valid_solver_wrapper)
473
+ def pivot_eps(self):
474
+ """
475
+ Query or set the pivot epsilon value. See the
476
+ `cuDSS documentation
477
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
478
+ for more information.
479
+ """
480
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_EPSILON, self._pivot_epsilon)
481
+
482
+ return self._pivot_epsilon.item()
483
+
484
+ @pivot_eps.setter
485
+ @utils.precondition(_check_valid_solver_wrapper)
486
+ def pivot_eps(self, epsilon):
487
+ """
488
+ Set the pivot epsilon value. See the
489
+ `cuDSS documentation
490
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
491
+ for more information.
492
+
493
+ Args:
494
+ epsilon: The pivot epsilon value (Python numerical type).
495
+
496
+ """
497
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_EPSILON, self._pivot_epsilon, epsilon)
498
+
499
+
500
+ class SolutionConfig:
501
+ """
502
+ An interface to configure :meth:`nvmath.sparse.advanced.DirectSolver.solve`. The
503
+ current configuration can also be queried.
504
+ """
505
+
506
+ __slots__ = (
507
+ "_solver",
508
+ "_config_ptr",
509
+ "_solve_alg",
510
+ "_ir_n_steps",
511
+ )
512
+
513
+ def __init__(self, solver):
514
+ """
515
+ ctor for internal use only.
516
+ """
517
+ self._solver = solver
518
+ self._config_ptr = self._solver.config_ptr
519
+ assert self._config_ptr is not None, "Internal error"
520
+
521
+ get_dtype = cudss.get_config_param_dtype
522
+
523
+ self._solve_alg = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.SOLVE_ALG))
524
+ self._ir_n_steps = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.IR_N_STEPS))
525
+
526
+ def _check_valid_solver_wrapper(self, *args, **kwargs):
527
+ _check_valid_solver(self)
528
+
529
+ @property
530
+ @utils.precondition(_check_valid_solver_wrapper)
531
+ def solution_algorithm(self):
532
+ """
533
+ Query or set the solution algorithm used. See
534
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
535
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
536
+ information.
537
+ """
538
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.SOLVE_ALG, self._solve_alg)
539
+
540
+ return cudss.AlgType(self._solve_alg.item())
541
+
542
+ @solution_algorithm.setter
543
+ @utils.precondition(_check_valid_solver_wrapper)
544
+ def solution_algorithm(self, algorithm):
545
+ """
546
+ Set the algorithm to use for solving. See :class:`nvmath.bindings.cudss.AlgType` and
547
+ the `cuDSS documentation
548
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
549
+ information.
550
+
551
+ Args:
552
+ algorithm: The solution algorithm of type :class:`nvmath.bindings.cudss.AlgType`
553
+ or Python `int`.
554
+
555
+ """
556
+ algorithm = cudss.AlgType(algorithm)
557
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.SOLVE_ALG, self._solve_alg, algorithm)
558
+
559
+ @property
560
+ @utils.precondition(_check_valid_solver_wrapper)
561
+ def ir_num_steps(self):
562
+ """
563
+ Query or set the number of steps used for iterative refinement. See the
564
+ `cuDSS documentation
565
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
566
+ for more information.
567
+ """
568
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.IR_N_STEPS, self._ir_n_steps)
569
+
570
+ return self._ir_n_steps.item()
571
+
572
+ @ir_num_steps.setter
573
+ @utils.precondition(_check_valid_solver_wrapper)
574
+ def ir_num_steps(self, num_steps):
575
+ """
576
+ Set the number of steps to use for iterative refinement. See the
577
+ `cuDSS documentation
578
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
579
+ for more information.
580
+
581
+ Args:
582
+ num_steps: The number of steps to use for iterative refinement as a
583
+ Python `int`.
584
+
585
+ """
586
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.IR_N_STEPS, self._ir_n_steps, num_steps)
587
+
588
+
589
+ class InternalConfig:
590
+ """
591
+ Interface class for internal use only. No precondition for `@property` since this is
592
+ used in the ctor before `solver.valid_state` is set.
593
+ """
594
+
595
+ def __init__(self, solver):
596
+ """
597
+ ctor for internal use only.
598
+ """
599
+ self._solver = solver
600
+ self._config_ptr = self._solver.config_ptr
601
+ assert self._config_ptr is not None, "Internal error"
602
+
603
+ get_dtype = cudss.get_config_param_dtype
604
+
605
+ self._hybrid_mode = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HYBRID_MODE))
606
+ self._hybrid_device_memory_limit = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HYBRID_DEVICE_MEMORY_LIMIT))
607
+ self._use_cuda_register_memory = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.USE_CUDA_REGISTER_MEMORY))
608
+ self._host_nthreads = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HOST_NTHREADS))
609
+ self._hybrid_execute_mode = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HYBRID_EXECUTE_MODE))
610
+
611
+ @property
612
+ def hybrid_mode(self):
613
+ """
614
+ Query or set the hybrid memory mode. See the
615
+ `cuDSS documentation
616
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
617
+ for more information.
618
+ """
619
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.HYBRID_MODE, self._hybrid_mode)
620
+
621
+ return self._hybrid_mode.item()
622
+
623
+ @hybrid_mode.setter
624
+ def hybrid_mode(self, mode):
625
+ """
626
+ Set the hybrid memory mode. See the
627
+ `cuDSS documentation
628
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
629
+ for more information.
630
+
631
+ Args:
632
+ mode: The hybrid memory mode as Python `int` (0=device or 1=hybrid).
633
+
634
+ """
635
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.HYBRID_MODE, self._hybrid_mode, mode)
636
+
637
+ @property
638
+ def hybrid_device_memory_limit(self):
639
+ """
640
+ Query or set the hybrid device memory limit. See the
641
+ `cuDSS documentation
642
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
643
+ for more information.
644
+ """
645
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.HYBRID_DEVICE_MEMORY_LIMIT, self._hybrid_device_memory_limit)
646
+
647
+ return self._hybrid_device_memory_limit.item()
648
+
649
+ @hybrid_device_memory_limit.setter
650
+ def hybrid_device_memory_limit(self, limit):
651
+ """
652
+ Set the hybrid device memory limit. See the
653
+ `cuDSS documentation
654
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
655
+ for more information.
656
+
657
+ Args:
658
+ limit: The hybrid memory limit as Python `int`.
659
+
660
+ """
661
+ _set_scalar_attribute(
662
+ self._config_ptr, ConfigParamEnum.HYBRID_DEVICE_MEMORY_LIMIT, self._hybrid_device_memory_limit, limit
663
+ )
664
+
665
+ @property
666
+ def use_cuda_register_memory(self):
667
+ """
668
+ Query or set the CUDA memory registration flag. See the
669
+ `cuDSS documentation
670
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
671
+ for more information.
672
+ """
673
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.USE_CUDA_REGISTER_MEMORY, self._use_cuda_register_memory)
674
+
675
+ return self._use_cuda_register_memory.item()
676
+
677
+ @use_cuda_register_memory.setter
678
+ def use_cuda_register_memory(self, flag):
679
+ """
680
+ Set the CUDA memory registration flag. See the
681
+ `cuDSS documentation
682
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
683
+ for more information.
684
+
685
+ Args:
686
+ flag: The memory registration flag as Python `int` (0 or 1).
687
+
688
+ """
689
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.USE_CUDA_REGISTER_MEMORY, self._use_cuda_register_memory, flag)
690
+
691
+ @property
692
+ def host_nthreads(self):
693
+ """
694
+ Query or set the number of host threads. See the
695
+ `cuDSS documentation
696
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
697
+ for more information.
698
+ """
699
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.HOST_NTHREADS, self._host_nthreads)
700
+
701
+ return self._host_nthreads.item()
702
+
703
+ @host_nthreads.setter
704
+ def host_nthreads(self, nthreads):
705
+ """
706
+ Set the number of host threads. See the
707
+ `cuDSS documentation
708
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
709
+ for more information.
710
+
711
+ Args:
712
+ nthreads: The number of host threads as Python `int`.
713
+
714
+ """
715
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.HOST_NTHREADS, self._host_nthreads, nthreads)
716
+
717
+ @property
718
+ def hybrid_execute_mode(self):
719
+ """
720
+ Query or set the hybrid execution mode. See the
721
+ `cuDSS documentation
722
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
723
+ for more information.
724
+ """
725
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.HYBRID_EXECUTE_MODE, self._hybrid_execute_mode)
726
+
727
+ return self._hybrid_execute_mode.item()
728
+
729
+ @hybrid_execute_mode.setter
730
+ def hybrid_execute_mode(self, mode):
731
+ """
732
+ Set the hybrid execution mode. See the
733
+ `cuDSS documentation
734
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
735
+ for more information.
736
+
737
+ Args:
738
+ mode: The hybrid execution mode as Python `int` (0=device or 1=hybrid).
739
+
740
+ """
741
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.HYBRID_EXECUTE_MODE, self._hybrid_execute_mode, mode)