cuda - Converting a dense matrix to sparse CSR format with cuSPARSE -
i want use scsrmv cusparse function.
reading documentation here, can't figure how define csrrowptra , csrcolinda:
csrrowptra : integer array of m+1 elements contains start of every row , end of last row plus one.
csrcolinda : integer array of nnz ( = csrrowptra(m) - csrrowptra(0) ) column indices of nonzero elements of matrix a.
so , example:
float *devrow; cudamalloc((void **)&devrow, (m+1)*sizeof(float)); and if a matrix, then:
for (int i=0; i<m; i+= n) //m rows , n columns devrow[i] = a[i]; this start of every row. last row , plus 1? confused me.
and columns? like:
for (int i=0;i<nnz;i++) devcol = devrow[m] - devrow[0];
you can convert dense matrix sparse code write yourself. csr (compressed-sparse-row) formulation, use cusparse function this.
the general format of csr sparse matrix representation documented in many places, including cusparse manual.
Comments
Post a Comment