Get wrong answers with cusparse csrgemm function, but only values are changed

Hi,

I was getting wrong answers with cusparse libraries.
Specifically, I was running the program downloaded from this github repo:


The original program can run fine. However, after I changed the initial values of matrix A, the answer becomes incorrect. The program generates incorrect result since the call to the "cusparseDdense2csr(handle, N, N, descrA, d_A_dense, lda, d_nnzPerVectorA, d_A, d_A_RowIndices, d_A_ColIndices) " function — the spasification from dense A to sparse A.

For example, the matrix A is:
[ 0, 104, 108, 0
0, 105, 109, 0
0, 106, 110, 0
1, 0, 0, 115]
After the cusparseDdense2csr call, the program outputs the non-zero values of A as:
A[0] = 105.000000 A[1] = 110.000000 A[2] = 115.000000 A[3] = 0.000000 A[4] = 0.000000 A[5] = 0.000000 A[6] = 0.000000 A[7] = 1.000000 A[8] = 108.000000 A[9] = 0.000000 A[10] = 0.000000 A[11] = 0.000000 A[12] = 104.000000

The zeros are unexpected.

I changed nothing but the initial values of matrix A in the original program. Actually, any other values different from the original program would cause wrong answer.

Do you what is causing this problem?
The program is attached. testsparse.cu.txt (12.0 KB)