Skip to content

noun: Lagoon %int2 comparison + reduction array jets - #1048

Open
sigilante wants to merge 1 commit into
sigilante/twoc-jetsfrom
sigilante/twoc-int2-cmp-reduce
Open

sigilante wants to merge 1 commit into
sigilante/twoc-jetsfrom
sigilante/twoc-int2-cmp-reduce

Conversation

@sigilante

@sigilante sigilante commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1047. Hoon/master side: urbit/numerics#67.

Extends the Lagoon array jets with %int2 cases beside %i754 for the comparison and reduction ops (no GEMM):

  • gth/gte/lth/lte — per-lane signed (two's-complement) compare → 1/0 ray.
  • cumsum — full wrapping sum → scalar ray.
  • dot — sum of products (wrapping) → scalar ray.
  • min/max — extremum by two's-complement order → scalar ray.
  • argmin/argmax — forward ravel-index of the first extremum (bare index).

Native per lane (8…128-bit, no GMP); signed compares reinterpret the lane as the matching signed C type. Scalar reductions box via a _la_scalar_box helper = +scalar-to-ray's shape (all-1s of the input rank).

Also fixes the i754 reduction-jet result shape (carries urbit/numerics#68 into the runtime): cumsum/min/max/dot shared the same _la_scalar_box helper, replacing the prior hardcoded ~[1 1]/~[len 1]/~[1] that only matched one rank — a silent jet/Hoon mismatch on the boxed meta. trace (always rank-2) and diag (returns a vector) are correct as-is.

Verified jet == numerics Hoon on a hoon-135 fakezod across native widths incl. 128-bit, ties, and negatives — for both %int2 and (now) %i754 reductions.

🤖 Generated with Claude Code

Adds the %int2 (signed two's-complement) element-wise comparison
(gth/gte/lth/lte) and reduction (cumsum/dot/min/max/argmin/argmax) array
jets, on top of the twoc scalar jets, rebased onto #1057.

- The %int2 cases slot into #1057's rewritten comparison and reduction
  wrappers; the dot case is added to #1057's restructured +dot wrapper
  (its unifying-equality-safe field reads made the auto-merge miss it).
- All the new _la_int2_* helpers and the wrapper int2 results are typed
  u3_weak (they decline with u3_none); _la_int2_box, which transfers its
  r_data into the boxed ray, is annotated `@Refcount: transfers `r_data``
  so the reduction wrappers do not read as leaking it (refcount linter,
  #1059).
- The reduction result shape is the all-ones-of-rank +scalar-to-ray box,
  matching #1057's i754 _ones_shape; #1048's separate i754 reduction-
  shape fix is already carried by #1057, so only the %int2 additions
  land here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rqqco86RgnvtiC4axw8Px3
@sigilante
sigilante force-pushed the sigilante/twoc-int2-cmp-reduce branch from 2a00167 to ead7273 Compare September 12, 2026 04:27
@sigilante

Copy link
Copy Markdown
Collaborator Author

Rebased onto #1047 (base retargeted to sigilante/twoc-jets), so this PR is now just the %int2 comparison/reduction commit. The %int2 cases (gth/gte/lth/lte, cumsum/dot/min/max/argmin/argmax) slot into #1057's rewritten comparison and reduction wrappers; the +dot case was added by hand to #1057's restructured (unifying-equality-safe) dot wrapper, which the auto-merge could not place. All _la_int2_* helpers and int2 wrapper results are typed u3_weak; _la_int2_box (which transfers r_data into the boxed ray) carries @Refcount: transfers r_data`` so the reduction wrappers do not read as leaking it (refcount linter, #1059).

#1048's separate i754 reduction-shape fix is dropped — #1057 already boxes those with the all-ones-of-rank +scalar-to-ray shape (_ones_shape), which the %int2 box matches.

Verification: builds clean at both loom widths (-Werror); linter reports 0 findings on lagoon.c (strict-weak). lagoon-int2 (5 arms: modular wrap, signed div/rem, abs, comparison convention, cumsum) and twoc (13 arms) run green jetted for both binaries. Merge order: #1057, then #1047, then this.

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.

1 participant