Contents · Physics Engines
Part 0 · Orientation
Part 1 · Mathematical Foundations
Part 2 · Equations of Motion
Part 3 · Time Integration
Part 4 · Collision Detection
Part 5 · Contact & Constraints
Part 6 · Constraint Solvers
Part 7 · Position-Based Dynamics
Part 8 · GPU & Parallelism
- GPU and Massively Parallel Simulation
Part 9 · Differentiable Simulation
Part 8 · GPU & Parallelism
GPU and Massively Parallel Simulation
A GPU has thousands of lanes. A physics step wants to use all of them. There are two ways to get there, and they are not equally easy.
Two kinds of parallelism
The first is batched environments: run thousands of independent simulations side by side, one per GPU lane, sharing nothing. This is embarrassingly parallel, and it is how end-to-end GPU reinforcement learning collapses training time. A single workstation GPU can step tens of thousands of copies at once, buying two to three orders of magnitude over a CPU farm.1 Nothing about the physics changes; you just stamp out many worlds.
The second is parallelism inside one solve. This is the hard one. The constraint solvers that engines rely on are variants of Gauss-Seidel, and Gauss-Seidel is sequential by construction: each constraint reads the results of the ones before it. To parallelize a single large world we have to break that dependency without giving up the fast convergence that made Gauss-Seidel worth using.
The matrix-splitting view
Both classical iterations come from splitting the system matrix. For , write as its diagonal, strict lower, and strict upper parts:
Jacobi keeps only on the left and pushes everything else to the right, evaluated at the old iterate:
Per component this is . Every unknown depends only on old values, so all of them update at once. That is perfect for a GPU, but Jacobi converges slowly.
Gauss-Seidel moves to the left as well, so updates use the fresh values already computed this sweep:
The in-place substitution roughly doubles the convergence rate, but it forces to wait for , and for . Sequential.
A worked step
Take a small tridiagonal system:
Here and holds the off-diagonals. Start from . The first Jacobi step is just , since :
Now one more Jacobi step, feeding into :
So , crawling toward . For contrast, a single Gauss-Seidel sweep from reuses each value immediately: , then , then . One sweep, and it is already closer. That head start is exactly what we do not want to throw away when we go parallel.
Graph coloring: Gauss-Seidel in parallel
The fix is to notice why Gauss-Seidel is sequential. Two constraints conflict only when they share a body, where one writes a value the other is about to read. Constraints that touch disjoint bodies never conflict and can be applied simultaneously with no loss of freshness.
So build the constraint graph, one node per body, one edge per constraint, and color the edges so that no two edges meeting at a node share a color. Each color class is then a set of mutually independent constraints. Sweep the colors in turn; within a color, fire every constraint in parallel. With colors you get sequential parallel passes per iteration, and the result matches Gauss-Seidel because no body is ever touched twice inside one pass.23
- constraints
- 17
- colors K
- 4
- parallel passes
- 4
Color 1 of 4: these 6 constraints touch disjoint bodies and solve in parallel.
The trade-off is now visible. More colors means more sequential passes, so a good coloring is one with few colors and large, balanced color classes. This is the structure behind GPU-friendly Gauss-Seidel solvers for cloth, soft bodies, and particle systems, where a lattice colors with a handful of colors and each pass saturates the device.23
Batched worlds give parallelism for free; parallelism inside a solve has to be earned by coloring. With the solver mapped onto the hardware, the last part asks what happens when we want to differentiate straight through it.
Footnotes
-
Makoviychuk et al., Isaac Gym: High Performance GPU-Based Physics Simulation For Robot Learning (2021). ↩
-
Fratarcangeli, Tibaldo & Pellacini, Vivace: a Practical Gauss-Seidel Method for Stable Soft Body Dynamics (SIGGRAPH Asia 2016). ↩ ↩2
-
Macklin, Müller, Chentanez & Kim, Unified Particle Physics for Real-Time Applications (SIGGRAPH 2014). ↩ ↩2