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

[LinearAlgebra] Refactor sparse matrix product #4547

Merged
merged 5 commits into from
Mar 16, 2024

Conversation

alxbilger
Copy link
Contributor

@alxbilger alxbilger commented Feb 29, 2024

  1. All types of Eigen::SparseMatrix are now supported. For that, the implementation relies completely on the Eigen matrix product to compute the intersection. The trick is to flag the non-zero values with its index position in the array. The matrix product will implicitly keep track of all the operations thanks to the newly introduced scalar types.
  2. Because of the new method, SparseMatrixStorageOrder is no longer useful. It can be removed later
  3. Unit tests are extensive. They test all possible configuration of storage of LHS, RHS and Result. They are required because a condition on the storage type is required to swap the indices after the matrix product.
  4. A parallel version of the algorithm is introduced
  5. Benchmarks: Benchmark of the new sparse matrix product alxbilger/SofaBenchmark#39

Analysis of the results of the benchmarks:

  • The best configuration storage for the fast matrix product seems to be ColColCol
  • The fast matrix product is always faster than the regular product, except for a matrix of size 1000 and sparsity of 15%. This probably indicates that the method is adapted for very sparse matrices
  • The parallel fast matrix product algorithm is always faster than the sequential algorithm, except for very small matrices where the overhead of parallelism is not negligible. However, the speed up is not linear with the number of cores and can be disappointing.
  • The parallel fast matrix product is always faster than the regular product even for the matrix of size 1000 and sparsity of 15%, but not for very small matrices (overhead).

By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@alxbilger alxbilger added pr: status to review To notify reviewers to review this pull-request refactoring Refactor code labels Feb 29, 2024
@alxbilger
Copy link
Contributor Author

[ci-build][with-all-tests]

@alxbilger
Copy link
Contributor Author

Formatted spreadsheet of the benchmark result
sparsematrixproductBenchmark.ods

@alxbilger alxbilger added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Mar 15, 2024
@fredroy fredroy merged commit 1e50c10 into sofa-framework:master Mar 16, 2024
11 checks passed
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@alxbilger is there a sense to keep this empty file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

File removed in #4599

bakpaul pushed a commit to bakpaul/sofa that referenced this pull request Mar 21, 2024
* [LinearAlgebra] Refactor sparse matrix product

* Move tests as a template test

* Fix all combinations of storage

* Introduce parallel computation

* Manage options for more types
@bakpaul bakpaul added this to the v24.06 milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: status ready Approved a pull-request, ready to be squashed refactoring Refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants