code wiki / (root) / nx_parallel_test.nx

nx_parallel_test.nx

buildroot/runtime/nx_parallel_test.nx

3720 B99 linesdepth 8pulls 15 transitivereach 0 importersview sourcekind gate/prooftopic parallel
docsdependenciesstructsconstsfunctions

about

nx_parallel_test.nx -- larger-scale parallel primitive stress. T1: parallel_map of N elements where every input is the counter address; fn FAA-bumps the counter. Functionally equivalent to parallel_for(0, N, bump) but avoids the pre-existing static-i64-from-main codegen bug documented in [[project-nx-threads-bedrock-2026-05-15]] pitfalls. T2: parallel_map: square 4096 elements, verify each. T3: parallel_reduce: sum 1..1000 == 500500.

dependencies 6 imports · 0 importers

nx_kernel_v2.nx nx_log.nx nx_atom.nx nx_thread_pool.nx nx_parallel.nx nx_hw.nx nx_parallel_test.nx

imports: nx_kernel_v2.nxnx_log.nxnx_atom.nxnx_thread_pool.nxnx_parallel.nxnx_hw.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_hw_worker_count nx_hw_cpu_count sys_mmap sys_munmap nx_pool_new nx_hw_worker_count ↻ sys_mmap ↻ nx_chan_new sys_mmap ↻ _nx_chan_cell sys_thread_create nx_thread_spawn sys_mmap ↻ nx_thread_spawn_fn sys_mmap ↻ nx_parallel_map_i64 sys_mmap ↻ nx_atom_load_i64 _nx_chunk_start _nx_chunk_end nx_pool_submit nx_atom_faa_i64 nx_chan_send nx_chan_try_send _nx_chan_cell ↻ nx_thread_yield _pool_futex_wake_all sys_futex_wake nx_atom_load_i64 ↻ nx_parallel_reduce_i64 sys_mmap ↻ nx_atom_load_i64 ↻ _nx_chunk_start ↻ _nx_chunk_end ↻ nx_pool_submit ↻ nx_pool_shutdown nx_atom_faa_i64 ↻ nx_chan_send ↻ _pool_futex_wake_all ↻

structs

none

consts

18const T1_ITERS: i64 = 4000
19const MAP_LEN: i64 = 4096
20const REDUCE_LEN: i64 = 1000 // sum 1..1000 = 1000*1001/2 = 500500

functions

24func bump_via_addr(addr_as_i64: i64) -> i64
calls 1: nx_atom_faa_i64
30func square(x: i64) -> i64 { return x * x }
31func iadd(a: i64, b: i64) -> i64 { return a + b }
33func main() -> nx_exit