Solver performance optimization: selective joint computation#1134
Open
yutingye wants to merge 1 commit into
Open
Solver performance optimization: selective joint computation#1134yutingye wants to merge 1 commit into
yutingye wants to merge 1 commit into
Conversation
Summary: Re-applies the solver optimization idea from D51049715 on the current master. Currently, SkeletonState computes both transforms and derivatives for all joints during solver evaluations. This is wasteful when only a subset of joints is relevant to the error functions being solved. This diff adds an optimization to: 1. Introduce a `JointSet` type (bitset<1024>) for efficiently tracking sets of joints. 2. Add `getAffectedJoints()` virtual method to `SkeletonErrorFunctionT` that returns which joints are directly used by each error function. Error functions can override this to provide an accurate list (default returns all joints set). 3. Add an `initialize()` method to `SolverFunctionT` that is called once before each solve loop. In `SkeletonSolverFunctionT`, this pre-computes: - `activeJointXform_`: joints that need transforms (all ancestors of affected joints) - `activeJointDeriv_`: joints that need derivatives (only active ancestors of affected joints) 4. Add a `SkeletonStateT::set()` overload that accepts per-joint `needXform` and `needDeriv` flags, allowing selective computation. 5. Add parameter caching in `updateSkeletonState()` to skip redundant state updates. 6. Implement `getAffectedJoints()` for `CollisionErrorFunctionT` and `MarkerErrorFunctionT` to provide accurate affected joint lists. As a side effect, `setEnabledParameters()` now properly propagates to all error functions at the beginning of each solve via `initialize()`, fixing a long-standing issue where downstream callers had to ensure `setEnabledParameters()` was called after all error functions were added. Differential Revision: D95663660
Contributor
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.
Summary:
Re-applies the solver optimization idea from D51049715 on the current master.
Currently, SkeletonState computes both transforms and derivatives for all joints during solver evaluations. This is wasteful when only a subset of joints is relevant to the error functions being solved.
This diff adds an optimization to:
Introduce a
JointSettype (bitset<1024>) for efficiently tracking sets of joints.Add
getAffectedJoints()virtual method toSkeletonErrorFunctionTthat returns which joints are directly used by each error function. Error functions can override this to provide an accurate list (default returns all joints set).Add an
initialize()method toSolverFunctionTthat is called once before each solve loop. InSkeletonSolverFunctionT, this pre-computes:activeJointXform_: joints that need transforms (all ancestors of affected joints)activeJointDeriv_: joints that need derivatives (only active ancestors of affected joints)Add a
SkeletonStateT::set()overload that accepts per-jointneedXformandneedDerivflags, allowing selective computation.Add parameter caching in
updateSkeletonState()to skip redundant state updates.Implement
getAffectedJoints()forCollisionErrorFunctionTandMarkerErrorFunctionTto provide accurate affected joint lists.As a side effect,
setEnabledParameters()now properly propagates to all error functions at the beginning of each solve viainitialize(), fixing a long-standing issue where downstream callers had to ensuresetEnabledParameters()was called after all error functions were added.Differential Revision: D95663660