Skip to content

noun: migrate lagoon jet to stateless SoftBLAS (64-bit)#1022

Open
sigilante wants to merge 4 commits into
ml/64from
neal/lagoon-softblas-64
Open

noun: migrate lagoon jet to stateless SoftBLAS (64-bit)#1022
sigilante wants to merge 4 commits into
ml/64from
neal/lagoon-softblas-64

Conversation

@sigilante

Copy link
Copy Markdown
Collaborator

Summary

Migrates the 64-bit lagoon jet to the current SoftBLAS API, on top of ml/64.

  • Bump ext/softblas to 40ff4fa — allocation-free / stateless rewrite (per-call rndMode replacing the global softblas_roundingMode; B1–B5 correctness fixes). Drop the deleted src/softblas_state.c from the wrapper.
  • Update pkg/noun/jets/i/lagoon.c 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 (avoids colliding with softblas.h's new inline). Preserves the 64-bit calling convention — the braced u3r_mean {sample, &ptr} pairs and syz_x+1 byte handling.

The jet also picks up the recent numerics correctness fixes the 64-bit copy was missing (mod round-the-quotient, _get_dims leak, range/bloq guards, argmin/argmax index). Source tracks numerics lagoon/vere64; see urbit/numerics#37.

Testing

Built on ml/64 with zig 0.15.2. Booted a fake ~tex, verified add/dot/mmul/mod produce correct values, and the full lagoon test suite passes — all 9 suites, ok=%.y.

🤖 Generated with Claude Code

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>
@sigilante sigilante requested a review from a team as a code owner May 31, 2026 12:30
@matthew-levan

Copy link
Copy Markdown
Contributor

LGTM, will wait for #1021 before merging this one.

sigilante and others added 2 commits June 1, 2026 10:01
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants