2

I currently solve Ax=b equation two times.

where A is sparse matrix NxN

x, b are vectors of size N. (I have b1 and b2)

I want to reduce times by solving both of them in one shot using cusparse functions.

so what I though is to build from the 2 b's I have, one matrix of size Nx2, and solve it with A as the equation AX=B can do.

  1. Is it theoretically right?
  2. which cusparse function should I use?

please pay attention I'm working with sparse matrix and not dense matrix.

Thanks!

Rotem.O
  • 93
  • 1
  • 11
  • 1
    cusolver may be useful. Take a look [here](http://docs.nvidia.com/cuda/cusolver/index.html#csrqr_batch_examples) and [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cusolversp-linear-solver-). – Robert Crovella Mar 02 '16 at 15:17
  • batch is not helpful here as it refers to the A matrix and not to the b vector. thanks anyway – Rotem.O Mar 03 '16 at 07:58

1 Answers1

1

To answer your questions

  1. Yes, it is possible to solve a suitably well conditioned sparse problem for multiple RHS vectors in this way.

  2. Unless your LHS sparse matrix is either tridiagonal or triangular, then you can't use cusparse directly for this.

    cusolver 7.5 contains several "low level" routines for factorising sparse matrices, meaning that you can factorize once and reuse the factorisation several times with different RHS, for example cusolverSpXcsrluSolve() can be called after an LU factorisation to solve using the same precomputed factorisation as many times as you require. (Note I originally had assumed that there was a sparse getrs like function in cusolve, and it appears there isn't. I certainly talked to NVIDIA about the use case for one some years ago and thought they had added it, sorry for the confusion there).

Community
  • 1
  • 1
talonmies
  • 70,661
  • 34
  • 192
  • 269
  • just to be sure I understood right - I need to have my LHS as triangular (or tridiagonal) to use cusparse. correct? also, getrs is for dense matrix - how does it fits here? thanks! – Rotem.O Mar 03 '16 at 07:59
  • @Rotem.O: Yes, cusparse doesn't actually have a solver in it, just sparse blas like operations. So there are back substitution routines for upper or lower triangular, or tridiagonal matrices, but not more than that. You can use another package like cusolver for factorization (ie. Cholesky or LU depending on your matrix). The getrs reference is a mistake. I plunged into the wrong part of the documentation looking for a function to do the multiple RHS solve. I'll update the answer when I get a chance – talonmies Mar 03 '16 at 10:05
  • Currently, `cusolverSpXcsrluSolve()` only provides the CPU path. As an alternative, one could use the solution at [Solving sparse linear systems in CUDA using LU factorization](http://stackoverflow.com/questions/17721987/solving-sparse-linear-systems-in-cuda-using-lu-factorization). – Vitality Jun 15 '16 at 20:04