cusparseCsr2cscEx2_buffersize huge buffersize

I am trying to use Cusparse as below but the buffer is requiring 22 TB memory regardless of matrix size. I would appreciate it if you can comment. I didn’t find any specific remedy on documents.


! Creating the descriptor for the sparse matrix Bbar
istat = cusparseCreate(h_Bbar)
istat = cusparseCreateMatDescr(descr_Bbar)
istat = cusparseSetMatType(descr_Bbar,CUSPARSE_MATRIX_TYPE_GENERAL)
istat = cusparseSetMatIndexBase(descr_Bbar,CUSPARSE_INDEX_BASE_ONE)

#if CUDA_VERSION >= 11000
istat = cusparseCreateCsr(spMatDescr_Bbar,ntsx3,ntbx3,nnz_Bbar,B_RowPtr_d,B_ColInd_d,B_Val_d,CUSPARSE_INDEX_32I,&
CUSPARSE_INDEX_32I,CUSPARSE_INDEX_BASE_ONE,CUDA_R_64F)
if (istat /= CUSPARSE_STATUS_SUCCESS) print’(" cusparseCreateCsr Error : ",i)’,istat
#endif

! Specifying the buffer size for csr2csc for Bbar and also performing the conversion

#if CUDA_VERSION >= 11000
! Specifying the buffer size
istat = cusparseCsr2cscEx2_buffersize(h_Bbar,ntsx3,ntbx3,nnz_Bbar,Bbar_Val_d,Bbar_RowPtr_d,Bbar_ColInd_d,&
Bbar_Val_tr_d,Bbar_ColPtr_d,Bbar_RowInd_d,CUDA_R_64F,CUSPARSE_ACTION_NUMERIC,CUSPARSE_INDEX_BASE_ONE,&
CUSPARSE_CSRMV_ALG2,bsize)
print’(" cusparseCsr2cscEx2 buffersize required in init_conv: ",i)’,bsize
if (bsize > 0) allocate(buffer(bsize))

! Performing the csr2csc conversion
istat = cusparseCsr2cscEx2(h_Bbar,ntsx3,ntbx3,nnz_Bbar,Bbar_Val_d,Bbar_RowPtr_d,Bbar_ColInd_d,&
  Bbar_Val_tr_d,Bbar_ColPtr_d,Bbar_RowInd_d,CUDA_R_64F,CUSPARSE_ACTION_NUMERIC,CUSPARSE_INDEX_BASE_ONE,&
  CUSPARSE_CSRMV_ALG2,buffer)
if (istat /= CUSPARSE_STATUS_SUCCESS) print'(" cusparseCsr2cscEx2 Error : ",i)',istat

Can you please provide the full code and the sizes of the input matrix (rows, columns, nnz)?

sure!

So, it is a Molecular dynamics, Brownian dynamics simulation code.
the simple form of B(nm) matrix is in form of
B=|-1 1 0 0 0 …|
|0 -1 1 0 0 …|

and vectors are (n
1) dimensional.
n depends on the system of interest that we want to do the simulation for it.

The code uses CUSPARSE_CSRMV_ALG2 instead of CUSPARSE_CSR2CSC_ALG1 or `CUSPARSE_CSR2CSC_ALG2. This leaves the buffer size to an undefined value

Oh, Right. Thank you very much. I fixed it.
But now a question, what does bsize=0 mean? should it be always >0?
In the example “/examples/CUDA-Libraries/cuSPARSE/test_sparse_cuf/tcusparsemv1.cuf” buffer is allocated if bzise>0.
if it is bsize=0, the istat = cusparseCsr2cscEx2( …) returns istat=3 error.

Does it has to do with :