code wiki / _hdl_build / nx_race_native.nx
nx_race_native.nx
buildroot/runtime/_hdl_build/nx_race_native.nx
about
nx_race_native.nx -- "OURS" in the cross-language RACE: the SAME workload as the IR program, compiled
SOVEREIGN (nx_cc -> nxasm_x86, no gcc) and run as a direct native loop. Timed head-to-head vs the
exported C/JS/Python/Perl/Java versions. The answer must match the Nishi IR-interpreted truth and every
exported language (correctness); wall-time shows where our output sits vs mainstream toolchains.
license_tier: ORIGINAL
⚠⚠HEADER CORRECTED 2026-08-14 -- IT DESCRIBED A DIFFERENT PROGRAM THAN THE ONE BELOW, THREE WAYS:
it claimed the workload was "sum of i for 1..120,000,000"; the code runs a 50,000,000-iteration LEHMER
step, not a sum; and the quoted answer 200000010000000 is the sum 1..20,000,000 (n(n+1)/2), matching
NEITHER. For a benchmark whose entire claim is that every language runs THE SAME WORKLOAD, a stale
header is not cosmetic: anyone porting from the comment implements a different program and the race
silently compares two workloads.
★★★A CROSS-LANGUAGE BENCHMARK'S HEADER IS PART OF ITS CONTRACT, AND A CONTRACT THAT DISAGREES WITH THE
CODE IS WORSE THAN NO CONTRACT -- THE READER TRUSTS IT PRECISELY BECAUSE IT IS SPECIFIC.
★THE CORRECT ANSWER, MEASURED 2026-08-14 BY RUNNING IT: 668950819 (seed h=1, RN_ITERS Lehmer steps).
The old header quoted 200000010000000, which is the sum 1..20,000,000 and matches nothing this program
computes. A stated answer is the ONLY part of a cross-language contract a port can actually check
itself against, so a wrong one is worse than none: it certifies a mismatched port as correct.
⚠OWED: the exported C/JS/Python/Perl/Java ports must be read to confirm they run THIS loop (same
multiplier, same modulus, same iteration count) and produce 668950819. Until that is checked the
race's comparability is asserted, not proven -- and this header is no longer the evidence for it.
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 27 | const RN_ITERS: i64 = 50000000 // loop count -- shared with every exported port |
| 28 | const RN_MINSTD_MULT: i64 = 48271 // Park-Miller revised multiplier |
| 29 | const RN_MINSTD_MOD: i64 = 2147483647 // 2^31 - 1, Mersenne prime modulus |
functions
| 30 | func putn(v: i64) -> i64 |
| 43 | func main() -> i64 |