You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Best practice: threaded sparse matrix assembly #71
Package version 2.1 fixed an allocation issue and introduced a Base.sum method for ExtendabelSparse matrices. See several modified versions of your MWE in this gist, and the corresponding comments.
Multithreaded performance is tricky and so far I see a significant gain only if assembly per item is expensive. There probably is a way to speed up the reduction by directly creating new columns from all matrices at once, but this is quite hard to realize if one cannot avoid that different submatrices can add to the same entry, as it essentially happens with finite element assembly.
Would it be worth to extend if I extend the MWE to a 2D case, like a 9-point stencil?
I think it could be more representative of actual work in a production code. Maybe we better appreciate a speed up with such example? I could also throw a heavy function evaluation instead of 2 and -1.
Thank you for the proposal - good idea!
However, there are the parallel test examples in tests, they could be used to create benchmarks which are closer to the way things are used in FEM assembly. In particular, they use grid partitioning and partition graph coloring such that write conflicts during assembly are prevented.
Up to now I didn't find the time to make them proper benchmarks.
OK, I see, thank you. I was proposing this because I used FD in a project. But, yes, FEM-like assemblies are more general and parallel performance on such assemblies is of more general interest.
Activity
j-fu commentedon Jun 5, 2026
The MWE has two issues:
threadid()to address thread local data is no longer recommendedI will come up with an alternaive MWE later.
tduretz commentedon Jun 5, 2026
Thanks! I am adding the MWE here for this page to be self-contained:
j-fu commentedon Jun 6, 2026
Package version 2.1 fixed an allocation issue and introduced a Base.sum method for ExtendabelSparse matrices. See several modified versions of your MWE in this gist, and the corresponding comments.
Multithreaded performance is tricky and so far I see a significant gain only if assembly per item is expensive. There probably is a way to speed up the reduction by directly creating new columns from all matrices at once, but this is quite hard to realize if one cannot avoid that different submatrices can add to the same entry, as it essentially happens with finite element assembly.
tduretz commentedon Jun 7, 2026
Would it be worth to extend if I extend the MWE to a 2D case, like a 9-point stencil?
I think it could be more representative of actual work in a production code. Maybe we better appreciate a speed up with such example? I could also throw a heavy function evaluation instead of
2and-1.j-fu commentedon Jun 9, 2026
Thank you for the proposal - good idea!
However, there are the parallel test examples in
tests, they could be used to create benchmarks which are closer to the way things are used in FEM assembly. In particular, they use grid partitioning and partition graph coloring such that write conflicts during assembly are prevented.Up to now I didn't find the time to make them proper benchmarks.
tduretz commentedon Jun 22, 2026
OK, I see, thank you. I was proposing this because I used FD in a project. But, yes, FEM-like assemblies are more general and parallel performance on such assemblies is of more general interest.