Repository navigation
Conversation
fredroy
force-pushed
the
deterministic_matrix_assembly
branch
from
October 21, 2026 00:56
26c651a to
82d7d3c
Compare
alxbilger
approved these changes
Oct 27, 2026
alxbilger
left a comment
Contributor
There was a problem hiding this comment.
The only concern is the loss of performances. Otherwise 👍
Contributor
Author
You were right to be concerned, with a specially crafted scene (long graph depth and very long path name) master: |
fredroy
force-pushed
the
deterministic_matrix_assembly
branch
from
October 28, 2026 01:30
b9f3f8c to
af9d2fd
Compare
Contributor
Author
PR with new containers: |
hugtalbot
reviewed
Oct 29, 2026
hugtalbot
reviewed
Oct 29, 2026
…of the components The force fields are allocated in an order and added to the scene graph in the reverse order, so that the expected order (the scene graph) differs from the order of their addresses.
… scene graph Before, the contributors of the assembly were iterated in the order of the std::map containing them, i.e. ordered by addresses: the rounding of the sums of contributions to the same entries depended on where the components were allocated, which changes from one run to another. Now the contributions follow the order of the scene graph traversal: - IndependentContributors stores vectors filled by visiting m_forceFields, m_masses and m_mechanicalMappings (collected in traversal order) - the shared mapped matrices are created, and projected, in the order in which their pair of mechanical states is first encountered - the duplicated mechanical states of a component are removed without sorting them by address The containers used for lookups are still keyed by pointers.
Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>
fredroy
force-pushed
the
deterministic_matrix_assembly
branch
from
October 30, 2026 06:49
cb554f5 to
033a103
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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(really poor results)
Now the contributions follow the order of the scene graph traversal:
- IndependentContributors stores vectors filled by visiting m_forceFields, m_masses and m_mechanicalMappings (collected in traversal order)
- the shared mapped matrices are created, and projected, in the order in which their pair of mechanical states is first encountered
- the duplicated mechanical states of a component are removed without sorting them by address
EDIT: add the benchmark scene
[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