Skip to content

feat: linarize most bached simulation kernels by switching to batch-interleaved formats - #37

Merged
sebcrozet merged 7 commits into
mainfrom
linear-batches
Aug 30, 2026
Merged

feat: linarize most bached simulation kernels by switching to batch-interleaved formats#37
sebcrozet merged 7 commits into
mainfrom
linear-batches

Conversation

@sebcrozet

@sebcrozet sebcrozet commented Aug 30, 2026

Copy link
Copy Markdown
Member

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..n are for batch 0, elements n + 1..2n for 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, elements k..n are 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 (where nb is the number of batches), elements 1, 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.

@sebcrozet
sebcrozet merged commit 3bf7c6d into main Aug 30, 2026
5 checks passed
@sebcrozet
sebcrozet deleted the linear-batches branch August 30, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant