Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
cusolverRf.h340 linesDownload Raw Back to include
1/*
2 * Copyright 1993-2014 NVIDIA Corporation.  All rights reserved.
3 *
4 * NOTICE TO LICENSEE:
5 *
6 * This source code and/or documentation ("Licensed Deliverables") are
7 * subject to NVIDIA intellectual property rights under U.S. and
8 * international Copyright laws.
9 *
10 * These Licensed Deliverables contained herein is PROPRIETARY and
11 * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12 * conditions of a form of NVIDIA software license agreement by and
13 * between NVIDIA and Licensee ("License Agreement") or electronically
14 * accepted by Licensee.  Notwithstanding any terms or conditions to
15 * the contrary in the License Agreement, reproduction or disclosure
16 * of the Licensed Deliverables to any third party without the express
17 * written consent of NVIDIA is prohibited.
18 *
19 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20 * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21 * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE.  IT IS
22 * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23 * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24 * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25 * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27 * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28 * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32 * OF THESE LICENSED DELIVERABLES.
33 *
34 * U.S. Government End Users.  These Licensed Deliverables are a
35 * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36 * 1995), consisting of "commercial computer software" and "commercial
37 * computer software documentation" as such terms are used in 48
38 * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39 * only as a commercial end item.  Consistent with 48 C.F.R.12.212 and
40 * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41 * U.S. Government End Users acquire the Licensed Deliverables with
42 * only those rights set forth herein.
43 *
44 * Any use of the Licensed Deliverables in individual and commercial
45 * software must include, in the user documentation and internal
46 * comments to the code, the above Disclaimer and U.S. Government End
47 * Users Notice.
48 */
49
50#if !defined(CUSOLVERRF_H_)
51  #define CUSOLVERRF_H_
52
53  #include "driver_types.h"
54  #include "cuComplex.h"
55  #include "cusolver_common.h"
56
57  #if defined(__cplusplus)
58extern "C" {
59  #endif /* __cplusplus */
60
61  /* CUSOLVERRF mode */
62  typedef enum {
63    CUSOLVERRF_RESET_VALUES_FAST_MODE_OFF = 0, // default
64    CUSOLVERRF_RESET_VALUES_FAST_MODE_ON = 1
65  } cusolverRfResetValuesFastMode_t;
66
67  /* CUSOLVERRF matrix format */
68  typedef enum {
69    CUSOLVERRF_MATRIX_FORMAT_CSR = 0, // default
70    CUSOLVERRF_MATRIX_FORMAT_CSC = 1
71  } cusolverRfMatrixFormat_t;
72
73  /* CUSOLVERRF unit diagonal */
74  typedef enum {
75    CUSOLVERRF_UNIT_DIAGONAL_STORED_L = 0, // default
76    CUSOLVERRF_UNIT_DIAGONAL_STORED_U = 1,
77    CUSOLVERRF_UNIT_DIAGONAL_ASSUMED_L = 2,
78    CUSOLVERRF_UNIT_DIAGONAL_ASSUMED_U = 3
79  } cusolverRfUnitDiagonal_t;
80
81  /* CUSOLVERRF factorization algorithm */
82  typedef enum {
83    CUSOLVERRF_FACTORIZATION_ALG0 = 0, // default
84    CUSOLVERRF_FACTORIZATION_ALG1 = 1,
85    CUSOLVERRF_FACTORIZATION_ALG2 = 2,
86  } cusolverRfFactorization_t;
87
88  /* CUSOLVERRF triangular solve algorithm */
89  typedef enum {
90    CUSOLVERRF_TRIANGULAR_SOLVE_ALG1 = 1, // default
91    CUSOLVERRF_TRIANGULAR_SOLVE_ALG2 = 2,
92    CUSOLVERRF_TRIANGULAR_SOLVE_ALG3 = 3
93  } cusolverRfTriangularSolve_t;
94
95  /* CUSOLVERRF numeric boost report */
96  typedef enum {
97    CUSOLVERRF_NUMERIC_BOOST_NOT_USED = 0, // default
98    CUSOLVERRF_NUMERIC_BOOST_USED = 1
99  } cusolverRfNumericBoostReport_t;
100
101  /* Opaque structure holding CUSOLVERRF library common */
102  struct cusolverRfCommon;
103  typedef struct cusolverRfCommon* cusolverRfHandle_t;
104
105  /* CUSOLVERRF create (allocate memory) and destroy (free memory) in the handle
106   */
107  cusolverStatus_t CUSOLVERAPI cusolverRfCreate(cusolverRfHandle_t* handle);
108  cusolverStatus_t CUSOLVERAPI cusolverRfDestroy(cusolverRfHandle_t handle);
109
110  /* CUSOLVERRF set and get input format */
111  cusolverStatus_t CUSOLVERAPI cusolverRfGetMatrixFormat(
112    cusolverRfHandle_t        handle,
113    cusolverRfMatrixFormat_t* format,
114    cusolverRfUnitDiagonal_t* diag);
115
116  cusolverStatus_t CUSOLVERAPI cusolverRfSetMatrixFormat(
117    cusolverRfHandle_t       handle,
118    cusolverRfMatrixFormat_t format,
119    cusolverRfUnitDiagonal_t diag);
120
121  /* CUSOLVERRF set and get numeric properties */
122  cusolverStatus_t CUSOLVERAPI cusolverRfSetNumericProperties(
123    cusolverRfHandle_t handle,
124    double             zero,
125    double             boost);
126
127  cusolverStatus_t CUSOLVERAPI cusolverRfGetNumericProperties(
128    cusolverRfHandle_t handle,
129    double*            zero,
130    double*            boost);
131
132  cusolverStatus_t CUSOLVERAPI cusolverRfGetNumericBoostReport(
133    cusolverRfHandle_t              handle,
134    cusolverRfNumericBoostReport_t* report);
135
136  /* CUSOLVERRF choose the triangular solve algorithm */
137  cusolverStatus_t CUSOLVERAPI cusolverRfSetAlgs(
138    cusolverRfHandle_t          handle,
139    cusolverRfFactorization_t   factAlg,
140    cusolverRfTriangularSolve_t solveAlg);
141
142  cusolverStatus_t CUSOLVERAPI cusolverRfGetAlgs(
143    cusolverRfHandle_t           handle,
144    cusolverRfFactorization_t*   factAlg,
145    cusolverRfTriangularSolve_t* solveAlg);
146
147  /* CUSOLVERRF set and get fast mode */
148  cusolverStatus_t CUSOLVERAPI cusolverRfGetResetValuesFastMode(
149    cusolverRfHandle_t               handle,
150    cusolverRfResetValuesFastMode_t* fastMode);
151
152  cusolverStatus_t CUSOLVERAPI cusolverRfSetResetValuesFastMode(
153    cusolverRfHandle_t              handle,
154    cusolverRfResetValuesFastMode_t fastMode);
155
156  /*** Non-Batched Routines ***/
157  /* CUSOLVERRF setup of internal structures from host or device memory */
158  cusolverStatus_t CUSOLVERAPI
159    cusolverRfSetupHost(/* Input (in the host memory) */
160                        int     n,
161                        int     nnzA,
162                        int*    h_csrRowPtrA,
163                        int*    h_csrColIndA,
164                        double* h_csrValA,
165                        int     nnzL,
166                        int*    h_csrRowPtrL,
167                        int*    h_csrColIndL,
168                        double* h_csrValL,
169                        int     nnzU,
170                        int*    h_csrRowPtrU,
171                        int*    h_csrColIndU,
172                        double* h_csrValU,
173                        int*    h_P,
174                        int*    h_Q,
175                        /* Output */
176                        cusolverRfHandle_t handle);
177
178  cusolverStatus_t CUSOLVERAPI
179    cusolverRfSetupDevice(/* Input (in the device memory) */
180                          int     n,
181                          int     nnzA,
182                          int*    csrRowPtrA,
183                          int*    csrColIndA,
184                          double* csrValA,
185                          int     nnzL,
186                          int*    csrRowPtrL,
187                          int*    csrColIndL,
188                          double* csrValL,
189                          int     nnzU,
190                          int*    csrRowPtrU,
191                          int*    csrColIndU,
192                          double* csrValU,
193                          int*    P,
194                          int*    Q,
195                          /* Output */
196                          cusolverRfHandle_t handle);
197
198  /* CUSOLVERRF update the matrix values (assuming the reordering, pivoting
199     and consequently the sparsity pattern of L and U did not change),
200     and zero out the remaining values. */
201  cusolverStatus_t CUSOLVERAPI
202    cusolverRfResetValues(/* Input (in the device memory) */
203                          int     n,
204                          int     nnzA,
205                          int*    csrRowPtrA,
206                          int*    csrColIndA,
207                          double* csrValA,
208                          int*    P,
209                          int*    Q,
210                          /* Output */
211                          cusolverRfHandle_t handle);
212
213  /* CUSOLVERRF analysis (for parallelism) */
214  cusolverStatus_t CUSOLVERAPI cusolverRfAnalyze(cusolverRfHandle_t handle);
215
216  /* CUSOLVERRF re-factorization (for parallelism) */
217  cusolverStatus_t CUSOLVERAPI cusolverRfRefactor(cusolverRfHandle_t handle);
218
219  /* CUSOLVERRF extraction: Get L & U packed into a single matrix M */
220  cusolverStatus_t CUSOLVERAPI
221    cusolverRfAccessBundledFactorsDevice(/* Input */
222                                         cusolverRfHandle_t handle,
223                                         /* Output (in the host memory) */
224                                         int* nnzM,
225                                         /* Output (in the device memory) */
226                                         int**    Mp,
227                                         int**    Mi,
228                                         double** Mx);
229
230  cusolverStatus_t CUSOLVERAPI
231    cusolverRfExtractBundledFactorsHost(/* Input */
232                                        cusolverRfHandle_t handle,
233                                        /* Output (in the host memory) */
234                                        int*     h_nnzM,
235                                        int**    h_Mp,
236                                        int**    h_Mi,
237                                        double** h_Mx);
238
239  /* CUSOLVERRF extraction: Get L & U individually */
240  cusolverStatus_t CUSOLVERAPI
241    cusolverRfExtractSplitFactorsHost(/* Input */
242                                      cusolverRfHandle_t handle,
243                                      /* Output (in the host memory) */
244                                      int*     h_nnzL,
245                                      int**    h_csrRowPtrL,
246                                      int**    h_csrColIndL,
247                                      double** h_csrValL,
248                                      int*     h_nnzU,
249                                      int**    h_csrRowPtrU,
250                                      int**    h_csrColIndU,
251                                      double** h_csrValU);
252
253  /* CUSOLVERRF (forward and backward triangular) solves */
254  cusolverStatus_t CUSOLVERAPI
255    cusolverRfSolve(/* Input (in the device memory) */
256                    cusolverRfHandle_t handle,
257                    int*               P,
258                    int*               Q,
259                    int                nrhs, // only nrhs=1 is supported
260                    double*            Temp, // of size ldt*nrhs (ldt>=n)
261                    int                ldt,
262                    /* Input/Output (in the device memory) */
263                    double* XF,
264                    /* Input */
265                    int ldxf);
266
267  /*** Batched Routines ***/
268  /* CUSOLVERRF-batch setup of internal structures from host */
269  cusolverStatus_t CUSOLVERAPI
270    cusolverRfBatchSetupHost(/* Input (in the host memory)*/
271                             int     batchSize,
272                             int     n,
273                             int     nnzA,
274                             int*    h_csrRowPtrA,
275                             int*    h_csrColIndA,
276                             double* h_csrValA_array[],
277                             int     nnzL,
278                             int*    h_csrRowPtrL,
279                             int*    h_csrColIndL,
280                             double* h_csrValL,
281                             int     nnzU,
282                             int*    h_csrRowPtrU,
283                             int*    h_csrColIndU,
284                             double* h_csrValU,
285                             int*    h_P,
286                             int*    h_Q,
287                             /* Output (in the device memory) */
288                             cusolverRfHandle_t handle);
289
290  /* CUSOLVERRF-batch update the matrix values (assuming the reordering,
291     pivoting and consequently the sparsity pattern of L and U did not change),
292     and zero out the remaining values. */
293  cusolverStatus_t CUSOLVERAPI
294    cusolverRfBatchResetValues(/* Input (in the device memory) */
295                               int     batchSize,
296                               int     n,
297                               int     nnzA,
298                               int*    csrRowPtrA,
299                               int*    csrColIndA,
300                               double* csrValA_array[],
301                               int*    P,
302                               int*    Q,
303                               /* Output */
304                               cusolverRfHandle_t handle);
305
306  /* CUSOLVERRF-batch analysis (for parallelism) */
307  cusolverStatus_t CUSOLVERAPI
308    cusolverRfBatchAnalyze(cusolverRfHandle_t handle);
309
310  /* CUSOLVERRF-batch re-factorization (for parallelism) */
311  cusolverStatus_t CUSOLVERAPI
312    cusolverRfBatchRefactor(cusolverRfHandle_t handle);
313
314  /* CUSOLVERRF-batch (forward and backward triangular) solves */
315  cusolverStatus_t CUSOLVERAPI
316    cusolverRfBatchSolve(/* Input (in the device memory) */
317                         cusolverRfHandle_t handle,
318                         int*               P,
319                         int*               Q,
320                         int                nrhs, // only nrhs=1 is supported
321                         double* Temp, // of size 2*batchSize*(n*nrhs)
322                         int     ldt,  // only ldt=n is supported
323                         /* Input/Output (in the device memory) */
324                         double* XF_array[],
325                         /* Input */
326                         int ldxf);
327
328  /* CUSOLVERRF-batch obtain the position of zero pivot */
329  cusolverStatus_t CUSOLVERAPI
330    cusolverRfBatchZeroPivot(/* Input */
331                             cusolverRfHandle_t handle,
332                             /* Output (in the host memory) */
333                             int* position);
334
335  #if defined(__cplusplus)
336}
337  #endif /* __cplusplus */
338
339#endif /* CUSOLVERRF_H_ */
340 
codekingpro/portable-devtools · Team Ai