Repository navigation
tests: the wake, boat-plant and tape tests without FMA contraction (master's macOS lanes) - #1606
Merged
Merged
Conversation
…ion (macOS arm64) Since #1538, #1532 and #1560, master's macos-latest recipe lanes have failed four tests that pass on Linux and Windows. All four are contraction: clang's default on aarch64 fuses multiply-adds into FMAs in these test files, while the code they check is built with -ffp-contract=off. - PhysicsFieldWakeShore.CrossPlatformGoldenHash (Release and Debug): the coast the test hands the wake, 7 - x - 0.2 |y|, fuses into an FMA. - PhysicsFieldWake.CrossPlatformGoldenHash and DynBoatPlant.CrossPlatformGoldenHash (Debug only): #1532 and #1538 added the first dot() calls to physics_field_test.cpp and physics_dyn_boat_plant_test.cpp. At -O0, cvc/physics/types.h's inline dot() is a weak definition in the test executable, and dyld binds the shared libcvc's calls to it. So the field step ran a contracted dot(). - PhTrain.TheTapesDerivativesMatchFiniteDifferences: the tape rounds once per operation, but the same expression over double fuses x * y + 2 x and 1.5 + x * x. It lands 5 to 8 ulps off, past EXPECT_DOUBLE_EQ's 4. The runner image did not cause it: the last green run and the red ones used the same macos-26-arm64 image and AppleClang 21. Build the three TUs as physics_dyn_bike_plant_test and nav_potential_test already are: -ffp-contract=off, and /fp:precise under MSVC.
transfix
enabled auto-merge (squash)
November 28, 2026 10:15
transfix
added a commit
that referenced
this pull request
Nov 29, 2026
…racted or not (#1635) cvc/physics/types.h's inline dot() fused into FMAs in any translation unit built with contraction: clang's default -ffp-contract=on on aarch64, gcc's default -ffp-contract=fast, MSVC's /fp:contract and /fp:fast. The deterministic sources are built with -ffp-contract=off, so the bits depended on the caller's flags, and in a shared macOS Debug build dyld bound libcvc's own calls to a test executable's contracted copy (the cause #1606 worked around with per-TU flags). Under -ffp-contract=fast the same held for a caller's p + v * s. Each product is now rounded before anything is added to it: - gcc and clang on aarch64 and x86-64: detail::rounded(), an empty asm on the product ("+w" / "+x", as glibc's math_opt_barrier). No instruction, and dot() stays inline. - MSVC: #pragma fp_contract(off) around the operators and dot() only (float_control push/pop). Checked in the generated code first. For arm64 macOS, clang 20 and 22 under -ffp-contract=off, on, fast and fast-honor-pragmas, at -O0 (the weak copy) and -O2 (inlined): no FMA in dot(), operator* or a caller's p + v * s. The instruction sequence is the uncontracted one. On an x86-64 with FMA, a hash over 200000 random inputs (inlined, the out-of-line copies, p + v * s) is the -ffp-contract=off hash for gcc 16, clang 20, MSVC 19.44 and clang-cl 22 in every mode. The old header gave five other hashes. What did not work: #pragma clang fp contract(off) and #pragma STDC FP_CONTRACT OFF (clang disregards them under -ffp-contract=fast, gcc ignores them), named temporaries (stop only -ffp-contract=on), gcc's optimize("fp-contract=off") (gcc then will not inline dot()). gcc's __builtin_assoc_barrier works, but clang has no such builtin. Goldens are untouched: the hardened helpers compute what the -ffp-contract=off sources always did.
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.
Fixes master's red
CI (recipe-first)macOS lanes (recipe / macos-latest / Releaseand/ Debug). They have failed libcvc's recipe ctest on every completed master run since 2026-11-25 (db642b6). PR runs skip macOS, so no PR showed it.Cause
FMA contraction in three test files. Clang's default (
-ffp-contract=on) fusesa * b + cinto an FMA where the ISA has one. That means aarch64 (the macOS arm64 lanes), but not x86-64 Linux or MSVC (/fp:strict). The physics and ocean code these tests check is built with-ffp-contract=off, and the test files were not.DynBoatPlant.CrossPlatformGoldenHashdot(), called by libcvc (below)PhysicsFieldWake.CrossPlatformGoldenHashdot(), called by libcvcPhysicsFieldWakeShore.CrossPlatformGoldenHash7 - x - 0.2 |y|built in the test, plusdot()in DebugPhTrain.TheTapesDerivativesMatchFiniteDifferencesf.v == expression(x0, y0): 5 to 8 ulps, pastEXPECT_DOUBLE_EQ's 4The Debug-only goldens: #1538 and #1532 added the first
dot()calls tophysics_dyn_boat_plant_test.cppandphysics_field_test.cpp. At -O0,cvc/physics/types.h's inlinedot()is emitted as a weak definition in the test executable. dyld binds the shared libcvc's weak references to the first definition it loads, which is the executable's. So the field step (built with-ffp-contract=off) ended up calling the test's contracteddot(). Release inlinesdot()at each call site with that file's flags, so it is unaffected.The runner image is not the cause. The last green run (45610380387 on 3df78a3) and the red ones ran the same
macos-26-arm6420261117.0516 image with AppleClang 21.0.0. The failures also track the merges, on both the 20261117 and 20261123 images.Fix
Build
physics_field_test.cpp,physics_dyn_boat_plant_test.cppandph_train_test.cppthe wayphysics_dyn_bike_plant_test,nav_potential_testandphysics_immersion_testalready are:-ffp-contract=off, and/fp:preciseunder MSVC. No golden, tolerance or library code changes.Testing
ci/full/macos-fp-contractpush run ofCI (recipe-first)(46092709441) is green on all six jobs. Both macOS lanes ranmacos-26-arm6420261123.0526 with AppleClang 21.0.0, the image the reds also hit. ctest reported100% tests passed(8695 tests in Release, 8693 in Debug), and no test needed the until-pass retry. All four tests above passed in both lanes, so the Debug lanes confirm the weak-definition explanation.