nvmath-python 0.5.0__cp313-cp313-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 (174) hide show
  1. nvmath/__init__.pxd +0 -0
  2. nvmath/__init__.py +37 -0
  3. nvmath/_internal/__init__.py +0 -0
  4. nvmath/_internal/layout.py +58 -0
  5. nvmath/_utils.py +363 -0
  6. nvmath/bindings/__init__.pxd +0 -0
  7. nvmath/bindings/__init__.py +44 -0
  8. nvmath/bindings/_internal/__init__.pxd +0 -0
  9. nvmath/bindings/_internal/__init__.py +0 -0
  10. nvmath/bindings/_internal/cublas.cp313-win_amd64.pyd +0 -0
  11. nvmath/bindings/_internal/cublas.pxd +518 -0
  12. nvmath/bindings/_internal/cublasLt.cp313-win_amd64.pyd +0 -0
  13. nvmath/bindings/_internal/cublasLt.pxd +54 -0
  14. nvmath/bindings/_internal/cudss.cp313-win_amd64.pyd +0 -0
  15. nvmath/bindings/_internal/cudss.pxd +44 -0
  16. nvmath/bindings/_internal/cufft.cp313-win_amd64.pyd +0 -0
  17. nvmath/bindings/_internal/cufft.pxd +69 -0
  18. nvmath/bindings/_internal/cufftMp.pxd +77 -0
  19. nvmath/bindings/_internal/curand.cp313-win_amd64.pyd +0 -0
  20. nvmath/bindings/_internal/curand.pxd +42 -0
  21. nvmath/bindings/_internal/cusolver.cp313-win_amd64.pyd +0 -0
  22. nvmath/bindings/_internal/cusolver.pxd +15 -0
  23. nvmath/bindings/_internal/cusolverDn.cp313-win_amd64.pyd +0 -0
  24. nvmath/bindings/_internal/cusolverDn.pxd +386 -0
  25. nvmath/bindings/_internal/cusparse.cp313-win_amd64.pyd +0 -0
  26. nvmath/bindings/_internal/cusparse.pxd +270 -0
  27. nvmath/bindings/_internal/mathdx.cp313-win_amd64.pyd +0 -0
  28. nvmath/bindings/_internal/mathdx.pxd +79 -0
  29. nvmath/bindings/_internal/nvshmem.pxd +29 -0
  30. nvmath/bindings/_internal/utils.cp313-win_amd64.pyd +0 -0
  31. nvmath/bindings/_internal/utils.pxd +186 -0
  32. nvmath/bindings/cublas.cp313-win_amd64.pyd +0 -0
  33. nvmath/bindings/cublas.pxd +545 -0
  34. nvmath/bindings/cublas.pyi +18 -0
  35. nvmath/bindings/cublasLt.cp313-win_amd64.pyd +0 -0
  36. nvmath/bindings/cublasLt.pxd +99 -0
  37. nvmath/bindings/cudss.cp313-win_amd64.pyd +0 -0
  38. nvmath/bindings/cudss.pxd +83 -0
  39. nvmath/bindings/cudss.pyi +249 -0
  40. nvmath/bindings/cufft.cp313-win_amd64.pyd +0 -0
  41. nvmath/bindings/cufft.pxd +114 -0
  42. nvmath/bindings/cufftMp.pxd +124 -0
  43. nvmath/bindings/curand.cp313-win_amd64.pyd +0 -0
  44. nvmath/bindings/curand.pxd +71 -0
  45. nvmath/bindings/cusolver.cp313-win_amd64.pyd +0 -0
  46. nvmath/bindings/cusolver.pxd +60 -0
  47. nvmath/bindings/cusolverDn.cp313-win_amd64.pyd +0 -0
  48. nvmath/bindings/cusolverDn.pxd +410 -0
  49. nvmath/bindings/cusparse.cp313-win_amd64.pyd +0 -0
  50. nvmath/bindings/cusparse.pxd +329 -0
  51. nvmath/bindings/cycublas.cp313-win_amd64.pyd +0 -0
  52. nvmath/bindings/cycublas.pxd +657 -0
  53. nvmath/bindings/cycublasLt.cp313-win_amd64.pyd +0 -0
  54. nvmath/bindings/cycublasLt.pxd +1010 -0
  55. nvmath/bindings/cycudss.cp313-win_amd64.pyd +0 -0
  56. nvmath/bindings/cycudss.pxd +191 -0
  57. nvmath/bindings/cycufft.cp313-win_amd64.pyd +0 -0
  58. nvmath/bindings/cycufft.pxd +320 -0
  59. nvmath/bindings/cycufftMp.pxd +333 -0
  60. nvmath/bindings/cycurand.cp313-win_amd64.pyd +0 -0
  61. nvmath/bindings/cycurand.pxd +146 -0
  62. nvmath/bindings/cycusolver.cp313-win_amd64.pyd +0 -0
  63. nvmath/bindings/cycusolver.pxd +143 -0
  64. nvmath/bindings/cycusolverDn.cp313-win_amd64.pyd +0 -0
  65. nvmath/bindings/cycusolverDn.pxd +414 -0
  66. nvmath/bindings/cycusparse.cp313-win_amd64.pyd +0 -0
  67. nvmath/bindings/cycusparse.pxd +476 -0
  68. nvmath/bindings/cymathdx.cp313-win_amd64.pyd +0 -0
  69. nvmath/bindings/cymathdx.pxd +363 -0
  70. nvmath/bindings/cynvshmem.pxd +126 -0
  71. nvmath/bindings/mathdx.cp313-win_amd64.pyd +0 -0
  72. nvmath/bindings/mathdx.pxd +131 -0
  73. nvmath/bindings/mathdx.pyi +686 -0
  74. nvmath/bindings/nvpl/__init__.pxd +0 -0
  75. nvmath/bindings/nvpl/__init__.py +11 -0
  76. nvmath/bindings/nvpl/_internal/__init__.pxd +0 -0
  77. nvmath/bindings/nvpl/_internal/__init__.py +0 -0
  78. nvmath/bindings/nvpl/_internal/fft.pxd +36 -0
  79. nvmath/bindings/nvpl/cyfft.pxd +87 -0
  80. nvmath/bindings/nvpl/fft.pxd +100 -0
  81. nvmath/bindings/nvshmem.pxd +54 -0
  82. nvmath/device/__init__.py +23 -0
  83. nvmath/device/_deprecated.py +33 -0
  84. nvmath/device/caching.py +51 -0
  85. nvmath/device/common.py +131 -0
  86. nvmath/device/common_backend.py +125 -0
  87. nvmath/device/common_cuda.py +156 -0
  88. nvmath/device/common_mathdx.py +97 -0
  89. nvmath/device/common_numba.py +159 -0
  90. nvmath/device/common_opaque_tensor.py +128 -0
  91. nvmath/device/cublasdx.py +1085 -0
  92. nvmath/device/cublasdx_backend.py +552 -0
  93. nvmath/device/cublasdx_numba.py +528 -0
  94. nvmath/device/cufftdx.py +551 -0
  95. nvmath/device/cufftdx_backend.py +194 -0
  96. nvmath/device/cufftdx_numba.py +123 -0
  97. nvmath/device/curand_kernel.py +9147 -0
  98. nvmath/device/nvrtc.py +95 -0
  99. nvmath/device/patch.py +35 -0
  100. nvmath/device/random.py +417 -0
  101. nvmath/device/random_helpers.py +23 -0
  102. nvmath/device/random_states.py +189 -0
  103. nvmath/device/types.py +11 -0
  104. nvmath/device/vector_types_numba.py +203 -0
  105. nvmath/distributed/__init__.py +117 -0
  106. nvmath/distributed/_internal/__init__.py +0 -0
  107. nvmath/distributed/_internal/nvshmem.py +243 -0
  108. nvmath/distributed/_internal/tensor_ifc_cupy.py +111 -0
  109. nvmath/distributed/_internal/tensor_ifc_numpy.py +53 -0
  110. nvmath/distributed/_internal/tensor_ifc_torch.py +108 -0
  111. nvmath/distributed/_internal/tensor_wrapper.py +59 -0
  112. nvmath/distributed/_utils.py +152 -0
  113. nvmath/distributed/fft/__init__.py +6 -0
  114. nvmath/distributed/fft/_configuration.py +86 -0
  115. nvmath/distributed/fft/fft.py +1737 -0
  116. nvmath/distributed/reshape/__init__.py +6 -0
  117. nvmath/distributed/reshape/_configuration.py +39 -0
  118. nvmath/distributed/reshape/reshape.py +1249 -0
  119. nvmath/fft/__init__.py +7 -0
  120. nvmath/fft/_configuration.py +208 -0
  121. nvmath/fft/_exec_utils.py +116 -0
  122. nvmath/fft/_helpers.py +260 -0
  123. nvmath/fft/fft.py +2346 -0
  124. nvmath/internal/__init__.py +5 -0
  125. nvmath/internal/enum_utils.py +142 -0
  126. nvmath/internal/formatters.py +87 -0
  127. nvmath/internal/mem_limit.py +51 -0
  128. nvmath/internal/package_ifc.py +119 -0
  129. nvmath/internal/package_ifc_cuda.py +43 -0
  130. nvmath/internal/package_ifc_cupy.py +49 -0
  131. nvmath/internal/package_ifc_torch.py +31 -0
  132. nvmath/internal/package_wrapper.py +14 -0
  133. nvmath/internal/tensor_ifc.py +143 -0
  134. nvmath/internal/tensor_ifc_cupy.py +185 -0
  135. nvmath/internal/tensor_ifc_numpy.py +157 -0
  136. nvmath/internal/tensor_ifc_torch.py +115 -0
  137. nvmath/internal/tensor_wrapper.py +160 -0
  138. nvmath/internal/typemaps.py +154 -0
  139. nvmath/internal/utils.py +634 -0
  140. nvmath/linalg/__init__.py +11 -0
  141. nvmath/linalg/_internal/__init__.py +3 -0
  142. nvmath/linalg/_internal/algo_cap_ifc.py +86 -0
  143. nvmath/linalg/_internal/algo_config_ifc.py +87 -0
  144. nvmath/linalg/_internal/enum_to_tuples.py +64 -0
  145. nvmath/linalg/_internal/epilog_protocol.py +738 -0
  146. nvmath/linalg/_internal/matmul_desc_ifc.py +72 -0
  147. nvmath/linalg/_internal/matmul_pref_ifc.py +65 -0
  148. nvmath/linalg/_internal/matrix_layout_ifc.py +59 -0
  149. nvmath/linalg/_internal/typemaps.py +135 -0
  150. nvmath/linalg/_internal/utils.py +96 -0
  151. nvmath/linalg/advanced/__init__.py +8 -0
  152. nvmath/linalg/advanced/_algorithmmod.py +142 -0
  153. nvmath/linalg/advanced/_configuration.py +320 -0
  154. nvmath/linalg/advanced/helpers/__init__.py +5 -0
  155. nvmath/linalg/advanced/helpers/matmul.py +173 -0
  156. nvmath/linalg/advanced/matmulmod.py +2855 -0
  157. nvmath/memory.py +266 -0
  158. nvmath/sparse/__init__.py +18 -0
  159. nvmath/sparse/_internal/__init__.py +21 -0
  160. nvmath/sparse/_internal/common_utils.py +81 -0
  161. nvmath/sparse/_internal/cudss_config_ifc.py +584 -0
  162. nvmath/sparse/_internal/cudss_data_ifc.py +291 -0
  163. nvmath/sparse/_internal/cudss_utils.py +398 -0
  164. nvmath/sparse/_internal/sparse_csr_ifc.py +154 -0
  165. nvmath/sparse/_internal/sparse_format_helpers.py +88 -0
  166. nvmath/sparse/_internal/sparse_tensor_ifc.py +80 -0
  167. nvmath/sparse/advanced/__init__.py +7 -0
  168. nvmath/sparse/advanced/_configuration.py +150 -0
  169. nvmath/sparse/advanced/direct_solver.py +1705 -0
  170. nvmath_python-0.5.0.dist-info/METADATA +122 -0
  171. nvmath_python-0.5.0.dist-info/RECORD +174 -0
  172. nvmath_python-0.5.0.dist-info/WHEEL +5 -0
  173. nvmath_python-0.5.0.dist-info/licenses/LICENSE +177 -0
  174. nvmath_python-0.5.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,584 @@
1
+ # Copyright (c) 2025, 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
+
21
+ ConfigParamEnum: TypeAlias = cudss.ConfigParam
22
+
23
+ # Future-proofing - cuDSS is currently not thread-safe.
24
+ # https://docs.nvidia.com/cuda/cudss/general.html#thread-safety
25
+ _tls = threading.local()
26
+ _tls.size_written = np.empty((1,), dtype=np.uint64)
27
+
28
+
29
+ def _get_scalar_attribute(config_ptr, name, attribute):
30
+ """
31
+ name = cudss enumerator for the attribute.
32
+ attribute = numpy ndarray object into which the value is stored.
33
+ """
34
+ cudss.config_get(config_ptr, name, attribute.ctypes.data, attribute.dtype.itemsize, _tls.size_written.ctypes.data)
35
+ assert _tls.size_written[0] <= attribute.dtype.itemsize, "Internal error."
36
+
37
+
38
+ def _set_scalar_attribute(config_ptr, name, attribute, value):
39
+ """
40
+ name = cudss enumerator for the attribute.
41
+ attribute = numpy ndarray object into which the value is stored.
42
+ value = the value to set the the attribute to.
43
+ """
44
+ attribute[0] = value
45
+ cudss.config_set(config_ptr, name, attribute.ctypes.data, attribute.dtype.itemsize)
46
+
47
+
48
+ def _check_valid_solver(config):
49
+ """
50
+ Check if the configuration points to a valid DirectSolver object.
51
+ """
52
+ if not config._solver.valid_state:
53
+ m = re.match(r"<nvmath\..*\.(.*Config) object at (.*)>$", str(config))
54
+ assert m is not None, "Internal error."
55
+ name = m.group(1)
56
+ address = m.group(2)
57
+
58
+ raise RuntimeError(f"The {name} object at {address} cannot be used after it's solver object is free'd.")
59
+
60
+
61
+ # TODO: Set user permutation as part of PlanConfig, even though it sets the data object.
62
+ class PlanConfig:
63
+ """
64
+ An interface to configure :meth:`nvmath.sparse.advanced.DirectSolver.plan`. The
65
+ current configuration can also be queried.
66
+ """
67
+
68
+ def __init__(self, solver):
69
+ """
70
+ ctor for internal use only.
71
+ """
72
+ self._solver = solver
73
+ self._config_ptr = self._solver.config_ptr
74
+ assert self._config_ptr is not None, "Internal error"
75
+
76
+ get_dtype = cudss.get_config_param_dtype
77
+
78
+ self._host_nthreads = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HOST_NTHREADS))
79
+ self._reordering_alg = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.REORDERING_ALG))
80
+ self._pivot_type = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.PIVOT_TYPE))
81
+ self._pivot_threshold = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.PIVOT_THRESHOLD))
82
+ self._max_lu_nnz = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.MAX_LU_NNZ))
83
+
84
+ def _check_valid_solver_wrapper(self, *args, **kwargs):
85
+ _check_valid_solver(self)
86
+
87
+ @property
88
+ @utils.precondition(_check_valid_solver_wrapper)
89
+ def host_nthreads(self):
90
+ """
91
+ Query or set the number of host threads. See the
92
+ `cuDSS documentation
93
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
94
+ for more information.
95
+ """
96
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.HOST_NTHREADS, self._host_nthreads)
97
+
98
+ return self._host_nthreads.item()
99
+
100
+ @host_nthreads.setter
101
+ @utils.precondition(_check_valid_solver_wrapper)
102
+ def host_nthreads(self, nthreads):
103
+ """
104
+ Set the number of host threads. See the
105
+ `cuDSS documentation
106
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
107
+ for more information.
108
+
109
+ Args:
110
+ nthreads: The number of host threads as Python `int`.
111
+
112
+ """
113
+ if not self._solver.multithreading:
114
+ raise ValueError(
115
+ "The number of host threads cannot be set if a multithreading library was not provided during problem \
116
+ specification."
117
+ )
118
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.HOST_NTHREADS, self._host_nthreads, nthreads)
119
+
120
+ @property
121
+ @utils.precondition(_check_valid_solver_wrapper)
122
+ def reordering_algorithm(self):
123
+ """
124
+ Query or set the reordering algorithm used. See
125
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
126
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
127
+ information.
128
+ """
129
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.REORDERING_ALG, self._reordering_alg)
130
+
131
+ return cudss.AlgType(self._reordering_alg.item())
132
+
133
+ @reordering_algorithm.setter
134
+ @utils.precondition(_check_valid_solver_wrapper)
135
+ def reordering_algorithm(self, algorithm):
136
+ """
137
+ Set the reordering algorithm to use. See :class:`nvmath.bindings.cudss.AlgType` and
138
+ the `cuDSS documentation
139
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
140
+ information.
141
+
142
+ Args:
143
+ algorithm: The reordering algorithm of type
144
+ :class:`nvmath.bindings.cudss.AlgType` or Python `int`.
145
+
146
+ """
147
+ algorithm = cudss.AlgType(algorithm)
148
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.REORDERING_ALG, self._reordering_alg, algorithm)
149
+
150
+ @property
151
+ @utils.precondition(_check_valid_solver_wrapper)
152
+ def pivot_type(self):
153
+ """
154
+ Query or set the type of pivoting. See
155
+ :class:`nvmath.bindings.cudss.PivotType` and the `cuDSS documentation
156
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
157
+ for more information.
158
+ """
159
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_TYPE, self._pivot_type)
160
+
161
+ return cudss.PivotType(self._pivot_type.item())
162
+
163
+ @pivot_type.setter
164
+ @utils.precondition(_check_valid_solver_wrapper)
165
+ def pivot_type(self, pivot_type):
166
+ """
167
+ Set the type of pivoting. See :class:`nvmath.bindings.cudss.PivotType` and the
168
+ `cuDSS documentation
169
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
170
+ information.
171
+
172
+ Args:
173
+ pivot_type: The type of pivoting (:class:`nvmath.bindings.cudss.PivotType` or
174
+ Python `int`).
175
+
176
+ """
177
+ pivot_type = cudss.PivotType(pivot_type)
178
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_TYPE, self._pivot_type, pivot_type)
179
+
180
+ @property
181
+ @utils.precondition(_check_valid_solver_wrapper)
182
+ def pivot_threshold(self):
183
+ """
184
+ Query or set the pivot threshold. See the
185
+ `cuDSS documentation
186
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
187
+ for more information.
188
+ """
189
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_THRESHOLD, self._pivot_threshold)
190
+
191
+ return self._pivot_threshold.item()
192
+
193
+ @pivot_threshold.setter
194
+ @utils.precondition(_check_valid_solver_wrapper)
195
+ def pivot_threshold(self, pivot_threshold):
196
+ """
197
+ Set the pivot threshold. See the
198
+ `cuDSS documentation
199
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
200
+ for more information.
201
+
202
+ Args:
203
+ pivot_threshold: The threshold for pivoting (Python `float`).
204
+
205
+ """
206
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_THRESHOLD, self._pivot_threshold, pivot_threshold)
207
+
208
+ @property
209
+ @utils.precondition(_check_valid_solver_wrapper)
210
+ def max_nnz(self):
211
+ """
212
+ Query or set the maximum limit for non-zero factors in the LU decomposition. See the
213
+ `cuDSS documentation
214
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
215
+ for more information.
216
+ """
217
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.MAX_LU_NNZ, self._max_lu_nnz)
218
+
219
+ return self._max_lu_nnz.item()
220
+
221
+ @max_nnz.setter
222
+ @utils.precondition(_check_valid_solver_wrapper)
223
+ def max_nnz(self, max_nnz):
224
+ """
225
+ Set the maximum limit for non-zero factors in the LU decomposition. See the
226
+ `cuDSS documentation
227
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
228
+ for more information.
229
+
230
+ Args:
231
+ max_nnz: The maximum limit for non-zero factors in the LU decomposition
232
+ (Python `int`).
233
+
234
+ """
235
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.MAX_LU_NNZ, self._max_lu_nnz, max_nnz)
236
+
237
+
238
+ class FactorizationConfig:
239
+ """
240
+ An interface to configure :meth:`nvmath.sparse.advanced.DirectSolver.factorize`. The
241
+ current configuration can also be queried.
242
+ """
243
+
244
+ def __init__(self, solver):
245
+ """
246
+ ctor for internal use only.
247
+ """
248
+ self._solver = solver
249
+ self._config_ptr = self._solver.config_ptr
250
+ assert self._config_ptr is not None, "Internal error"
251
+
252
+ get_dtype = cudss.get_config_param_dtype
253
+
254
+ self._factorization_alg = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.FACTORIZATION_ALG))
255
+ self._pivot_epsilon_alg = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.PIVOT_EPSILON_ALG))
256
+ self._pivot_epsilon = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.PIVOT_EPSILON))
257
+
258
+ def _check_valid_solver_wrapper(self, *args, **kwargs):
259
+ _check_valid_solver(self)
260
+
261
+ @property
262
+ @utils.precondition(_check_valid_solver_wrapper)
263
+ def factorization_algorithm(self):
264
+ """
265
+ Query or set the factorization algorithm used. See
266
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
267
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
268
+ information.
269
+ """
270
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.FACTORIZATION_ALG, self._factorization_alg)
271
+
272
+ return cudss.AlgType(self._factorization_alg.item())
273
+
274
+ @factorization_algorithm.setter
275
+ @utils.precondition(_check_valid_solver_wrapper)
276
+ def factorization_algorithm(self, algorithm):
277
+ """
278
+ Set the factorization algorithm to use. See :class:`nvmath.bindings.cudss.AlgType`
279
+ and the `cuDSS documentation
280
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
281
+ information.
282
+
283
+ Args:
284
+ algorithm: The factorization algorithm of type
285
+ :class:`nvmath.bindings.cudss.AlgType` or Python `int`.
286
+
287
+ """
288
+ algorithm = cudss.AlgType(algorithm)
289
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.FACTORIZATION_ALG, self._factorization_alg, algorithm)
290
+
291
+ @property
292
+ @utils.precondition(_check_valid_solver_wrapper)
293
+ def pivot_eps_algorithm(self):
294
+ """
295
+ Query or set the algorithm used for pivot epsilon calculation. See
296
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
297
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
298
+ information.
299
+ """
300
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_EPSILON_ALG, self._pivot_epsilon_alg)
301
+
302
+ return cudss.AlgType(self._factorization_alg.item())
303
+
304
+ @pivot_eps_algorithm.setter
305
+ @utils.precondition(_check_valid_solver_wrapper)
306
+ def pivot_eps_algorithm(self, algorithm):
307
+ """
308
+ Set the algorithm to use for pivot epsilon calculation. See
309
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
310
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
311
+ information.
312
+
313
+ Args:
314
+ algorithm: The pivot epsilon algorithm of type
315
+ :class:`nvmath.bindings.cudss.AlgType` or Python `int`.
316
+
317
+ """
318
+ algorithm = cudss.AlgType(algorithm)
319
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_EPSILON_ALG, self._pivot_epsilon_alg, algorithm)
320
+
321
+ @property
322
+ @utils.precondition(_check_valid_solver_wrapper)
323
+ def pivot_eps(self):
324
+ """
325
+ Query or set the pivot epsilon value. See the
326
+ `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.PIVOT_EPSILON, self._pivot_epsilon)
331
+
332
+ return self._factorization_alg.item()
333
+
334
+ @pivot_eps.setter
335
+ @utils.precondition(_check_valid_solver_wrapper)
336
+ def pivot_eps(self, epsilon):
337
+ """
338
+ Set the pivot epsilon value. See the
339
+ `cuDSS documentation
340
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
341
+ for more information.
342
+
343
+ Args:
344
+ epsilon: The pivot epsilon value (Python numerical type).
345
+
346
+ """
347
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.PIVOT_EPSILON, self._pivot_epsilon, epsilon)
348
+
349
+
350
+ class SolutionConfig:
351
+ """
352
+ An interface to configure :meth:`nvmath.sparse.advanced.DirectSolver.solve`. The
353
+ current configuration can also be queried.
354
+ """
355
+
356
+ def __init__(self, solver):
357
+ """
358
+ ctor for internal use only.
359
+ """
360
+ self._solver = solver
361
+ self._config_ptr = self._solver.config_ptr
362
+ assert self._config_ptr is not None, "Internal error"
363
+
364
+ get_dtype = cudss.get_config_param_dtype
365
+
366
+ self._solve_alg = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.SOLVE_ALG))
367
+ self._ir_n_steps = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.IR_N_STEPS))
368
+
369
+ def _check_valid_solver_wrapper(self, *args, **kwargs):
370
+ _check_valid_solver(self)
371
+
372
+ @property
373
+ @utils.precondition(_check_valid_solver_wrapper)
374
+ def solution_algorithm(self):
375
+ """
376
+ Query or set the solution algorithm used. See
377
+ :class:`nvmath.bindings.cudss.AlgType` and the `cuDSS documentation
378
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
379
+ information.
380
+ """
381
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.SOLVE_ALG, self._solve_alg)
382
+
383
+ return cudss.AlgType(self._solve_alg.item())
384
+
385
+ @solution_algorithm.setter
386
+ @utils.precondition(_check_valid_solver_wrapper)
387
+ def solution_algorithm(self, algorithm):
388
+ """
389
+ Set the algorithm to use for solving. See :class:`nvmath.bindings.cudss.AlgType` and
390
+ the `cuDSS documentation
391
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_ for more
392
+ information.
393
+
394
+ Args:
395
+ algorithm: The solution algorithm of type :class:`nvmath.bindings.cudss.AlgType`
396
+ or Python `int`.
397
+
398
+ """
399
+ algorithm = cudss.AlgType(algorithm)
400
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.SOLVE_ALG, self._solve_alg, algorithm)
401
+
402
+ @property
403
+ @utils.precondition(_check_valid_solver_wrapper)
404
+ def ir_num_steps(self):
405
+ """
406
+ Query or set the number of steps used for iterative refinement. Set the
407
+ `cuDSS documentation
408
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
409
+ for more information.
410
+ """
411
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.IR_N_STEPS, self._ir_n_steps)
412
+
413
+ return self._ir_n_steps.item()
414
+
415
+ @ir_num_steps.setter
416
+ @utils.precondition(_check_valid_solver_wrapper)
417
+ def ir_num_steps(self, num_steps):
418
+ """
419
+ Set the number of steps to use for iterative refinement. Set the
420
+ `cuDSS documentation
421
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
422
+ for more information.
423
+
424
+ Args:
425
+ num_steps: The number of steps to use for iterative refinement as a
426
+ Python `int`.
427
+
428
+ """
429
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.IR_N_STEPS, self._ir_n_steps, num_steps)
430
+
431
+
432
+ class InternalConfig:
433
+ """
434
+ Interface class for internal use only. No precondition for `@property` since this is
435
+ used in the ctor before `solver.valid_state` is set.
436
+ """
437
+
438
+ def __init__(self, solver):
439
+ """
440
+ ctor for internal use only.
441
+ """
442
+ self._solver = solver
443
+ self._config_ptr = self._solver.config_ptr
444
+ assert self._config_ptr is not None, "Internal error"
445
+
446
+ get_dtype = cudss.get_config_param_dtype
447
+
448
+ self._hybrid_mode = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HYBRID_MODE))
449
+ self._hybrid_device_memory_limit = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HYBRID_DEVICE_MEMORY_LIMIT))
450
+ self._use_cuda_register_memory = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.USE_CUDA_REGISTER_MEMORY))
451
+ self._host_nthreads = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HOST_NTHREADS))
452
+ self._hybrid_execute_mode = np.zeros((1,), dtype=get_dtype(ConfigParamEnum.HYBRID_EXECUTE_MODE))
453
+
454
+ @property
455
+ def hybrid_mode(self):
456
+ """
457
+ Query or set the hybrid memory mode. See the
458
+ `cuDSS documentation
459
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
460
+ for more information.
461
+ """
462
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.HYBRID_MODE, self._hybrid_mode)
463
+
464
+ return self._hybrid_mode.item()
465
+
466
+ @hybrid_mode.setter
467
+ def hybrid_mode(self, mode):
468
+ """
469
+ Set the hybrid memory mode. See the
470
+ `cuDSS documentation
471
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
472
+ for more information.
473
+
474
+ Args:
475
+ mode: The hybrid memory mode as Python `int` (0=device or 1=hybrid).
476
+
477
+ """
478
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.HYBRID_MODE, self._hybrid_mode, mode)
479
+
480
+ @property
481
+ def hybrid_device_memory_limit(self):
482
+ """
483
+ Query or set the hybrid device memory limit. See the
484
+ `cuDSS documentation
485
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
486
+ for more information.
487
+ """
488
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.HYBRID_DEVICE_MEMORY_LIMIT, self._hybrid_device_memory_limit)
489
+
490
+ return self._hybrid_mode.item()
491
+
492
+ @hybrid_device_memory_limit.setter
493
+ def hybrid_device_memory_limit(self, limit):
494
+ """
495
+ Set the hybrid device memory limit. See the
496
+ `cuDSS documentation
497
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
498
+ for more information.
499
+
500
+ Args:
501
+ limit: The hybrid memory limit as Python `int`.
502
+
503
+ """
504
+ _set_scalar_attribute(
505
+ self._config_ptr, ConfigParamEnum.HYBRID_DEVICE_MEMORY_LIMIT, self._hybrid_device_memory_limit, limit
506
+ )
507
+
508
+ @property
509
+ def use_cuda_register_memory(self):
510
+ """
511
+ Query or set the CUDA memory registration flag. See the
512
+ `cuDSS documentation
513
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
514
+ for more information.
515
+ """
516
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.USE_CUDA_REGISTER_MEMORY, self._use_cuda_register_memory)
517
+
518
+ return self._use_cuda_register_memory.item()
519
+
520
+ @use_cuda_register_memory.setter
521
+ def use_cuda_register_memory(self, flag):
522
+ """
523
+ Set the CUDA memory registration flag. See the
524
+ `cuDSS documentation
525
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
526
+ for more information.
527
+
528
+ Args:
529
+ flag: The memory registration flag as Python `int` (0 or 1).
530
+
531
+ """
532
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.USE_CUDA_REGISTER_MEMORY, self._use_cuda_register_memory, flag)
533
+
534
+ @property
535
+ def host_nthreads(self):
536
+ """
537
+ Query or set the number of host threads. See the
538
+ `cuDSS documentation
539
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
540
+ for more information.
541
+ """
542
+ _get_scalar_attribute(self._config_ptr, ConfigParamEnum.HOST_NTHREADS, self._host_nthreads)
543
+
544
+ return self._host_nthreads.item()
545
+
546
+ @host_nthreads.setter
547
+ def host_nthreads(self, nthreads):
548
+ """
549
+ Set the number of host threads. See the
550
+ `cuDSS documentation
551
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
552
+ for more information.
553
+
554
+ Args:
555
+ nthreads: The number of host threads as Python `int`.
556
+
557
+ """
558
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.HOST_NTHREADS, self._host_nthreads, nthreads)
559
+
560
+ @property
561
+ def hybrid_execute_mode(self):
562
+ """
563
+ Query or set the hybrid execution mode. 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.HYBRID_MODE, self._hybrid_mode)
569
+
570
+ return self._hybrid_mode.item()
571
+
572
+ @hybrid_execute_mode.setter
573
+ def hybrid_execute_mode(self, mode):
574
+ """
575
+ Set the hybrid execution mode. See the
576
+ `cuDSS documentation
577
+ <https://docs.nvidia.com/cuda/cudss/types.html#cudssconfigparam-t>`_
578
+ for more information.
579
+
580
+ Args:
581
+ mode: The hybrid execution mode as Python `int` (0=device or 1=hybrid).
582
+
583
+ """
584
+ _set_scalar_attribute(self._config_ptr, ConfigParamEnum.HYBRID_EXECUTE_MODE, self._hybrid_execute_mode, mode)