code wiki / (root) / nx_conv2d_mt_gate.nx

nx_conv2d_mt_gate.nx

buildroot/runtime/nx_conv2d_mt_gate.nx

8620 B266 linesdepth 8pulls 14 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_conv2d_mt_gate.nx -- adversarial gate for the multi-threaded conv2d forward (nx_conv2d_forward_mt / nx_conv2d_forward_pool) against the serial oracle nx_conv2d_forward. The MT path is an INDEPENDENT implementation of the same math (organ policy: the serial path was left untouched), so full-buffer bit-exact comparison here is a real two-implementation oracle, not a self-comparison. Checks (10): 1 serial oracle runs OK on the small shape 2..6 MT bit-exact vs serial for nworkers in {1, 2, 3, 0=auto, 1000=clamped-past-row-count}; output poisoned before each run so unwritten rows cannot pass 7 no-bias variant bit-exact (nworkers=3) 8..9 caller-owned pool reused across two calls (second call has different input contents) -- proves the completed-counter DELTA wait, both bit-exact 10 speedup on a big shape (1x64x128x128, C_out=64), auto workers: bit-exact AND wall-time speedup >= floor Small shape uses prime-ish dims (H=17, W=13, C_out=5) so any stride or band-boundary bug lands off-pattern and fails the compare. genealogy_id: substrate_conv2d_v1_direct + nx_conv_speedup_banding lineage_id: conv2d_mt_gate_v1

dependencies 2 imports · 0 importers

nx_conv2d.nx nx_fmt.nx nx_conv2d_mt_gate.nx

imports: nx_conv2d.nxnx_fmt.nx

imported by: nobody (leaf or entry point)

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

main g_t4 nx_t_alloc nx_dt_is_valid nx_dt_element_bytes sys_mmap nx_t_compute_strides_rowma g_fill g_lcg g_fill_small g_lcg ↻ nx_conv2d_forward nx_t_is_contiguous fmt_puts fmt_puts_fd sys_write fmt_putn fmt_putn_fd sys_write ↻ g_nl fmt_puts ↻ g_poison nx_conv2d_forward_mt nx_hw_worker_count nx_hw_cpu_count sys_mmap ↻ sys_munmap nx_conv2d_forward ↻ 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_conv2d_forward_pool

structs

none

consts

33const GT_N: i64 = 2
34const GT_CIN: i64 = 3
35const GT_COUT: i64 = 5
36const GT_H: i64 = 17
37const GT_W: i64 = 13
40const GB_CIN: i64 = 64
41const GB_COUT: i64 = 64
42const GB_H: i64 = 128
43const GB_W: i64 = 128
50const GATE_SPEEDUP_FLOOR_X100: i64 = 200

functions

52func g_lcg(s: i64) -> i64
called by 2: g_fillg_fill_small
60func g_fill(p: *i64, count: i64, seed: i64) -> i64
called by 1: main calls 1: g_lcg
72func g_fill_small(p: *i64, count: i64, seed: i64) -> i64
called by 1: main calls 1: g_lcg
85func g_poison(p: *i64, count: i64) -> i64
called by 1: main
95func g_same(a: *i64, b: *i64, count: i64) -> i64
called by 1: main
104func g_t4(d0: i64, d1: i64, d2: i64, d3: i64, err: *nx_int) -> *NxTensor
called by 1: main calls 1: nx_t_alloc
110func g_nl() -> i64
called by 1: main calls 1: fmt_puts
115func main() -> i64