Skip to content

[LinearSystem] Introduce ConstantSparsityProjectionMethod#4552

Merged
fredroy merged 7 commits intosofa-framework:masterfrom
alxbilger:constantsparsityprojection
Mar 18, 2024
Merged

[LinearSystem] Introduce ConstantSparsityProjectionMethod#4552
fredroy merged 7 commits intosofa-framework:masterfrom
alxbilger:constantsparsityprojection

Conversation

@alxbilger
Copy link
Contributor

Based on #4547. The diff: alxbilger/sofa@sparsematrixproduct...alxbilger:sofa:constantsparsityprojection

Matrix projection method taking advantage of the constant sparsity of the matrices in the computation of sparse matrix product. A boolean Data enables parallel computation.

Benchmark on the reduced diamond for 1000 time steps (previous results in #4490):

MatrixProjectionMethod + areJacobiansConstant=False

This is the most generic method

[INFO]    [BatchGUI] 1000 iterations done in 13.576 s ( 73.6594 FPS).
 LEVEL   START    NUM      MIN     MAX   MEAN     DEV    TOTAL  PERCENT ID
   6       0.84    1       9.59   24.93   11.24    2.22   11.24   88.66 ......projectMappedMatrices

MatrixProjectionMethod + areJacobiansConstant=True

[INFO]    [BatchGUI] 1000 iterations done in 8.1806 s ( 122.24 FPS).
 LEVEL   START    NUM      MIN     MAX   MEAN     DEV    TOTAL  PERCENT ID
   6       0.75    1       5.53   17.84    6.32    0.88    6.32   83.28 ......projectMappedMatrices

ConstantSparsityProjectionMethod + areJacobiansConstant=True + parallelProduct=False

[INFO]    [BatchGUI] 1000 iterations done in 11.3896 s ( 87.799 FPS).
 LEVEL   START    NUM      MIN     MAX   MEAN     DEV    TOTAL  PERCENT ID
   6       0.82    1       7.71  510.45    9.73   15.92    9.73   87.39 ......projectMappedMatrices

Note that the timer includes the first iteration which is very very slow. It alters the average.

ConstantSparsityProjectionMethod + areJacobiansConstant=True + parallelProduct=True

[INFO]    [BatchGUI] 1000 iterations done in 4.48981 s ( 222.726 FPS).
 LEVEL   START    NUM      MIN     MAX   MEAN     DEV    TOTAL  PERCENT ID
  6       0.75    1       2.31  522.09    3.32   16.42    3.32   72.50 ......projectMappedMatrices

Note that the timer includes the first iteration which is very very slow. It alters the average.

Conclusion

We can observe that the parallelism is necessary to take advantage of the constant sparsity pattern. The fastest configuration is now ConstantSparsityProjectionMethod + areJacobiansConstant=True + parallelProduct=True compared to MatrixProjectionMethod + areJacobiansConstant=True before this PR. It's a speed up of x1.8.

For the records, at the beginning of this series of enhancement (#4443), the reduced diamond run at 44 FPS. Now it is 222 FPS = speed up x5.


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: enhancement About a possible enhancement pr: status to review To notify reviewers to review this pull-request pr: highlighted in next release Highlight this contribution in the notes of the upcoming release labels Mar 1, 2024
@alxbilger alxbilger changed the title [LinearAlgebra] Refactor sparse matrix product [LinearSystem] Introduce ConstantSparsityProjectionMethod Mar 1, 2024
@alxbilger
Copy link
Contributor Author

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

@fredroy fredroy 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 18, 2024
@fredroy fredroy merged commit aa2d590 into sofa-framework:master Mar 18, 2024
bakpaul pushed a commit to bakpaul/sofa that referenced this pull request Mar 21, 2024
…work#4552)

* [LinearAlgebra] Refactor sparse matrix product

* Move tests as a template test

* Fix all combinations of storage

* Introduce parallel computation

* Manage options for more types

* [LinearSystem] Introduce ConstantSparsityProjectionMethod

---------

Co-authored-by: Frederick Roy <[email protected]>
@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: enhancement About a possible enhancement pr: highlighted in next release Highlight this contribution in the notes of the upcoming release pr: status ready Approved a pull-request, ready to be squashed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants