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

Matrix assembly rework #1000

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Matrix assembly rework #1000

wants to merge 3 commits into from

Conversation

JordiManyer
Copy link
Member

@JordiManyer JordiManyer commented Apr 17, 2024

This relates to what we discussed. @amartinhuertas @fverdugo

A little context:

The current implementation of the sparse matrix assembly is (loosely) done as follows:

  • when first assembled, we assemble entries InserterCSC object, with a similar layout to SparseMatrixCSC.
  • when re-assembled, we assemble entries directly onto the sparse matrix.
    Both of these have the advantage of saving memory, but at the cost of doing sparse row/col index searches every time we assemble an entry.

We would like to investigate the option of working with COO-type structures. These are more expensive memory-wise, but can save quite a lot of time when re-assembling the matrix.

I've added a MWE on a possible implementation of the latter. Also, here are some results from the benchmarks at the end:

  • When first assembling: Both approaches take the same time, but COO has 3x the memory footprint.
  • When reassembling: COO is twice as fast than the current implementation.

@JordiManyer JordiManyer added the enhancement New feature or request label Apr 17, 2024
@JordiManyer JordiManyer added this to the v0.19 milestone Apr 17, 2024
@JordiManyer JordiManyer self-assigned this Apr 17, 2024
@oriolcg
Copy link
Member

oriolcg commented Jun 28, 2024

Hi @JordiManyer , what is the status of this PR? Have you tried the new implementation for Nonlinear/transient problems?

@JordiManyer
Copy link
Member Author

JordiManyer commented Jul 1, 2024

@oriolcg I don't have time atm, I'll try to push this further after the summer. I am not focusing complicated problems yet, but obviously anything that assembles repeatedly (like NL or transient) would benefit from this. I am worried about the memory footprint though... I think I can make most of it lazy so that we don't have to keep any Float values in memory, but it will take take some time to work it out.

Copy link

codecov bot commented Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.24%. Comparing base (9675711) to head (5486d72).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1000   +/-   ##
=======================================
  Coverage   88.23%   88.24%           
=======================================
  Files         179      179           
  Lines       22593    22593           
=======================================
+ Hits        19936    19937    +1     
+ Misses       2657     2656    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants