Skip to content

Integrate, finalize and store in single precision, as the reference does - #236

Merged
nicolas-maman merged 1 commit into
mainfrom
float-finalize
Nov 24, 2026
Merged

nicolas-maman merged 1 commit into
mainfrom
float-finalize

Conversation

@nicolas-maman

Copy link
Copy Markdown
Collaborator

Progress at a glance

  • Positions integrated in float (b3IntegratePositionsTask's sums)
  • Sleep velocity estimate in float; the pose still moves in double
  • World inertia rotated in float at all four places (math.rotate_inertiaf)
  • Sweep reach worked out only for a body that sweeps
  • Stored friction impulse as a float sum
  • Suite benches print the solve's stages on both sides; AEPHYSICS_BENCH_NO_SLEEP=1
  • Golden trace and test_human's figure hashes regenerated
  • Full local suite green on Aether 0.940.0, no warnings

Why

A stage-by-stage read of the sleep scene against Box3D showed two simple per-body loops well behind: integrating the positions (0.068 ms against 0.044) and finalizing the bodies (0.134 against 0.098). Both widened float velocities and motions to double and narrowed them back, where the reference stays in float. A body's sleep velocity took five square roots through std.math's out-of-line call (aether#3852), and its world inertia took two double 3x3 products.

Numbers

Pinned to one core, best of five, ms per step:

Scene main this PR Box3D
sleep 1.948 1.917 1.767
large world 0.0110 0.0107 0.0089
convex pile 9.63 9.49 8.57
washer 15.23 15.08 14.36

Results move

The falling ragdolls now sleep at step 256; before this change they slept at 271, and Box3D's own two builds sleep at 273 and 274. That shift comes from the pile's chaos, not from the float estimate. With the estimate alone put back in double, the ragdolls still sleep at 256. With the inertia alone put back in double, they sleep at 264. Every other check passes unchanged: soak, the human drop and throw sweeps, and the worker hashes.

Details are in bench/RESULTS.md, under "Single precision where the reference keeps it".

Integrating the positions and finalizing the bodies widened the float
velocities and motions to double, worked in double and narrowed back,
where Box3D works in float throughout: a body's sleep velocity took five
square roots through std.math's out-of-line call, its world inertia two
double 3x3 products. Now the positions are integrated, the sleep
velocity estimated and the world inertia rotated (at all four places it
is made, math.rotate_inertiaf) in single precision with the reference's
sums; the pose still moves in double. The sweep's reach is worked out
only for a body that sweeps, and the stored friction impulse is a float
sum.

The suite prints the solve's stages under AEPHYSICS_STAGES=1 and
suite_box3d.c the reference's beside them; AEPHYSICS_BENCH_NO_SLEEP=1
keeps every body awake in both, for long profiles.

The golden trace and test_human's three figure hashes are regenerated:
the falling ragdolls sleep at 256 where they slept at 271 (Box3D's own
builds: 273 and 274), the pile's chaos rather than the estimate (the
estimate alone in double still sleeps at 256).
@nicolas-maman
nicolas-maman merged commit a68d831 into main Nov 24, 2026
3 checks passed
@nicolas-maman
nicolas-maman deleted the float-finalize branch November 24, 2026 21:54
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