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

Improve matrix_assembly_data performance #1754

Open
upsj opened this issue Dec 12, 2024 · 2 comments
Open

Improve matrix_assembly_data performance #1754

upsj opened this issue Dec 12, 2024 · 2 comments
Labels
is:idea Just a thought - if it's good, it could evolve into a proposal.

Comments

@upsj
Copy link
Member

upsj commented Dec 12, 2024

We could make the performance of matrix_assembly_data much better by building a row-wise flat hash map ourselves. For that we only need an upper bound for the number of columns for each row (either individual or a global upper bound). The access could be implemented in a thread-safe fashion (atomicCAS on the column indices, atomicAdd on the values) or single-threaded fashion (non-atomic access to the column indices)
If we wanted to build an unbounded hash map, we could collect elements exceeding the size bounds in a global "overflow" hash map, but that would probably be harder to do in a thread-safe fashion.

@MarcelKoch
Copy link
Member

I think Dune has some interesting ideas on how to assemble matrices. Here is the documentation of their approaches: https://dune-project.org/doxygen/2.10.0/classDune_1_1BCRSMatrix.html#details

@MarcelKoch MarcelKoch added the is:idea Just a thought - if it's good, it could evolve into a proposal. label Dec 12, 2024
@upsj
Copy link
Member Author

upsj commented Dec 14, 2024

I believe we might be talking about different concepts of matrix assembly here. The documentation you attached seems to be focused more on assembling the sparsity pattern (with the values being set once, no duplicates), while our concept is more about collecting values (with multiple values being added together). Once the sparsity pattern is assembled, we can use something like csr_lookup or a matrix representation of the sum_duplicates operation to implement the actual assembly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:idea Just a thought - if it's good, it could evolve into a proposal.
Projects
None yet
Development

No branches or pull requests

2 participants