I have a large non-symmetric sparse matrix A and I want to solve the system A * x = b for some given right-hand side b. CuSPARSE only has triangular solvers and so I figured out that I have to take the following steps:

- Decompose A into A = LU with cusparseDcsrilu0
- Solve the system L * y = b for y with cusparseDcsrsv_solve
- Solve the system U * x = y for x with cusparseDcsrsv_solve

Analytically, we would now have L * (U * x) = b = A * x, since A = LU. However, the answer for x that CuSPARSE produces does not satisfy A * x = b. After some digging, I found that the answer does indeed satisfy L * (U * x) = b, but L*U = A **only in the sparse sense**, i.e. LU = A in all entries where A is non-zero, but LU has some additional non-zero entries. Thus LU != A in the dense sense, and so the solution I get from solving L * (U * x) = b does not satisfy A * x = b.

I think this may be the fill-in problem Iâ€™ve read about. How do I fix this? How can I solve the system A * x = b with CuSPARSE when A can by any sparse matrix?

Is there perhaps some way to extend the sparsity pattern of A (i.e. include some 0 entries in the sparsity pattern) to avoid the fill-in problem? Note that I need to solve A * x = b for many different Aâ€™s, but they all have the same sparsity pattern. So it would be ok if the step of extending the sparsity pattern is expensive, because it would only have to be done once and could be reused.

Thanks for the help.