Skip to main content

cusolverDnXgetrf

Function cusolverDnXgetrf 

Source
pub unsafe extern "C" fn cusolverDnXgetrf(
    handle: cusolverDnHandle_t,
    params: cusolverDnParams_t,
    m: i64,
    n: i64,
    dataTypeA: cudaDataType,
    A: *mut c_void,
    lda: i64,
    ipiv: *mut i64,
    computeType: cudaDataType,
    bufferOnDevice: *mut c_void,
    workspaceInBytesOnDevice: size_t,
    bufferOnHost: *mut c_void,
    workspaceInBytesOnHost: size_t,
    info: *mut c_int,
) -> cusolverStatus_t
Expand description

The helper function below can calculate the sizes needed for pre-allocated buffer.

The function below

computes the LU factorization of a $m \times n$ matrix: $$ P\*A = L\*U $$

where A is a $m \times n$ matrix, P is a permutation matrix, L is a lower triangular matrix with unit diagonal, and U is an upper triangular matrix using the generic API interface.

If LU factorization failed, i.e. matrix A (U) is singular, The output parameter info=i indicates U(i,i) = 0.

If output parameter info = -i (less than zero), the i-th parameter is wrong (not counting handle).

If ipiv is null, no pivoting is performed. The factorization is A=L*U, which is not numerically stable.

No matter LU factorization failed or not, the output parameter ipiv contains pivoting sequence, row i is interchanged with row ipiv(i).

The user has to provide device and host working spaces which are pointed by input parameters bufferOnDevice and bufferOnHost. The input parameters workspaceInBytesOnDevice (and workspaceInBytesOnHost) is size in bytes of the device (and host) working space, and it is returned by cusolverDnXgetrf_bufferSize.

The user can combine cusolverDnXgetrf and cusolverDnGetrs to complete a linear solver.

Currently, cusolverDnXgetrf supports two algorithms. To select legacy implementation, the user has to call cusolverDnSetAdvOptions.

Please visit cuSOLVER Library Samples - Xgetrf for a code example.

Algorithms supported by cusolverDnXgetrf

cusolverAlgMode_t::CUSOLVER_ALG_0 or NULLDefault algorithm. The fastest, requires a large workspace of m*n elements.
cusolverAlgMode_t::CUSOLVER_ALG_1Legacy implementation

List of input arguments for cusolverDnXgetrf_bufferSize and cusolverDnXgetrf:

The generic API has two different types, dataTypeA is data type of the matrix A, computeType is compute type of the operation. cusolverDnXgetrf only supports the following four combinations.

Valid combination of data type and compute type

DataTypeAComputeTypeMeaning
CUDA_R_32FCUDA_R_32FSGETRF
CUDA_R_64FCUDA_R_64FDGETRF
CUDA_C_32FCUDA_C_32FCGETRF
CUDA_C_64FCUDA_C_64FZGETRF

§Parameters

  • handle: Handle to the cuSolverDN library context.
  • params: Structure with information collected by cusolverDnSetAdvOptions.
  • m: Number of rows of matrix A.
  • n: Number of columns of matrix A.
  • dataTypeA: Data type of array A.
  • A: <type> array of dimension lda * n with lda is not less than max(1,m).
  • lda: Leading dimension of two-dimensional array used to store matrix A.
  • ipiv: Array of size at least min(m,n), containing pivot indices.
  • computeType: Data type of computation.
  • bufferOnDevice: Device workspace. Array of type void of size workspaceInBytesOnDevice bytes.
  • workspaceInBytesOnDevice: Size in bytes of bufferOnDevice, returned by cusolverDnXgetrf_bufferSize.
  • bufferOnHost: Host workspace. Array of type void of size workspaceInBytesOnHost bytes.
  • workspaceInBytesOnHost: Size in bytes of bufferOnHost, returned by cusolverDnXgetrf_bufferSize.
  • info: If info = 0, the LU factorization is successful. if info = -i, the i-th parameter is wrong (not counting handle). If info = i, the U(i,i) = 0.

§Return value