nx_native_rmsnorm_long_bench.nx source
↩ module page · 47 lines · 1217 B
1// nx_native_rmsnorm_long_bench.nx -- LONG RMSNorm bench for Stabilizer.
2//
3// Original 2048 x 5000 iter version (nx_native_rmsnorm_bench.nx) ran
4// ~0.06s gcc-O0 and the paired Stabilizer found CI 0.65-6.17x (no
5// defensible signal, gcc -O0 noise floor 61% on this workload).
6// Scaling to 4096 x 50000 = 200x ops; target ~3-5s gcc-O0, ~10-15s
7// Nishi. Should clear noise floor decisively.
8
9import "nx_syscalls.nx"
10const K_MAGIC_4096: i64 = 4096
11const K_MAGIC_50000: i64 = 50000
12
13func main() -> i64 {
14 let N: i64 = K_MAGIC_4096
15 let ITERS: i64 = K_MAGIC_50000
16
17 let buf: *u8 = sys_mmap(N * 8)
18 let x: *i64 = buf as *i64
19
20 var k: i64 = 0
21 while k < N {
22 x[k] = (k * 31 + 5) & 1023
23 k = k + 1
24 }
25
26 var checksum: i64 = 0
27 var iter: i64 = 0
28 while iter < ITERS {
29 var ss: i64 = 0
30 var i: i64 = 0
31 while i < N {
32 ss = ss + x[i] * x[i]
33 i = i + 1
34 }
35 let scale: i64 = (ss / N) >> 4
36 var s: i64 = 0
37 var j: i64 = 0
38 while j < N {
39 s = s + ((x[j] * scale) >> 10)
40 j = j + 1
41 }
42 checksum = checksum + (s & 255)
43 iter = iter + 1
44 }
45
46 return checksum
47}