Skip to content

[LinearSystem] Contributions to the global matrix in the order of the paths of the components - #6426

Open
fredroy wants to merge 3 commits into
sofa-framework:masterfrom
fredroy:deterministic_matrix_assembly
Open

fredroy wants to merge 3 commits into
sofa-framework:masterfrom
fredroy:deterministic_matrix_assembly

Conversation

@fredroy

@fredroy fredroy commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Fix

Before, the containers of the components (and of the pairs of mechanical states) of the assembly were ordered by addresses
Now they are ordered by the paths of the components in the scene graph, thus allowing deterministic results

[with-all-tests]


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).

@fredroy
fredroy requested a review from alxbilger October 20, 2026 23:04
@fredroy fredroy added pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI labels Oct 20, 2026
…of the components

MatrixLinearSystem builds the matrices of the components in the order of their addresses (maps keyed by
pointers): the rounding of the sums of contributions to the same entries changes with the memory layout,
from one run to another.
- the same scene, its force fields allocated in two opposite orders: the assembled entry is 0 or 1 (three
  force fields add 1, 1e16 and -1e16 to it);
- force fields created in the reverse order of their paths are built in the order of their addresses.
… paths of the components

The containers of the components (and of the pairs of mechanical states) of the assembly were ordered by
addresses: the order in which the contributions are added to the same entries, hence the rounding of the
sums, depended on the memory layout, which changes from one run to another.
They are ordered by the paths of the components in the scene graph.
@fredroy
fredroy force-pushed the deterministic_matrix_assembly branch from 26c651a to 82d7d3c Compare October 21, 2026 00:56

@alxbilger alxbilger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The only concern is the loss of performances. Otherwise 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants