Skip to content

Implement CuSparseMatrix::set_element #137

@AlbanOdot

Description

@AlbanOdot

Hi!

I post here a feature request from the OG taichi repo since it is now moving so slow.

I would like to use setitem when dealing with sparse matrices on the GPU.
EigenSparseMatrix conveniently implements set_element but not CuSparseMatrix which make the code not portable.

One simple solution could be to implement a method very similar to CuSparseMatrix::get_element but that simply set the value instead of returning it.
I do understand that dynamic memory allocation on the GPU is trickier than what is achieved with Eigen but we could have a basic use case which improves current behavior while not adding much code complexity.
I can see 2 cases:

The value already exists 👍🏻. Just update the "CuSparseMatrix::value" array.
The value does not exist 👎🏻. Throw an error just like it does at the moment.
This easy to implement feature would greatly benefit the API and portability while adding coherence to SparseMatrix behavior.
Finally, this feature is highly needed when dealing with implicit simulations and Dirichlet boundary conditions. These conditions require to update the system matrix which API is usually quite straightforward.

If you have a workaround while this feature is developed, I would really appreciate it as this is totally blocking any advancement on my project.

As an answer to your question on the OG feature request:
You can use the already implemented solvers (cuda and eigen) with sparse matrices where you would have to develop them by hand without it. Which takes a lot of time to validate and will probably be never as good as the cuSparseSolver version.

Best regards,
AlbanOdot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions