math: jet-anchor @rd exp + vere jet mirror#63
Open
sigilante wants to merge 4 commits into
Open
Conversation
Wrap math.hoon's width doors in a %math engine DOOR under the shared %non chapter (=< math preserves the /+ math + rd:math API), mirroring /lib/lagoon's %non/%lagoon jet structure, with ~/ hints on the rd door and exp arm. The engine MUST be a door (^| =+ [rnd] ~/ %math |%): a sample-less ~/-core anchors its parent to the dashboard root, so the jet never attaches (found by tracing _cj_hot_mean in the runtime). Mirror the vere-side C jet into libmath/vere/ (jets/i/math.c + tree-registration.snippet.c + README) for hand-maintained cross-repo sync -- the runtime jets live in urbit/vere (PR to follow). Add libmath/tools/rd_exp_check.c, the SoftFloat-f64 reference proving the jet is bit-exact to the Hoon. @rd exp verified jetted (34us vs ~970us interpreted), bit-exact 0x4005.bf0a.8b14.576a. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add @rd log as the second jetted transcendental, and refactor the vere master (libmath/vere/jets/i/math.c) so the SoftFloat algorithm cores (_rd_exp, _rd_log) are shared between the runtime jet and a standalone bit-exact harness (libmath/vere/test/, via -DMATH_JET_HARNESS) -- the C the test runs is byte-for-byte the C the jet runs, so they can't drift. log transcribes math.hoon ++rd ++log (2^e*m reduction + degree-9 atanh Horner); ~/ %log hint added. Verified bit-exact to the Hoon incl the subnormal and sqrt(2)-boundary branches, and jetted on-ship (log:rd:math .~2 = 0x3fe6.2e42.fefa.39ef). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-ship) Finish the @rd jet port begun with exp/log: add faithful softfloat cores + u3 wrappers for sin/cos/tan/atan/atan2/asin/acos/sqt/cbt/pow/pow-n/log-2/log-10, each transcribing its Hoon arm's exact reduction/coefficients/Horner order so jet output is bit-identical to the pure-Hoon reference, not merely faithful. - math.hoon: ~/ hints on all 15 @rd arms under the %math door anchor. - jets/i/math.c: 15 algorithm cores shared with the harness via -DMATH_JET_HARNESS, plus u3 ABI wrappers. Fix the 2-arg wrappers (atan2/pow/pow-n) to use brace-enclosed u3r_mean pairs {axis,&ptr} — the flat form failed -Werror=missing-braces and never compiled. - test/rd_check.c: add emit2() + atan2/pow/pow-n vectors. - test/verify_clean.sh: one-query-at-a-time on-ship diff, NO C-c. (SIGINT mid-event corrupts the loom; the old verify.sh's C-c spam was crashing the serf and masquerading as a jet bug.) Verified bit-exact on a fresh fakeship: 234/234 vectors, 0 DIFF (198 single-arg via verify_clean.sh, 36 two-arg via gen/m2.hoon in one event). sin x 200k under %bout = 431ms (~2.1us/call) confirms jetting. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mirror /lib/lagoon's layout: maintain both runtimes' vendored jet files under
libmath/, in noun/jets/ form. The two math.c copies differ by exactly two lines
-- the two-arg u3r_mean form (brace-pair {axis,&p} on 64-bit vere-ml64 vs flat
varargs on 32-bit vere), because that macro's API diverged between the runtimes.
Everything else (15 algorithm cores, 12 single-arg wrappers, helpers) is
byte-identical: marshalling is chub-based and word-size-agnostic.
- libmath/vere/ noun/jets/{i/math.c,135/tree.c,q.h,w.h} -- 32-bit
- libmath/vere64/ noun/jets/{i/math.c,135/tree.c,q.h,w.h} -- 64-bit (+ test/)
Both built and verified bit-exact: full -test suite (math-exp/log/sqrt/ainv/
atan/tan/trig/derived) passes ok=%.y on a jetted 32-bit AND 64-bit fakeship,
plus the standalone harness's 234 single+two-arg vectors. Vendor 135 only (the
stock test ships' hoon-version; apply to 136/137 only if a target needs them).
Drop the now-redundant tree-registration.snippet.c (the full vendored tree.c
plus the rewritten README supersede it). README documents the 2-line divergence,
per-word-size apply steps, the door-anchor gotcha, -test verification, and the
SIGINT-corrupts-the-loom warning.
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.
First slice of the transcendental jetting effort: wire the first jetted
math.hoonarm (@rd exp) and establish the structure + cross-repo mirror therest will follow.
The Hoon transcendentals themselves already merged; this PR adds only the
jet-anchoring structure and the vere-side mirror. (math.hoon's large diff
is almost entirely the
++ mathre-indent — review with whitespace hidden; thesubstantive change is ~18 lines.)
What changed
libmath/desk/lib/math.hoon— wrap the width doors in a%mathenginedoor under the shared
%nonchapter, mirroring/lib/lagoon's%non/%lagoonjet structure.=< mathkeeps the/+ math+rd:math/~(exp rd:math [%n rtol])API unchanged.~/hints on therddoor andexparm.
libmath/vere/(new) — hand-maintained mirror of the runtime jet code(
jets/i/math.c, thetree.cregistration snippet, README). The jets live inurbit/verepkg/noun; a matching PR there will follow.libmath/tools/rd_exp_check.c(new) — SoftFloat-f64 reference that provesthe jet is bit-exact to the Hoon (not merely faithful).
The gotcha (documented in the README)
A
~/-hinted engine core must be a door (^| =+ [rnd] ~/ %math |%), not abare
|%: a sample-less~/-core anchors its parent to the dashboard root,so
%mathand everything under it miss the hot dashboard — the core registersbut no C jet ever attaches. Found by tracing
_cj_hot_meanin the runtime(
math par=0 MISS→math par=non FOUNDonce it's a door).Verified
exp:rd:math .~1→0x4005.bf0a.8b14.576a(bit-exact), 34 µs jetted vs~970 µs interpreted; the rest of math.hoon (other fns/widths, the rounding-mode
door idiom) unchanged.
Follow-on
The remaining 14 fns × 4 widths follow this exact mold (one
u3wi_body + tree.centry + bit-exact harness each), plus the matching
urbit/vereruntime PR.🤖 Generated with Claude Code