interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / native / nvml / README.md

75 lines · 4660 bytes Raw Blame History Rendered
1<!-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -->
2# native/nvml: the Omega side of the CUDA++ NVML subset
3
4Two pure Omega units carry RM request/reply policy and error-string encoding.
5`api.om` is the C ABI library unit: call orchestration, transport dispatch, copy
6bounds, handle mapping, the string cache and the process lock. The omega-bridge#83
7emitter generates `compat/nvml/` from it; see `compat/nvml/README.md`.
8
9| Unit | Sources (composed in this order, each followed by a newline) | Export |
10| --- | --- | --- |
11| `nvml_step` | `nvml.om`, `query.om`, `step.om` | `omega_nvml_step(result, s[128 ulong], b[83296 uchar])` |
12| `nvml_errstr` | `errstr.om` | `omega_nvml_errstr(result, code, o[64 uchar])` |
13
14`om/units.sh` lowers both through omega-bridge (`bridge-seeded`, pinned
15omc e5b32567) into the committed `src/cudapp_om_nvml_step.c` and
16`src/cudapp_om_nvml_errstr.c`; their prototypes are in `src/cudapp_native.h`
17and their identities in `src/cudapp_om_nvml_*.ident` and
18`src/cudapp_om_units.ident`. Never edit the generated C; edit the `.om` and
19rerun `om/units.sh`. `tests/nvml/gate.om` refuses a stale generated file.
20
21## The step protocol
22
23A pure unit cannot touch the OS, so `nvml_step` is a resumable state machine.
24`api.om` stores the op (s0) and its arguments (s1..s4), then loops:
25
261. call `omega_nvml_step`;
272. if s8 asks for an action (1 ioctl, 2 open, 3 close), perform exactly that
28 action through `omega2_nvrm_ioctl`, `omega2_nvrm_open_file` or
29 `omega2_nvrm_close_file` (`native/nvrm/transport.om`, aien-dev/CUDApp#281)
30 with the fd, nr, header length and params length the step chose, write the
31 transport result into s14 and its omega2 status into s15;
323. stop when s8 is 0; s6 is the `nvmlReturn_t`, s7 the output bytes at OO, s5
33 the scalar output and s27 whether to store it.
34
35The full slot map is the header comment of `nvml.om`. Transport results are a
36`long` carried as its two's-complement bits in a ulong (−1 is 2^64−1).
37
38## What each op asks the resource manager
39
40All layouts are cited in the sources to open-gpu-kernel-modules 580.173.02
41(commit 20e4e6e1), `src/common/sdk/nvidia/inc`.
42
43| NVML call | RM traffic |
44| --- | --- |
45| `nvmlInit_v2` (op 1) | open `/dev/nvidiactl`; `NV_ESC_CARD_INFO` (nr 200); root client (`NV01_ROOT_CLIENT`, nr 43); per GPU: `GET_ID_INFO_V2` (0x205), open `/dev/nvidia<minor>`, `NV_ESC_REGISTER_FD` (nr 201), device (0x80) and subdevice (0x2080) alloc, `CLASSLIST_V2` (0x800292) to find `BLACKWELL_COMPUTE_B` (0xCEC0). Reference counted. |
46| `nvmlShutdown` (op 2) | last reference only: free subdevices, devices, the root client; close every fd. |
47| `GetName` (op 5) | `GPU_GET_NAME_STRING` (0x20800110), ASCII flavour. |
48| `GetUUID` (op 6) | `GPU_GET_GID_INFO` (0x2080014a), binary SHA-1 form, printed `GPU-8-4-4-4-12`. |
49| `GetTemperature` (op 7) | two `THERMAL_SYSTEM_EXECUTE_V2` (0x20800513) passes: enumerate targets and sensors, then read the first sensor on a GPU-type target. |
50| `GetMemoryInfo` (op 8) | `FB_GET_INFO_V2` (0x20801303): TOTAL_RAM_SIZE, HEAP_FREE (KiB), IS_ZERO_FB (NOT_SUPPORTED when set). |
51| `GetUtilizationRates` (op 9) | `PERF_GET_GPUMON_PERFMON_UTIL_SAMPLES_V2` (0x20802096): newest sample of the 72-entry ring. |
52| `GetComputeRunningProcesses_v3` (op 10) | `GPU_GET_PIDS` (0x2080018d) for class 0xCEC0, then `GPU_GET_PID_INFO` (0x2080018e) in chunks of at most 200 for video-memory usage. |
53
54Error policy (`nvml.om`): an omega2 status other than 0 is UNKNOWN; ioctl
55EPERM/EACCES is NO_PERMISSION, other errnos UNKNOWN; open ENOENT/ENXIO/ENODEV
56is DRIVER_NOT_LOADED; RM status 0x1B is NO_PERMISSION, 0x0F GPU_IS_LOST,
570x56 NOT_SUPPORTED, anything else UNKNOWN. A failed `nvmlInit_v2` tears down
58everything it opened and leaves the refcount at 0.
59
60## Known limits
61
62- At most 8 GPUs; more is UNKNOWN at init.
63- `GetUtilizationRates` sends 55888 bytes of params. The pinned omc e5b32567
64 bounds program-mode `devcall` at 16383 bytes; whether the lowered #281
65 transport can carry this control is NOT_RUN (live RM is not authorized). The
66 program-mode `cudapp-smi` needs aien-dev/omega-mv#1048 for the same control.
67- A trap inside the teardown after a failed init can leave descriptors open;
68 the library then reports UNKNOWN.
69- Live resource-manager behavior is NOT_RUN: every test runs against
70 `tests/nvml/rmfake.om`.
71
72Constants: `evidence/NVML-2026-11-06/wolfram.txt`. Tests: `tests/nvml/gate.om`
73(`make test-nvml`). The 476 checks run twice: in `tests/nvml/host.om`, a pure
74Omega port of the protocol, and through the generated `libnvidia-ml.so.1` with
75the C caller `tests/nvml/nvml_test.c`; both against the fake transport.