code wiki / _hdl_build / nx_gpu_mem.nx
nx_gpu_mem.nx
buildroot/runtime/_hdl_build/nx_gpu_mem.nx
about
nx_gpu_mem.nx -- HEAPS AND RESIDENCY over the dxg door (gpu GP6): allocate, place, make resident, EVICT, with the
budget READ from the device, never assumed. One heap = one EXISTINGHEAP allocation of a page-aligned size,
placed at a GPU virtual address through the paging queue and made resident; eviction is the device's own
EVICT, and the proof that it happened is the device's own paging state (a make-resident after an evict
answers DXG_MKRES_PENDING instead of 0).
SCOPE, stated once: these heaps are SYSTEM-memory backed (the UMD-less EXISTINGHEAP path R4d measured), so they
live in the NON-LOCAL segment; a VRAM (local-segment) heap needs the vendor UMD's private allocation data, the
same blocker class as the command ring (gpu.plan GP5 lesson). Exhausting the non-local budget would exhaust the
host's RAM, so this lib walks a BOUNDED window under the budget and never crosses it; the exhaust-to-evict test on
the local segment is named on the board as owed, not claimed.
license_tier: ORIGINAL No hw writes (Rule 26): per-process allocations, released with the process.
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_dxg.nxnx_gpu_sync.nx
imported by: nx_gpu_mem_gate.nx
structs
| none |
consts
| 17 | const GM_MAX_HEAPS: i64 = 64 |
| 18 | const GM_ERR_BUDGET: i64 = 0 - 21 // the budget query refused |
| 19 | const GM_ERR_ALLOC: i64 = 0 - 22 // an allocation refused or returned no handle |
| 20 | const GM_ERR_MAP: i64 = 0 - 23 // the GPU VA map refused (259 = pending is fine) |
| 21 | const GM_ERR_RES: i64 = 0 - 24 // make-resident refused (259 = pending is fine) |
| 22 | const GM_ERR_EVICT: i64 = 0 - 25 // evict refused |
| 23 | const GM_ERR_TOOMANY: i64 = 0 - 26 // more heaps than the table holds |
functions
| 26 | func gm_table_new() -> *i64 { let t: *i64 = sys_mmap(GM_MAX_HEAPS * 8 * 4) as *i64; return t } |
| 27 | func gm_handle(t: *i64, i: i64) -> i64 { return t[i] } |
| 28 | func gm_va(t: *i64, i: i64) -> i64 { return t[GM_MAX_HEAPS + i] } |
| 29 | func gm_sysmem(t: *i64, i: i64) -> *u8 { return t[GM_MAX_HEAPS * 2 + i] as *u8 } |
| 30 | func gm_bytes(t: *i64, i: i64) -> i64 { return t[GM_MAX_HEAPS * 3 + i] } |
| 33 | func gpu_mem_budget(fd: i64, adapter: i64, group: i64, out: *i64) -> i64 |
| 41 | func gpu_mem_heap(fd: i64, device: i64, pq: i64, t: *i64, i: i64, bytes: i64, mapf: *i64, resf: *i64) -> i64 |
| 58 | func gpu_mem_evict(fd: i64, device: i64, t: *i64, i: i64, outtrim: *i64) -> i64 |
| 65 | func gpu_mem_reresident(fd: i64, pq: i64, t: *i64, i: i64, resf: *i64) -> i64 |