Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lang] Support linear system solving on GPU with cuSolver #5860

Merged
merged 20 commits into from
Aug 31, 2022

Conversation

FantasyVR
Copy link
Collaborator

@FantasyVR FantasyVR commented Aug 23, 2022

Related issue = #2906

We implement a basic linear system solver according to cuSolverSp_LinearSolver.

The demo is shown in misc/test_coo_cusolver.py. To solve a linear system, you could follow the steps as below:

  1. Create three ti.ndarrays according to COO format, the datatype of row/column indices ndarray should be ti.i32 and the datatype of value ndarray should be ti.f32.
  2. Create a ti.linagl.SparseMatrix as A.
  3. Build the sparse matrix using build_coo function. The sparse matrix will be stored in CSR format.
  4. Create a ti.linalg.SparseSolver.
  5. Create two ti.ndarrray to store the right hand side b of linear system and the unkonw variables x.
  6. Solve the linear system A * x = b with solve_cu function.

@netlify
Copy link

netlify bot commented Aug 23, 2022

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit 777c5aa
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/630df34a965ad70009972e57
😎 Deploy Preview https://deploy-preview-5860--docsite-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@FantasyVR FantasyVR marked this pull request as ready for review August 24, 2022 06:47
Copy link
Contributor

@Hanke98 Hanke98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response! Just flew back from a conference today. I will do a more careful review tomorrow!

taichi/program/sparse_solver.cpp Outdated Show resolved Hide resolved
taichi/rhi/cuda/cusparse_functions.inc.h Show resolved Hide resolved
Copy link
Contributor

@Hanke98 Hanke98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! LGTM mostly! I only have few nits:

misc/test_coo_cusolver.py Outdated Show resolved Hide resolved
misc/test_coo_cusolver.py Show resolved Hide resolved
taichi/program/sparse_solver.cpp Show resolved Hide resolved
taichi/program/sparse_solver.cpp Show resolved Hide resolved
Copy link
Contributor

@Hanke98 Hanke98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@FantasyVR FantasyVR merged commit 005c9aa into taichi-dev:master Aug 31, 2022
@FantasyVR FantasyVR deleted the cu_solver branch November 23, 2022 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants