interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / ng / bench / PAYOFF.md

326 lines · 23042 bytes Raw Blame History Source

PAYOFF: which compiler passes buy the most speed (M3 payoff map, lane ng-bench)

Question (omp-queen-ng, 2026-11-07T11:31:44Z): for the 13 baseline kernels, why is omc slower than gcc -O2, and which missing compiler passes would close the most of that gap, ranked by expected geometric-mean gain per core type.

Method in one paragraph: omc's own binary of each kernel was edited by hand into a ladder of arms, each rung adding what one pass would emit (hand/*.spec, written by hand.om, every word checked against objdump, every arm's output checked against the kernel's referee hash). The ladders were timed with ngbench v2 on one X925 core and one A725 core under the pre-registration PREREG-payoff.md (commit b5f46745, posted 11:54:28Z before any timing row). A step factor is a rung's time over the time of the rung below it on the same block; below 1 means faster. Kernels without a hand ladder: fib38/fib40 cite the plan-breaker v2 round; sha and chacha are MODELED from an instruction census (section 5). Every statistic and every number derived from the rows was computed by Wolfram; queries and results are in evidence/20261107T1155Z-payoff/.

Status words: the step factors are CHIP_TESTED, one Spark, core 9 (X925) and core 11 (A725), these frozen inputs, these hand-built arms. They are not QUALIFIED and not NG output: the arms show what a pass is worth when it is done perfectly by hand on the hot loop, an upper bound for what NG's pass can earn on the same code.

The answer, in plain words

Ranked by expected geometric-mean gain over the 13 baseline kernels (1.10 means the 13 kernels together run 10% faster when that one pass is added and nothing else changes). Every arm is judged against the same-round A/A copy ngA (a byte-identical copy of omc timed in the same blocks), and each rung against the rung below it. "Measured" uses only timed hand arms and the cited fib round; "with MODELED" adds the sha and chacha estimates of section 5. Both rounds ran beside GPU training and CPU model jobs (section 2). The A/A controls pass on all 9 cases on both cores, so neither round is marked CONTAMINATED under the queen's rule; that does not clear them of memory-bandwidth contention, which slows both A/A copies alike (section 2). The rounds are not contention-cleared.

rankX925 (core 9)gain measuredwith MODELEDA725 (core 11)gain measuredwith MODELED
1VEC1.23671.2367LICM+ROT1.21161.2214
2CALL1.17411.1745VEC1.19711.1971
3LICM+ROT1.14011.1418BCE1.10911.1276
4DIV1.08821.0882DIV1.07551.0755
5REC1.08041.0804REC1.06981.0698
6BCE1.02371.0268CALL1.06351.0656
7INL1.01381.0138ISEL1.02511.0251
8IFC1.00861.0086IFC1.02101.0210
9ISEL1.00751.0075INL1.01561.0156

All passes together, measured and MODELED factors combined: 2.062 (X925) and 2.149 (A725). The baseline gap omc/gcc -O2 was 2.846 and 2.920, so the nine passes, done perfectly, close about half the gap in time terms and leave omc 1.380 (X925) and 1.359 (A725) times slower than gcc -O2 by geometric mean (Wolfram, wolfram-summary-*). Measured factors only (sha and chacha at 1): 2.052 (X925) and 2.092 (A725), residual gap 1.387 and 1.395 (WolframLanguageEvaluator: the wolfram-rank-ngA-query.wl definitions, then N[gm[Flatten[Table[meas[P], {P, passes}]]]] -> 2.052417168399068 (X925), 2.0924839475506367 (A725); {N[2.846/2.052417168399068, 4], N[2.920/2.0924839475506367, 4]} -> {1.387, 1.395}).

Idle-machine rerun R2 (2026-11-07, PREREG-slice.md, evidence evidence/20261107T1416Z-r2/)

The same 20 hand arms, fixture and protocol, rerun with ngbench v3 only when no GPU window was held or waiting and no ollm process existed anywhere on the machine, checked at start inside the pool lock, before and after every case of every block (busy count 0 in all 306 block-case pairs on each core) and at the end. X925 16:55:45Z to 17:01:52Z, A725 17:58:47Z to 18:11:59Z. A/A passes on all 9 cases on both cores; no case is CONTENDED (clean blocks 31 of 31 on X925, at least 30 of 31 on A725, 6 pairs dropped for a foreign runnable task on core 11). Other CPU jobs did run on the machine (load 7.8 to 14.2 at the X925 start and end, 4.3 and 4.2 for the A725; cluster-*.txt); the busy count does not see them.

Result: on both cores every one of the 40 step factors' R2 interval overlaps its first-round interval (30 of the 40 R2 medians lie inside the first-round interval; the 10 that do not are listed in STEP-COMPARE.md), and the ranking order is unchanged on both cores. The first round's ranking stands.

rankX925 (core 9)gain measuredwith MODELEDA725 (core 11)gain measuredwith MODELED
1VEC1.23861.2386LICM+ROT1.21141.2211
2CALL1.17431.1747VEC1.19341.1934
3LICM+ROT1.14311.1448BCE1.11021.1285
4DIV1.08851.0885DIV1.07581.0758
5REC1.08041.0804REC1.06981.0698
6BCE1.02301.0260CALL1.06361.0656
7INL1.01341.0134ISEL1.02391.0239
8IFC1.00861.0086IFC1.02161.0216
9ISEL1.00741.0074INL1.01611.0161

All passes together, measured and MODELED factors combined (hand-edit upper bounds, not NG output): 2.0695 (X925) and 2.1436 (A725); the residual gap to gcc -O2 is then 1.375 and 1.362 (WolframLanguageEvaluator: {N[2.846/2.0695054771976467, 4], N[2.920/2.143593256476995, 4]} -> {1.3752077640566664, 1.3621987245840814}). Measured factors only: 2.0597 (X925) and 2.0881 (A725), first round 2.0524 and 2.0925 (wolfram-allmeasured-*, the rank query ending in N[gm[Flatten[Table[meas[P], {P, passes}]]]]). One verdict moved, on the A725: LICM+ROT on arith is now NO DIFFERENCE (1.0044, interval 0.9913 to 1.0169; it was SLOWER); BCE on linear stays SLOWER. Each R1/R2 step factor pair with its interval is in evidence/20261107T1416Z-r2/STEP-COMPARE.md.

The contention sign of the first round is gone on the X925: omc/gcc -O2 over the baseline round is 1.0036 by geometric mean (first round 0.9878; bcopy 1.0105, was 0.9644). On the A725 it went the other way (0.9710; bcopy 0.8186, branch 0.9516): gcc -O2's short runs there were bimodal in R2 (bcopy's second run of a block often 27 ms against 18 ms), while omc's long runs did not move. gcc-referenced A725 numbers from R2 carry that noise; the step factors do not use gcc.

What it means for NG:

  1. The two core types want different passes first. The big X925 core already hides most of the cost of omc's extra instructions (its out-of-order window absorbs rebuilt constants and bounds checks): one removed loop instruction is worth e = 0.12 of its share of the time there, against e = 0.63 on the A725 (section 5). On the X925 the wins come from work the core cannot hide: whole calls (CALL, leafcall 0.363), one byte at a time (VEC, bcopy 0.063), a slow divide (DIV, arith 0.333). On the A725 plain instruction removal (LICM+ROT, BCE) pays almost as much as those.
  2. LICM+ROT is the safest first pass: it is in the top three on both cores and applies to 8 of the 13 kernels.
  3. VEC's score comes from one kernel (bcopy, 16 bytes per pass); it is large because omc copies one byte at a time. chacha's XOR step has the same shape and is not in the score.
  4. CALL on the X925 is three measurements that agree (leafcall 0.363, fib40 0.578, fib38 0.591); on the A725 the fib38 arm is the plan-breaker's placement case (1.087), which drags CALL down to sixth there.
  5. Some passes cost time where the loop is waiting on one long chain of dependent work rather than on the number of instructions (section 4). A compiler that removes instructions without watching code placement will see a few percent lost there.

1. Where the time goes: omc's hot loops against gcc -O2

Instructions per pass of the hot loop, from objdump -D -b binary -m aarch64 of omc's binary (cfd96b48 and 5f90edea emit the same bytes) and objdump -d of the baseline gcc -O2 binary. "Loop body" is the static size from the loop head to its back branch, both included; loops with a forward branch inside (branch, the Collatz step) count both sides.

kernelomcngLngBtop runggcc -O2what omc spends the difference on
bcopy18 per byte117ngV 9 per 16 bytes6 per 16 bytes (NEON)3 bounds checks (6), the 10^6 while bound counter (3), limit constant rebuilt each pass (MOV+MOVK), top test plus back branch, one byte per pass
arith1711(no BCE rung)ngM 1414UDIV+MSUB for % 1000003 where gcc multiplies by the reciprocal (UMULH); 5 constants rebuilt per pass
branch18 inner, 31 outer12 / 24(counter kept)ngC 11 / 227, branchless CSINCCollatz step as branches; CSET/AND boolean lowering; constants rebuilt
isort28 inner147about 6, inlined2 bounds checks per access pair, rebuilt limits, top test plus back branch
sort24 inner147same pattern as isort
leafcall27 per call plus the calleengR 8, ngI 8about 5, inlinedper-call frame, stack check, 5 STR + 5 LDR of live values around the call
matmul22 inner139about 72 checks, rebuilt 2400-byte stride and limits; the column walk is memory-bound in both
sieve19 per mark94about 4check, counter, rebuilt limit 2000000
linear201713ngF 11f32 load as LDR W + FMOV + FCVT; checks per pass; the FADD chain sets the floor

sha and chacha are straight-line after omc's unroll; their executed instructions per 64-byte block, by class (MODELED inputs, section 5):

kernelinstructions per blockconstant rebuild (LICM)bounds checks (BCE)spill, reload around calls (CALL)register copies
sha3650 = s256 1299 + r256 2279 + block loop 72913652592 (r256 renames 9 per round)
chacha6871 = 10 x dround 486 + block 646 + xor step 1320 + run 45107219021781

2. What else was running, and the controls

The rounds shared the machine with GPU training legs (ownmodel own1-leg23, leg24, leg25: ollm-gb10 gtrain4), CPU model jobs (wsp ollm train, ownmodel-gates6 ollm serve on ports 18291/18292, wsp wpolicy), listed per round with times and sources in evidence/20261107T1155Z-payoff/OVERLAP.md. They were seen only on other cores in the cluster snapshots at round start and end. The per-block scans (one before and one after each case in each block, not continuous) found a foreign runnable task on the timed core 3 times on X925 and 12 times on A725; those flag 3 and 11 (block, case) pairs, of which 2 and 9 fall in measured blocks (the others are warm-up blocks 0 to 2, never in the statistics) and were dropped as contaminated. All of the jobs share memory bandwidth and the system-level cache, which ngbench's per-core scan cannot see; the A725 round also had a CPU-bound ollm on core 19 of its own cluster.

What protects the ratios: every block runs all arms of a case back to back in a palindrome (ABBA), so a slow minute slows every arm of that block together, and the A/A copy measures what is left. Same-round A/A, ngA/omc, clean-block median [95% interval] (Wolfram, {x925,a725}/wolfram-ngA-*; the rule passes when the interval contains 1 or the median lies in [0.99, 1.01]):

kernelX925 ngA/omcA725 ngA/omc
bcopy1.0005 [0.9991, 1.0015]1.0004 [0.9993, 1.0140]
arith1.0000 [0.9951, 1.0011]0.9997 [0.9945, 1.0045]
branch1.0003 [0.9977, 1.0016]0.9992 [0.9913, 1.0152]
isort0.9992 [0.9970, 1.0026]1.0002 [0.9978, 1.0082]
sort0.9995 [0.9902, 1.0008]1.0002 [0.9917, 1.0077]
leafcall0.9999 [0.9985, 1.0011]1.0004 [0.9982, 1.0013]
matmul0.9969 [0.9867, 1.0035]1.0006 [0.9919, 1.0084]
sieve0.9997 [0.9969, 1.0019]0.9989 [0.9948, 1.0056]
linear0.9995 [0.9985, 1.0004]0.9996 [0.9851, 1.0060]

All 18 pass, so neither round is CONTAMINATED under the rule. This check has a blind spot: ngA and omc are the same bytes, so a load that steals memory bandwidth slows both equally and the A/A ratio stays at 1. Contention can still bias steps between arms that use memory differently. A second check: omc/gcc -O2 in this round over the same ratio in the baseline round (20261107T0830Z, clean medians), Wolfram geometric mean 0.9878 on X925 and 0.9943 on A725:

kernelX925 this/baselineA725 this/baseline
bcopy0.96440.9800
arith0.99110.9955
branch0.99250.9962
isort0.99221.0015
sort1.00130.9980
leafcall0.99050.9923
matmul0.98720.9875
sieve0.97610.9989
linear0.99510.9994

The largest moves are bcopy (0.964 on X925, 0.980 on A725) and sieve on X925 (0.976): those are the kernels that move the most memory, and gcc's arm lost ground against omc's, which fits bandwidth contention slowing the faster arm more. The pass step factors are taken within one round and one block, so this shift does not enter them directly, but bcopy's VEC factor and the X925 bcopy steps (whose intervals are wide: LICM+ROT [0.674, 0.793], BCE [0.665, 0.780]) are the numbers most exposed to it. The bcopy and sieve shifts are evidence that contention was present. A rerun of the top ranks with the GPU line and the ollm jobs idle would settle how much it moved them.

3. Measured step factors

Clean-block median [95% interval], n = 31 blocks less the contaminated ones (stats-wall-ngA.tsv and stats-wall.tsv, Wolfram queries wolfram-ngA-query.wl and wolfram-wall-query.wl). First rungs are judged against the same-round A/A copy ngA; later rungs against the rung below. Below 1 is faster.

kernelpassratioX925 (core 9)A725 (core 11)
bcopyLICM+ROTngL/ngA0.6846 [0.6739, 0.7932]0.7414 [0.7367, 0.7493]
bcopyBCEngB/ngL0.7719 [0.6647, 0.7798]0.6116 [0.6064, 0.6125]
bcopyVECngV/ngB0.0632 [0.0623, 0.0648]0.0964 [0.0955, 0.0979]
arithLICM+ROTngL/ngA0.9964 [0.9950, 0.9968]1.0175 [1.0094, 1.0405]
arithDIVngM/ngL0.3333 [0.3317, 0.3344]0.3882 [0.3854, 0.3917]
branchLICM+ROTngL/ngA0.9374 [0.9359, 0.9405]0.6003 [0.5895, 0.6030]
branchIFCngC/ngL0.8952 [0.8939, 0.8981]0.7630 [0.7470, 0.7696]
isortLICM+ROTngL/ngA0.6837 [0.6825, 0.6865]0.6140 [0.6063, 0.6229]
isortBCEngB/ngL0.9775 [0.9748, 0.9795]0.7144 [0.7056, 0.7209]
sortLICM+ROTngL/ngA0.6818 [0.6802, 0.6853]0.7314 [0.7240, 0.7356]
sortBCEngB/ngL0.9809 [0.9796, 0.9817]0.6993 [0.6974, 0.7023]
leafcallCALLngR/ngA0.3634 [0.3618, 0.3653]0.4655 [0.4635, 0.4673]
leafcallINLngI/ngR0.8369 [0.8320, 0.8456]0.8173 [0.8146, 0.8206]
matmulLICM+ROTngL/ngA0.7611 [0.7511, 0.7807]0.6926 [0.6904, 0.6971]
matmulBCEngB/ngL1.0346 [1.0156, 1.0457]0.8812 [0.8768, 0.8847]
sieveLICM+ROTngL/ngA0.7826 [0.7777, 0.7888]0.6774 [0.6693, 0.6801]
sieveBCEngB/ngL0.9747 [0.9663, 0.9803]0.8698 [0.8636, 0.8849]
linearLICM+ROTngL/ngA1.0246 [1.0223, 1.0262]0.8646 [0.8616, 0.8690]
linearBCEngB/ngL0.9875 [0.9862, 0.9889]1.1109 [1.1039, 1.1145]
linearISELngF/ngB0.9077 [0.9047, 0.9092]0.7249 [0.7225, 0.7356]

Where each kernel ends up (clean medians): ngA (= omc) over gcc -O2, the top rung against ngA, the top rung against gcc -O2.

kernelX925 ngA/gcctop rungX925 top/ngAX925 top/gccA725 ngA/gccA725 top/ngAA725 top/gcc
bcopy28.9690ngV0.03300.981029.60300.04371.2930
arith3.4092ngM0.33111.12942.55480.39481.0070
branch1.8485ngC0.83921.55243.36630.44981.5145
isort1.9640ngB0.66861.31222.71560.43951.1963
sort2.7135ngB0.66841.81362.43410.51111.2321
leafcall3.3651ngI0.30531.02512.76410.38121.0511
matmul1.6434ngB0.79421.30592.22290.60971.3529
sieve2.0183ngB0.76271.54532.47950.58941.4614
linear1.2396ngF0.91741.13901.82230.69771.2707

leafcall with CALL+INL and bcopy with VEC reach gcc -O2 (within 5% on X925: 1.025 and 0.981). The loops that stay 1.3 to 1.8 times slower than gcc after their ladder (sort, sieve, branch, matmul on X925) still run more instructions per pass than gcc's (section 1: rungs stop at 4 to 13, gcc's loops are about 4 to 7, branch's Collatz step is branchless CSINC in gcc). Which gcc transformations make up that rest was not taken apart in this round.

4. Steps that were slower, and why that matters

Four of the 40 step factors are above 1 with their whole interval:

corekernelstepfactorwhat the loop waits on
X925linearLICM+ROT (ngL/ngA)1.0246the FADD chain (each sum waits for the previous one)
X925matmulBCE (ngB/ngL)1.0346the 2400-byte column stride (memory)
A725arithLICM+ROT (ngL/ngA)1.0175the UDIV chain (one divide per pass)
A725linearBCE (ngB/ngL)1.1109the FADD chain

All four are loops bound by one long chain (a divide, a floating-point add, or a cache miss per pass), where the number of other instructions matters little, as pre-registered for matmul and linear. Removing instructions also moves the loop's head and its branch to new addresses; the plan-breaker D arm already showed that placement alone moves fib38 by 18% on the A725. These factors are kept as measured and enter the ranking as they are. The smallest experiment that would separate placement from the pass: one control arm per case with omc's own loop moved to the rung's loop address (same instructions, new placement), timed in the same blocks.

5. sha and chacha: MODELED, not measured

Both are straight-line after omc unrolls them, so a hand ladder would mean rewriting thousands of words; the pre-registered model is used instead. Inputs:

What the model cannot see: the 592 register copies in sha's rounds (9 per round, the a..h rotation that a register allocator renames away) belong to no measured pass; both cores eliminate many moves at rename, so their worth is not estimated here. chacha's 64-byte XOR step would also vectorise (VEC); only bcopy measures VEC, and its loop is the same shape, so it is reported as an analogy, not folded into the ranking.

Results (Wolfram, {x925,a725}/wolfram-rank-ngA-*):

X925A725
e(core) = median of (1 - step) / f over 14 measured LICM+ROT and BCE steps0.12050.6288
sha LICM+ROT (p = 0.0025)0.99970.9984
sha BCE (p = 0.0373)0.99550.9766
sha CALL (p = 0.0142)0.99830.9910
chacha LICM+ROT (p = 0.1560)0.98120.9019
chacha BCE (p = 0.2768)0.96670.8259
chacha CALL (p = 0.0259)0.99690.9837

The per-step values of (1 - step) / f range from -0.47 to 1.20 (the four slower steps give the negative ones), so e is a rough central value; the modeled factors are MODELED, not measured, and move the ranking only for BCE on the A725 (1.109 to 1.128).

6. fib38 and fib40 (cited, not re-measured)

From evidence/20261107T0830Z-planbreaker-v2/RESULTS.md, clean medians: ngA (CALL: callee-saved registers instead of omc's spills) over omc X925 0.578 (fib40) and 0.591 (fib38), A725 0.888 and 1.087; ngE (the second recursive call turned into a loop, named REC here) over omc X925 0.350 and 0.357, A725 0.633 and 0.634. In the ranking CALL uses ngA/omc and REC uses (ngE/omc) / (ngA/omc), a quotient of two cited medians, not a per-block step. The A725 fib38 CALL factor above 1 is a placement effect (ngD, the same code with fib aligned to 64 bytes, is 0.816 of ngA there).

7. Validity

8. Receipts