code wiki / _hdl_build / nx_nv.nx

nx_nv.nx

buildroot/runtime/_hdl_build/nx_nv.nx

2527 B37 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_nv.nx -- the native-Linux NVIDIA OPEN-KERNEL-MODULE device shim (TIER-1 sovereign executor), sibling to nx_dxg (the WSL2 GPU-PV shim). This is the path that ACTUALLY EXECUTES on real silicon -- modeled on tinygrad's ops_nv.py, which submits via /dev/nvidia* + a GPFIFO ring + a usermode doorbell, bypassing the CUDA runtime (and bypassing the proprietary dxg priv-data handshake that walls WSL2). Runs on a native-Linux / rented cloud GPU instance (brick-safe, rule #26). LOCALLY-VERIFIABLE (gated bit-exact here): the GPFIFO entry encoder + the doorbell offset. CLOUD-PENDING (structured, completed against the instance's open-gpu-kernel-modules headers on first run): the full RM-API object tree -- NV_ESC_RM_ALLOC on /dev/nvidiactl for root client -> device -> subdevice -> channel-group -> GPFIFO channel (NV_CHANNELGPFIFO_ALLOCATION_PARAMETERS) -> compute object; NV_ESC_RM_CONTROL for GPFIFO_SCHEDULE + GET_WORK_SUBMIT_TOKEN; NV_ESC_RM_MAP_MEMORY for the usermode doorbell BAR. Pure funcs, no main. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_nv.nx nx_nv_gate.nx

imports: nx_syscalls.nx

imported by: nx_nv_gate.nx

structs

none

consts

17const NV_ESC_RM_ALLOC: i64 = 0x2b
18const NV_ESC_RM_CONTROL: i64 = 0x2a
19const NV_ESC_RM_MAP_MEMORY: i64 = 0x4e
21const NV_DOORBELL_OFF: i64 = 0x90

functions

23func nv_open_ctl() -> i64 { return sys_openat_rd("/dev/nvidiactl" as *u8) }
called by 1: main calls 1: sys_openat_rd
24func nv_open_dev() -> i64 { return sys_openat_rd("/dev/nvidia0" as *u8) }
calls 1: sys_openat_rd
25func nv_open_uvm() -> i64 { return sys_openat_rd("/dev/nvidia-uvm" as *u8) }
calls 1: sys_openat_rd
30func nv_gpfifo_entry(gpu_va: i64, len_dwords: i64) -> i64 { return ((gpu_va >> 2) << 2) | (len_dwords << 42) | (1 << 41) }
called by 1: main
33func nv_doorbell_ring(mmio_base: i64, token: i64) -> i64