Repository navigation
cvc::algo::det: cross-platform exp, log and pow; cvc::ocean's sea is the same on every platform - #1138
Merged
Conversation
…the same on every platform Before O6 puts the sea into the physics state_hash, h0 and the shore layer must give the same bits on every platform; they called libm, whose transcendentals each platform rounds its own way (docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md, B1's open item). - cvc::physics's private det_math moves to cvc::algo as cvc/algo/det_math.h (standard library only), and gains exp, log, pow, sinh, cosh, acos and hypot. pow carries log x as a double-double and multiplies it by y exactly, so it stays within 3 ULP of libm even where y log x is large; y = 1, 2, -1 and 0.5 are one correctly rounded operation each. physics/det_math.h is now a namespace alias, so the physics step is unchanged (its bit pins and physics_replay_test hold). - cvc::ocean's spectrum, h0 and shore layer call det:: in place of std::, and are built without FMA contraction. cvc::ocean may now include cvc::algo (which depends on nothing). - algo_det_math_test (was physics_det_math_test) measures each new function against libm over the ranges the ocean uses, checks libm's special cases (pow's C99 Annex F table), and pins bits. ocean_spectrum_test and ocean_shore_test pin digests of the spectrum, h0 and the shore layer's planes, evaluate() and swash(), measured on Windows, for CI to check elsewhere.
transfix
enabled auto-merge (squash)
November 10, 2026 22:31
transfix
added a commit
that referenced
this pull request
Nov 11, 2026
…me (O6a) (#1139) On top of #1138. cvc/physics/fluid_surface.h: fluid_surface (level, height, velocity, digest), still_surface and wave_train_surface (linear Airy trains, det:: math). field::surface (fluid only) clips each cell's top to the surface and drives drag with its velocity. world::field_time() is anchored to the clock by follow()'s first call, or set by set_field_time. With a surface, save() carries the field-time anchor and each surface's digest, so state_hash covers them and restore refuses other surfaces; without one the format is unchanged. physics_field_test adds B6's tests: half draft on calm water, heave in phase with a swell at its period, the field time, hashing and restore.
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.
The prerequisite for O6 in
docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md: cvc::ocean's sea gives the same bits on every platform. O6 folds h0 and the shore layer into the physicsstate_hash, which a native run and a wasm run must agree on. Until now both called libm's exp, log, pow, sin and cos, which MSVC, glibc, Apple and musl each round their own way.cvc/algo/det_math.hdet_mathis nowcvc::algo::det, public and standard library only. Like the rest of cvc::algo, it depends on no other libcvc library.src/cvc/physics/det_math.his now a namespace alias,cvc::physics::det = cvc::algo::det, so every physics call site stays as it was. The existing functions' code did not change.cvc::ocean
det::in place ofstd::for every transcendental (sqrt, floor and fabs are already exact).-ffp-contract=off,/fp:precise), as for physics.Tests
algo_det_math_test(wasphysics_det_math_test; now linked against libcvc rather than compiling det_math in):Worst errors measured against MSVC's libm:
Each bound is that plus one, as the file already does for another platform's libm.
ocean_spectrum_test,OceanH0.IsTheSameOnEveryPlatform: digests of the spectrum on a grid of k and of three cascades' h0, with wind sea, swell and finite depth.ocean_shore_test,OceanShore.IsTheSameOnEveryPlatform: a digest of a sloped island's shore layer (all ten planes, evaluate() and swash() at three times). Its grid is built from correctly rounded operations only.Where the pins come from: all were measured on Windows (MSVC, x86_64). This PR's Linux and macOS CI runs are the cross-platform check. A platform that disagrees has found a leak to fix, never a baseline to re-record.
Checked locally (Windows Release, GL build)
algo_det_math_test11,ocean_spectrum_test14,ocean_shore_test16.physics_*test,physics_replay_test(the recorded trace's hashes),cvcgl_ocean_fftandcvcgl_physics_scene_bindingpass.lsystem_coast --frames 80 --shore-check:git clang-format18.1.8 is clean on the changed lines.Next
O6: the
fluid_surfacehook oncvc::physics::field, the deterministic CPU FFT of the physics band, the pinned time base and pycvc bindings.