Cusolver Library
Cusolver Library
Chapter 1. Introduction.........................................................................................1
1.1. cuSolverDN: Dense LAPACK..............................................................................2
1.2. cuSolverSP: Sparse LAPACK..............................................................................2
1.3. cuSolverRF: Refactorization.............................................................................3
1.4. Naming Conventions...................................................................................... 3
1.5. Asynchronous Execution................................................................................. 4
1.6. Library Property...........................................................................................5
1.7. high precision package.................................................................................. 5
Chapter 2. Using the cuSolver API........................................................................... 6
2.1. Thread Safety............................................................................................. 6
2.2. Scalar Parameters........................................................................................ 6
2.3. Parallelism with Streams................................................................................ 6
2.4. Link Third-party LAPACK Library....................................................................... 7
2.5. convention of info........................................................................................ 7
Chapter 3. cuSolver Types Reference....................................................................... 8
3.1. cuSolverDN Types......................................................................................... 8
3.1.1. cusolverDnHandle_t................................................................................. 8
3.1.2. cublasFillMode_t..................................................................................... 8
3.1.3. cublasOperation_t................................................................................... 8
3.1.4. cusolverEigType_t....................................................................................9
3.1.5. cusolverEigMode_t................................................................................... 9
3.1.6. cusolverStatus_t..................................................................................... 9
3.2. cuSolverSP Types..........................................................................................9
3.2.1. cusolverSpHandle_t................................................................................. 9
3.2.2. cusparseMatDescr_t................................................................................ 10
3.2.3. cusolverStatus_t.................................................................................... 10
3.3. cuSolverRF Types........................................................................................ 11
3.3.1. cusolverRfHandle_t................................................................................ 11
3.3.2. cusolverRfMatrixFormat_t........................................................................ 11
3.3.3. cusolverRfNumericBoostReport_t................................................................ 11
3.3.4. cusolverRfResetValuesFastMode_t............................................................... 12
3.3.5. cusolverRfFactorization_t.........................................................................12
3.3.6. cusolverRfTriangularSolve_t...................................................................... 12
3.3.7. cusolverRfUnitDiagonal_t......................................................................... 12
3.3.8. cusolverStatus_t.................................................................................... 13
Chapter 4. cuSolver Formats Reference................................................................... 14
4.1. Index Base Format...................................................................................... 14
4.2. Vector (Dense) Format................................................................................. 14
4.3. Matrix (Dense) Format..................................................................................14
4.4. Matrix (CSR) Format.................................................................................... 15
[Link]
cuSOLVER Library DU-06709-001_v10.1 | ii
4.5. Matrix (CSC) Format.................................................................................... 16
Chapter 5. cuSolverDN: dense LAPACK Function Reference...........................................17
5.1. cuSolverDN Helper Function Reference..............................................................17
5.1.1. cusolverDnCreate().................................................................................17
5.1.2. cusolverDnDestroy()................................................................................18
5.1.3. cusolverDnSetStream()............................................................................ 18
5.1.4. cusolverDnGetStream()............................................................................18
5.1.5. cusolverDnCreateSyevjInfo()..................................................................... 19
5.1.6. cusolverDnDestroySyevjInfo().................................................................... 19
5.1.7. cusolverDnXsyevjSetTolerance()................................................................. 19
5.1.8. cusolverDnXsyevjSetMaxSweeps()................................................................20
5.1.9. cusolverDnXsyevjSetSortEig().....................................................................20
5.1.10. cusolverDnXsyevjGetResidual()................................................................. 20
5.1.11. cusolverDnXsyevjGetSweeps().................................................................. 21
5.1.12. cusolverDnCreateGesvdjInfo().................................................................. 21
5.1.13. cusolverDnDestroyGesvdjInfo()................................................................. 22
5.1.14. cusolverDnXgesvdjSetTolerance().............................................................. 22
5.1.15. cusolverDnXgesvdjSetMaxSweeps().............................................................22
5.1.16. cusolverDnXgesvdjSetSortEig()..................................................................23
5.1.17. cusolverDnXgesvdjGetResidual()................................................................23
5.1.18. cusolverDnXgesvdjGetSweeps().................................................................23
5.2. Dense Linear Solver Reference........................................................................24
5.2.1. cusolverDn<t>potrf()...............................................................................25
5.2.2. cusolverDn<t>potrs()...............................................................................28
5.2.3. cusolverDn<t>potri()............................................................................... 30
5.2.4. cusolverDn<t>getrf()............................................................................... 33
5.2.5. cusolverDn<t>getrs()...............................................................................36
5.2.6. cusolverDn<t>geqrf().............................................................................. 38
5.2.7. cusolverDn<t>ormqr()............................................................................. 41
5.2.8. cusolverDn<t>orgqr().............................................................................. 45
5.2.9. cusolverDn<t>sytrf()............................................................................... 48
5.2.10. cusolverDn<t>potrfBatched()................................................................... 51
5.2.11. cusolverDn<t>potrsBatched()................................................................... 54
5.3. Dense Eigenvalue Solver Reference.................................................................. 56
5.3.1. cusolverDn<t>gebrd().............................................................................. 56
5.3.2. cusolverDn<t>orgbr().............................................................................. 60
5.3.3. cusolverDn<t>sytrd()...............................................................................64
5.3.4. cusolverDn<t>ormtr().............................................................................. 68
5.3.5. cusolverDn<t>orgtr()............................................................................... 72
5.3.6. cusolverDn<t>gesvd().............................................................................. 75
5.3.7. cusolverDn<t>gesvdj()............................................................................. 80
5.3.8. cusolverDn<t>gesvdjBatched()................................................................... 85
5.3.9. cusolverDn<t>syevd().............................................................................. 90
[Link]
cuSOLVER Library DU-06709-001_v10.1 | iii
5.3.10. cusolverDn<t>sygvd().............................................................................94
5.3.11. cusolverDn<t>syevj()............................................................................. 99
5.3.12. cusolverDn<t>sygvj()............................................................................ 104
5.3.13. cusolverDn<t>syevjBatched().................................................................. 110
Chapter 6. cuSolverSP: sparse LAPACK Function Reference......................................... 115
6.1. Helper Function Reference...........................................................................115
6.1.1. cusolverSpCreate()............................................................................... 115
6.1.2. cusolverSpDestroy().............................................................................. 115
6.1.3. cusolverSpSetStream()........................................................................... 116
6.1.4. cusolverSpXcsrissym()............................................................................ 116
6.2. High Level Function Reference...................................................................... 117
6.2.1. cusolverSp<t>csrlsvlu()...........................................................................118
6.2.2. cusolverSp<t>csrlsvqr().......................................................................... 122
6.2.3. cusolverSp<t>csrlsvchol()........................................................................ 125
6.2.4. cusolverSp<t>csrlsqvqr()......................................................................... 128
6.2.5. cusolverSp<t>csreigvsi()......................................................................... 132
6.2.6. cusolverSp<t>csreigs()............................................................................136
6.3. Low Level Function Reference...................................................................... 138
6.3.1. cusolverSpXcsrsymrcm()......................................................................... 138
6.3.2. cusolverSpXcsrsymmdq().........................................................................140
6.3.3. cusolverSpXcsrsymamd().........................................................................141
6.3.4. cusolverSpXcsrmetisnd()......................................................................... 143
6.3.5. cusolverSpXcsrzfd()............................................................................... 145
6.3.6. cusolverSpXcsrperm()............................................................................ 147
6.3.7. cusolverSpXcsrqrBatched()...................................................................... 149
Chapter 7. cuSolverRF: Refactorization Reference.................................................... 158
7.1. cusolverRfAccessBundledFactors()...................................................................158
7.2. cusolverRfAnalyze().................................................................................... 159
7.3. cusolverRfSetupDevice().............................................................................. 160
7.4. cusolverRfSetupHost()................................................................................. 162
7.5. cusolverRfCreate()..................................................................................... 164
7.6. cusolverRfExtractBundledFactorsHost()............................................................ 165
7.7. cusolverRfExtractSplitFactorsHost().................................................................166
7.8. cusolverRfDestroy().................................................................................... 167
7.9. cusolverRfGetMatrixFormat().........................................................................167
7.10. cusolverRfGetNumericProperties()................................................................. 168
7.11. cusolverRfGetNumericBoostReport()...............................................................168
7.12. cusolverRfGetResetValuesFastMode()..............................................................169
7.13. cusolverRfGet_Algs()................................................................................. 169
7.14. cusolverRfRefactor()................................................................................. 169
7.15. cusolverRfResetValues()..............................................................................170
7.16. cusolverRfSetMatrixFormat()........................................................................171
7.17. cusolverRfSetNumericProperties()................................................................. 172
[Link]
cuSOLVER Library DU-06709-001_v10.1 | iv
7.18. cusolverRfSetResetValuesFastMode().............................................................. 172
7.19. cusolverRfSetAlgs()................................................................................... 173
7.20. cusolverRfSolve()..................................................................................... 173
7.21. cusolverRfBatchSetupHost().........................................................................175
7.22. cusolverRfBatchAnalyze()............................................................................177
7.23. cusolverRfBatchResetValues().......................................................................178
7.24. cusolverRfBatchRefactor()...........................................................................179
7.25. cusolverRfBatchSolve()...............................................................................180
7.26. cusolverRfBatchZeroPivot()......................................................................... 181
Appendix A. cuSolverRF Examples........................................................................ 183
A.1. cuSolverRF In-memory Example..................................................................... 183
A.2. cuSolverRF-batch Example........................................................................... 187
Appendix B. CSR QR Batch Examples..................................................................... 191
B.1. Batched Sparse QR example 1.......................................................................191
B.2. Batched Sparse QR example 2.......................................................................195
Appendix C. QR Examples................................................................................... 201
C.1. QR Factorization Dense Linear Solver.............................................................. 201
C.2. orthogonalization...................................................................................... 205
Appendix D. LU Examples................................................................................... 211
D.1. LU Factorization....................................................................................... 211
Appendix E. Cholesky Examples........................................................................... 216
E.1. batched Cholesky Factorization..................................................................... 216
Appendix F. Examples of Dense Eigenvalue Solver.................................................... 221
F.1. Standard Symmetric Dense Eigenvalue Solver..................................................... 221
F.2. Generalized Symmetric-Definite Dense Eigenvalue Solver.......................................224
F.3. Standard Symmetric Dense Eigenvalue Solver (via Jacobi method)............................ 227
F.4. Generalized Symmetric-Definite Dense Eigenvalue Solver (via Jacobi method).............. 231
F.5. batch eigenvalue solver for dense symmetric matrix............................................ 236
Appendix G. Examples of Singular Value Decomposition............................................. 242
G.1. SVD with singular vectors............................................................................ 242
G.2. SVD with singular vectors (via Jacobi method)...................................................246
G.3. batch dense SVD solver.............................................................................. 251
Appendix H. Acknowledgements........................................................................... 258
Appendix I. Bibliography.....................................................................................261
[Link]
cuSOLVER Library DU-06709-001_v10.1 | v
[Link]
cuSOLVER Library DU-06709-001_v10.1 | vi
Chapter 1.
INTRODUCTION
The cuSolver library is a high-level package based on the cuBLAS and cuSPARSE
libraries. It combines three separate libraries under a single umbrella, each of which can
be used independently or in concert with other toolkit libraries.
The intent of cuSolver is to provide useful LAPACK-like features, such as common
matrix factorization and triangular solve routines for dense matrices, a sparse
least-squares solver and an eigenvalue solver. In addition cuSolver provides a new
refactorization library useful for solving sequences of matrices with a shared sparsity
pattern.
The first part of cuSolver is called cuSolverDN, and deals with dense matrix
factorization and solve routines such as LU, QR, SVD and LDLT, as well as useful
utilities such as matrix and vector permutations.
Next, cuSolverSP provides a new set of sparse routines based on a sparse QR
factorization. Not all matrices have a good sparsity pattern for parallelism in
factorization, so the cuSolverSP library also provides a CPU path to handle those
sequential-like matrices. For those matrices with abundant parallelism, the GPU path
will deliver higher performance. The library is designed to be called from C and C++.
The final part is cuSolverRF, a sparse re-factorization package that can provide very
good performance when solving a sequence of matrices where only the coefficients are
changed but the sparsity pattern remains the same.
The GPU path of the cuSolver library assumes data is already in the device memory.
It is the responsibility of the developer to allocate memory and to copy data between
GPU memory and CPU memory using standard CUDA runtime API routines, such as
cudaMalloc(), cudaFree(), cudaMemcpy(), and cudaMemcpyAsync().
The cuSolver library requires hardware with a CUDA compute capability (CC) of at
least 2.0 or higher. Please see the NVIDIA CUDA C Programming Guide, Appendix A for
a list of the compute capabilities corresponding to all NVIDIA GPUs.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 1
Introduction
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 2
Introduction
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 3
Introduction
The cuSolverRF library routines are available for data type double. Most of the routines
follow the naming convention:
cusolverRf_<operation>_[[Host]](...)
where the trailing optional Host qualifier indicates the data is accessed on the
host versus on the device, which is the default. The <operation> can be Setup,
Analyze, Refactor, Solve, ResetValues, AccessBundledFactors and
ExtractSplitFactors.
Finally, the return type of the cuSolverRF library routines is cusolverStatus_t.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 4
Introduction
A developer can also use the cudaMemcpy() routine to copy data from the
device to the host and vice versa, using the cudaMemcpyDeviceToHost and
cudaMemcpyHostToDevice parameters, respectively. In this case there is no need to add
a call to cudaDeviceSynchronize() because the call to cudaMemcpy() with the above
parameters is blocking and completes only when the results are ready on the host.
int major=-1,minor=-1,patch=-1;
cusolverGetProperty(MAJOR_VERSION, &major);
cusolverGetProperty(MINOR_VERSION, &minor);
cusolverGetProperty(PATCH_LEVEL, &patch);
printf("CUSOLVER Version (Major,Minor,PatchLevel): %d.%d.%d\n",
major,minor,patch);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 5
Chapter 2.
USING THE CUSOLVER API
This chapter describes how to use the cuSolver library API. It is not a reference for the
cuSolver API data types and functions; that is provided in subsequent chapters.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 6
Using the cuSolver API
‣ If you use libcusolver_static.a, then you must link with a LAPACK library,
otherwise the linker will report missing symbols. If you use a third-party LAPACK
library, you may take the advantage of the third-party LAPACK library routines to
accelerate symmetric eigenvalue solver and singular value decomposition.
‣ The liblapack_static.a is built inside [Link]. Hence, if you
use [Link], then you don't need to specify a LAPACK library. The
[Link] will not pick up any routines from the third-party LAPACK
library even you link the application with it.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 7
Chapter 3.
CUSOLVER TYPES REFERENCE
3.1.1. cusolverDnHandle_t
This is a pointer type to an opaque cuSolverDN context, which the user must initialize
by calling cusolverDnCreate() prior to calling any other library function. An
un-initialized Handle object will lead to unexpected behavior, including crashes of
cuSolverDN. The handle created and returned by cusolverDnCreate() must be
passed to every cuSolverDN function.
3.1.2. cublasFillMode_t
The type indicates which part (lower or upper) of the dense matrix was filled and
consequently should be used by the function. Its values correspond to Fortran characters
‘L’ or ‘l’ (lower) and ‘U’ or ‘u’ (upper) that are often used as parameters to legacy
BLAS implementations.
Value Meaning
3.1.3. cublasOperation_t
The cublasOperation_t type indicates which operation needs to be performed
with the dense matrix. Its values correspond to Fortran characters ‘N’ or ‘n’ (non-
transpose), ‘T’ or ‘t’ (transpose) and ‘C’ or ‘c’ (conjugate transpose) that are often
used as parameters to legacy BLAS implementations.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 8
cuSolver Types Reference
Value Meaning
3.1.4. cusolverEigType_t
The cusolverEigType_t type indicates which type of eigenvalue solver is. Its values
correspond to Fortran integer 1 (A*x = lambda*B*x), 2 (A*B*x = lambda*x), 3 (B*A*x =
lambda*x), used as parameters to legacy LAPACK implementations.
Value Meaning
3.1.5. cusolverEigMode_t
The cusolverEigMode_t type indicates whether or not eigenvectors are computed. Its
values correspond to Fortran character 'N' (only eigenvalues are computed), 'V' (both
eigenvalues and eigenvectors are computed) used as parameters to legacy LAPACK
implementations.
Value Meaning
3.1.6. cusolverStatus_t
This is the same as cusolverStatus_t in the sparse LAPACK section.
3.2.1. cusolverSpHandle_t
This is a pointer type to an opaque cuSolverSP context, which the user must initialize
by calling cusolverSpCreate() prior to calling any other library function. An
un-initialized Handle object will lead to unexpected behavior, including crashes of
cuSolverSP. The handle created and returned by cusolverSpCreate() must be passed
to every cuSolverSP function.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 9
cuSolver Types Reference
3.2.2. cusparseMatDescr_t
We have chosen to keep the same structure as exists in cuSparse to describe the shape
and properties of a matrix. This enables calls to either cuSparse or cuSolver using the
same matrix description.
typedef struct {
cusparseMatrixType_t MatrixType;
cusparseFillMode_t FillMode;
cusparseDiagType_t DiagType;
cusparseIndexBase_t IndexBase;
} cusparseMatDescr_t;
3.2.3. cusolverStatus_t
This is a status type returned by the library functions and it can have the following
values.
CUSOLVER_STATUS_SUCCESS
The operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED
The cuSolver library was not initialized. This is usually caused by the
lack of a prior call, an error in the CUDA Runtime API called by the
cuSolver routine, or an error in the hardware setup.
To correct: call cusolverCreate() prior to the function call; and
check that the hardware, an appropriate version of the driver, and the
cuSolver library are correctly installed.
CUSOLVER_STATUS_ALLOC_FAILED
Resource allocation failed inside the cuSolver library. This is usually
caused by a cudaMalloc() failure.
To correct: prior to the function call, deallocate previously allocated
memory as much as possible.
CUSOLVER_STATUS_INVALID_VALUE
An unsupported value or parameter was passed to the function (a
negative vector size, for example).
To correct: ensure that all the parameters being passed have valid
values.
CUSOLVER_STATUS_ARCH_MISMATCH
The function requires a feature absent from the device architecture;
usually caused by the lack of support for atomic operations or double
precision.
To correct: compile and run the application on a device with compute
capability 2.0 or above.
CUSOLVER_STATUS_EXECUTION_FAILED
The GPU program failed to execute. This is often caused by a launch
failure of the kernel on the GPU, which can be caused by multiple
reasons.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 10
cuSolver Types Reference
3.3.1. cusolverRfHandle_t
The cusolverRfHandle_t is a pointer to an opaque data structure that contains
the cuSolverRF library handle. The user must initialize the handle by calling
cusolverRfCreate() prior to any other cuSolverRF library calls. The handle is passed
to all other cuSolverRF library calls.
3.3.2. cusolverRfMatrixFormat_t
The cusolverRfMatrixFormat_t is an enum that indicates the input/output matrix
format assumed by the cusolverRfSetupDevice(), cusolverRfSetupHost(),
cusolverRfResetValues(), cusolveRfExtractBundledFactorsHost() and
cusolverRfExtractSplitFactorsHost() routines.
Value Meaning
3.3.3. cusolverRfNumericBoostReport_t
The cusolverRfNumericBoostReport_t is an enum that indicates whether
numeric boosting (of the pivot) was used during the cusolverRfRefactor() and
cusolverRfSolve() routines. The numeric boosting is disabled by default.
Value Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 11
cuSolver Types Reference
3.3.4. cusolverRfResetValuesFastMode_t
The cusolverRfResetValuesFastMode_t is an enum that indicates the mode used for
the cusolverRfResetValues() routine. The fast mode requires extra memory and is
recommended only if very fast calls to cusolverRfResetValues() are needed.
Value Meaning
3.3.5. cusolverRfFactorization_t
The cusolverRfFactorization_t is an enum that indicates which (internal)
algorithm is used for refactorization in the cusolverRfRefactor() routine.
Value Meaning
3.3.6. cusolverRfTriangularSolve_t
The cusolverRfTriangularSolve_t is an enum that indicates which (internal)
algorithm is used for triangular solve in the cusolverRfSolve() routine.
Value Meaning
CUSOLVER_TRIANGULAR_SOLVE_ALG0 algorithm 0.
CUSOLVER_TRIANGULAR_SOLVE_ALG1 algorithm 1. (default)
CUSOLVER_TRIANGULAR_SOLVE_ALG2 algorithm 2. Domino-based scheme.
CUSOLVER_TRIANGULAR_SOLVE_ALG3 algorithm 3. Domino-based scheme.
3.3.7. cusolverRfUnitDiagonal_t
The cusolverRfUnitDiagonal_t is an enum that indicates whether and
where the unit diagonal is stored in the input/output triangular factors
in the cusolverRfSetupDevice(), cusolverRfSetupHost() and
cusolverRfExtractSplitFactorsHost() routines.
Value Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 12
cuSolver Types Reference
3.3.8. cusolverStatus_t
The cusolverStatus_t is an enum that indicates success or failure of the cuSolverRF
library call. It is returned by all the cuSolver library routines, and it uses the same
enumerated values as the sparse and dense Lapack routines.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 13
Chapter 4.
CUSOLVER FORMATS REFERENCE
is represented as
is represented as
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 14
cuSolver Formats Reference
Note that in our CSR format sparse matrices are assumed to be stored in row-major
order, in other words, the index arrays are first sorted by row indices and then within
each row by column indices. Also it is assumed that each pair of row and column indices
appears only once.
For example, the 4x4 matrix
is represented as
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 15
cuSolver Formats Reference
Note that in our CSC format sparse matrices are assumed to be stored in column-major
order, in other words, the index arrays are first sorted by column indices and then
within each column by row indices. Also it is assumed that each pair of row and column
indices appears only once.
For example, the 4x4 matrix
is represented as
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 16
Chapter 5.
CUSOLVERDN: DENSE LAPACK FUNCTION
REFERENCE
This chapter describes the API of cuSolverDN, which provides a subset of dense
LAPACK functions.
5.1.1. cusolverDnCreate()
cusolverStatus_t
cusolverDnCreate(cusolverDnHandle_t *handle);
This function initializes the cuSolverDN library and creates a handle on the cuSolverDN
context. It must be called before any other cuSolverDN API function is invoked. It
allocates hardware resources necessary for accessing the GPU.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the initialization succeeded.
CUSOLVER_STATUS_NOT_INITIALIZED the CUDA Runtime initialization failed.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 17
cuSolverDN: dense LAPACK Function Reference
5.1.2. cusolverDnDestroy()
cusolverStatus_t
cusolverDnDestroy(cusolverDnHandle_t handle);
Status Returned
CUSOLVER_STATUS_SUCCESS the shutdown succeeded.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
5.1.3. cusolverDnSetStream()
cusolverStatus_t
cusolverDnSetStream(cusolverDnHandle_t handle, cudaStream_t streamId)
This function sets the stream to be used by the cuSolverDN library to execute its
routines.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the stream was set successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
5.1.4. cusolverDnGetStream()
cusolverStatus_t
cusolverDnGetStream(cusolverDnHandle_t handle, cudaStream_t *streamId)
This function sets the stream to be used by the cuSolverDN library to execute its
routines.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the stream was set successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 18
cuSolverDN: dense LAPACK Function Reference
5.1.5. cusolverDnCreateSyevjInfo()
cusolverStatus_t
cusolverDnCreateSyevjInfo(
syevjInfo_t *info);
This function creates and initializes the structure of syevj, syevjBatched and sygvj to
default values.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the structure was initialized successfully.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
5.1.6. cusolverDnDestroySyevjInfo()
cusolverStatus_t
cusolverDnDestroySyevjInfo(
syevjInfo_t info);
This function destroys and releases any memory required by the structure.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the resources are released successfully.
5.1.7. cusolverDnXsyevjSetTolerance()
cusolverStatus_t
cusolverDnXsyevjSetTolerance(
syevjInfo_t info,
double tolerance)
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 19
cuSolverDN: dense LAPACK Function Reference
5.1.8. cusolverDnXsyevjSetMaxSweeps()
cusolverStatus_t
cusolverDnXsyevjSetMaxSweeps(
syevjInfo_t info,
int max_sweeps)
This function configures maximum number of sweeps in syevj. The default value is
100.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
5.1.9. cusolverDnXsyevjSetSortEig()
cusolverStatus_t
cusolverDnXsyevjSetSortEig(
syevjInfo_t info,
int sort_eig)
if sort_eig is zero, the eigenvalues are not sorted. This function only works for
syevjBatched. syevj and sygvj always sort eigenvalues in ascending order. By
default, eigenvalues are always sorted in ascending order.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
5.1.10. cusolverDnXsyevjGetResidual()
cusolverStatus_t
cusolverDnXsyevjGetResidual(
cusolverDnHandle_t handle,
syevjInfo_t info,
double *residual)
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 20
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_SUPPORTED does not support batched version
5.1.11. cusolverDnXsyevjGetSweeps()
cusolverStatus_t
cusolverDnXsyevjGetSweeps(
cusolverDnHandle_t handle,
syevjInfo_t info,
int *executed_sweeps)
This function reports number of executed sweeps of syevj or sygvj. It does not
support syevjBatched. If the user calls this function after syevjBatched, the error
CUSOLVER_STATUS_NOT_SUPPORTED is returned.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_SUPPORTED does not support batched version
5.1.12. cusolverDnCreateGesvdjInfo()
cusolverStatus_t
cusolverDnCreateGesvdjInfo(
gesvdjInfo_t *info);
This function creates and initializes the structure of gesvdj and gesvdjBatched to
default values.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the structure was initialized successfully.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 21
cuSolverDN: dense LAPACK Function Reference
5.1.13. cusolverDnDestroyGesvdjInfo()
cusolverStatus_t
cusolverDnDestroyGesvdjInfo(
gesvdjInfo_t info);
This function destroys and releases any memory required by the structure.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the resources are released successfully.
5.1.14. cusolverDnXgesvdjSetTolerance()
cusolverStatus_t
cusolverDnXgesvdjSetTolerance(
gesvdjInfo_t info,
double tolerance)
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
5.1.15. cusolverDnXgesvdjSetMaxSweeps()
cusolverStatus_t
cusolverDnXgesvdjSetMaxSweeps(
gesvdjInfo_t info,
int max_sweeps)
This function configures maximum number of sweeps in gesvdj. The default value is
100.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 22
cuSolverDN: dense LAPACK Function Reference
5.1.16. cusolverDnXgesvdjSetSortEig()
cusolverStatus_t
cusolverDnXgesvdjSetSortEig(
gesvdjInfo_t info,
int sort_svd)
if sort_svd is zero, the singular values are not sorted. This function only works for
gesvdjBatched. gesvdj always sorts singular values in descending order. By default,
singular values are always sorted in descending order.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
5.1.17. cusolverDnXgesvdjGetResidual()
cusolverStatus_t
cusolverDnXgesvdjGetResidual(
cusolverDnHandle_t handle,
gesvdjInfo_t info,
double *residual)
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_SUPPORTED does not support batched version
5.1.18. cusolverDnXgesvdjGetSweeps()
cusolverStatus_t
cusolverDnXgesvdjGetSweeps(
cusolverDnHandle_t handle,
gesvdjInfo_t info,
int *executed_sweeps)
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 23
cuSolverDN: dense LAPACK Function Reference
This function reports number of executed sweeps of gesvdj. It does not support
gesvdjBatched. If the user calls this function after gesvdjBatched, the error
CUSOLVER_STATUS_NOT_SUPPORTED is returned.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_SUPPORTED does not support batched version
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 24
cuSolverDN: dense LAPACK Function Reference
5.2.1. cusolverDn<t>potrf()
These helper functions calculate the necessary size of work buffers.
cusolverStatus_t
cusolverDnSpotrf_bufferSize(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnDpotrf_bufferSize(cusolveDnHandle_t handle,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnCpotrf_bufferSize(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnZpotrf_bufferSize(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
int *Lwork);
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSpotrf(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
float *Workspace,
int Lwork,
int *devInfo );
cusolverStatus_t
cusolverDnDpotrf(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
double *Workspace,
int Lwork,
int *devInfo );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 25
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCpotrf(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
cuComplex *Workspace,
int Lwork,
int *devInfo );
cusolverStatus_t
cusolverDnZpotrf(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
cuDoubleComplex *Workspace,
int Lwork,
int *devInfo );
The user has to provide working space which is pointed by input parameter Workspace.
The input parameter Lwork is size of the working space, and it is returned by
potrf_bufferSize().
If Cholesky factorization failed, i.e. some leading minor of A is not positive definite,
or equivalently some diagonal elements of L or U is not a real number. The output
parameter devInfo would indicate smallest leading minor of A which is not positive
definite.
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
API of potrf
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 26
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0 or
lda<max(1,n)).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 27
cuSolverDN: dense LAPACK Function Reference
5.2.2. cusolverDn<t>potrs()
cusolverStatus_t
cusolverDnSpotrs(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
int nrhs,
const float *A,
int lda,
float *B,
int ldb,
int *devInfo);
cusolverStatus_t
cusolverDnDpotrs(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
int nrhs,
const double *A,
int lda,
double *B,
int ldb,
int *devInfo);
cusolverStatus_t
cusolverDnCpotrs(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
int nrhs,
const cuComplex *A,
int lda,
cuComplex *B,
int ldb,
int *devInfo);
cusolverStatus_t
cusolverDnZpotrs(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
int nrhs,
const cuDoubleComplex *A,
int lda,
cuDoubleComplex *B,
int ldb,
int *devInfo);
where A is a n×n Hermitian matrix, only lower or upper part is meaningful. The input
parameter uplo indicates which part of the matrix is used. The function would leave
other part untouched.
The user has to call potrf first to factorize matrix A. If input parameter uplo is
CUBLAS_FILL_MODE_LOWER, A is lower triangular Cholesky factor L correspoding to
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 28
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0, nrhs<0,
lda<max(1,n) or ldb<max(1,n)).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 29
cuSolverDN: dense LAPACK Function Reference
5.2.3. cusolverDn<t>potri()
These helper functions calculate the necessary size of work buffers.
cusolverStatus_t
cusolverDnSpotri_bufferSize(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnDpotri_bufferSize(cusolveDnHandle_t handle,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnCpotri_bufferSize(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnZpotri_bufferSize(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
int *Lwork);
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSpotri(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
float *Workspace,
int Lwork,
int *devInfo );
cusolverStatus_t
cusolverDnDpotri(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
double *Workspace,
int Lwork,
int *devInfo );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 30
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCpotri(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
cuComplex *Workspace,
int Lwork,
int *devInfo );
cusolverStatus_t
cusolverDnZpotri(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
cuDoubleComplex *Workspace,
int Lwork,
int *devInfo );
This function computes the inverse of a positive-definite matrix A using the Cholesky
factorization
computed by potrf().
A is a n×n matrix containing the triangular factor L or U computed by the Cholesky
factorization. Only lower or upper part is meaningful and the input parameter uplo
indicates which part of the matrix is used. The function would leave the other part
untouched.
If the input parameter uplo is CUBLAS_FILL_MODE_LOWER, only lower triangular part of
A is processed, and replaced the by lower triangular part of the inverse of A.
If the input parameter uplo is CUBLAS_FILL_MODE_UPPER, only upper triangular part
of A is processed, and replaced by the upper triangular part of the inverse of A.
The user has to provide the working space which is pointed to by input parameter
Workspace. The input parameter Lwork is the size of the working space, returned by
potri_bufferSize().
If the computation of the inverse fails, i.e. some leading minor of L or U, is null, the
output parameter devInfo would indicate the smallest leading minor of L or U which is
not positive definite.
If the output parameter devInfo = -i (less than zero), the i-th parameter is wrong
(not counting the handle).
API of potri
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 31
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0 or
lda<max(1,n)).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 32
cuSolverDN: dense LAPACK Function Reference
5.2.4. cusolverDn<t>getrf()
These helper functions calculate the size of work buffers needed.
cusolverStatus_t
cusolverDnSgetrf_bufferSize(cusolverDnHandle_t handle,
int m,
int n,
float *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnDgetrf_bufferSize(cusolverDnHandle_t handle,
int m,
int n,
double *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnCgetrf_bufferSize(cusolverDnHandle_t handle,
int m,
int n,
cuComplex *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnZgetrf_bufferSize(cusolverDnHandle_t handle,
int m,
int n,
cuDoubleComplex *A,
int lda,
int *Lwork );
The S and D data types are real single and double precision, respectively.
cusolverStatus_t
cusolverDnSgetrf(cusolverDnHandle_t handle,
int m,
int n,
float *A,
int lda,
float *Workspace,
int *devIpiv,
int *devInfo );
cusolverStatus_t
cusolverDnDgetrf(cusolverDnHandle_t handle,
int m,
int n,
double *A,
int lda,
double *Workspace,
int *devIpiv,
int *devInfo );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 33
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCgetrf(cusolverDnHandle_t handle,
int m,
int n,
cuComplex *A,
int lda,
cuComplex *Workspace,
int *devIpiv,
int *devInfo );
cusolverStatus_t
cusolverDnZgetrf(cusolverDnHandle_t handle,
int m,
int n,
cuDoubleComplex *A,
int lda,
cuDoubleComplex *Workspace,
int *devIpiv,
int *devInfo );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 34
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n<0 or
lda<max(1,m)).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 35
cuSolverDN: dense LAPACK Function Reference
5.2.5. cusolverDn<t>getrs()
cusolverStatus_t
cusolverDnSgetrs(cusolverDnHandle_t handle,
cublasOperation_t trans,
int n,
int nrhs,
const float *A,
int lda,
const int *devIpiv,
float *B,
int ldb,
int *devInfo );
cusolverStatus_t
cusolverDnDgetrs(cusolverDnHandle_t handle,
cublasOperation_t trans,
int n,
int nrhs,
const double *A,
int lda,
const int *devIpiv,
double *B,
int ldb,
int *devInfo );
cusolverStatus_t
cusolverDnCgetrs(cusolverDnHandle_t handle,
cublasOperation_t trans,
int n,
int nrhs,
const cuComplex *A,
int lda,
const int *devIpiv,
cuComplex *B,
int ldb,
int *devInfo );
cusolverStatus_t
cusolverDnZgetrs(cusolverDnHandle_t handle,
cublasOperation_t trans,
int n,
int nrhs,
const cuDoubleComplex *A,
int lda,
const int *devIpiv,
cuDoubleComplex *B,
int ldb,
int *devInfo );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 36
cuSolverDN: dense LAPACK Function Reference
where A is a n×n matrix, and was LU-factored by getrf, that is, lower trianular part of
A is L, and upper triangular part (including diagonal elements) of A is U. B is a n×nrhs
right-hand side matrix.
The input parameter trans is defined by
The input parameter devIpiv is an output of getrf. It contains pivot indices, which are
used to permutate right-hand sides.
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
The user can combine getrf and getrs to complete a linear solver. Please refer to
appendix D.1.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0 or
lda<max(1,n) or ldb<max(1,n)).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 37
cuSolverDN: dense LAPACK Function Reference
5.2.6. cusolverDn<t>geqrf()
These helper functions calculate the size of work buffers needed.
cusolverStatus_t
cusolverDnSgeqrf_bufferSize(cusolverDnHandle_t handle,
int m,
int n,
float *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnDgeqrf_bufferSize(cusolverDnHandle_t handle,
int m,
int n,
double *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnCgeqrf_bufferSize(cusolverDnHandle_t handle,
int m,
int n,
cuComplex *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnZgeqrf_bufferSize(cusolverDnHandle_t handle,
int m,
int n,
cuDoubleComplex *A,
int lda,
int *Lwork );
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSgeqrf(cusolverDnHandle_t handle,
int m,
int n,
float *A,
int lda,
float *TAU,
float *Workspace,
int Lwork,
int *devInfo );
cusolverStatus_t
cusolverDnDgeqrf(cusolverDnHandle_t handle,
int m,
int n,
double *A,
int lda,
double *TAU,
double *Workspace,
int Lwork,
int *devInfo );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 38
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCgeqrf(cusolverDnHandle_t handle,
int m,
int n,
cuComplex *A,
int lda,
cuComplex *TAU,
cuComplex *Workspace,
int Lwork,
int *devInfo );
cusolverStatus_t
cusolverDnZgeqrf(cusolverDnHandle_t handle,
int m,
int n,
cuDoubleComplex *A,
int lda,
cuDoubleComplex *TAU,
cuDoubleComplex *Workspace,
int Lwork,
int *devInfo );
where A is a m×n matrix, Q is a m×n matrix, and R is a n×n upper triangular matrix.
The user has to provide working space which is pointed by input parameter Workspace.
The input parameter Lwork is size of the working space, and it is returned by
geqrf_bufferSize().
The matrix R is overwritten in upper triangular part of A, including diagonal elements.
The matrix Q is not formed explicitly, instead, a sequence of householder vectors are
stored in lower triangular part of A. The leading nonzero element of householder vector
is assumed to be 1 such that output parameter TAU contains the scaling factor τ. If v
is original householder vector, q is the new householder vector corresponding to τ,
satisying the following relation
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
API of geqrf
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 39
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n<0 or
lda<max(1,m)).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 40
cuSolverDN: dense LAPACK Function Reference
5.2.7. cusolverDn<t>ormqr()
These helper functions calculate the size of work buffers needed.
cusolverStatus_t
cusolverDnSormqr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasOperation_t trans,
int m,
int n,
int k,
const float *A,
int lda,
const float *C,
int ldc,
int *lwork);
cusolverStatus_t
cusolverDnDormqr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasOperation_t trans,
int m,
int n,
int k,
const double *A,
int lda,
const double *C,
int ldc,
int *lwork);
cusolverStatus_t
cusolverDnCunmqr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasOperation_t trans,
int m,
int n,
int k,
const cuComplex *A,
int lda,
const cuComplex *C,
int ldc,
int *lwork);
cusolverStatus_t
cusolverDnZunmqr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasOperation_t trans,
int m,
int n,
int k,
const cuDoubleComplex *A,
int lda,
const cuDoubleComplex *C,
int ldc,
int *lwork);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 41
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSormqr(cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasOperation_t trans,
int m,
int n,
int k,
const float *A,
int lda,
const float *tau,
float *C,
int ldc,
float *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnDormqr(cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasOperation_t trans,
int m,
int n,
int k,
const double *A,
int lda,
const double *tau,
double *C,
int ldc,
double *work,
int lwork,
int *devInfo);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 42
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCunmqr(cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasOperation_t trans,
int m,
int n,
int k,
const cuComplex *A,
int lda,
const cuComplex *tau,
cuComplex *C,
int ldc,
cuComplex *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnZunmqr(cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasOperation_t trans,
int m,
int n,
int k,
const cuDoubleComplex *A,
int lda,
const cuDoubleComplex *tau,
cuDoubleComplex *C,
int ldc,
cuDoubleComplex *work,
int lwork,
int *devInfo);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 43
cuSolverDN: dense LAPACK Function Reference
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
The user can combine geqrf, ormqr and trsm to complete a linear solver or a least-
square solver. Please refer to appendix C.1.
API of ormqr
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS The operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED The library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE Invalid parameters were passed (m,n<0 or wrong
lda or ldc).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 44
cuSolverDN: dense LAPACK Function Reference
5.2.8. cusolverDn<t>orgqr()
These helper functions calculate the size of work buffers needed.
cusolverStatus_t
cusolverDnSorgqr_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int k,
const float *A,
int lda,
const float *tau,
int *lwork);
cusolverStatus_t
cusolverDnDorgqr_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int k,
const double *A,
int lda,
const double *tau,
int *lwork);
cusolverStatus_t
cusolverDnCungqr_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int k,
const cuComplex *A,
int lda,
const cuComplex *tau,
int *lwork);
cusolverStatus_t
cusolverDnZungqr_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int k,
const cuDoubleComplex *A,
int lda,
const cuDoubleComplex *tau,
int *lwork);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 45
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSorgqr(
cusolverDnHandle_t handle,
int m,
int n,
int k,
float *A,
int lda,
const float *tau,
float *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnDorgqr(
cusolverDnHandle_t handle,
int m,
int n,
int k,
double *A,
int lda,
const double *tau,
double *work,
int lwork,
int *devInfo);
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCungqr(
cusolverDnHandle_t handle,
int m,
int n,
int k,
cuComplex *A,
int lda,
const cuComplex *tau,
cuComplex *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnZungqr(
cusolverDnHandle_t handle,
int m,
int n,
int k,
cuDoubleComplex *A,
int lda,
const cuDoubleComplex *tau,
cuDoubleComplex *work,
int lwork,
int *devInfo);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 46
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n,k<0, n>m,
k>n or lda<m).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 47
cuSolverDN: dense LAPACK Function Reference
5.2.9. cusolverDn<t>sytrf()
These helper functions calculate the size of the needed buffers.
cusolverStatus_t
cusolverDnSsytrf_bufferSize(cusolverDnHandle_t handle,
int n,
float *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnDsytrf_bufferSize(cusolverDnHandle_t handle,
int n,
double *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnCsytrf_bufferSize(cusolverDnHandle_t handle,
int n,
cuComplex *A,
int lda,
int *Lwork );
cusolverStatus_t
cusolverDnZsytrf_bufferSize(cusolverDnHandle_t handle,
int n,
cuDoubleComplex *A,
int lda,
int *Lwork );
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSsytrf(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
int *ipiv,
float *work,
int lwork,
int *devInfo );
cusolverStatus_t
cusolverDnDsytrf(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
int *ipiv,
double *work,
int lwork,
int *devInfo );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 48
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCsytrf(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
int *ipiv,
cuComplex *work,
int lwork,
int *devInfo );
cusolverStatus_t
cusolverDnZsytrf(cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
int *ipiv,
cuDoubleComplex *work,
int lwork,
int *devInfo );
The user has to provide working space which is pointed by input parameter work.
The input parameter lwork is size of the working space, and it is returned by
sytrf_bufferSize().
If Bunch-Kaufman factorization failed, i.e. A is singular. The output parameter devInfo
= i would indicate D(i,i)=0.
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
The output parameter devIpiv contains pivoting sequence. If devIpiv(i) = k > 0,
D(i,i) is 1x1 block, and i-th row/column of A is interchanged with k-th row/column
of A. If uplo is CUBLAS_FILL_MODE_UPPER and devIpiv(i-1) = devIpiv(i) = -
m < 0, D(i-1:i,i-1:i) is a 2x2 block, and (i-1)-th row/column is interchanged
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 49
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0 or
lda<max(1,n)).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 50
cuSolverDN: dense LAPACK Function Reference
5.2.10. cusolverDn<t>potrfBatched()
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSpotrfBatched(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
float *Aarray[],
int lda,
int *infoArray,
int batchSize);
cusolverStatus_t
cusolverDnDpotrfBatched(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
double *Aarray[],
int lda,
int *infoArray,
int batchSize);
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCpotrfBatched(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuComplex *Aarray[],
int lda,
int *infoArray,
int batchSize);
cusolverStatus_t
cusolverDnZpotrfBatched(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *Aarray[],
int lda,
int *infoArray,
int batchSize);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 51
cuSolverDN: dense LAPACK Function Reference
If Cholesky factorization failed, i.e. some leading minor of A is not positive definite,
or equivalently some diagonal elements of L or U is not a real number. The output
parameter infoArray would indicate smallest leading minor of A which is not positive
definite.
infoArray is an integer array of size batchsize. If potrfBatched returns
CUSOLVER_STATUS_INVALID_VALUE, infoArray[0] = -i (less than zero), meaning
that the i-th parameter is wrong (not counting handle). If potrfBatched returns
CUSOLVER_STATUS_SUCCESS but infoArray[i] = k is positive, then i-th matrix is
not positive definite and the Cholesky factorization failed at row k.
Remark: the other part of A is used as a workspace. For example, if uplo is
CUBLAS_FILL_MODE_UPPER, upper triangle of A contains cholesky factor U and lower
triangle of A is destroyed after potrfBatched.
API of potrfBatched
parameter Memory In/out Meaning
Status Returned
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 52
cuSolverDN: dense LAPACK Function Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 53
cuSolverDN: dense LAPACK Function Reference
5.2.11. cusolverDn<t>potrsBatched()
cusolverStatus_t
cusolverDnSpotrsBatched(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
int nrhs,
float *Aarray[],
int lda,
float *Barray[],
int ldb,
int *info,
int batchSize);
cusolverStatus_t
cusolverDnDpotrsBatched(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
int nrhs,
double *Aarray[],
int lda,
double *Barray[],
int ldb,
int *info,
int batchSize);
cusolverStatus_t
cusolverDnCpotrsBatched(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
int nrhs,
cuComplex *Aarray[],
int lda,
cuComplex *Barray[],
int ldb,
int *info,
int batchSize);
cusolverStatus_t
cusolverDnZpotrsBatched(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
int nrhs,
cuDoubleComplex *Aarray[],
int lda,
cuDoubleComplex *Barray[],
int ldb,
int *info,
int batchSize);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 54
cuSolverDN: dense LAPACK Function Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 55
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0, nrhs<0,
lda<max(1,n), ldb<max(1,n) or batchSize<0).
5.3.1. cusolverDn<t>gebrd()
These helper functions calculate the size of work buffers needed.
cusolverStatus_t
cusolverDnSgebrd_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int *Lwork );
cusolverStatus_t
cusolverDnDgebrd_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int *Lwork );
cusolverStatus_t
cusolverDnCgebrd_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int *Lwork );
cusolverStatus_t
cusolverDnZgebrd_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int *Lwork );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 56
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSgebrd(cusolverDnHandle_t handle,
int m,
int n,
float *A,
int lda,
float *D,
float *E,
float *TAUQ,
float *TAUP,
float *Work,
int Lwork,
int *devInfo );
cusolverStatus_t
cusolverDnDgebrd(cusolverDnHandle_t handle,
int m,
int n,
double *A,
int lda,
double *D,
double *E,
double *TAUQ,
double *TAUP,
double *Work,
int Lwork,
int *devInfo );
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCgebrd(cusolverDnHandle_t handle,
int m,
int n,
cuComplex *A,
int lda,
float *D,
float *E,
cuComplex *TAUQ,
cuComplex *TAUP,
cuComplex *Work,
int Lwork,
int *devInfo );
cusolverStatus_t
cusolverDnZgebrd(cusolverDnHandle_t handle,
int m,
int n,
cuDoubleComplex *A,
int lda,
double *D,
double *E,
cuDoubleComplex *TAUQ,
cuDoubleComplex *TAUP,
cuDoubleComplex *Work,
int Lwork,
int *devInfo );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 57
cuSolverDN: dense LAPACK Function Reference
This function reduces a general m×n matrix A to a real upper or lower bidiagonal form B
by an orthogonal transformation:
If m>=n, B is upper bidiagonal; if m<n, B is lower bidiagonal.
The matrix Q and P are overwritten into matrix A in the following sense:
if m>=n, the diagonal and the first superdiagonal are overwritten with the upper
bidiagonal matrix B; the elements below the diagonal, with the array TAUQ, represent the
orthogonal matrix Q as a product of elementary reflectors, and the elements above the
first superdiagonal, with the array TAUP, represent the orthogonal matrix P as a product
of elementary reflectors.
if m<n, the diagonal and the first subdiagonal are overwritten with the lower bidiagonal
matrix B; the elements below the first subdiagonal, with the array TAUQ, represent the
orthogonal matrix Q as a product of elementary reflectors, and the elements above
the diagonal, with the array TAUP, represent the orthogonal matrix P as a product of
elementary reflectors.
The user has to provide working space which is pointed by input parameter Work.
The input parameter Lwork is size of the working space, and it is returned by
gebrd_bufferSize().
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
Remark: gebrd only supports m>=n.
API of gebrd
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 58
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n<0, or
lda<max(1,m)).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 59
cuSolverDN: dense LAPACK Function Reference
5.3.2. cusolverDn<t>orgbr()
These helper functions calculate the size of work buffers needed.
cusolverStatus_t
cusolverDnSorgbr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
int m,
int n,
int k,
const float *A,
int lda,
const float *tau,
int *lwork);
cusolverStatus_t
cusolverDnDorgbr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
int m,
int n,
int k,
const double *A,
int lda,
const double *tau,
int *lwork);
cusolverStatus_t
cusolverDnCungbr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
int m,
int n,
int k,
const cuComplex *A,
int lda,
const cuComplex *tau,
int *lwork);
cusolverStatus_t
cusolverDnZungbr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
int m,
int n,
int k,
const cuDoubleComplex *A,
int lda,
const cuDoubleComplex *tau,
int *lwork);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 60
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSorgbr(
cusolverDnHandle_t handle,
cublasSideMode_t side,
int m,
int n,
int k,
float *A,
int lda,
const float *tau,
float *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnDorgbr(
cusolverDnHandle_t handle,
cublasSideMode_t side,
int m,
int n,
int k,
double *A,
int lda,
const double *tau,
double *work,
int lwork,
int *devInfo);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 61
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCungbr(
cusolverDnHandle_t handle,
cublasSideMode_t side,
int m,
int n,
int k,
cuComplex *A,
int lda,
const cuComplex *tau,
cuComplex *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnZungbr(
cusolverDnHandle_t handle,
cublasSideMode_t side,
int m,
int n,
int k,
cuDoubleComplex *A,
int lda,
const cuDoubleComplex *tau,
cuDoubleComplex *work,
int lwork,
int *devInfo);
This function generates one of the unitary matrices Q or P**H determined by gebrd
when reducing a matrix A to bidiagonal form:
Q and P**H are defined as products of elementary reflectors H(i) or G(i) respectively.
The user has to provide working space which is pointed by input parameter work.
The input parameter lwork is size of the working space, and it is returned by
orgbr_bufferSize().
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
API of orgbr
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 62
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n<0 or wrong
lda ).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 63
cuSolverDN: dense LAPACK Function Reference
5.3.3. cusolverDn<t>sytrd()
These helper functions calculate the size of work buffers needed.
cusolverStatus_t
cusolverDnSsytrd_bufferSize(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
const float *A,
int lda,
const float *d,
const float *e,
const float *tau,
int *lwork);
cusolverStatus_t
cusolverDnDsytrd_bufferSize(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
const double *A,
int lda,
const double *d,
const double *e,
const double *tau,
int *lwork);
cusolverStatus_t
cusolverDnChetrd_bufferSize(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
const cuComplex *A,
int lda,
const float *d,
const float *e,
const cuComplex *tau,
int *lwork);
cusolverStatus_t
cusolverDnZhetrd_bufferSize(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
const cuDoubleComplex *A,
int lda,
const double *d,
const double *e,
const cuDoubleComplex *tau,
int *lwork);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 64
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSsytrd(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
float *d,
float *e,
float *tau,
float *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnDsytrd(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
double *d,
double *e,
double *tau,
double *work,
int lwork,
int *devInfo);
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnChetrd(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
float *d,
float *e,
cuComplex *tau,
cuComplex *work,
int lwork,
int *devInfo);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 65
cuSolverDN: dense LAPACK Function Reference
This function reduces a general symmetric (Hermitian) n×n matrix A to real symmetric
tridiagonal form T by an orthogonal transformation:
As an output, A contains T and householder reflection vectors. If uplo =
CUBLAS_FILL_MODE_UPPER, the diagonal and first superdiagonal of A are overwritten
by the corresponding elements of the tridiagonal matrix T, and the elements above the
first superdiagonal, with the array tau, represent the orthogonal matrix Q as a product
of elementary reflectors; If uplo = CUBLAS_FILL_MODE_LOWER, the diagonal and first
subdiagonal of A are overwritten by the corresponding elements of the tridiagonal
matrix T, and the elements below the first subdiagonal, with the array tau, represent the
orthogonal matrix Q as a product of elementary reflectors.
The user has to provide working space which is pointed by input parameter work.
The input parameter lwork is size of the working space, and it is returned by
sytrd_bufferSize().
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
API of sytrd
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 66
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed
(n<0, or lda<max(1,n), or uplo is
not CUBLAS_FILL_MODE_LOWER or
CUBLAS_FILL_MODE_UPPER).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 67
cuSolverDN: dense LAPACK Function Reference
5.3.4. cusolverDn<t>ormtr()
These helper functions calculate the size of work buffers needed.
cusolverStatus_t
cusolverDnSormtr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasFillMode_t uplo,
cublasOperation_t trans,
int m,
int n,
const float *A,
int lda,
const float *tau,
const float *C,
int ldc,
int *lwork);
cusolverStatus_t
cusolverDnDormtr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasFillMode_t uplo,
cublasOperation_t trans,
int m,
int n,
const double *A,
int lda,
const double *tau,
const double *C,
int ldc,
int *lwork);
cusolverStatus_t
cusolverDnCunmtr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasFillMode_t uplo,
cublasOperation_t trans,
int m,
int n,
const cuComplex *A,
int lda,
const cuComplex *tau,
const cuComplex *C,
int ldc,
int *lwork);
cusolverStatus_t
cusolverDnZunmtr_bufferSize(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasFillMode_t uplo,
cublasOperation_t trans,
int m,
int n,
const cuDoubleComplex *A,
int lda,
const cuDoubleComplex *tau,
const cuDoubleComplex *C,
int ldc,
int *lwork);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 68
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSormtr(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasFillMode_t uplo,
cublasOperation_t trans,
int m,
int n,
float *A,
int lda,
float *tau,
float *C,
int ldc,
float *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnDormtr(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasFillMode_t uplo,
cublasOperation_t trans,
int m,
int n,
double *A,
int lda,
double *tau,
double *C,
int ldc,
double *work,
int lwork,
int *devInfo);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 69
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCunmtr(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasFillMode_t uplo,
cublasOperation_t trans,
int m,
int n,
cuComplex *A,
int lda,
cuComplex *tau,
cuComplex *C,
int ldc,
cuComplex *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnZunmtr(
cusolverDnHandle_t handle,
cublasSideMode_t side,
cublasFillMode_t uplo,
cublasOperation_t trans,
int m,
int n,
cuDoubleComplex *A,
int lda,
cuDoubleComplex *tau,
cuDoubleComplex *C,
int ldc,
cuDoubleComplex *work,
int lwork,
int *devInfo);
The user has to provide working space which is pointed by input parameter work.
The input parameter lwork is size of the working space, and it is returned by
ormtr_bufferSize().
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 70
cuSolverDN: dense LAPACK Function Reference
API of ormtr
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 71
cuSolverDN: dense LAPACK Function Reference
5.3.5. cusolverDn<t>orgtr()
These helper functions calculate the size of work buffers needed.
cusolverStatus_t
cusolverDnSorgtr_bufferSize(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
const float *A,
int lda,
const float *tau,
int *lwork);
cusolverStatus_t
cusolverDnDorgtr_bufferSize(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
const double *A,
int lda,
const double *tau,
int *lwork);
cusolverStatus_t
cusolverDnCungtr_bufferSize(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
const cuComplex *A,
int lda,
const cuComplex *tau,
int *lwork);
cusolverStatus_t
cusolverDnZungtr_bufferSize(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
const cuDoubleComplex *A,
int lda,
const cuDoubleComplex *tau,
int *lwork);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 72
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSorgtr(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
const float *tau,
float *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnDorgtr(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
const double *tau,
double *work,
int lwork,
int *devInfo);
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCungtr(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
const cuComplex *tau,
cuComplex *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnZungtr(
cusolverDnHandle_t handle,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
const cuDoubleComplex *tau,
cuDoubleComplex *work,
int lwork,
int *devInfo);
This function generates a unitary matrix Q which is defined as the product of n-1
elementary reflectors of order n, as returned by sytrd:
The user has to provide working space which is pointed by input parameter work.
The input parameter lwork is size of the working space, and it is returned by
orgtr_bufferSize().
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 73
cuSolverDN: dense LAPACK Function Reference
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle).
API of orgtr
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0 or wrong lda
).
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 74
cuSolverDN: dense LAPACK Function Reference
5.3.6. cusolverDn<t>gesvd()
The helper functions below can calculate the sizes needed for pre-allocated buffer.
cusolverStatus_t
cusolverDnSgesvd_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int *lwork );
cusolverStatus_t
cusolverDnDgesvd_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int *lwork );
cusolverStatus_t
cusolverDnCgesvd_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int *lwork );
cusolverStatus_t
cusolverDnZgesvd_bufferSize(
cusolverDnHandle_t handle,
int m,
int n,
int *lwork );
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 75
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSgesvd (
cusolverDnHandle_t handle,
signed char jobu,
signed char jobvt,
int m,
int n,
float *A,
int lda,
float *S,
float *U,
int ldu,
float *VT,
int ldvt,
float *work,
int lwork,
float *rwork,
int *devInfo);
cusolverStatus_t
cusolverDnDgesvd (
cusolverDnHandle_t handle,
signed char jobu,
signed char jobvt,
int m,
int n,
double *A,
int lda,
double *S,
double *U,
int ldu,
double *VT,
int ldvt,
double *work,
int lwork,
double *rwork,
int *devInfo);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 76
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCgesvd (
cusolverDnHandle_t handle,
signed char jobu,
signed char jobvt,
int m,
int n,
cuComplex *A,
int lda,
float *S,
cuComplex *U,
int ldu,
cuComplex *VT,
int ldvt,
cuComplex *work,
int lwork,
float *rwork,
int *devInfo);
cusolverStatus_t
cusolverDnZgesvd (
cusolverDnHandle_t handle,
signed char jobu,
signed char jobvt,
int m,
int n,
cuDoubleComplex *A,
int lda,
double *S,
cuDoubleComplex *U,
int ldu,
cuDoubleComplex *VT,
int ldvt,
cuDoubleComplex *work,
int lwork,
double *rwork,
int *devInfo);
This function computes the singular value decomposition (SVD) of a m×n matrix A and
corresponding the left and/or right singular vectors. The SVD is written
where Σ is an m×n matrix which is zero except for its min(m,n) diagonal elements, U is
an m×m unitary matrix, and V is an n×n unitary matrix. The diagonal elements of Σ are
the singular values of A; they are real and non-negative, and are returned in descending
order. The first min(m,n) columns of U and V are the left and right singular vectors of A.
The user has to provide working space which is pointed by input parameter work.
The input parameter lwork is size of the working space, and it is returned by
gesvd_bufferSize().
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong
(not counting handle). if bdsqr did not converge, devInfo specifies how many
superdiagonals of an intermediate bidiagonal form did not converge to zero.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 77
cuSolverDN: dense LAPACK Function Reference
The rwork is real array of dimension (min(m,n)-1). If devInfo>0 and rwork is not
nil, rwork contains the unconverged superdiagonal elements of an upper bidiagonal
matrix. This is slightly different from LAPACK which puts unconverged superdiagonal
elements in work if type is real; in rwork if type is complex. rwork can be a NULL
pointer if the user does not want the information from supperdiagonal.
Appendix G.1 provides a simple example of gesvd.
Remark 1: gesvd only supports m>=n.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 78
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n<0
or lda<max(1,m) or ldu<max(1,m) or
ldvt<max(1,n) ).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 79
cuSolverDN: dense LAPACK Function Reference
5.3.7. cusolverDn<t>gesvdj()
The helper functions below can calculate the sizes needed for pre-allocated buffer.
cusolverStatus_t
cusolverDnSgesvdj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int econ,
int m,
int n,
const float *A,
int lda,
const float *S,
const float *U,
int ldu,
const float *V,
int ldv,
int *lwork,
gesvdjInfo_t params);
cusolverStatus_t
cusolverDnDgesvdj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int econ,
int m,
int n,
const double *A,
int lda,
const double *S,
const double *U,
int ldu,
const double *V,
int ldv,
int *lwork,
gesvdjInfo_t params);
cusolverStatus_t
cusolverDnCgesvdj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int econ,
int m,
int n,
const cuComplex *A,
int lda,
const float *S,
const cuComplex *U,
int ldu,
const cuComplex *V,
int ldv,
int *lwork,
gesvdjInfo_t params);
cusolverStatus_t
cusolverDnZgesvdj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int econ,
int m,
int n,
const cuDoubleComplex *A,
int lda,
const double *S,
const cuDoubleComplex *U,
int ldu,
const cuDoubleComplex *V,
int ldv,
int *lwork,
gesvdjInfo_t params);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 80
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSgesvdj(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int econ,
int m,
int n,
float *A,
int lda,
float *S,
float *U,
int ldu,
float *V,
int ldv,
float *work,
int lwork,
int *info,
gesvdjInfo_t params);
cusolverStatus_t
cusolverDnDgesvdj(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int econ,
int m,
int n,
double *A,
int lda,
double *S,
double *U,
int ldu,
double *V,
int ldv,
double *work,
int lwork,
int *info,
gesvdjInfo_t params);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 81
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCgesvdj(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int econ,
int m,
int n,
cuComplex *A,
int lda,
float *S,
cuComplex *U,
int ldu,
cuComplex *V,
int ldv,
cuComplex *work,
int lwork,
int *info,
gesvdjInfo_t params);
cusolverStatus_t
cusolverDnZgesvdj(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int econ,
int m,
int n,
cuDoubleComplex *A,
int lda,
double *S,
cuDoubleComplex *U,
int ldu,
cuDoubleComplex *V,
int ldv,
cuDoubleComplex *work,
int lwork,
int *info,
gesvdjInfo_t params);
This function computes the singular value decomposition (SVD) of a m×n matrix A and
corresponding the left and/or right singular vectors. The SVD is written
where Σ is an m×n matrix which is zero except for its min(m,n) diagonal elements, U is
an m×m unitary matrix, and V is an n×n unitary matrix. The diagonal elements of Σ are
the singular values of A; they are real and non-negative, and are returned in descending
order. The first min(m,n) columns of U and V are the left and right singular vectors of A.
gesvdj has the same functionality as gesvd. The difference is that gesvd uses QR
algorithm and gesvdj uses Jacobi method. The parallelism of Jacobi method gives GPU
better performance on small and medium size matrices. Moreover the user can configure
gesvdj to perform approximation up to certain accuracy.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 82
cuSolverDN: dense LAPACK Function Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 83
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n<0
or lda<max(1,m) or ldu<max(1,m)
or ldv<max(1,n) or jobz is not
CUSOLVER_EIG_MODE_NOVECTOR or
CUSOLVER_EIG_MODE_VECTOR ).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 84
cuSolverDN: dense LAPACK Function Reference
5.3.8. cusolverDn<t>gesvdjBatched()
The helper functions below can calculate the sizes needed for pre-allocated buffer.
cusolverStatus_t
cusolverDnSgesvdjBatched_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int m,
int n,
const float *A,
int lda,
const float *S,
const float *U,
int ldu,
const float *V,
int ldv,
int *lwork,
gesvdjInfo_t params,
int batchSize);
cusolverStatus_t
cusolverDnDgesvdjBatched_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int m,
int n,
const double *A,
int lda,
const double *S,
const double *U,
int ldu,
const double *V,
int ldv,
int *lwork,
gesvdjInfo_t params,
int batchSize);
cusolverStatus_t
cusolverDnCgesvdjBatched_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int m,
int n,
const cuComplex *A,
int lda,
const float *S,
const cuComplex *U,
int ldu,
const cuComplex *V,
int ldv,
int *lwork,
gesvdjInfo_t params,
int batchSize);
cusolverStatus_t
cusolverDnZgesvdjBatched_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int m,
int n,
const cuDoubleComplex *A,
int lda,
const double *S,
const cuDoubleComplex *U,
int ldu,
const cuDoubleComplex *V,
int ldv,
int *lwork,
gesvdjInfo_t params,
[Link]
intLibrary
cuSOLVER batchSize); DU-06709-001_v10.1 | 85
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSgesvdjBatched(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int m,
int n,
float *A,
int lda,
float *S,
float *U,
int ldu,
float *V,
int ldv,
float *work,
int lwork,
int *info,
gesvdjInfo_t params,
int batchSize);
cusolverStatus_t
cusolverDnDgesvdjBatched(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int m,
int n,
double *A,
int lda,
double *S,
double *U,
int ldu,
double *V,
int ldv,
double *work,
int lwork,
int *info,
gesvdjInfo_t params,
int batchSize);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 86
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCgesvdjBatched(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int m,
int n,
cuComplex *A,
int lda,
float *S,
cuComplex *U,
int ldu,
cuComplex *V,
int ldv,
cuComplex *work,
int lwork,
int *info,
gesvdjInfo_t params,
int batchSize);
cusolverStatus_t
cusolverDnZgesvdjBatched(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
int m,
int n,
cuDoubleComplex *A,
int lda,
double *S,
cuDoubleComplex *U,
int ldu,
cuDoubleComplex *V,
int ldv,
cuDoubleComplex *work,
int lwork,
int *info,
gesvdjInfo_t params,
int batchSize);
This function computes singular values and singular vectors of a squence of general m×n
matrices
where is a real m×n diagonal matrix which is zero except for its min(m,n) diagonal
elements. (left singular vectors) is a m×m unitary matrix and (right singular
vectors) is a n×n unitary matrix. The diagonal elements of are the singular values of
in either descending order or non-sorting order.
gesvdjBatched performs gesvdj on each matrix. It requires that all matrices are of the
same size m,n no greater than 32 and are packed in contiguous way,
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 87
cuSolverDN: dense LAPACK Function Reference
Each matrix is column-major with leading dimension lda, so the formula for random
access is .
The parameter S also contains singular values of each matrix in contiguous way,
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 88
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n<0
or lda<max(1,m) or ldu<max(1,m)
or ldv<max(1,n) or jobz is not
CUSOLVER_EIG_MODE_NOVECTOR or
CUSOLVER_EIG_MODE_VECTOR , or batchSize<0
).
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 89
cuSolverDN: dense LAPACK Function Reference
5.3.9. cusolverDn<t>syevd()
The helper functions below can calculate the sizes needed for pre-allocated buffer.
cusolverStatus_t
cusolverDnSsyevd_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const float *A,
int lda,
const float *W,
int *lwork);
cusolverStatus_t
cusolverDnDsyevd_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const double *A,
int lda,
const double *W,
int *lwork);
cusolverStatus_t
cusolverDnCheevd_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuComplex *A,
int lda,
const float *W,
int *lwork);
cusolverStatus_t
cusolverDnZheevd_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuDoubleComplex *A,
int lda,
const double *W,
int *lwork);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 90
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSsyevd(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
float *W,
float *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnDsyevd(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
double *W,
double *work,
int lwork,
int *devInfo);
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCheevd(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
float *W,
cuComplex *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnZheevd(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
double *W,
cuDoubleComplex *work,
int lwork,
int *devInfo);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 91
cuSolverDN: dense LAPACK Function Reference
where Λ is a real n×n diagonal matrix. V is an n×n unitary matrix. The diagonal elements
of Λ are the eigenvalues of A in ascending order.
The user has to provide working space which is pointed by input parameter work.
The input parameter lwork is size of the working space, and it is returned by
syevd_bufferSize().
If output parameter devInfo = -i (less than zero), the i-th parameter is wrong (not
counting handle). If devInfo = i (greater than zero), i off-diagonal elements of an
intermediate tridiagonal form did not converge to zero.
if jobz = CUSOLVER_EIG_MODE_VECTOR, A contains the orthonormal eigenvectors
of the matrix A. The eigenvectors are computed by a divide and conquer algorithm.
Appendix F.1 provides a simple example of syevd.
API of syevd
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 92
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0,
or lda<max(1,n), or jobz is not
CUSOLVER_EIG_MODE_NOVECTOR or
CUSOLVER_EIG_MODE_VECTOR, or uplo
is not CUBLAS_FILL_MODE_LOWER or
CUBLAS_FILL_MODE_UPPER).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 93
cuSolverDN: dense LAPACK Function Reference
5.3.10. cusolverDn<t>sygvd()
The helper functions below can calculate the sizes needed for pre-allocated buffer.
cusolverStatus_t
cusolverDnSsygvd_bufferSize(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const float *A,
int lda,
const float *B,
int ldb,
const float *W,
int *lwork);
cusolverStatus_t
cusolverDnDsygvd_bufferSize(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const double *A,
int lda,
const double *B,
int ldb,
const double *W,
int *lwork);
cusolverStatus_t
cusolverDnChegvd_bufferSize(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuComplex *A,
int lda,
const cuComplex *B,
int ldb,
const float *W,
int *lwork);
cusolverStatus_t
cusolverDnZhegvd_bufferSize(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuDoubleComplex *A,
int lda,
const cuDoubleComplex *B,
int ldb,
const double *W,
int *lwork);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 94
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSsygvd(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
float *B,
int ldb,
float *W,
float *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnDsygvd(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
double *B,
int ldb,
double *W,
double *work,
int lwork,
int *devInfo);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 95
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnChegvd(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
cuComplex *B,
int ldb,
float *W,
cuComplex *work,
int lwork,
int *devInfo);
cusolverStatus_t
cusolverDnZhegvd(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
cuDoubleComplex *B,
int ldb,
double *W,
cuDoubleComplex *work,
int lwork,
int *devInfo);
where the matrix B is positive definite. Λ is a real n×n diagonal matrix. The diagonal
elements of Λ are the eigenvalues of (A, B) in ascending order. V is an n×n orthogonal
matrix. The eigenvectors are normalized as follows:
The user has to provide working space which is pointed by input parameter work.
The input parameter lwork is size of the working space, and it is returned by
sygvd_bufferSize().
If output parameter devInfo = -i (less than zero), the i-th parameter is
wrong (not counting handle). If devInfo = i (i > 0 and i<=n) and jobz =
CUSOLVER_EIG_MODE_NOVECTOR, i off-diagonal elements of an intermediate
tridiagonal form did not converge to zero. If devInfo = N + i (i > 0), then the
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 96
cuSolverDN: dense LAPACK Function Reference
leading minor of order i of B is not positive definite. The factorization of B could not be
completed and no eigenvalues or eigenvectors were computed.
if jobz = CUSOLVER_EIG_MODE_VECTOR, A contains the orthogonal eigenvectors of
the matrix A. The eigenvectors are computed by divide and conquer algorithm.
Appendix F.2 provides a simple example of sygvd.
API of sygvd
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 97
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0, or
lda<max(1,n), or ldb<max(1,n), or itype
is not 1, 2 or 3, or jobz is not 'N' or 'V', or
uplo is not CUBLAS_FILL_MODE_LOWER or
CUBLAS_FILL_MODE_UPPER).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 98
cuSolverDN: dense LAPACK Function Reference
5.3.11. cusolverDn<t>syevj()
The helper functions below can calculate the sizes needed for pre-allocated buffer.
cusolverStatus_t
cusolverDnSsyevj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const float *A,
int lda,
const float *W,
int *lwork,
syevjInfo_t params);
cusolverStatus_t
cusolverDnDsyevj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const double *A,
int lda,
const double *W,
int *lwork,
syevjInfo_t params);
cusolverStatus_t
cusolverDnCheevj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuComplex *A,
int lda,
const float *W,
int *lwork,
syevjInfo_t params);
cusolverStatus_t
cusolverDnZheevj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuDoubleComplex *A,
int lda,
const double *W,
int *lwork,
syevjInfo_t params);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 99
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSsyevj(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
float *W,
float *work,
int lwork,
int *info,
syevjInfo_t params);
cusolverStatus_t
cusolverDnDsyevj(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
double *W,
double *work,
int lwork,
int *info,
syevjInfo_t params);
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCheevj(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
float *W,
cuComplex *work,
int lwork,
int *info,
syevjInfo_t params);
cusolverStatus_t
cusolverDnZheevj(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
double *W,
cuDoubleComplex *work,
int lwork,
int *info,
syevjInfo_t params);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 100
cuSolverDN: dense LAPACK Function Reference
where Λ is a real n×n diagonal matrix. Q is an n×n unitary matrix. The diagonal elements
of Λ are the eigenvalues of A in ascending order.
syevj has the same functionality as syevd. The difference is that syevd uses QR
algorithm and syevj uses Jacobi method. The parallelism of Jacobi method gives GPU
better performance on small and medium size matrices. Moreover the user can configure
syevj to perform approximation up to certain accuracy.
How does it work?
syevj iteratively generates a sequence of unitary matrices to transform matrix A to the
following form
The same as syevd, the user has to provide working space pointed by input parameter
work. The input parameter lwork is the size of the working space, and it is returned by
syevj_bufferSize().
If output parameter info = -i (less than zero), the i-th parameter is wrong (not
counting handle). If info = n+1, syevj does not converge under given tolerance and
maximum sweeps.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 101
cuSolverDN: dense LAPACK Function Reference
If the user sets an improper tolerance, syevj may not converge. For example, tolerance
should not be smaller than machine accuracy.
if jobz = CUSOLVER_EIG_MODE_VECTOR, A contains the orthonormal eigenvectors V.
Appendix F.3 provides a simple example of syevj.
API of syevj
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 102
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0,
or lda<max(1,n), or jobz is not
CUSOLVER_EIG_MODE_NOVECTOR or
CUSOLVER_EIG_MODE_VECTOR, or uplo
is not CUBLAS_FILL_MODE_LOWER or
CUBLAS_FILL_MODE_UPPER).
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 103
cuSolverDN: dense LAPACK Function Reference
5.3.12. cusolverDn<t>sygvj()
The helper functions below can calculate the sizes needed for pre-allocated buffer.
cusolverStatus_t
cusolverDnSsygvj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const float *A,
int lda,
const float *B,
int ldb,
const float *W,
int *lwork,
syevjInfo_t params);
cusolverStatus_t
cusolverDnDsygvj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const double *A,
int lda,
const double *B,
int ldb,
const double *W,
int *lwork,
syevjInfo_t params);
cusolverStatus_t
cusolverDnChegvj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuComplex *A,
int lda,
const cuComplex *B,
int ldb,
const float *W,
int *lwork,
syevjInfo_t params);
cusolverStatus_t
cusolverDnZhegvj_bufferSize(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuDoubleComplex *A,
int lda,
const cuDoubleComplex *B,
int ldb,
const double *W,
int *lwork,
syevjInfo_t params);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 104
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSsygvj(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
float *B,
int ldb,
float *W,
float *work,
int lwork,
int *info,
syevjInfo_t params);
cusolverStatus_t
cusolverDnDsygvj(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
double *B,
int ldb,
double *W,
double *work,
int lwork,
int *info,
syevjInfo_t params);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 105
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnChegvj(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
cuComplex *B,
int ldb,
float *W,
cuComplex *work,
int lwork,
int *info,
syevjInfo_t params);
cusolverStatus_t
cusolverDnZhegvj(
cusolverDnHandle_t handle,
cusolverEigType_t itype,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
cuDoubleComplex *B,
int ldb,
double *W,
cuDoubleComplex *work,
int lwork,
int *info,
syevjInfo_t params);
where the matrix B is positive definite. Λ is a real n×n diagonal matrix. The diagonal
elements of Λ are the eigenvalues of (A, B) in ascending order. V is an n×n orthogonal
matrix. The eigenvectors are normalized as follows:
This function has the same functionality as sygvd except that syevd in sygvd is
replaced by syevj in sygvj. Therefore, sygvj inherits properties of syevj, the user
can use cusolverDnXsyevjSetTolerance and cusolverDnXsyevjSetMaxSweeps to
configure tolerance and maximum sweeps.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 106
cuSolverDN: dense LAPACK Function Reference
However the meaning of residual is different from syevj. sygvj first computes
Cholesky factorization of matrix B,
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 107
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 108
cuSolverDN: dense LAPACK Function Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 109
cuSolverDN: dense LAPACK Function Reference
5.3.13. cusolverDn<t>syevjBatched()
The helper functions below can calculate the sizes needed for pre-allocated buffer.
cusolverStatus_t
cusolverDnSsyevjBatched_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const float *A,
int lda,
const float *W,
int *lwork,
syevjInfo_t params,
int batchSize
);
cusolverStatus_t
cusolverDnDsyevjBatched_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const double *A,
int lda,
const double *W,
int *lwork,
syevjInfo_t params,
int batchSize
);
cusolverStatus_t
cusolverDnCheevjBatched_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuComplex *A,
int lda,
const float *W,
int *lwork,
syevjInfo_t params,
int batchSize
);
cusolverStatus_t
cusolverDnZheevjBatched_bufferSize(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
const cuDoubleComplex *A,
int lda,
const double *W,
int *lwork,
syevjInfo_t params,
int batchSize
);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 110
cuSolverDN: dense LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverDnSsyevjBatched(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
float *A,
int lda,
float *W,
float *work,
int lwork,
int *info,
syevjInfo_t params,
int batchSize
);
cusolverStatus_t
cusolverDnDsyevjBatched(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
double *A,
int lda,
double *W,
double *work,
int lwork,
int *info,
syevjInfo_t params,
int batchSize
);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 111
cuSolverDN: dense LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverDnCheevjBatched(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuComplex *A,
int lda,
float *W,
cuComplex *work,
int lwork,
int *info,
syevjInfo_t params,
int batchSize
);
cusolverStatus_t
cusolverDnZheevjBatched(
cusolverDnHandle_t handle,
cusolverEigMode_t jobz,
cublasFillMode_t uplo,
int n,
cuDoubleComplex *A,
int lda,
double *W,
cuDoubleComplex *work,
int lwork,
int *info,
syevjInfo_t params,
int batchSize
);
where is a real n×n diagonal matrix. is an n×n unitary matrix. The diagonal
elements of are the eigenvalues of in either ascending order or non-sorting order.
syevjBatched performs syevj on each matrix. It requires that all matrices are of the
same size n no greater than 32 and are packed in contiguous way,
Each matrix is column-major with leading dimension lda, so the formula for random
access is .
The parameter W also contains eigenvalues of each matrix in contiguous way,
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 112
cuSolverDN: dense LAPACK Function Reference
Except for tolerance and maximum sweeps, syevjBatched can either sort the
eigenvalues in ascending order (default) or chose as-is (without sorting) by the function
cusolverDnXsyevjSetSortEig. If the user packs several tiny matrices into diagonal
blocks of one matrix, non-sorting option can separate spectrum of those tiny matrices.
syevjBatched cannot report residual and executed sweeps by function
cusolverDnXsyevjGetResidual and cusolverDnXsyevjGetSweeps. Any call of the
above two returns CUSOLVER_STATUS_NOT_SUPPORTED. The user needs to compute
residual explicitly.
The user has to provide working space pointed by input parameter work. The
input parameter lwork is the size of the working space, and it is returned by
syevjBatched_bufferSize().
The output parameter info is an integer array of size batchSize. If the function returns
CUSOLVER_STATUS_INVALID_VALUE, the first element info[0] = -i (less than zero)
indicates i-th parameter is wrong (not counting handle). Otherwise, if info[i] =
n+1, syevjBatched does not converge on i-th matrix under given tolerance and
maximum sweeps.
if jobz = CUSOLVER_EIG_MODE_VECTOR, contains the orthonormal eigenvectors
.
Appendix F.5 provides a simple example of syevjBatched.
API of syevjBatched
parameter Memory In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 113
cuSolverDN: dense LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n<0,
n>32 or lda<max(1,n), or jobz is not
CUSOLVER_EIG_MODE_NOVECTOR or
CUSOLVER_EIG_MODE_VECTOR, or uplo
is not CUBLAS_FILL_MODE_LOWER or
CUBLAS_FILL_MODE_UPPER), or batchSize<0.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 114
Chapter 6.
CUSOLVERSP: SPARSE LAPACK FUNCTION
REFERENCE
This chapter describes the API of cuSolverSP, which provides a subset of LAPACK
funtions for sparse matrices in CSR or CSC format.
6.1.1. cusolverSpCreate()
cusolverStatus_t
cusolverSpCreate(cusolverSpHandle_t *handle)
This function initializes the cuSolverSP library and creates a handle on the cuSolver
context. It must be called before any other cuSolverSP API function is invoked. It
allocates hardware resources necessary for accessing the GPU.
Output
handle the pointer to the handle to the cuSolverSP
context.
Status Returned
CUSOLVER_STATUS_SUCCESS the initialization succeeded.
CUSOLVER_STATUS_NOT_INITIALIZED the CUDA Runtime initialization failed.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
6.1.2. cusolverSpDestroy()
cusolverStatus_t
cusolverSpDestroy(cusolverSpHandle_t handle)
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 115
cuSolverSP: sparse LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the shutdown succeeded.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
6.1.3. cusolverSpSetStream()
cusolverStatus_t
cusolverSpSetStream(cusolverSpHandle_t handle, cudaStream_t streamId)
This function sets the stream to be used by the cuSolverSP library to execute its routines.
Input
handle the handle to the cuSolverSP context.
streamId the stream to be used by the library.
Status Returned
CUSOLVER_STATUS_SUCCESS the stream was set successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
6.1.4. cusolverSpXcsrissym()
cusolverStatus_t
cusolverSpXcsrissymHost(cusolverSpHandle_t handle,
int m,
int nnzA,
const cusparseMatDescr_t descrA,
const int *csrRowPtrA,
const int *csrEndPtrA,
const int *csrColIndA,
int *issym);
This function checks if A has symmetric pattern or not. The output parameter issym
reports 1 if A is symmetric; otherwise, it reports 0.
The matrix A is an m×m sparse matrix that is defined in CSR storage format by the four
arrays csrValA, csrRowPtrA, csrEndPtrA and csrColIndA.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL.
The csrlsvlu and csrlsvqr do not accept non-general matrix. the user has to extend
the matrix into its missing upper/lower part, otherwise the result is not expected. The
user can use csrissym to check if the matrix has symmetric pattern or not.
Remark 1: only CPU path is provided.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 116
cuSolverSP: sparse LAPACK Function Reference
Remark 2: the user has to check returned status to get valid information. The function
converts A to CSC format and compare CSR and CSC format. If the CSC failed because
of insufficient resources, issym is undefined, and this state can only be detected by the
return status code.
Input
parameter MemorySpace description
Output
parameter MemorySpace description
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,nnzA<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 117
cuSolverSP: sparse LAPACK Function Reference
6.2.1. cusolverSp<t>csrlsvlu()
cusolverStatus_t
cusolverSpScsrlsvlu[Host](cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const float *b,
float tol,
int reorder,
float *x,
int *singularity);
cusolverStatus_t
cusolverSpDcsrlsvlu[Host](cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const double *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const double *b,
double tol,
int reorder,
double *x,
int *singularity);
cusolverStatus_t
cusolverSpCcsrlsvlu[Host](cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const cuComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const cuComplex *b,
float tol,
int reorder,
cuComplex *x,
int *singularity);
cusolverStatus_t
cusolverSpZcsrlsvlu[Host](cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const cuDoubleComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const cuDoubleComplex *b,
double tol,
int reorder,
cuDoubleComplex *x,
int *singularity);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 118
cuSolverSP: sparse LAPACK Function Reference
A is an n×n sparse matrix that is defined in CSR storage format by the three arrays
csrValA, csrRowPtrA, and csrColIndA. b is the right-hand-side vector of size n, and x
is the solution vector of size n.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL. If matrix A is
symmetric/Hermitian and only lower/upper part is used or meaningful, the user has
to extend the matrix into its missing upper/lower part, otherwise the result would be
wrong.
The linear system is solved by sparse LU with partial pivoting,
cusolver library provides two reordering schemes, symrcm and symamd, to reduce
zero fill-in which dramactically affects the performance of LU factorization. The input
parameter reorder can enable symrcm (or symamd) if reorder is 1 (or 2), otherwise, no
reordering is performed.
If reorder is nonzero, csrlsvlu does
where .
If A is singular under given tolerance (max(tol,0)), then some diagonal elements of U is
zero, i.e.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 119
cuSolverSP: sparse LAPACK Function Reference
Output
parameter cusolverSp *Host description
MemSpace MemSpace
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 120
cuSolverSP: sparse LAPACK Function Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 121
cuSolverSP: sparse LAPACK Function Reference
6.2.2. cusolverSp<t>csrlsvqr()
cusolverStatus_t
cusolverSpScsrlsvqr[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const float *b,
float tol,
int reorder,
float *x,
int *singularity);
cusolverStatus_t
cusolverSpDcsrlsvqr[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const double *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const double *b,
double tol,
int reorder,
double *x,
int *singularity);
cusolverStatus_t
cusolverSpCcsrlsvqr[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const cuComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const cuComplex *b,
float tol,
int reorder,
cuComplex *x,
int *singularity);
cusolverStatus_t
cusolverSpZcsrlsvqr[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const cuDoubleComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const cuDoubleComplex *b,
double tol,
int reorder,
cuDoubleComplex *x,
int *singularity);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 122
cuSolverSP: sparse LAPACK Function Reference
A is an m×m sparse matrix that is defined in CSR storage format by the three arrays
csrValA, csrRowPtrA, and csrColIndA. b is the right-hand-side vector of size m, and x
is the solution vector of size m.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL. If matrix A is
symmetric/Hermitian and only lower/upper part is used or meaningful, the user has
to extend the matrix into its missing upper/lower part, otherwise the result would be
wrong.
The linear system is solved by sparse QR factorization,
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 123
cuSolverSP: sparse LAPACK Function Reference
Output
parameter cusolverSp *Host description
MemSpace MemSpace
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,nnz<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 124
cuSolverSP: sparse LAPACK Function Reference
6.2.3. cusolverSp<t>csrlsvchol()
cusolverStatus_t
cusolverSpScsrlsvchol[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const float *csrVal,
const int *csrRowPtr,
const int *csrColInd,
const float *b,
float tol,
int reorder,
float *x,
int *singularity);
cusolverStatus_t
cusolverSpDcsrlsvchol[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const double *csrVal,
const int *csrRowPtr,
const int *csrColInd,
const double *b,
double tol,
int reorder,
double *x,
int *singularity);
cusolverStatus_t
cusolverSpCcsrlsvchol[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const cuComplex *csrVal,
const int *csrRowPtr,
const int *csrColInd,
const cuComplex *b,
float tol,
int reorder,
cuComplex *x,
int *singularity);
cusolverStatus_t
cusolverSpZcsrlsvchol[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const cuDoubleComplex *csrVal,
const int *csrRowPtr,
const int *csrColInd,
const cuDoubleComplex *b,
double tol,
int reorder,
cuDoubleComplex *x,
int *singularity);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 125
cuSolverSP: sparse LAPACK Function Reference
A is an m×m symmetric postive definite sparse matrix that is defined in CSR storage
format by the three arrays csrValA, csrRowPtrA, and csrColIndA. b is the right-hand-
side vector of size m, and x is the solution vector of size m.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL and upper triangular
part of A is ignored (if parameter reorder is zero). In other words, suppose input matrix
A is decomposed as , where L is lower triangular, D is diagonal and U is
upper triangular. The function would ignore U and regard A as a symmetric matrix with
the formula . If parameter reorder is nonzero, the user has to extend A to
a full matrix, otherwise the solution would be wrong.
The linear system is solved by sparse Cholesky factorization,
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 126
cuSolverSP: sparse LAPACK Function Reference
Output
parameter cusolverSp *Host description
MemSpace MemSpace
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,nnz<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 127
cuSolverSP: sparse LAPACK Function Reference
6.2.4. cusolverSp<t>csrlsqvqr()
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverSpScsrlsqvqr[Host](cusolverSpHandle_t handle,
int m,
int n,
int nnz,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const float *b,
float tol,
int *rankA,
float *x,
int *p,
float *min_norm);
cusolverStatus_t
cusolverSpDcsrlsqvqr[Host](cusolverSpHandle_t handle,
int m,
int n,
int nnz,
const cusparseMatDescr_t descrA,
const double *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const double *b,
double tol,
int *rankA,
double *x,
int *p,
double *min_norm);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 128
cuSolverSP: sparse LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverSpCcsrlsqvqr[Host](cusolverSpHandle_t handle,
int m,
int n,
int nnz,
const cusparseMatDescr_t descrA,
const cuComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const cuComplex *b,
float tol,
int *rankA,
cuComplex *x,
int *p,
float *min_norm);
cusolverStatus_t
cusolverSpZcsrlsqvqr[Host](cusolverSpHandle_t handle,
int m,
int n,
int nnz,
const cusparseMatDescr_t descrA,
const cuDoubleComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const cuDoubleComplex *b,
double tol,
int *rankA,
cuDoubleComplex *x,
int *p,
double *min_norm);
A is an m×n sparse matrix that is defined in CSR storage format by the three arrays
csrValA, csrRowPtrA, and csrColIndA. b is the right-hand-side vector of size m, and x
is the least-square solution vector of size n.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL. If A is square,
symmetric/Hermitian and only lower/upper part is used or meaningful, the user has to
extend the matrix into its missing upper/lower part, otherwise the result is wrong.
This function only works if m is greater or equal to n, in other words, A is a tall matrix.
The least-square problem is solved by sparse QR factorization with column pivoting,
If A is of full rank (i.e. all columns of A are linear independent), then matrix P is an
identity. Suppose rank of A is k, less than n, the permutation matrix P reorders columns
of A in the following sense:
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 129
cuSolverSP: sparse LAPACK Function Reference
where and A have the same rank, but is almost zero, i.e. every column of is
linear combination of .
The input parameter tol decides numerical rank. The absolute value of every entry in
is less than or equal to tolerance=max(tol,0).
The output parameter rankA denotes numerical rank of A.
or in matrix form
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 130
cuSolverSP: sparse LAPACK Function Reference
CUSPARSE_INDEX_BASE_ZERO and
CUSPARSE_INDEX_BASE_ONE.
Output
parameter cusolverSp *Host description
MemSpace MemSpace
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n,nnz<=0),
base index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 131
cuSolverSP: sparse LAPACK Function Reference
6.2.5. cusolverSp<t>csreigvsi()
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverSpScsreigvsi[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
float mu0,
const float *x0,
int maxite,
float tol,
float *mu,
float *x);
cusolverStatus_t
cusolverSpDcsreigvsi[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const double *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
double mu0,
const double *x0,
int maxite,
double tol,
double *mu,
double *x);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 132
cuSolverSP: sparse LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverSpCcsreigvsi[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const cuComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
cuComplex mu0,
const cuComplex *x0,
int maxite,
float tol,
cuComplex *mu,
cuComplex *x);
cusolverStatus_t
cusolverSpZcsreigvsi(cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const cuDoubleComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
cuDoubleComplex mu0,
const cuDoubleComplex *x0,
int maxite,
double tol,
cuDoubleComplex *mu,
cuDoubleComplex *x);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 133
cuSolverSP: sparse LAPACK Function Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 134
cuSolverSP: sparse LAPACK Function Reference
Output
parameter cusolverSp *Host description
MemSpace MemSpace
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,nnz<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 135
cuSolverSP: sparse LAPACK Function Reference
6.2.6. cusolverSp<t>csreigs()
cusolverStatus_t
solverspScsreigs[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
cuComplex left_bottom_corner,
cuComplex right_upper_corner,
int *num_eigs);
cusolverStatus_t
cusolverSpDcsreigs[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const double *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
cuDoubleComplex left_bottom_corner,
cuDoubleComplex right_upper_corner,
int *num_eigs);
cusolverStatus_t
cusolverSpCcsreigs[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const cuComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
cuComplex left_bottom_corner,
cuComplex right_upper_corner,
int *num_eigs);
cusolverStatus_t
cusolverSpZcsreigs[Host](cusolverSpHandle_t handle,
int m,
int nnz,
const cusparseMatDescr_t descrA,
const cuDoubleComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
cuDoubleComplex left_bottom_corner,
cuDoubleComplex right_upper_corner,
int *num_eigs);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 136
cuSolverSP: sparse LAPACK Function Reference
where closed line C is boundary of the box B which is a rectangle specified by two
points, one is left bottom corner (input parameter left_botoom_corner) and the other
is right upper corner (input parameter right_upper_corner). P(z)=det(A - z*I) is
the characteristic polynomial of A.
A is an m×m sparse matrix that is defined in CSR storage format by the three arrays
csrValA, csrRowPtrA, and csrColIndA.
The output parameter num_eigs is number of algebraic eigenvalues in the box B. This
number may not be accurate due to several reasons:
1. the contour C is close to some eigenvalues or even passes through some eigenvalues.
2. the numerical integration is not accurate due to coarse grid size. The default resolution
is 1200 grids along contour C uniformly.
Even though csreigs may not be accurate, it still can give the user some idea how
many eigenvalues in a region where the resolution of disk theorem is bad. For example,
standard 3-point stencil of finite difference of Laplacian operator is a tridiagonal matrix,
and disk theorem would show "all eigenvalues are in the interval [0, 4*N^2]" where N is
number of grids. In this case, csreigs is useful for any interval inside [0, 4*N^2].
Remark 1: if A is symmetric in real or hermitian in complex, all eigenvalues are real.
The user still needs to specify a box, not an interval. The height of the box can be much
smaller than the width.
Remark 2: only CPU (Host) path is provided.
Input
parameter cusolverSp *Host description
MemSpace MemSpace
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 137
cuSolverSP: sparse LAPACK Function Reference
Output
parameter cusolverSp *Host description
MemSpace MemSpace
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,nnz<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
6.3.1. cusolverSpXcsrsymrcm()
cusolverStatus_t
cusolverSpXcsrsymrcmHost(cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const int *csrRowPtrA,
const int *csrColIndA,
int *p);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 138
cuSolverSP: sparse LAPACK Function Reference
A is an n×n sparse matrix that is defined in CSR storage format by the three arrays
csrValA, csrRowPtrA, and csrColIndA.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL. Internally rcm works
on , the user does not need to extend the matrix if the matrix is not symmetric.
Remark 1: only CPU (Host) path is provided.
Input
parameter *Host MemSpace description
Output
parameter hsolver description
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n,nnzA<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 139
cuSolverSP: sparse LAPACK Function Reference
6.3.2. cusolverSpXcsrsymmdq()
cusolverStatus_t
cusolverSpXcsrsymmdqHost(cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const int *csrRowPtrA,
const int *csrColIndA,
int *p);
A is an n×n sparse matrix that is defined in CSR storage format by the three arrays
csrValA, csrRowPtrA, and csrColIndA.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL. Internally mdq works
on , the user does not need to extend the matrix if the matrix is not symmetric.
Remark 1: only CPU (Host) path is provided.
Input
parameter *Host MemSpace description
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 140
cuSolverSP: sparse LAPACK Function Reference
Output
parameter hsolver description
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n,nnzA<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
6.3.3. cusolverSpXcsrsymamd()
cusolverStatus_t
cusolverSpXcsrsymamdHost(cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const int *csrRowPtrA,
const int *csrColIndA,
int *p);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 141
cuSolverSP: sparse LAPACK Function Reference
A is an n×n sparse matrix that is defined in CSR storage format by the three arrays
csrValA, csrRowPtrA, and csrColIndA.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL. Internally amd works
on , the user does not need to extend the matrix if the matrix is not symmetric.
Remark 1: only CPU (Host) path is provided.
Input
parameter *Host MemSpace description
Output
parameter hsolver description
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n,nnzA<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 142
cuSolverSP: sparse LAPACK Function Reference
6.3.4. cusolverSpXcsrmetisnd()
cusolverStatus_t
cusolverSpXcsrmetisndHost(
cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const int *csrRowPtrA,
const int *csrColIndA,
const int64_t *options,
int *p);
A is an n×n sparse matrix that is defined in CSR storage format by the three arrays
csrValA, csrRowPtrA, and csrColIndA.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL. Internally
csrmetisnd works on , the user does not need to extend the matrix if the matrix
is not symmetric.
Remark 1: only CPU (Host) path is provided.
Input
parameter *Host MemSpace description
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 143
cuSolverSP: sparse LAPACK Function Reference
Output
parameter *Host MemSpace description
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n,nnzA<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 144
cuSolverSP: sparse LAPACK Function Reference
6.3.5. cusolverSpXcsrzfd()
cusolverStatus_t
cusolverSpScsrzfdHost(
cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
int *P,
int *numnz)
cusolverStatus_t
cusolverSpDcsrzfdHost(
cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const double *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
int *P,
int *numnz)
cusolverStatus_t
cusolverSpCcsrzfdHost(
cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const cuComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
int *P,
int *numnz)
cusolverStatus_t
cusolverSpZcsrzfdHost(
cusolverSpHandle_t handle,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const cuDoubleComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
int *P,
int *numnz)
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 145
cuSolverSP: sparse LAPACK Function Reference
Output
parameter *Host MemSpace description
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (n,nnzA<=0), base
index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 146
cuSolverSP: sparse LAPACK Function Reference
6.3.6. cusolverSpXcsrperm()
cusolverStatus_t
cusolverSpXcsrperm_bufferSizeHost(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
int *csrRowPtrA,
int *csrColIndA,
const int *p,
const int *q,
size_t *bufferSizeInBytes);
cusolverStatus_t
cusolverSpXcsrpermHost(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
int *csrRowPtrA,
int *csrColIndA,
const int *p,
const int *q,
int *map,
void *pBuffer);
A is an m×n sparse matrix that is defined in CSR storage format by the three arrays
csrValA, csrRowPtrA and csrColIndA.
The operation is in-place, i.e. the matrix A is overwritten by B.
The permutation vector p and q are base 0. p performs row permutation while q
performs column permutation. One can also use MATLAB command to
permutate matrix A.
This function only computes sparsity pattern of B. The user can use parameter map to
get csrValB as well. The parameter map is an input/output. If the user sets map=0:1:
(nnzA-1) before calling csrperm, csrValB=csrValA(map).
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL. If A is symmetric and
only lower/upper part is provided, the user has to pass into this function.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 147
cuSolverSP: sparse LAPACK Function Reference
and left permutation vector p=(0,2,1), right permutation vector q=(2,1,0), then
is
Remark 2: the user can combine csrsymrcm and csrperm to get which has less
zero fill-in during QR factorization.
Input
parameter cusolverSp description
MemSpace
Output
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 148
cuSolverSP: sparse LAPACK Function Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n,nnzA<=0),
base index is not 0 or 1.
CUSOLVER_STATUS_ARCH_MISMATCH the device only supports compute capability 2.0
and above.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED the matrix type is not supported.
6.3.7. cusolverSpXcsrqrBatched()
The create and destroy methods start and end the lifetime of a csrqrInfo object.
cusolverStatus_t
cusolverSpCreateCsrqrInfo(csrqrInfo_t *info);
cusolverStatus_t
cusolverSpDestroyCsrqrInfo(csrqrInfo_t info);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 149
cuSolverSP: sparse LAPACK Function Reference
Analysis is the same for all data types, but each data type has a unique buffer size.
cusolverStatus_t
cusolverSpXcsrqrAnalysisBatched(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const int *csrRowPtrA,
const int *csrColIndA,
csrqrInfo_t info);
cusolverStatus_t
cusolverSpScsrqrBufferInfoBatched(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
int batchSize,
csrqrInfo_t info,
size_t *internalDataInBytes,
size_t *workspaceInBytes);
cusolverStatus_t
cusolverSpDcsrqrBufferInfoBatched(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const double *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
int batchSize,
csrqrInfo_t info,
size_t *internalDataInBytes,
size_t *workspaceInBytes);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 150
cuSolverSP: sparse LAPACK Function Reference
cusolverStatus_t
cusolverSpCcsrqrBufferInfoBatched(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const cuComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
int batchSize,
csrqrInfo_t info,
size_t *internalDataInBytes,
size_t *workspaceInBytes);
cusolverStatus_t
cusolverSpZcsrqrBufferInfoBatched(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const cuDoubleComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
int batchSize,
csrqrInfo_t info,
size_t *internalDataInBytes,
size_t *workspaceInBytes);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 151
cuSolverSP: sparse LAPACK Function Reference
The S and D data types are real valued single and double precision, respectively.
cusolverStatus_t
cusolverSpScsrqrsvBatched(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const float *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const float *b,
float *x,
int batchSize,
csrqrInfo_t info,
void *pBuffer);
cusolverStatus_t
cusolverSpDcsrqrsvBatched(cusolverSpHandle_t handle,
int m,
int n,
int nnz,
const cusparseMatDescr_t descrA,
const double *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const double *b,
double *x,
int batchSize,
csrqrInfo_t info,
void *pBuffer);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 152
cuSolverSP: sparse LAPACK Function Reference
The C and Z data types are complex valued single and double precision, respectively.
cusolverStatus_t
cusolverSpCcsrqrsvBatched(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const cuComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const cuComplex *b,
cuComplex *x,
int batchSize,
csrqrInfo_t info,
void *pBuffer);
cusolverStatus_t
cusolverSpZcsrqrsvBatched(cusolverSpHandle_t handle,
int m,
int n,
int nnzA,
const cusparseMatDescr_t descrA,
const cuDoubleComplex *csrValA,
const int *csrRowPtrA,
const int *csrColIndA,
const cuDoubleComplex *b,
cuDoubleComplex *x,
int batchSize,
csrqrInfo_t info,
void *pBuffer);
where each is a m×n sparse matrix that is defined in CSR storage format by the four
arrays csrValA, csrRowPtrA and csrColIndA.
The supported matrix type is CUSPARSE_MATRIX_TYPE_GENERAL. If A is symmetric and
only lower/upper part is prvided, the user has to pass into this function.
The prerequisite to use batched sparse QR has two-folds. First all matrices must have
the same sparsity pattern. Second, no column pivoting is used in least-square problem,
so the solution is valid only if is of full rank for all j = 1,2,..., batchSize
. All matrices have the same sparity pattern, so only one copy of csrRowPtrA and
csrColIndA is used. But the array csrValA stores coefficients of one after another. In
other words, csrValA[k*nnzA : (k+1)*nnzA] is the value of .
The batched QR uses opaque data structure csrqrInfo to keep intermediate data, for
example, matrix Q and matrix R of QR factorization. The user needs to create csrqrInfo
first by cusolverSpCreateCsrqrInfo before any function in batched QR operation.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 153
cuSolverSP: sparse LAPACK Function Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 154
cuSolverSP: sparse LAPACK Function Reference
Example: suppose that A0, A1, .., A9 have the same sparsity pattern, the following code
solves 10 linear systems by batched sparse QR.
// Suppose that A0, A1, .., A9 are m x m sparse matrix represented by CSR
format,
// Each matrix Aj has nonzero nnzA, and shares the same csrRowPtrA and
csrColIndA.
// csrValA is aggregation of A0, A1, ..., A9.
int m ; // number of rows and columns of each Aj
int nnzA ; // number of nonzeros of each Aj
int *csrRowPtrA ; // each Aj has the same csrRowPtrA
int *csrColIndA ; // each Aj has the same csrColIndA
double *csrValA ; // aggregation of A0,A1,...,A9
cont int batchSize = 10; // 10 linear systems
cudaMalloc(&pBuffer, workspaceInBytes);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 155
cuSolverSP: sparse LAPACK Function Reference
Output
parameter cusolverSp description
MemSpace
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED the resources could not be allocated.
CUSOLVER_STATUS_INVALID_VALUE invalid parameters were passed (m,n,nnzA<=0),
base index is not 0 or 1.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 156
cuSolverSP: sparse LAPACK Function Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 157
Chapter 7.
CUSOLVERRF: REFACTORIZATION
REFERENCE
7.1. cusolverRfAccessBundledFactors()
cusolverStatus_t
cusolverRfAccessBundledFactors(/* Input */
cusolverRfHandle_t handle,
/* Output (in the host memory) */
int* nnzM,
/* Output (in the device memory) */
int** Mp,
int** Mi,
double** Mx);
This routine allows direct access to the lower L and upper U triangular factors stored in
the cuSolverRF library handle. The factors are compressed into a single matrix M=(L-
I)+U, where the unitary diagonal of L is not stored. It is assumed that a prior call to the
cusolverRfRefactor() was done in order to generate these triangular factors.
parameter MemSpace In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 158
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
7.2. cusolverRfAnalyze()
cusolverStatus_t
cusolverRfAnalyze(cusolverRfHandle_t handle);
This routine performs the appropriate analysis of parallelism available in the LU re-
factorization depending upon the algorithm chosen by the user.
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
CUSOLVER_STATUS_ALLOC_FAILED an allocation of memory failed.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 159
cuSolverRF: Refactorization Reference
7.3. cusolverRfSetupDevice()
cusolverStatus_t
cusolverRfSetupDevice(/* Input (in the device memory) */
int n,
int nnzA,
int* csrRowPtrA,
int* csrColIndA,
double* csrValA,
int nnzL,
int* csrRowPtrL,
int* csrColIndL,
double* csrValL,
int nnzU,
int* csrRowPtrU,
int* csrColIndU,
double* csrValU,
int* P,
int* Q,
/* Output */
cusolverRfHandle_t handle);
This routine assembles the internal data structures of the cuSolverRF library. It is often
the first routine to be called after the call to the cusolverRfCreate() routine.
This routine accepts as input (on the device) the original matrix A, the lower (L) and
upper (U) triangular factors, as well as the left (P) and the right (Q) permutations
resulting from the full LU factorization of the first (i=1) linear system
The permutations P and Q represent the final composition of all the left and right
reorderings applied to the original matrix A, respectively. However, these permutations
are often associated with partial pivoting and reordering to minimize fill-in, respectively.
This routine needs to be called only once for a single linear system
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 160
cuSolverRF: Refactorization Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 161
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE an unsupported value or parameter was passed.
CUSOLVER_STATUS_ALLOC_FAILED an allocation of memory failed.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
7.4. cusolverRfSetupHost()
cusolverStatus_t
cusolverRfSetupHost(/* Input (in the host memory) */
int n,
int nnzA,
int* h_csrRowPtrA,
int* h_csrColIndA,
double* h_csrValA,
int nnzL,
int* h_csrRowPtrL,
int* h_csrColIndL,
double* h_csrValL,
int nnzU,
int* h_csrRowPtrU,
int* h_csrColIndU,
double* h_csrValU,
int* h_P,
int* h_Q,
/* Output */
cusolverRfHandle_t handle);
This routine assembles the internal data structures of the cuSolverRF library. It is often
the first routine to be called after the call to the cusolverRfCreate() routine.
This routine accepts as input (on the host) the original matrix A, the lower (L) and
upper (U) triangular factors, as well as the left (P) and the right (Q) permutations
resulting from the full LU factorization of the first (i=1) linear system
The permutations P and Q represent the final composition of all the left and right
reorderings applied to the original matrix A, respectively. However, these permutations
are often associated with partial pivoting and reordering to minimize fill-in, respectively.
This routine needs to be called only once for a single linear system
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 162
cuSolverRF: Refactorization Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 163
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE an unsupported value or parameter was passed.
CUSOLVER_STATUS_ALLOC_FAILED an allocation of memory failed.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
7.5. cusolverRfCreate()
cusolverStatus_t cusolverRfCreate(cusolverRfHandle_t *handle);
This routine initializes the cuSolverRF library. It allocates required resources and must
be called prior to any other cuSolverRF library routine.
parameter MemSpace In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED an allocation of memory failed.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 164
cuSolverRF: Refactorization Reference
7.6. cusolverRfExtractBundledFactorsHost()
cusolverStatus_t
cusolverRfExtractBundledFactorsHost(/* Input */
cusolverRfHandle_t handle,
/* Output (in the host memory) */
int* h_nnzM,
int** h_Mp,
int** h_Mi,
double** h_Mx);
This routine extracts lower (L) and upper (U) triangular factors from the cuSolverRF
library handle into the host memory. The factors are compressed into a single matrix
M=(L-I)+U, where the unitary diagonal of (L) is not stored. It is assumed that a prior
call to the cusolverRfRefactor() was done in order to generate these triangular
factors.
parameter MemSpace In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED an allocation of memory failed.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 165
cuSolverRF: Refactorization Reference
7.7. cusolverRfExtractSplitFactorsHost()
cusolverStatus_t
cusolverRfExtractSplitFactorsHost(/* Input */
cusolverRfHandle_t handle,
/* Output (in the host memory) */
int* h_nnzL,
int** h_Lp,
int** h_Li,
double** h_Lx,
int* h_nnzU,
int** h_Up,
int** h_Ui,
double** h_Ux);
This routine extracts lower (L) and upper (U) triangular factors from the
cuSolverRF library handle into the host memory. It is assumed that a prior call to the
cusolverRfRefactor() was done in order to generate these triangular factors.
parameter MemSpace In/out Meaning
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 166
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_ALLOC_FAILED an allocation of memory failed.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
7.8. cusolverRfDestroy()
cusolverStatus_t cusolverRfDestroy(cusolverRfHandle_t handle);
This routine shuts down the cuSolverRF library. It releases acquired resources and must
be called after all the cuSolverRF library routines.
parameter MemSpace In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
7.9. cusolverRfGetMatrixFormat()
cusolverStatus_t
cusolverRfGetMatrixFormat(cusolverRfHandle_t handle,
cusolverRfMatrixFormat_t *format,
cusolverRfUnitDiagonal_t *diag);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 167
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
7.10. cusolverRfGetNumericProperties()
cusolverStatus_t
cusolverRfGetNumericProperties(cusolverRfHandle_t handle,
double *zero,
double *boost);
This routine gets the numeric values used for checking for ''zero'' pivot and for boosting
it in the cusolverRfRefactor() and cusolverRfSolve() routines. The numeric
boosting will be used only if boost > 0.0.
parameter MemSpace In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
7.11. cusolverRfGetNumericBoostReport()
cusolverStatus_t
cusolverRfGetNumericBoostReport(cusolverRfHandle_t handle,
cusolverRfNumericBoostReport_t *report);
This routine gets the report whether numeric boosting was used in the
cusolverRfRefactor() and cusolverRfSolve() routines.
parameter MemSpace In/out Meaning
Status Returned
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 168
cuSolverRF: Refactorization Reference
7.12. cusolverRfGetResetValuesFastMode()
cusolverStatus_t
cusolverRfGetResetValuesFastMode(cusolverRfHandle_t handle,
rfResetValuesFastMode_t *fastMode);
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
7.13. cusolverRfGet_Algs()
cusolverStatus_t
cusolverRfGet_Algs(cusolverRfHandle_t handle,
cusolverRfFactorization_t* fact_alg,
cusolverRfTriangularSolve_t* solve_alg);
This routine gets the algorithm used for the refactorization in cusolverRfRefactor()
and the triangular solve in cusolverRfSolve().
parameter MemSpace In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
7.14. cusolverRfRefactor()
cusolverStatus_t cusolverRfRefactor(cusolverRfHandle_t handle);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 169
cuSolverRF: Refactorization Reference
exploring the available parallelism on the GPU. It is assumed that a prior call to the
glu_analyze() was done in order to find the available paralellism.
This routine may be called multiple times, once for each of the linear systems
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
CUSOLVER_STATUS_ZERO_PIVOT a zero pivot was encountered during the
computation.
7.15. cusolverRfResetValues()
cusolverStatus_t
cusolverRfResetValues(/* Input (in the device memory) */
int n,
int nnzA,
int* csrRowPtrA,
int* csrColIndA,
double* csrValA,
int* P,
int* Q,
/* Output */
cusolverRfHandle_t handle);
This routine updates internal data structures with the values of the new coefficient
matrix. It is assumed that the arrays csrRowPtrA, csrColIndA, P and Q have not
changed since the last call to the cusolverRfSetup[Host|Device] routine. This
assumption reflects the fact that the sparsity pattern of coefficient matrices as well as
reordering to minimize fill-in and pivoting remain the same in the set of linear systems
This routine may be called multiple times, once for each of the linear systems
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 170
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE an unsupported value or parameter was passed.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
7.16. cusolverRfSetMatrixFormat()
cusolverStatus_t
cusolverRfSetMatrixFormat(cusolverRfHandle_t handle,
gluMatrixFormat_t format,
gluUnitDiagonal_t diag);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 171
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE an enumerated mode parameter is wrong.
7.17. cusolverRfSetNumericProperties()
cusolverStatus_t
cusolverRfSetNumericProperties(cusolverRfHandle_t handle,
double zero,
double boost);
This routine sets the numeric values used for checking for ''zero'' pivot and for boosting
it in the cusolverRfRefactor() and cusolverRfSolve() routines. It may be called
multiple times prior to cusolverRfRefactor() and cusolverRfSolve() routines.
The numeric boosting will be used only if boost > 0.0.
parameter MemSpace In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
7.18. cusolverRfSetResetValuesFastMode()
cusolverStatus_t
cusolverRfSetResetValuesFastMode(cusolverRfHandle_t handle,
gluResetValuesFastMode_t fastMode);
This routine sets the mode used in the cusolverRfResetValues routine. The
fast mode requires extra memory and is recommended only if very fast calls
to cusolverRfResetValues() are needed. It may be called once prior to
cusolverRfAnalyze() routine.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 172
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE an enumerated mode parameter is wrong.
7.19. cusolverRfSetAlgs()
cusolverStatus_t
cusolverRfSetAlgs(cusolverRfHandle_t handle,
gluFactorization_t fact_alg,
gluTriangularSolve_t alg);
This routine sets the algorithm used for the refactorization in cusolverRfRefactor()
and the triangular solve in cusolverRfSolve(). It may be called once prior to
cusolverRfAnalyze() routine.
parameter MemSpace In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
7.20. cusolverRfSolve()
cusolverStatus_t
cusolverRfSolve(/* Input (in the device memory) */
cusolverRfHandle_t handle,
int *P,
int *Q,
int nrhs,
double *Temp,
int ldt,
/* Input/Output (in the device memory) */
double *XF,
/* Input */
int ldxf);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 173
cuSolverRF: Refactorization Reference
This routine performs the forward and backward solve with the lower and
upper triangular factors resulting from the LU re-factorization
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE an unsupported value or parameter was passed.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 174
cuSolverRF: Refactorization Reference
7.21. cusolverRfBatchSetupHost()
cusolverStatus_t
cusolverRfBatchSetupHost(/* Input (in the host memory) */
int batchSize,
int n,
int nnzA,
int* h_csrRowPtrA,
int* h_csrColIndA,
double *h_csrValA_array[],
int nnzL,
int* h_csrRowPtrL,
int* h_csrColIndL,
double *h_csrValL,
int nnzU,
int* h_csrRowPtrU,
int* h_csrColIndU,
double *h_csrValU,
int* h_P,
int* h_Q,
/* Output */
cusolverRfHandle_t handle);
This routine assembles the internal data structures of the cuSolverRF library for batched
operation. It is called after the call to the cusolverRfCreate() routine, and before any
other batched routines.
The batched operation assumes that the user has the following linear systems
where each matrix in the set has the same sparsity pattern, and quite similar such
that factorization can be done by the same permutation P and Q. In other words,
is a small perturbation of .
This routine accepts as input (on the host) the original matrix A (sparsity pattern and
batched values), the lower (L) and upper (U) triangular factors, as well as the left (P)
and the right (Q) permutations resulting from the full LU factorization of the first (i=1)
linear system
The permutations P and Q represent the final composition of all the left and right
reorderings applied to the original matrix A, respectively. However, these permutations
are often associated with partial pivoting and reordering to minimize fill-in, respectively.
Remark 1: the matrices A, L and U must be CSR format and base-0.
Remark 2: to get best performance, batchSize should be multiple of 32 and greater or
equal to 32. The algorithm is memory-bound, once bandwidth limit is reached, there is
no room to improve performance by large batchSize. In practice, batchSize of 32 -
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 175
cuSolverRF: Refactorization Reference
128 is often enough to obtain good performance, but in some cases larger batchSize
might be beneficial.
This routine needs to be called only once for a single linear system
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 176
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE an unsupported value or parameter was passed.
CUSOLVER_STATUS_ALLOC_FAILED an allocation of memory failed.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
7.22. cusolverRfBatchAnalyze()
cusolverStatus_t cusolverRfBatchAnalyze(cusolverRfHandle_t handle);
This routine performs the appropriate analysis of parallelism available in the batched
LU re-factorization.
It is assumed that a prior call to the cusolverRfBatchSetup[Host]() was done in
order to create internal data structures needed for the analysis.
This routine needs to be called only once for a single linear system
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 177
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
CUSOLVER_STATUS_ALLOC_FAILED an allocation of memory failed.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
7.23. cusolverRfBatchResetValues()
cusolverStatus_t
cusolverRfBatchResetValues(/* Input (in the device memory) */
int batchSize,
int n,
int nnzA,
int* csrRowPtrA,
int* csrColIndA,
double* csrValA_array[],
int *P,
int *Q,
/* Output */
cusolverRfHandle_t handle);
This routine updates internal data structures with the values of the new coefficient
matrix. It is assumed that the arrays csrRowPtrA, csrColIndA, P and Q have not
changed since the last call to the cusolverRfbatch_setup_host routine.
This assumption reflects the fact that the sparsity pattern of coefficient matrices as
well as reordering to minimize fill-in and pivoting remain the same in the set of linear
systems
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 178
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE an unsupported value or parameter was passed.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
7.24. cusolverRfBatchRefactor()
cusolverStatus_t cusolverRfBatchRefactor(cusolverRfHandle_t handle);
exploring the available parallelism on the GPU. It is assumed that a prior call to the
cusolverRfBatchAnalyze() was done in order to find the available paralellism.
Remark: cusolverRfBatchRefactor() would not report any failure of LU
refactorization. The user has to call cusolverRfBatchZeroPivot() to know which
matrix failed the LU refactorization.
parameter Memory In/out Meaning
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 179
cuSolverRF: Refactorization Reference
7.25. cusolverRfBatchSolve()
cusolverStatus_t
cusolverRfBatchSolve(/* Input (in the device memory) */
cusolverRfHandle_t handle,
int *P,
int *Q,
int nrhs,
double *Temp,
int ldt,
/* Input/Output (in the device memory) */
double *XF_array[],
/* Input */
int ldxf);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 180
cuSolverRF: Refactorization Reference
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
CUSOLVER_STATUS_INVALID_VALUE an unsupported value or parameter was passed.
CUSOLVER_STATUS_EXECUTION_FAILED a kernel failed to launch on the GPU.
CUSOLVER_STATUS_INTERNAL_ERROR an internal operation failed.
7.26. cusolverRfBatchZeroPivot()
cusolverStatus_t
cusolverRfBatchZeroPivot(/* Input */
cusolverRfHandle_t handle
/* Output (in the host memory) */
int *position);
Status Returned
CUSOLVER_STATUS_SUCCESS the operation completed successfully.
CUSOLVER_STATUS_NOT_INITIALIZED the library was not initialized.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 181
cuSolverRF: Refactorization Reference
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 182
Appendix A.
CUSOLVERRF EXAMPLES
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 183
cuSolverRF Examples
but we change the indexing from one- to zero-based to follow the C programming
language. The example begins with the usual includes and main()
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include "cusolverRf.h"
#define TEST_PASSED 0
#define TEST_FAILED 1
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 184
cuSolverRF Examples
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 185
cuSolverRF Examples
//assemble internal data structures (you should use the coeffcient matrix A
//corresponding to the second (i=1) linear system in this call)
t1 = cusolver_test_seconds();
status = cusolverRfSetupHost(n, nnzA, Ap, Ai, Ax,
nnzL, Lp, Li, Lx, nnzU, Up, Ui, Ux, P, Q, gH);
cudaStatus = cudaDeviceSynchronize();
t2 = cusolver_test_seconds();
if ((status != CUSOLVER_STATUS_SUCCESS) || (cudaStatus != cudaSuccess)) {
printf ("[cusolverRf status \%d]\n",status);
return TEST_FAILED;
}
printf("cusolverRfSetupHost time = \%f (s)\n", t2-t1);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 186
cuSolverRF Examples
/* check if done */
/* ... */
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 187
cuSolverRF Examples
but we change the indexing from one- to zero-based to follow the C programming
language. The first part is the usual includes and main definition
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include "cusolverRf.h"
#define TEST_PASSED 0
#define TEST_FAILED 1
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 188
cuSolverRF Examples
Next we initialize the data needed and the create library handles
/* ASSUMPTION:
recall that we are solving a batch of linear systems
A_{j} x_{j} = f_{j} for j=0,...,batchSize-1
where the sparsity pattern of the coefficient matrices A_{j}
as well as the reordering to minimize fill-in and the pivoting
used during the LU factorization remain the same. */
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 189
cuSolverRF Examples
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 190
Appendix B.
CSR QR BATCH EXAMPLES
All right-hand side vectors are small perturbation of the Matlab vector 'ones(4,1)'.
We assume device memory is big enough to compute all matrices in one pass.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 191
CSR QR Batch Examples
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cusolverSp.h>
#include <cuda_runtime_api.h>
size_t size_qr = 0;
size_t size_internal = 0;
void *buffer_qr = NULL; // working space for numerical factorization
/* | 1 |
* A = | 2 |
* | 3 |
* | 0.1 0.1 0.1 4 |
* CSR of A is based-1
*
* b = [1 1 1 1]
*/
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 192
CSR QR Batch Examples
const int m = 4 ;
const int nnzA = 7;
const int csrRowPtrA[m+1] = { 1, 2, 3, 4, 8};
const int csrColIndA[nnzA] = { 1, 2, 3, 1, 2, 3, 4};
const double csrValA[nnzA] = { 1.0, 2.0, 3.0, 0.1, 0.1, 0.1, 4.0};
const double b[m] = {1.0, 1.0, 1.0, 1.0};
const int batchSize = 17;
cusparse_status = cusparseCreateMatDescr(&descrA);
assert(cusparse_status == CUSPARSE_STATUS_SUCCESS);
cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ONE); // base-1
cusolver_status = cusolverSpCreateCsrqrInfo(&info);
assert(cusolver_status == CUSOLVER_STATUS_SUCCESS);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 193
CSR QR Batch Examples
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 194
CSR QR Batch Examples
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 195
CSR QR Batch Examples
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cusolverSp.h>
#include <cuda_runtime_api.h>
size_t size_qr = 0;
size_t size_internal = 0;
void *buffer_qr = NULL; // working space for numerical factorization
/* | 1 |
* A = | 2 |
* | 3 |
* | 0.1 0.1 0.1 4 |
* CSR of A is based-1
*
* b = [1 1 1 1]
*/
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 196
CSR QR Batch Examples
const int m = 4 ;
const int nnzA = 7;
const int csrRowPtrA[m+1] = { 1, 2, 3, 4, 8};
const int csrColIndA[nnzA] = { 1, 2, 3, 1, 2, 3, 4};
const double csrValA[nnzA] = { 1.0, 2.0, 3.0, 0.1, 0.1, 0.1, 4.0};
const double b[m] = {1.0, 1.0, 1.0, 1.0};
const int batchSize = 17;
cusparse_status = cusparseCreateMatDescr(&descrA);
assert(cusparse_status == CUSPARSE_STATUS_SUCCESS);
cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ONE); // base-1
cusolver_status = cusolverSpCreateCsrqrInfo(&info);
assert(cusolver_status == CUSOLVER_STATUS_SUCCESS);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 197
CSR QR Batch Examples
// don't copy csrValABatch and bBatch because device memory may be big enough
cudaStat1 = cudaMemcpy(d_csrColIndA, csrColIndA, sizeof(int) * nnzA,
cudaMemcpyHostToDevice);
cudaStat2 = cudaMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int) * (m+1),
cudaMemcpyHostToDevice);
assert(cudaStat1 == cudaSuccess);
assert(cudaStat2 == cudaSuccess);
int batchSizeMax = 2;
while(batchSizeMax < batchSize){
printf("batchSizeMax = %d\n", batchSizeMax);
cusolver_status = cusolverSpDcsrqrBufferInfoBatched(
cusolverH, m, m, nnzA,
// d_csrValA is don't care
descrA, d_csrValA, d_csrRowPtrA, d_csrColIndA,
batchSizeMax, // WARNING: use batchSizeMax
info,
&size_internal,
&size_qr);
assert(cusolver_status == CUSOLVER_STATUS_SUCCESS);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 198
CSR QR Batch Examples
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 199
CSR QR Batch Examples
Check results
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 200
Appendix C.
QR EXAMPLES
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 201
QR Examples
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include ormqr_example.cpp
* nvcc -o -fopenmp [Link] ormqr_example.o -L/usr/local/cuda/lib64 -lcudart -
lcublas -lcusolver
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cublas_v2.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 202
QR Examples
double A[lda*m] = { 1.0, 4.0, 2.0, 2.0, 5.0, 1.0, 3.0, 6.0, 1.0};
// double X[ldb*nrhs] = { 1.0, 1.0, 1.0}; // exact solution
double B[ldb*nrhs] = { 6.0, 15.0, 4.0};
double XC[ldb*nrhs]; // solution matrix from GPU
int info_gpu = 0;
cublas_status = cublasCreate(&cublasH);
assert(CUBLAS_STATUS_SUCCESS == cublas_status);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 203
QR Examples
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 204
QR Examples
cublas_status = cublasDtrsm(
cublasH,
CUBLAS_SIDE_LEFT,
CUBLAS_FILL_MODE_UPPER,
CUBLAS_OP_N,
CUBLAS_DIAG_NON_UNIT,
m,
nrhs,
&one,
d_A,
lda,
d_B,
ldb);
cudaStat1 = cudaDeviceSynchronize();
assert(CUBLAS_STATUS_SUCCESS == cublas_status);
assert(cudaSuccess == cudaStat1);
// free resources
if (d_A ) cudaFree(d_A);
if (d_tau ) cudaFree(d_tau);
if (d_B ) cudaFree(d_B);
if (devInfo) cudaFree(devInfo);
if (d_work ) cudaFree(d_work);
if (cublasH ) cublasDestroy(cublasH);
if (cusolverH) cusolverDnDestroy(cusolverH);
cudaDeviceReset();
return 0;
}
C.2. orthogonalization
This chapter provides a simple example in the C programming language of how to do
orthgonalization by QR factorization.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 205
QR Examples
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include orgqr_example.cpp
* g++ -fopenmp -o [Link] orgqr_example.o -L/usr/local/cuda/lib64 -lcudart -
lcublas -lcusolver
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cublas_v2.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 206
QR Examples
int lwork_geqrf = 0;
int lwork_orgqr = 0;
int lwork = 0;
int info_gpu = 0;
cublas_status = cublasCreate(&cublasH);
assert(CUBLAS_STATUS_SUCCESS == cublas_status);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 207
QR Examples
// step 5: compute Q
cusolver_status= cusolverDnDorgqr(
cusolverH,
m,
n,
n,
d_A,
lda,
d_tau,
d_work,
lwork,
devInfo);
cudaStat1 = cudaDeviceSynchronize();
assert(CUSOLVER_STATUS_SUCCESS == cusolver_status);
assert(cudaSuccess == cudaStat1);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 208
QR Examples
// R = -Q**T*Q + I
cublas_status = cublasDgemm_v2(
cublasH,
CUBLAS_OP_T, // Q**T
CUBLAS_OP_N, // Q
n, // number of rows of R
n, // number of columns of R
m, // number of columns of Q**T
&h_minus_one, /* host pointer */
d_A, // Q**T
lda,
d_A, // Q
lda,
&h_one, /* hostpointer */
d_R,
n);
assert(CUBLAS_STATUS_SUCCESS == cublas_status);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 209
QR Examples
free resources
// free resources
if (d_A ) cudaFree(d_A);
if (d_tau ) cudaFree(d_tau);
if (devInfo) cudaFree(devInfo);
if (d_work ) cudaFree(d_work);
if (d_R ) cudaFree(d_R);
if (cublasH ) cublasDestroy(cublasH);
if (cusolverH) cusolverDnDestroy(cusolverH);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 210
Appendix D.
LU EXAMPLES
D.1. LU Factorization
This chapter provides a simple example in the C programming language of how to use a
dense LU factorization to solve a linear system
The code uses getrf to do LU factorization and getrs to do backward and forward solve.
The parameter pivot_on decides whether partial pivoting is performed or not.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 211
LU Examples
...
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include getrf_example.cpp
* g++ -fopenmp -o [Link] getrf_example.o -L/usr/local/cuda/lib64 -lcusolver -
lcudart
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 212
LU Examples
...
double A[lda*m] = { 1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 10.0};
double B[m] = { 1.0, 2.0, 3.0 };
double X[m]; /* X = A\B */
double LU[lda*m]; /* L and U */
int Ipiv[m]; /* host copy of pivoting sequence */
int info = 0; /* host copy of error info */
if (pivot_on){
printf("pivot is on : compute P*A = L*U \n");
}else{
printf("pivot is off: compute A = L*U (not numerically stable)\n");
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 213
LU Examples
...
/* step 4: LU factorization */
if (pivot_on){
status = cusolverDnDgetrf(
cusolverH,
m,
m,
d_A,
lda,
d_work,
d_Ipiv,
d_info);
}else{
status = cusolverDnDgetrf(
cusolverH,
m,
m,
d_A,
lda,
d_work,
NULL,
d_info);
}
cudaStat1 = cudaDeviceSynchronize();
assert(CUSOLVER_STATUS_SUCCESS == status);
assert(cudaSuccess == cudaStat1);
if (pivot_on){
cudaStat1 = cudaMemcpy(Ipiv , d_Ipiv, sizeof(int)*m,
cudaMemcpyDeviceToHost);
}
cudaStat2 = cudaMemcpy(LU , d_A , sizeof(double)*lda*m,
cudaMemcpyDeviceToHost);
cudaStat3 = cudaMemcpy(&info, d_info, sizeof(int), cudaMemcpyDeviceToHost);
assert(cudaSuccess == cudaStat1);
assert(cudaSuccess == cudaStat2);
assert(cudaSuccess == cudaStat3);
if ( 0 > info ){
printf("%d-th parameter is wrong \n", -info);
exit(1);
}
if (pivot_on){
printf("pivoting sequence, matlab base-1\n");
for(int j = 0 ; j < m ; j++){
printf("Ipiv(%d) = %d\n", j+1, Ipiv[j]);
}
}
printf("L and U = (matlab base-1)\n");
printMatrix(m, m, LU, lda, "LU");
printf("=====\n");
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 214
LU Examples
...
/*
* step 5: solve A*X = B
* | 1 | | -0.3333 |
* B = | 2 |, X = | 0.6667 |
* | 3 | | 0 |
*
*/
if (pivot_on){
status = cusolverDnDgetrs(
cusolverH,
CUBLAS_OP_N,
m,
1, /* nrhs */
d_A,
lda,
d_Ipiv,
d_B,
ldb,
d_info);
}else{
status = cusolverDnDgetrs(
cusolverH,
CUBLAS_OP_N,
m,
1, /* nrhs */
d_A,
lda,
NULL,
d_B,
ldb,
d_info);
}
cudaStat1 = cudaDeviceSynchronize();
assert(CUSOLVER_STATUS_SUCCESS == status);
assert(cudaSuccess == cudaStat1);
/* free resources */
if (d_A ) cudaFree(d_A);
if (d_B ) cudaFree(d_B);
if (d_Ipiv ) cudaFree(d_Ipiv);
if (d_info ) cudaFree(d_info);
if (d_work ) cudaFree(d_work);
if (cusolverH ) cusolverDnDestroy(cusolverH);
if (stream ) cudaStreamDestroy(stream);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 215
Appendix E.
CHOLESKY EXAMPLES
each A[i] is a 3x3 dense Hermitian matrix. In this example, there are two matrices, A0
and A1. A0 is positive definite and A1 is not.
The code uses potrfBatched to do Cholesky factorization and potrsBatched to do
backward and forward solve. potrfBatched would report singularity on A1.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 216
Cholesky Examples
...
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include batchchol_example.cpp
* g++ -o [Link] batchchol_example.o -L/usr/local/cuda/lib64 -lcusolver -
lcudart
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 217
Cholesky Examples
...
double A0[lda*m] = { 1.0, 2.0, 3.0, 2.0, 5.0, 5.0, 3.0, 5.0, 12.0 };
double A1[lda*m] = { 1.0, 2.0, 3.0, 2.0, 4.0, 5.0, 3.0, 5.0, 12.0 };
double B0[m] = { 1.0, 1.0, 1.0 };
double X0[m]; /* X0 = A0\B0 */
int infoArray[batchSize]; /* host copy of error info */
double *Aarray[batchSize];
double *Barray[batchSize];
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 218
Cholesky Examples
...
assert( 0 == infoArray[0] );
/* A1 is singular */
assert( 2 == infoArray[1] );
/*
* step 4: solve A0*X0 = B0
* | 1 | | 10.5 |
* B0 = | 1 |, X0 = | -2.5 |
* | 1 | | -1.5 |
*/
status = cusolverDnDpotrsBatched(
handle,
uplo,
m,
nrhs, /* only support rhs = 1*/
d_Aarray,
lda,
d_Barray,
ldb,
d_infoArray,
batchSize);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 219
Cholesky Examples
...
cudaStat1 = cudaDeviceSynchronize();
assert(CUSOLVER_STATUS_SUCCESS == status);
assert(cudaSuccess == cudaStat1);
/* free resources */
if (d_Aarray ) cudaFree(d_Aarray);
if (d_Barray ) cudaFree(d_Barray);
if (d_infoArray ) cudaFree(d_infoArray);
if (handle ) cusolverDnDestroy(handle);
if (stream ) cudaStreamDestroy(stream);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 220
Appendix F.
EXAMPLES OF DENSE EIGENVALUE SOLVER
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 221
Examples of Dense Eigenvalue Solver
The following code uses syevd to compute eigenvalues and eigenvectors, then compare
to exact eigenvalues {2,3,4}.
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include syevd_example.cpp
* g++ -o [Link] syevd_example.o -L/usr/local/cuda/lib64 -lcudart -lcusolver
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
int info_gpu = 0;
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 222
Examples of Dense Eigenvalue Solver
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 223
Examples of Dense Eigenvalue Solver
// free resources
if (d_A ) cudaFree(d_A);
if (d_W ) cudaFree(d_W);
if (devInfo) cudaFree(devInfo);
if (d_work ) cudaFree(d_work);
if (cusolverH) cusolverDnDestroy(cusolverH);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 224
Examples of Dense Eigenvalue Solver
The following code uses sygvd to compute eigenvalues and eigenvectors, then compare
to exact eigenvalues {0.158660256604, 0.370751508101882, 0.6}.
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include sygvd_example.cpp
* g++ -o [Link] sygvd_example.o -L/usr/local/cuda/lib64 -lcusolver
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 225
Examples of Dense Eigenvalue Solver
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 226
Examples of Dense Eigenvalue Solver
// free resources
if (d_A ) cudaFree(d_A);
if (d_B ) cudaFree(d_B);
if (d_W ) cudaFree(d_W);
if (devInfo) cudaFree(devInfo);
if (d_work ) cudaFree(d_work);
if (cusolverH) cusolverDnDestroy(cusolverH);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 227
Examples of Dense Eigenvalue Solver
The following code uses syevj to compute eigenvalues and eigenvectors, then compare
to exact eigenvalues {2,3,4}.
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include syevj_example.cpp
* g++ -o syevj_example syevj_example.o -L/usr/local/cuda/lib64 -lcusolver -
lcudart
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
/* configuration of syevj */
const double tol = 1.e-7;
const int max_sweeps = 15;
const cusolverEigMode_t jobz = CUSOLVER_EIG_MODE_VECTOR; // compute
eigenvectors.
const cublasFillMode_t uplo = CUBLAS_FILL_MODE_LOWER;
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 228
Examples of Dense Eigenvalue Solver
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 229
Examples of Dense Eigenvalue Solver
if ( 0 == info ){
printf("syevj converges \n");
}else if ( 0 > info ){
printf("%d-th parameter is wrong \n", -info);
exit(1);
}else{
printf("WARNING: info = %d : syevj does not converge \n", info );
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 230
Examples of Dense Eigenvalue Solver
status = cusolverDnXsyevjGetSweeps(
cusolverH,
syevj_params,
&executed_sweeps);
assert(CUSOLVER_STATUS_SUCCESS == status);
status = cusolverDnXsyevjGetResidual(
cusolverH,
syevj_params,
&residual);
assert(CUSOLVER_STATUS_SUCCESS == status);
/* free resources */
if (d_A ) cudaFree(d_A);
if (d_W ) cudaFree(d_W);
if (d_info ) cudaFree(d_info);
if (d_work ) cudaFree(d_work);
if (cusolverH ) cusolverDnDestroy(cusolverH);
if (stream ) cudaStreamDestroy(stream);
if (syevj_params) cusolverDnDestroySyevjInfo(syevj_params);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 231
Examples of Dense Eigenvalue Solver
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include sygvj_example.cpp
* g++ -o sygvj_example sygvj_example.o -L/usr/local/cuda/lib64 -lcusolver -
lcudart
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 232
Examples of Dense Eigenvalue Solver
/* configuration of sygvj */
const double tol = 1.e-7;
const int max_sweeps = 15;
const cusolverEigType_t itype = CUSOLVER_EIG_TYPE_1; // A*x = (lambda)*B*x
const cusolverEigMode_t jobz = CUSOLVER_EIG_MODE_VECTOR; // compute
eigenvectors.
const cublasFillMode_t uplo = CUBLAS_FILL_MODE_LOWER;
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 233
Examples of Dense Eigenvalue Solver
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 234
Examples of Dense Eigenvalue Solver
if ( 0 == info ){
printf("sygvj converges \n");
}else if ( 0 > info ){
printf("Error: %d-th parameter is wrong \n", -info);
exit(1);
}else if ( m >= info ){
printf("Error: leading minor of order %d of B is not positive definite
\n", -info);
exit(1);
}else { /* info = m+1 */
printf("WARNING: info = %d : sygvj does not converge \n", info );
}
status = cusolverDnXsyevjGetSweeps(
cusolverH,
syevj_params,
&executed_sweeps);
assert(CUSOLVER_STATUS_SUCCESS == status);
status = cusolverDnXsyevjGetResidual(
cusolverH,
syevj_params,
&residual);
assert(CUSOLVER_STATUS_SUCCESS == status);
/* free resources */
if (d_A ) cudaFree(d_A);
if (d_B ) cudaFree(d_B);
if (d_W ) cudaFree(d_W);
if (d_info ) cudaFree(d_info);
if (d_work ) cudaFree(d_work);
if (cusolverH) cusolverDnDestroy(cusolverH);
if (stream ) cudaStreamDestroy(stream);
if (syevj_params) cusolverDnDestroySyevjInfo(syevj_params);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 235
Examples of Dense Eigenvalue Solver
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 236
Examples of Dense Eigenvalue Solver
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include batchsyevj_example.cpp
* g++ -o batchsyevj_example batchsyevj_example.o -L/usr/local/cuda/lib64 -
lcusolver -lcudart
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 237
Examples of Dense Eigenvalue Solver
double *A0 = A;
double *A1 = A + lda*m;
/*
* | 1 -1 0 |
* A0 = | -1 2 0 |
* | 0 0 0 |
* A0 is column-major
*/
A0[0 + 0*lda] = 1.0;
A0[1 + 0*lda] = -1.0;
A0[2 + 0*lda] = 0.0;
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 238
Examples of Dense Eigenvalue Solver
/* disable sorting */
status = cusolverDnXsyevjSetSortEig(
syevj_params,
sort_eig);
assert(CUSOLVER_STATUS_SUCCESS == status);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 239
Examples of Dense Eigenvalue Solver
double *V0 = V;
double *V1 = V + lda*m;
printf("V0 = (matlab base-1)\n");
printMatrix(m, m, V0, lda, "V0");
printf("V1 = (matlab base-1)\n");
printMatrix(m, m, V1, lda, "V1");
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 240
Examples of Dense Eigenvalue Solver
/*
* The folowing two functions do not support batched version.
* The error CUSOLVER_STATUS_NOT_SUPPORTED is returned.
*/
status = cusolverDnXsyevjGetSweeps(
cusolverH,
syevj_params,
&executed_sweeps);
assert(CUSOLVER_STATUS_NOT_SUPPORTED == status);
status = cusolverDnXsyevjGetResidual(
cusolverH,
syevj_params,
&residual);
assert(CUSOLVER_STATUS_NOT_SUPPORTED == status);
/* free resources */
if (d_A ) cudaFree(d_A);
if (d_W ) cudaFree(d_W);
if (d_info ) cudaFree(d_info);
if (d_work ) cudaFree(d_work);
if (cusolverH) cusolverDnDestroy(cusolverH);
if (stream ) cudaStreamDestroy(stream);
if (syevj_params) cusolverDnDestroySyevjInfo(syevj_params);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 241
Appendix G.
EXAMPLES OF SINGULAR VALUE
DECOMPOSITION
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 242
Examples of Singular Value Decomposition
...
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include svd_example.cpp
* g++ -o [Link] svd_example.o -L/usr/local/cuda/lib64 -lcudart -lcublas -
lcusolver
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cublas_v2.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg);
}
}
}
int lwork = 0;
int info_gpu = 0;
const double h_one = 1;
const double h_minus_one = -1;
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 243
Examples of Singular Value Decomposition
...
cublas_status = cublasCreate(&cublasH);
assert(CUBLAS_STATUS_SUCCESS == cublas_status);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 244
Examples of Singular Value Decomposition
...
// step 6: |A - U*S*VT|
// W = S*VT
cublas_status = cublasDdgmm(
cublasH,
CUBLAS_SIDE_LEFT,
n,
n,
d_VT,
lda,
d_S,
1,
d_W,
lda);
assert(CUBLAS_STATUS_SUCCESS == cublas_status);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 245
Examples of Singular Value Decomposition
...
// A := -U*W + A
cudaStat1 = cudaMemcpy(d_A, A, sizeof(double)*lda*n,
cudaMemcpyHostToDevice);
assert(cudaSuccess == cudaStat1);
cublas_status = cublasDgemm_v2(
cublasH,
CUBLAS_OP_N, // U
CUBLAS_OP_N, // W
m, // number of rows of A
n, // number of columns of A
n, // number of columns of U
&h_minus_one, /* host pointer */
d_U, // U
lda,
d_W, // W
lda,
&h_one, /* hostpointer */
d_A,
lda);
assert(CUBLAS_STATUS_SUCCESS == cublas_status);
// free resources
if (d_A ) cudaFree(d_A);
if (d_S ) cudaFree(d_S);
if (d_U ) cudaFree(d_U);
if (d_VT ) cudaFree(d_VT);
if (devInfo) cudaFree(devInfo);
if (d_work ) cudaFree(d_work);
if (d_rwork) cudaFree(d_rwork);
if (d_W ) cudaFree(d_W);
if (cublasH ) cublasDestroy(cublasH);
if (cusolverH) cusolverDnDestroy(cusolverH);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 246
Examples of Singular Value Decomposition
...
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include gesvdj_example.cpp
* g++ -o gesvdj_example gesvdj_example.o -L/usr/local/cuda/lib64 -lcudart -
lcusolver
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %20.16E\n", name, row+1, col+1, Areg);
}
}
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 247
Examples of Singular Value Decomposition
...
/* configuration of gesvdj */
const double tol = 1.e-7;
const int max_sweeps = 15;
const cusolverEigMode_t jobz = CUSOLVER_EIG_MODE_VECTOR; // compute
eigenvectors.
const int econ = 0 ; /* econ = 1 for economy size */
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 248
Examples of Singular Value Decomposition
...
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 249
Examples of Singular Value Decomposition
...
if ( 0 == info ){
printf("gesvdj converges \n");
}else if ( 0 > info ){
printf("%d-th parameter is wrong \n", -info);
exit(1);
}else{
printf("WARNING: info = %d : gesvdj does not converge \n", info );
}
status = cusolverDnXgesvdjGetSweeps(
cusolverH,
gesvdj_params,
&executed_sweeps);
assert(CUSOLVER_STATUS_SUCCESS == status);
status = cusolverDnXgesvdjGetResidual(
cusolverH,
gesvdj_params,
&residual);
assert(CUSOLVER_STATUS_SUCCESS == status);
/* free resources */
if (d_A ) cudaFree(d_A);
if (d_S ) cudaFree(d_S);
if (d_U ) cudaFree(d_U);
if (d_V ) cudaFree(d_V);
if (d_info) cudaFree(d_info);
if (d_work ) cudaFree(d_work);
if (cusolverH) cusolverDnDestroy(cusolverH);
if (stream ) cudaStreamDestroy(stream);
if (gesvdj_params) cusolverDnDestroyGesvdjInfo(gesvdj_params);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 250
Examples of Singular Value Decomposition
The following code uses gesvdjBatched to compute singular values and singular
vectors.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 251
Examples of Singular Value Decomposition
/*
* How to compile (assume cuda is installed at /usr/local/cuda/)
* nvcc -c -I/usr/local/cuda/include gesvdjbatch_example.cpp
* g++ -o gesvdjbatch_example gesvdjbatch_example.o -L/usr/local/cuda/lib64 -
lcusolver -lcudart
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <cusolverDn.h>
void printMatrix(int m, int n, const double*A, int lda, const char* name)
{
for(int row = 0 ; row < m ; row++){
for(int col = 0 ; col < n ; col++){
double Areg = A[row + col*lda];
printf("%s(%d,%d) = %20.16E\n", name, row+1, col+1, Areg);
}
}
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 252
Examples of Singular Value Decomposition
double *A0 = A;
double *A1 = A + lda*n; /* Aj is m-by-n */
/*
* | 1 -1 |
* A0 = | -1 2 |
* | 0 0 |
* A0 is column-major
*/
A0[0 + 0*lda] = 1.0;
A0[1 + 0*lda] = -1.0;
A0[2 + 0*lda] = 0.0;
/*
* | 3 4 |
* A1 = | 4 7 |
* | 0 0 |
* A1 is column-major
*/
A1[0 + 0*lda] = 3.0;
A1[1 + 0*lda] = 4.0;
A1[2 + 0*lda] = 0.0;
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 253
Examples of Singular Value Decomposition
/* disable sorting */
status = cusolverDnXgesvdjSetSortEig(
gesvdj_params,
sort_svd);
assert(CUSOLVER_STATUS_SUCCESS == status);
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 254
Examples of Singular Value Decomposition
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 255
Examples of Singular Value Decomposition
double *U0 = U;
double *U1 = U + ldu*m; /* Uj is m-by-m */
printf("U0 = (matlab base-1)\n");
printMatrix(m, m, U0, ldu, "U0");
printf("U1 = (matlab base-1)\n");
printMatrix(m, m, U1, ldu, "U1");
double *V0 = V;
double *V1 = V + ldv*n; /* Vj is n-by-n */
printf("V0 = (matlab base-1)\n");
printMatrix(n, n, V0, ldv, "V0");
printf("V1 = (matlab base-1)\n");
printMatrix(n, n, V1, ldv, "V1");
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 256
Examples of Singular Value Decomposition
/*
* The folowing two functions do not support batched version.
* The error CUSOLVER_STATUS_NOT_SUPPORTED is returned.
*/
status = cusolverDnXgesvdjGetSweeps(
cusolverH,
gesvdj_params,
&executed_sweeps);
assert(CUSOLVER_STATUS_NOT_SUPPORTED == status);
status = cusolverDnXgesvdjGetResidual(
cusolverH,
gesvdj_params,
&residual);
assert(CUSOLVER_STATUS_NOT_SUPPORTED == status);
/* free resources */
if (d_A ) cudaFree(d_A);
if (d_U ) cudaFree(d_U);
if (d_V ) cudaFree(d_V);
if (d_S ) cudaFree(d_S);
if (d_info ) cudaFree(d_info);
if (d_work ) cudaFree(d_work);
if (cusolverH) cusolverDnDestroy(cusolverH);
if (stream ) cudaStreamDestroy(stream);
if (gesvdj_params) cusolverDnDestroyGesvdjInfo(gesvdj_params);
cudaDeviceReset();
return 0;
}
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 257
Appendix H.
ACKNOWLEDGEMENTS
NVIDIA would like to thank the following individuals and institutions for their
contributions:
‣ CPU LAPACK routines from netlib, CLAPACK-3.2.1 ([Link]
clapack/)
The following is license of CLAPACK-3.2.1.
Copyright (c) 1992-2008 The University of Tennessee. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer listed in this license in the documentation and/
or other materials provided with the distribution.
- Neither the name of the copyright holders nor the names of its contributors may be
used to endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
‣ METIS-5.1.0 ([Link]
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 258
Acknowledgements
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 259
Acknowledgements
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 260
Appendix I.
BIBLIOGRAPHY
[1] Timothy A. Davis, Direct Methods for sparse Linear Systems, siam 2006.
[2] E. Chuthill and J. McKee, reducing the bandwidth of sparse symmetric matrices,
ACM '69 Proceedings of the 1969 24th national conference, Pages 157-172.
[3] Alan George, Joseph W. H. Liu, An Implementation of a Pseudoperipheral Node
Finder, ACM Transactions on Mathematical Software (TOMS) Volume 5 Issue 3, Sept.
1979 Pages 284-295.
[4] J. R. Gilbert and T. Peierls, Sparse partial pivoting in time proportional to arithmetic
operations, SIAM J. Sci. Statist. Comput., 9 (1988), pp. 862-874.
[5] Alan George and Esmond Ng, An Implementation of Gaussian Elimination with
Partial Pivoting for Sparse Systems, SIAM J. Sci. and Stat. Comput., 6(2), 390-409.
[6] Alan George and Esmond Ng, Symbolic Factorization for Sparse Gaussian
Elimination with Paritial Pivoting, SIAM J. Sci. and Stat. Comput., 8(6), 877-898.
[7] John R. Gilbert, Xiaoye S. Li, Esmond G. Ng, Barry W. Peyton, Computing Row
and Column Counts for Sparse QR and LU Factorization, BIT 2001, Vol. 41, No. 4, pp.
693-711.
[8] Patrick R. Amestoy, Timothy A. Davis, Iain S. Duff, An Approximate Minimum
Degree Ordering Algorithm, SIAM J. Matrix Analysis Applic. Vol 17, no 4, pp. 886-905,
Dec. 1996.
[9] Alan George, Joseph W. Liu, A Fast Implementation of the Minimum Degree
Algorithm Using Quotient Graphs, ACM Transactions on Mathematical Software, Vol 6,
No. 3, September 1980, page 337-358.
[10] Alan George, Joseph W. Liu, Computer Solution of Large Sparse Positive Definite
Systems, Englewood Cliffs, New Jersey: Prentice-Hall, 1981.
[11] Iain S. Duff, ALGORITHM 575 Permutations for a Zero-Free Diagonal, ACM
Transactions on Mathematical Software, Vol 7, No 3, September 1981, Page 387-390
[12] Iain S. Duff and Jacko Koster, On algorithms for permuting large entries to the
diagonal of a sparse matrix, SIAM Journal on Matrix Analysis and Applications, 2001,
Vol. 22, No. 4 : pp. 973-996
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 261
Bibliography
[13] "A Fast and Highly Quality Multilevel Scheme for Partitioning Irregular Graphs".
George Karypis and Vipin Kumar. SIAM Journal on Scientific Computing, Vol. 20, No. 1,
pp. 359-392, 1999.
[Link]
cuSOLVER Library DU-06709-001_v10.1 | 262
Notice
ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS,
DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY,
"MATERIALS") ARE BEING PROVIDED "AS IS." NVIDIA MAKES NO WARRANTIES,
EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE
MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF
NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR
PURPOSE.
Information furnished is believed to be accurate and reliable. However, NVIDIA
Corporation assumes no responsibility for the consequences of use of such
information or for any infringement of patents or other rights of third parties
that may result from its use. No license is granted by implication of otherwise
under any patent rights of NVIDIA Corporation. Specifications mentioned in this
publication are subject to change without notice. This publication supersedes and
replaces all other information previously supplied. NVIDIA Corporation products
are not authorized as critical components in life support devices or systems
without express written approval of NVIDIA Corporation.
Trademarks
NVIDIA and the NVIDIA logo are trademarks or registered trademarks of NVIDIA
Corporation in the U.S. and other countries. Other company and product names
may be trademarks of the respective companies with which they are associated.
Copyright
© 2014-2019 NVIDIA Corporation. All rights reserved.
[Link]