Skip to main content

cusparseCsr2cscEx2

Function cusparseCsr2cscEx2 

Source
pub unsafe extern "C" fn cusparseCsr2cscEx2(
    handle: cusparseHandle_t,
    m: c_int,
    n: c_int,
    nnz: c_int,
    csrVal: *const c_void,
    csrRowPtr: *const c_int,
    csrColInd: *const c_int,
    cscVal: *mut c_void,
    cscColPtr: *mut c_int,
    cscRowInd: *mut c_int,
    valType: cudaDataType,
    copyValues: cusparseAction_t,
    idxBase: cusparseIndexBase_t,
    alg: cusparseCsr2CscAlg_t,
    buffer: *mut c_void,
) -> cusparseStatus_t
Expand description

This function converts a sparse matrix in CSR format (that is defined by the three arrays csrVal, csrRowPtr, and csrColInd) into a sparse matrix in CSC format (that is defined by arrays cscVal, cscRowInd, and cscColPtr). The resulting matrix can also be seen as the transpose of the original sparse matrix. Notice that this routine can also be used to convert a matrix in CSC format into a matrix in CSR format.

The routine requires extra storage proportional to the number of nonzero values nnz. It provides in output always the same matrix.

It is executed asynchronously with respect to the host, and it may return control to the application on the host before the result is ready.

The function cusparseCsr2cscEx2_bufferSize returns the size of the workspace needed by cusparseCsr2cscEx2. User needs to allocate a buffer of this size and give that buffer to cusparseCsr2cscEx2 as an argument.

If nnz == 0, then csrColInd, csrVal, cscVal, and cscRowInd could have NULL value. In this case, cscColPtr is set to idxBase for all values.

If m == 0 or n == 0, the pointers are not checked and the routine returns cusparseStatus_t::CUSPARSE_STATUS_SUCCESS.

cusparseCsr2cscEx2 supports the following data types:

cusparseCsr2cscEx2 supports the following algorithms (cusparseCsr2CscAlg_t):

AlgorithmNotes
cusparseCsr2CscAlg_t::CUSPARSE_CSR2CSC_ALG_DEFAULT, CUSPARSE_CSR2CSC_ALG1Default algorithm
ActionNotes
cusparseAction_t::CUSPARSE_ACTION_SYMBOLICCompute the “structure” of the CSC output matrix (offset, row indices)
cusparseAction_t::CUSPARSE_ACTION_NUMERICCompute the “structure” of the CSC output matrix and copy the values

cusparseCsr2cscEx2 has the following properties:

  • The routine requires no extra storage
  • The routine supports asynchronous execution

cusparseCsr2cscEx2 supports the following optimizations:

  • CUDA graph capture
  • Hardware Memory Compression.

§Parameters

  • handle: Handle to the cuSPARSE library context.
  • m: Number of rows of the CSR input matrix; number of columns of the CSC ouput matrix.
  • n: Number of columns of the CSR input matrix; number of rows of the CSC ouput matrix.
  • nnz: Number of nonzero elements of the CSR and CSC matrices.
  • csrVal: Value array of size nnz of the CSR matrix; of same type as valType.
  • csrRowPtr: Integer array of size m + 1 that containes the CSR row offsets.
  • csrColInd: Integer array of size nnz that containes the CSR column indices.
  • cscVal: Value array of size nnz of the CSC matrix; of same type as valType.
  • cscColPtr: Integer array of size n + 1 that containes the CSC column offsets.
  • cscRowInd: Integer array of size nnz that containes the CSC row indices.
  • valType: Value type for both CSR and CSC matrices.
  • copyValues: cusparseAction_t::CUSPARSE_ACTION_SYMBOLIC or cusparseAction_t::CUSPARSE_ACTION_NUMERIC.
  • idxBase: Index base cusparseIndexBase_t::CUSPARSE_INDEX_BASE_ZERO or cusparseIndexBase_t::CUSPARSE_INDEX_BASE_ONE.
  • alg: Algorithm implementation. see cusparseCsr2CscAlg_t for possible values.
  • buffer: Pointer to workspace buffer.