# Problem using cusparseScsric0 function

**URL:** <https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213>\
**Category:** GPU-Accelerated Libraries\
**Created:** [November 6, 2012, 8:23pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213 "2012-11-06T20:23:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aflavia](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Aflavia](https://forums.developer.nvidia.com/u/Aflavia)\
**Post date:** [November 6, 2012, 8:23pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/1 "2012-11-06T20:23:54Z")

</div>

Hi, my name is Ana.

I have been used function in the NVIDIA library: Cusparse and Cublas. I have been implemented in my program the conjugate gradient method using these functions. Thus, it´s worked very well!

However, when I used Cholesky preconditioned and CG iterative methods, in another case, one problem occurred with cusparseScsric0 function. I am using matrix from The University of Florida (Sparse Matrix Collection), website: [http://www.cise.ufl.edu/research/sparse/matrices/](http://www.cise.ufl.edu/research/sparse/matrices/) in my algorithms with symmetric positive definite linear systems (FIDAP/ex5).

Thus, I have two questions:

1 – Incomplete Cholesky factorization could be: op(A)aproximately R R^T? I read from Matrix Computation´s book (Golub & Van Loan, 2rd Ed., section 10.3.2, pg. 530) about this function.

2 - In the manual “Cuda\_cusparse” there is an information about the cusparseScsric0. The function is defined Hermitian/symmetric positive definite sparse matrix (CSR storage format by the three arrays csrValM, csrRowPtrA and csrColIndA). I didn’t understand the supported matrix type: CUSPARSE\_MATRIX\_TYPE\_GENERAL, because only a lower or upper Hermitian/symmetric part of the matrix is actually stored. I used lower or upper or general matrix and I did none result. The results in all the simulations were: CUSPARSE\_STATUS\_MATRIX\_TYPE\_NOT\_SUPPORTED.

Please, I need your help!

---

<div class="post-metadata">

**Author:** ![philippev](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/philippev/32/9748_2.png) [@philippev](https://forums.developer.nvidia.com/u/philippev)\
**Post date:** [November 7, 2012, 6:17pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/2 "2012-11-07T18:17:19Z")

</div>

Answer to 2:  
You need to set the Matrix type to CUSPARSE\_MATRIX\_TYPE\_SYMMETRIC ( or CUSPARSE\_MATRIX\_TYPE\_HERMITIAN)  
using the routine cusparseSetMatType( cusparseMatDescr\_t descrA, cusparseMatrixType\_t )

---

<div class="post-metadata">

**Author:** ![Aflavia](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Aflavia](https://forums.developer.nvidia.com/u/Aflavia)\
**Post date:** [November 7, 2012, 8:25pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/3 "2012-11-07T20:25:32Z")

</div>

Thank you Philip!!!

I set the parameters as below:

```
cusparseMatDescr_t descrA = 0;
cusparseStatus = cusparseCreateMatDescr(&descrA); 
cusparseSetMatType(descrA,CUSPARSE_MATRIX_TYPE_SYMMETRIC);
cusparseSetMatIndexBase(descrA,CUSPARSE_INDEX_BASE_ZERO);

```

In this case, only the main diagonal was calculted!

Do you also defined cusparseSetMatFillMode ? When I define the matrix A as UPPER type, for example, some values were determined incorrectly!

Thanks again!!!

---

<div class="post-metadata">

**Author:** ![philippev](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/philippev/32/9748_2.png) [@philippev](https://forums.developer.nvidia.com/u/philippev)\
**Post date:** [November 8, 2012, 12:19am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/4 "2012-11-08T00:19:14Z")

</div>

Most of the matrices of the University of Florida are in base 1 ( Fortran legacy )

Could you try :  
cusparseSetMatIndexBase(descrA,CUSPARSE\_INDEX\_BASE\_ONE);

For the fillMode, usually they are in LOWER type. But you can easily look into the matrix file to see if it is an UPPER or a LOWER.

---

<div class="post-metadata">

**Author:** ![Aflavia](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Aflavia](https://forums.developer.nvidia.com/u/Aflavia)\
**Post date:** [November 8, 2012, 4:04pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/5 "2012-11-08T16:04:42Z")

</div>

Thank you Philip!!!

Another question:

I’m in trouble with the csric0 function!!!

I think there must be a failure on the data structur!!!

CG works very well! But, PCG (cholesky) not converge!!!

I used a small matrix (University Florida - s.p.d.) to check the values. I stored UPPER part of the matrix A for cholesky method. In this case, some values the output function were calculated incorrectly, when I aplly: cusparseScsric0. Some results were: #QNAN0!

Did you use this function correctly?

Thanks, Ana.

---

<div class="post-metadata">

**Author:** ![lchien](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@lchien](https://forums.developer.nvidia.com/u/lchien)\
**Post date:** [November 9, 2012, 1:44am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/6 "2012-11-09T01:44:55Z")

</div>

Could you please show part of your code?  
The matrix is base 1 and lower triangle, but you can use csr2coo to have a upper triangle one.

---

<div class="post-metadata">

**Author:** ![Seltymar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Seltymar](https://forums.developer.nvidia.com/u/Seltymar)\
**Post date:** [November 9, 2012, 2:11am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/7 "2012-11-09T02:11:55Z")

</div>

Hi,

Same things for me. I tried with a symmetric matrix where I store only the upper side. The base index is 0 (I made it myself). Some values are indefinite after using csric0.  
There is something strange: I store the upper side of the matrix but if I say in the descriptor that the matrix is lower I don’t have anymore indefinite value. Both cases, the PCG does not converge.

EDIT: Actualy, if I put in the descriptor that the matrix is lower instead of upper, it returns me exactly the same matrix.  
I guess, there is a problem when I use csric0 for the upper side matrix.

---

<div class="post-metadata">

**Author:** ![lchien](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@lchien](https://forums.developer.nvidia.com/u/lchien)\
**Post date:** [November 12, 2012, 8:02pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/8 "2012-11-12T20:02:53Z")

</div>

Seltymar, could you show your code? Otherwise it is not easy to find the root cause.

---

<div class="post-metadata">

**Author:** ![Seltymar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Seltymar](https://forums.developer.nvidia.com/u/Seltymar)\
**Post date:** [November 13, 2012, 2:20am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/9 "2012-11-13T02:20:02Z")

</div>

This is the code used to compute the incomplete cholesky.  
The matrix is composed of dev\_valR, dev\_row\_ptrR and dev\_colIndR which correspond to the CSR matrix. I tested the matrix on a PCG using a Jacobi preconditioner. It is slow but works.  
Also, it happens often that using cusparseScsrsv\_analysis and cusparseScsric0 makes the cusparseScsrsv\_analysis fail with the code error 6: execution failed and the cusparseScsric0 has the error 7: internal error.

```auto
int N = width*height;

/* Get handle to the CUBLAS context */
    cublasHandle_t cublasHandle = 0;
    cublasStatus_t cublasStatus;
    cublasStatus = cublasCreate(&cublasHandle);
    if(cublasStatus != CUBLAS_STATUS_SUCCESS)
        fprintf(stderr, "cublasCreate returned error code %d !
", cublasStatus);

    /* Get handle to the CUSPARSE context */
    cusparseHandle_t cusparseHandle = 0;
    cusparseStatus_t cusparseStatus;
    cusparseStatus = cusparseCreate(&cusparseHandle);
    if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
        fprintf(stderr, "cusparseCreate returned error code %d !
", cusparseStatus);

    cusparseMatDescr_t descrR = 0;
    cusparseStatus = cusparseCreateMatDescr(&descrR);
    if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
        fprintf(stderr, "cusparseCreateMatDescr returned error code %d !
", cusparseStatus);

    cusparseSetMatFillMode(descrR,CUSPARSE_FILL_MODE_UPPER);
    cusparseSetMatType(descrR,CUSPARSE_MATRIX_TYPE_SYMMETRIC);
    cusparseSetMatIndexBase(descrR,CUSPARSE_INDEX_BASE_ZERO);

    // create the analysis info object for the R matrix 
    cusparseSolveAnalysisInfo_t infoR = 0;
    cusparseStatus = cusparseCreateSolveAnalysisInfo(&infoR);
    if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
        fprintf(stderr, "cusparseCreateSolveAnalysisInfo returned error code %d !
", cusparseStatus);
	
	
    cusparseStatus = cusparseScsrsv_analysis(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE, N, nnz_Symmetric, descrR, dev_valR, dev_row_ptrR, dev_colIndR, infoR);
    if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
        fprintf(stderr, "cusparseScsrsv_analysis returned error code %d !
", cusparseStatus);
	
	
    // generate the Incomplete Cholesky factor H for the matrix R using cusparseScsric0 
    cusparseStatus = cusparseScsric0(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE, N, descrR, dev_valR, dev_row_ptrR, dev_colIndR, infoR);
    if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
        fprintf(stderr, "cusparseScsric0 returned error code %d !
", cusparseStatus);

```

---

<div class="post-metadata">

**Author:** ![lchien](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@lchien](https://forums.developer.nvidia.com/u/lchien)\
**Post date:** [November 13, 2012, 4:09am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/10 "2012-11-13T04:09:59Z")

</div>

The code looks fine.  
If csrsv\_analysis failed, either csr format is wrong or there exists some bug.  
If (dev\_rowPtrR, dev\_colIndR, dev\_valR) is indeed upper triangular matrix of dimension NxN, nnz\_Symmetric nonzero entries, we need to take a look on the matrix.  
Could you please file a bug?  
(If you are not a registered developer, please sign up, then file a bug.)

---

<div class="post-metadata">

**Author:** ![Seltymar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Seltymar](https://forums.developer.nvidia.com/u/Seltymar)\
**Post date:** [November 13, 2012, 7:39am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/11 "2012-11-13T07:39:46Z")

</div>

As the cusparse function was correct, I focused and checked again my matrix and I fixed a bug so now the incomplete cholesky looks correct (no more indefinite values).  
Also, in the documentation it is written that the dev\_rowPtrR has m+1 which contains the beginning of all row and the end of the last one+1. My pointer contained only the beginning of each row, I changed it to have the last element.  
But I still have some problem with my residual. I will check it again.  
This is the rest of the conjugate gradient (I didn’t follow exactly what Maxim Naumov did):

```auto
// create the info and analyse the lower and upper triangular factors
cusparseSolveAnalysisInfo_t inforRt = 0;
cusparseSolveAnalysisInfo_t inforR = 0;
cusparseCreateSolveAnalysisInfo(&inforRt ) ;
cusparseCreateSolveAnalysisInfo(&inforR ) ;
cusparseStatus=cusparseScsrsv_analysis(cusparseHandle , CUSPARSE_OPERATION_TRANSPOSE ,N , nnz_Symmetric, descrR , dev_valR , dev_row_ptrR , dev_colIndR , inforRt);
if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
    fprintf(stderr, "cusparseScsrsv_analysis inforRt returned error code %d !", cusparseStatus);

cusparseStatus=cusparseScsrsv_analysis(cusparseHandle , CUSPARSE_OPERATION_NON_TRANSPOSE ,N , nnz_Symmetric, descrR , dev_valR , dev_row_ptrR , dev_colIndR , inforR);
if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
    fprintf(stderr, "cusparseScsrsv_analysis inforR returned error code %d !", cusparseStatus);
	
// Ax = A*x
cusparseStatus = cusparseScsrmv(cusparseHandle,CUSPARSE_OPERATION_NON_TRANSPOSE, N, N, nnz, &alpha, descr, dev_val, dev_row_ptr, dev_colInd, dev_alphaLaplacian, &beta, dev_Ax);

// r= r - Ax
cublasStatus = cublasSaxpy(cublasHandle, N, &alpham1, dev_Ax, 1, d_r, 1);

// z_{0} = C^{-1}*r_{0}
cusparseScsrsv_solve(cusparseHandle, CUSPARSE_OPERATION_TRANSPOSE , N, &alpha, descrR, dev_valR, dev_row_ptrR, dev_colIndR, inforRt, d_r, d_y);
cusparseScsrsv_solve(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE , N, &alpha, descrR, dev_valR, dev_row_ptrR, dev_colIndR, inforR, d_y, dev_z);

cublasStatus = cublasSdot(cublasHandle, N, d_r, 1, dev_z, 1, &r1);

k = 1;
	
printf("residual = %e", sqrt(r1));
	
while (r1 > tol*tol && k <= 20 )//max_iter)
{	
    if (k > 1) {
        //b_{i} = (r_{i+1}, z_{i+1}/(r_{i} , z_{i})
        b = r1 / r0;

        // p_{i+1}= z_{i+1} + b_{i}* p_{i} 
        cublasStatus = cublasSscal(cublasHandle, N, &b, dev_p, 1);

        cublasStatus = cublasSaxpy(cublasHandle, N, &alpha, dev_z, 1, dev_p, 1);
    } else {
        // p = z
        cublasStatus = cublasScopy(cublasHandle, N, dev_z, 1, dev_p, 1);
    }
		
    // Ax_{i} = A*p^{T}_{i}
    cusparseScsrmv(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE, N, N, nnz, &alpha, descr, dev_val, dev_row_ptr, dev_colInd, dev_p, &beta, dev_Ax);

     // Ax_{i} = p_{i}*Ax_{i}
     cublasStatus = cublasSdot(cublasHandle, N, dev_p, 1, dev_Ax, 1, &dot);

		
      //a = (r_{i} , z_{i})/(Ap_{i} , p_{i})
      a = r1 / dot;
		
      // x_{i+1}= x_{i} + a*p_{i}
      cublasStatus = cublasSaxpy(cublasHandle, N, &a, dev_p, 1, dev_alphaLaplacian, 1);

na = -a;

	// r_{i+1} = r_{i} - a *Ax_{i}
        cublasStatus = cublasSaxpy(cublasHandle, N, &na, dev_Ax, 1, d_r, 1);

        r0 = r1;

    // z_{i+1} = C^{-1}*r_{i+1}		
    cusparseScsrsv_solve(cusparseHandle, CUSPARSE_OPERATION_TRANSPOSE , N, &alpha, descrR, dev_valR, dev_row_ptrR, dev_colIndR,inforRt, d_r, d_y);
     cusparseScsrsv_solve(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE , N, &alpha, descrR, dev_valR, dev_row_ptrR, dev_colIndR, inforR, d_y, dev_z);
	
      // r1_{i+1} = r_{i+1} * z_{i+1}
      cublasStatus = cublasSdot(cublasHandle, N, d_r, 1, dev_z, 1, &r1);
        printf("iteration = %3d, residual = %e", k, sqrt(r1));	
	k++;		
}

```

The matrix (dev\_val, dev\_row\_ptr, dev\_colInd) is the same matrix than dev\_valR but containing all data. I will try the method of maxim Naumov, maybe it will resolve my problem.

EDIT:  
My residual r1 is \< 0, so I guess my matrix R is still not correct.

---

<div class="post-metadata">

**Author:** ![Aflavia](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Aflavia](https://forums.developer.nvidia.com/u/Aflavia)\
**Post date:** [November 13, 2012, 6:49pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/12 "2012-11-13T18:49:10Z")

</div>

Seltymar, I think that has one problem with: cusparseScsrsv\_solve and cusparseScsric0. My program not converged!!!

I resolved CG and its ok!

When aplly PCG not converged.  
I calculated incomplete cholesky separately (not use cusparseScsric0) and aplly cusparseScsrsv\_solve (preconditioner) function and not converged (same matrix resolved in CG). In this case, PCG, I added just cusparseScsrsv\_solve function. Thus, there is one problem!!!

When aplly cusparseScsric0 same things for me!!!

Ana.

---

<div class="post-metadata">

**Author:** ![Seltymar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Seltymar](https://forums.developer.nvidia.com/u/Seltymar)\
**Post date:** [November 14, 2012, 12:23am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/13 "2012-11-14T00:23:45Z")

</div>

Hi Ana,  
Do you still have indefinite value like #QNANO after using cusparseScsric0 ? I have correct values now (My matrix was incorrect but converged with PCG using a Jacobi preconditioner so it’s difficult to know what’s going wrong).

I will check my result after using cusparseScrsv\_solve and if I find nothing I will file a bug.

EDIT:

```auto
cusparseScsrsv_solve(cusparseHandle, CUSPARSE_OPERATION_TRANSPOSE , N, &alpha, descrR, dev_valR, dev_row_ptrR, dev_colIndR, inforRt, d_r, d_y);

```

The result of this function is not correct. I have wrong values in the output d\_y.

I applied to the CUDA developper program. I’m waiting to be accepted.

---

<div class="post-metadata">

**Author:** ![Aflavia](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Aflavia](https://forums.developer.nvidia.com/u/Aflavia)\
**Post date:** [November 14, 2012, 1:48pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/14 "2012-11-14T13:48:40Z")

</div>

Hi Seltymar,

When aplly cusparseScsric0, I found some values with: #QNANO.  
My matrix is small (27 x 27) and I have wrong values in the output this function.

Set:

cusparseSetMatIndexBase(descrA,CUSPARSE\_INDEX\_BASE\_ZERO);  
cusparseSetMatType(descrA,CUSPARSE\_MATRIX\_TYPE\_SYMMETRIC);  
cusparseSetMatFillMode(descrA,CUSPARSE\_FILL\_MODE\_UPPER);

Did you program converged, when used cusparseScsric0 whit CG?

, Ana.

---

<div class="post-metadata">

**Author:** ![Seltymar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Seltymar](https://forums.developer.nvidia.com/u/Seltymar)\
**Post date:** [November 15, 2012, 6:39am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/15 "2012-11-15T06:39:06Z")

</div>

I have correct values when using cusparseScsrcric0 but it does not converge.  
For me, the function cusparseScrsv\_solve does nothing. If I initialize my output vector to 5 for example, after using cusparseScrsv\_solve, it gives me 5.

I have same parameter for the matrix.

EDIT:  
I have filed a bug about cusparseScrsv\_solve.

EDIT 2:  
I’m not sure if it is interesting to use PCG with a incomplete Cholesky. The time for the analyze and to create the Cholesky matrix takes around the same time than a PCG using a Jacobi preconditioner which is fast to invert.  
To execute this

```auto
// z_{0} = C^{-1}*r_{0}

```

, I created a kernel function with CUDA and it’s quite fast. But of course, it depends how many iterations you CG does. I have around 150 iterations which is not so big.

---

<div class="post-metadata">

**Author:** ![Aflavia](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Aflavia](https://forums.developer.nvidia.com/u/Aflavia)\
**Post date:** [November 20, 2012, 12:00pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/16 "2012-11-20T12:00:54Z")

</div>

In my case, cusparseScsrcric0 function is with some wrong values.  
How did you used this function (parameter)? Did you change something in this function?

I configured:

cusparseSetMatIndexBase(descrA,CUSPARSE\_INDEX\_BASE\_ZERO);  
cusparseSetMatType(descrA,CUSPARSE\_MATRIX\_TYPE\_SYMMETRIC);  
cusparseSetMatFillMode(descrA,CUSPARSE\_FILL\_MODE\_UPPER);

I think that using cusparseSetMatFillMode like UPPER appears a problem. How did you used?

Thanks, Ana.

---

<div class="post-metadata">

**Author:** ![Seltymar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Seltymar](https://forums.developer.nvidia.com/u/Seltymar)\
**Post date:** [November 21, 2012, 12:17am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/17 "2012-11-21T00:17:39Z")

</div>

i have set parameters like this:

```auto
cusparseMatDescr_t descrR = 0;
cusparseStatus = cusparseCreateMatDescr(&descrR);
if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
    fprintf(stderr, "cusparseCreateMatDescr returned error code %d !
", cusparseStatus);

cusparseSetMatFillMode(descrR,CUSPARSE_FILL_MODE_UPPER);
cusparseSetMatType(descrR,CUSPARSE_MATRIX_TYPE_SYMMETRIC);
cusparseSetMatIndexBase(descrR,CUSPARSE_INDEX_BASE_ZERO);
 
// create the analysis info object for the R matrix 
cusparseSolveAnalysisInfo_t infoR = 0;
cusparseStatus = cusparseCreateSolveAnalysisInfo(&infoR);
if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
     fprintf(stderr, "cusparseCreateSolveAnalysisInfo returned error code %d !
", cusparseStatus);
	
cusparseStatus = cusparseScsrsv_analysis(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE, N, nnz_Symmetric, descrR, dev_valR, dev_row_ptrR, dev_colIndR, infoR);
if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
    fprintf(stderr, "cusparseScsrsv_analysis returned error code %d !
", cusparseStatus);
	
// generate the Incomplete Cholesky factor H for the matrix R using cusparseScsric0 
cusparseStatus = cusparseScsric0(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE, N, descrR, dev_valR, dev_row_ptrR, dev_colIndR, infoR);
if(cusparseStatus!=CUSPARSE_STATUS_SUCCESS)
    fprintf(stderr, "cusparseScsric0 returned error code %d !
", cusparseStatus);

```

the matrix R (csr format: dev\_valR, dev\_row\_ptrR, dev\_colIndR) is size N with nnz\_Symmetric non zero elements. The matrix R is upper side of the symmetric matrix.

---

<div class="post-metadata">

**Author:** ![Aflavia](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Aflavia](https://forums.developer.nvidia.com/u/Aflavia)\
**Post date:** [November 22, 2012, 12:45pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/18 "2012-11-22T12:45:07Z")

</div>

Its like my parameters, except dev\_row\_ptrR array where I put (N+1) values. Did your array is N?

How did you set nnz\_Symmetric? Its just UPPER ou full symmetric matrix.

Your matrix is small? I´m testing 27 x 27 matrix with few nonzeros values.

cusparseSolveAnalysisInfo\_t infoA = 0;  
cusparseStatus = cusparseCreateSolveAnalysisInfo(&infoA);

cusparseMatDescr\_t descrA = 0;  
cusparseStatus = cusparseCreateMatDescr(&descrA);  
cusparseSetMatIndexBase(descrA,CUSPARSE\_INDEX\_BASE\_ZERO);  
cusparseSetMatType(descrA,CUSPARSE\_MATRIX\_TYPE\_SYMMETRIC);  
cusparseSetMatFillMode(descrA,CUSPARSE\_FILL\_MODE\_UPPER);

cusparseStatus = cusparseScsrsv\_analysis(cusparseHandle, CUSPARSE\_OPERATION\_NON\_TRANSPOSE, M, nnz, descrA, d\_ValAICP, d\_csrRowPtrA, d\_cooColIndA, infoA);  
if ( checkCusparseStatus (cusparseStatus, (char\*)“cusparseScsrv\_analysis” ) ) return EXIT\_FAILURE;

cusparseStatus = cusparseScsric0(cusparseHandle, CUSPARSE\_OPERATION\_NON\_TRANSPOSE, M, descrA, d\_ValAICP, d\_csrRowPtrA, d\_cooColIndA, infoA);  
if ( checkCusparseStatus (cusparseStatus, (char\*)“cusparseScsric0” ) ) return EXIT\_FAILURE;

Thanks, Ana.

---

<div class="post-metadata">

**Author:** ![Seltymar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Seltymar](https://forums.developer.nvidia.com/u/Seltymar)\
**Post date:** [November 26, 2012, 12:41am UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/19 "2012-11-26T00:41:05Z")

</div>

I have (N+1) values for the dev\_roz\_ptrR.

nnz\_Symmetric is the number of non-zero values only for the upper side.

I have test it with several matrices but they are all big, several millions of nonzeros values.

I have the same code than you, if nnz is the number of nonzeros values only for the upper side.

Maybe if you can give me your input data I can try myself.

---

<div class="post-metadata">

**Author:** ![Aflavia](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Aflavia](https://forums.developer.nvidia.com/u/Aflavia)\
**Post date:** [November 26, 2012, 4:39pm UTC](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213/20 "2012-11-26T16:39:05Z")

</div>

Seltymar,

The matrix that I´m using: [FIDAP/ex5 sparse matrix](http://www.cise.ufl.edu/research/sparse/matrices/FIDAP/ex5.html)

I inverted rows and columns to obtain UPPER side.

Thanks, I await your response!!!

Ana.

[Next page](https://forums.developer.nvidia.com/t/problem-using-cusparsescsric0-function/27213.md?page=2)
