From c0bfe85e57417c2caeec38829dc269f30ddfdcdb Mon Sep 17 00:00:00 2001 From: Max Gekk Date: Mon, 23 Nov 2026 05:39:57 +0100 Subject: [PATCH 1/8] [VFDLIBM-30] Requote cosh and atan2 from both hosts' re-runs Generated-by: Claude Code (Opus 5.5) --- PLAN.md | 22 +++++----- README.md | 6 +-- SKILLS.md | 40 +++++++++---------- .../vecbricks/vfdlibm/Atan2Benchmark.java | 4 +- .../vecbricks/vfdlibm/CoshBenchmark.java | 5 +-- .../vecbricks/vfdlibm/CoshKindsBench.java | 4 +- .../io/github/vecbricks/vfdlibm/Atan2.java | 8 ++-- .../io/github/vecbricks/vfdlibm/Cosh.java | 21 +++++----- 8 files changed, 54 insertions(+), 56 deletions(-) diff --git a/PLAN.md b/PLAN.md index 577f611..570eeb6 100644 --- a/PLAN.md +++ b/PLAN.md @@ -42,8 +42,8 @@ own logarithm and exponential and calls only `sqrt`, `fabs` and `scalbn`. `sinh` (`VFdlibm.sinh`, from `e_sinh.c`, computing through `expm1`'s common path below 22 and finishing the rest per lane), and so is `cosh` (`VFdlibm.cosh`, from `e_cosh.c`, through `exp`'s common path and expm1's `k == 0` lines, with two arms for its small range: the default arm is the slice arm, -provisionally: the host files of 21 November read the finish arm lower on every `CoshBenchmark` -row, by ratios near 1.3x or inside it, and decide neither). `asin` is done +provisionally: the EPYC 7763's run and re-run read the finish arm lower on common data, the Xeon +8573C's one run gives no direction, and the arm is the owner's call, section 5). `asin` is done too (`VFdlibm.asin`, from `e_asin.c`, with `sqrt` as the Vector API's `SQRT`, one arm, and the lanes of `|x| >= 1` finished per lane), and so is `atan` (`VFdlibm.atan`, from `s_atan.c`, five ranges through one division on blended operands, the lanes from `2^66` up finished per lane), and @@ -156,14 +156,16 @@ five are a later, optional set; the large-argument reduction of the trigonometri needs rule 2 yet, so `VFdlibm` runs one arm at every species. Every default stays provisional until a host run revises it. Meanwhile `VFdlibm` calls the finish arm of `exp`, `log` and `log10`; the guarded arm of `expm1` and `log1p`, by the owner's deferral of rule 1 until the 8573C's second - run (issue #30, 21 November); the slice arm of `cosh`, provisionally, as the rule's exception - (`bench/results/cosh-xeon8573c-2026-11-21.txt` and `cosh-epyc7763-2026-11-21.txt` read the finish - arm lower on every row by ratios near 1.3x or inside it, and give no direction); and the guarded - arm of `atan2`, which has no finish arm, so rule 1 does not pick between its two ([issue #30's - corrected comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272)). - Neither host's file gives the arms a direction (`atan2-xeon8573c-2026-11-22.txt`, inside 1.3x; - `atan2-epyc7763-2026-11-22.txt`, near 1.3x or inside it, one run), so guarded stays the default at - every species by the owner's decision of 22 November until a re-run of each host. + run (issue #30, 21 November); the slice arm of `cosh`, provisionally, as the rule's exception, + whose arm is the owner's call: `bench/results/cosh-epyc7763-2026-11-21.txt` holds a run and a + re-run, which agree on the finish arm lower on common data and give no direction on mixed data, + `cosh-xeon8573c-2026-11-21.txt` one run with no direction, and the `cosh-kinds-` files no + direction at 3.5% or 17% of small lanes; and the guarded arm of `atan2`, which has no finish arm, + so rule 1 does not pick between its two ([issue #30's corrected + comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272)). Each host has + timed atan2's arms in a run and a re-run (`atan2-xeon8573c-2026-11-22.txt`, + `atan2-epyc7763-2026-11-22.txt`), and neither file gives them a direction, so guarded stays the + default at every species by the owner's decision of 22 November. ## 6. Rules diff --git a/README.md b/README.md index b845d3b..ce8391f 100644 --- a/README.md +++ b/README.md @@ -192,9 +192,9 @@ fdlibm's own sequence of operations, lane by lane. That is this library. (`exp-onediv-xeon8573c-2026-11-03.txt` and those of 20 and 21 November; `log1p-xeon8573c-2026-11-03.txt` and `expm1-xeon8573c-2026-11-04.txt` have no `*Max` row) time the finish that boxed before issue #37 and are left out of the rules. `atan2` has no finish arm, so - the rule does not pick between its two; neither host's file gives them a direction, and its - guarded arm stays the default at every species by the owner's decision until a re-run of each - host. Every default stays provisional until a host run revises it; `PLAN.md` section 5 gives each + the rule does not pick between its two; neither host's file gives them a direction after a run and + a re-run each, and its guarded arm stays the default at every species by the owner's decision. + Every default stays provisional until a host run revises it; `PLAN.md` section 5 gives each function's case. The laptop's numbers do not agree at every width. ## Testing diff --git a/SKILLS.md b/SKILLS.md index a55d4aa..fe8ebd1 100644 --- a/SKILLS.md +++ b/SKILLS.md @@ -1108,18 +1108,18 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer only on `|x| < 0.5*ln2`, so their cost follows the share of that range, which is 3.5% in Varka's baseline benchmark and 17% in Spark's unit tests (issue #32): at 8 lanes a vector holds one in 27% and 82% of the cases. `CoshKindsBench` has those two shares, and - `CoshBenchmark`'s common data 0.6% of them. A laptop run under load read no direction and was - not kept. Each host has since run both classes once - (`bench/results/cosh-xeon8573c-2026-11-21.txt`, `cosh-epyc7763-2026-11-21.txt`, - `cosh-kinds-xeon8573c-2026-11-21.txt` and `cosh-kinds-epyc7763-2026-11-21.txt`), and no file - decides the arm: on `CoshBenchmark` the finish arm reads lower on every row, slice over finish - 1.24 to 1.35 on the Xeon 8573C and 1.29 to 1.35 on the EPYC 7763, ratios near 1.3x or inside - it that give no direction until a re-run; on `CoshKindsBench` the finish arm reads lower by - more than 1.3x only on data with no small lane, and the arms read within 1.3x of each other, - with no direction, at 3.5% and 17% of small lanes, Varka's and Spark's shares. cosh is the - named exception to issue #30's tie rule (its per-lane set is not rare, so a host run decides), - so the default is still the plan's baseline design, not a measurement, and stays provisional - until a host run decides it. + `CoshBenchmark`'s common data 0.6% of them. A laptop run under load read no direction and was not + kept. On `CoshBenchmark` the EPYC 7763's run and re-run + (`bench/results/cosh-epyc7763-2026-11-21.txt`) both read the finish arm lower outside 1.3x on + common data and agree, a direction on common data, and give no direction on mixed data; the Xeon + 8573C has one run (`cosh-xeon8573c-2026-11-21.txt`), whose ratios are near 1.3x or inside it and + give no direction until a re-run. On `CoshKindsBench` (`cosh-kinds-epyc7763-2026-11-21.txt`, two + runs, and `cosh-kinds-xeon8573c-2026-11-21.txt`, one) the finish arm reads lower by more than 1.3x + only on data with no small lane, and at 3.5% and 17% of small lanes, Varka's and Spark's shares, + the arms read within 1.3x of each other, with no direction. cosh is the named exception to issue + #30's tie rule (its per-lane set is not rare, so a host run decides), so the default is still the + plan's baseline design, not a measurement, and stays provisional; which arm it keeps is the + owner's call. - **Which exp faults reach cosh.** `exp.dropCorrection` and `exp.constantOffByOneUlp`, which change `expCore`'s lanes of `|x| >= 0.5 ln2`. `exp.thresholdMoved` moves the subnormal scale-back, which `expCore` leaves out, and `exp.dropKForcing` the lanes of the word of 0.5 @@ -1269,15 +1269,13 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer `bench/alloc-check.py` passes on the `Atan2Benchmark` rows (`blended` and `guarded`, at 256 bits, the preferred species and `SPECIES_MAX`, common and mixed data) at this laptop's flags and as an AVX2 host, and CI runs it. Those local readings are not committed, so no figure of them is - quoted. Each host has timed both arms once (`bench/results/atan2-xeon8573c-2026-11-22.txt` and - `atan2-epyc7763-2026-11-22.txt`): on the Xeon they read within 1.3x of each other at every - width, and on the EPYC 7763 near 1.3x or inside it, so neither file gives them a direction. - atan2 has no finish arm (both arms compute the special lanes in the vector; blended runs their - blends in every vector, guarded behind a test), so rule 1 of issue #30 does not pick between - them ([the issue's corrected - comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272)). - So guarded stays the default at every species by the owner's decision of 22 November until a - re-run of each host. + quoted. Each host has timed both arms in a run and a re-run + (`bench/results/atan2-xeon8573c-2026-11-22.txt` and `atan2-epyc7763-2026-11-22.txt`), and neither + file gives them a direction. atan2 has no finish arm (both arms compute the special lanes in the + vector; blended runs their blends in every vector, guarded behind a test), so rule 1 of issue #30 + does not pick between them ([the issue's corrected + comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272)). So guarded + stays the default at every species by the owner's decision of 22 November. - **A lane the core must not see.** A NaN, an infinity or a huge `t` in a lane the special blends overwrite would send the vector to atan's per-lane finish. The mask `t < 2^66` keeps them out (a NaN compares false), and a vector with no special lane never reaches the finish. diff --git a/src/jmh/java/io/github/vecbricks/vfdlibm/Atan2Benchmark.java b/src/jmh/java/io/github/vecbricks/vfdlibm/Atan2Benchmark.java index 07409ff..4252d17 100644 --- a/src/jmh/java/io/github/vecbricks/vfdlibm/Atan2Benchmark.java +++ b/src/jmh/java/io/github/vecbricks/vfdlibm/Atan2Benchmark.java @@ -31,8 +31,8 @@ * at 256 bits, at the host's preferred species and at {@code SPECIES_MAX}. 128 bits is left out: * on x86 C2 lowers no mask at two 64-bit lanes, so every 128-bit arm boxes (SKILLS.md). {@code * bench/alloc-check.py} reads it for what the bodies allocate, and - * bench/results/atan2-xeon8573c-2026-11-22.txt and atan2-epyc7763-2026-11-22.txt time it, one - * run on each host, which gives the two arms no direction. + * bench/results/atan2-xeon8573c-2026-11-22.txt and atan2-epyc7763-2026-11-22.txt time it, a run and + * a re-run on each host, which give the two arms no direction. * *

{@code inputs} picks the data: {@code common} draws {@code y} and {@code x} from {@code * (-4, 4)}, where no lane is special (NaN, zero, infinite), none has {@code x = 1.0} and none diff --git a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java index 80fdd11..7dcd8db 100644 --- a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java +++ b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java @@ -51,9 +51,8 @@ * DoubleVector.SPECIES_MAX}, where the finish writes out its first eight lanes with constant * indices and a loop takes any past eight; the rows read under 0.1 B/op in the laptop reading of * bench/results/max-finish-alloc-free-laptop-2026-11-21.txt (allocation only, no timing). No - * file reads the finish they replaced. bench/results/cosh-xeon8573c-2026-11-21.txt and - * cosh-epyc7763-2026-11-21.txt read these rows, one run on each host, and give the two arms no - * direction. + * file reads the finish they replaced. bench/results/cosh-xeon8573c-2026-11-21.txt (one run) and + * cosh-epyc7763-2026-11-21.txt (a run and a re-run) read these rows; no file decides the arm. */ @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) diff --git a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java index d05fa27..0c59879 100644 --- a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java +++ b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java @@ -59,8 +59,8 @@ * (AGENTS.md); by hand that is {@code -f 2 -wi 3 -w 2s -i 5 -r 2s -prof gc -jvmArgsAppend * -XX:CompileCommand=inline,io.github.vecbricks.vfdlibm.*::*}. * - *

bench/results/cosh-kinds-xeon8573c-2026-11-21.txt and cosh-kinds-epyc7763-2026-11-21.txt - * read these rows, one run on each host, and decide no arm. + *

bench/results/cosh-kinds-xeon8573c-2026-11-21.txt (one run) and + * cosh-kinds-epyc7763-2026-11-21.txt (a run and a re-run) read these rows, and decide no arm. */ @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) diff --git a/src/main/java/io/github/vecbricks/vfdlibm/Atan2.java b/src/main/java/io/github/vecbricks/vfdlibm/Atan2.java index 21c0b8a..8a84ed7 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/Atan2.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/Atan2.java @@ -60,10 +60,10 @@ * {@code guarded} only in a vector with a live special lane, which is the one {@code VFdlibm} * calls, at every species. atan2 has no finish arm, so rule 1 of issue #30 (a tie goes to the * finish arm) does not pick between the two (the issue's corrected comment, - * https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272). Neither host's file - * gives the arms a direction ({@code bench/results/atan2-xeon8573c-2026-11-22.txt}, inside 1.3x; - * {@code atan2-epyc7763-2026-11-22.txt}, near 1.3x or inside it, one run), so guarded stays the - * default at every species by the owner's decision of 22 November until a re-run of each host. + * https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272). Each host has timed both + * arms in a run and a re-run ({@code bench/results/atan2-xeon8573c-2026-11-22.txt} and {@code + * atan2-epyc7763-2026-11-22.txt}), and neither file gives them a direction, so guarded stays the + * default at every species by the owner's decision of 22 November. */ final class Atan2 { diff --git a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java index 9f34773..fe9b5ef 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java @@ -81,17 +81,16 @@ * the body. * *

{@link #cosh(DoubleVector, VectorMask)}, which {@code VFdlibm.cosh} calls, is the slice - * arm, provisionally: the choice is the design's, not a measurement's. Each host has run {@code - * CoshBenchmark} and {@code CoshKindsBench} once ({@code - * bench/results/cosh-xeon8573c-2026-11-21.txt}, {@code cosh-epyc7763-2026-11-21.txt} and the - * two {@code cosh-kinds-} files of that day), and no file decides the arm. On {@code - * CoshBenchmark} the finish arm reads lower on every row, slice over finish 1.24 to 1.35 on the - * Xeon 8573C and 1.29 to 1.35 on the EPYC 7763, ratios near 1.3x or inside it that give no - * direction until a re-run. On {@code CoshKindsBench} the finish arm reads lower by more than - * 1.3x only on data with no small lane, and at 3.5% and 17% of small lanes the arms read within - * 1.3x of each other, with no direction ({@code SKILLS.md}). cosh is the named exception to - * issue #30's tie rule, since its per-lane set is not rare: a host run decides its arm, and the - * slice default stays provisional until one does. The default is chosen in {@code cosh(x, + * arm, provisionally: the choice is the design's, not a measurement's. On {@code CoshBenchmark} the + * EPYC 7763's run and re-run ({@code bench/results/cosh-epyc7763-2026-11-21.txt}) both read the + * finish arm lower outside 1.3x on common data and agree, a direction on common data, and give no + * direction on mixed data; the Xeon 8573C has one run ({@code cosh-xeon8573c-2026-11-21.txt}), + * whose ratios give no direction until a re-run. On {@code CoshKindsBench} ({@code + * cosh-kinds-epyc7763-2026-11-21.txt}, two runs, and {@code cosh-kinds-xeon8573c-2026-11-21.txt}, + * one) the arms read within 1.3x of each other at 3.5% and 17% of small lanes, with no direction + * ({@code SKILLS.md}). cosh is the named exception to issue #30's tie rule, since its per-lane set + * is not rare: a host run decides its arm, which is the owner's call, and the slice default stays + * provisional until then. The default is chosen in {@code cosh(x, * live)}; other places say "the default arm". */ final class Cosh { From b5b747ddcbf921961e521c72f790c06e5c6b9e6d Mon Sep 17 00:00:00 2001 From: Max Gekk Date: Mon, 23 Nov 2026 05:42:30 +0100 Subject: [PATCH 2/8] [VFDLIBM-30] Restore cosh's no-small-lane reading and add the Xeon atan2 re-run's datapath Generated-by: Claude Code (Opus 5.5) --- HARDWARE.md | 3 ++- src/main/java/io/github/vecbricks/vfdlibm/Cosh.java | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/HARDWARE.md b/HARDWARE.md index 162c8c3..0ae59eb 100644 --- a/HARDWARE.md +++ b/HARDWARE.md @@ -80,7 +80,8 @@ at 256 and 93.7 to 96.3 at 512: `exp-onediv-xeon8573c-2026-11-03.txt` (34.7 / 68 files of 21 November, from two runs: `exp-xeon8573c-2026-11-21.txt` and its five siblings (34.5 / 69.1 / 93.7, 2.00, 1.36) and `sinh-`, `cosh-` and `cosh-kinds-xeon8573c-2026-11-21.txt` (34.9 / 69.9 / 94.8, 2.00, 1.36), and the four of 22 November, `asin-xeon8573c-2026-11-22.txt` and its -three siblings (35.7 / 70.8 / 96.3, 1.98, 1.36). `log1p-xeon8573c-2026-11-03.txt`, of the same +three siblings (35.7 / 70.8 / 96.3, 1.98, 1.36, and 34.6 / 69.1 / 93.8, 2.00, 1.36 for the second +run in `atan2-xeon8573c-2026-11-22.txt`). `log1p-xeon8573c-2026-11-03.txt`, of the same day as the pair, reads 41.5 / 82.7 / 113.0 (1.99, 1.37), and its scalar `StrictMath` loop reads 7,358 ns on common data where the `log1p` file of 21 November reads 8,846. Each file's header says which it ran on; no cause for the difference is claimed here. The 25 nightly draws of this CPU in diff --git a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java index fe9b5ef..1cea5a0 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java @@ -85,12 +85,14 @@ * EPYC 7763's run and re-run ({@code bench/results/cosh-epyc7763-2026-11-21.txt}) both read the * finish arm lower outside 1.3x on common data and agree, a direction on common data, and give no * direction on mixed data; the Xeon 8573C has one run ({@code cosh-xeon8573c-2026-11-21.txt}), - * whose ratios give no direction until a re-run. On {@code CoshKindsBench} ({@code + * whose ratios are near 1.3x or inside it and give no direction. On {@code CoshKindsBench} ({@code * cosh-kinds-epyc7763-2026-11-21.txt}, two runs, and {@code cosh-kinds-xeon8573c-2026-11-21.txt}, - * one) the arms read within 1.3x of each other at 3.5% and 17% of small lanes, with no direction - * ({@code SKILLS.md}). cosh is the named exception to issue #30's tie rule, since its per-lane set - * is not rare: a host run decides its arm, which is the owner's call, and the slice default stays - * provisional until then. The default is chosen in {@code cosh(x, + * one) the finish arm reads lower by more than 1.3x only on data with no small lane, and at 3.5% + * and 17% of small lanes the arms read within 1.3x of each other, with no direction ({@code + * SKILLS.md}). So the one direction is the EPYC's on common data, where 0.6% of the lanes are + * small. cosh is the named exception to issue #30's tie rule, since its per-lane set is not rare: a + * host run decides its arm, by the owner's call, and the slice default stays provisional until + * then. The default is chosen in {@code cosh(x, * live)}; other places say "the default arm". */ final class Cosh { From 5292a15d9d7d61e70b9aa6273e635109f726031b Mon Sep 17 00:00:00 2001 From: Max Gekk Date: Mon, 23 Nov 2026 05:48:02 +0100 Subject: [PATCH 3/8] [VFDLIBM-30] Make cosh's finish arm the default VFdlibm.cosh, in both forms, now runs Cosh's finish arm, by the owner's decision of 23 November 2026 (issue #30); the slice arm stays, tested, and every lane gives the same bits. Generated-by: Claude Code (Opus 5.5) --- CHANGELOG.md | 6 ++++ PLAN.md | 17 ++++----- README.md | 3 +- SKILLS.md | 13 ++++--- .../vecbricks/vfdlibm/CoshBenchmark.java | 7 ++-- .../vecbricks/vfdlibm/CoshKindsBench.java | 13 +++---- .../io/github/vecbricks/vfdlibm/Cosh.java | 35 +++++++++---------- .../io/github/vecbricks/vfdlibm/VFdlibm.java | 2 +- 8 files changed, 54 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 888f9ae..39f4c45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,12 @@ two NaNs with different bits in a function of two arguments (`AGENTS.md`, "Relea varies by JIT tier. Lanes with an infinity or a NaN in either argument are finished per lane by `StrictMath.hypot`. +### Changed + +- `VFdlibm.cosh` runs the finish arm, which finishes the small range (`|x| < 0.5*ln2`) per lane by + `StrictMath.cosh`, instead of the slice arm, which computed it in the vector; every lane gives the + same bits as before (issue #30, the owner's decision of 23 November 2026). + ## [0.2.0] - 2026-11-22 ### Added diff --git a/PLAN.md b/PLAN.md index 570eeb6..b7716fe 100644 --- a/PLAN.md +++ b/PLAN.md @@ -41,9 +41,8 @@ row order decides which comes first. `exp` is the first port and is done (`VFdli own logarithm and exponential and calls only `sqrt`, `fabs` and `scalbn`. `sinh` is done (`VFdlibm.sinh`, from `e_sinh.c`, computing through `expm1`'s common path below 22 and finishing the rest per lane), and so is `cosh` (`VFdlibm.cosh`, from `e_cosh.c`, through `exp`'s common path -and expm1's `k == 0` lines, with two arms for its small range: the default arm is the slice arm, -provisionally: the EPYC 7763's run and re-run read the finish arm lower on common data, the Xeon -8573C's one run gives no direction, and the arm is the owner's call, section 5). `asin` is done +and expm1's `k == 0` lines, with two arms for its small range: the default arm is the finish arm, by +the owner's decision of 23 November, section 5). `asin` is done too (`VFdlibm.asin`, from `e_asin.c`, with `sqrt` as the Vector API's `SQRT`, one arm, and the lanes of `|x| >= 1` finished per lane), and so is `atan` (`VFdlibm.atan`, from `s_atan.c`, five ranges through one division on blended operands, the lanes from `2^66` up finished per lane), and @@ -156,11 +155,13 @@ five are a later, optional set; the large-argument reduction of the trigonometri needs rule 2 yet, so `VFdlibm` runs one arm at every species. Every default stays provisional until a host run revises it. Meanwhile `VFdlibm` calls the finish arm of `exp`, `log` and `log10`; the guarded arm of `expm1` and `log1p`, by the owner's deferral of rule 1 until the 8573C's second - run (issue #30, 21 November); the slice arm of `cosh`, provisionally, as the rule's exception, - whose arm is the owner's call: `bench/results/cosh-epyc7763-2026-11-21.txt` holds a run and a - re-run, which agree on the finish arm lower on common data and give no direction on mixed data, - `cosh-xeon8573c-2026-11-21.txt` one run with no direction, and the `cosh-kinds-` files no - direction at 3.5% or 17% of small lanes; and the guarded arm of `atan2`, which has no finish arm, + run (issue #30, 21 November); the finish arm of `cosh`, the rule's exception, by the owner's + decision of 23 November (issue #30): no measured row favours slice, the EPYC 7763's two runs read + finish lower on common data near 1.3x, neither host gives a direction at Varka's and Spark's + shares of small lanes, and rule 1's tie goes to the finish arm + (`bench/results/cosh-epyc7763-2026-11-21.txt`, a run and a re-run; + `cosh-xeon8573c-2026-11-21.txt`, one run; the `cosh-kinds-` files), and the slice arm stays, + tested, so the choice can be re-measured; and the guarded arm of `atan2`, which has no finish arm, so rule 1 does not pick between its two ([issue #30's corrected comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272)). Each host has timed atan2's arms in a run and a re-run (`atan2-xeon8573c-2026-11-22.txt`, diff --git a/README.md b/README.md index ce8391f..396b31a 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,8 @@ fdlibm's own sequence of operations, lane by lane. That is this library. Xeon Platinum 8573C and the EPYC 7763 (`bench/results/`), and each file's reading is in `SKILLS.md`; where two arms are within 1.3x of each other no direction is read, and where the hosts disagree the files say so. The rules are set (issue #30): a tie within 1.3x on every host - that has a file goes to the finish arm, except for `cosh`, whose arm a host run decides, and where + that has a file goes to the finish arm, except for `cosh`, whose arm a host run decides (the owner + made it the finish arm on 23 November: no measured row favours its slice arm), and where hosts disagree each species keeps its own arm (no function needs that yet). `expm1` and `log1p` stay on their guarded arm by the owner's deferral of the rule until the 8573C's second run. The `*Max` rows of the host files of 3 to 21 November for `exp`, `expm1`, `log`, `log10` and `log1p` diff --git a/SKILLS.md b/SKILLS.md index fe8ebd1..3045318 100644 --- a/SKILLS.md +++ b/SKILLS.md @@ -1103,8 +1103,9 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer graph (above). With one `expCore` and about 35 more operations, `CoshBenchmark`'s rows are held by `bench/alloc-check.py` (CI runs it, and it was run locally before any test was written), at the runner's flags and as AVX2. -- **Two arms, one provisional default.** `coshSlice` computes the small range in the vector and - `coshFinish` finishes its lanes per lane; the default arm is the slice arm. The arms differ +- **Two arms; the finish arm is the default.** `coshSlice` computes the small range in the vector + and `coshFinish` finishes its lanes per lane; the default arm was the slice arm until 23 November, + and is the finish arm since, by the owner's decision. The arms differ only on `|x| < 0.5*ln2`, so their cost follows the share of that range, which is 3.5% in Varka's baseline benchmark and 17% in Spark's unit tests (issue #32): at 8 lanes a vector holds one in 27% and 82% of the cases. `CoshKindsBench` has those two shares, and @@ -1117,9 +1118,11 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer runs, and `cosh-kinds-xeon8573c-2026-11-21.txt`, one) the finish arm reads lower by more than 1.3x only on data with no small lane, and at 3.5% and 17% of small lanes, Varka's and Spark's shares, the arms read within 1.3x of each other, with no direction. cosh is the named exception to issue - #30's tie rule (its per-lane set is not rare, so a host run decides), so the default is still the - plan's baseline design, not a measurement, and stays provisional; which arm it keeps is the - owner's call. + #30's tie rule (its per-lane set is not rare, so a host run decides), and the owner made the + finish arm its default on 23 November: no measured row favours slice, the EPYC 7763's two runs + read finish lower on common data near 1.3x, neither host gives a direction at Varka's and Spark's + shares of small lanes, and rule 1's tie goes to the finish arm. It is not read as faster, and the + slice arm stays, tested, so the choice can be re-measured. - **Which exp faults reach cosh.** `exp.dropCorrection` and `exp.constantOffByOneUlp`, which change `expCore`'s lanes of `|x| >= 0.5 ln2`. `exp.thresholdMoved` moves the subnormal scale-back, which `expCore` leaves out, and `exp.dropKForcing` the lanes of the word of 0.5 diff --git a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java index 7dcd8db..46deade 100644 --- a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java +++ b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java @@ -27,8 +27,8 @@ /** * cosh over an array of 1024 doubles: the scalar {@code StrictMath.cosh} loop and {@code * Cosh}'s two arms, {@link Cosh#coshSlice} (the small range, {@code |x| < 0.5*ln2}, computed in - * the vector, the default arm) and {@link Cosh#coshFinish} (the small range - * finished per lane), each vector form at 256 and 512 bits and at the host's preferred species, + * the vector) and {@link Cosh#coshFinish} (the small range finished per lane, the default + * arm), each vector form at 256 and 512 bits and at the host's preferred species, * and at {@code SPECIES_MAX}. 128 bits is left out: on x86 C2 lowers no mask at two 64-bit lanes, * so every 128-bit arm boxes (SKILLS.md). On a host without 512-bit vectors the 512-bit * benchmarks run in software and measure nothing useful. @@ -52,7 +52,8 @@ * indices and a loop takes any past eight; the rows read under 0.1 B/op in the laptop reading of * bench/results/max-finish-alloc-free-laptop-2026-11-21.txt (allocation only, no timing). No * file reads the finish they replaced. bench/results/cosh-xeon8573c-2026-11-21.txt (one run) and - * cosh-epyc7763-2026-11-21.txt (a run and a re-run) read these rows; no file decides the arm. + * cosh-epyc7763-2026-11-21.txt (a run and a re-run) read these rows; the finish arm is + * the default by the owner's decision of 23 November. */ @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) diff --git a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java index 0c59879..042b44f 100644 --- a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java +++ b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java @@ -27,11 +27,11 @@ /** * cosh's two arms at a share of small-range lanes, to decide which of them {@link VFdlibm#cosh} * runs: the scalar {@code StrictMath.cosh} loop, {@link Cosh#coshSlice} (the small range, {@code - * |x| < 0.5*ln2}, computed in the vector, the default arm) and {@link - * Cosh#coshFinish} (finished per lane), each - * vector form at 256 bits and at the host's preferred species, over an array of 1024 doubles. - * The arms differ only in that range, and {@code CoshBenchmark}'s {@code common} data has 0.6% of - * its lanes there, which says little: a vector holds a small lane with probability {@code 1 - + * |x| < 0.5*ln2}, computed in the vector) and {@link Cosh#coshFinish} (finished per lane, the + * default arm), each vector form at 256 bits and at the host's preferred species, over an array of + * 1024 doubles. The arms differ only in that range, and {@code CoshBenchmark}'s {@code common} data + * has 0.6% of its lanes there, which says little: a vector holds a small lane with probability + * {@code 1 - * (1-p)^n}, so at 3.5% 13% of the 4-lane and 25% of the 8-lane vectors do (the share of Varka's * baseline benchmark, {@code x} in [-10, 10)), and at 17% (the share of Spark's unit tests, * -2.0 to 2.0 in steps of 0.1) 52% and 77% (the survey on issue #32). Those are the shares in @@ -60,7 +60,8 @@ * -XX:CompileCommand=inline,io.github.vecbricks.vfdlibm.*::*}. * *

bench/results/cosh-kinds-xeon8573c-2026-11-21.txt (one run) and - * cosh-kinds-epyc7763-2026-11-21.txt (a run and a re-run) read these rows, and decide no arm. + * cosh-kinds-epyc7763-2026-11-21.txt (a run and a re-run) read these rows, and give no direction + * at either share; the finish arm is the default by the owner's decision of 23 November. */ @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) diff --git a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java index 1cea5a0..e773d15 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java @@ -80,20 +80,19 @@ * exists; after it there are only Vector API operations and the per-lane finish written out in * the body. * - *

{@link #cosh(DoubleVector, VectorMask)}, which {@code VFdlibm.cosh} calls, is the slice - * arm, provisionally: the choice is the design's, not a measurement's. On {@code CoshBenchmark} the - * EPYC 7763's run and re-run ({@code bench/results/cosh-epyc7763-2026-11-21.txt}) both read the - * finish arm lower outside 1.3x on common data and agree, a direction on common data, and give no - * direction on mixed data; the Xeon 8573C has one run ({@code cosh-xeon8573c-2026-11-21.txt}), - * whose ratios are near 1.3x or inside it and give no direction. On {@code CoshKindsBench} ({@code + *

{@link #cosh(DoubleVector, VectorMask)}, which {@code VFdlibm.cosh} calls, is the finish arm, + * the default by the owner's decision of 23 November 2026 (issue #30): no measured row favours + * slice, the EPYC 7763's two runs read finish lower on common data near 1.3x, neither host gives a + * direction at Varka's and Spark's shares of small lanes, and rule 1's tie goes to the finish arm. + * It is not read as faster. On {@code CoshBenchmark} the EPYC 7763's run and re-run ({@code + * bench/results/cosh-epyc7763-2026-11-21.txt}) agree on the finish arm lower on common data and + * give no direction on mixed data; the Xeon 8573C's one run ({@code cosh-xeon8573c-2026-11-21.txt}) + * is near 1.3x or inside it, with no direction. On {@code CoshKindsBench} ({@code * cosh-kinds-epyc7763-2026-11-21.txt}, two runs, and {@code cosh-kinds-xeon8573c-2026-11-21.txt}, * one) the finish arm reads lower by more than 1.3x only on data with no small lane, and at 3.5% - * and 17% of small lanes the arms read within 1.3x of each other, with no direction ({@code - * SKILLS.md}). So the one direction is the EPYC's on common data, where 0.6% of the lanes are - * small. cosh is the named exception to issue #30's tie rule, since its per-lane set is not rare: a - * host run decides its arm, by the owner's call, and the slice default stays provisional until - * then. The default is chosen in {@code cosh(x, - * live)}; other places say "the default arm". + * and 17% of small lanes the arms read within 1.3x of each other ({@code SKILLS.md}). The slice arm + * stays, tested, so the choice can be re-measured. The default is chosen in {@code cosh(x, live)}; + * other places say "the default arm". */ final class Cosh { @@ -163,25 +162,25 @@ final class Cosh { private Cosh() {} /** - * cosh as {@code VFdlibm.cosh} computes it, the slice arm. {@code live} is null for every + * cosh as {@code VFdlibm.cosh} computes it, the finish arm. {@code live} is null for every * lane; otherwise only live lanes are computed, inactive lanes return {@code x}'s lane * untouched, and an inactive lane never takes the per-lane finish. */ static DoubleVector cosh(DoubleVector x, VectorMask live) { - return cosh(x, live, SLICE); + return cosh(x, live, FINISH); } /** - * cosh with the small range computed in the vector, as {@link #cosh(DoubleVector, - * VectorMask)} does. + * cosh with the small range computed in the vector, the arm that is not the default. {@code + * live} is as for {@link #cosh(DoubleVector, VectorMask)}. */ static DoubleVector coshSlice(DoubleVector x, VectorMask live) { return cosh(x, live, SLICE); } /** - * cosh with the small range finished per lane. {@code live} is as for {@link - * #cosh(DoubleVector, VectorMask)}. + * cosh with the small range finished per lane, as {@link #cosh(DoubleVector, VectorMask)} + * does. */ static DoubleVector coshFinish(DoubleVector x, VectorMask live) { return cosh(x, live, FINISH); diff --git a/src/main/java/io/github/vecbricks/vfdlibm/VFdlibm.java b/src/main/java/io/github/vecbricks/vfdlibm/VFdlibm.java index 17cee1f..57cc1bd 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/VFdlibm.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/VFdlibm.java @@ -30,7 +30,7 @@ * under {@code bench/results/}, in the source repository and not in the jar, read what the body * allocates at each, in bytes per op, an op being one pass over 1024 doubles. The arm that {@code * exp}, {@code log} and {@code log10} call is the finish arm, the one {@code expm1}, {@code - * log1p} and {@code atan2} call is the guarded arm, and the one {@code cosh} calls is the slice + * log1p} and {@code atan2} call is the guarded arm, and the one {@code cosh} calls is the finish * arm; {@code hypot} has one arm, the finish. No file under {@code bench/results/} reads {@code * hypot} yet: every file the list below cites predates it, and of the list only the allocation * check that CI runs covers it. From c7feadfd73d4b11e981f8b0b5f053beeaaf5b6d2 Mon Sep 17 00:00:00 2001 From: Max Gekk Date: Mon, 23 Nov 2026 05:59:05 +0100 Subject: [PATCH 4/8] [VFDLIBM-30] Give cosh's default its reason as the files read it Generated-by: Claude Code (Opus 5.5) --- PLAN.md | 7 ++++--- README.md | 4 ++-- SKILLS.md | 7 ++++--- .../java/io/github/vecbricks/vfdlibm/CoshKindsBench.java | 5 ++--- src/main/java/io/github/vecbricks/vfdlibm/Cosh.java | 7 ++++--- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/PLAN.md b/PLAN.md index b7716fe..cd2c295 100644 --- a/PLAN.md +++ b/PLAN.md @@ -156,9 +156,10 @@ five are a later, optional set; the large-argument reduction of the trigonometri until a host run revises it. Meanwhile `VFdlibm` calls the finish arm of `exp`, `log` and `log10`; the guarded arm of `expm1` and `log1p`, by the owner's deferral of rule 1 until the 8573C's second run (issue #30, 21 November); the finish arm of `cosh`, the rule's exception, by the owner's - decision of 23 November (issue #30): no measured row favours slice, the EPYC 7763's two runs read - finish lower on common data near 1.3x, neither host gives a direction at Varka's and Spark's - shares of small lanes, and rule 1's tie goes to the finish arm + decision of 23 November (issue #30): no row gives slice a direction (at 17% of small lanes it + reads lower, inside 1.3x), the EPYC 7763's two runs give finish one on common data, neither host + gives a direction at Varka's and Spark's shares of small lanes, and the owner applied rule 1's + tie-break to cosh (`bench/results/cosh-epyc7763-2026-11-21.txt`, a run and a re-run; `cosh-xeon8573c-2026-11-21.txt`, one run; the `cosh-kinds-` files), and the slice arm stays, tested, so the choice can be re-measured; and the guarded arm of `atan2`, which has no finish arm, diff --git a/README.md b/README.md index 396b31a..b66de6f 100644 --- a/README.md +++ b/README.md @@ -185,8 +185,8 @@ fdlibm's own sequence of operations, lane by lane. That is this library. Xeon Platinum 8573C and the EPYC 7763 (`bench/results/`), and each file's reading is in `SKILLS.md`; where two arms are within 1.3x of each other no direction is read, and where the hosts disagree the files say so. The rules are set (issue #30): a tie within 1.3x on every host - that has a file goes to the finish arm, except for `cosh`, whose arm a host run decides (the owner - made it the finish arm on 23 November: no measured row favours its slice arm), and where + that has a file goes to the finish arm, except for `cosh`, whose arm the owner decided on 23 + November (the finish arm: no row gives its slice arm a direction), and where hosts disagree each species keeps its own arm (no function needs that yet). `expm1` and `log1p` stay on their guarded arm by the owner's deferral of the rule until the 8573C's second run. The `*Max` rows of the host files of 3 to 21 November for `exp`, `expm1`, `log`, `log10` and `log1p` diff --git a/SKILLS.md b/SKILLS.md index 3045318..1ed9d53 100644 --- a/SKILLS.md +++ b/SKILLS.md @@ -1119,9 +1119,10 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer only on data with no small lane, and at 3.5% and 17% of small lanes, Varka's and Spark's shares, the arms read within 1.3x of each other, with no direction. cosh is the named exception to issue #30's tie rule (its per-lane set is not rare, so a host run decides), and the owner made the - finish arm its default on 23 November: no measured row favours slice, the EPYC 7763's two runs - read finish lower on common data near 1.3x, neither host gives a direction at Varka's and Spark's - shares of small lanes, and rule 1's tie goes to the finish arm. It is not read as faster, and the + finish arm its default on 23 November: no row gives slice a direction (at 17% of small lanes it + reads lower, inside 1.3x), the EPYC 7763's two runs give finish one on common data, neither host + gives a direction at Varka's and Spark's shares of small lanes, and the owner applied rule 1's + tie-break to cosh. It is not read as faster, and the slice arm stays, tested, so the choice can be re-measured. - **Which exp faults reach cosh.** `exp.dropCorrection` and `exp.constantOffByOneUlp`, which change `expCore`'s lanes of `|x| >= 0.5 ln2`. `exp.thresholdMoved` moves the subnormal diff --git a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java index 042b44f..5586a00 100644 --- a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java +++ b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java @@ -31,9 +31,8 @@ * default arm), each vector form at 256 bits and at the host's preferred species, over an array of * 1024 doubles. The arms differ only in that range, and {@code CoshBenchmark}'s {@code common} data * has 0.6% of its lanes there, which says little: a vector holds a small lane with probability - * {@code 1 - - * (1-p)^n}, so at 3.5% 13% of the 4-lane and 25% of the 8-lane vectors do (the share of Varka's - * baseline benchmark, {@code x} in [-10, 10)), and at 17% (the share of Spark's unit tests, + * {@code 1 - (1-p)^n}, so at 3.5% 13% of the 4-lane and 25% of the 8-lane vectors do (the share of + * Varka's baseline benchmark, {@code x} in [-10, 10)), and at 17% (the share of Spark's unit tests, * -2.0 to 2.0 in steps of 0.1) 52% and 77% (the survey on issue #32). Those are the shares in * theory; the exact placement below has 35 of the 256 four-lane vectors and 34 of the 128 * eight-lane ones hold a small lane at 3.5% (14% and 27%), and 134 and 105 at 17% (52% and 82%). diff --git a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java index e773d15..17fa392 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java @@ -81,9 +81,10 @@ * the body. * *

{@link #cosh(DoubleVector, VectorMask)}, which {@code VFdlibm.cosh} calls, is the finish arm, - * the default by the owner's decision of 23 November 2026 (issue #30): no measured row favours - * slice, the EPYC 7763's two runs read finish lower on common data near 1.3x, neither host gives a - * direction at Varka's and Spark's shares of small lanes, and rule 1's tie goes to the finish arm. + * the default by the owner's decision of 23 November 2026 (issue #30): no row gives slice a + * direction (at 17% of small lanes it reads lower, inside 1.3x), the EPYC 7763's two runs give + * finish one on common data, neither host gives a direction at Varka's and Spark's shares of small + * lanes, and the owner applied rule 1's tie-break to cosh. * It is not read as faster. On {@code CoshBenchmark} the EPYC 7763's run and re-run ({@code * bench/results/cosh-epyc7763-2026-11-21.txt}) agree on the finish arm lower on common data and * give no direction on mixed data; the Xeon 8573C's one run ({@code cosh-xeon8573c-2026-11-21.txt}) From e9d43a9fd793c465f6d6533d83edff85d8d54fab Mon Sep 17 00:00:00 2001 From: Max Gekk Date: Mon, 23 Nov 2026 06:12:49 +0100 Subject: [PATCH 5/8] Revert "[VFDLIBM-30] Give cosh's default its reason as the files read it" This reverts commit c7feadfd73d4b11e981f8b0b5f053beeaaf5b6d2: the owner keeps the slice arm as cosh's default for now, until the Xeon 8573C's cosh re-run is in. Generated-by: Claude Code (Opus 5.5) --- PLAN.md | 7 +++---- README.md | 4 ++-- SKILLS.md | 7 +++---- .../java/io/github/vecbricks/vfdlibm/CoshKindsBench.java | 5 +++-- src/main/java/io/github/vecbricks/vfdlibm/Cosh.java | 7 +++---- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/PLAN.md b/PLAN.md index cd2c295..b7716fe 100644 --- a/PLAN.md +++ b/PLAN.md @@ -156,10 +156,9 @@ five are a later, optional set; the large-argument reduction of the trigonometri until a host run revises it. Meanwhile `VFdlibm` calls the finish arm of `exp`, `log` and `log10`; the guarded arm of `expm1` and `log1p`, by the owner's deferral of rule 1 until the 8573C's second run (issue #30, 21 November); the finish arm of `cosh`, the rule's exception, by the owner's - decision of 23 November (issue #30): no row gives slice a direction (at 17% of small lanes it - reads lower, inside 1.3x), the EPYC 7763's two runs give finish one on common data, neither host - gives a direction at Varka's and Spark's shares of small lanes, and the owner applied rule 1's - tie-break to cosh + decision of 23 November (issue #30): no measured row favours slice, the EPYC 7763's two runs read + finish lower on common data near 1.3x, neither host gives a direction at Varka's and Spark's + shares of small lanes, and rule 1's tie goes to the finish arm (`bench/results/cosh-epyc7763-2026-11-21.txt`, a run and a re-run; `cosh-xeon8573c-2026-11-21.txt`, one run; the `cosh-kinds-` files), and the slice arm stays, tested, so the choice can be re-measured; and the guarded arm of `atan2`, which has no finish arm, diff --git a/README.md b/README.md index b66de6f..396b31a 100644 --- a/README.md +++ b/README.md @@ -185,8 +185,8 @@ fdlibm's own sequence of operations, lane by lane. That is this library. Xeon Platinum 8573C and the EPYC 7763 (`bench/results/`), and each file's reading is in `SKILLS.md`; where two arms are within 1.3x of each other no direction is read, and where the hosts disagree the files say so. The rules are set (issue #30): a tie within 1.3x on every host - that has a file goes to the finish arm, except for `cosh`, whose arm the owner decided on 23 - November (the finish arm: no row gives its slice arm a direction), and where + that has a file goes to the finish arm, except for `cosh`, whose arm a host run decides (the owner + made it the finish arm on 23 November: no measured row favours its slice arm), and where hosts disagree each species keeps its own arm (no function needs that yet). `expm1` and `log1p` stay on their guarded arm by the owner's deferral of the rule until the 8573C's second run. The `*Max` rows of the host files of 3 to 21 November for `exp`, `expm1`, `log`, `log10` and `log1p` diff --git a/SKILLS.md b/SKILLS.md index 1ed9d53..3045318 100644 --- a/SKILLS.md +++ b/SKILLS.md @@ -1119,10 +1119,9 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer only on data with no small lane, and at 3.5% and 17% of small lanes, Varka's and Spark's shares, the arms read within 1.3x of each other, with no direction. cosh is the named exception to issue #30's tie rule (its per-lane set is not rare, so a host run decides), and the owner made the - finish arm its default on 23 November: no row gives slice a direction (at 17% of small lanes it - reads lower, inside 1.3x), the EPYC 7763's two runs give finish one on common data, neither host - gives a direction at Varka's and Spark's shares of small lanes, and the owner applied rule 1's - tie-break to cosh. It is not read as faster, and the + finish arm its default on 23 November: no measured row favours slice, the EPYC 7763's two runs + read finish lower on common data near 1.3x, neither host gives a direction at Varka's and Spark's + shares of small lanes, and rule 1's tie goes to the finish arm. It is not read as faster, and the slice arm stays, tested, so the choice can be re-measured. - **Which exp faults reach cosh.** `exp.dropCorrection` and `exp.constantOffByOneUlp`, which change `expCore`'s lanes of `|x| >= 0.5 ln2`. `exp.thresholdMoved` moves the subnormal diff --git a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java index 5586a00..042b44f 100644 --- a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java +++ b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java @@ -31,8 +31,9 @@ * default arm), each vector form at 256 bits and at the host's preferred species, over an array of * 1024 doubles. The arms differ only in that range, and {@code CoshBenchmark}'s {@code common} data * has 0.6% of its lanes there, which says little: a vector holds a small lane with probability - * {@code 1 - (1-p)^n}, so at 3.5% 13% of the 4-lane and 25% of the 8-lane vectors do (the share of - * Varka's baseline benchmark, {@code x} in [-10, 10)), and at 17% (the share of Spark's unit tests, + * {@code 1 - + * (1-p)^n}, so at 3.5% 13% of the 4-lane and 25% of the 8-lane vectors do (the share of Varka's + * baseline benchmark, {@code x} in [-10, 10)), and at 17% (the share of Spark's unit tests, * -2.0 to 2.0 in steps of 0.1) 52% and 77% (the survey on issue #32). Those are the shares in * theory; the exact placement below has 35 of the 256 four-lane vectors and 34 of the 128 * eight-lane ones hold a small lane at 3.5% (14% and 27%), and 134 and 105 at 17% (52% and 82%). diff --git a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java index 17fa392..e773d15 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java @@ -81,10 +81,9 @@ * the body. * *

{@link #cosh(DoubleVector, VectorMask)}, which {@code VFdlibm.cosh} calls, is the finish arm, - * the default by the owner's decision of 23 November 2026 (issue #30): no row gives slice a - * direction (at 17% of small lanes it reads lower, inside 1.3x), the EPYC 7763's two runs give - * finish one on common data, neither host gives a direction at Varka's and Spark's shares of small - * lanes, and the owner applied rule 1's tie-break to cosh. + * the default by the owner's decision of 23 November 2026 (issue #30): no measured row favours + * slice, the EPYC 7763's two runs read finish lower on common data near 1.3x, neither host gives a + * direction at Varka's and Spark's shares of small lanes, and rule 1's tie goes to the finish arm. * It is not read as faster. On {@code CoshBenchmark} the EPYC 7763's run and re-run ({@code * bench/results/cosh-epyc7763-2026-11-21.txt}) agree on the finish arm lower on common data and * give no direction on mixed data; the Xeon 8573C's one run ({@code cosh-xeon8573c-2026-11-21.txt}) From c419f3950a474e685dea2b20569147cf6f04f5b0 Mon Sep 17 00:00:00 2001 From: Max Gekk Date: Mon, 23 Nov 2026 06:12:49 +0100 Subject: [PATCH 6/8] Revert "[VFDLIBM-30] Make cosh's finish arm the default" This reverts commit 5292a15: the owner keeps the slice arm as cosh's default for now, until the Xeon 8573C's cosh re-run is in. Generated-by: Claude Code (Opus 5.5) --- CHANGELOG.md | 6 ---- PLAN.md | 17 +++++---- README.md | 3 +- SKILLS.md | 13 +++---- .../vecbricks/vfdlibm/CoshBenchmark.java | 7 ++-- .../vecbricks/vfdlibm/CoshKindsBench.java | 13 ++++--- .../io/github/vecbricks/vfdlibm/Cosh.java | 35 ++++++++++--------- .../io/github/vecbricks/vfdlibm/VFdlibm.java | 2 +- 8 files changed, 42 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39f4c45..888f9ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,12 +21,6 @@ two NaNs with different bits in a function of two arguments (`AGENTS.md`, "Relea varies by JIT tier. Lanes with an infinity or a NaN in either argument are finished per lane by `StrictMath.hypot`. -### Changed - -- `VFdlibm.cosh` runs the finish arm, which finishes the small range (`|x| < 0.5*ln2`) per lane by - `StrictMath.cosh`, instead of the slice arm, which computed it in the vector; every lane gives the - same bits as before (issue #30, the owner's decision of 23 November 2026). - ## [0.2.0] - 2026-11-22 ### Added diff --git a/PLAN.md b/PLAN.md index b7716fe..570eeb6 100644 --- a/PLAN.md +++ b/PLAN.md @@ -41,8 +41,9 @@ row order decides which comes first. `exp` is the first port and is done (`VFdli own logarithm and exponential and calls only `sqrt`, `fabs` and `scalbn`. `sinh` is done (`VFdlibm.sinh`, from `e_sinh.c`, computing through `expm1`'s common path below 22 and finishing the rest per lane), and so is `cosh` (`VFdlibm.cosh`, from `e_cosh.c`, through `exp`'s common path -and expm1's `k == 0` lines, with two arms for its small range: the default arm is the finish arm, by -the owner's decision of 23 November, section 5). `asin` is done +and expm1's `k == 0` lines, with two arms for its small range: the default arm is the slice arm, +provisionally: the EPYC 7763's run and re-run read the finish arm lower on common data, the Xeon +8573C's one run gives no direction, and the arm is the owner's call, section 5). `asin` is done too (`VFdlibm.asin`, from `e_asin.c`, with `sqrt` as the Vector API's `SQRT`, one arm, and the lanes of `|x| >= 1` finished per lane), and so is `atan` (`VFdlibm.atan`, from `s_atan.c`, five ranges through one division on blended operands, the lanes from `2^66` up finished per lane), and @@ -155,13 +156,11 @@ five are a later, optional set; the large-argument reduction of the trigonometri needs rule 2 yet, so `VFdlibm` runs one arm at every species. Every default stays provisional until a host run revises it. Meanwhile `VFdlibm` calls the finish arm of `exp`, `log` and `log10`; the guarded arm of `expm1` and `log1p`, by the owner's deferral of rule 1 until the 8573C's second - run (issue #30, 21 November); the finish arm of `cosh`, the rule's exception, by the owner's - decision of 23 November (issue #30): no measured row favours slice, the EPYC 7763's two runs read - finish lower on common data near 1.3x, neither host gives a direction at Varka's and Spark's - shares of small lanes, and rule 1's tie goes to the finish arm - (`bench/results/cosh-epyc7763-2026-11-21.txt`, a run and a re-run; - `cosh-xeon8573c-2026-11-21.txt`, one run; the `cosh-kinds-` files), and the slice arm stays, - tested, so the choice can be re-measured; and the guarded arm of `atan2`, which has no finish arm, + run (issue #30, 21 November); the slice arm of `cosh`, provisionally, as the rule's exception, + whose arm is the owner's call: `bench/results/cosh-epyc7763-2026-11-21.txt` holds a run and a + re-run, which agree on the finish arm lower on common data and give no direction on mixed data, + `cosh-xeon8573c-2026-11-21.txt` one run with no direction, and the `cosh-kinds-` files no + direction at 3.5% or 17% of small lanes; and the guarded arm of `atan2`, which has no finish arm, so rule 1 does not pick between its two ([issue #30's corrected comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272)). Each host has timed atan2's arms in a run and a re-run (`atan2-xeon8573c-2026-11-22.txt`, diff --git a/README.md b/README.md index 396b31a..ce8391f 100644 --- a/README.md +++ b/README.md @@ -185,8 +185,7 @@ fdlibm's own sequence of operations, lane by lane. That is this library. Xeon Platinum 8573C and the EPYC 7763 (`bench/results/`), and each file's reading is in `SKILLS.md`; where two arms are within 1.3x of each other no direction is read, and where the hosts disagree the files say so. The rules are set (issue #30): a tie within 1.3x on every host - that has a file goes to the finish arm, except for `cosh`, whose arm a host run decides (the owner - made it the finish arm on 23 November: no measured row favours its slice arm), and where + that has a file goes to the finish arm, except for `cosh`, whose arm a host run decides, and where hosts disagree each species keeps its own arm (no function needs that yet). `expm1` and `log1p` stay on their guarded arm by the owner's deferral of the rule until the 8573C's second run. The `*Max` rows of the host files of 3 to 21 November for `exp`, `expm1`, `log`, `log10` and `log1p` diff --git a/SKILLS.md b/SKILLS.md index 3045318..fe8ebd1 100644 --- a/SKILLS.md +++ b/SKILLS.md @@ -1103,9 +1103,8 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer graph (above). With one `expCore` and about 35 more operations, `CoshBenchmark`'s rows are held by `bench/alloc-check.py` (CI runs it, and it was run locally before any test was written), at the runner's flags and as AVX2. -- **Two arms; the finish arm is the default.** `coshSlice` computes the small range in the vector - and `coshFinish` finishes its lanes per lane; the default arm was the slice arm until 23 November, - and is the finish arm since, by the owner's decision. The arms differ +- **Two arms, one provisional default.** `coshSlice` computes the small range in the vector and + `coshFinish` finishes its lanes per lane; the default arm is the slice arm. The arms differ only on `|x| < 0.5*ln2`, so their cost follows the share of that range, which is 3.5% in Varka's baseline benchmark and 17% in Spark's unit tests (issue #32): at 8 lanes a vector holds one in 27% and 82% of the cases. `CoshKindsBench` has those two shares, and @@ -1118,11 +1117,9 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer runs, and `cosh-kinds-xeon8573c-2026-11-21.txt`, one) the finish arm reads lower by more than 1.3x only on data with no small lane, and at 3.5% and 17% of small lanes, Varka's and Spark's shares, the arms read within 1.3x of each other, with no direction. cosh is the named exception to issue - #30's tie rule (its per-lane set is not rare, so a host run decides), and the owner made the - finish arm its default on 23 November: no measured row favours slice, the EPYC 7763's two runs - read finish lower on common data near 1.3x, neither host gives a direction at Varka's and Spark's - shares of small lanes, and rule 1's tie goes to the finish arm. It is not read as faster, and the - slice arm stays, tested, so the choice can be re-measured. + #30's tie rule (its per-lane set is not rare, so a host run decides), so the default is still the + plan's baseline design, not a measurement, and stays provisional; which arm it keeps is the + owner's call. - **Which exp faults reach cosh.** `exp.dropCorrection` and `exp.constantOffByOneUlp`, which change `expCore`'s lanes of `|x| >= 0.5 ln2`. `exp.thresholdMoved` moves the subnormal scale-back, which `expCore` leaves out, and `exp.dropKForcing` the lanes of the word of 0.5 diff --git a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java index 46deade..7dcd8db 100644 --- a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java +++ b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshBenchmark.java @@ -27,8 +27,8 @@ /** * cosh over an array of 1024 doubles: the scalar {@code StrictMath.cosh} loop and {@code * Cosh}'s two arms, {@link Cosh#coshSlice} (the small range, {@code |x| < 0.5*ln2}, computed in - * the vector) and {@link Cosh#coshFinish} (the small range finished per lane, the default - * arm), each vector form at 256 and 512 bits and at the host's preferred species, + * the vector, the default arm) and {@link Cosh#coshFinish} (the small range + * finished per lane), each vector form at 256 and 512 bits and at the host's preferred species, * and at {@code SPECIES_MAX}. 128 bits is left out: on x86 C2 lowers no mask at two 64-bit lanes, * so every 128-bit arm boxes (SKILLS.md). On a host without 512-bit vectors the 512-bit * benchmarks run in software and measure nothing useful. @@ -52,8 +52,7 @@ * indices and a loop takes any past eight; the rows read under 0.1 B/op in the laptop reading of * bench/results/max-finish-alloc-free-laptop-2026-11-21.txt (allocation only, no timing). No * file reads the finish they replaced. bench/results/cosh-xeon8573c-2026-11-21.txt (one run) and - * cosh-epyc7763-2026-11-21.txt (a run and a re-run) read these rows; the finish arm is - * the default by the owner's decision of 23 November. + * cosh-epyc7763-2026-11-21.txt (a run and a re-run) read these rows; no file decides the arm. */ @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) diff --git a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java index 042b44f..0c59879 100644 --- a/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java +++ b/src/jmh/java/io/github/vecbricks/vfdlibm/CoshKindsBench.java @@ -27,11 +27,11 @@ /** * cosh's two arms at a share of small-range lanes, to decide which of them {@link VFdlibm#cosh} * runs: the scalar {@code StrictMath.cosh} loop, {@link Cosh#coshSlice} (the small range, {@code - * |x| < 0.5*ln2}, computed in the vector) and {@link Cosh#coshFinish} (finished per lane, the - * default arm), each vector form at 256 bits and at the host's preferred species, over an array of - * 1024 doubles. The arms differ only in that range, and {@code CoshBenchmark}'s {@code common} data - * has 0.6% of its lanes there, which says little: a vector holds a small lane with probability - * {@code 1 - + * |x| < 0.5*ln2}, computed in the vector, the default arm) and {@link + * Cosh#coshFinish} (finished per lane), each + * vector form at 256 bits and at the host's preferred species, over an array of 1024 doubles. + * The arms differ only in that range, and {@code CoshBenchmark}'s {@code common} data has 0.6% of + * its lanes there, which says little: a vector holds a small lane with probability {@code 1 - * (1-p)^n}, so at 3.5% 13% of the 4-lane and 25% of the 8-lane vectors do (the share of Varka's * baseline benchmark, {@code x} in [-10, 10)), and at 17% (the share of Spark's unit tests, * -2.0 to 2.0 in steps of 0.1) 52% and 77% (the survey on issue #32). Those are the shares in @@ -60,8 +60,7 @@ * -XX:CompileCommand=inline,io.github.vecbricks.vfdlibm.*::*}. * *

bench/results/cosh-kinds-xeon8573c-2026-11-21.txt (one run) and - * cosh-kinds-epyc7763-2026-11-21.txt (a run and a re-run) read these rows, and give no direction - * at either share; the finish arm is the default by the owner's decision of 23 November. + * cosh-kinds-epyc7763-2026-11-21.txt (a run and a re-run) read these rows, and decide no arm. */ @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) diff --git a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java index e773d15..1cea5a0 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java @@ -80,19 +80,20 @@ * exists; after it there are only Vector API operations and the per-lane finish written out in * the body. * - *

{@link #cosh(DoubleVector, VectorMask)}, which {@code VFdlibm.cosh} calls, is the finish arm, - * the default by the owner's decision of 23 November 2026 (issue #30): no measured row favours - * slice, the EPYC 7763's two runs read finish lower on common data near 1.3x, neither host gives a - * direction at Varka's and Spark's shares of small lanes, and rule 1's tie goes to the finish arm. - * It is not read as faster. On {@code CoshBenchmark} the EPYC 7763's run and re-run ({@code - * bench/results/cosh-epyc7763-2026-11-21.txt}) agree on the finish arm lower on common data and - * give no direction on mixed data; the Xeon 8573C's one run ({@code cosh-xeon8573c-2026-11-21.txt}) - * is near 1.3x or inside it, with no direction. On {@code CoshKindsBench} ({@code + *

{@link #cosh(DoubleVector, VectorMask)}, which {@code VFdlibm.cosh} calls, is the slice + * arm, provisionally: the choice is the design's, not a measurement's. On {@code CoshBenchmark} the + * EPYC 7763's run and re-run ({@code bench/results/cosh-epyc7763-2026-11-21.txt}) both read the + * finish arm lower outside 1.3x on common data and agree, a direction on common data, and give no + * direction on mixed data; the Xeon 8573C has one run ({@code cosh-xeon8573c-2026-11-21.txt}), + * whose ratios are near 1.3x or inside it and give no direction. On {@code CoshKindsBench} ({@code * cosh-kinds-epyc7763-2026-11-21.txt}, two runs, and {@code cosh-kinds-xeon8573c-2026-11-21.txt}, * one) the finish arm reads lower by more than 1.3x only on data with no small lane, and at 3.5% - * and 17% of small lanes the arms read within 1.3x of each other ({@code SKILLS.md}). The slice arm - * stays, tested, so the choice can be re-measured. The default is chosen in {@code cosh(x, live)}; - * other places say "the default arm". + * and 17% of small lanes the arms read within 1.3x of each other, with no direction ({@code + * SKILLS.md}). So the one direction is the EPYC's on common data, where 0.6% of the lanes are + * small. cosh is the named exception to issue #30's tie rule, since its per-lane set is not rare: a + * host run decides its arm, by the owner's call, and the slice default stays provisional until + * then. The default is chosen in {@code cosh(x, + * live)}; other places say "the default arm". */ final class Cosh { @@ -162,25 +163,25 @@ final class Cosh { private Cosh() {} /** - * cosh as {@code VFdlibm.cosh} computes it, the finish arm. {@code live} is null for every + * cosh as {@code VFdlibm.cosh} computes it, the slice arm. {@code live} is null for every * lane; otherwise only live lanes are computed, inactive lanes return {@code x}'s lane * untouched, and an inactive lane never takes the per-lane finish. */ static DoubleVector cosh(DoubleVector x, VectorMask live) { - return cosh(x, live, FINISH); + return cosh(x, live, SLICE); } /** - * cosh with the small range computed in the vector, the arm that is not the default. {@code - * live} is as for {@link #cosh(DoubleVector, VectorMask)}. + * cosh with the small range computed in the vector, as {@link #cosh(DoubleVector, + * VectorMask)} does. */ static DoubleVector coshSlice(DoubleVector x, VectorMask live) { return cosh(x, live, SLICE); } /** - * cosh with the small range finished per lane, as {@link #cosh(DoubleVector, VectorMask)} - * does. + * cosh with the small range finished per lane. {@code live} is as for {@link + * #cosh(DoubleVector, VectorMask)}. */ static DoubleVector coshFinish(DoubleVector x, VectorMask live) { return cosh(x, live, FINISH); diff --git a/src/main/java/io/github/vecbricks/vfdlibm/VFdlibm.java b/src/main/java/io/github/vecbricks/vfdlibm/VFdlibm.java index 57cc1bd..17cee1f 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/VFdlibm.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/VFdlibm.java @@ -30,7 +30,7 @@ * under {@code bench/results/}, in the source repository and not in the jar, read what the body * allocates at each, in bytes per op, an op being one pass over 1024 doubles. The arm that {@code * exp}, {@code log} and {@code log10} call is the finish arm, the one {@code expm1}, {@code - * log1p} and {@code atan2} call is the guarded arm, and the one {@code cosh} calls is the finish + * log1p} and {@code atan2} call is the guarded arm, and the one {@code cosh} calls is the slice * arm; {@code hypot} has one arm, the finish. No file under {@code bench/results/} reads {@code * hypot} yet: every file the list below cites predates it, and of the list only the allocation * check that CI runs covers it. From f515172139998b24d8d22671fe497289ea3f6a26 Mon Sep 17 00:00:00 2001 From: Max Gekk Date: Mon, 23 Nov 2026 06:17:54 +0100 Subject: [PATCH 7/8] [VFDLIBM-30] Keep cosh's slice default, provisionally, and cite its readings without leaning Generated-by: Claude Code (Opus 5.5) --- PLAN.md | 14 +++++++------ SKILLS.md | 19 +++++++---------- .../io/github/vecbricks/vfdlibm/Cosh.java | 21 ++++++++----------- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/PLAN.md b/PLAN.md index 570eeb6..c2d0a7a 100644 --- a/PLAN.md +++ b/PLAN.md @@ -42,8 +42,7 @@ own logarithm and exponential and calls only `sqrt`, `fabs` and `scalbn`. `sinh` (`VFdlibm.sinh`, from `e_sinh.c`, computing through `expm1`'s common path below 22 and finishing the rest per lane), and so is `cosh` (`VFdlibm.cosh`, from `e_cosh.c`, through `exp`'s common path and expm1's `k == 0` lines, with two arms for its small range: the default arm is the slice arm, -provisionally: the EPYC 7763's run and re-run read the finish arm lower on common data, the Xeon -8573C's one run gives no direction, and the arm is the owner's call, section 5). `asin` is done +provisionally, until a host run decides, section 5). `asin` is done too (`VFdlibm.asin`, from `e_asin.c`, with `sqrt` as the Vector API's `SQRT`, one arm, and the lanes of `|x| >= 1` finished per lane), and so is `atan` (`VFdlibm.atan`, from `s_atan.c`, five ranges through one division on blended operands, the lanes from `2^66` up finished per lane), and @@ -157,10 +156,13 @@ five are a later, optional set; the large-argument reduction of the trigonometri until a host run revises it. Meanwhile `VFdlibm` calls the finish arm of `exp`, `log` and `log10`; the guarded arm of `expm1` and `log1p`, by the owner's deferral of rule 1 until the 8573C's second run (issue #30, 21 November); the slice arm of `cosh`, provisionally, as the rule's exception, - whose arm is the owner's call: `bench/results/cosh-epyc7763-2026-11-21.txt` holds a run and a - re-run, which agree on the finish arm lower on common data and give no direction on mixed data, - `cosh-xeon8573c-2026-11-21.txt` one run with no direction, and the `cosh-kinds-` files no - direction at 3.5% or 17% of small lanes; and the guarded arm of `atan2`, which has no finish arm, + whose arm a host run decides ([issue #30's + comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7091848602)): on + `CoshBenchmark`'s common data the EPYC 7763's two runs read the finish arm lower, near 1.3x + (`bench/results/cosh-epyc7763-2026-11-21.txt`); on `CoshKindsBench` the finish arm reads lower at + 3.5% of small lanes and the slice arm at 17%, inside 1.3x on both hosts; the Xeon 8573C has one + cosh run (`cosh-xeon8573c-2026-11-21.txt`), and a re-run is dispatched; and the guarded arm of + `atan2`, which has no finish arm, so rule 1 does not pick between its two ([issue #30's corrected comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272)). Each host has timed atan2's arms in a run and a re-run (`atan2-xeon8573c-2026-11-22.txt`, diff --git a/SKILLS.md b/SKILLS.md index fe8ebd1..7b4809f 100644 --- a/SKILLS.md +++ b/SKILLS.md @@ -1109,17 +1109,14 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer Varka's baseline benchmark and 17% in Spark's unit tests (issue #32): at 8 lanes a vector holds one in 27% and 82% of the cases. `CoshKindsBench` has those two shares, and `CoshBenchmark`'s common data 0.6% of them. A laptop run under load read no direction and was not - kept. On `CoshBenchmark` the EPYC 7763's run and re-run - (`bench/results/cosh-epyc7763-2026-11-21.txt`) both read the finish arm lower outside 1.3x on - common data and agree, a direction on common data, and give no direction on mixed data; the Xeon - 8573C has one run (`cosh-xeon8573c-2026-11-21.txt`), whose ratios are near 1.3x or inside it and - give no direction until a re-run. On `CoshKindsBench` (`cosh-kinds-epyc7763-2026-11-21.txt`, two - runs, and `cosh-kinds-xeon8573c-2026-11-21.txt`, one) the finish arm reads lower by more than 1.3x - only on data with no small lane, and at 3.5% and 17% of small lanes, Varka's and Spark's shares, - the arms read within 1.3x of each other, with no direction. cosh is the named exception to issue - #30's tie rule (its per-lane set is not rare, so a host run decides), so the default is still the - plan's baseline design, not a measurement, and stays provisional; which arm it keeps is the - owner's call. + kept. The slice arm stays the default, provisionally, as the named exception to issue #30's tie + rule (its per-lane set is not rare, so a host run decides; [issue #30's + comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7091848602)). The readings, + by minimums: on `CoshBenchmark`'s common data the EPYC 7763's two runs read the finish arm lower, + near 1.3x (`bench/results/cosh-epyc7763-2026-11-21.txt`); on `CoshKindsBench` the finish arm reads + lower at 3.5% of small lanes and the slice arm at 17%, inside 1.3x on both hosts + (`cosh-kinds-epyc7763-2026-11-21.txt`, `cosh-kinds-xeon8573c-2026-11-21.txt`). The Xeon 8573C has + one cosh run (`cosh-xeon8573c-2026-11-21.txt`), and a re-run is dispatched. - **Which exp faults reach cosh.** `exp.dropCorrection` and `exp.constantOffByOneUlp`, which change `expCore`'s lanes of `|x| >= 0.5 ln2`. `exp.thresholdMoved` moves the subnormal scale-back, which `expCore` leaves out, and `exp.dropKForcing` the lanes of the word of 0.5 diff --git a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java index 1cea5a0..dc5524b 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java @@ -81,18 +81,15 @@ * the body. * *

{@link #cosh(DoubleVector, VectorMask)}, which {@code VFdlibm.cosh} calls, is the slice - * arm, provisionally: the choice is the design's, not a measurement's. On {@code CoshBenchmark} the - * EPYC 7763's run and re-run ({@code bench/results/cosh-epyc7763-2026-11-21.txt}) both read the - * finish arm lower outside 1.3x on common data and agree, a direction on common data, and give no - * direction on mixed data; the Xeon 8573C has one run ({@code cosh-xeon8573c-2026-11-21.txt}), - * whose ratios are near 1.3x or inside it and give no direction. On {@code CoshKindsBench} ({@code - * cosh-kinds-epyc7763-2026-11-21.txt}, two runs, and {@code cosh-kinds-xeon8573c-2026-11-21.txt}, - * one) the finish arm reads lower by more than 1.3x only on data with no small lane, and at 3.5% - * and 17% of small lanes the arms read within 1.3x of each other, with no direction ({@code - * SKILLS.md}). So the one direction is the EPYC's on common data, where 0.6% of the lanes are - * small. cosh is the named exception to issue #30's tie rule, since its per-lane set is not rare: a - * host run decides its arm, by the owner's call, and the slice default stays provisional until - * then. The default is chosen in {@code cosh(x, + * arm, provisionally, as the named exception to issue #30's tie rule: its per-lane set is not rare, + * so a host run decides its arm (issue #30, + * https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7091848602). The readings, by + * minimums: on {@code CoshBenchmark}'s common data the EPYC 7763's two runs read the finish arm + * lower, near 1.3x ({@code bench/results/cosh-epyc7763-2026-11-21.txt}); on {@code CoshKindsBench} + * the finish arm reads lower at 3.5% of small lanes and the slice arm at 17%, inside 1.3x on both + * hosts ({@code cosh-kinds-epyc7763-2026-11-21.txt}, {@code cosh-kinds-xeon8573c-2026-11-21.txt}). + * The Xeon 8573C has one cosh run ({@code cosh-xeon8573c-2026-11-21.txt}), and a re-run is + * dispatched. The default is chosen in {@code cosh(x, * live)}; other places say "the default arm". */ final class Cosh { From 218c53ed6f783891235fe32ad66b7b3b13beb425 Mon Sep 17 00:00:00 2001 From: Max Gekk Date: Mon, 23 Nov 2026 07:00:44 +0100 Subject: [PATCH 8/8] [VFDLIBM-30] Read cosh's EPYC direction as its file states it, restore the no-small-lane reading, and recount the 8573C's files Generated-by: Claude Code (Opus 5.5) --- HARDWARE.md | 25 ++++++++++--------- PLAN.md | 24 ++++++++++-------- README.md | 3 ++- SKILLS.md | 12 +++++---- .../io/github/vecbricks/vfdlibm/Cosh.java | 14 ++++++----- 5 files changed, 44 insertions(+), 34 deletions(-) diff --git a/HARDWARE.md b/HARDWARE.md index 0ae59eb..37a60bb 100644 --- a/HARDWARE.md +++ b/HARDWARE.md @@ -35,7 +35,7 @@ be the whole string ("The Arm host" below). | machine | host key and CPU string | vector flags | JVM | lane-ops/ns at 128 / 256 / 512 | control | 512:256 | source | |---|---|---|---|---|---|---|---| -| Intel Xeon Platinum 8573C | `xeon8573c`, `INTEL(R) XEON(R) PLATINUM 8573C` | full `avx512` set | `UseAVX=3`, `MaxVectorSize=64` | two readings: 34.5-35.7 / 68.8-70.8 / 93.7-96.3 (fifteen files, 3 to 22 November 2026); 41.5 / 82.7 / 113.0 (one file, 3 November) | 1.98 to 2.00 in the files; 2.00 to 2.03 in Varka's runs | 1.36 to 1.37 in the files; 1.34 to 1.36 in Varka's runs | Varka, `VARKA-62.md` 11.9, 4 runs (the control and 512:256 ranges of Varka's runs); the files named under "The 8573C's two readings" below; the string from vecbricks/varka's fork runs 41465323581, 41255932044 and 41241977271 (the owner's fork of apache/spark) | +| Intel Xeon Platinum 8573C | `xeon8573c`, `INTEL(R) XEON(R) PLATINUM 8573C` | full `avx512` set | `UseAVX=3`, `MaxVectorSize=64` | two readings: 34.5-35.7 / 68.8-70.8 / 93.7-96.3 (nineteen files, 3 to 22 November 2026); 41.5 / 82.7 / 113.0 (one file, 3 November) | 1.98 to 2.00 in the files; 2.00 to 2.03 in Varka's runs | 1.36 to 1.37 in the files; 1.34 to 1.36 in Varka's runs | Varka, `VARKA-62.md` 11.9, 4 runs (the control and 512:256 ranges of Varka's runs); the files named under "The 8573C's two readings" below; the string from vecbricks/varka's fork runs 41465323581, 41255932044 and 41241977271 (the owner's fork of apache/spark) | | Intel Xeon 6973P-C (Granite Rapids) | `xeon6973p`, `Intel(R) Xeon(R) 6973P-C` | full `avx512` set | `UseAVX=3`, `MaxVectorSize=64` | see source | 2.00 to 2.01 | 1.33 to 1.35 | Varka, `VARKA-62.md` 11.9, 2 runs; the string from vfdlibm run 41442062308 | | AMD EPYC 9V45 (Zen 5) | `epyc9v45`, `AMD EPYC 9V45 96-Core Processor` | full `avx512` set | `UseAVX=3`, `MaxVectorSize=64` | see source | 2.04 | 1.99 | Varka, `VARKA-62.md` 11.9, 1 run; the string from Varka's fork runs 41486339971, 41446843041 and 41329377429 | | AMD EPYC 7763 (Zen 3) | `epyc7763`, `AMD EPYC 7763 64-Core Processor` | `avx2`, no `avx512` | `UseAVX=2`, `MaxVectorSize=32` | 45.0-46.5 / 90.0-92.6 / 90.0-92.6 | 1.99 to 2.01 | 1.00 | Varka, `VARKA-62.md` 11.9, 8 runs; the lane rates, a range, from 16 Varka fork runs, 31 October to 2 November 2026 (41236071283 to 41460150392); the string from `bench/results/exp-epyc7763-2026-11-02.txt` and `log-epyc7763-2026-11-02.txt`; `exp-epyc7763-2026-11-20.txt` reads 46.2 / 92.2 / 92.5 (control 2.00, 512:256 1.00) in its first run and 46.3 / 92.4 / 92.4 in its second, inside the range | @@ -74,19 +74,20 @@ it, none is claimed, and whether the ports' arms should differ on Arm waits for ### The 8573C's two readings -Fifteen of the sixteen files of this host read 34.5 to 35.7 lane-ops/ns at 128 bits, 68.8 to 70.8 -at 256 and 93.7 to 96.3 at 512: `exp-onediv-xeon8573c-2026-11-03.txt` (34.7 / 68.8 / 94.1, control +Nineteen of the twenty files of this host read 34.5 to 35.7 lane-ops/ns at 128 bits, 68.8 to 70.8 at +256 and 93.7 to 96.3 at 512: `exp-onediv-xeon8573c-2026-11-03.txt` (34.7 / 68.8 / 94.1, control 1.98, 512:256 1.37), `expm1-xeon8573c-2026-11-04.txt` (34.8 / 69.2 / 94.1, 1.99, 1.36), the nine files of 21 November, from two runs: `exp-xeon8573c-2026-11-21.txt` and its five siblings (34.5 / -69.1 / 93.7, 2.00, 1.36) and `sinh-`, `cosh-` and `cosh-kinds-xeon8573c-2026-11-21.txt` (34.9 / -69.9 / 94.8, 2.00, 1.36), and the four of 22 November, `asin-xeon8573c-2026-11-22.txt` and its -three siblings (35.7 / 70.8 / 96.3, 1.98, 1.36, and 34.6 / 69.1 / 93.8, 2.00, 1.36 for the second -run in `atan2-xeon8573c-2026-11-22.txt`). `log1p-xeon8573c-2026-11-03.txt`, of the same -day as the pair, reads 41.5 / 82.7 / 113.0 (1.99, 1.37), and its scalar `StrictMath` loop reads -7,358 ns on common data where the `log1p` file of 21 November reads 8,846. Each file's header says -which it ran on; no cause for the difference is claimed here. The 25 nightly draws of this CPU in -"What the pool gives" below read 34.5 to 41.7, 68.9 to 83.2 and 93.6 to 113.0 at the three -widths. +69.1 / 93.7, 2.00, 1.36) and `sinh-`, `cosh-` and `cosh-kinds-xeon8573c-2026-11-21.txt` (34.9 / 69.9 +/ 94.8, 2.00, 1.36), and the eight of 22 November, from two runs: `asin-xeon8573c-2026-11-22.txt` +and its three siblings (35.7 / 70.8 / 96.3, 1.98, 1.36), and run 45082534869's `expm1-`, `log-`, +`log10-` and `log1p-xeon8573c-2026-11-22.txt` with the second run in +`atan2-xeon8573c-2026-11-22.txt` (34.6 / 69.1 / 93.8, 2.00, 1.36). `log1p-xeon8573c-2026-11-03.txt`, +of the same day as the pair, reads 41.5 / 82.7 / 113.0 (1.99, 1.37), and its scalar `StrictMath` +loop reads 7,358 ns on common data where the `log1p` file of 21 November reads 8,846. Each file's +header says which it ran on; no cause for the difference is claimed here. The 25 nightly draws of +this CPU in "What the pool gives" below read 34.5 to 41.7, 68.9 to 83.2 and 93.6 to 113.0 at the +three widths. The two Xeons are the AVX-512 hosts results wait for and are read first; their 512:256 of about 1.35 means a 512-bit arm can win there, but not by the factor of two its lane count suggests. diff --git a/PLAN.md b/PLAN.md index c2d0a7a..872c220 100644 --- a/PLAN.md +++ b/PLAN.md @@ -154,20 +154,24 @@ five are a later, optional set; the large-argument reduction of the trigonometri out of both rules; a later run's `*Max` rows time today's finish. On the other rows no function needs rule 2 yet, so `VFdlibm` runs one arm at every species. Every default stays provisional until a host run revises it. Meanwhile `VFdlibm` calls the finish arm of `exp`, `log` and `log10`; - the guarded arm of `expm1` and `log1p`, by the owner's deferral of rule 1 until the 8573C's second - run (issue #30, 21 November); the slice arm of `cosh`, provisionally, as the rule's exception, - whose arm a host run decides ([issue #30's - comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7091848602)): on - `CoshBenchmark`'s common data the EPYC 7763's two runs read the finish arm lower, near 1.3x - (`bench/results/cosh-epyc7763-2026-11-21.txt`); on `CoshKindsBench` the finish arm reads lower at - 3.5% of small lanes and the slice arm at 17%, inside 1.3x on both hosts; the Xeon 8573C has one - cosh run (`cosh-xeon8573c-2026-11-21.txt`), and a re-run is dispatched; and the guarded arm of - `atan2`, which has no finish arm, - so rule 1 does not pick between its two ([issue #30's corrected + the guarded arm of `expm1` and `log1p`, by the owner's deferral of rule 1 (issue #30, 21 November) + until a second run, on the 8573C, of the code the 22 November files time (those files are the + first run of it); the slice arm of `cosh`, provisionally, as the rule's exception, whose arm a + host run decides ([issue #30's + comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7091848602); its readings are + under the list); and the guarded arm of `atan2`, which has no finish arm, so rule 1 does not pick + between its two ([issue #30's corrected comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7085437272)). Each host has timed atan2's arms in a run and a re-run (`atan2-xeon8573c-2026-11-22.txt`, `atan2-epyc7763-2026-11-22.txt`), and neither file gives them a direction, so guarded stays the default at every species by the owner's decision of 22 November. + cosh's readings, by minimums: on `CoshBenchmark` the EPYC 7763's two runs agree, outside 1.3x, on + the finish arm lower on common data (slice over finish 1.33 to 1.37), a direction, and give no + direction on mixed data (`bench/results/cosh-epyc7763-2026-11-21.txt`); on `CoshKindsBench` the + finish arm reads lower outside 1.3x with no small lane (1.46 to 1.70 on both hosts), lower inside + 1.3x at 3.5% of small lanes, and the slice arm lower inside 1.3x at 17% + (`cosh-kinds-epyc7763-2026-11-21.txt`, `cosh-kinds-xeon8573c-2026-11-21.txt`). The Xeon 8573C has + one `CoshBenchmark` run (`cosh-xeon8573c-2026-11-21.txt`); a second run decides. ## 6. Rules diff --git a/README.md b/README.md index ce8391f..1b0682d 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,8 @@ fdlibm's own sequence of operations, lane by lane. That is this library. hosts disagree the files say so. The rules are set (issue #30): a tie within 1.3x on every host that has a file goes to the finish arm, except for `cosh`, whose arm a host run decides, and where hosts disagree each species keeps its own arm (no function needs that yet). `expm1` and `log1p` - stay on their guarded arm by the owner's deferral of the rule until the 8573C's second run. The + stay on their guarded arm by the owner's deferral of the rule until a second run, on the 8573C, of + the code its files of 22 November time. The `*Max` rows of the host files of 3 to 21 November for `exp`, `expm1`, `log`, `log10` and `log1p` (`exp-onediv-xeon8573c-2026-11-03.txt` and those of 20 and 21 November; `log1p-xeon8573c-2026-11-03.txt` and `expm1-xeon8573c-2026-11-04.txt` have no `*Max` row) time the diff --git a/SKILLS.md b/SKILLS.md index 7b4809f..21db6d3 100644 --- a/SKILLS.md +++ b/SKILLS.md @@ -1112,11 +1112,13 @@ blend and 10 to 23 instructions. At 128 bits the bodies are 8 to 16 times longer kept. The slice arm stays the default, provisionally, as the named exception to issue #30's tie rule (its per-lane set is not rare, so a host run decides; [issue #30's comment](https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7091848602)). The readings, - by minimums: on `CoshBenchmark`'s common data the EPYC 7763's two runs read the finish arm lower, - near 1.3x (`bench/results/cosh-epyc7763-2026-11-21.txt`); on `CoshKindsBench` the finish arm reads - lower at 3.5% of small lanes and the slice arm at 17%, inside 1.3x on both hosts - (`cosh-kinds-epyc7763-2026-11-21.txt`, `cosh-kinds-xeon8573c-2026-11-21.txt`). The Xeon 8573C has - one cosh run (`cosh-xeon8573c-2026-11-21.txt`), and a re-run is dispatched. + by minimums: on `CoshBenchmark` the EPYC 7763's two runs agree, outside 1.3x, on the finish arm + lower on common data (slice over finish 1.33 to 1.37), a direction, and give no direction on mixed + data (`bench/results/cosh-epyc7763-2026-11-21.txt`); on `CoshKindsBench` the finish arm reads + lower outside 1.3x with no small lane (1.46 to 1.70 on both hosts), lower inside 1.3x at 3.5% of + small lanes, and the slice arm lower inside 1.3x at 17% (`cosh-kinds-epyc7763-2026-11-21.txt`, + `cosh-kinds-xeon8573c-2026-11-21.txt`). The Xeon 8573C has one `CoshBenchmark` run + (`cosh-xeon8573c-2026-11-21.txt`); a second run decides. - **Which exp faults reach cosh.** `exp.dropCorrection` and `exp.constantOffByOneUlp`, which change `expCore`'s lanes of `|x| >= 0.5 ln2`. `exp.thresholdMoved` moves the subnormal scale-back, which `expCore` leaves out, and `exp.dropKForcing` the lanes of the word of 0.5 diff --git a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java index dc5524b..7cc2841 100644 --- a/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java +++ b/src/main/java/io/github/vecbricks/vfdlibm/Cosh.java @@ -84,12 +84,14 @@ * arm, provisionally, as the named exception to issue #30's tie rule: its per-lane set is not rare, * so a host run decides its arm (issue #30, * https://github.com/vecbricks/vfdlibm/issues/30#issuecomment-7091848602). The readings, by - * minimums: on {@code CoshBenchmark}'s common data the EPYC 7763's two runs read the finish arm - * lower, near 1.3x ({@code bench/results/cosh-epyc7763-2026-11-21.txt}); on {@code CoshKindsBench} - * the finish arm reads lower at 3.5% of small lanes and the slice arm at 17%, inside 1.3x on both - * hosts ({@code cosh-kinds-epyc7763-2026-11-21.txt}, {@code cosh-kinds-xeon8573c-2026-11-21.txt}). - * The Xeon 8573C has one cosh run ({@code cosh-xeon8573c-2026-11-21.txt}), and a re-run is - * dispatched. The default is chosen in {@code cosh(x, + * minimums: on {@code CoshBenchmark} the EPYC 7763's two runs agree, outside 1.3x, on the finish + * arm lower on common data (slice over finish 1.33 to 1.37), a direction, and give no direction on + * mixed data ({@code bench/results/cosh-epyc7763-2026-11-21.txt}); on {@code CoshKindsBench} the + * finish arm reads lower outside 1.3x with no small lane (1.46 to 1.70 on both hosts), lower inside + * 1.3x at 3.5% of small lanes, and the slice arm lower inside 1.3x at 17% ({@code + * cosh-kinds-epyc7763-2026-11-21.txt}, {@code cosh-kinds-xeon8573c-2026-11-21.txt}). The Xeon 8573C + * has one {@code CoshBenchmark} run ({@code cosh-xeon8573c-2026-11-21.txt}); a second run decides. + * The default is chosen in {@code cosh(x, * live)}; other places say "the default arm". */ final class Cosh {