feat: linarize most bached simulation kernels by switching to batch-interleaved formats - #37
Merged
Conversation
…tact-to-multibody index
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.
This PR Modifies the way internal objects in the rigid-body simulation (contacts, constraints, collision pairs, etc.) are stored in gpu memory. Before, we preallocated a range of contiguous elements per-batch. For example elements
0..nare for batch 0, elementsn + 1..2nfor batch 1, etc. While the mental model for this is simple, this makes the indexing complicated in scenarios where different batches might contain different numbers of elements (meaning that, for example, elementsk..nare empty).This PR switches these to batch-interleaved format. This is essentially the transpose of the above. It means that elements
0, nb, 2nb, 3nb, ...are for batch 0 (wherenbis the number of batches), elements1, nb + 1, 2nb + 1, 3nb + 1, ...are for batch 1, etc. So the stride between two elements belonging to the same batch is equal to the number of batches. The consequence is that all empty entries are pushed to the end of the buffers, making indexing much simpler. It also means that several kernels can just iterate through the elements linearly, without worrying about the concept of batches at all.