taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.49k stars 2.28k forks source link

Support sparse matrix and sparse linear solvers #2906

Closed FantasyVR closed 1 year ago

FantasyVR commented 3 years ago

Concisely describe the proposed feature Many problems in computer graphics (especially physical simulation) need to solve sparse linear systems. While some of these problems can be addressed using matrix-free solvers (e.g., conjugate gradients), many need explicitly constructing a sparse matrix, in standard formats such as CSR and COO.

Currently, Taichi does not have first-class support for these matrices. Note that the sparse computation system in Taichi is designed for spatial sparsity instead of matrix sparsity.

Describe the solution you'd like (if any)

Unify CPU and GPU API

mzy2240 commented 3 years ago

Will you consider supporting sparse matrix solver like Suitesparse?

zishengye commented 3 years ago

Will you consider an inclusion of some engineering level packages like PETSc and Trilinos. These packages not only support different types of matrix formats but also a lot of preconditioners.

FantasyVR commented 3 years ago

Will you consider supporting sparse matrix solvers like Suitesparse?

@mzy2240 Thanks for your suggestion. We just wrap Eigen for now. SuiteSparse is in our plan. If you have interest,
Welcome to join us and support more features.

FantasyVR commented 3 years ago

Will you consider the inclusion of some engineering level packages like PETSc and Trilinos. These packages not only support different types of matrix formats but also a lot of preconditioners.

Our plan is to design a general sparse linear system solver. But now, we intend to implement a basic and useable version based on Eigen. More packages like SuitSparse, Pardiso, CuSolver et al. are in our plan. And we welcome you to join us during the process.

zishengye commented 3 years ago

Maybe KokkosKernel could help your work.

mzy2240 commented 2 years ago

Do you consider supporting conversion from and to scipy.sparse matrix? Scipy is probably the most used library when dealing with sparse matrix in python.

Hanke98 commented 2 years ago

Hi, there! I am now working on implementing the basic operation operations such as +, -, *, @, etc. on GPU. However, I found that the + and - operations are not common cases according to this post.

Is it OK to use cuSparse Routine csrgeam, which performs C=α∗A+β∗B, to implement the + operation?

FantasyVR commented 2 years ago

Hi @Hanke98. Exactly. I thinkcsrgeam could be used to implement +, -, scalar *. I just implemented a not finished one. It could be as a reference.