noun: migrate lagoon jet to stateless SoftBLAS (64-bit)#1022
Open
sigilante wants to merge 4 commits into
Open
Conversation
Bump ext/softblas to urbit/SoftBLAS 40ff4fa (allocation-free; per-call
rndMode arg replacing the global softblas_roundingMode; B1-B5 fixes) and
drop the deleted src/softblas_state.c from the wrapper.
Update the lagoon jet for the new API: thread the active rounding mode
through all 32 BLAS calls via a file-static _la_rnd, and rename the local
_set_rounding -> _set_rounding_la to avoid colliding with softblas.h's new
inline. Preserves the 64-bit calling convention (braced u3r_mean
{sample,&ptr} pairs) and syz_x+1 byte handling.
Built on ml/64 with zig 0.15.2; booted fake ~tex and the full lagoon test
suite passes (9 suites, ok=%.y). Jet source matches numerics
lagoon/vere64.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
LGTM, will wait for #1021 before merging this one. |
The %mod ray-op (u3qi_la_mod_i754) and mod-scalar (u3qi_la_mods_i754) jets rounded the quotient to nearest (IEEE remainder) and returned the dividend on a zero divisor, diverging from the Hoon +mod, which does C fmod: truncate the quotient toward zero, and returns NaN on a zero divisor or non-finite operand. Truncate the quotient with softfloat_round_minMag, and when the quotient is non-finite (exp bits all 1) overwrite the result with the width's qNaN. Applied to both functions, all four widths (f16/f32/f64/f128). Verified on ~tex (64-bit jet): 5 mod 3 -> 2.0 (was -1.0); 5 mod 0 -> NaN (was 5.0); for f32 and f64, ray-mod and mod-scalar. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sigilante
added a commit
that referenced
this pull request
Jun 9, 2026
The %mod ray-op (u3qi_la_mod_i754) and mod-scalar (u3qi_la_mods_i754) jets rounded the quotient to nearest (IEEE remainder) and returned the dividend on a zero divisor, diverging from the Hoon +mod (C fmod: truncate toward zero; NaN on /0 or a non-finite operand). Truncate the quotient with softfloat_round_minMag, and on a non-finite quotient overwrite the result with the width's qNaN. Both functions, all four widths. The 64-bit variant of this fix (PR #1022) was verified on a live ship. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
u3qeq_sub hardcoded u3i_words(4, e.c) where every other f128 op uses the width constant n. On the 64-bit build c3_w is uint64_t, so a float128 is n=2 words; writing 4 emitted a ~256-bit atom whose high half is stack garbage read past the alloca(16) buffer (the observed 254-bit [operand|difference] result). On 32-bit builds n=4, so the literal was accidentally correct -- which is why only the 64-bit (vere64) build mis-evaluated ~(sub rq ...). Verified on a fresh ~lex booted with the rebuilt 64-bit binary: (met 0 (sub:rq .~~~1.0 .~~~0.877)) now 126 bits (was 254), value .~~~0.123..., matching add/mul and the SoftFloat reference. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Migrates the 64-bit lagoon jet to the current SoftBLAS API, on top of
ml/64.ext/softblasto40ff4fa— allocation-free / stateless rewrite (per-callrndModereplacing the globalsoftblas_roundingMode; B1–B5 correctness fixes). Drop the deletedsrc/softblas_state.cfrom the wrapper.pkg/noun/jets/i/lagoon.cfor the new API: thread the active rounding mode through all 32 BLAS calls via a file-static_la_rnd, and rename the local_set_rounding→_set_rounding_la(avoids colliding withsoftblas.h's new inline). Preserves the 64-bit calling convention — the bracedu3r_mean {sample, &ptr}pairs andsyz_x+1byte handling.The jet also picks up the recent numerics correctness fixes the 64-bit copy was missing (mod round-the-quotient,
_get_dimsleak, range/bloq guards, argmin/argmax index). Source tracks numericslagoon/vere64; see urbit/numerics#37.Testing
Built on
ml/64with zig 0.15.2. Booted a fake~tex, verifiedadd/dot/mmul/modproduce correct values, and the full lagoon test suite passes — all 9 suites,ok=%.y.🤖 Generated with Claude Code