code wiki / (root) / nx_hw_simd_caps_test.nx

nx_hw_simd_caps_test.nx source

↩ module page · 30 lines · 1095 B

1// nx_hw_simd_caps_test.nx -- exercise all 6 probe entry points. 2// 3// Verifies the /proc/cpuinfo probe runs cleanly and returns 4// non-negative results. Doesn't assert specific capabilities -- 5// those depend on the host CPU. 6 7import "nx_kernel_v2.nx" 8import "nx_log.nx" 9import "nx_hw_simd_caps.nx" 10 11// Helper sums all probe results -- routes through non-main helper 12// to dodge the pre-existing static-i64-from-main codegen bug. 13func sum_all_caps() -> i64 { 14 let a2: i64 = nx_hw_has_avx2() 15 let a512: i64 = nx_hw_has_avx512() 16 let sse: i64 = nx_hw_has_sse4_2() 17 let rvv: i64 = nx_hw_has_rvv() 18 let nn: i64 = nx_hw_has_neon() 19 let any: i64 = nx_hw_simd_i64x4_available() 20 return a2 + a512 + sse + rvv + nn + any 21} 22 23func main() -> nx_exit { 24 println("=== nx_hw_simd_caps probe smoke ===" as *u8) 25 let total: i64 = sum_all_caps() 26 if total < 0 { println("FAIL probe < 0" as *u8); return 1 } 27 println("PASS: all 6 probe entries returned non-negative" as *u8) 28 println("(actual flags depend on host CPU; bench just confirms probe works)" as *u8) 29 return 0 30}