cusparseDcsrsv2_solve "invalid value" error

I a trying to do an incomplete-LU factorization, I am doing my preconditioning in fortran ( L and U factors of the ILU(0) ). I am getting a strange quirk in my code where it sometimes throws an “invalid value” error in cusparseDcsrsv2_solve. I am having trouble thinking of a reason my code would sometimes work and other times through an error. Any suggestions will help.

void load_lusol_cusparse1(double* CSR_LU, int* CSR_I, int* CSR_J,
int N, int M)
{
printf("\n");
printf(" ### COMMENT from load_lusol_cusparse1 \n");
printf(" ### Starting GPU work \n");
// Setup cusparse.
cusparseCreate(&cusparseHandle);

// Set up L
cusparseCreateMatDescr (&L_described);
cusparseSetMatType (L_described,CUSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatIndexBase (L_described,CUSPARSE_INDEX_BASE_ONE);
cusparseSetMatFillMode (L_described,CUSPARSE_FILL_MODE_LOWER);
cusparseSetMatDiagType (L_described,CUSPARSE_DIAG_TYPE_UNIT);
cusparseStatus_t status = cusparseCreateCsrsv2Info(&L_analyzed);
printf(“Set up L = %s \n”,cusparseGetErrorString(status));

// Set up U
cusparseCreateMatDescr (&U_described);
cusparseSetMatType (U_described,CUSPARSE_MATRIX_TYPE_GENERAL);
cusparseSetMatIndexBase (U_described,CUSPARSE_INDEX_BASE_ONE);
cusparseSetMatFillMode (U_described,CUSPARSE_FILL_MODE_UPPER);
cusparseSetMatDiagType (U_described,CUSPARSE_DIAG_TYPE_NON_UNIT);
status = cusparseCreateCsrsv2Info(&U_analyzed);
printf(“Set up U = %s \n”,cusparseGetErrorString(status));

// Get algorithm buffer sizes
status = cusparseDcsrsv2_bufferSize(cusparseHandle,
CUSPARSE_OPERATION_NON_TRANSPOSE,
N, M, L_described, CSR_LU, CSR_I, CSR_J,
L_analyzed, &Lbuf_size);
printf(“Buffer L Create = %s \n”,cusparseGetErrorString(status));
status = cusparseDcsrsv2_bufferSize(cusparseHandle,
CUSPARSE_OPERATION_NON_TRANSPOSE,
N, M, U_described, CSR_LU, CSR_I, CSR_J,
U_analyzed, &Ubuf_size);
printf(“Buffer U Create = %s \n”,cusparseGetErrorString(status));
// Allocate buffers
cudaMalloc((void**)&Lbuffer, Lbuf_size);
cudaMalloc((void**)&Ubuffer, Ubuf_size);

//Analyze L
status = cusparseDcsrsv2_analysis(cusparseHandle,
CUSPARSE_OPERATION_NON_TRANSPOSE,
N, M, L_described, CSR_LU, CSR_I, CSR_J,
L_analyzed, CUSPARSE_SOLVE_POLICY_USE_LEVEL,
Lbuffer);
printf(“Analyze L = %s \n”,cusparseGetErrorString(status));

//Analyze U
status = cusparseDcsrsv2_analysis(cusparseHandle,
CUSPARSE_OPERATION_NON_TRANSPOSE,
N, M, U_described, CSR_LU, CSR_I, CSR_J,
U_analyzed, CUSPARSE_SOLVE_POLICY_USE_LEVEL,
Ubuffer);
printf(“Analyze U = %s \n”,cusparseGetErrorString(status));

cudaDeviceSynchronize();
}

void lusol_cusparse1(double* x, double* CSR_LU, int* CSR_I,
int* CSR_J, int N, int M)
{

// Forward solve (Lx=y)
cusparseStatus_t status = cusparseDcsrsv2_solve(cusparseHandle,
CUSPARSE_OPERATION_NON_TRANSPOSE,
N, M, &alpha, L_described, CSR_LU, CSR_I, CSR_J,
L_analyzed, x, x,
CUSPARSE_SOLVE_POLICY_USE_LEVEL, Lbuffer);
if (status!=-1){printf(“Forward Solve Error = %s \n”,cusparseGetErrorString(status));}

// Backward solve (Uy=x)
status= cusparseDcsrsv2_solve(cusparseHandle,
CUSPARSE_OPERATION_NON_TRANSPOSE,
N, M, &alpha, U_described, CSR_LU, CSR_I, CSR_J,
U_analyzed, x, x,
CUSPARSE_SOLVE_POLICY_USE_LEVEL, Ubuffer);
if (status!=0){printf(“Backward Solve Error = %s \n”,cusparseGetErrorString(status));}

cudaDeviceSynchronize();
}

  • Miko