code wiki / _hdl_build / nx_gpu_sync.nx
nx_gpu_sync.nx
buildroot/runtime/_hdl_build/nx_gpu_sync.nx
about
nx_gpu_sync.nx -- the sovereign GPU FENCE over the dxg door (gpu GP7, the fence half of "fences and barriers").
A monotonic timeline fence the CPU can signal and wait on, as ONE composed primitive over the nx_dxg shim:
gpu_sync_fence creates a MONITORED_FENCE sync object on the device, signals it to 1 and then to 2, and waits
for 2 -- a round trip that only completes when the signals advanced the real fence. It returns 0 on the
round trip, a NEGATIVE code naming the stage that refused, and leaves the sync-object handle in outso[0] so
a caller that wants the fence for real work keeps it.
PROVENANCE: the ABI and the round-trip were measured LIVE on the RTX 5080 by the R4g candidate gate
(_offc/cand__gpu_dxg_syncobj_gate, size-swept ioctl codes, type-99 refused, three tampers rejected) and sat
unpromoted for weeks. Folded here so the estate has ONE fence primitive and ONE gate over it
(nx_gpu_sync_gate). The BARRIER half of GP7 (a barrier a recorded list carries between a write and a read)
is NOT here: it needs a command list the dxg door can execute, which the raw channel cannot carry without
a vendor UMD (gpu.plan GP5 lesson row, 2026-09-02). This file is the fence; the board says which half.
SCOPE: /dev/dxg only (WSL2 GPU-PV). No third party in the run path: raw ioctls through nx_syscalls.
license_tier: ORIGINAL No hw writes (Rule 26): sync objects are per-process kernel state, never persistent.
dependencies 2 imports · 3 importers
imports: nx_syscalls.nxnx_dxg.nx
imported by: nx_gpu_mem.nxnx_gpu_mem_gate.nxnx_gpu_sync_gate.nx
structs
| none |
consts
| 20 | const GS_ERR_CREATE: i64 = 0 - 1 // the create ioctl refused or returned no object |
| 21 | const GS_ERR_SIGNAL1: i64 = 0 - 2 // the first CPU signal refused |
| 22 | const GS_ERR_SIGNAL2: i64 = 0 - 3 // the second CPU signal refused |
| 23 | const GS_ERR_WAIT: i64 = 0 - 4 // the synchronous wait did not complete cleanly |
| 24 | const GS_FENCE_STEP1: i64 = 1 |
| 25 | const GS_FENCE_STEP2: i64 = 2 |
| 40 | const GS_ERR_ENUM: i64 = 0 - 11 |
| 41 | const GS_ERR_NODISC: i64 = 0 - 12 |
| 42 | const GS_ERR_OPEN: i64 = 0 - 13 |
| 43 | const GS_ERR_DEVICE: i64 = 0 - 14 |
| 44 | const GS_ADAPTER_ROW: i64 = 20 |
| 45 | const GS_QTYPE_FLAGS: i64 = 15 |
functions
| 28 | func gpu_sync_fence(fd: i64, device: i64, outso: *i64, outfva: *i64) -> i64 |
| 47 | func gpu_sync_open(fd: i64, outah: *i64, outdev: *i64) -> i64 called by 2: maingpu_sync_device calls 7: sys_mmapdxg_enumsys_munmapdxg_rd32dxg_query_typedxg_open_from_luid+1 |
| 76 | func gpu_sync_device(fd: i64, outdev: *i64) -> i64 |