Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/ng/bench/PREREG-payoff.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / bench / PREREG-payoff.md` 132 lines · 8598 bytes Raw Blame History Rendered 1 # PREREG: the M3 payoff map, hand-edited pass arms (lane ng-bench) 2 3 Committed and posted on the BOARD before any timing row of this round. Task: omp-queen-ng 2026-11-07T11:31:44Z 4 ("for each of the 13 kernels, read omc's disassembly vs gcc -O2 and attribute the gap to causes, with a 5 measured estimate where a hand-edited binary can test it"). Base: Radicle main ``da8b7e66``. The harness, 6 metric, interval and clean-block rule are the ones of `PREREG.md` and `PREREG-contamination.md`, unchanged. 7 8 ## What is measured 9 10 For 9 kernels, omc's own binary is edited by hand into a ladder of arms, each rung adding one compiler pass 11 (or one bundle, named below) to the rung before it. Each rung is what that pass would emit on this code; the 12 edit touches only the hot function or loop, everything else is omc's bytes. A rung's step factor is the time 13 of the rung over the time of the rung below it, on the same block. The arms are models of passes, built by 14 hand; they are not NG output. 15 16 | kernel | ladder (rung = previous + pass) | pass names used in the ranking | 17 |---|---|---| 18 | bcopy | omc, ngL, ngB, ngV | LICM+ROT, BCE, VEC | 19 | arith | omc, ngL, ngM | LICM+ROT, DIV | 20 | branch | omc, ngL, ngC | LICM+ROT, IFC | 21 | isort | omc, ngL, ngB | LICM+ROT, BCE | 22 | sort | omc, ngL, ngB | LICM+ROT, BCE | 23 | matmul | omc, ngL, ngB | LICM+ROT, BCE | 24 | sieve | omc, ngL, ngB | LICM+ROT, BCE | 25 | linear | omc, ngL, ngB, ngF | LICM+ROT, BCE, ISEL | 26 | leafcall | omc, ngR, ngI | CALL, INL | 27 28 Pass meanings (the spec files in `hand/` state, per kernel, exactly what each rung changes and why it is legal): 29 30 - LICM+ROT: constants, limits and array bases computed once before the loop instead of every pass; every loop 31 tested at the bottom (one branch per pass); immediates folded into CMP/TST/ADD forms; boolean conditions 32 lowered to branches instead of CSET/AND (`and` operands here are side-effect free). Bounds checks and `while` 33 iteration-bound counters are kept. 34 - BCE: bounds checks and `while` iteration-bound counters removed where a range argument (stated in the spec) 35 proves they cannot fire; for `linear`, the per-iteration checks become one range check before the loop. 36 - VEC: 16 bytes per pass with SIMD (LDR Q, REV64+EXT, EOR, STR Q). 37 - DIV: remainder by a constant through a multiply by its reciprocal (UMULH); the constant is gcc's. 38 - IFC: if-conversion, both Collatz branches and the max update become CSEL. 39 - CALL: register allocation across the call (no per-call frame, stack check, spill and reload). 40 - INL: the callee inlined. 41 - ISEL: f32 loads straight into FP registers (LDR S) instead of LDR W + FMOV. 42 43 Control arm `ngA` on every kernel: a byte-identical copy of omc's binary (A/A control, judged like `gccO2aa` in 44 PREREG.md rule 2: its interval against omc contains 1 or its median lies in [0.99, 1.01]). 45 Context arm `gccO2`: the baseline gcc -O2 binary. 46 47 ## Arms and binaries 48 49 Built by `seed/ng/bench/hand.om` (this commit; compiled by `seed/out/omc` sha256 ``cfd96b48`…0d8a` to `hand` 50 sha256 ``f352309bee8789f37cb494f604042ba20dc695174cd9dfef2c742aa6de41a9d3``) from three inputs per arm: 51 52 1. `hand/K-V.spec`: the edit (directives `@old` check omc's original words, `@at`, `@word`, `@nop`), one 53 instruction per case line with the expected disassembly after `|`. 54 2. `hand/K-V.words`: the instruction words, encoded by the ng-a64 lane's encoder `ng a64-enc` (omega-mv 55 ng/a64-m2 ``9c1bc18c2ed270010ac687cda9182436e66f192d``, `seed/ng/src/{ir,a64,main}.om`, built by omc 56 `cfd96b48` to `ng` sha256 ``7221cc0d4a622db74975418bf5cace5789995516259cf77768c7b186e578a510``). Words the 57 encoder has no form for (the 6 SIMD words of bcopy-V) are literal `@word` lines. 58 3. omc's binary of the kernel (`seed/out/omc` `cfd96b48` and the baseline's `5f90edea` emit identical bytes for 59 all 9 kernels). 60 61 `hand splice SPEC WORDS IN OUT` writes the arm; `objdump -D -b binary -m aarch64 --adjust-vma=0x400000 OUT | 62 hand check SPEC` must pass (every written word's disassembly equals the spec's text; objdump is the referee); 63 the arm's stdout must have the kernel's `kernels/want/K.sha256`. All 20 arms pass all three (smoke on core 1, 64 not a timing). The 47 binaries of the round, with their sha256, are `hand/payoff-manifest.sha256`. 65 66 ## Round 67 68 Fixture DIR `/tmp/ngb/payrun`: `bin/ARM/CASE` as in the manifest, `want/` copied from `kernels/want/`. 69 One invocation per core, ngbench v2 (binary sha256 ``ba6351527ef844836776dbaff44b782c5957225f35a172205ae4d77904ff0200``): 70 71 `ngbench run 31 3 DIR omc ngA ngL ngB ngV ngM ngC ngR ngI ngF gccO2 -- bcopy arith branch isort sort leafcall matmul sieve linear` 72 73 | round | core | prefix | 74 |---|---|---| 75 | X925 | 9 | `flock -x -w 3600 ~/handoffs/hive/queen/pool-8-9.lock taskset -c 9 nice -n 10` | 76 | A725 | 11 | `flock -x -w 3600 ~/handoffs/hive/queen/pool-10-11.lock taskset -c 11 nice -n 10` | 77 78 Absent arm/case pairs are skipped by ngbench. Start/end records as in PREREG.md. Rows go to 79 `evidence/-payoff/{x925,a725}/rows.txt`, unedited. 80 81 ## Metric and statistics (fixed now) 82 83 Per block b, case c: r(X/Y, b) = (sum of X's two walls) / (sum of Y's two walls). Reported: median and the 84 distribution-free 95% interval [r(k), r(n+1-k)] (PREREG.md; n = 31 gives k = 10), on all measured blocks and on 85 the clean blocks (PREREG-contamination.md; the verdict uses the clean blocks when at least 21 remain). 86 87 Per case and core: every rung against omc, every rung against the rung below it (the step factor), every rung 88 against gccO2, ngA/omc. 89 90 Ranking, per core type: for pass P, the measured step factors s(P, k) on the kernels where P has a rung; for every 91 other of the 13 baseline kernels the factor is 1. Expected geomean gain of P = 1 / (product over the 13 kernels of 92 s(P, k))^(1/13). Passes are ranked by it. Step factors depend on the ladder order (BCE is measured after 93 LICM+ROT); that order is part of the result. 94 95 ## Kernels without a hand ladder in this round 96 97 - fib38, fib40: the measured plan-breaker v2 round (`evidence/20261107T0830Z-planbreaker-v2/RESULTS.md`) is cited: 98 ngA = CALL (callee-saved convention), ngD = CALL+ALIGN, ngE = CALL + the second recursive call as a loop. 99 - sha, chacha (and x25519, which has no C referee and is outside the 13): MODELED, labelled so. Method fixed 100 now: classify every instruction of the hot function in omc's disassembly into the categories a pass removes 101 (bounds-check compare/branch and its limit constant: BCE; constant and address rematerialisation: LICM; 102 per-call spill/reload, frame and stack check: CALL), take the fraction p(P) of the hot function's executed 103 instructions that P removes, and model the step factor as 1 - e(core) p(P), where e(core) is the median, over 104 the measured LICM+ROT and BCE steps of this round, of (1 - step factor) / (fraction of the loop's executed 105 instructions that step removed). The removed fractions come from the instruction counts per loop pass in 106 the specs and omc's disassembly. All arithmetic in Wolfram. 107 108 ## Decision rules 109 110 - Validity: PREREG.md rules 1, 3, 4; contamination rules of PREREG-contamination.md. A round with any `fail` or 111 `refused` row is invalid. 112 - A/A: more than 1 of the 9 `ngA/omc` controls failing flags the round NOISY; it is rerun once and both are kept. 113 - A rung is faster than the rung below if its step interval's upper end is below 1; slower if the lower end is 114 above 1; otherwise no difference is detected (its factor still enters the geomean, marked). 115 - Status words: the step factors are CHIP_TESTED on the core type measured, for these frozen inputs and these 116 hand-built arms. They are not QUALIFIED (no held-out run: the arms are input-specific binaries) and they are 117 not NG results. 118 119 ## Expectations, stated before the round 120 121 From the instruction counts per loop pass (omc vs each rung), every rung is expected to be faster than the rung 122 below on both cores, with two exceptions where no difference is plausible: matmul (2400-byte column stride, 123 expected to be memory-bound) and linear ngF (the loop is bound by the FADD latency chain). The core-1 smoke 124 runs of bcopy were seen while building (omc 964 ms, ngL 720, ngB 272, ngV 42, gccO2 31 ms on a shared core); 125 they are not evidence. 126 127 ## Known limits 128 129 - Hand arms change code placement as well as instruction count; the plan-breaker D arm showed placement alone 130 moving fib38 by 18% on A725. Arms of one kernel are edited in place at omc's address, except arith, whose 131 rungs are both rebuilt at a 64-byte-aligned loop head past the end of the file (the M rung does not fit). 132 - One machine, two core types, time only (no counters: `perf_event_paranoid` = 4).