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_tExpand 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):
| Algorithm | Notes |
|---|---|
cusparseCsr2CscAlg_t::CUSPARSE_CSR2CSC_ALG_DEFAULT, CUSPARSE_CSR2CSC_ALG1 | Default algorithm |
| Action | Notes |
|---|---|
cusparseAction_t::CUSPARSE_ACTION_SYMBOLIC | Compute the “structure” of the CSC output matrix (offset, row indices) |
cusparseAction_t::CUSPARSE_ACTION_NUMERIC | Compute 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 sizennzof the CSR matrix; of same type asvalType.csrRowPtr: Integer array of sizem + 1that containes the CSR row offsets.csrColInd: Integer array of sizennzthat containes the CSR column indices.cscVal: Value array of sizennzof the CSC matrix; of same type asvalType.cscColPtr: Integer array of sizen + 1that containes the CSC column offsets.cscRowInd: Integer array of sizennzthat containes the CSC row indices.valType: Value type for both CSR and CSC matrices.copyValues:cusparseAction_t::CUSPARSE_ACTION_SYMBOLICorcusparseAction_t::CUSPARSE_ACTION_NUMERIC.idxBase: Index basecusparseIndexBase_t::CUSPARSE_INDEX_BASE_ZEROorcusparseIndexBase_t::CUSPARSE_INDEX_BASE_ONE.alg: Algorithm implementation. seecusparseCsr2CscAlg_tfor possible values.buffer: Pointer to workspace buffer.