title: cuSparse vs. cuBlas triangular solvers
body: <p>Actually I posted a relevant question a few days ago, but I got zeros answers, however, I came to a very strange finding yesterday, as  mentioned in my previous question: <a href="https://stackoverflow.com/q/11382346/1501149">Very slow performance of cusparse csrsv_analysis</a>, the analysis phase of the sparse triangular solver of cusparse is annoyingly slow, not to mention it's sometimes unnecessary when the coefficients matrix sparsity pattern doesn't allow parallelization, so I wanted to see how cublas dense triangular solver would handle that, so I replaced the cusparse solver with a cublas solver after converting my coefficients matrix to dense format, and the cublas verions was ~7x faster than the cusparse version given the same matrix and even after including the matrix format conversion time in CuBlas solver ! I revised the solution so it's correct in both cases !</p>
  
  <p><strong>CuSparse version</strong></p>
  
  <pre><code>// Analysis phase   
  cusparseStatus = cusparseDcsrsv_analysis(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE, N, NZ, descrL, matrixLU, iRow, jCol, inforL) ;
  if(cusparseStatus != CUSPARSE_STATUS_SUCCESS) printf("%s \n\n","cusparseDcsrsv_analysis1 Error !") ;
  cusparseStatus = cusparseDcsrsv_analysis(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE, N, NZ, descrU, matrixLU, iRow, jCol, inforU) ;
  if(cusparseStatus != CUSPARSE_STATUS_SUCCESS) printf("%s \n\n","cusparseDcsrsv_analysis2 Error !") ;
  
  // Solve phase  
  cusparseStatus = cusparseDcsrsv_solve(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE, N, &amp;c2, descrL, matrixLU, iRow, jCol, inforL, r, t) ;
  if(cusparseStatus != CUSPARSE_STATUS_SUCCESS) printf("%s \n\n","cusparseDcsrsv_solve1 Error !") ;
  cusparseStatus = cusparseDcsrsv_solve(cusparseHandle, CUSPARSE_OPERATION_NON_TRANSPOSE, N, &amp;c2, descrU, matrixLU, iRow, jCol, inforU, t, z) ;
  if(cusparseStatus != CUSPARSE_STATUS_SUCCESS) printf("%s \n\n","cusparseDcsrsv_solve2 Error !") ;
  </code></pre>
  
  <p><strong>CuBlas version</strong></p>
  
  <pre><code>// CSR to dense conversion
  cusparseStatus = cusparseDcsr2dense(cusparseHandle, N, N, descrLU, matrixLU, iRow, jCol, aLU, N) ; 
  if(cusparseStatus != CUSPARSE_STATUS_SUCCESS) printf("%s \n\n","cusparseDcsr2dense1 Error !") ;
  
  // Solving directly
  cublasStatus = cublasDtrsv(cublasHandle, CUBLAS_FILL_MODE_LOWER, CUBLAS_OP_N, CUBLAS_DIAG_UNIT, N, aLU, N, z, 1) ;
  if(cublasStatus != CUBLAS_STATUS_SUCCESS) printf("%s \n\n","cublasSolve1 Error !") ;
  cublasStatus = cublasDtrsv(cublasHandle, CUBLAS_FILL_MODE_UPPER, CUBLAS_OP_N, CUBLAS_DIAG_NON_UNIT, N, aLU, N, z, 1) ;
  if(cublasStatus != CUBLAS_STATUS_SUCCESS) printf("%s \n\n","cublasSolve2 Error !") ;
  </code></pre>
  
  <p>Test case:</p>
  
  <ul>
  <li>Size (N) = <strong>5000 * 5000</strong></li>
  <li>Number of non zeros (NZ) = <strong>35,000</strong></li>
  <li>Number of iterations: <strong>3</strong></li>
  <li>CuSparse solution time, analysis phase executed once: <strong>180 ms</strong></li>
  <li>CuBlas solution time: <strong>30 ms</strong></li>
  <li>GPU: <strong>GeForce GTX 550 Ti</strong></li>
  <li>OS: <strong>Windows 7 ultimate, 64 bit</strong></li>
  </ul>
  
  <p>Of course, using CuBlas is impractical for me, since my work involves large dimensions matrices, starting from 100,000 and even reaching 1,000,000, and so, memory allocation of such sizes is simply impractical, so is there a way to start the sparse solver without the analysis phase ?</p>