Repository navigation
[VFDLIBM-34] Gate the hypot port on a scalar e_hypot.c equal to StrictMath.hypot in every JIT mode - #136
Open
MaxGekk wants to merge 4 commits into
Open
[VFDLIBM-34] Gate the hypot port on a scalar e_hypot.c equal to StrictMath.hypot in every JIT mode#136MaxGekk wants to merge 4 commits into
MaxGekk wants to merge 4 commits into
Conversation
added 4 commits
November 22, 2026 18:37
…Math.hypot in every JIT mode HypotTest transcribes e_hypot.c line by line and compares it with StrictMath.hypot by PairBits under MAGNITUDES, on inputs that take every return of the C, in this JVM and in one JVM per JIT mode (-Xint, C1 only, C2 only, default tiering). Two changed transcriptions show the inputs can tell. Generated-by: Claude Code (Opus 5.5)
Count every mismatch, keep the equal-word draws finite, run the variants only when asked, cap the child JVMs' heap, drop the dependency on Atan2Test, and say what the per-mode run asserts and what it only prints. Generated-by: Claude Code (Opus 5.5)
The child JVM now fails when a pass sees no two-NaN lane of distinct candidates or leaves a way out of the C untaken, as the in-process gate does; runInJvm destroys the child in a finally and reports the output read before a timeout; cHypot's Javadoc limits the finite-radicand claim to the C as written. Generated-by: Claude Code (Opus 5.5)
…e hypot gate The children inherit no JAVA_TOOL_OPTIONS, JDK_JAVA_OPTIONS or _JAVA_OPTIONS and must report interpreted or mixed mode as their flag says; the gate requires both sqrt forms after the 2^1022 scaling, where the C reads stale words; the children run only in a test JVM with no -XX: option (the default-width CI rows and a plain verify) and time out after 60 s. Generated-by: Claude Code (Opus 5.5)
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.
What changes were proposed in this pull request?
Part of #34: the entry gate for porting
hypot, step 1 of its plan, before any vector code.HypotTest.cHypotisreference/fdlibm-5.3/e_hypot.cin scalar Java, line by line, each statement tagged with its C line;__HI(v) = wreplaces the high word and keeps the low word, and lines 80-84 leavehaandhbstale as the C does.scalarTranscriptionIsStrictMathcompares it withStrictMath.hypotthroughPairBits.matchesunderMAGNITUDES, so raw bits on every lane but one of two NaNs with different bits, where both results must be a candidate. It also asserts that every way out of the C is taken (ratio return, non-finite, zerob, the three scalings, bothsqrtforms, equal high words withbthe larger, and eachsqrtform after the 2^1022 scaling, where the C reads its stale words).The inputs are every pair of the special values and of e_hypot.c's high words at three low words, the fuzz's pair draws with
wordGapsat+-0x3c00000and its neighbours and 0, pairs at each scaling word with the other word inside line 63's gap, subnormal and zerob, equal high words,anear2b, NaNs beside NaNs (random payloads, one bit apart, sign apart), beside infinities and beside finite values, Pythagorean triples scaled across the scalings, random bits, Varka's baseline range and every exponent: 1,243,449 pairs.scalarTranscriptionIsStrictMathInEveryJitModeruns the same check in a JVM of its own per mode (-Xint,-XX:TieredStopAtLevel=1,-XX:-TieredCompilation, default tiering), started from the test byProcessBuilderwithHypotTest.main, so neitherpom.xmlnor the fault runs change. It asserts each child had its flag, reports interpreted mode for-Xintand mixed mode for the others, and exited 0; the child exits 1 if any of its three passes has a mismatch, sees no two-NaN lane of distinct candidates or leaves a way out of the C untaken. The children inherit noJAVA_TOOL_OPTIONS,JDK_JAVA_OPTIONSor_JAVA_OPTIONS, time out after 60 s (locally-Xinttook 1.3 s, C1 only 0.2 s, C2 only 0.3 s, tiered 0.2 s), and are destroyed on a timeout or interrupt. The candidate each mode returns is printed, not asserted, since it is not specified.The children do not depend on the vector width, so they run only in a test JVM with no
-XX:option, i.e. wherevfdlibm.test.jvmArgsis empty: ci.yml's rows "x86 128+256 bits, 512 on AVX-512 runners" and "Arm 128 bits" (once per architecture) and a plainmvn -B verify,dev/release.sh's included; the other rows skip them.theInputsSeeAChangedTranscriptionshows the inputs can tell: the transcription withhaandhbrefreshed after the 2^1022 scaling, or without line 63's early return, differs fromStrictMath.anInfinityBesideANaNIsPositiveInfinitypins line 69.Why are the changes needed?
#34 makes a scalar transcription that equals
StrictMath.hypotthe condition for starting the vector port, and the two-NaN contract (AGENTS.md, "Releases") needs evidence thathypot's results on those lanes are among theMAGNITUDEScandidates in every JIT tier.Result: no input differs outside the two-NaN lane, in any mode.
Two-NaN lanes, by
StrictMath.hypot(JDK 25.0.5.1, x86-64):-Xintand C1 only returned the second argument's candidate on every lane in every pass; C2 only and default tiering returned the second argument's on 161 lanes of the first pass (before compilation) and the first argument's on every other lane, all later passes included. Neither rule is the C's larger-high-worda, which agrees with PROOFS.md's probe statement.The transcription's own
a + bon those lanes keeps the C'sbwhen interpreted and the C'sawhen compiled by C1 or C2; it is a candidate in every case.Changed transcriptions, on 9,500,985 pairs: refreshed words differ on 52,720, no early return on 1,316,919.
w >= bat line 95 changed no result on these inputs, so it is not among the variants.Does this PR introduce any user-facing change?
No.
How was this patch tested?
mvn -B verifypassed (all suites and fault runs).HypotTest,HarnessSelfTestandPlantedFaultTestpassed again after each round of review fixes.A larger run, 9,500,985 pairs, two passes, in each mode, all with no mismatch:
java <mode flag> --add-modules jdk.incubator.vector -cp target/classes:target/test-classes io.github.vecbricks.vfdlibm.HypotTest 0x100000 2 variants.No hard-case file for
hypotexists yet; the Pythagorean triples are exact cases computed here.Known nit left:
lowWord,fromWordsandconcatduplicate private helpers ofFuzzandAtan2Test.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5.5)