Skip to main content

cusolverDnXgesvdr

Function cusolverDnXgesvdr 

Source
pub unsafe extern "C" fn cusolverDnXgesvdr(
    handle: cusolverDnHandle_t,
    params: cusolverDnParams_t,
    jobu: c_schar,
    jobv: c_schar,
    m: i64,
    n: i64,
    k: i64,
    p: i64,
    niters: i64,
    dataTypeA: cudaDataType,
    A: *mut c_void,
    lda: i64,
    dataTypeSrand: cudaDataType,
    Srand: *mut c_void,
    dataTypeUrand: cudaDataType,
    Urand: *mut c_void,
    ldUrand: i64,
    dataTypeVrand: cudaDataType,
    Vrand: *mut c_void,
    ldVrand: i64,
    computeType: cudaDataType,
    bufferOnDevice: *mut c_void,
    workspaceInBytesOnDevice: size_t,
    bufferOnHost: *mut c_void,
    workspaceInBytesOnHost: size_t,
    d_info: *mut c_int,
) -> cusolverStatus_t
Expand description

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

The routine below

This function computes the approximated rank-k singular value decomposition (k-SVD) of an $m \times n$ matrix A and the corresponding left and/or right singular vectors. The k-SVD is written as: $$ A_{k}\approx U\*\Sigma\*V^{H} $$

where $\Sigma$ is a $k \times k$ matrix which is zero except for its diagonal elements, U is an $m \times k$ orthonormal matrix, and V is an $k \times n$ orthonormal matrix. The diagonal elements of $\Sigma$ are the approximated singular values of A; they are real and non-negative, and are returned in descending order. The columns of U and V are the top-k left and right singular vectors of A.

cusolverDnXgesvdr implements randomized methods described in [15] to compute k-SVD that is accurate with high probability if the conditions described in [15] hold. cusolverDnXgesvdr is intended to compute a very small portion of the spectrum (meaning that k is very small compared to min(m,n)). of A fast and with good quality, specially when the dimensions of the matrix are large.

The accuracy of the method depends on the spectrum of A, the number of power iterations niters, the oversampling parameter p and the ratio between p and the dimensions of the matrix A. Larger values of oversampling p or larger number of iterations niters might produce more accurate approximations, but it will also increase the run time of cusolverDnXgesvdr.

Our recommendation is to use two iterations and set the oversampling to at least 2k. Once the solver provides enough accuracy, adjust the values of k and niters for better performance.

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 cusolverDnXgesvdr_bufferSize.

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

Currently, cusolverDnXgesvdr supports only the default algorithm.

Algorithms supported by cusolverDnXgesvdr

cusolverAlgMode_t::CUSOLVER_ALG_0 or NULLDefault algorithm.

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

Remark 1: gesvdr supports n>=m as well.

Remark 2: the routine returns V, not $V^{H}$

List of input arguments for cusolverDnXgesvdr_bufferSize and cusolverDnXgesvdr:

The generic API has five different types, dataTypeA is data type of the matrix A, dataTypeS is data type of the vector S and dataTypeU is data type of the matrix U, dataTypeV is data type of the matrix V, computeType is compute type of the operation. cusolverDnXgesvdr only supports the following four combinations.

Valid combination of data type and compute type

DataTypeADataTypeSDataTypeUDataTypeVComputeTypeMeaning
CUDA_R_32FCUDA_R_32FCUDA_R_32FCUDA_R_32FCUDA_R_32FSGESVDR
CUDA_R_64FCUDA_R_64FCUDA_R_64FCUDA_R_64FCUDA_R_64FDGESVDR
CUDA_C_32FCUDA_R_32FCUDA_C_32FCUDA_C_32FCUDA_C_32FCGESVDR
CUDA_C_64FCUDA_R_64FCUDA_C_64FCUDA_C_64FCUDA_C_64FZGESVDR

§Parameters

  • handle: Handle to the cuSolverDN library context.
  • params: Structure with information collected by cusolverDnSetAdvOptions.
  • jobu: Specifies options for computing all or part of the matrix U: = ‘S’: the first k columns of U (the left singular vectors) are returned in the array U; = ‘N’: no columns of U (no left singular vectors) are computed.
  • jobv: Specifies options for computing all or part of the matrix V: = ‘S’: the first k rows of V (the right singular vectors) are returned in the array V; = ‘N’: no rows of V (no right singular vectors) are computed.
  • m: Number of rows of matrix A.
  • n: Number of columns of matrix A.
  • k: Rank of the k-SVD decomposition of matrix A. rank is less than min(m,n).
  • p: Oversampling. The size of the subspace will be (k + p). (k+p) is less than min(m,n).
  • niters: Number of iteration of power method.
  • dataTypeA: Data type of array A.
  • A: Array of dimension lda * n with lda is not less than max(1,m). On exit, the contents of A are destroyed.
  • lda: Leading dimension of two-dimensional array used to store matrix A.
  • computeType: Data type of computation.
  • bufferOnDevice: Device workspace. Array of type void of size workspaceInBytesOnDevice bytes.
  • workspaceInBytesOnDevice: Size in bytes of bufferOnDevice, returned by cusolverDnXgesvdr_bufferSize.
  • bufferOnHost: Host workspace. Array of type void of size workspaceInBytesOnHost bytes.
  • workspaceInBytesOnHost: Size in bytes of bufferOnHost, returned by cusolverDnXgesvdr_bufferSize.
  • d_info: If info = 0, the operation is successful. If info = -i, the i-th parameter is wrong (not counting handle).

§Return value