Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/patches/d3a70f94fddc6fc2 # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## compat/nvml: NVML C ABI subset over pure Omega units, rebased on main (DRA-159) merged `d3a70f94fddc6fc2` #365 · opened 2026-11-06 20:40 UTC · closed 2026-11-15 14:36 UTC · merged 2026-11-15 14:36 UTC Imported from GitHub aien-dev/CUDApp#365, by drakestapleton Base `b774723f537cec16a359fe082b8100317a5b5490` · Head `4bf58894d1985d41240736145de7b5fe03e377ee` Merged on GitHub as `4bf58894d1985d41240736145de7b5fe03e377ee`; reachable from main `21d8de285f713adf09e0d6ba6db2b37139d0674e` (observed 2026-11-18T16:38:19Z) drakestapleton wrote on 2026-11-06 20:40 UTC DRA-159 (NVML replacement). Draft. Do not merge before #280 lands. The NVML commits from #305 (`feat/cudapp-nvml`, stacked on #286 smi) rebased onto `main` `b774723f`, so the NVML slice no longer waits on #286. The content matches #305 apart from refreshed crumbs and a new evidence dir `evidence/NVML-2026-11-06/`. #305 can be closed in favour of this PR once Queen decides. ## What moved to Omega - `native/nvml/{nvml,query,step}.om` → pure unit `nvml_step` (argument checks, RM request build/decode, `nvmlReturn_t` mapping, init refcount, teardown). - `native/nvml/errstr.om` → pure unit `nvml_errstr`. - `compat/nvml`: thin libnvidia-ml C ABI shell (pointer/ioctl glue only, guarded by the thin-shell check). - `tests/nvml/rmfake.om`: device-free resource-manager fake. ## Host gate (Spark, `bwrap … taskset -c 18,19 nice -n 10`, omc `e5b32567` sha256 `2c824805`…, omega-bridge `bc11b30`) check rc last line label `make test-nvml CUDAPP_OMC_HOST=1 OMEGA_OMC=… OMEGA_BRIDGE=…` 0 `CUDAPP-NVML HOST PASS` (476 checks, 22/22 mutants caught, 55 ABI facts equal to CUDA nvml.h, thin-shell guard + its negative control) PASS `sh om/units.sh --check` 0 `PASS portable Omega units regenerate byte for byte` PASS `crumb verify .` 0 `OK: 42 crumbs current` PASS negative: `make test-nvml` without env 2 `make: *** [mk/nvml.mk:15: test-nvml] Error 2` PASS (red as required) negative: `run.sh` with a non-pin omc 69 `REFUSED: omc digest a82c1b5f… is not the omega-mv e5b32567 pin` PASS (red as required) Chip / live-RM tiers: NOT_RUN (no GPU window; DRA-118). Host results are not chip qualification. ROADMAP status stays MISSING. ## Update at `a33b2524` (drift) `drift` failed at `fb7f885f`. That failure is inherited from main `b774723f`: omega `a64e6705` (omega-mv #596) changed PORTABILITY.md and portability_table.tsv, which CUDA++ already carries. `a33b2524` records those omega blobs in `tools/extract/drift-baseline.tsv`, as #280 `dcd553fd` does. Host-local results on the Spark (bwrap, cores 18,19): - `tools/extract/drift.sh --self-test HEAD`: rc 0, `SELF-TEST: PASS (all controls red, real check green)`. Without the change: rc 1, `SELF-TEST: FAIL`. - `make test-nvml` at `a33b2524`: rc 0, `CUDAPP-NVML HOST PASS`. ### Apply it ``` git checkout -b patch-d3a70f94fddc6fc2 b774723f537cec16a359fe082b8100317a5b5490 curl -fsSL https://interplane.io/drakestapleton/CUDApp/patches/d3a70f94fddc6fc2.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/CUDApp 365 4bf58894d1985d41240736145de7b5fe03e377ee ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"CUDApp","number":365,"url":"https://github.com/aien-dev/CUDApp/pull/365","export_sha256":"0aafd51b77ff5776d6baaf9b88b48c8b36a6e27c8d829ae8ded561b71712b17a","imported_utc":"2026-11-18T16:38:19Z"} ``` ### Changes ``` diff --git a/ROADMAP.md b/ROADMAP.md index 5969ed10..c4a19bc4 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -21,7 +21,7 @@ Sources: Omega `docs/OMEGA.md` sections 2 to 5 (branch `docs/what-omega-is`, 202 | `nvidia.ko` | Kernel driver: GPU boot, memory, channels | my own GB10 driver, in three repositories: aien-dev/aien-gpu (Omega units inside a Linux module), aien-dev/omega-gpu-driver (seeded Omega over `vfio-pci`), aienux#441 (L332: C reference driver and GB10 simulator) | BUILDING | no track has run on the GB10. aien-gpu `docs/STATUS.md` (ec9d6d76): host and QEMU EXERCISED, hardware NOT_RUN. omega-gpu-driver README (07781415): W0 EXERCISED in QEMU only. aienux#441: merged into aienux main on 2026-10-30 (merge 4c25c6ce); L332 simulator gates PASS at cd5eef7a (`evidence/own-gpu-driver/rung1/gates-20261021T2158Z.txt` there). Open before the chip: the chip id is unread (`PMC_BOOT_42`, aienux `docs/GB10_FIRMWARE_INVENTORY.md` on main since #441), the GPU windows wait for my go, and the `nvrm/` client still speaks NVIDIA's ioctls (moving it is PROPOSED) | | `nvidia-uvm.ko` | Unified memory, page tables, faults | my own GB10 driver (same three repositories; aien-gpu's README names `nvidia_uvm` as replaced) | BUILDING | host simulator, 225 checks PASS (aienux `feat/gb10-gpu-mmu-sim` bcc56506); no chip run | | `nvidia-modeset.ko`, `nvidia-drm.ko` | Display | not needed for compute | not used by CUDA++ | | -| `nvidia-smi`, NVML | Status, clocks, power | not started | MISSING | | +| `nvidia-smi`, NVML | Status, clocks, power | NVML subset `compat/nvml/` over pure Omega units (`native/nvml/`) | BUILDING | 2026-11-06 note: first-party seeded Omega NVML replacement: pure units `native/nvml/` (`nvml_step`, `nvml_errstr`), thin C ABI shell `compat/nvml/`, and resource-manager fake `tests/nvml/rmfake.om`. Host tier passes 476 checks, 22 killed mutants, and CUDA 13.0 ABI comparison (`evidence/NVML-2026-11-06/`); live RM and GB10 chip NOT_RUN (awaits GPU window). | | GSP firmware (`gsp_*.bin`) | Runs inside the GPU | stays NVIDIA's: the chip checks its signature | not replaceable | the kernel module loads NVIDIA's signed file from the system's firmware folder; CUDA++ never ships it | ## 2. Bars before I say "replaces CUDA" diff --git a/compat/nvml/.crumb b/compat/nvml/.crumb new file mode 100644 index 00000000..bdc4d4f1 --- /dev/null +++ b/compat/nvml/.crumb @@ -0,0 +1,20 @@ +{ + "extensions": { + "generated": { + "children": [], + "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "compiled_at": "2026-11-06T20:17:31Z", + "compiler": "crumb-compile/1", + "digest": "sha256:74e3e6a8a4810ad8dd4968d888d20eb6b7c9606e8ec8581763a8877701a894ce", + "evidence_files": 0, + "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "files": 3, + "generated_at_commit": "54075dceb012f08257a3138756a1e3023b9ba4a4", + "source_tree": "sha256:2aba75c7feeec8619934f37caeb8ad793608f71904266d036a7a793fcd5fee28" + } + }, + "layer": "development", + "name": "cudapp-nvml", + "purpose": "Thin C ABI shell and own nvml.h for the CUDA++ libnvidia-ml subset over native/nvml and the omega2_nvrm transport", + "schema_version": "1.0.0" +} diff --git a/compat/nvml/README.md b/compat/nvml/README.md new file mode 100644 index 00000000..2b01dc52 --- /dev/null +++ b/compat/nvml/README.md @@ -0,0 +1,42 @@ + +# compat/nvml: CUDA++ libnvidia-ml subset + +A C ABI shell that answers this subset of NVML (CUDA 13.0 `nvml.h`, line of +each prototype in `nvml.h` here): + +`nvmlInit_v2`, `nvmlShutdown`, `nvmlErrorString`, `nvmlDeviceGetCount_v2`, +`nvmlDeviceGetHandleByIndex_v2`, `nvmlDeviceGetName`, `nvmlDeviceGetUUID`, +`nvmlDeviceGetTemperature`, `nvmlDeviceGetMemoryInfo`, +`nvmlDeviceGetUtilizationRates`, `nvmlDeviceGetComputeRunningProcesses_v3`, +and the unversioned `nvmlInit`/`nvmlDeviceGetCount`/... names through the +same macros NVIDIA's header uses (off with `NVML_NO_UNVERSIONED_FUNC_DEFS`). + +- `nvml.h` is our own header: only the types, values and prototypes of the + subset, each cited to the CUDA 13.0 `nvml.h` line. No NVIDIA text is copied. + `tests/nvml/abi.c` checks 55 sizes, offsets and values against the toolkit + header, and `tests/nvml/run.sh` compiles the shell against NVIDIA's + prototypes (header only). +- `cudapp_nvml.c` is the shell. It holds a mutex, the step state and buffer, + the handle table and the `nvmlErrorString` cache. Every decision (argument + checks, RM requests, reply decoding, error mapping, teardown) is in the + Omega units `nvml_step` and `nvml_errstr` (`native/nvml`); the shell only + performs the action each step asks for. `tests/nvml/run.sh` refuses a shell + that names an OS call, a device path or an RM command. + +The shell reaches the OS only through `omega2_nvrm_open_file`, +`omega2_nvrm_close_file` and `omega2_nvrm_ioctl` +(`native/nvrm/transport.om`, aien-dev/CUDApp#281). It is not in `SRCS`: a +library build links `cudapp_nvml.c`, `src/cudapp_om_nvml_step.c`, +`src/cudapp_om_nvml_errstr.c` and the #281 transport. NVIDIA's +libnvidia-ml is never linked or loaded. + +## Status + +| Tier | Verdict | +| --- | --- | +| Host, fake resource manager (`make test-nvml`) | PASS (476 checks, 22/22 mutants caught), 2026-11-06 | +| ABI against CUDA 13.0 `nvml.h` | PASS (55 facts) | +| Live resource manager | NOT_RUN: opening `/dev/nvidia*` needs an authorized GPU window | +| Utilization over the #281 transport | NOT_RUN: 55888-byte control vs the e5b32567 devcall bound (aien-dev/omega-mv#1048) | + +Evidence: `evidence/NVML-2026-11-06/`. diff --git a/compat/nvml/cudapp_nvml.c b/compat/nvml/cudapp_nvml.c new file mode 100644 index 00000000..d2215739 --- /dev/null +++ b/compat/nvml/cudapp_nvml.c @@ -0,0 +1,167 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* CUDA++ NVML subset: the C ABI shell over the Omega unit nvml_step (native/nvml). It holds no + * policy. Each entry point stores its op and arguments, then alternates omega_nvml_step with the + * one action the step requests, performed by the Omega RM transport (omega2_nvrm_*, native/nvrm/ + * transport.om), until the step reports done. Every return code, decode and teardown decision is + * made in Omega. The shell only maps nvmlDevice_t to an index, bounds the copies and serializes + * calls; a refused or trapped step, a malformed request or a runaway loop is NVML_ERROR_UNKNOWN. */ +#include "nvml.h" + +#include +#include +#include + +#include "cudapp_native.h" + +/* native/nvrm/transport.om lowered by omega-bridge (aien-dev/CUDApp#281). */ +uint32_t omega2_nvrm_open_file(uint64_t *result, const uint8_t *o_path, uint64_t o_path_len); +uint32_t omega2_nvrm_close_file(uint64_t *result, uint64_t o_fd); +uint32_t omega2_nvrm_ioctl(uint64_t *result, uint64_t o_fd, uint64_t o_nr, uint8_t *o_h, + uint64_t o_h_len, uint8_t *o_p, uint64_t o_p_len); + +/* native/nvml/nvml.om: SN, BN, PO, OO; at most 8 GPUs. */ +enum { NVML_SN = 128, NVML_BN = 83296, NVML_PO = 4608, NVML_OO = 60496, NVML_GPUS = 8 }; +enum { NVML_STEPS = 4096 }; +#define NVML_MAGIC 0x434450504e564d4cull + +struct nvmlDevice_st { + uint64_t magic; + uint64_t index; +}; + +static pthread_mutex_t nvml_lock = PTHREAD_MUTEX_INITIALIZER; +static uint64_t nvml_s[NVML_SN]; +static uint8_t nvml_b[NVML_BN]; +static struct nvmlDevice_st nvml_dev[NVML_GPUS] = { + {NVML_MAGIC, 0}, {NVML_MAGIC, 1}, {NVML_MAGIC, 2}, {NVML_MAGIC, 3}, + {NVML_MAGIC, 4}, {NVML_MAGIC, 5}, {NVML_MAGIC, 6}, {NVML_MAGIC, 7}, +}; +static char nvml_text[32][64]; +static uint8_t nvml_text_set[32]; + +/* The index of a handle this library issued, or UINT64_MAX; Omega rejects that as an argument. */ +static uint64_t nvml_index(nvmlDevice_t d) { + uintptr_t p = (uintptr_t)d, lo = (uintptr_t)&nvml_dev[0]; + if (p < lo || p >= lo + sizeof nvml_dev || (p - lo) % sizeof nvml_dev[0] != 0) return UINT64_MAX; + return d->magic == NVML_MAGIC ? d->index : UINT64_MAX; +} + +static int nvml_act(void) { + uint64_t *s = nvml_s, r = 0; + uint32_t st; + switch (s[8]) { + case 1: + if (s[11] > NVML_PO || s[12] > NVML_OO - NVML_PO) return -1; + st = omega2_nvrm_ioctl(&r, s[9], s[10], nvml_b, s[11], nvml_b + NVML_PO, s[12]); + break; + case 2: + if (s[13] == 0 || s[13] > NVML_OO - NVML_PO) return -1; + st = omega2_nvrm_open_file(&r, nvml_b + NVML_PO, s[13]); + break; + case 3: + st = omega2_nvrm_close_file(&r, s[9]); + break; + default: + return -1; + } + s[14] = r; + s[15] = st; + return 0; +} + +static nvmlReturn_t nvml_run(uint64_t op, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, + void *out, uint64_t cap, unsigned int *scalar) { + uint64_t *s = nvml_s; + nvmlReturn_t ret = NVML_ERROR_UNKNOWN; + pthread_mutex_lock(&nvml_lock); + s[0] = op; + s[1] = a1; + s[2] = a2; + s[3] = a3; + s[4] = a4; + s[22] = 0; + for (unsigned n = 0; n < NVML_STEPS; n++) { + uint64_t r = 1; + if (omega_nvml_step(&r, s, NVML_SN, nvml_b, NVML_BN) != OMEGA_OK || r != 0) break; + if (s[8] != 0) { + if (nvml_act() != 0) break; + continue; + } + if (s[7] > cap || (s[7] != 0 && out == NULL) || (s[27] != 0 && (scalar == NULL || s[5] > UINT32_MAX))) + break; + if (s[7] != 0) memcpy(out, nvml_b + NVML_OO, s[7]); + if (s[27] != 0) *scalar = (unsigned int)s[5]; + ret = s[6] <= 30 || s[6] == 999 ? (nvmlReturn_t)s[6] : NVML_ERROR_UNKNOWN; + break; + } + s[22] = 0; + pthread_mutex_unlock(&nvml_lock); + return ret; +} + +nvmlReturn_t nvmlInit_v2(void) { return nvml_run(1, 0, 0, 0, 0, NULL, 0, NULL); } + +nvmlReturn_t nvmlShutdown(void) { return nvml_run(2, 0, 0, 0, 0, NULL, 0, NULL); } + +nvmlReturn_t nvmlDeviceGetCount_v2(unsigned int *deviceCount) { + return nvml_run(3, 0, deviceCount != NULL, 0, 0, NULL, 0, deviceCount); +} + +nvmlReturn_t nvmlDeviceGetHandleByIndex_v2(unsigned int index, nvmlDevice_t *device) { + unsigned int i = 0; + nvmlReturn_t r = nvml_run(4, index, device != NULL, 0, 0, NULL, 0, &i); + if (r == NVML_SUCCESS) { + if (i >= NVML_GPUS) return NVML_ERROR_UNKNOWN; + *device = &nvml_dev[i]; + } + return r; +} + +nvmlReturn_t nvmlDeviceGetName(nvmlDevice_t device, char *name, unsigned int length) { + return nvml_run(5, nvml_index(device), name != NULL, length, 0, name, length, NULL); +} + +nvmlReturn_t nvmlDeviceGetUUID(nvmlDevice_t device, char *uuid, unsigned int length) { + return nvml_run(6, nvml_index(device), uuid != NULL, length, 0, uuid, length, NULL); +} + +nvmlReturn_t nvmlDeviceGetTemperature(nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, + unsigned int *temp) { + return nvml_run(7, nvml_index(device), temp != NULL, (uint64_t)(unsigned int)sensorType, 0, NULL, + 0, temp); +} + +nvmlReturn_t nvmlDeviceGetMemoryInfo(nvmlDevice_t device, nvmlMemory_t *memory) { + return nvml_run(8, nvml_index(device), memory != NULL, 0, 0, memory, sizeof *memory, NULL); +} + +nvmlReturn_t nvmlDeviceGetUtilizationRates(nvmlDevice_t device, nvmlUtilization_t *utilization) { + return nvml_run(9, nvml_index(device), utilization != NULL, 0, 0, utilization, sizeof *utilization, + NULL); +} + +nvmlReturn_t nvmlDeviceGetComputeRunningProcesses_v3(nvmlDevice_t device, unsigned int *infoCount, + nvmlProcessInfo_t *infos) { + uint64_t want = infoCount != NULL ? *infoCount : 0; + return nvml_run(10, nvml_index(device), infoCount != NULL, want, infos != NULL, infos, + want * sizeof(nvmlProcessInfo_t), infoCount); +} + +/* The text comes from the Omega unit nvml_errstr; each slot is filled once and stays stable. */ +const char *nvmlErrorString(nvmlReturn_t result) { + uint8_t o[64]; + uint64_t r = 0, slot; + const char *t = "Unknown Error"; + pthread_mutex_lock(&nvml_lock); + if (omega_nvml_errstr(&r, (uint64_t)(int64_t)result, o, sizeof o) == OMEGA_OK && (r & 255) < 64 && + (slot = r >> 8 & 255) < 32) { + if (!nvml_text_set[slot]) { + memcpy(nvml_text[slot], o, 64); + nvml_text[slot][r & 255] = 0; + nvml_text_set[slot] = 1; + } + t = nvml_text[slot]; + } + pthread_mutex_unlock(&nvml_lock); + return t; +} diff --git a/compat/nvml/nvml.h b/compat/nvml/nvml.h new file mode 100644 index 00000000..b2b7e00d --- /dev/null +++ b/compat/nvml/nvml.h @@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* CUDA++ NVML subset: an ABI-compatible declaration of the libnvidia-ml entry points + * compat/nvml/cudapp_nvml.c implements. Written for CUDA++; not NVIDIA's header. Type layouts, + * enum values and symbol names follow nvml.h from CUDA 13.0 (NVML_API_VERSION 13); the line + * numbers below refer to /usr/local/cuda-13.0/targets/sbsa-linux/include/nvml.h. */ +#ifndef CUDAPP_NVML_H +#define CUDAPP_NVML_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* nvml.h:117-129: the unversioned names map to the current versions. */ +#ifndef NVML_NO_UNVERSIONED_FUNC_DEFS +#define nvmlInit nvmlInit_v2 +#define nvmlDeviceGetCount nvmlDeviceGetCount_v2 +#define nvmlDeviceGetHandleByIndex nvmlDeviceGetHandleByIndex_v2 +#define nvmlDeviceGetComputeRunningProcesses nvmlDeviceGetComputeRunningProcesses_v3 +#endif + +/* nvml.h:155 */ +#define NVML_VALUE_NOT_AVAILABLE (-1) + +/* nvml.h:157 */ +typedef struct nvmlDevice_st *nvmlDevice_t; + +/* nvml.h:244-248 */ +typedef struct nvmlUtilization_st { + unsigned int gpu; + unsigned int memory; +} nvmlUtilization_t; + +/* nvml.h:254-260 */ +typedef struct nvmlMemory_st { + unsigned long long total; + unsigned long long free; + unsigned long long used; +} nvmlMemory_t; + +/* nvml.h:303-312 */ +typedef struct nvmlProcessInfo_v2_st { + unsigned int pid; + unsigned long long usedGpuMemory; + unsigned int gpuInstanceId; + unsigned int computeInstanceId; +} nvmlProcessInfo_v2_t, nvmlProcessInfo_t; + +/* nvml.h:934-940 */ +typedef enum nvmlTemperatureSensors_enum { + NVML_TEMPERATURE_GPU = 0, + NVML_TEMPERATURE_COUNT +} nvmlTemperatureSensors_t; + +/* nvml.h:1269-1304 */ +typedef enum nvmlReturn_enum { + NVML_SUCCESS = 0, + NVML_ERROR_UNINITIALIZED = 1, + NVML_ERROR_INVALID_ARGUMENT = 2, + NVML_ERROR_NOT_SUPPORTED = 3, + NVML_ERROR_NO_PERMISSION = 4, + NVML_ERROR_ALREADY_INITIALIZED = 5, + NVML_ERROR_NOT_FOUND = 6, + NVML_ERROR_INSUFFICIENT_SIZE = 7, + NVML_ERROR_INSUFFICIENT_POWER = 8, + NVML_ERROR_DRIVER_NOT_LOADED = 9, + NVML_ERROR_TIMEOUT = 10, + NVML_ERROR_IRQ_ISSUE = 11, + NVML_ERROR_LIBRARY_NOT_FOUND = 12, + NVML_ERROR_FUNCTION_NOT_FOUND = 13, + NVML_ERROR_CORRUPTED_INFOROM = 14, + NVML_ERROR_GPU_IS_LOST = 15, + NVML_ERROR_RESET_REQUIRED = 16, + NVML_ERROR_OPERATING_SYSTEM = 17, + NVML_ERROR_LIB_RM_VERSION_MISMATCH = 18, + NVML_ERROR_IN_USE = 19, + NVML_ERROR_MEMORY = 20, + NVML_ERROR_NO_DATA = 21, + NVML_ERROR_VGPU_ECC_NOT_SUPPORTED = 22, + NVML_ERROR_INSUFFICIENT_RESOURCES = 23, + NVML_ERROR_FREQ_NOT_SUPPORTED = 24, + NVML_ERROR_ARGUMENT_VERSION_MISMATCH = 25, + NVML_ERROR_DEPRECATED = 26, + NVML_ERROR_NOT_READY = 27, + NVML_ERROR_GPU_NOT_FOUND = 28, + NVML_ERROR_INVALID_STATE = 29, + NVML_ERROR_RESET_TYPE_NOT_SUPPORTED = 30, + NVML_ERROR_UNKNOWN = 999 +} nvmlReturn_t; + +/* nvml.h:3804-3834 */ +#define NVML_DEVICE_UUID_BUFFER_SIZE 80 +#define NVML_DEVICE_UUID_V2_BUFFER_SIZE 96 +#define NVML_DEVICE_NAME_BUFFER_SIZE 64 +#define NVML_DEVICE_NAME_V2_BUFFER_SIZE 96 + +nvmlReturn_t nvmlInit_v2(void); /* nvml.h:3731 */ +nvmlReturn_t nvmlShutdown(void); /* nvml.h:3765 */ +const char *nvmlErrorString(nvmlReturn_t result); /* nvml.h:3786 */ +nvmlReturn_t nvmlDeviceGetCount_v2(unsigned int *deviceCount); /* nvml.h:4221 */ +nvmlReturn_t nvmlDeviceGetHandleByIndex_v2(unsigned int index, nvmlDevice_t *device); /* 4289 */ +nvmlReturn_t nvmlDeviceGetName(nvmlDevice_t device, char *name, unsigned int length); /* 4432 */ +nvmlReturn_t nvmlDeviceGetUUID(nvmlDevice_t device, char *uuid, unsigned int length); /* 4816 */ +nvmlReturn_t nvmlDeviceGetTemperature(nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, + unsigned int *temp); /* nvml.h:5571 */ +nvmlReturn_t nvmlDeviceGetMemoryInfo(nvmlDevice_t device, nvmlMemory_t *memory); /* 6330 */ +nvmlReturn_t nvmlDeviceGetUtilizationRates(nvmlDevice_t device, + nvmlUtilization_t *utilization); /* nvml.h:6671 */ +nvmlReturn_t nvmlDeviceGetComputeRunningProcesses_v3(nvmlDevice_t device, unsigned int *infoCount, + nvmlProcessInfo_t *infos); /* nvml.h:6985 */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/evidence/NVML-2026-11-06/README.md b/evidence/NVML-2026-11-06/README.md new file mode 100644 index 00000000..f3ba5053 --- /dev/null +++ b/evidence/NVML-2026-11-06/README.md @@ -0,0 +1,50 @@ + +# NVML subset host tier, 2026-11-06 + +Branch `feat/cudapp-nvml` (CUDApp), base `feat/cudapp-smi` (#286, 85f48ad). +Compiler: omc at omega-mv e5b32567, sha256 +`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`; +omega-bridge bc11b30b (`bridge-seeded` frontend 23ff7a23…). Every command ran +inside a device-free namespace on cores 10-14: + +```sh +W="bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10" +$W make test-nvml OMEGA_OMC=$OMC OMEGA_BRIDGE=$BRIDGE # rc 0, CUDAPP-NVML HOST PASS +env -u OMEGA_OMC -u OMEGA_BRIDGE $W make test-nvml # rc 2, NOT_RUN +OMEGA_OMC= $W sh tests/nvml/run.sh # rc 69, REFUSED (omc digest) +env -u OMEGA_OMC -u OMEGA_BRIDGE $W sh tests/nvml/run.sh # rc 77, NOT_RUN +``` + +`commands.txt` has the rc and last line of each; the logs are beside it +(home directory written as `~`). + +## Verdicts + +| Tier | Verdict | +| --- | --- | +| Committed generated C (`src/cudapp_om_nvml_{step,errstr}.c`) fresh against the `.om` | PASS | +| Fake resource manager (`tests/nvml/rmfake.om` behind `tests/nvml/transport.c`) | PASS, 476 checks | +| Error-string oracle negative control (one oracle row altered) | PASS: the run fails 1 of 476 | +| ABI: 55 sizes, offsets and values, `compat/nvml/nvml.h` vs CUDA 13.0 `nvml.h` | PASS | +| Shell compiles against NVIDIA's prototypes (header only) | PASS | +| Thin-shell guard, and its negative control (a shell calling `ioctl`) | PASS | +| Mutants of `native/nvml/*.om` | 22/22 caught | +| Live resource manager (`/dev/nvidiactl`, `/dev/nvidia0`) | NOT_RUN: no authorized GPU window | +| GB10 chip | NOT_RUN | + +The fake transport replaces `omega2_nvrm_*` at link time, so no test opens a +device; the bwrap namespace (empty `/dev`) makes that hold by construction. + +## Oracle provenance + +`tests/nvml/errstr-oracle.tsv` holds 37 rows (codes −1, 0..32, 999, 1000, +4294967295). It was captured on this Spark with Python `ctypes` calling +`nvmlErrorString` from `/usr/lib/aarch64-linux-gnu/libnvidia-ml.so.580.173.02` +without `nvmlInit` (the call opens no device). The library is used only as +that oracle; nothing in CUDA++ links or loads it. + +## Constants + +`wolfram.txt`: every derived constant (packed path words, buffer offsets, +command values in hex, fake RM values, two's-complement errno words, packed +error strings) with the Wolfram Language query and its result. diff --git a/evidence/NVML-2026-11-06/commands.txt b/evidence/NVML-2026-11-06/commands.txt new file mode 100644 index 00000000..ef6605d9 --- /dev/null +++ b/evidence/NVML-2026-11-06/commands.txt @@ -0,0 +1,4 @@ +make test-nvml OMEGA_OMC= OMEGA_BRIDGE= rc=0 last=CUDAPP-NVML HOST PASS +make test-nvml (unset) rc=2 last=make: *** [mk/nvml.mk:15: test-nvml] Error 2 +run.sh (unset) rc=77 last=NOT_RUN: set OMEGA_OMC (omega-mv e5b32567 omc) and OMEGA_BRIDGE (omega-bridge checkout) +run.sh (wrong omc) rc=69 last=REFUSED: omc digest c5ac9979232afd0d750e1d5088af69692032997136f761e585a25aa9a1cfc87e is not the omega-mv e5b32567 pin diff --git a/evidence/NVML-2026-11-06/run-unset.log b/evidence/NVML-2026-11-06/run-unset.log new file mode 100644 index 00000000..fa8550ea --- /dev/null +++ b/evidence/NVML-2026-11-06/run-unset.log @@ -0,0 +1 @@ +NOT_RUN: set OMEGA_OMC (omega-mv e5b32567 omc) and OMEGA_BRIDGE (omega-bridge checkout) diff --git a/evidence/NVML-2026-11-06/test-nvml.log b/evidence/NVML-2026-11-06/test-nvml.log new file mode 100644 index 00000000..1fa6ca15 --- /dev/null +++ b/evidence/NVML-2026-11-06/test-nvml.log @@ -0,0 +1,33 @@ +OMEGA_OMC="/home/drakestapleton/work/cudastack/omega-mv/seed/out/omc" OMEGA_BRIDGE="/home/drakestapleton/work/cudastack/omega-bridge" sh tests/nvml/run.sh +PASS committed src/cudapp_om_nvml_step.c is the bridge output of native/nvml +PASS committed src/cudapp_om_nvml_errstr.c is the bridge output of native/nvml +PASS fake tier: CUDAPP-NVML HOST PASS (476 checks) +PASS oracle negative control (altered string rejected: CUDAPP-NVML HOST FAIL (1 of 476 checks)) +PASS abi: 55 facts equal to /usr/local/cuda/include/nvml.h +PASS shell compiles against the CUDA nvml.h prototypes +PASS thin-shell guard +PASS thin-shell guard negative control + mutant nvml 'if eq v 86': caught (CUDAPP-NVML HOST FAIL (3 of 476 checks)) + mutant nvml 'if eq v 27': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant nvml 'if or or eq x 18446744073709551614 eq x 18446744073709551610 eq x 18446744073709551597': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant nvml 'put b n uchar add 48 rem minor 10': caught (CUDAPP-NVML HOST FAIL (157 of 411 checks)) + mutant nvml 'if gt get s 16 0': caught (CUDAPP-NVML HOST FAIL (16 of 476 checks)) + mutant nvml 'if gt get s 16 1': caught (CUDAPP-NVML HOST FAIL (3 of 476 checks)) + mutant nvml 'for t ulong 26': caught (CUDAPP-NVML HOST FAIL (138 of 476 checks)) + mutant nvml 'if eq g32 b add add PO 4 mul i 4 52928': caught (CUDAPP-NVML HOST FAIL (29 of 476 checks)) + mutant query 'if ge get s 1 get s 21': caught (CUDAPP-NVML HOST FAIL (4 of 476 checks)) + mutant query 'put b add OO 3 45': caught (CUDAPP-NVML HOST FAIL (6 of 476 checks)) + mutant query 'put b n 45': caught (CUDAPP-NVML HOST FAIL (6 of 476 checks)) + mutant query 'if eq g32 b add add add PO 24 mul tg 44 16 1': caught (CUDAPP-NVML HOST FAIL (8 of 476 checks)) + mutant query 'if ge v 2147483648': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'if ne g32 b add PO 8 0': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'p64 b add OO 16 mul sub t f 1024': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant query 'o = add add PO 16 mul rem add r 71 72 776': caught (CUDAPP-NVML HOST FAIL (4 of 476 checks)) + mutant query 'p32 b OO div g 100': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant query 'p64 b add q 8 18446744073709551615': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'p32 b add q 16 4294967295': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant query 'if or gt c 72 ge r 72': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'if gt f t': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant errstr 'n = w8 o n 32496501618079059': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) +mutants caught 22/22 +CUDAPP-NVML HOST PASS diff --git a/evidence/NVML-2026-11-06/unset.log b/evidence/NVML-2026-11-06/unset.log new file mode 100644 index 00000000..d3b92abf --- /dev/null +++ b/evidence/NVML-2026-11-06/unset.log @@ -0,0 +1,2 @@ +test-nvml: NOT_RUN (requires CUDAPP_OMC_HOST=1 with OMEGA_OMC and OMEGA_BRIDGE) +make: *** [mk/nvml.mk:15: test-nvml] Error 2 diff --git a/evidence/NVML-2026-11-06/wolfram.txt b/evidence/NVML-2026-11-06/wolfram.txt new file mode 100644 index 00000000..1f271716 --- /dev/null +++ b/evidence/NVML-2026-11-06/wolfram.txt @@ -0,0 +1,11 @@ +# Wolfram Language evaluations (mcp__wolfram_wolframlanguageevaluator) behind the native/nvml and tests/nvml constants. +# Recorded 2026-11-06 by the Smi lane. Each query is followed by its result. +WolframLanguageEvaluator: {Map[FromDigits[Reverse[ToCharacterCode[#]],256]&,{"/dev/nvi","dia","diactl"}], ToCharacterCode["GPU-"], 4608+55888, 4608+55888+22800, 950*24, 24+32*44, 8+200*72, 12+950*4, 4+128*8, 4+200*4, 12+256, 4+128, 72*776, 16+72*776, BaseForm[{545259792,545259850,545259917,545259918,545260819,545264387,545267862,8389266,3472883713,52928,8320,128,65},16], 2^31, 2^64-1, 2^32-1, 4+2*8, 4+1*8,4+0*8} +-> Out[1]= {{7599382571363165231, 6383972, 119247139334500}, {71, 80, 85, 45}, 60496, 83296, 22800, 1432, 14408, 3812, 1028, 804, 268, 132, 55872, 55888, BaseForm[{545259792, 545259850, 545259917, 545259918, 545260819, 545264387, 545267862, 8389266, 3472883713, 52928, 8320, 128, 65}, 16], 2147483648, 18446744073709551615, 4294967295, 20, 12, 4} +WolframLanguageEvaluator: Map[IntegerString[#,16]&,{...}] +-> Out[1]= {"20800110", "2080014a", "2080018d", "2080018e", "20800513", "20801303", "20802096", "800292", "cf000001", "cec0", "2080", "80", "41", "205", "ffffffff"} +WolframLanguageEvaluator: {FromDigits["c1d00001",16], FromDigits[Reverse[FromDigits[#,16]&/@{"fb","8e","53","f0","32","07","e8","9b"}],256], FromDigits[Reverse[FromDigits[#,16]&/@{"d0","2f","ac","df","e2","69","5b","59"}],256], FromDigits[Reverse[FromDigits[#,16]&/@{"d0","2f","ac","df","e2","69","5b","5a"}],256], FromDigits[Reverse[ToCharacterCode["NVIDIA G"]],256], FromDigits[Reverse[ToCharacterCode["B10"]],256], 335*1048576, 128000000*1024, 100000000*1024, 28000000*1024, 4242*65536, 2^32-10, 1000*65536, 1249*65536, FromDigits["a0b5",16], FromDigits["c6c0",16], FromDigits["c86f",16]} +-> Out[1]= {3251634177, 11234237185837469435, 6438856515392384976, 6510914109430312912, 5125168158881699406, 3158338, 351272960, 131072000000, 102400000000, 28672000000, 278003712, 4294967286, 65536000, 81854464, 41141, 50880, 51311} +WolframLanguageEvaluator: {2^64-1,2^64-2,2^64-6,2^64-13,2^64-19,2^63} -> Out[1]= {18446744073709551615, 18446744073709551614, 18446744073709551610, 18446744073709551603, 18446744073709551597, 9223372036854775808} +WolframLanguageEvaluator: strs={"Unknown Error","Success","Uninitialized","Invalid Argument","Not Supported","Insufficient Permissions","Already Initialized","Not Found","Insufficient Size","Insufficient External Power","Driver Not Loaded","Timeout","Interrupt Request Issue","NVML Shared Library Not Found","Function Not Found","Corrupted infoROM","GPU is lost","GPU requires reset","GPU access blocked by the operating system","Driver/library version mismatch","In use by another client","Insufficient Memory","No data","vGPU ECC not supported","Insufficient Resources","Invalid Frequency","Argument version mismatch","Requested functionality has been deprecated","System is not in ready state","No supported GPUs were found","Resource not in correct state to perform requested operation","Reset type is not supported for given device"};Map[Function[s,{StringLength[s],Map[FromDigits[Reverse[#],256]&,Partition[ToCharacterCode[s],UpTo[8]]]}],strs] +-> Out[1]= {{13, {2336936577129475669, 491496043077}}, {7, {32496501618079059}}, {13, {7019269490406420053, 431199250796}}, {16, {2334106421097295433, 8389754676633367105}}, {13, {8102104729526759246, 431198859887}}, {24, {7163369272552681033, 8243082793294128489, 8317708060499077485}}, {19, {2340011850872286273, 7596553777019711049, 6579578}}, {9, {7959390263430115150, 100}}, {17, {7163369272552681033, 8820672744039277929, 101}}, {27, {7163369272552681033, 8392533911299581289, 8020946586210038373, 7497079}}, {17, {5629625314317005380, 7306071626148246639, 100}}, {7, {32780218601924948}}, {23, {8103508940177043017, 8315181416901124212, 28558111363637364}}, {29, {7018951417441113678, 8242266043723310450, 2338616487855092321, 431349919558}}, {18, {7957695015192261958, 8462059330058800672, 25710}}, {17, {7310591744862744387, 5715753362816311396, 77}}, {11, {7791354250702180423, 7631727}}, {18, {8462656715649011783, 8315177770710037097, 29797}}, {42, {7305792289330516039, 7738151096046089075, 7526676582952363109, 8386109761144168549, 8391184066093215337, 28005}}, {31, {7795575260105503300, 8511936827898356329, 7863406374178484837, 29382749079827305}}, {24, {7070762961532382793, 7307218417350680697, 8389754659302219890}}, {19, {7163369272552681033, 7882791524569605481, 7959151}}, {7, {27431034381430606}}, {22, {4846793629153380214, 8103509687752683040, 110386908131184}}, {22, {7163369272552681033, 8315142586355311977, 126879297336687}}, {17, {2334106421097295433, 7164775612281090630, 121}}, {25, {8389754676633367105, 7957695011148363296, 7166460029768920352, 104}}, {43, {7310594974728414546, 7598807797348048996, 2340029477534396015, 7954875788945482088, 7017564186559734816, 6579572}}, {28, {7575174855750023507, 7955925901184475251, 8295763985654182432, 1702125940}}, {28, {8030041785346584398, 6147491695809623154, 7358993333126373491, 1684960623}}, {60, {7305808869231650130, 2336920844765195808, 2338603393875079011, 8031079655624766579, 7886488383275757600, 8391162085809418784, 7021786302599160933, 1852795252}}, {44, {8751655660178072914, 8029390865705231728, 8245933071047794804, 2338053640979506548, 7306000154022537575, 1701013878}}} diff --git a/evidence/NVML-2026-11-06/wrong-omc.log b/evidence/NVML-2026-11-06/wrong-omc.log new file mode 100644 index 00000000..d5ba7efe --- /dev/null +++ b/evidence/NVML-2026-11-06/wrong-omc.log @@ -0,0 +1 @@ +REFUSED: omc digest c5ac9979232afd0d750e1d5088af69692032997136f761e585a25aa9a1cfc87e is not the omega-mv e5b32567 pin diff --git a/evidence/NVML-2026-11-07/README.md b/evidence/NVML-2026-11-07/README.md new file mode 100644 index 00000000..44b5e804 --- /dev/null +++ b/evidence/NVML-2026-11-07/README.md @@ -0,0 +1,72 @@ + +# NVML subset host tier, refresh against main and #280, 2026-11-07 + +Branch `feat/omega-nvml-replacement` (CUDApp #365) at 27e0b93d, base `main` +b774723f (main has not moved since the branch was cut, so no rebase). +27e0b93d takes #280's `tests/nvml/run.sh` byte for byte: the bridge-seeded +frontend pin is now read from `om/units.sh` instead of a second copy. +Compiler: omc at omega-mv e5b32567, sha256 +`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`. +Bridges built from the fingerprinted seed (sha256 191b776e…) with +`tools/build.sh`: bc11b30b (bridge-seeded 23ff7a23…, the main pin) and +d90433a9 (bridge-seeded a3a455bd…, the #280 pin). Every command ran in a +device-free namespace on cores 10-11 under the pool-10-11 lock: + +```sh +B="bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10,11 nice -n 10" +$B make test-nvml CUDAPP_OMC_HOST=1 OMEGA_OMC=$OMC OMEGA_BRIDGE=$BRIDGE +$B env OMEGA_OMC=$OMC OMEGA_BRIDGE=$BRIDGE sh om/units.sh --check +``` + +The full command list is `gates.sh`/`run3.sh` in the card workspace; the rc +and last line of each command are in `head/commands.txt` and +`merge-280/commands.txt`, with the logs beside them (home directory written as `~`). +In both files the first `om/units.sh --check` line (rc 3, `NOT_RUN: set +OMEGA_SEED`) is a setup miss: the bridge's `build/bootstrap/omc` seed was not in +place. The last two lines are the rerun with the seed in place. + +## `head/`: #365 at 27e0b93d (bridge bc11b30b) + +| Check | rc | Verdict | +| --- | --- | --- | +| `make test-nvml` (476 checks, 22/22 mutants caught, ABI 55 facts, thin-shell guard) | 0 | PASS | +| `om/units.sh --check` | 0 | PASS | +| `crumb verify .` | 0 | PASS (42 current) | +| NEG `make test-nvml`, env unset | 2 | red as required | +| NEG `run.sh`, env unset | 77 | red as required (NOT_RUN) | +| NEG `run.sh`, non-pin omc | 69 | red as required (REFUSED) | +| NEG `run.sh`, `om/units.sh` without `FRONTEND_PIN` (new with 27e0b93d) | 74 | red as required | +| NEG `run.sh`, `om/units.sh` naming another frontend pin (new) | 69 | red as required | +| NEG `om/units.sh --check`, one byte appended to `cudapp_om_nvml_step.c` | 1 | red as required | + +## `merge-280/`: #365 merged into #280 (integ/omega-cuda-stack 630e119b, bridge d90433a9) + +#280 already carries the NVML slice (from #305, regenerated at the a3a455bd +frontend). Merging #365 into 630e119b gives 16 add/add or content conflicts. +Before 27e0b93d there were 17; `tests/nvml/run.sh` no longer conflicts. +Resolve every conflict to #280's side and the merged tree is #280's tree +exactly (both `3ba84627c9810c45276189012ab6c6a8c605d903`). So once #280 lands, +#365 adds nothing but this evidence directory. Conflicted paths: `ROADMAP.md`, +`compat/nvml/.crumb`, `evidence/NVML-2026-11-06/{commands.txt,test-nvml.log,wrong-omc.log}`, +`native/nvml/.crumb`, `om/units.sh`, `src/cudapp_native.h`, +`src/cudapp_om_nvml_{errstr,step}.{c,ident}`, `src/cudapp_om_units.ident`, +`tests/nvml/.crumb`, `tools/extract/{.crumb,drift-baseline.tsv}`. + +| Check | rc | Verdict | +| --- | --- | --- | +| `make test-nvml` (476 checks, 22/22 mutants caught) | 0 | PASS | +| `om/units.sh --check`: per-unit byte comparison (NVML included) | — | PASS: every unit compared equal; the script reached its last step | +| `om/units.sh --check`: #280's `om/no-posix.sh --check` | 128 | NOT_RUN: it reads oracle compilers with `git show` from the omega-mv checkout holding `OMEGA_OMC`; here omc is a bare copy | +| `crumb verify .` | 1 | FAIL on `tools/prof` only. This is #280's own head 630e119b (same tree), reported to the #280 owner; not NVML | +| Negative controls (env unset, non-pin omc, no/other `FRONTEND_PIN`, tampered unit) | 2, 77, 69, 74, 69, 1 | all red as required | + +## Not run + +- Live resource manager (`/dev/nvidiactl`, `/dev/nvidia0`) and GB10 chip tier: + NOT_RUN. main has no `native/nvrm/transport.om` (#281 is in #280 only), and + there is no live driver for `compat/nvml` yet. +- Utilization over the #281 transport: NOT_RUN (55888-byte control vs the + e5b32567 devcall bound, aien-dev/omega-mv#1048). +- CI does not run `make test-nvml`. `host-tests` runs `make test` without + `CUDAPP_OMC_HOST=1`, so `test-nvml` is not in `CARRIED_HOST_TESTS` there. + These host results come from the Spark only. diff --git a/evidence/NVML-2026-11-07/head/commands.txt b/evidence/NVML-2026-11-07/head/commands.txt new file mode 100644 index 00000000..f22e680b --- /dev/null +++ b/evidence/NVML-2026-11-07/head/commands.txt @@ -0,0 +1,13 @@ +head 27e0b93d9c45964159226d4a05a535bcf79fcfef started 2026-11-07T02:03:59Z +make test-nvml CUDAPP_OMC_HOST=1 OMEGA_OMC= OMEGA_BRIDGE= rc=0 last=CUDAPP-NVML HOST PASS +om/units.sh --check rc=3 last=NOT_RUN: set OMEGA_SEED to baseline compiler +crumb verify . rc=0 last=crumb verify: OK: 42 crumbs current +NEG make test-nvml (env unset) rc=2 last=make: *** [mk/nvml.mk:15: test-nvml] Error 2 +NEG run.sh (env unset) rc=77 last=NOT_RUN: set OMEGA_OMC (omega-mv e5b32567 omc) and OMEGA_BRIDGE (omega-bridge checkout) +NEG run.sh (non-pin omc) rc=69 last=REFUSED: omc digest 1b0df60a229936d785379d4a69ffabe4c1260f50c9b37230cdfbcc549f89e8eb is not the omega-mv e5b32567 pin +NEG run.sh (om/units.sh without FRONTEND_PIN) rc=74 last=REFUSED: no FRONTEND_PIN in om/units.sh +NEG run.sh (om/units.sh names another frontend pin) rc=69 last=REFUSED: bridge-seeded digest 23ff7a2356bb5d980060a4685a27ac46587013069b7d24b37c2873d7ee659b37 is not the om/units.sh frontend pin +NEG om/units.sh --check (tampered cudapp_om_nvml_step.c) rc=3 last=NOT_RUN: set OMEGA_SEED to baseline compiler +finished 2026-11-07T02:04:23Z +om/units.sh --check rc=0 last=PASS portable Omega units regenerate byte for byte +NEG om/units.sh --check (tampered cudapp_om_nvml_step.c) rc=1 last=FAIL ~/work/hive/t_44f4eda6/tmp/dest2-head-27e0b93d/cudapp_om_nvml_step.c differs from pinned tools diff --git a/evidence/NVML-2026-11-07/head/crumb.log b/evidence/NVML-2026-11-07/head/crumb.log new file mode 100644 index 00000000..7970ab6f --- /dev/null +++ b/evidence/NVML-2026-11-07/head/crumb.log @@ -0,0 +1 @@ +crumb verify: OK: 42 crumbs current diff --git a/evidence/NVML-2026-11-07/head/no-fpin.log b/evidence/NVML-2026-11-07/head/no-fpin.log new file mode 100644 index 00000000..5a867c64 --- /dev/null +++ b/evidence/NVML-2026-11-07/head/no-fpin.log @@ -0,0 +1 @@ +REFUSED: no FRONTEND_PIN in om/units.sh diff --git a/evidence/NVML-2026-11-07/head/other-fpin.log b/evidence/NVML-2026-11-07/head/other-fpin.log new file mode 100644 index 00000000..52a78cd5 --- /dev/null +++ b/evidence/NVML-2026-11-07/head/other-fpin.log @@ -0,0 +1 @@ +REFUSED: bridge-seeded digest 23ff7a2356bb5d980060a4685a27ac46587013069b7d24b37c2873d7ee659b37 is not the om/units.sh frontend pin diff --git a/evidence/NVML-2026-11-07/head/run-unset.log b/evidence/NVML-2026-11-07/head/run-unset.log new file mode 100644 index 00000000..fa8550ea --- /dev/null +++ b/evidence/NVML-2026-11-07/head/run-unset.log @@ -0,0 +1 @@ +NOT_RUN: set OMEGA_OMC (omega-mv e5b32567 omc) and OMEGA_BRIDGE (omega-bridge checkout) diff --git a/evidence/NVML-2026-11-07/head/test-nvml.log b/evidence/NVML-2026-11-07/head/test-nvml.log new file mode 100644 index 00000000..dc7978e4 --- /dev/null +++ b/evidence/NVML-2026-11-07/head/test-nvml.log @@ -0,0 +1,33 @@ +OMEGA_OMC="~/work/hive/t_44f4eda6/bin/omc" OMEGA_BRIDGE="~/work/hive/t_44f4eda6/bridge-main" sh tests/nvml/run.sh +PASS committed src/cudapp_om_nvml_step.c is the bridge output of native/nvml +PASS committed src/cudapp_om_nvml_errstr.c is the bridge output of native/nvml +PASS fake tier: CUDAPP-NVML HOST PASS (476 checks) +PASS oracle negative control (altered string rejected: CUDAPP-NVML HOST FAIL (1 of 476 checks)) +PASS abi: 55 facts equal to /usr/local/cuda/include/nvml.h +PASS shell compiles against the CUDA nvml.h prototypes +PASS thin-shell guard +PASS thin-shell guard negative control + mutant nvml 'if eq v 86': caught (CUDAPP-NVML HOST FAIL (3 of 476 checks)) + mutant nvml 'if eq v 27': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant nvml 'if or or eq x 18446744073709551614 eq x 18446744073709551610 eq x 18446744073709551597': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant nvml 'put b n uchar add 48 rem minor 10': caught (CUDAPP-NVML HOST FAIL (157 of 411 checks)) + mutant nvml 'if gt get s 16 0': caught (CUDAPP-NVML HOST FAIL (16 of 476 checks)) + mutant nvml 'if gt get s 16 1': caught (CUDAPP-NVML HOST FAIL (3 of 476 checks)) + mutant nvml 'for t ulong 26': caught (CUDAPP-NVML HOST FAIL (138 of 476 checks)) + mutant nvml 'if eq g32 b add add PO 4 mul i 4 52928': caught (CUDAPP-NVML HOST FAIL (29 of 476 checks)) + mutant query 'if ge get s 1 get s 21': caught (CUDAPP-NVML HOST FAIL (4 of 476 checks)) + mutant query 'put b add OO 3 45': caught (CUDAPP-NVML HOST FAIL (6 of 476 checks)) + mutant query 'put b n 45': caught (CUDAPP-NVML HOST FAIL (6 of 476 checks)) + mutant query 'if eq g32 b add add add PO 24 mul tg 44 16 1': caught (CUDAPP-NVML HOST FAIL (8 of 476 checks)) + mutant query 'if ge v 2147483648': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'if ne g32 b add PO 8 0': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'p64 b add OO 16 mul sub t f 1024': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant query 'o = add add PO 16 mul rem add r 71 72 776': caught (CUDAPP-NVML HOST FAIL (4 of 476 checks)) + mutant query 'p32 b OO div g 100': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant query 'p64 b add q 8 18446744073709551615': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'p32 b add q 16 4294967295': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant query 'if or gt c 72 ge r 72': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'if gt f t': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant errstr 'n = w8 o n 32496501618079059': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) +mutants caught 22/22 +CUDAPP-NVML HOST PASS diff --git a/evidence/NVML-2026-11-07/head/units-check.log b/evidence/NVML-2026-11-07/head/units-check.log new file mode 100644 index 00000000..fbd72b03 --- /dev/null +++ b/evidence/NVML-2026-11-07/head/units-check.log @@ -0,0 +1 @@ +PASS portable Omega units regenerate byte for byte diff --git a/evidence/NVML-2026-11-07/head/units-tamper.log b/evidence/NVML-2026-11-07/head/units-tamper.log new file mode 100644 index 00000000..8552907a --- /dev/null +++ b/evidence/NVML-2026-11-07/head/units-tamper.log @@ -0,0 +1 @@ +FAIL ~/work/hive/t_44f4eda6/tmp/dest2-head-27e0b93d/cudapp_om_nvml_step.c differs from pinned tools diff --git a/evidence/NVML-2026-11-07/head/unset.log b/evidence/NVML-2026-11-07/head/unset.log new file mode 100644 index 00000000..d3b92abf --- /dev/null +++ b/evidence/NVML-2026-11-07/head/unset.log @@ -0,0 +1,2 @@ +test-nvml: NOT_RUN (requires CUDAPP_OMC_HOST=1 with OMEGA_OMC and OMEGA_BRIDGE) +make: *** [mk/nvml.mk:15: test-nvml] Error 2 diff --git a/evidence/NVML-2026-11-07/head/wrong-omc.log b/evidence/NVML-2026-11-07/head/wrong-omc.log new file mode 100644 index 00000000..2cc9cee4 --- /dev/null +++ b/evidence/NVML-2026-11-07/head/wrong-omc.log @@ -0,0 +1 @@ +REFUSED: omc digest 1b0df60a229936d785379d4a69ffabe4c1260f50c9b37230cdfbcc549f89e8eb is not the omega-mv e5b32567 pin diff --git a/evidence/NVML-2026-11-07/merge-280/commands.txt b/evidence/NVML-2026-11-07/merge-280/commands.txt new file mode 100644 index 00000000..4e742862 --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/commands.txt @@ -0,0 +1,13 @@ +head 630e119bdc1682fe418a305f4548e60ff74e8153 started 2026-11-07T02:04:23Z +make test-nvml CUDAPP_OMC_HOST=1 OMEGA_OMC= OMEGA_BRIDGE= rc=0 last=CUDAPP-NVML HOST PASS +om/units.sh --check rc=3 last=NOT_RUN: set OMEGA_SEED to baseline compiler +crumb verify . rc=1 last=crumb verify: FAIL: 1 of 92 crumbs stale; run: crumb compile +NEG make test-nvml (env unset) rc=2 last=make: *** [mk/nvml.mk:15: test-nvml] Error 2 +NEG run.sh (env unset) rc=77 last=NOT_RUN: set OMEGA_OMC (omega-mv e5b32567 omc) and OMEGA_BRIDGE (omega-bridge checkout) +NEG run.sh (non-pin omc) rc=69 last=REFUSED: omc digest 1b0df60a229936d785379d4a69ffabe4c1260f50c9b37230cdfbcc549f89e8eb is not the omega-mv e5b32567 pin +NEG run.sh (om/units.sh without FRONTEND_PIN) rc=74 last=REFUSED: no FRONTEND_PIN in om/units.sh +NEG run.sh (om/units.sh names another frontend pin) rc=69 last=REFUSED: bridge-seeded digest a3a455bd77381e132215924295763e8728889d7d578278ae376de78324be8629 is not the om/units.sh frontend pin +NEG om/units.sh --check (tampered cudapp_om_nvml_step.c) rc=3 last=NOT_RUN: set OMEGA_SEED to baseline compiler +finished 2026-11-07T02:04:51Z +om/units.sh --check rc=128 last=fatal: not a git repository (or any of the parent directories): .git +NEG om/units.sh --check (tampered cudapp_om_nvml_step.c) rc=1 last=FAIL ~/work/hive/t_44f4eda6/tmp/dest2-trial-280-630e119b/cudapp_om_nvml_step.c differs from pinned tools diff --git a/evidence/NVML-2026-11-07/merge-280/crumb.log b/evidence/NVML-2026-11-07/merge-280/crumb.log new file mode 100644 index 00000000..b5fe33c0 --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/crumb.log @@ -0,0 +1,2 @@ +STALE tools/prof +crumb verify: FAIL: 1 of 92 crumbs stale; run: crumb compile diff --git a/evidence/NVML-2026-11-07/merge-280/no-fpin.log b/evidence/NVML-2026-11-07/merge-280/no-fpin.log new file mode 100644 index 00000000..5a867c64 --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/no-fpin.log @@ -0,0 +1 @@ +REFUSED: no FRONTEND_PIN in om/units.sh diff --git a/evidence/NVML-2026-11-07/merge-280/other-fpin.log b/evidence/NVML-2026-11-07/merge-280/other-fpin.log new file mode 100644 index 00000000..d00faf4a --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/other-fpin.log @@ -0,0 +1 @@ +REFUSED: bridge-seeded digest a3a455bd77381e132215924295763e8728889d7d578278ae376de78324be8629 is not the om/units.sh frontend pin diff --git a/evidence/NVML-2026-11-07/merge-280/run-unset.log b/evidence/NVML-2026-11-07/merge-280/run-unset.log new file mode 100644 index 00000000..fa8550ea --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/run-unset.log @@ -0,0 +1 @@ +NOT_RUN: set OMEGA_OMC (omega-mv e5b32567 omc) and OMEGA_BRIDGE (omega-bridge checkout) diff --git a/evidence/NVML-2026-11-07/merge-280/test-nvml.log b/evidence/NVML-2026-11-07/merge-280/test-nvml.log new file mode 100644 index 00000000..b1a009ba --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/test-nvml.log @@ -0,0 +1,33 @@ +OMEGA_OMC="~/work/hive/t_44f4eda6/bin/omc" OMEGA_BRIDGE="~/work/hive/t_44f4eda6/bridge-280" sh tests/nvml/run.sh +PASS committed src/cudapp_om_nvml_step.c is the bridge output of native/nvml +PASS committed src/cudapp_om_nvml_errstr.c is the bridge output of native/nvml +PASS fake tier: CUDAPP-NVML HOST PASS (476 checks) +PASS oracle negative control (altered string rejected: CUDAPP-NVML HOST FAIL (1 of 476 checks)) +PASS abi: 55 facts equal to /usr/local/cuda/include/nvml.h +PASS shell compiles against the CUDA nvml.h prototypes +PASS thin-shell guard +PASS thin-shell guard negative control + mutant nvml 'if eq v 86': caught (CUDAPP-NVML HOST FAIL (3 of 476 checks)) + mutant nvml 'if eq v 27': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant nvml 'if or or eq x 18446744073709551614 eq x 18446744073709551610 eq x 18446744073709551597': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant nvml 'put b n uchar add 48 rem minor 10': caught (CUDAPP-NVML HOST FAIL (157 of 411 checks)) + mutant nvml 'if gt get s 16 0': caught (CUDAPP-NVML HOST FAIL (16 of 476 checks)) + mutant nvml 'if gt get s 16 1': caught (CUDAPP-NVML HOST FAIL (3 of 476 checks)) + mutant nvml 'for t ulong 26': caught (CUDAPP-NVML HOST FAIL (138 of 476 checks)) + mutant nvml 'if eq g32 b add add PO 4 mul i 4 52928': caught (CUDAPP-NVML HOST FAIL (29 of 476 checks)) + mutant query 'if ge get s 1 get s 21': caught (CUDAPP-NVML HOST FAIL (4 of 476 checks)) + mutant query 'put b add OO 3 45': caught (CUDAPP-NVML HOST FAIL (6 of 476 checks)) + mutant query 'put b n 45': caught (CUDAPP-NVML HOST FAIL (6 of 476 checks)) + mutant query 'if eq g32 b add add add PO 24 mul tg 44 16 1': caught (CUDAPP-NVML HOST FAIL (8 of 476 checks)) + mutant query 'if ge v 2147483648': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'if ne g32 b add PO 8 0': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'p64 b add OO 16 mul sub t f 1024': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant query 'o = add add PO 16 mul rem add r 71 72 776': caught (CUDAPP-NVML HOST FAIL (4 of 476 checks)) + mutant query 'p32 b OO div g 100': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant query 'p64 b add q 8 18446744073709551615': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'p32 b add q 16 4294967295': caught (CUDAPP-NVML HOST FAIL (2 of 476 checks)) + mutant query 'if or gt c 72 ge r 72': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant query 'if gt f t': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) + mutant errstr 'n = w8 o n 32496501618079059': caught (CUDAPP-NVML HOST FAIL (1 of 476 checks)) +mutants caught 22/22 +CUDAPP-NVML HOST PASS diff --git a/evidence/NVML-2026-11-07/merge-280/units-check.log b/evidence/NVML-2026-11-07/merge-280/units-check.log new file mode 100644 index 00000000..5a904c3a --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/units-check.log @@ -0,0 +1 @@ +fatal: not a git repository (or any of the parent directories): .git diff --git a/evidence/NVML-2026-11-07/merge-280/units-tamper.log b/evidence/NVML-2026-11-07/merge-280/units-tamper.log new file mode 100644 index 00000000..76206047 --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/units-tamper.log @@ -0,0 +1 @@ +FAIL ~/work/hive/t_44f4eda6/tmp/dest2-trial-280-630e119b/cudapp_om_nvml_step.c differs from pinned tools diff --git a/evidence/NVML-2026-11-07/merge-280/unset.log b/evidence/NVML-2026-11-07/merge-280/unset.log new file mode 100644 index 00000000..d3b92abf --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/unset.log @@ -0,0 +1,2 @@ +test-nvml: NOT_RUN (requires CUDAPP_OMC_HOST=1 with OMEGA_OMC and OMEGA_BRIDGE) +make: *** [mk/nvml.mk:15: test-nvml] Error 2 diff --git a/evidence/NVML-2026-11-07/merge-280/wrong-omc.log b/evidence/NVML-2026-11-07/merge-280/wrong-omc.log new file mode 100644 index 00000000..2cc9cee4 --- /dev/null +++ b/evidence/NVML-2026-11-07/merge-280/wrong-omc.log @@ -0,0 +1 @@ +REFUSED: omc digest 1b0df60a229936d785379d4a69ffabe4c1260f50c9b37230cdfbcc549f89e8eb is not the omega-mv e5b32567 pin diff --git a/mk/nvml.mk b/mk/nvml.mk new file mode 100644 index 00000000..60f10b26 --- /dev/null +++ b/mk/nvml.mk @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# CUDA++ NVML host tier: the libnvidia-ml C ABI subset (compat/nvml) over native/nvml against the +# resource-manager fake tests/nvml/rmfake.om, the CUDA nvml.h ABI comparison and mutants. Device-free: +# the fake transport replaces omega2_nvrm_*; nothing opens /dev/nvidia*. +# Needs the pinned OMEGA_OMC and an OMEGA_BRIDGE checkout (rmfake.om and the mutants are bridged). +.PHONY: test-nvml +NVML_RUN := $(and $(filter 1,$(CUDAPP_OMC_HOST)),$(OMEGA_BRIDGE)) +ifneq ($(NVML_RUN),) +CARRIED_HOST_TESTS += test-nvml +test-nvml: + OMEGA_OMC="$(OMEGA_OMC)" OMEGA_BRIDGE="$(OMEGA_BRIDGE)" sh tests/nvml/run.sh +else +test-nvml: + @echo "test-nvml: NOT_RUN (requires CUDAPP_OMC_HOST=1 with OMEGA_OMC and OMEGA_BRIDGE)" + @exit 2 +endif diff --git a/native/nvml/.crumb b/native/nvml/.crumb new file mode 100644 index 00000000..8c19ef4e --- /dev/null +++ b/native/nvml/.crumb @@ -0,0 +1,20 @@ +{ + "extensions": { + "generated": { + "children": [], + "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "compiled_at": "2026-11-06T20:17:31Z", + "compiler": "crumb-compile/1", + "digest": "sha256:0478166416f4bc47f81c83cf72cfc8d1398581f8c2e82764ec58ebc1aeb507cb", + "evidence_files": 0, + "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "files": 5, + "generated_at_commit": "54075dceb012f08257a3138756a1e3023b9ba4a4", + "source_tree": "sha256:0d893f6962dfc1f2ba270d235a07f220071da5a86c7d6baf557e786e60e9e163" + } + }, + "layer": "development", + "name": "cudapp-nvml-omega", + "purpose": "Pure Omega units nvml_step and nvml_errstr: every decision of the CUDA++ libnvidia-ml subset (RM requests, reply decoding, error mapping, teardown)", + "schema_version": "1.0.0" +} diff --git a/native/nvml/README.md b/native/nvml/README.md new file mode 100644 index 00000000..611ab38d --- /dev/null +++ b/native/nvml/README.md @@ -0,0 +1,71 @@ + +# native/nvml: the Omega side of the CUDA++ NVML subset + +Two pure Omega units carry every decision of the libnvidia-ml subset in +`compat/nvml`: + +| Unit | Sources (composed in this order, each followed by a newline) | Export | +| --- | --- | --- | +| `nvml_step` | `nvml.om`, `query.om`, `step.om` | `omega_nvml_step(result, s[128 ulong], b[83296 uchar])` | +| `nvml_errstr` | `errstr.om` | `omega_nvml_errstr(result, code, o[64 uchar])` | + +`om/units.sh` lowers both through omega-bridge (`bridge-seeded`, pinned +omc e5b32567) into the committed `src/cudapp_om_nvml_step.c` and +`src/cudapp_om_nvml_errstr.c`; their prototypes are in `src/cudapp_native.h` +and their identities in `src/cudapp_om_nvml_*.ident` and +`src/cudapp_om_units.ident`. Never edit the generated C; edit the `.om` and +rerun `om/units.sh`. `tests/nvml/run.sh` refuses a stale generated file. + +## The step protocol + +A pure unit cannot touch the OS, so `nvml_step` is a resumable state machine. +The C shell stores the op (s0) and its arguments (s1..s4), then loops: + +1. call `omega_nvml_step`; +2. if s8 asks for an action (1 ioctl, 2 open, 3 close), perform exactly that + action through `omega2_nvrm_ioctl`, `omega2_nvrm_open_file` or + `omega2_nvrm_close_file` (`native/nvrm/transport.om`, aien-dev/CUDApp#281) + with the fd, nr, header length and params length the step chose, write the + transport result into s14 and its omega2 status into s15; +3. stop when s8 is 0; s6 is the `nvmlReturn_t`, s7 the output bytes at OO, s5 + the scalar output and s27 whether to store it. + +The full slot map is the header comment of `nvml.om`. Transport results are a +`long` carried as its two's-complement bits in a ulong (−1 is 2^64−1). + +## What each op asks the resource manager + +All layouts are cited in the sources to open-gpu-kernel-modules 580.173.02 +(commit 20e4e6e1), `src/common/sdk/nvidia/inc`. + +| NVML call | RM traffic | +| --- | --- | +| `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`, `NV_ESC_REGISTER_FD` (nr 201), device (0x80) and subdevice (0x2080) alloc, `CLASSLIST_V2` (0x800292) to find `BLACKWELL_COMPUTE_B` (0xCEC0). Reference counted. | +| `nvmlShutdown` (op 2) | last reference only: free subdevices, devices, the root client; close every fd. | +| `GetName` (op 5) | `GPU_GET_NAME_STRING` (0x20800110), ASCII flavour. | +| `GetUUID` (op 6) | `GPU_GET_GID_INFO` (0x2080014a), binary SHA-1 form, printed `GPU-8-4-4-4-12`. | +| `GetTemperature` (op 7) | two `THERMAL_SYSTEM_EXECUTE_V2` (0x20800513) passes: enumerate targets and sensors, then read the first sensor on a GPU-type target. | +| `GetMemoryInfo` (op 8) | `FB_GET_INFO_V2` (0x20801303): TOTAL_RAM_SIZE, HEAP_FREE (KiB), IS_ZERO_FB (NOT_SUPPORTED when set). | +| `GetUtilizationRates` (op 9) | `PERF_GET_GPUMON_PERFMON_UTIL_SAMPLES_V2` (0x20802096): newest sample of the 72-entry ring. | +| `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. | + +Error policy (`nvml.om`): an omega2 status other than 0 is UNKNOWN; ioctl +EPERM/EACCES is NO_PERMISSION, other errnos UNKNOWN; open ENOENT/ENXIO/ENODEV +is DRIVER_NOT_LOADED; RM status 0x1B is NO_PERMISSION, 0x0F GPU_IS_LOST, +0x56 NOT_SUPPORTED, anything else UNKNOWN. A failed `nvmlInit_v2` tears down +everything it opened and leaves the refcount at 0. + +## Known limits + +- At most 8 GPUs; more is UNKNOWN at init. +- `GetUtilizationRates` sends 55888 bytes of params. The pinned omc e5b32567 + bounds program-mode `devcall` at 16383 bytes; whether the lowered #281 + transport can carry this control is NOT_RUN (live RM is not authorized). The + program-mode `cudapp-smi` needs aien-dev/omega-mv#1048 for the same control. +- A trap inside the teardown after a failed init can leave descriptors open; + the shell then reports UNKNOWN. +- Live resource-manager behavior is NOT_RUN: every test runs against + `tests/nvml/rmfake.om`. + +Constants: `evidence/NVML-2026-11-06/wolfram.txt`. Tests: `tests/nvml/run.sh` +(`make test-nvml`). diff --git a/native/nvml/errstr.om b/native/nvml/errstr.om new file mode 100644 index 00000000..eb8aa1d3 --- /dev/null +++ b/native/nvml/errstr.om @@ -0,0 +1,258 @@ +note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +note errstr.om: nvmlErrorString for compat/nvml (CUDA++ NVML subset). Pure unit nvml_errstr. +note The text of every nvmlReturn_t value 0..30 follows the strings libnvidia-ml 580.173.02 returns +note (tests/nvml/errstr-oracle.tsv); every other value is "Unknown Error", as in libnvidia-ml. +note Each string is packed eight bytes per ulong, little-endian, so the unit stays under the bridge's +note 1024-constant limit. Packs: WolframLanguageEvaluator Map[FromDigits[Reverse[#],256]&, +note Partition[ToCharacterCode[s],UpTo[8]]] per string (evidence/NVML-2026-11-06/wolfram.txt). +note Result: the string length in bits 0..7 and the cache slot (0..30 the code, 31 Unknown) in bits 8..15; +note o receives the bytes, zero padded to 64. + +fn w8 o edit uchar 64 at ulong v ulong to ulong +n = at +for i ulong 8 +c = and shr v mul i 8 255 +if ne c 0 +put o n uchar c +n = add n 1 +end +end +ret n +end + +fn nvml_errstr code ulong o edit uchar 64 to ulong +for i ulong 64 +put o i 0 +end +n = ulong 0 +k = ulong 31 +if eq code 0 +k = ulong 0 +n = w8 o n 32496501618079059 +ret or n shl k 8 +end +if eq code 1 +k = ulong 1 +n = w8 o n 7019269490406420053 +n = w8 o n 431199250796 +ret or n shl k 8 +end +if eq code 2 +k = ulong 2 +n = w8 o n 2334106421097295433 +n = w8 o n 8389754676633367105 +ret or n shl k 8 +end +if eq code 3 +k = ulong 3 +n = w8 o n 8102104729526759246 +n = w8 o n 431198859887 +ret or n shl k 8 +end +if eq code 4 +k = ulong 4 +n = w8 o n 7163369272552681033 +n = w8 o n 8243082793294128489 +n = w8 o n 8317708060499077485 +ret or n shl k 8 +end +if eq code 5 +k = ulong 5 +n = w8 o n 2340011850872286273 +n = w8 o n 7596553777019711049 +n = w8 o n 6579578 +ret or n shl k 8 +end +if eq code 6 +k = ulong 6 +n = w8 o n 7959390263430115150 +n = w8 o n 100 +ret or n shl k 8 +end +if eq code 7 +k = ulong 7 +n = w8 o n 7163369272552681033 +n = w8 o n 8820672744039277929 +n = w8 o n 101 +ret or n shl k 8 +end +if eq code 8 +k = ulong 8 +n = w8 o n 7163369272552681033 +n = w8 o n 8392533911299581289 +n = w8 o n 8020946586210038373 +n = w8 o n 7497079 +ret or n shl k 8 +end +if eq code 9 +k = ulong 9 +n = w8 o n 5629625314317005380 +n = w8 o n 7306071626148246639 +n = w8 o n 100 +ret or n shl k 8 +end +if eq code 10 +k = ulong 10 +n = w8 o n 32780218601924948 +ret or n shl k 8 +end +if eq code 11 +k = ulong 11 +n = w8 o n 8103508940177043017 +n = w8 o n 8315181416901124212 +n = w8 o n 28558111363637364 +ret or n shl k 8 +end +if eq code 12 +k = ulong 12 +n = w8 o n 7018951417441113678 +n = w8 o n 8242266043723310450 +n = w8 o n 2338616487855092321 +n = w8 o n 431349919558 +ret or n shl k 8 +end +if eq code 13 +k = ulong 13 +n = w8 o n 7957695015192261958 +n = w8 o n 8462059330058800672 +n = w8 o n 25710 +ret or n shl k 8 +end +if eq code 14 +k = ulong 14 +n = w8 o n 7310591744862744387 +n = w8 o n 5715753362816311396 +n = w8 o n 77 +ret or n shl k 8 +end +if eq code 15 +k = ulong 15 +n = w8 o n 7791354250702180423 +n = w8 o n 7631727 +ret or n shl k 8 +end +if eq code 16 +k = ulong 16 +n = w8 o n 8462656715649011783 +n = w8 o n 8315177770710037097 +n = w8 o n 29797 +ret or n shl k 8 +end +if eq code 17 +k = ulong 17 +n = w8 o n 7305792289330516039 +n = w8 o n 7738151096046089075 +n = w8 o n 7526676582952363109 +n = w8 o n 8386109761144168549 +n = w8 o n 8391184066093215337 +n = w8 o n 28005 +ret or n shl k 8 +end +if eq code 18 +k = ulong 18 +n = w8 o n 7795575260105503300 +n = w8 o n 8511936827898356329 +n = w8 o n 7863406374178484837 +n = w8 o n 29382749079827305 +ret or n shl k 8 +end +if eq code 19 +k = ulong 19 +n = w8 o n 7070762961532382793 +n = w8 o n 7307218417350680697 +n = w8 o n 8389754659302219890 +ret or n shl k 8 +end +if eq code 20 +k = ulong 20 +n = w8 o n 7163369272552681033 +n = w8 o n 7882791524569605481 +n = w8 o n 7959151 +ret or n shl k 8 +end +if eq code 21 +k = ulong 21 +n = w8 o n 27431034381430606 +ret or n shl k 8 +end +if eq code 22 +k = ulong 22 +n = w8 o n 4846793629153380214 +n = w8 o n 8103509687752683040 +n = w8 o n 110386908131184 +ret or n shl k 8 +end +if eq code 23 +k = ulong 23 +n = w8 o n 7163369272552681033 +n = w8 o n 8315142586355311977 +n = w8 o n 126879297336687 +ret or n shl k 8 +end +if eq code 24 +k = ulong 24 +n = w8 o n 2334106421097295433 +n = w8 o n 7164775612281090630 +n = w8 o n 121 +ret or n shl k 8 +end +if eq code 25 +k = ulong 25 +n = w8 o n 8389754676633367105 +n = w8 o n 7957695011148363296 +n = w8 o n 7166460029768920352 +n = w8 o n 104 +ret or n shl k 8 +end +if eq code 26 +k = ulong 26 +n = w8 o n 7310594974728414546 +n = w8 o n 7598807797348048996 +n = w8 o n 2340029477534396015 +n = w8 o n 7954875788945482088 +n = w8 o n 7017564186559734816 +n = w8 o n 6579572 +ret or n shl k 8 +end +if eq code 27 +k = ulong 27 +n = w8 o n 7575174855750023507 +n = w8 o n 7955925901184475251 +n = w8 o n 8295763985654182432 +n = w8 o n 1702125940 +ret or n shl k 8 +end +if eq code 28 +k = ulong 28 +n = w8 o n 8030041785346584398 +n = w8 o n 6147491695809623154 +n = w8 o n 7358993333126373491 +n = w8 o n 1684960623 +ret or n shl k 8 +end +if eq code 29 +k = ulong 29 +n = w8 o n 7305808869231650130 +n = w8 o n 2336920844765195808 +n = w8 o n 2338603393875079011 +n = w8 o n 8031079655624766579 +n = w8 o n 7886488383275757600 +n = w8 o n 8391162085809418784 +n = w8 o n 7021786302599160933 +n = w8 o n 1852795252 +ret or n shl k 8 +end +if eq code 30 +k = ulong 30 +n = w8 o n 8751655660178072914 +n = w8 o n 8029390865705231728 +n = w8 o n 8245933071047794804 +n = w8 o n 2338053640979506548 +n = w8 o n 7306000154022537575 +n = w8 o n 1701013878 +ret or n shl k 8 +end +n = w8 o n 2336936577129475669 +n = w8 o n 491496043077 +ret or n shl k 8 +end diff --git a/native/nvml/nvml.om b/native/nvml/nvml.om new file mode 100644 index 00000000..a98181ce --- /dev/null +++ b/native/nvml/nvml.om @@ -0,0 +1,492 @@ +note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +note nvml.om: state, transport requests, error policy, nvmlInit_v2 and nvmlShutdown for compat/nvml. +note Pure unit nvml_step (nvml.om, query.om, step.om). The C shell compat/nvml/cudapp_nvml.c owns no +note policy: it calls omega_nvml_step, performs the one action the step asks for through +note omega2_nvrm_open_file, omega2_nvrm_close_file or omega2_nvrm_ioctl (native/nvrm/transport.om), +note writes the result back and calls the step again until the step reports done. +note RM layouts: open-gpu-kernel-modules 580.173.02 (commit 20e4e6e1), src/common/sdk/nvidia/inc. +note Constants: evidence/NVML-2026-11-06/wolfram.txt. +note +note s (ulong 128), written by C: 0 op, 1..4 arguments, 14 action result, 15 omega2 status. +note written by the step: 5 scalar output, 6 nvmlReturn_t, 7 bytes of b at OO to copy out, +note 8 action (0 done, 1 ioctl, 2 open the path at PO of length 13, 3 close), 9 fd, +note 10 ioctl nr, 11 header bytes at b 0, 12 params bytes at b PO, 27 store the scalar (1). +note state: 16 init refcount, 17 phase (1 live), 18 control fd+1, 19 root client, 20 next handle, +note 21 GPU count, 22 resume point, 23 loop index, 24 pending error, 25 cursor, 26 scratch. +note GPU k (at most 8) at 32+8k: 0 fd+1, 1 minor, 2 gpuId, 3 deviceInstance, 4 device handle, +note 5 subdevice handle, 6 compute class. +note b (uchar 83296): header 0..4607, params PO..PO+55887, output OO..OO+22799. + +const SN ulong 128 +const BN ulong 83296 +const PO ulong 4608 +const OO ulong 60496 + +fn g32 b edit uchar BN off ulong to ulong +v = ulong 0 +for i ulong 4 +v = or v shl ulong get b add off i mul i 8 +end +ret v +end + +fn g64 b edit uchar BN off ulong to ulong +v = ulong 0 +for i ulong 8 +v = or v shl ulong get b add off i mul i 8 +end +ret v +end + +fn p32 b edit uchar BN off ulong v ulong to void +for i ulong 4 +put b add off i uchar and shr v mul i 8 255 +end +end + +fn p64 b edit uchar BN off ulong v ulong to void +for i ulong 8 +put b add off i uchar and shr v mul i 8 255 +end +end + +fn bzero b edit uchar BN off ulong n ulong to void +for i ulong n +put b add off i 0 +end +end + +fn dv k ulong f ulong to ulong +ret add 32 add mul k 8 f +end + +fn done s edit ulong SN code ulong to void +put s 6 code +put s 8 0 +put s 22 0 +end + +fn act s edit ulong SN k ulong fd ulong nr ulong hl ulong pl ulong to void +put s 8 k +put s 9 fd +put s 10 nr +put s 11 hl +put s 12 pl +end + +fn cfd s edit ulong SN to ulong +ret sub get s 18 1 +end + +note NV_ESC_RM_CONTROL (nr 42), NVOS54 32-byte header: hClient 0, hObject 4, cmd 8, status 28. +fn ctl s edit ulong SN b edit uchar BN obj ulong cmd ulong n ulong to void +bzero b 0 32 +p32 b 0 get s 19 +p32 b 4 obj +p32 b 8 cmd +act s 1 cfd s 42 32 n +end + +note NV_ESC_RM_ALLOC (nr 43), NVOS21 32-byte header: hRoot 0, parent 4, hObjectNew 8, hClass 12, +note status 28. The root client (class 65, NV01_ROOT_CLIENT) takes its handle from RM. +fn alc s edit ulong SN b edit uchar BN par ulong cls ulong n ulong to void +bzero b 0 32 +p32 b 0 get s 19 +p32 b 4 par +if ne cls 65 +p32 b 8 get s 20 +put s 20 add get s 20 1 +end +p32 b 12 cls +act s 1 cfd s 43 32 n +end + +note NV_ESC_RM_FREE (nr 41), NVOS00 16-byte header: hRoot 0, parent 4, hObjectOld 8, status 12. +fn rmfree s edit ulong SN b edit uchar BN root ulong par ulong obj ulong to void +bzero b 0 16 +p32 b 0 root +p32 b 4 par +p32 b 8 obj +act s 1 cfd s 41 16 0 +end + +note The device path /dev/nvidia or /dev/nvidiactl at PO; result its length. +fn path b edit uchar BN minor ulong isctl ulong to ulong +p64 b PO 7599382571363165231 +if eq isctl 1 +p64 b add PO 8 119247139334500 +ret 14 +end +p32 b add PO 8 6383972 +n = add PO 11 +if ge minor 100 +put b n uchar add 48 div minor 100 +n = add n 1 +end +if ge minor 10 +put b n uchar add 48 rem div minor 10 10 +n = add n 1 +end +put b n uchar add 48 rem minor 10 +ret sub add n 1 PO +end + +note Transport results are a long carried as its two's-complement bits in a ulong; -1 is +note 18446744073709551615 (2^64-1), -2 ...614, -6 ...610, -13 ...603, -19 ...597. +note An ioctl result: a nonzero omega2 status or an errno other than EPERM/EACCES (NO_PERMISSION 4) +note is UNKNOWN (999). +fn ioerr s edit ulong SN to ulong +if ne get s 15 0 +ret 999 +end +x = get s 14 +if eq x 0 +ret 0 +end +if or eq x 18446744073709551615 eq x 18446744073709551603 +ret 4 +end +ret 999 +end + +note An open result: ENOENT, ENXIO or ENODEV is DRIVER_NOT_LOADED (9), EPERM or EACCES NO_PERMISSION. +note A non-negative result (below 2^63) is the descriptor. +fn operr s edit ulong SN to ulong +if ne get s 15 0 +ret 999 +end +x = get s 14 +if lt x 9223372036854775808 +ret 0 +end +if or or eq x 18446744073709551614 eq x 18446744073709551610 eq x 18446744073709551597 +ret 9 +end +if or eq x 18446744073709551615 eq x 18446744073709551603 +ret 4 +end +ret 999 +end + +note RM status (nvstatuscodes.h): 0x1B INSUFFICIENT_PERMISSIONS -> 4, 0x0F GPU_IS_LOST -> 15, +note 0x56 NOT_SUPPORTED -> 3, anything else UNKNOWN. +fn rmerr v ulong to ulong +if eq v 0 +ret 0 +end +if eq v 27 +ret 4 +end +if eq v 15 +ret 15 +end +if eq v 86 +ret 3 +end +ret 999 +end + +fn chk s edit ulong SN b edit uchar BN off ulong to ulong +e = ioerr s +if ne e 0 +ret e +end +ret rmerr g32 b off +end + +note Teardown, resume points 100 and 101: per GPU free the subdevice, free the device, close its fd; +note then free the root client and close the control fd. Cursor s 25 walks items 0..25. +fn tdtry s edit ulong SN b edit uchar BN t ulong to bool +if lt t 24 +d = div t 3 +r = rem t 3 +if eq r 0 +x = get s dv d 5 +if ne x 0 +put s dv d 5 0 +rmfree s b get s 19 get s dv d 4 x +ret true +end +ret false +end +if eq r 1 +x = get s dv d 4 +if ne x 0 +put s dv d 4 0 +rmfree s b get s 19 get s 19 x +ret true +end +ret false +end +x = get s dv d 0 +if ne x 0 +put s dv d 0 0 +act s 3 sub x 1 0 0 0 +ret true +end +ret false +end +if eq t 24 +x = get s 19 +if ne x 0 +rmfree s b x x x +put s 19 0 +ret true +end +ret false +end +x = get s 18 +if ne x 0 +act s 3 sub x 1 0 0 0 +put s 18 0 +ret true +end +ret false +end + +fn tdstep s edit ulong SN b edit uchar BN to void +for t ulong 26 +if ge t get s 25 +if tdtry s b t +put s 25 add t 1 +put s 22 101 +ret +end +end +end +e = get s 24 +if eq e 0 +e = get s 26 +end +for i ulong 96 +put s add 16 i 0 +end +done s e +end + +fn tdres s edit ulong SN b edit uchar BN to void +e = ulong 0 +if eq get s 8 1 +e = chk s b 12 +else +e = ioerr s +end +if ne e 0 +put s 26 999 +end +tdstep s b +end + +fn fail s edit ulong SN b edit uchar BN code ulong to void +put s 24 code +put s 25 0 +put s 26 0 +tdstep s b +end + +note Next GPU: NV0000_CTRL_CMD_GPU_GET_ID_INFO_V2 (0x205, ctrl0000gpu.h:172-185) gives deviceInstance. +fn devnext s edit ulong SN b edit uchar BN to void +k = get s 23 +if ge k get s 21 +put s 17 1 +put s 16 1 +done s 0 +ret +end +bzero b PO 32 +p32 b PO get s dv k 2 +ctl s b get s 19 517 32 +put s 22 5 +end + +note NV_ESC_CARD_INFO (nr 200): 64 entries of 72 bytes, valid 0, gpu_id 16, minor_number 56. +fn cards s edit ulong SN b edit uchar BN to void +e = ioerr s +if ne e 0 +fail s b e +ret +end +n = ulong 0 +for i ulong 64 +o = mul i 72 +if ne get b o 0 +if ge n 8 +fail s b 999 +ret +end +m = g32 b add o 56 +if gt m 255 +fail s b 999 +ret +end +put s dv n 1 m +put s dv n 2 g32 b add o 16 +n = add n 1 +end +end +put s 21 n +put s 23 0 +devnext s b +end + +note NV0080_CTRL_CMD_GPU_GET_CLASSLIST_V2 (0x800292, ctrl0080gpu.h:506): numClasses 0, classList 4. +note 52928 is BLACKWELL_COMPUTE_B (0xCEC0), the class GET_PIDS filters on. +fn clist s edit ulong SN b edit uchar BN k ulong to void +n = g32 b PO +if gt n 200 +fail s b 999 +ret +end +c = ulong 0 +for i ulong n +if eq g32 b add add PO 4 mul i 4 52928 +c = 52928 +end +end +put s dv k 6 c +put s 23 add k 1 +devnext s b +end + +fn devstep s edit ulong SN b edit uchar BN pc ulong to void +k = get s 23 +if eq pc 6 +e = operr s +if ne e 0 +fail s b e +ret +end +put s dv k 0 add get s 14 1 +bzero b 0 4 +p32 b 0 cfd s +act s 1 get s 14 201 4 0 +put s 22 7 +ret +end +e = ulong 0 +if eq pc 7 +e = ioerr s +else +e = chk s b 28 +end +if ne e 0 +fail s b e +ret +end +if eq pc 5 +put s dv k 3 g32 b add PO 8 +n = path b get s dv k 1 0 +act s 2 0 0 0 0 +put s 13 n +put s 22 6 +ret +end +if eq pc 7 +bzero b PO 56 +p32 b PO get s dv k 3 +p32 b add PO 4 get s 19 +alc s b get s 19 128 56 +put s 22 8 +ret +end +if eq pc 8 +put s dv k 4 g32 b 8 +bzero b PO 4 +alc s b get s dv k 4 8320 4 +put s 22 9 +ret +end +if eq pc 9 +put s dv k 5 g32 b 8 +bzero b PO 804 +ctl s b get s dv k 4 8389266 804 +put s 22 10 +ret +end +clist s b k +end + +note nvmlInit_v2: a live library only counts the reference. Otherwise open /dev/nvidiactl, allocate +note the root client, read the card table, then per GPU: id info, open and register its device +note node, allocate NV01_DEVICE_0 (128) and NV20_SUBDEVICE_0 (8320), read the class list. +note Any failure tears everything down and returns its code with the refcount still 0. +fn init s edit ulong SN b edit uchar BN to void +pc = get s 22 +if ge pc 100 +tdres s b +ret +end +if eq pc 0 +if gt get s 16 0 +put s 16 add get s 16 1 +done s 0 +ret +end +for i ulong 96 +put s add 16 i 0 +end +put s 20 3472883713 +n = path b 0 1 +act s 2 0 0 0 0 +put s 13 n +put s 22 1 +ret +end +if eq pc 1 +e = operr s +if ne e 0 +done s e +ret +end +put s 18 add get s 14 1 +bzero b PO 4 +alc s b 0 65 0 +put s 22 2 +ret +end +if eq pc 2 +e = chk s b 28 +if ne e 0 +fail s b e +ret +end +x = g32 b 8 +if eq x 0 +fail s b 999 +ret +end +put s 19 x +bzero b 0 4608 +act s 1 cfd s 200 4608 0 +put s 22 3 +ret +end +if eq pc 3 +cards s b +ret +end +devstep s b pc +end + +note nvmlShutdown: UNINITIALIZED (1) without a live library; the last reference tears down and +note reports UNKNOWN if any free or close failed (the library is closed either way). +fn shut s edit ulong SN b edit uchar BN to void +pc = get s 22 +if ge pc 100 +tdres s b +ret +end +if eq get s 16 0 +done s 1 +ret +end +if gt get s 16 1 +put s 16 sub get s 16 1 +done s 0 +ret +end +put s 24 0 +put s 25 0 +put s 26 0 +tdstep s b +end diff --git a/native/nvml/query.om b/native/nvml/query.om new file mode 100644 index 00000000..dd5c83fd --- /dev/null +++ b/native/nvml/query.om @@ -0,0 +1,486 @@ +note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +note query.om: the device queries of compat/nvml, after nvml.om. Every query first checks, in order: +note a live library (else UNINITIALIZED 1), the GPU index s 1 below the count and a non-null output +note s 2 (else INVALID_ARGUMENT 2), as nvml.h:4432-4443 and its siblings document. + +fn pre s edit ulong SN to ulong +if eq get s 17 0 +ret 1 +end +if ge get s 1 get s 21 +ret 2 +end +if eq get s 2 0 +ret 2 +end +ret 0 +end + +fn hsub s edit ulong SN to ulong +ret get s dv get s 1 5 +end + +fn scal s edit ulong SN v ulong to void +put s 5 v +put s 27 1 +end + +note nvmlDeviceGetCount_v2 (nvml.h:4221) and nvmlDeviceGetHandleByIndex_v2 (nvml.h:4289). +fn count s edit ulong SN to void +if eq get s 17 0 +done s 1 +ret +end +if eq get s 2 0 +done s 2 +ret +end +scal s get s 21 +done s 0 +end + +fn handle s edit ulong SN to void +e = pre s +if ne e 0 +done s e +ret +end +scal s get s 1 +done s 0 +end + +note nvmlDeviceGetName (nvml.h:4432): NV2080_CTRL_CMD_GPU_GET_NAME_STRING (0x20800110, +note ctrl2080gpu.h:318), 132-byte params, flags 0 (ASCII) at 0, the name at 4. The name must be +note printable ASCII of 1..95 bytes ended by a zero within its 128 bytes. A length s 3 below the name +note plus its terminator is INSUFFICIENT_SIZE (7). +fn name s edit ulong SN b edit uchar BN to void +if eq get s 22 0 +e = pre s +if ne e 0 +done s e +ret +end +bzero b PO 132 +ctl s b hsub s 545259792 132 +put s 22 1 +ret +end +e = chk s b 28 +if ne e 0 +done s e +ret +end +if ne g32 b PO 0 +done s 999 +ret +end +n = ulong 0 +z = false +for i ulong 128 +c = get b add add PO 4 i +if not z +if eq c 0 +z = true +n = i +else +if or lt c 32 gt c 126 +done s 999 +ret +end +end +end +end +if or not z or eq n 0 gt n 95 +done s 999 +ret +end +if lt get s 3 add n 1 +done s 7 +ret +end +for i ulong n +put b add OO i get b add add PO 4 i +end +put b add OO n 0 +put s 7 add n 1 +done s 0 +end + +fn hexc d ulong to uchar +if lt d 10 +ret uchar add 48 d +end +ret uchar add 87 d +end + +note nvmlDeviceGetUUID (nvml.h:4816): NV2080_CTRL_CMD_GPU_GET_GID_INFO (0x2080014a, +note ctrl2080gpu.h:1775-1798), 268-byte params: index 0, flags 4 = 2 (BINARY, SHA1), length 8 = 16, +note data 12. Printed as nvidia-smi does: GPU- then 8-4-4-4-12 lower-case hex, 40 bytes plus a zero. +fn uuid s edit ulong SN b edit uchar BN to void +if eq get s 22 0 +e = pre s +if ne e 0 +done s e +ret +end +bzero b PO 268 +p32 b add PO 4 2 +ctl s b hsub s 545259850 268 +put s 22 1 +ret +end +e = chk s b 28 +if ne e 0 +done s e +ret +end +if ne g32 b add PO 8 16 +done s 999 +ret +end +if lt get s 3 41 +done s 7 +ret +end +put b OO 71 +put b add OO 1 80 +put b add OO 2 85 +put b add OO 3 45 +n = add OO 4 +for i ulong 16 +if or or eq i 4 eq i 6 or eq i 8 eq i 10 +put b n 45 +n = add n 1 +end +v = ulong get b add add PO 12 i +put b n hexc shr v 4 +put b add n 1 hexc and v 15 +n = add n 2 +end +put b n 0 +put s 7 41 +done s 0 +end + +note Thermal instructions (NV2080_CTRL_CMD_THERMAL_SYSTEM_EXECUTE_V2 0x20800513, ctrl2080thermal.h:135), +note 1432-byte params: API version 1 at 0, instruction size 44 at 8, count at 20, 32 instructions +note from 24, opcode at +8, operands at +12 and +16, executed flag +4 and result +0. +fn thins b edit uchar BN k ulong op ulong a ulong to void +o = add add PO 24 mul k 44 +p32 b add o 8 op +p32 b add o 12 a +end + +fn thgo s edit ulong SN b edit uchar BN n ulong to void +p32 b PO 1 +p32 b add PO 8 44 +p32 b add PO 20 n +ctl s b hsub s 545260819 1432 +end + +fn thok b edit uchar BN n ulong to bool +for k ulong n +o = add add PO 24 mul k 44 +if or ne g32 b add o 4 1 ne g32 b o 0 +ret false +end +end +ret true +end + +fn thread s edit ulong SN b edit uchar BN to void +nt = get s 25 +ns = get s 26 +for k ulong ns +q = add nt mul k 2 +tg = g32 b add add add PO 24 mul q 44 16 +if ge tg nt +done s 999 +ret +end +if eq g32 b add add add PO 24 mul tg 44 16 1 +v = g32 b add add add PO 24 mul add q 1 44 16 +if ge v 2147483648 +done s 999 +ret +end +scal s v +done s 0 +ret +end +end +done s 3 +end + +note nvmlDeviceGetTemperature (nvml.h:5571), sensor s 3 must be NVML_TEMPERATURE_GPU (0, nvml.h:936). +note Pass 1 counts targets (opcode 256) and sensors (1280); pass 2 asks each target's type (257) and +note each sensor's target (1312) and reading (5376). The first sensor on a GPU-type (1) target +note answers; none is NOT_SUPPORTED (3). More than 32 instructions or a negative reading is UNKNOWN. +fn temp s edit ulong SN b edit uchar BN to void +pc = get s 22 +if eq pc 0 +e = pre s +if ne e 0 +done s e +ret +end +if ne get s 3 0 +done s 2 +ret +end +bzero b PO 1432 +thins b 0 256 0 +thins b 1 1280 0 +thgo s b 2 +put s 22 1 +ret +end +e = chk s b 28 +if ne e 0 +done s e +ret +end +if eq pc 2 +if not thok b add get s 25 mul get s 26 2 +done s 999 +ret +end +thread s b +ret +end +if not thok b 2 +done s 999 +ret +end +nt = g32 b add PO 36 +ns = g32 b add PO 80 +if gt add nt mul ns 2 32 +done s 999 +ret +end +if eq ns 0 +done s 3 +ret +end +put s 25 nt +put s 26 ns +bzero b PO 1432 +for t ulong nt +thins b t 257 t +end +for k ulong ns +thins b add nt mul k 2 1312 k +thins b add add nt mul k 2 1 5376 k +end +thgo s b add nt mul ns 2 +put s 22 2 +end + +note nvmlDeviceGetMemoryInfo (nvml.h:6330): NV2080_CTRL_CMD_FB_GET_INFO_V2 (0x20801303, +note ctrl2080fb.h:459), 1028-byte params: count 0, then {index, data} pairs from 4. Asks IS_ZERO_FB +note (0x36), TOTAL_RAM_SIZE (0x08) and HEAP_FREE (0x16), both in KiB (ctrl2080fb.h:310,328,360). A GPU +note without framebuffer is NOT_SUPPORTED (nvml.h:6352-6354). Output nvmlMemory_t {total, free, used}. +fn mem s edit ulong SN b edit uchar BN to void +if eq get s 22 0 +e = pre s +if ne e 0 +done s e +ret +end +bzero b PO 1028 +p32 b PO 3 +p32 b add PO 4 54 +p32 b add PO 12 8 +p32 b add PO 20 22 +ctl s b hsub s 545264387 1028 +put s 22 1 +ret +end +e = chk s b 28 +if ne e 0 +done s e +ret +end +if or or ne g32 b add PO 4 54 ne g32 b add PO 12 8 ne g32 b add PO 20 22 +done s 999 +ret +end +if ne g32 b add PO 8 0 +done s 3 +ret +end +t = g32 b add PO 16 +f = g32 b add PO 24 +if gt f t +done s 999 +ret +end +p64 b OO mul t 1024 +p64 b add OO 8 mul f 1024 +p64 b add OO 16 mul sub t f 1024 +put s 7 24 +done s 0 +end + +note nvmlDeviceGetUtilizationRates (nvml.h:6671): the newest PERFMON sample as in native/smi/util.om, +note NV2080_CTRL_CMD_PERF_GET_GPUMON_PERFMON_UTIL_SAMPLES_V2 (0x20802096, ctrl2080perf.h:447-592), +note 55888-byte params: type 2 at 0, bufSize 55872 at 4, count 8, tracker 12, 72 samples of 776 from +note 16; newest at (tracker+71) mod 72, fb.util +8, gr.util +136 in percent*100. An empty ring or a +note malformed reply is UNKNOWN (999). Output nvmlUtilization_t {gpu, memory} in percent. +fn util s edit ulong SN b edit uchar BN to void +if eq get s 22 0 +e = pre s +if ne e 0 +done s e +ret +end +bzero b PO 55888 +put b PO 2 +p32 b add PO 4 55872 +ctl s b hsub s 545267862 55888 +put s 22 1 +ret +end +e = chk s b 28 +if ne e 0 +done s e +ret +end +c = g32 b add PO 8 +r = g32 b add PO 12 +if or gt c 72 ge r 72 +done s 999 +ret +end +o = add add PO 16 mul rem add r 71 72 776 +if or eq c 0 eq g64 b o 0 +done s 999 +ret +end +g = g32 b add o 136 +m = g32 b add o 8 +if or gt g 10000 gt m 10000 +done s 999 +ret +end +p32 b OO div g 100 +p32 b add OO 4 div m 100 +put s 7 8 +done s 0 +end + +note One NV2080_CTRL_CMD_GPU_GET_PID_INFO (0x2080018e, ctrl2080gpu.h:3590-3666) chunk of at most 200 +note PIDs from s 23: count at 0, 72-byte entries from 8: pid 0, index 4 = 0 (VIDEO_MEMORY_USAGE), +note result 8, memPrivate 16. +fn pchunk s edit ulong SN b edit uchar BN to void +k = get s 23 +m = sub get s 25 k +if gt m 200 +m = 200 +end +bzero b PO 14408 +p32 b PO m +for i ulong m +p32 b add add PO 8 mul i 72 g32 b add OO mul add k i 24 +end +put s 26 m +ctl s b hsub s 545259918 14408 +put s 22 2 +end + +fn pdone s edit ulong SN b edit uchar BN to void +e = chk s b 28 +if ne e 0 +done s e +ret +end +k = get s 23 +for i ulong get s 26 +o = add add PO 8 mul i 72 +q = add OO mul add k i 24 +if ne g32 b o g32 b q +done s 999 +ret +end +if ne g32 b add o 8 0 +p64 b add q 8 18446744073709551615 +else +p64 b add q 8 g64 b add o 16 +end +end +k = add k get s 26 +put s 23 k +if lt k get s 25 +pchunk s b +ret +end +scal s k +put s 7 mul k 24 +done s 0 +end + +note nvmlDeviceGetComputeRunningProcesses_v3 (nvml.h:6944-6985): s 2 infoCount non-null, s 3 its +note value, s 4 infos non-null (may be null only when s 3 is 0). NV2080_CTRL_CMD_GPU_GET_PIDS +note (0x2080018d, ctrl2080gpu.h:3521-3540), 3812-byte params: idType 0 (CLASS), id 4 = the compute +note class, count 8 (at most 950), pids from 12. More PIDs than s 3 is INSUFFICIENT_SIZE with the +note count stored. Output nvmlProcessInfo_t {pid 0, usedGpuMemory 8, gpuInstanceId 16, +note computeInstanceId 20} (nvml.h:301-312), ids 0xFFFFFFFF without MIG; a failed PID entry reports +note usedGpuMemory NVML_VALUE_NOT_AVAILABLE (nvml.h:155). +fn procs s edit ulong SN b edit uchar BN to void +pc = get s 22 +if eq pc 2 +pdone s b +ret +end +if eq pc 0 +e = pre s +if ne e 0 +done s e +ret +end +if and eq get s 4 0 ne get s 3 0 +done s 2 +ret +end +c = get s dv get s 1 6 +if eq c 0 +done s 3 +ret +end +bzero b PO 3812 +p32 b add PO 4 c +ctl s b hsub s 545259917 3812 +put s 22 1 +ret +end +e = chk s b 28 +if ne e 0 +done s e +ret +end +n = g32 b add PO 8 +if gt n 950 +done s 999 +ret +end +if gt n get s 3 +scal s n +done s 7 +ret +end +if eq n 0 +scal s 0 +done s 0 +ret +end +for i ulong n +q = add OO mul i 24 +p32 b q g32 b add add PO 12 mul i 4 +p64 b add q 8 0 +p32 b add q 16 4294967295 +p32 b add q 20 4294967295 +end +put s 25 n +put s 23 0 +pchunk s b +end diff --git a/native/nvml/step.om b/native/nvml/step.om new file mode 100644 index 00000000..d3eadf59 --- /dev/null +++ b/native/nvml/step.om @@ -0,0 +1,57 @@ +note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +note step.om: the exported nvml_step, after nvml.om and query.om. Ops in s 0: 1 nvmlInit_v2, +note 2 nvmlShutdown, 3 GetCount_v2, 4 GetHandleByIndex_v2, 5 GetName, 6 GetUUID, 7 GetTemperature, +note 8 GetMemoryInfo, 9 GetUtilizationRates, 10 GetComputeRunningProcesses_v3. A new call +note (resume point 0) clears the outputs. Result 0; an unknown op answers UNKNOWN (999). + +fn nvml_step s edit ulong SN b edit uchar BN to ulong +if eq get s 22 0 +put s 5 0 +put s 6 0 +put s 7 0 +put s 27 0 +end +op = get s 0 +if eq op 1 +init s b +ret 0 +end +if eq op 2 +shut s b +ret 0 +end +if eq op 3 +count s +ret 0 +end +if eq op 4 +handle s +ret 0 +end +if eq op 5 +name s b +ret 0 +end +if eq op 6 +uuid s b +ret 0 +end +if eq op 7 +temp s b +ret 0 +end +if eq op 8 +mem s b +ret 0 +end +if eq op 9 +util s b +ret 0 +end +if eq op 10 +procs s b +ret 0 +end +done s 999 +ret 0 +end diff --git a/om/units.sh b/om/units.sh index 45d1a23c..6bc78084 100755 --- a/om/units.sh +++ b/om/units.sh @@ -20,6 +20,8 @@ MOE="om/moe/moe_plan.om om/moe/moe_group.om om/moe/moe_ids32.om om/moe/moe_maps3 CLOSURE="$REAL,om/cache/digest.om,om/moe/moe_windows.om,om/moe/moe_group.om,native/learn53/moe-closure.om" OBSERVE="closure_code=$CLOSURE,om/moe/closure_code.om closure_launch=$CLOSURE,om/moe/closure_launch.om closure_dir=$CLOSURE,om/moe/closure_dir.om closure_alloc=$CLOSURE,om/moe/closure_alloc.om closure_series=$CLOSURE,om/moe/closure_series.om" UNITS="${OMEGA_UNITS:-om/encoder/bw_enc_sm121.om om/cubin/cubin_elf.om om/mathlibs/mathlibs_ir.om om/encoder/ampere_enc_sm86.om om/encoder/amp_runtime.om repack=$QUANT,om/quant/repack.om quant_wire=$QUANT,om/quant/runtime.om compose=$COMP encode=$ENC cache_runtime=om/cache/residency.om,om/cache/runtime.om lease=om/cache/residency.om,om/cache/runtime.om,om/cache/lease.om slotrev=om/cache/residency.om,om/cache/slotrev.om command=om/cache/residency.om,om/cache/command.om validate=$CACHE,$COMP,$ENC,om/components/admit.om,om/cache/validate.om digest=$REAL,om/cache/digest.om,om/cache/key.om code_digest=$REAL,om/cache/digest.om,om/cache/codekey.om templates=$REAL,om/cache/digest.om,om/cache/templates.om graph=$PIPE,om/pipeline/runtime.om context_lookup=om/pipeline/context.om,om/pipeline/context_abi.om binding=$REAL,om/pipeline/binding.om $MOE closure_pack=$CLOSURE,om/moe/closure_pack.om closure_bind=$CLOSURE,om/moe/closure_bind.om closure_blob=$CLOSURE,om/moe/closure_blob.om closure_cover=$CLOSURE,om/pipeline/mccover.om,om/pipeline/coverage_entry.om closure_intent=$CLOSURE,om/pipeline/mccover.om closure_seal=$CLOSURE,om/pipeline/mccover.om,om/pipeline/seal_entry.om closure_reseal=$CLOSURE,om/pipeline/mccover.om,om/pipeline/seal_reuse.om $OBSERVE prefill_shape=om/prefill-shape/admit.om prefill_reading=om/prefill-shape/reading.om prefill_workspace=om/prefill-shape/workspace.om prefill_order=om/prefill-shape/order.om attn_mirror_plan=om/attention-mirror/plan.om attn_mirror_step=om/attention-mirror/step.om q38_runtime=om/q38-head/envelope.om,om/q38-head/plan.om q38_emit=om/components/bw_alloc.om,om/components/bw_effect.om,om/components/bw_check.om,om/components/bw_project.om,$ENC,om/q38-head/bounds.om,om/q38-head/emit.om}" +NVML="nvml_step=native/nvml/nvml.om,native/nvml/query.om,native/nvml/step.om nvml_errstr=native/nvml/errstr.om" +[ -n "${OMEGA_UNITS:-}" ] || UNITS="$UNITS $NVML" PURE_UNITS="revision=om/pipeline/revision.om epoch=om/pipeline/epoch.om f16=om/numeric/f16.om" DEST="${OMEGA_UNITS_DEST:-$ROOT/src}" OUTS="cudapp_native.h cudapp_om_units.ident" diff --git a/src/cudapp_native.h b/src/cudapp_native.h index 7b0fb1b9..e4ec76c6 100644 --- a/src/cudapp_native.h +++ b/src/cudapp_native.h @@ -58,6 +58,8 @@ uint32_t omega_native_attnmirplan(uint64_t *result, const void *p0, uint64_t p0_ uint32_t omega_native_attnmirnext(uint64_t *result, uint64_t p0, uint64_t p1, uint64_t p2, uint64_t p3); uint32_t omega_q38_runtime(uint64_t *result, const void *p0, uint64_t p0_n, const void *p1, uint64_t p1_n, void *p2, uint64_t p2_n); uint32_t omega_q38_emit(uint64_t *result, void *p0, uint64_t p0_n); +uint32_t omega_nvml_step(uint64_t *result, void *p0, uint64_t p0_n, void *p1, uint64_t p1_n); +uint32_t omega_nvml_errstr(uint64_t *result, uint64_t p0, void *p1, uint64_t p1_n); uint32_t omega_native_revision(uint64_t *result, uint64_t p0); uint32_t omega_native_epoch(uint64_t *result, uint64_t p0); uint32_t omega_native_f16(uint64_t *result, uint64_t p0); diff --git a/src/cudapp_om_nvml_errstr.c b/src/cudapp_om_nvml_errstr.c new file mode 100644 index 00000000..3f610db6 --- /dev/null +++ b/src/cudapp_om_nvml_errstr.c @@ -0,0 +1,323 @@ +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wmisleading-indentation" +#endif +/* Emitted by Omega Bridge. GNU C11, POSIX. Scalars use canonical 64-bit bits. */ +#include +#include +#include +#include +#include +static _Thread_local jmp_buf o_jmp; +static _Thread_local int o_busy; +static __attribute__((noreturn)) void o_trap(int c){if(o_busy)longjmp(o_jmp,c);_exit(100+c);} +static _Thread_local unsigned o_depth; +static void o_enter(void){if(++o_depth>128)o_trap(6);} +static uint64_t o_leave(uint64_t v){--o_depth;return v;} +static unsigned o_width(unsigned t){static const unsigned w[]={0,1,8,16,32,64,8,16,32,64};return w[t];} +static __int128 o_value(unsigned t,uint64_t v){return t>=6 && v>>63 ? (__int128)v-(((__int128)1)<<64):(__int128)v;} +static uint64_t o_norm(unsigned t,__int128 v,int code){unsigned w=o_width(t);if(t>=6){__int128 m=((__int128)1)<<(w-1);if(v< -m||v>=m)o_trap(code);}else {if(v<0||(__uint128_t)v>=(((__uint128_t)1)<=6&&op<=11){switch(op){case 6:return x==y;case 7:return x!=y;case 8:return xy;default:return x>=y;}} + if(op==12)return a&b;if(op==13)return a|b;if(op==14)return a^b; + if(op==15||op==16){if(b>=w)o_trap(7);if(op==15)return t>=6?o_norm(t,x*(((__int128)1)<>b;if(!b)return a;return (a>>b)|((a>>63)?(UINT64_MAX<<(64-b)):0);} + if(op==17){if(t<6)return (0-a)&mask;return o_norm(t,-x,1);}if(op==18)return t==1?!a:(t>=6?~a:(~a)&mask); + if(op==4||op==5){if(!b)o_trap(2);z=op==4?x/y:x%y;return t>=6?o_norm(t,z,1):(uint64_t)z;} + if(t<6){if(op==1)return (a+b)&mask;if(op==2)return (a-b)&mask;return (a*b)&mask;} + if(op==1)z=x+y;if(op==2)z=x-y;if(op==3)z=x*y;return o_norm(t,z,1); +} +static uint64_t o_get(const void *p,uint64_t n,uint64_t i,unsigned t){if(i>=n)o_trap(3);switch(t){case 2:return ((const uint8_t*)p)[i];case 3:return ((const uint16_t*)p)[i];case 4:return ((const uint32_t*)p)[i];case 5:return ((const uint64_t*)p)[i];case 6:return (uint64_t)((const int8_t*)p)[i];case 7:return (uint64_t)((const int16_t*)p)[i];case 8:return (uint64_t)((const int32_t*)p)[i];default:return (uint64_t)((const int64_t*)p)[i];}} +static void o_put(void *p,uint64_t n,uint64_t i,uint64_t v,unsigned t){if(i>=n)o_trap(3);o_norm(t,o_value(t,v),5);switch(t){case 2:((uint8_t*)p)[i]=(uint8_t)v;break;case 3:((uint16_t*)p)[i]=(uint16_t)v;break;case 4:((uint32_t*)p)[i]=(uint32_t)v;break;case 5:((uint64_t*)p)[i]=v;break;case 6:((int8_t*)p)[i]=(int8_t)o_value(t,v);break;case 7:((int16_t*)p)[i]=(int16_t)o_value(t,v);break;case 8:((int32_t*)p)[i]=(int32_t)o_value(t,v);break;default:((int64_t*)p)[i]=(int64_t)o_value(t,v);}} +static void o_fill(void *p,uint64_t n,uint64_t v,unsigned t){for(uint64_t i=0;in||len>n-off)o_trap(3);int f=(int)o_value(8,fd);ssize_t r=op==1?read(f,(uint8_t*)p+off,(size_t)len):write(f,(const uint8_t*)p+off,(size_t)len);return r<0?(uint64_t)(-(int64_t)errno):(uint64_t)r;} +static int o_valid(unsigned t,uint64_t v){unsigned w=o_width(t);__int128 x=o_value(t,v);__int128 m=((__int128)1)<<(t>=6?w-1:w);return t>=6?x>=-m&&x=0&&x +#include +#if FLT_RADIX != 2 || FLT_MANT_DIG != 24 || FLT_MAX_EXP != 128 || DBL_MANT_DIG != 53 || DBL_MAX_EXP != 1024 || FLT_EVAL_METHOD != 0 +#error unsupported binary32 or binary64 environment +#endif +#if defined(__FAST_MATH__) +#error fast math is not a supported Omega environment +#endif +static int o_fnan(unsigned t,uint64_t a){return t==11?((a>>23&255)==255&&(a&UINT64_C(0x7fffff))!=0):((a>>52&2047)==2047&&(a&UINT64_C(0xfffffffffffff))!=0);} +static uint64_t o_fpn(unsigned t,uint64_t a,uint64_t b,uint64_t r){uint64_t q=t==11?UINT64_C(0x400000):UINT64_C(0x8000000000000);if(!o_fnan(t,r))return r;if(o_fnan(t,a)&&!(a&q))return a|q;if(o_fnan(t,b)&&!(b&q))return b|q;if(o_fnan(t,a))return a;if(o_fnan(t,b))return b;return t==11?UINT64_C(0x7fc00000):UINT64_C(0x7ff8000000000000);} +static uint64_t o_fp(unsigned op,unsigned t,uint64_t a,uint64_t b){if(t==11){uint32_t ua=(uint32_t)a,ub=(uint32_t)b,ur;float x,y;volatile float z;__builtin_memcpy(&x,&ua,4);__builtin_memcpy(&y,&ub,4);switch(op){case 1:z=x+y;break;case 2:z=x-y;break;case 3:z=x*y;break;case 4:z=x/y;break;case 6:return x==y;case 7:return x!=y;case 8:return xy;case 11:return x>=y;case 17:return ua^UINT32_C(0x80000000);case 19:return ua&UINT32_C(0x7fffffff);default:__builtin_trap();}__builtin_memcpy(&ur,(const void*)&z,4);return o_fpn(11,ua,ub,ur);}uint64_t ur;double x,y;volatile double z;__builtin_memcpy(&x,&a,8);__builtin_memcpy(&y,&b,8);switch(op){case 1:z=x+y;break;case 2:z=x-y;break;case 3:z=x*y;break;case 4:z=x/y;break;case 6:return x==y;case 7:return x!=y;case 8:return xy;case 11:return x>=y;case 17:return a^UINT64_C(0x8000000000000000);case 19:return a&UINT64_C(0x7fffffffffffffff);default:__builtin_trap();}__builtin_memcpy(&ur,(const void*)&z,8);return o_fpn(12,a,b,ur);} +static uint64_t o_fcv(unsigned t,unsigned s,uint64_t a){uint32_t u=(uint32_t)a;float f;double x;if(s==t)return a;if(s<11){if(t==11){volatile float z=s>=6?(float)(int64_t)a:(float)a;__builtin_memcpy(&u,(const void*)&z,4);return u;}volatile double z=s>=6?(double)(int64_t)a:(double)a;__builtin_memcpy(&a,(const void*)&z,8);return a;}if(t==12){if(o_fnan(11,a))return (uint64_t)(u>>31)<<63|UINT64_C(0x7ff8000000000000)|(uint64_t)(u&UINT32_C(0x7fffff))<<29;__builtin_memcpy(&f,&u,4);volatile double z=f;__builtin_memcpy(&a,(const void*)&z,8);return a;}if(t==11){if(o_fnan(12,a))return (a>>63)<<31|UINT64_C(0x7fc00000)|(a>>29&UINT64_C(0x3fffff));__builtin_memcpy(&x,&a,8);volatile float z=(float)x;__builtin_memcpy(&u,(const void*)&z,4);return u;}if(s==11){__builtin_memcpy(&f,&u,4);x=f;}else __builtin_memcpy(&x,&a,8);if(x!=x)return 0;unsigned w=o_width(t);if(t>=6){double m=(double)((uint64_t)1<<(w-1));if(x>=m)return ((uint64_t)1<<(w-1))-1;if(x<-m)return (uint64_t)0-((uint64_t)1<<(w-1));return (uint64_t)(int64_t)x;}if(x<1.0)return 0;if(x>=(w==64?18446744073709551616.0:(double)((uint64_t)1< +#include +#include +#include +#include +static _Thread_local jmp_buf o_jmp; +static _Thread_local int o_busy; +static __attribute__((noreturn)) void o_trap(int c){if(o_busy)longjmp(o_jmp,c);_exit(100+c);} +static _Thread_local unsigned o_depth; +static void o_enter(void){if(++o_depth>128)o_trap(6);} +static uint64_t o_leave(uint64_t v){--o_depth;return v;} +static unsigned o_width(unsigned t){static const unsigned w[]={0,1,8,16,32,64,8,16,32,64};return w[t];} +static __int128 o_value(unsigned t,uint64_t v){return t>=6 && v>>63 ? (__int128)v-(((__int128)1)<<64):(__int128)v;} +static uint64_t o_norm(unsigned t,__int128 v,int code){unsigned w=o_width(t);if(t>=6){__int128 m=((__int128)1)<<(w-1);if(v< -m||v>=m)o_trap(code);}else {if(v<0||(__uint128_t)v>=(((__uint128_t)1)<=6&&op<=11){switch(op){case 6:return x==y;case 7:return x!=y;case 8:return xy;default:return x>=y;}} + if(op==12)return a&b;if(op==13)return a|b;if(op==14)return a^b; + if(op==15||op==16){if(b>=w)o_trap(7);if(op==15)return t>=6?o_norm(t,x*(((__int128)1)<>b;if(!b)return a;return (a>>b)|((a>>63)?(UINT64_MAX<<(64-b)):0);} + if(op==17){if(t<6)return (0-a)&mask;return o_norm(t,-x,1);}if(op==18)return t==1?!a:(t>=6?~a:(~a)&mask); + if(op==4||op==5){if(!b)o_trap(2);z=op==4?x/y:x%y;return t>=6?o_norm(t,z,1):(uint64_t)z;} + if(t<6){if(op==1)return (a+b)&mask;if(op==2)return (a-b)&mask;return (a*b)&mask;} + if(op==1)z=x+y;if(op==2)z=x-y;if(op==3)z=x*y;return o_norm(t,z,1); +} +static uint64_t o_get(const void *p,uint64_t n,uint64_t i,unsigned t){if(i>=n)o_trap(3);switch(t){case 2:return ((const uint8_t*)p)[i];case 3:return ((const uint16_t*)p)[i];case 4:return ((const uint32_t*)p)[i];case 5:return ((const uint64_t*)p)[i];case 6:return (uint64_t)((const int8_t*)p)[i];case 7:return (uint64_t)((const int16_t*)p)[i];case 8:return (uint64_t)((const int32_t*)p)[i];default:return (uint64_t)((const int64_t*)p)[i];}} +static void o_put(void *p,uint64_t n,uint64_t i,uint64_t v,unsigned t){if(i>=n)o_trap(3);o_norm(t,o_value(t,v),5);switch(t){case 2:((uint8_t*)p)[i]=(uint8_t)v;break;case 3:((uint16_t*)p)[i]=(uint16_t)v;break;case 4:((uint32_t*)p)[i]=(uint32_t)v;break;case 5:((uint64_t*)p)[i]=v;break;case 6:((int8_t*)p)[i]=(int8_t)o_value(t,v);break;case 7:((int16_t*)p)[i]=(int16_t)o_value(t,v);break;case 8:((int32_t*)p)[i]=(int32_t)o_value(t,v);break;default:((int64_t*)p)[i]=(int64_t)o_value(t,v);}} +static void o_fill(void *p,uint64_t n,uint64_t v,unsigned t){for(uint64_t i=0;in||len>n-off)o_trap(3);int f=(int)o_value(8,fd);ssize_t r=op==1?read(f,(uint8_t*)p+off,(size_t)len):write(f,(const uint8_t*)p+off,(size_t)len);return r<0?(uint64_t)(-(int64_t)errno):(uint64_t)r;} +static int o_valid(unsigned t,uint64_t v){unsigned w=o_width(t);__int128 x=o_value(t,v);__int128 m=((__int128)1)<<(t>=6?w-1:w);return t>=6?x>=-m&&x=0&&x +#include +#if FLT_RADIX != 2 || FLT_MANT_DIG != 24 || FLT_MAX_EXP != 128 || DBL_MANT_DIG != 53 || DBL_MAX_EXP != 1024 || FLT_EVAL_METHOD != 0 +#error unsupported binary32 or binary64 environment +#endif +#if defined(__FAST_MATH__) +#error fast math is not a supported Omega environment +#endif +static int o_fnan(unsigned t,uint64_t a){return t==11?((a>>23&255)==255&&(a&UINT64_C(0x7fffff))!=0):((a>>52&2047)==2047&&(a&UINT64_C(0xfffffffffffff))!=0);} +static uint64_t o_fpn(unsigned t,uint64_t a,uint64_t b,uint64_t r){uint64_t q=t==11?UINT64_C(0x400000):UINT64_C(0x8000000000000);if(!o_fnan(t,r))return r;if(o_fnan(t,a)&&!(a&q))return a|q;if(o_fnan(t,b)&&!(b&q))return b|q;if(o_fnan(t,a))return a;if(o_fnan(t,b))return b;return t==11?UINT64_C(0x7fc00000):UINT64_C(0x7ff8000000000000);} +static uint64_t o_fp(unsigned op,unsigned t,uint64_t a,uint64_t b){if(t==11){uint32_t ua=(uint32_t)a,ub=(uint32_t)b,ur;float x,y;volatile float z;__builtin_memcpy(&x,&ua,4);__builtin_memcpy(&y,&ub,4);switch(op){case 1:z=x+y;break;case 2:z=x-y;break;case 3:z=x*y;break;case 4:z=x/y;break;case 6:return x==y;case 7:return x!=y;case 8:return xy;case 11:return x>=y;case 17:return ua^UINT32_C(0x80000000);case 19:return ua&UINT32_C(0x7fffffff);default:__builtin_trap();}__builtin_memcpy(&ur,(const void*)&z,4);return o_fpn(11,ua,ub,ur);}uint64_t ur;double x,y;volatile double z;__builtin_memcpy(&x,&a,8);__builtin_memcpy(&y,&b,8);switch(op){case 1:z=x+y;break;case 2:z=x-y;break;case 3:z=x*y;break;case 4:z=x/y;break;case 6:return x==y;case 7:return x!=y;case 8:return xy;case 11:return x>=y;case 17:return a^UINT64_C(0x8000000000000000);case 19:return a&UINT64_C(0x7fffffffffffffff);default:__builtin_trap();}__builtin_memcpy(&ur,(const void*)&z,8);return o_fpn(12,a,b,ur);} +static uint64_t o_fcv(unsigned t,unsigned s,uint64_t a){uint32_t u=(uint32_t)a;float f;double x;if(s==t)return a;if(s<11){if(t==11){volatile float z=s>=6?(float)(int64_t)a:(float)a;__builtin_memcpy(&u,(const void*)&z,4);return u;}volatile double z=s>=6?(double)(int64_t)a:(double)a;__builtin_memcpy(&a,(const void*)&z,8);return a;}if(t==12){if(o_fnan(11,a))return (uint64_t)(u>>31)<<63|UINT64_C(0x7ff8000000000000)|(uint64_t)(u&UINT32_C(0x7fffff))<<29;__builtin_memcpy(&f,&u,4);volatile double z=f;__builtin_memcpy(&a,(const void*)&z,8);return a;}if(t==11){if(o_fnan(12,a))return (a>>63)<<31|UINT64_C(0x7fc00000)|(a>>29&UINT64_C(0x3fffff));__builtin_memcpy(&x,&a,8);volatile float z=(float)x;__builtin_memcpy(&u,(const void*)&z,4);return u;}if(s==11){__builtin_memcpy(&f,&u,4);x=f;}else __builtin_memcpy(&x,&a,8);if(x!=x)return 0;unsigned w=o_width(t);if(t>=6){double m=(double)((uint64_t)1<<(w-1));if(x>=m)return ((uint64_t)1<<(w-1))-1;if(x<-m)return (uint64_t)0-((uint64_t)1<<(w-1));return (uint64_t)(int64_t)x;}if(x<1.0)return 0;if(x>=(w==64?18446744073709551616.0:(double)((uint64_t)1<=1000000)o_trap(4); +{uint64_t _i=({uint64_t _a=v1;uint64_t _b=v3;o_op(1, 5, _a,_b);});uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,2);} +} +} +return o_leave(0); +} +static uint64_t f5(uint64_t v0, uint64_t v1){ +o_enter(); +return o_leave(({uint64_t _a=32ULL;uint64_t _b=({uint64_t _a=({uint64_t _a=v0;uint64_t _b=8ULL;o_op(3, 5, _a,_b);});uint64_t _b=v1;o_op(1, 5, _a,_b);});o_op(1, 5, _a,_b);})); +} +static uint64_t f6(void *v0, uint64_t v0_n, uint64_t v1){ +o_enter(); +{uint64_t _i=6ULL;uint64_t _v=v1;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=8ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=22ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +static uint64_t f7(void *v0, uint64_t v0_n, uint64_t v1, uint64_t v2, uint64_t v3, uint64_t v4, uint64_t v5){ +o_enter(); +{uint64_t _i=8ULL;uint64_t _v=v1;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=9ULL;uint64_t _v=v2;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=10ULL;uint64_t _v=v3;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=11ULL;uint64_t _v=v4;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=12ULL;uint64_t _v=v5;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +static uint64_t f8(void *v0, uint64_t v0_n){ +o_enter(); +return o_leave(({uint64_t _a=o_get(v0, v0_n, 18ULL, 5);uint64_t _b=1ULL;o_op(2, 5, _a,_b);})); +} +static uint64_t f9(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n, uint64_t v2, uint64_t v3, uint64_t v4){ +o_enter(); +({uint64_t p1=0ULL;uint64_t p2=32ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=0ULL;uint64_t p2=o_get(v0, v0_n, 19ULL, 5);f2(v1, v1_n, p1, p2);}); +({uint64_t p1=4ULL;uint64_t p2=v2;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=8ULL;uint64_t p2=v3;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=1ULL;uint64_t p2=({f8(v0, v0_n);});uint64_t p3=42ULL;uint64_t p4=32ULL;uint64_t p5=v4;f7(v0, v0_n, p1, p2, p3, p4, p5);}); +return o_leave(0); +} +static uint64_t f10(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n, uint64_t v2, uint64_t v3, uint64_t v4){ +o_enter(); +({uint64_t p1=0ULL;uint64_t p2=32ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=0ULL;uint64_t p2=o_get(v0, v0_n, 19ULL, 5);f2(v1, v1_n, p1, p2);}); +({uint64_t p1=4ULL;uint64_t p2=v2;f2(v1, v1_n, p1, p2);}); +if(({uint64_t _a=v3;uint64_t _b=65ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=8ULL;uint64_t p2=o_get(v0, v0_n, 20ULL, 5);f2(v1, v1_n, p1, p2);}); +{uint64_t _i=20ULL;uint64_t _v=({uint64_t _a=o_get(v0, v0_n, 20ULL, 5);uint64_t _b=1ULL;o_op(1, 5, _a,_b);});o_put(v0, v0_n, _i,_v,5);} +} +({uint64_t p1=12ULL;uint64_t p2=v3;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=1ULL;uint64_t p2=({f8(v0, v0_n);});uint64_t p3=43ULL;uint64_t p4=32ULL;uint64_t p5=v4;f7(v0, v0_n, p1, p2, p3, p4, p5);}); +return o_leave(0); +} +static uint64_t f11(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n, uint64_t v2, uint64_t v3, uint64_t v4){ +o_enter(); +({uint64_t p1=0ULL;uint64_t p2=16ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=0ULL;uint64_t p2=v2;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=4ULL;uint64_t p2=v3;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=8ULL;uint64_t p2=v4;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=1ULL;uint64_t p2=({f8(v0, v0_n);});uint64_t p3=41ULL;uint64_t p4=16ULL;uint64_t p5=0ULL;f7(v0, v0_n, p1, p2, p3, p4, p5);}); +return o_leave(0); +} +static uint64_t f12(void *v0, uint64_t v0_n, uint64_t v1, uint64_t v2){ +o_enter(); +({uint64_t p1=4608ULL;uint64_t p2=7599382571363165231ULL;f3(v0, v0_n, p1, p2);}); +if(({uint64_t _a=v2;uint64_t _b=1ULL;o_op(6, 5, _a,_b);})){ +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t p2=119247139334500ULL;f3(v0, v0_n, p1, p2);}); +return o_leave(14ULL); +} +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t p2=6383972ULL;f2(v0, v0_n, p1, p2);}); +uint64_t __attribute__((unused)) v3=({uint64_t _a=4608ULL;uint64_t _b=11ULL;o_op(1, 5, _a,_b);}); +if(({uint64_t _a=v1;uint64_t _b=100ULL;o_op(11, 5, _a,_b);})){ +{uint64_t _i=v3;uint64_t _v=o_cast(2, 5, ({uint64_t _a=48ULL;uint64_t _b=({uint64_t _a=v1;uint64_t _b=100ULL;o_op(4, 5, _a,_b);});o_op(1, 5, _a,_b);}));o_put(v0, v0_n, _i,_v,2);} +v3=({uint64_t _a=v3;uint64_t _b=1ULL;o_op(1, 5, _a,_b);}); +} +if(({uint64_t _a=v1;uint64_t _b=10ULL;o_op(11, 5, _a,_b);})){ +{uint64_t _i=v3;uint64_t _v=o_cast(2, 5, ({uint64_t _a=48ULL;uint64_t _b=({uint64_t _a=({uint64_t _a=v1;uint64_t _b=10ULL;o_op(4, 5, _a,_b);});uint64_t _b=10ULL;o_op(5, 5, _a,_b);});o_op(1, 5, _a,_b);}));o_put(v0, v0_n, _i,_v,2);} +v3=({uint64_t _a=v3;uint64_t _b=1ULL;o_op(1, 5, _a,_b);}); +} +{uint64_t _i=v3;uint64_t _v=o_cast(2, 5, ({uint64_t _a=48ULL;uint64_t _b=({uint64_t _a=v1;uint64_t _b=10ULL;o_op(5, 5, _a,_b);});o_op(1, 5, _a,_b);}));o_put(v0, v0_n, _i,_v,2);} +return o_leave(({uint64_t _a=({uint64_t _a=v3;uint64_t _b=1ULL;o_op(1, 5, _a,_b);});uint64_t _b=4608ULL;o_op(2, 5, _a,_b);})); +} +static uint64_t f13(void *v0, uint64_t v0_n){ +o_enter(); +if(({uint64_t _a=o_get(v0, v0_n, 15ULL, 5);uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +return o_leave(999ULL); +} +uint64_t __attribute__((unused)) v1=o_get(v0, v0_n, 14ULL, 5); +if(({uint64_t _a=v1;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +return o_leave(0ULL); +} +if(({uint64_t _a=({uint64_t _a=v1;uint64_t _b=18446744073709551615ULL;o_op(6, 5, _a,_b);});uint64_t _b=({uint64_t _a=v1;uint64_t _b=18446744073709551603ULL;o_op(6, 5, _a,_b);});o_op(13, 1, _a,_b);})){ +return o_leave(4ULL); +} +return o_leave(999ULL); +} +static uint64_t f14(void *v0, uint64_t v0_n){ +o_enter(); +if(({uint64_t _a=o_get(v0, v0_n, 15ULL, 5);uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +return o_leave(999ULL); +} +uint64_t __attribute__((unused)) v1=o_get(v0, v0_n, 14ULL, 5); +if(({uint64_t _a=v1;uint64_t _b=9223372036854775808ULL;o_op(8, 5, _a,_b);})){ +return o_leave(0ULL); +} +if(({uint64_t _a=({uint64_t _a=({uint64_t _a=v1;uint64_t _b=18446744073709551614ULL;o_op(6, 5, _a,_b);});uint64_t _b=({uint64_t _a=v1;uint64_t _b=18446744073709551610ULL;o_op(6, 5, _a,_b);});o_op(13, 1, _a,_b);});uint64_t _b=({uint64_t _a=v1;uint64_t _b=18446744073709551597ULL;o_op(6, 5, _a,_b);});o_op(13, 1, _a,_b);})){ +return o_leave(9ULL); +} +if(({uint64_t _a=({uint64_t _a=v1;uint64_t _b=18446744073709551615ULL;o_op(6, 5, _a,_b);});uint64_t _b=({uint64_t _a=v1;uint64_t _b=18446744073709551603ULL;o_op(6, 5, _a,_b);});o_op(13, 1, _a,_b);})){ +return o_leave(4ULL); +} +return o_leave(999ULL); +} +static uint64_t f15(uint64_t v0){ +o_enter(); +if(({uint64_t _a=v0;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +return o_leave(0ULL); +} +if(({uint64_t _a=v0;uint64_t _b=27ULL;o_op(6, 5, _a,_b);})){ +return o_leave(4ULL); +} +if(({uint64_t _a=v0;uint64_t _b=15ULL;o_op(6, 5, _a,_b);})){ +return o_leave(15ULL); +} +if(({uint64_t _a=v0;uint64_t _b=86ULL;o_op(6, 5, _a,_b);})){ +return o_leave(3ULL); +} +return o_leave(999ULL); +} +static uint64_t f16(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n, uint64_t v2){ +o_enter(); +uint64_t __attribute__((unused)) v3=({f13(v0, v0_n);}); +if(({uint64_t _a=v3;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +return o_leave(v3); +} +return o_leave(({uint64_t p0=({uint64_t p1=v2;f0(v1, v1_n, p1);});f15(p0);})); +} +static uint64_t f17(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n, uint64_t v2){ +o_enter(); +if(({uint64_t _a=v2;uint64_t _b=24ULL;o_op(8, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v3=({uint64_t _a=v2;uint64_t _b=3ULL;o_op(4, 5, _a,_b);}); +uint64_t __attribute__((unused)) v4=({uint64_t _a=v2;uint64_t _b=3ULL;o_op(5, 5, _a,_b);}); +if(({uint64_t _a=v4;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v5=o_get(v0, v0_n, ({uint64_t p0=v3;uint64_t p1=5ULL;f5(p0, p1);}), 5); +if(({uint64_t _a=v5;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +{uint64_t _i=({uint64_t p0=v3;uint64_t p1=5ULL;f5(p0, p1);});uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p2=o_get(v0, v0_n, 19ULL, 5);uint64_t p3=o_get(v0, v0_n, ({uint64_t p0=v3;uint64_t p1=4ULL;f5(p0, p1);}), 5);uint64_t p4=v5;f11(v0, v0_n, v1, v1_n, p2, p3, p4);}); +return o_leave(1ULL); +} +return o_leave(0ULL); +} +if(({uint64_t _a=v4;uint64_t _b=1ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v5=o_get(v0, v0_n, ({uint64_t p0=v3;uint64_t p1=4ULL;f5(p0, p1);}), 5); +if(({uint64_t _a=v5;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +{uint64_t _i=({uint64_t p0=v3;uint64_t p1=4ULL;f5(p0, p1);});uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p2=o_get(v0, v0_n, 19ULL, 5);uint64_t p3=o_get(v0, v0_n, 19ULL, 5);uint64_t p4=v5;f11(v0, v0_n, v1, v1_n, p2, p3, p4);}); +return o_leave(1ULL); +} +return o_leave(0ULL); +} +uint64_t __attribute__((unused)) v5=o_get(v0, v0_n, ({uint64_t p0=v3;uint64_t p1=0ULL;f5(p0, p1);}), 5); +if(({uint64_t _a=v5;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +{uint64_t _i=({uint64_t p0=v3;uint64_t p1=0ULL;f5(p0, p1);});uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=3ULL;uint64_t p2=({uint64_t _a=v5;uint64_t _b=1ULL;o_op(2, 5, _a,_b);});uint64_t p3=0ULL;uint64_t p4=0ULL;uint64_t p5=0ULL;f7(v0, v0_n, p1, p2, p3, p4, p5);}); +return o_leave(1ULL); +} +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=24ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v3=o_get(v0, v0_n, 19ULL, 5); +if(({uint64_t _a=v3;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p2=v3;uint64_t p3=v3;uint64_t p4=v3;f11(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=19ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(1ULL); +} +return o_leave(0ULL); +} +uint64_t __attribute__((unused)) v3=o_get(v0, v0_n, 18ULL, 5); +if(({uint64_t _a=v3;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=3ULL;uint64_t p2=({uint64_t _a=v3;uint64_t _b=1ULL;o_op(2, 5, _a,_b);});uint64_t p3=0ULL;uint64_t p4=0ULL;uint64_t p5=0ULL;f7(v0, v0_n, p1, p2, p3, p4, p5);}); +{uint64_t _i=18ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(1ULL); +} +return o_leave(0ULL); +} +static uint64_t f18(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +{ +uint64_t v2=0; +uint64_t k1=26ULL; +for(;o_op(8,5, v2, k1);v2=o_op(1,5, v2,1)){ +if(({uint64_t _a=v2;uint64_t _b=o_get(v0, v0_n, 25ULL, 5);o_op(11, 5, _a,_b);})){ +if(({uint64_t p2=v2;f17(v0, v0_n, v1, v1_n, p2);})){ +{uint64_t _i=25ULL;uint64_t _v=({uint64_t _a=v2;uint64_t _b=1ULL;o_op(1, 5, _a,_b);});o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=22ULL;uint64_t _v=101ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +} +} +} +uint64_t __attribute__((unused)) v2=o_get(v0, v0_n, 24ULL, 5); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +v2=o_get(v0, v0_n, 26ULL, 5); +} +{ +uint64_t v3=0; +uint64_t k1=96ULL; +for(;o_op(8,5, v3, k1);v3=o_op(1,5, v3,1)){ +{uint64_t _i=({uint64_t _a=16ULL;uint64_t _b=v3;o_op(1, 5, _a,_b);});uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +} +} +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +static uint64_t f19(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=0ULL; +if(({uint64_t _a=o_get(v0, v0_n, 8ULL, 5);uint64_t _b=1ULL;o_op(6, 5, _a,_b);})){ +v2=({uint64_t p2=12ULL;f16(v0, v0_n, v1, v1_n, p2);}); +}else{ +v2=({f13(v0, v0_n);}); +} +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +{uint64_t _i=26ULL;uint64_t _v=999ULL;o_put(v0, v0_n, _i,_v,5);} +} +({f18(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +static uint64_t f20(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n, uint64_t v2){ +o_enter(); +{uint64_t _i=24ULL;uint64_t _v=v2;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=25ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=26ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +({f18(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +static uint64_t f21(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=o_get(v0, v0_n, 23ULL, 5); +if(({uint64_t _a=v2;uint64_t _b=o_get(v0, v0_n, 21ULL, 5);o_op(11, 5, _a,_b);})){ +{uint64_t _i=17ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=16ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=4608ULL;uint64_t p2=32ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=4608ULL;uint64_t p2=o_get(v0, v0_n, ({uint64_t p0=v2;uint64_t p1=2ULL;f5(p0, p1);}), 5);f2(v1, v1_n, p1, p2);}); +({uint64_t p2=o_get(v0, v0_n, 19ULL, 5);uint64_t p3=517ULL;uint64_t p4=32ULL;f9(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=5ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +static uint64_t f22(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=({f13(v0, v0_n);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p2=v2;f20(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v3=0ULL; +{ +uint64_t v4=0; +uint64_t k1=64ULL; +for(;o_op(8,5, v4, k1);v4=o_op(1,5, v4,1)){ +uint64_t __attribute__((unused)) v5=({uint64_t _a=v4;uint64_t _b=72ULL;o_op(3, 5, _a,_b);}); +if(({uint64_t _a=o_get(v1, v1_n, v5, 2);uint64_t _b=0ULL;o_op(7, 2, _a,_b);})){ +if(({uint64_t _a=v3;uint64_t _b=8ULL;o_op(11, 5, _a,_b);})){ +({uint64_t p2=999ULL;f20(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v6=({uint64_t p1=({uint64_t _a=v5;uint64_t _b=56ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +if(({uint64_t _a=v6;uint64_t _b=255ULL;o_op(10, 5, _a,_b);})){ +({uint64_t p2=999ULL;f20(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +{uint64_t _i=({uint64_t p0=v3;uint64_t p1=1ULL;f5(p0, p1);});uint64_t _v=v6;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=({uint64_t p0=v3;uint64_t p1=2ULL;f5(p0, p1);});uint64_t _v=({uint64_t p1=({uint64_t _a=v5;uint64_t _b=16ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});o_put(v0, v0_n, _i,_v,5);} +v3=({uint64_t _a=v3;uint64_t _b=1ULL;o_op(1, 5, _a,_b);}); +} +} +} +{uint64_t _i=21ULL;uint64_t _v=v3;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=23ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +({f21(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +static uint64_t f23(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n, uint64_t v2){ +o_enter(); +uint64_t __attribute__((unused)) v3=({uint64_t p1=4608ULL;f0(v1, v1_n, p1);}); +if(({uint64_t _a=v3;uint64_t _b=200ULL;o_op(10, 5, _a,_b);})){ +({uint64_t p2=999ULL;f20(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v4=0ULL; +{ +uint64_t v5=0; +uint64_t c1=0; +for(;o_op(8,5, v5, v3);v5=o_op(1,5, v5,1)){ +if(c1++>=1000000)o_trap(4); +if(({uint64_t _a=({uint64_t p1=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=v5;uint64_t _b=4ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});uint64_t _b=52928ULL;o_op(6, 5, _a,_b);})){ +v4=52928ULL; +} +} +} +{uint64_t _i=({uint64_t p0=v2;uint64_t p1=6ULL;f5(p0, p1);});uint64_t _v=v4;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=23ULL;uint64_t _v=({uint64_t _a=v2;uint64_t _b=1ULL;o_op(1, 5, _a,_b);});o_put(v0, v0_n, _i,_v,5);} +({f21(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +static uint64_t f24(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n, uint64_t v2){ +o_enter(); +uint64_t __attribute__((unused)) v3=o_get(v0, v0_n, 23ULL, 5); +if(({uint64_t _a=v2;uint64_t _b=6ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v4=({f14(v0, v0_n);}); +if(({uint64_t _a=v4;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p2=v4;f20(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +{uint64_t _i=({uint64_t p0=v3;uint64_t p1=0ULL;f5(p0, p1);});uint64_t _v=({uint64_t _a=o_get(v0, v0_n, 14ULL, 5);uint64_t _b=1ULL;o_op(1, 5, _a,_b);});o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;uint64_t p2=4ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=0ULL;uint64_t p2=({f8(v0, v0_n);});f2(v1, v1_n, p1, p2);}); +({uint64_t p1=1ULL;uint64_t p2=o_get(v0, v0_n, 14ULL, 5);uint64_t p3=201ULL;uint64_t p4=4ULL;uint64_t p5=0ULL;f7(v0, v0_n, p1, p2, p3, p4, p5);}); +{uint64_t _i=22ULL;uint64_t _v=7ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +uint64_t __attribute__((unused)) v4=0ULL; +if(({uint64_t _a=v2;uint64_t _b=7ULL;o_op(6, 5, _a,_b);})){ +v4=({f13(v0, v0_n);}); +}else{ +v4=({uint64_t p2=28ULL;f16(v0, v0_n, v1, v1_n, p2);}); +} +if(({uint64_t _a=v4;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p2=v4;f20(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=5ULL;o_op(6, 5, _a,_b);})){ +{uint64_t _i=({uint64_t p0=v3;uint64_t p1=3ULL;f5(p0, p1);});uint64_t _v=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});o_put(v0, v0_n, _i,_v,5);} +uint64_t __attribute__((unused)) v5=({uint64_t p1=o_get(v0, v0_n, ({uint64_t p0=v3;uint64_t p1=1ULL;f5(p0, p1);}), 5);uint64_t p2=0ULL;f12(v1, v1_n, p1, p2);}); +({uint64_t p1=2ULL;uint64_t p2=0ULL;uint64_t p3=0ULL;uint64_t p4=0ULL;uint64_t p5=0ULL;f7(v0, v0_n, p1, p2, p3, p4, p5);}); +{uint64_t _i=13ULL;uint64_t _v=v5;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=22ULL;uint64_t _v=6ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=7ULL;o_op(6, 5, _a,_b);})){ +({uint64_t p1=4608ULL;uint64_t p2=56ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=4608ULL;uint64_t p2=o_get(v0, v0_n, ({uint64_t p0=v3;uint64_t p1=3ULL;f5(p0, p1);}), 5);f2(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});uint64_t p2=o_get(v0, v0_n, 19ULL, 5);f2(v1, v1_n, p1, p2);}); +({uint64_t p2=o_get(v0, v0_n, 19ULL, 5);uint64_t p3=128ULL;uint64_t p4=56ULL;f10(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=8ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=8ULL;o_op(6, 5, _a,_b);})){ +{uint64_t _i=({uint64_t p0=v3;uint64_t p1=4ULL;f5(p0, p1);});uint64_t _v=({uint64_t p1=8ULL;f0(v1, v1_n, p1);});o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=4608ULL;uint64_t p2=4ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p2=o_get(v0, v0_n, ({uint64_t p0=v3;uint64_t p1=4ULL;f5(p0, p1);}), 5);uint64_t p3=8320ULL;uint64_t p4=4ULL;f10(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=9ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=9ULL;o_op(6, 5, _a,_b);})){ +{uint64_t _i=({uint64_t p0=v3;uint64_t p1=5ULL;f5(p0, p1);});uint64_t _v=({uint64_t p1=8ULL;f0(v1, v1_n, p1);});o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=4608ULL;uint64_t p2=804ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p2=o_get(v0, v0_n, ({uint64_t p0=v3;uint64_t p1=4ULL;f5(p0, p1);}), 5);uint64_t p3=8389266ULL;uint64_t p4=804ULL;f9(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=10ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +({uint64_t p2=v3;f23(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +static uint64_t f25(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=o_get(v0, v0_n, 22ULL, 5); +if(({uint64_t _a=v2;uint64_t _b=100ULL;o_op(11, 5, _a,_b);})){ +({f19(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +if(({uint64_t _a=o_get(v0, v0_n, 16ULL, 5);uint64_t _b=0ULL;o_op(10, 5, _a,_b);})){ +{uint64_t _i=16ULL;uint64_t _v=({uint64_t _a=o_get(v0, v0_n, 16ULL, 5);uint64_t _b=1ULL;o_op(1, 5, _a,_b);});o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +{ +uint64_t v3=0; +uint64_t k2=96ULL; +for(;o_op(8,5, v3, k2);v3=o_op(1,5, v3,1)){ +{uint64_t _i=({uint64_t _a=16ULL;uint64_t _b=v3;o_op(1, 5, _a,_b);});uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +} +} +{uint64_t _i=20ULL;uint64_t _v=3472883713ULL;o_put(v0, v0_n, _i,_v,5);} +uint64_t __attribute__((unused)) v3=({uint64_t p1=0ULL;uint64_t p2=1ULL;f12(v1, v1_n, p1, p2);}); +({uint64_t p1=2ULL;uint64_t p2=0ULL;uint64_t p3=0ULL;uint64_t p4=0ULL;uint64_t p5=0ULL;f7(v0, v0_n, p1, p2, p3, p4, p5);}); +{uint64_t _i=13ULL;uint64_t _v=v3;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=22ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=1ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v3=({f14(v0, v0_n);}); +if(({uint64_t _a=v3;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v3;f6(v0, v0_n, p1);}); +return o_leave(0); +} +{uint64_t _i=18ULL;uint64_t _v=({uint64_t _a=o_get(v0, v0_n, 14ULL, 5);uint64_t _b=1ULL;o_op(1, 5, _a,_b);});o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=4608ULL;uint64_t p2=4ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p2=0ULL;uint64_t p3=65ULL;uint64_t p4=0ULL;f10(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=2ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=2ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v3=({uint64_t p2=28ULL;f16(v0, v0_n, v1, v1_n, p2);}); +if(({uint64_t _a=v3;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p2=v3;f20(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v4=({uint64_t p1=8ULL;f0(v1, v1_n, p1);}); +if(({uint64_t _a=v4;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +({uint64_t p2=999ULL;f20(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +{uint64_t _i=19ULL;uint64_t _v=v4;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;uint64_t p2=4608ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=1ULL;uint64_t p2=({f8(v0, v0_n);});uint64_t p3=200ULL;uint64_t p4=4608ULL;uint64_t p5=0ULL;f7(v0, v0_n, p1, p2, p3, p4, p5);}); +{uint64_t _i=22ULL;uint64_t _v=3ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=3ULL;o_op(6, 5, _a,_b);})){ +({f22(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +({uint64_t p2=v2;f24(v0, v0_n, v1, v1_n, p2);}); +return o_leave(0); +} +static uint64_t f26(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=o_get(v0, v0_n, 22ULL, 5); +if(({uint64_t _a=v2;uint64_t _b=100ULL;o_op(11, 5, _a,_b);})){ +({f19(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +if(({uint64_t _a=o_get(v0, v0_n, 16ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +({uint64_t p1=1ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=o_get(v0, v0_n, 16ULL, 5);uint64_t _b=1ULL;o_op(10, 5, _a,_b);})){ +{uint64_t _i=16ULL;uint64_t _v=({uint64_t _a=o_get(v0, v0_n, 16ULL, 5);uint64_t _b=1ULL;o_op(2, 5, _a,_b);});o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +{uint64_t _i=24ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=25ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=26ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +({f18(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +static uint64_t f27(void *v0, uint64_t v0_n){ +o_enter(); +if(({uint64_t _a=o_get(v0, v0_n, 17ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +return o_leave(1ULL); +} +if(({uint64_t _a=o_get(v0, v0_n, 1ULL, 5);uint64_t _b=o_get(v0, v0_n, 21ULL, 5);o_op(11, 5, _a,_b);})){ +return o_leave(2ULL); +} +if(({uint64_t _a=o_get(v0, v0_n, 2ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +return o_leave(2ULL); +} +return o_leave(0ULL); +} +static uint64_t f28(void *v0, uint64_t v0_n){ +o_enter(); +return o_leave(o_get(v0, v0_n, ({uint64_t p0=o_get(v0, v0_n, 1ULL, 5);uint64_t p1=5ULL;f5(p0, p1);}), 5)); +} +static uint64_t f29(void *v0, uint64_t v0_n, uint64_t v1){ +o_enter(); +{uint64_t _i=5ULL;uint64_t _v=v1;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=27ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +static uint64_t f30(void *v0, uint64_t v0_n){ +o_enter(); +if(({uint64_t _a=o_get(v0, v0_n, 17ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +({uint64_t p1=1ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=o_get(v0, v0_n, 2ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +({uint64_t p1=2ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=o_get(v0, v0_n, 21ULL, 5);f29(v0, v0_n, p1);}); +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +static uint64_t f31(void *v0, uint64_t v0_n){ +o_enter(); +uint64_t __attribute__((unused)) v1=({f27(v0, v0_n);}); +if(({uint64_t _a=v1;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v1;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=o_get(v0, v0_n, 1ULL, 5);f29(v0, v0_n, p1);}); +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +static uint64_t f32(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +if(({uint64_t _a=o_get(v0, v0_n, 22ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v2=({f27(v0, v0_n);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=4608ULL;uint64_t p2=132ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p2=({f28(v0, v0_n);});uint64_t p3=545259792ULL;uint64_t p4=132ULL;f9(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +uint64_t __attribute__((unused)) v2=({uint64_t p2=28ULL;f16(v0, v0_n, v1, v1_n, p2);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=({uint64_t p1=4608ULL;f0(v1, v1_n, p1);});uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v3=0ULL; +uint64_t __attribute__((unused)) v4=0ULL; +{ +uint64_t v5=0; +uint64_t k1=128ULL; +for(;o_op(8,5, v5, k1);v5=o_op(1,5, v5,1)){ +uint64_t __attribute__((unused)) v6=o_get(v1, v1_n, ({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});uint64_t _b=v5;o_op(1, 5, _a,_b);}), 2); +if(({uint64_t _a=v4;uint64_t _b=0;o_op(18, 1, _a,_b);})){ +if(({uint64_t _a=v6;uint64_t _b=0ULL;o_op(6, 2, _a,_b);})){ +v4=1ULL; +v3=v5; +}else{ +if(({uint64_t _a=({uint64_t _a=v6;uint64_t _b=32ULL;o_op(8, 2, _a,_b);});uint64_t _b=({uint64_t _a=v6;uint64_t _b=126ULL;o_op(10, 2, _a,_b);});o_op(13, 1, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +} +} +} +} +if(({uint64_t _a=({uint64_t _a=v4;uint64_t _b=0;o_op(18, 1, _a,_b);});uint64_t _b=({uint64_t _a=({uint64_t _a=v3;uint64_t _b=0ULL;o_op(6, 5, _a,_b);});uint64_t _b=({uint64_t _a=v3;uint64_t _b=95ULL;o_op(10, 5, _a,_b);});o_op(13, 1, _a,_b);});o_op(13, 1, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=o_get(v0, v0_n, 3ULL, 5);uint64_t _b=({uint64_t _a=v3;uint64_t _b=1ULL;o_op(1, 5, _a,_b);});o_op(8, 5, _a,_b);})){ +({uint64_t p1=7ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +{ +uint64_t v5=0; +uint64_t c1=0; +for(;o_op(8,5, v5, v3);v5=o_op(1,5, v5,1)){ +if(c1++>=1000000)o_trap(4); +{uint64_t _i=({uint64_t _a=60496ULL;uint64_t _b=v5;o_op(1, 5, _a,_b);});uint64_t _v=o_get(v1, v1_n, ({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});uint64_t _b=v5;o_op(1, 5, _a,_b);}), 2);o_put(v1, v1_n, _i,_v,2);} +} +} +{uint64_t _i=({uint64_t _a=60496ULL;uint64_t _b=v3;o_op(1, 5, _a,_b);});uint64_t _v=0ULL;o_put(v1, v1_n, _i,_v,2);} +{uint64_t _i=7ULL;uint64_t _v=({uint64_t _a=v3;uint64_t _b=1ULL;o_op(1, 5, _a,_b);});o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +static uint64_t f33(uint64_t v0){ +o_enter(); +if(({uint64_t _a=v0;uint64_t _b=10ULL;o_op(8, 5, _a,_b);})){ +return o_leave(o_cast(2, 5, ({uint64_t _a=48ULL;uint64_t _b=v0;o_op(1, 5, _a,_b);}))); +} +return o_leave(o_cast(2, 5, ({uint64_t _a=87ULL;uint64_t _b=v0;o_op(1, 5, _a,_b);}))); +} +static uint64_t f34(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +if(({uint64_t _a=o_get(v0, v0_n, 22ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v2=({f27(v0, v0_n);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=4608ULL;uint64_t p2=268ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});uint64_t p2=2ULL;f2(v1, v1_n, p1, p2);}); +({uint64_t p2=({f28(v0, v0_n);});uint64_t p3=545259850ULL;uint64_t p4=268ULL;f9(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +uint64_t __attribute__((unused)) v2=({uint64_t p2=28ULL;f16(v0, v0_n, v1, v1_n, p2);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});uint64_t _b=16ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=o_get(v0, v0_n, 3ULL, 5);uint64_t _b=41ULL;o_op(8, 5, _a,_b);})){ +({uint64_t p1=7ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +{uint64_t _i=60496ULL;uint64_t _v=71ULL;o_put(v1, v1_n, _i,_v,2);} +{uint64_t _i=({uint64_t _a=60496ULL;uint64_t _b=1ULL;o_op(1, 5, _a,_b);});uint64_t _v=80ULL;o_put(v1, v1_n, _i,_v,2);} +{uint64_t _i=({uint64_t _a=60496ULL;uint64_t _b=2ULL;o_op(1, 5, _a,_b);});uint64_t _v=85ULL;o_put(v1, v1_n, _i,_v,2);} +{uint64_t _i=({uint64_t _a=60496ULL;uint64_t _b=3ULL;o_op(1, 5, _a,_b);});uint64_t _v=45ULL;o_put(v1, v1_n, _i,_v,2);} +uint64_t __attribute__((unused)) v3=({uint64_t _a=60496ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);}); +{ +uint64_t v4=0; +uint64_t k1=16ULL; +for(;o_op(8,5, v4, k1);v4=o_op(1,5, v4,1)){ +if(({uint64_t _a=({uint64_t _a=({uint64_t _a=v4;uint64_t _b=4ULL;o_op(6, 5, _a,_b);});uint64_t _b=({uint64_t _a=v4;uint64_t _b=6ULL;o_op(6, 5, _a,_b);});o_op(13, 1, _a,_b);});uint64_t _b=({uint64_t _a=({uint64_t _a=v4;uint64_t _b=8ULL;o_op(6, 5, _a,_b);});uint64_t _b=({uint64_t _a=v4;uint64_t _b=10ULL;o_op(6, 5, _a,_b);});o_op(13, 1, _a,_b);});o_op(13, 1, _a,_b);})){ +{uint64_t _i=v3;uint64_t _v=45ULL;o_put(v1, v1_n, _i,_v,2);} +v3=({uint64_t _a=v3;uint64_t _b=1ULL;o_op(1, 5, _a,_b);}); +} +uint64_t __attribute__((unused)) v5=o_cast(5, 2, o_get(v1, v1_n, ({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=12ULL;o_op(1, 5, _a,_b);});uint64_t _b=v4;o_op(1, 5, _a,_b);}), 2)); +{uint64_t _i=v3;uint64_t _v=({uint64_t p0=({uint64_t _a=v5;uint64_t _b=4ULL;o_op(16, 5, _a,_b);});f33(p0);});o_put(v1, v1_n, _i,_v,2);} +{uint64_t _i=({uint64_t _a=v3;uint64_t _b=1ULL;o_op(1, 5, _a,_b);});uint64_t _v=({uint64_t p0=({uint64_t _a=v5;uint64_t _b=15ULL;o_op(12, 5, _a,_b);});f33(p0);});o_put(v1, v1_n, _i,_v,2);} +v3=({uint64_t _a=v3;uint64_t _b=2ULL;o_op(1, 5, _a,_b);}); +} +} +{uint64_t _i=v3;uint64_t _v=0ULL;o_put(v1, v1_n, _i,_v,2);} +{uint64_t _i=7ULL;uint64_t _v=41ULL;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +static uint64_t f35(void *v0, uint64_t v0_n, uint64_t v1, uint64_t v2, uint64_t v3){ +o_enter(); +uint64_t __attribute__((unused)) v4=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=24ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=v1;uint64_t _b=44ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);}); +({uint64_t p1=({uint64_t _a=v4;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t p2=v2;f2(v0, v0_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=v4;uint64_t _b=12ULL;o_op(1, 5, _a,_b);});uint64_t p2=v3;f2(v0, v0_n, p1, p2);}); +return o_leave(0); +} +static uint64_t f36(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n, uint64_t v2){ +o_enter(); +({uint64_t p1=4608ULL;uint64_t p2=1ULL;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t p2=44ULL;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=20ULL;o_op(1, 5, _a,_b);});uint64_t p2=v2;f2(v1, v1_n, p1, p2);}); +({uint64_t p2=({f28(v0, v0_n);});uint64_t p3=545260819ULL;uint64_t p4=1432ULL;f9(v0, v0_n, v1, v1_n, p2, p3, p4);}); +return o_leave(0); +} +static uint64_t f37(void *v0, uint64_t v0_n, uint64_t v1){ +o_enter(); +{ +uint64_t v2=0; +uint64_t c1=0; +for(;o_op(8,5, v2, v1);v2=o_op(1,5, v2,1)){ +if(c1++>=1000000)o_trap(4); +uint64_t __attribute__((unused)) v3=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=24ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=v2;uint64_t _b=44ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);}); +if(({uint64_t _a=({uint64_t _a=({uint64_t p1=({uint64_t _a=v3;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});f0(v0, v0_n, p1);});uint64_t _b=1ULL;o_op(7, 5, _a,_b);});uint64_t _b=({uint64_t _a=({uint64_t p1=v3;f0(v0, v0_n, p1);});uint64_t _b=0ULL;o_op(7, 5, _a,_b);});o_op(13, 1, _a,_b);})){ +return o_leave(0ULL); +} +} +} +return o_leave(1ULL); +} +static uint64_t f38(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=o_get(v0, v0_n, 25ULL, 5); +uint64_t __attribute__((unused)) v3=o_get(v0, v0_n, 26ULL, 5); +{ +uint64_t v4=0; +uint64_t c1=0; +for(;o_op(8,5, v4, v3);v4=o_op(1,5, v4,1)){ +if(c1++>=1000000)o_trap(4); +uint64_t __attribute__((unused)) v5=({uint64_t _a=v2;uint64_t _b=({uint64_t _a=v4;uint64_t _b=2ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);}); +uint64_t __attribute__((unused)) v6=({uint64_t p1=({uint64_t _a=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=24ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=v5;uint64_t _b=44ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});uint64_t _b=16ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +if(({uint64_t _a=v6;uint64_t _b=v2;o_op(11, 5, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=({uint64_t p1=({uint64_t _a=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=24ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=v6;uint64_t _b=44ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});uint64_t _b=16ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});uint64_t _b=1ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v7=({uint64_t p1=({uint64_t _a=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=24ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=({uint64_t _a=v5;uint64_t _b=1ULL;o_op(1, 5, _a,_b);});uint64_t _b=44ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});uint64_t _b=16ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +if(({uint64_t _a=v7;uint64_t _b=2147483648ULL;o_op(11, 5, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=v7;f29(v0, v0_n, p1);}); +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +} +} +({uint64_t p1=3ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +static uint64_t f39(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=o_get(v0, v0_n, 22ULL, 5); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v3=({f27(v0, v0_n);}); +if(({uint64_t _a=v3;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v3;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=o_get(v0, v0_n, 3ULL, 5);uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=2ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=4608ULL;uint64_t p2=1432ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=0ULL;uint64_t p2=256ULL;uint64_t p3=0ULL;f35(v1, v1_n, p1, p2, p3);}); +({uint64_t p1=1ULL;uint64_t p2=1280ULL;uint64_t p3=0ULL;f35(v1, v1_n, p1, p2, p3);}); +({uint64_t p2=2ULL;f36(v0, v0_n, v1, v1_n, p2);}); +{uint64_t _i=22ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +uint64_t __attribute__((unused)) v3=({uint64_t p2=28ULL;f16(v0, v0_n, v1, v1_n, p2);}); +if(({uint64_t _a=v3;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v3;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=2ULL;o_op(6, 5, _a,_b);})){ +if(({uint64_t _a=({uint64_t p1=({uint64_t _a=o_get(v0, v0_n, 25ULL, 5);uint64_t _b=({uint64_t _a=o_get(v0, v0_n, 26ULL, 5);uint64_t _b=2ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});f37(v1, v1_n, p1);});uint64_t _b=0;o_op(18, 1, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({f38(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +if(({uint64_t _a=({uint64_t p1=2ULL;f37(v1, v1_n, p1);});uint64_t _b=0;o_op(18, 1, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v4=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=36ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +uint64_t __attribute__((unused)) v5=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=80ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +if(({uint64_t _a=({uint64_t _a=v4;uint64_t _b=({uint64_t _a=v5;uint64_t _b=2ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});uint64_t _b=32ULL;o_op(10, 5, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=v5;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +({uint64_t p1=3ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +{uint64_t _i=25ULL;uint64_t _v=v4;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=26ULL;uint64_t _v=v5;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=4608ULL;uint64_t p2=1432ULL;f4(v1, v1_n, p1, p2);}); +{ +uint64_t v6=0; +uint64_t c1=0; +for(;o_op(8,5, v6, v4);v6=o_op(1,5, v6,1)){ +if(c1++>=1000000)o_trap(4); +({uint64_t p1=v6;uint64_t p2=257ULL;uint64_t p3=v6;f35(v1, v1_n, p1, p2, p3);}); +} +} +{ +uint64_t v6=0; +uint64_t c1=0; +for(;o_op(8,5, v6, v5);v6=o_op(1,5, v6,1)){ +if(c1++>=1000000)o_trap(4); +({uint64_t p1=({uint64_t _a=v4;uint64_t _b=({uint64_t _a=v6;uint64_t _b=2ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});uint64_t p2=1312ULL;uint64_t p3=v6;f35(v1, v1_n, p1, p2, p3);}); +({uint64_t p1=({uint64_t _a=({uint64_t _a=v4;uint64_t _b=({uint64_t _a=v6;uint64_t _b=2ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});uint64_t _b=1ULL;o_op(1, 5, _a,_b);});uint64_t p2=5376ULL;uint64_t p3=v6;f35(v1, v1_n, p1, p2, p3);}); +} +} +({uint64_t p2=({uint64_t _a=v4;uint64_t _b=({uint64_t _a=v5;uint64_t _b=2ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});f36(v0, v0_n, v1, v1_n, p2);}); +{uint64_t _i=22ULL;uint64_t _v=2ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +static uint64_t f40(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +if(({uint64_t _a=o_get(v0, v0_n, 22ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v2=({f27(v0, v0_n);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=4608ULL;uint64_t p2=1028ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=4608ULL;uint64_t p2=3ULL;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});uint64_t p2=54ULL;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=12ULL;o_op(1, 5, _a,_b);});uint64_t p2=8ULL;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=20ULL;o_op(1, 5, _a,_b);});uint64_t p2=22ULL;f2(v1, v1_n, p1, p2);}); +({uint64_t p2=({f28(v0, v0_n);});uint64_t p3=545264387ULL;uint64_t p4=1028ULL;f9(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +uint64_t __attribute__((unused)) v2=({uint64_t p2=28ULL;f16(v0, v0_n, v1, v1_n, p2);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=({uint64_t _a=({uint64_t _a=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});uint64_t _b=54ULL;o_op(7, 5, _a,_b);});uint64_t _b=({uint64_t _a=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=12ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});uint64_t _b=8ULL;o_op(7, 5, _a,_b);});o_op(13, 1, _a,_b);});uint64_t _b=({uint64_t _a=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=20ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});uint64_t _b=22ULL;o_op(7, 5, _a,_b);});o_op(13, 1, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=3ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v3=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=16ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +uint64_t __attribute__((unused)) v4=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=24ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +if(({uint64_t _a=v4;uint64_t _b=v3;o_op(10, 5, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=60496ULL;uint64_t p2=({uint64_t _a=v3;uint64_t _b=1024ULL;o_op(3, 5, _a,_b);});f3(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=60496ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t p2=({uint64_t _a=v4;uint64_t _b=1024ULL;o_op(3, 5, _a,_b);});f3(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=60496ULL;uint64_t _b=16ULL;o_op(1, 5, _a,_b);});uint64_t p2=({uint64_t _a=({uint64_t _a=v3;uint64_t _b=v4;o_op(2, 5, _a,_b);});uint64_t _b=1024ULL;o_op(3, 5, _a,_b);});f3(v1, v1_n, p1, p2);}); +{uint64_t _i=7ULL;uint64_t _v=24ULL;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +static uint64_t f41(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +if(({uint64_t _a=o_get(v0, v0_n, 22ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v2=({f27(v0, v0_n);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=4608ULL;uint64_t p2=55888ULL;f4(v1, v1_n, p1, p2);}); +{uint64_t _i=4608ULL;uint64_t _v=2ULL;o_put(v1, v1_n, _i,_v,2);} +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});uint64_t p2=55872ULL;f2(v1, v1_n, p1, p2);}); +({uint64_t p2=({f28(v0, v0_n);});uint64_t p3=545267862ULL;uint64_t p4=55888ULL;f9(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +uint64_t __attribute__((unused)) v2=({uint64_t p2=28ULL;f16(v0, v0_n, v1, v1_n, p2);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v3=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +uint64_t __attribute__((unused)) v4=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=12ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +if(({uint64_t _a=({uint64_t _a=v3;uint64_t _b=72ULL;o_op(10, 5, _a,_b);});uint64_t _b=({uint64_t _a=v4;uint64_t _b=72ULL;o_op(11, 5, _a,_b);});o_op(13, 1, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v5=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=16ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=({uint64_t _a=({uint64_t _a=v4;uint64_t _b=71ULL;o_op(1, 5, _a,_b);});uint64_t _b=72ULL;o_op(5, 5, _a,_b);});uint64_t _b=776ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);}); +if(({uint64_t _a=({uint64_t _a=v3;uint64_t _b=0ULL;o_op(6, 5, _a,_b);});uint64_t _b=({uint64_t _a=({uint64_t p1=v5;f1(v1, v1_n, p1);});uint64_t _b=0ULL;o_op(6, 5, _a,_b);});o_op(13, 1, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v6=({uint64_t p1=({uint64_t _a=v5;uint64_t _b=136ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +uint64_t __attribute__((unused)) v7=({uint64_t p1=({uint64_t _a=v5;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +if(({uint64_t _a=({uint64_t _a=v6;uint64_t _b=10000ULL;o_op(10, 5, _a,_b);});uint64_t _b=({uint64_t _a=v7;uint64_t _b=10000ULL;o_op(10, 5, _a,_b);});o_op(13, 1, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=60496ULL;uint64_t p2=({uint64_t _a=v6;uint64_t _b=100ULL;o_op(4, 5, _a,_b);});f2(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=60496ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});uint64_t p2=({uint64_t _a=v7;uint64_t _b=100ULL;o_op(4, 5, _a,_b);});f2(v1, v1_n, p1, p2);}); +{uint64_t _i=7ULL;uint64_t _v=8ULL;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +static uint64_t f42(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=o_get(v0, v0_n, 23ULL, 5); +uint64_t __attribute__((unused)) v3=({uint64_t _a=o_get(v0, v0_n, 25ULL, 5);uint64_t _b=v2;o_op(2, 5, _a,_b);}); +if(({uint64_t _a=v3;uint64_t _b=200ULL;o_op(10, 5, _a,_b);})){ +v3=200ULL; +} +({uint64_t p1=4608ULL;uint64_t p2=14408ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=4608ULL;uint64_t p2=v3;f2(v1, v1_n, p1, p2);}); +{ +uint64_t v4=0; +uint64_t c1=0; +for(;o_op(8,5, v4, v3);v4=o_op(1,5, v4,1)){ +if(c1++>=1000000)o_trap(4); +({uint64_t p1=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=v4;uint64_t _b=72ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});uint64_t p2=({uint64_t p1=({uint64_t _a=60496ULL;uint64_t _b=({uint64_t _a=({uint64_t _a=v2;uint64_t _b=v4;o_op(1, 5, _a,_b);});uint64_t _b=24ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});f2(v1, v1_n, p1, p2);}); +} +} +{uint64_t _i=26ULL;uint64_t _v=v3;o_put(v0, v0_n, _i,_v,5);} +({uint64_t p2=({f28(v0, v0_n);});uint64_t p3=545259918ULL;uint64_t p4=14408ULL;f9(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=2ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +static uint64_t f43(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=({uint64_t p2=28ULL;f16(v0, v0_n, v1, v1_n, p2);}); +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v2;f6(v0, v0_n, p1);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v3=o_get(v0, v0_n, 23ULL, 5); +{ +uint64_t v4=0; +uint64_t k1=o_get(v0, v0_n, 26ULL, 5); +uint64_t c1=0; +for(;o_op(8,5, v4, k1);v4=o_op(1,5, v4,1)){ +if(c1++>=1000000)o_trap(4); +uint64_t __attribute__((unused)) v5=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=v4;uint64_t _b=72ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);}); +uint64_t __attribute__((unused)) v6=({uint64_t _a=60496ULL;uint64_t _b=({uint64_t _a=({uint64_t _a=v3;uint64_t _b=v4;o_op(1, 5, _a,_b);});uint64_t _b=24ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);}); +if(({uint64_t _a=({uint64_t p1=v5;f0(v1, v1_n, p1);});uint64_t _b=({uint64_t p1=v6;f0(v1, v1_n, p1);});o_op(7, 5, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=({uint64_t p1=({uint64_t _a=v5;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=({uint64_t _a=v6;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t p2=18446744073709551615ULL;f3(v1, v1_n, p1, p2);}); +}else{ +({uint64_t p1=({uint64_t _a=v6;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t p2=({uint64_t p1=({uint64_t _a=v5;uint64_t _b=16ULL;o_op(1, 5, _a,_b);});f1(v1, v1_n, p1);});f3(v1, v1_n, p1, p2);}); +} +} +} +v3=({uint64_t _a=v3;uint64_t _b=o_get(v0, v0_n, 26ULL, 5);o_op(1, 5, _a,_b);}); +{uint64_t _i=23ULL;uint64_t _v=v3;o_put(v0, v0_n, _i,_v,5);} +if(({uint64_t _a=v3;uint64_t _b=o_get(v0, v0_n, 25ULL, 5);o_op(8, 5, _a,_b);})){ +({f42(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +({uint64_t p1=v3;f29(v0, v0_n, p1);}); +{uint64_t _i=7ULL;uint64_t _v=({uint64_t _a=v3;uint64_t _b=24ULL;o_op(3, 5, _a,_b);});o_put(v0, v0_n, _i,_v,5);} +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +static uint64_t f44(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +uint64_t __attribute__((unused)) v2=o_get(v0, v0_n, 22ULL, 5); +if(({uint64_t _a=v2;uint64_t _b=2ULL;o_op(6, 5, _a,_b);})){ +({f43(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +if(({uint64_t _a=v2;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +uint64_t __attribute__((unused)) v3=({f27(v0, v0_n);}); +if(({uint64_t _a=v3;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v3;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=({uint64_t _a=o_get(v0, v0_n, 4ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);});uint64_t _b=({uint64_t _a=o_get(v0, v0_n, 3ULL, 5);uint64_t _b=0ULL;o_op(7, 5, _a,_b);});o_op(12, 1, _a,_b);})){ +({uint64_t p1=2ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v4=o_get(v0, v0_n, ({uint64_t p0=o_get(v0, v0_n, 1ULL, 5);uint64_t p1=6ULL;f5(p0, p1);}), 5); +if(({uint64_t _a=v4;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +({uint64_t p1=3ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +({uint64_t p1=4608ULL;uint64_t p2=3812ULL;f4(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=4ULL;o_op(1, 5, _a,_b);});uint64_t p2=v4;f2(v1, v1_n, p1, p2);}); +({uint64_t p2=({f28(v0, v0_n);});uint64_t p3=545259917ULL;uint64_t p4=3812ULL;f9(v0, v0_n, v1, v1_n, p2, p3, p4);}); +{uint64_t _i=22ULL;uint64_t _v=1ULL;o_put(v0, v0_n, _i,_v,5);} +return o_leave(0); +} +uint64_t __attribute__((unused)) v3=({uint64_t p2=28ULL;f16(v0, v0_n, v1, v1_n, p2);}); +if(({uint64_t _a=v3;uint64_t _b=0ULL;o_op(7, 5, _a,_b);})){ +({uint64_t p1=v3;f6(v0, v0_n, p1);}); +return o_leave(0); +} +uint64_t __attribute__((unused)) v4=({uint64_t p1=({uint64_t _a=4608ULL;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);}); +if(({uint64_t _a=v4;uint64_t _b=950ULL;o_op(10, 5, _a,_b);})){ +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=v4;uint64_t _b=o_get(v0, v0_n, 3ULL, 5);o_op(10, 5, _a,_b);})){ +({uint64_t p1=v4;f29(v0, v0_n, p1);}); +({uint64_t p1=7ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +if(({uint64_t _a=v4;uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +({uint64_t p1=0ULL;f29(v0, v0_n, p1);}); +({uint64_t p1=0ULL;f6(v0, v0_n, p1);}); +return o_leave(0); +} +{ +uint64_t v5=0; +uint64_t c1=0; +for(;o_op(8,5, v5, v4);v5=o_op(1,5, v5,1)){ +if(c1++>=1000000)o_trap(4); +uint64_t __attribute__((unused)) v6=({uint64_t _a=60496ULL;uint64_t _b=({uint64_t _a=v5;uint64_t _b=24ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);}); +({uint64_t p1=v6;uint64_t p2=({uint64_t p1=({uint64_t _a=({uint64_t _a=4608ULL;uint64_t _b=12ULL;o_op(1, 5, _a,_b);});uint64_t _b=({uint64_t _a=v5;uint64_t _b=4ULL;o_op(3, 5, _a,_b);});o_op(1, 5, _a,_b);});f0(v1, v1_n, p1);});f2(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=v6;uint64_t _b=8ULL;o_op(1, 5, _a,_b);});uint64_t p2=0ULL;f3(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=v6;uint64_t _b=16ULL;o_op(1, 5, _a,_b);});uint64_t p2=4294967295ULL;f2(v1, v1_n, p1, p2);}); +({uint64_t p1=({uint64_t _a=v6;uint64_t _b=20ULL;o_op(1, 5, _a,_b);});uint64_t p2=4294967295ULL;f2(v1, v1_n, p1, p2);}); +} +} +{uint64_t _i=25ULL;uint64_t _v=v4;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=23ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +({f42(v0, v0_n, v1, v1_n);}); +return o_leave(0); +} +static uint64_t f45(void *v0, uint64_t v0_n, void *v1, uint64_t v1_n){ +o_enter(); +if(({uint64_t _a=o_get(v0, v0_n, 22ULL, 5);uint64_t _b=0ULL;o_op(6, 5, _a,_b);})){ +{uint64_t _i=5ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=6ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=7ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +{uint64_t _i=27ULL;uint64_t _v=0ULL;o_put(v0, v0_n, _i,_v,5);} +} +uint64_t __attribute__((unused)) v2=o_get(v0, v0_n, 0ULL, 5); +if(({uint64_t _a=v2;uint64_t _b=1ULL;o_op(6, 5, _a,_b);})){ +({f25(v0, v0_n, v1, v1_n);}); +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=2ULL;o_op(6, 5, _a,_b);})){ +({f26(v0, v0_n, v1, v1_n);}); +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=3ULL;o_op(6, 5, _a,_b);})){ +({f30(v0, v0_n);}); +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=4ULL;o_op(6, 5, _a,_b);})){ +({f31(v0, v0_n);}); +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=5ULL;o_op(6, 5, _a,_b);})){ +({f32(v0, v0_n, v1, v1_n);}); +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=6ULL;o_op(6, 5, _a,_b);})){ +({f34(v0, v0_n, v1, v1_n);}); +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=7ULL;o_op(6, 5, _a,_b);})){ +({f39(v0, v0_n, v1, v1_n);}); +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=8ULL;o_op(6, 5, _a,_b);})){ +({f40(v0, v0_n, v1, v1_n);}); +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=9ULL;o_op(6, 5, _a,_b);})){ +({f41(v0, v0_n, v1, v1_n);}); +return o_leave(0ULL); +} +if(({uint64_t _a=v2;uint64_t _b=10ULL;o_op(6, 5, _a,_b);})){ +({f44(v0, v0_n, v1, v1_n);}); +return o_leave(0ULL); +} +({uint64_t p1=999ULL;f6(v0, v0_n, p1);}); +return o_leave(0ULL); +} +uint32_t omega_nvml_step(uint64_t *result, void *p0, uint64_t p0_n, void *p1, uint64_t p1_n){ +if(!o_buf(result,1,1,5))return 32; +if(!o_buf(p0, p0_n,128, 5))return 32; +if(o_overlap(result,8,p0, p0_n*8))return 32; +if(!o_buf(p1, p1_n,83296, 2))return 32; +if(o_overlap(result,8,p1, p1_n*1))return 32; +if(o_overlap(p1, p1_n*1, p0, p0_n*8))return 32; +if(o_busy)return 33; +o_busy=1;o_depth=0;int code=setjmp(o_jmp); +if(!code)*result=f45(p0, p0_n, p1, p1_n); +o_busy=0;o_depth=0;return (uint32_t)code; +} +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif diff --git a/src/cudapp_om_nvml_step.ident b/src/cudapp_om_nvml_step.ident new file mode 100644 index 00000000..0c73af26 --- /dev/null +++ b/src/cudapp_om_nvml_step.ident @@ -0,0 +1 @@ +omega-ident 2 unit=nvml_step abi=bridge-seeded src=b982522e1b4667539fef916d9654286f60dabe9b46229acdbf56da5757ea9756 c=e0299f94fbd9784569ed6143e6531b5cea0a6b658ffd2e8bb6dc7db8f3a00ba9 omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f converter=69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84 frontend=23ff7a2356bb5d980060a4685a27ac46587013069b7d24b37c2873d7ee659b37 path=nvml_step=native/nvml/nvml.om,native/nvml/query.om,native/nvml/step.om diff --git a/src/cudapp_om_units.ident b/src/cudapp_om_units.ident index 63035a9e..d291165e 100644 --- a/src/cudapp_om_units.ident +++ b/src/cudapp_om_units.ident @@ -45,6 +45,8 @@ omega-ident 2 unit=attn_mirror_plan abi=bridge-seeded src=8ba540f04b2d098d34a902 omega-ident 2 unit=attn_mirror_step abi=bridge-seeded src=1bd3c7d9b8b9777dd893b1b70b3f16ab77dcd06dd2217808f13fc9c2896adc30 c=388daa2ba07d73c3bf26d89c7e16be6241d906c63ac868f96b3064556959cdcb omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f converter=69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84 frontend=23ff7a2356bb5d980060a4685a27ac46587013069b7d24b37c2873d7ee659b37 path=attn_mirror_step=om/attention-mirror/step.om omega-ident 2 unit=q38_runtime abi=bridge-seeded src=9b688d301a7dfa239268b23487bd653243625a785bb33f941c2f94d9f40a38ff c=5978e339d1946cd160ce1cd418ff4dbc72ae9d8727fc407066a114681f64cc38 omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f converter=69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84 frontend=23ff7a2356bb5d980060a4685a27ac46587013069b7d24b37c2873d7ee659b37 path=q38_runtime=om/q38-head/envelope.om,om/q38-head/plan.om omega-ident 2 unit=q38_emit abi=bridge-seeded src=5489b421b4c617d5bfaccd26756f59b9c207d3a67490d726d36ddb7ba4cde35a c=d6f2d354e16ea5e7f34181e4e63387c30da9759048caa18083eeb3dd88bc8bde omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f converter=69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84 frontend=23ff7a2356bb5d980060a4685a27ac46587013069b7d24b37c2873d7ee659b37 path=q38_emit=om/components/bw_alloc.om,om/components/bw_effect.om,om/components/bw_check.om,om/components/bw_project.om,om/encoder/bw_enc_sm121.om,om/encoder/bw_spec_sm121.om,om/components/encode.om,om/q38-head/bounds.om,om/q38-head/emit.om +omega-ident 2 unit=nvml_step abi=bridge-seeded src=b982522e1b4667539fef916d9654286f60dabe9b46229acdbf56da5757ea9756 c=e0299f94fbd9784569ed6143e6531b5cea0a6b658ffd2e8bb6dc7db8f3a00ba9 omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f converter=69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84 frontend=23ff7a2356bb5d980060a4685a27ac46587013069b7d24b37c2873d7ee659b37 path=nvml_step=native/nvml/nvml.om,native/nvml/query.om,native/nvml/step.om +omega-ident 2 unit=nvml_errstr abi=bridge-seeded src=cc7a11ea811e1a0b350c6df5244b4b657019ccc75c14a27ec40926c784abdd1d c=68f86b50ff3ac4ba9e4ba15212f27e358238802637f968115ee94c1d62a14f79 omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f converter=69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84 frontend=23ff7a2356bb5d980060a4685a27ac46587013069b7d24b37c2873d7ee659b37 path=nvml_errstr=native/nvml/errstr.om omega-ident 2 unit=revision abi=bridge-freest src=53a0fb536fed186d2fcd2d1793eb580892f07a372292f2ca0d7d7cb1cafb9c2d c=951aaf9528e3a24ff8e08cf40d064c3816feb9be352b959b512bb0ae59dca718 omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f converter=836cbf9ef8a3c4ee82b0458070884405bc8296f83b10f933556bf27750bb3661 frontend=51b41794e7001c5606b715fd7de8a34ec935a6e4e4bc1da36ad08102c009537d path=revision=om/pipeline/revision.om omega-ident 2 unit=epoch abi=bridge-freest src=7c11d2780ea1bed2aa899857d7cd476b4b300c7bd96825f9e36e73a50cb1b1f4 c=f437139b5681cd5045c05aff9159cc34848d78b97f88e641184e909aec2a7e59 omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f converter=836cbf9ef8a3c4ee82b0458070884405bc8296f83b10f933556bf27750bb3661 frontend=51b41794e7001c5606b715fd7de8a34ec935a6e4e4bc1da36ad08102c009537d path=epoch=om/pipeline/epoch.om omega-ident 2 unit=f16 abi=bridge-freest src=d1525d68f507f69b801be5a29fe2d46b775ba5d1fbdd6fa5ae2fb1539048d734 c=548482f1bbd07815a573157e11a3c72a0d269ced1b12b589e3cb321f20cb2d58 omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f converter=836cbf9ef8a3c4ee82b0458070884405bc8296f83b10f933556bf27750bb3661 frontend=51b41794e7001c5606b715fd7de8a34ec935a6e4e4bc1da36ad08102c009537d path=f16=om/numeric/f16.om diff --git a/tests/nvml/.crumb b/tests/nvml/.crumb new file mode 100644 index 00000000..3b11d72f --- /dev/null +++ b/tests/nvml/.crumb @@ -0,0 +1,20 @@ +{ + "extensions": { + "generated": { + "children": [], + "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "compiled_at": "2026-11-07T01:53:37Z", + "compiler": "crumb-compile/1", + "digest": "sha256:d88ff25e66f49a63baf8ad98bd0cb187ebc4a717acede3d1215bef83a58c3f03", + "evidence_files": 0, + "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "files": 7, + "generated_at_commit": "a33b2524c2e8455add4e8998b903c2b214f61a7f", + "source_tree": "sha256:5121761be50641b95f0819dcb16d63da394fad0bc0bc6647f8c35ae97bf6465e" + } + }, + "layer": "development", + "name": "cudapp-nvml-tests", + "purpose": "Host tier for the NVML subset: resource-manager fake, fake transport, ABI comparison with CUDA nvml.h, negative controls, mutants", + "schema_version": "1.0.0" +} diff --git a/tests/nvml/abi.c b/tests/nvml/abi.c new file mode 100644 index 00000000..5860dbd5 --- /dev/null +++ b/tests/nvml/abi.c @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* Prints the NVML ABI facts the CUDA++ subset depends on. tests/nvml/run.sh builds it once with + * compat/nvml/nvml.h and once with the CUDA toolkit's nvml.h (header only, nothing is linked) and + * requires identical output. */ +#include +#include + +#include "nvml.h" + +#define SHOW(x) printf("%s %lld\n", #x, (long long)(x)) + +int main(void) { + SHOW(sizeof(nvmlDevice_t)); + SHOW(sizeof(nvmlReturn_t)); + SHOW(sizeof(nvmlTemperatureSensors_t)); + SHOW(sizeof(nvmlUtilization_t)); + SHOW(offsetof(nvmlUtilization_t, gpu)); + SHOW(offsetof(nvmlUtilization_t, memory)); + SHOW(sizeof(nvmlMemory_t)); + SHOW(offsetof(nvmlMemory_t, total)); + SHOW(offsetof(nvmlMemory_t, free)); + SHOW(offsetof(nvmlMemory_t, used)); + SHOW(sizeof(nvmlProcessInfo_t)); + SHOW(offsetof(nvmlProcessInfo_t, pid)); + SHOW(offsetof(nvmlProcessInfo_t, usedGpuMemory)); + SHOW(offsetof(nvmlProcessInfo_t, gpuInstanceId)); + SHOW(offsetof(nvmlProcessInfo_t, computeInstanceId)); + SHOW(sizeof(nvmlProcessInfo_v2_t)); + SHOW(NVML_VALUE_NOT_AVAILABLE); + SHOW(NVML_TEMPERATURE_GPU); + SHOW(NVML_TEMPERATURE_COUNT); + SHOW(NVML_DEVICE_NAME_BUFFER_SIZE); + SHOW(NVML_DEVICE_NAME_V2_BUFFER_SIZE); + SHOW(NVML_DEVICE_UUID_BUFFER_SIZE); + SHOW(NVML_DEVICE_UUID_V2_BUFFER_SIZE); + SHOW(NVML_SUCCESS); + SHOW(NVML_ERROR_UNINITIALIZED); + SHOW(NVML_ERROR_INVALID_ARGUMENT); + SHOW(NVML_ERROR_NOT_SUPPORTED); + SHOW(NVML_ERROR_NO_PERMISSION); + SHOW(NVML_ERROR_ALREADY_INITIALIZED); + SHOW(NVML_ERROR_NOT_FOUND); + SHOW(NVML_ERROR_INSUFFICIENT_SIZE); + SHOW(NVML_ERROR_INSUFFICIENT_POWER); + SHOW(NVML_ERROR_DRIVER_NOT_LOADED); + SHOW(NVML_ERROR_TIMEOUT); + SHOW(NVML_ERROR_IRQ_ISSUE); + SHOW(NVML_ERROR_LIBRARY_NOT_FOUND); + SHOW(NVML_ERROR_FUNCTION_NOT_FOUND); + SHOW(NVML_ERROR_CORRUPTED_INFOROM); + SHOW(NVML_ERROR_GPU_IS_LOST); + SHOW(NVML_ERROR_RESET_REQUIRED); + SHOW(NVML_ERROR_OPERATING_SYSTEM); + SHOW(NVML_ERROR_LIB_RM_VERSION_MISMATCH); + SHOW(NVML_ERROR_IN_USE); + SHOW(NVML_ERROR_MEMORY); + SHOW(NVML_ERROR_NO_DATA); + SHOW(NVML_ERROR_VGPU_ECC_NOT_SUPPORTED); + SHOW(NVML_ERROR_INSUFFICIENT_RESOURCES); + SHOW(NVML_ERROR_FREQ_NOT_SUPPORTED); + SHOW(NVML_ERROR_ARGUMENT_VERSION_MISMATCH); + SHOW(NVML_ERROR_DEPRECATED); + SHOW(NVML_ERROR_NOT_READY); + SHOW(NVML_ERROR_GPU_NOT_FOUND); + SHOW(NVML_ERROR_INVALID_STATE); + SHOW(NVML_ERROR_RESET_TYPE_NOT_SUPPORTED); + SHOW(NVML_ERROR_UNKNOWN); + return 0; +} diff --git a/tests/nvml/errstr-oracle.tsv b/tests/nvml/errstr-oracle.tsv new file mode 100644 index 00000000..955c30f0 --- /dev/null +++ b/tests/nvml/errstr-oracle.tsv @@ -0,0 +1,37 @@ +-1 Unknown Error +0 Success +1 Uninitialized +2 Invalid Argument +3 Not Supported +4 Insufficient Permissions +5 Already Initialized +6 Not Found +7 Insufficient Size +8 Insufficient External Power +9 Driver Not Loaded +10 Timeout +11 Interrupt Request Issue +12 NVML Shared Library Not Found +13 Function Not Found +14 Corrupted infoROM +15 GPU is lost +16 GPU requires reset +17 GPU access blocked by the operating system +18 Driver/library version mismatch +19 In use by another client +20 Insufficient Memory +21 No data +22 vGPU ECC not supported +23 Insufficient Resources +24 Invalid Frequency +25 Argument version mismatch +26 Requested functionality has been deprecated +27 System is not in ready state +28 No supported GPUs were found +29 Resource not in correct state to perform requested operation +30 Reset type is not supported for given device +31 Unknown Error +32 Unknown Error +999 Unknown Error +1000 Unknown Error +4294967295 Unknown Error diff --git a/tests/nvml/nvml_test.c b/tests/nvml/nvml_test.c new file mode 100644 index 00000000..2142d76e --- /dev/null +++ b/tests/nvml/nvml_test.c @@ -0,0 +1,344 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* Host test of the CUDA++ NVML subset (compat/nvml) over the Omega RM fake (tests/nvml/rmfake.om). + * Expected return codes follow the documented returns of each entry point in nvml.h (CUDA 13.0). + * usage: nvml_test ERRSTR_ORACLE.tsv */ +#include +#include +#include + +#include "nvml.h" +#include "transport.h" + +static unsigned checks, fails; + +#define CHECK(cond, ...) \ + do { \ + checks++; \ + if (!(cond)) { \ + fails++; \ + printf("FAIL line %d: ", __LINE__); \ + printf(__VA_ARGS__); \ + printf("\n"); \ + } \ + } while (0) + +#define RC(call, want, what) \ + do { \ + nvmlReturn_t got_ = (call); \ + CHECK(got_ == (want), "%s: rc %d, want %d", what, (int)got_, (int)(want)); \ + } while (0) + +static const char *const UUID0 = "GPU-fb8e53f0-3207-e89b-d02f-acdfe2695b59"; +static const char *const UUID1 = "GPU-fb8e53f0-3207-e89b-d02f-acdfe2695b5a"; + +/* Every fd closed, every RM object freed, no request outside the RM contract. */ +static void clean(const char *what) { + CHECK(fake_get(14) == 0, "%s: open fd mask %llx", what, (unsigned long long)fake_get(14)); + CHECK(fake_get(15) == 0, "%s: %llu live RM objects", what, (unsigned long long)fake_get(15)); + CHECK(fake_get(16) == 0, "%s: root client still allocated", what); + CHECK(fake_get(8) == fake_get(9), "%s: %llu opens, %llu closes", what, + (unsigned long long)fake_get(8), (unsigned long long)fake_get(9)); + CHECK(fake_get(13) == 0, "%s: %llu RM contract violations", what, + (unsigned long long)fake_get(13)); +} + +static void errstrings(const char *path) { + FILE *f = fopen(path, "r"); + CHECK(f != NULL, "open %s", path); + if (f == NULL) return; + char line[256]; + unsigned rows = 0; + while (fgets(line, sizeof line, f)) { + char *tab = strchr(line, '\t'); + if (tab == NULL) continue; + *tab = 0; + char *want = tab + 1; + want[strcspn(want, "\n")] = 0; + long long code = strtoll(line, NULL, 10); + const char *got = nvmlErrorString((nvmlReturn_t)(int)(unsigned)code); + CHECK(got != NULL && strcmp(got, want) == 0, "nvmlErrorString(%lld) = \"%s\", want \"%s\"", + code, got ? got : "(null)", want); + rows++; + } + fclose(f); + CHECK(rows == 37, "oracle rows %u, want 37", rows); + CHECK(nvmlErrorString(NVML_SUCCESS) == nvmlErrorString(NVML_SUCCESS), "stable string pointer"); + CHECK(nvmlErrorString((nvmlReturn_t)31) == nvmlErrorString((nvmlReturn_t)999), + "one Unknown Error string"); +} + +static void healthy(void) { + unsigned n = 77, t = 0; + nvmlDevice_t d = NULL, d1 = NULL; + char buf[128]; + fake_reset(0); + + RC(nvmlDeviceGetCount_v2(&n), NVML_ERROR_UNINITIALIZED, "count before init"); + RC(nvmlDeviceGetHandleByIndex_v2(0, &d), NVML_ERROR_UNINITIALIZED, "handle before init"); + RC(nvmlShutdown(), NVML_ERROR_UNINITIALIZED, "shutdown before init"); + CHECK(fake_get(8) == 0, "no open before init"); + + RC(nvmlInit_v2(), NVML_SUCCESS, "init"); + RC(nvmlDeviceGetCount_v2(&n), NVML_SUCCESS, "count"); + CHECK(n == 1, "count %u, want 1", n); + RC(nvmlDeviceGetCount_v2(NULL), NVML_ERROR_INVALID_ARGUMENT, "count NULL"); + + RC(nvmlDeviceGetHandleByIndex_v2(0, &d), NVML_SUCCESS, "handle 0"); + CHECK(d != NULL, "handle 0 non-NULL"); + RC(nvmlDeviceGetHandleByIndex_v2(1, &d1), NVML_ERROR_INVALID_ARGUMENT, "handle 1"); + RC(nvmlDeviceGetHandleByIndex_v2(0, NULL), NVML_ERROR_INVALID_ARGUMENT, "handle NULL"); + + memset(buf, 'x', sizeof buf); + RC(nvmlDeviceGetName(d, buf, NVML_DEVICE_NAME_V2_BUFFER_SIZE), NVML_SUCCESS, "name 96"); + CHECK(strcmp(buf, "NVIDIA GB10") == 0, "name \"%.64s\"", buf); + RC(nvmlDeviceGetName(d, buf, 11), NVML_ERROR_INSUFFICIENT_SIZE, "name length 11"); + memset(buf, 'x', sizeof buf); + RC(nvmlDeviceGetName(d, buf, 12), NVML_SUCCESS, "name length 12"); + CHECK(strcmp(buf, "NVIDIA GB10") == 0, "name 12 \"%.64s\"", buf); + RC(nvmlDeviceGetName(NULL, buf, 64), NVML_ERROR_INVALID_ARGUMENT, "name NULL device"); + RC(nvmlDeviceGetName((nvmlDevice_t)(void *)buf, buf, 64), NVML_ERROR_INVALID_ARGUMENT, + "name foreign device"); + RC(nvmlDeviceGetName(d, NULL, 64), NVML_ERROR_INVALID_ARGUMENT, "name NULL buffer"); + + memset(buf, 'x', sizeof buf); + RC(nvmlDeviceGetUUID(d, buf, NVML_DEVICE_UUID_V2_BUFFER_SIZE), NVML_SUCCESS, "uuid 96"); + CHECK(strcmp(buf, UUID0) == 0, "uuid \"%.96s\"", buf); + RC(nvmlDeviceGetUUID(d, buf, 40), NVML_ERROR_INSUFFICIENT_SIZE, "uuid length 40"); + memset(buf, 'x', sizeof buf); + RC(nvmlDeviceGetUUID(d, buf, 41), NVML_SUCCESS, "uuid length 41"); + CHECK(strcmp(buf, UUID0) == 0, "uuid 41 \"%.96s\"", buf); + RC(nvmlDeviceGetUUID(d, NULL, 80), NVML_ERROR_INVALID_ARGUMENT, "uuid NULL buffer"); + + RC(nvmlDeviceGetTemperature(d, NVML_TEMPERATURE_GPU, &t), NVML_SUCCESS, "temperature"); + CHECK(t == 40, "temperature %u, want 40", t); + RC(nvmlDeviceGetTemperature(d, NVML_TEMPERATURE_COUNT, &t), NVML_ERROR_INVALID_ARGUMENT, + "temperature sensor 1"); + RC(nvmlDeviceGetTemperature(d, NVML_TEMPERATURE_GPU, NULL), NVML_ERROR_INVALID_ARGUMENT, + "temperature NULL"); + + nvmlMemory_t m; + memset(&m, 0xa5, sizeof m); + RC(nvmlDeviceGetMemoryInfo(d, &m), NVML_SUCCESS, "memory"); + CHECK(m.total == 131072000000ull && m.free == 102400000000ull && m.used == 28672000000ull, + "memory %llu/%llu/%llu", (unsigned long long)m.total, (unsigned long long)m.free, + (unsigned long long)m.used); + RC(nvmlDeviceGetMemoryInfo(d, NULL), NVML_ERROR_INVALID_ARGUMENT, "memory NULL"); + + nvmlUtilization_t u = {77, 77}; + RC(nvmlDeviceGetUtilizationRates(d, &u), NVML_SUCCESS, "utilization"); + CHECK(u.gpu == 42 && u.memory == 13, "utilization %u/%u, want 42/13", u.gpu, u.memory); + RC(nvmlDeviceGetUtilizationRates(d, NULL), NVML_ERROR_INVALID_ARGUMENT, "utilization NULL"); + + nvmlProcessInfo_t p[5]; + n = 0; + RC(nvmlDeviceGetComputeRunningProcesses_v3(d, &n, NULL), NVML_ERROR_INSUFFICIENT_SIZE, + "procs count 0"); + CHECK(n == 2, "procs needed %u, want 2", n); + n = 1; + RC(nvmlDeviceGetComputeRunningProcesses_v3(d, &n, p), NVML_ERROR_INSUFFICIENT_SIZE, + "procs count 1"); + CHECK(n == 2, "procs needed %u, want 2", n); + n = 2; + RC(nvmlDeviceGetComputeRunningProcesses_v3(d, &n, NULL), NVML_ERROR_INVALID_ARGUMENT, + "procs NULL infos"); + RC(nvmlDeviceGetComputeRunningProcesses_v3(d, NULL, p), NVML_ERROR_INVALID_ARGUMENT, + "procs NULL count"); + memset(p, 0, sizeof p); + n = 5; + RC(nvmlDeviceGetComputeRunningProcesses_v3(d, &n, p), NVML_SUCCESS, "procs count 5"); + CHECK(n == 2, "procs %u, want 2", n); + CHECK(p[0].pid == 68451 && p[0].usedGpuMemory == 351272960ull, "proc 0 %u %llu", p[0].pid, + (unsigned long long)p[0].usedGpuMemory); + CHECK(p[1].pid == 4242 && p[1].usedGpuMemory == 278003712ull, "proc 1 %u %llu", p[1].pid, + (unsigned long long)p[1].usedGpuMemory); + CHECK(p[0].gpuInstanceId == 0xFFFFFFFFu && p[0].computeInstanceId == 0xFFFFFFFFu && + p[1].gpuInstanceId == 0xFFFFFFFFu && p[1].computeInstanceId == 0xFFFFFFFFu, + "proc instance ids not NVML_VALUE_NOT_AVAILABLE"); + CHECK(p[2].pid == 0, "proc 2 written"); + + RC(nvmlShutdown(), NVML_SUCCESS, "shutdown"); + RC(nvmlDeviceGetCount_v2(&n), NVML_ERROR_UNINITIALIZED, "count after shutdown"); + RC(nvmlDeviceGetName(d, buf, 64), NVML_ERROR_UNINITIALIZED, "name after shutdown"); + RC(nvmlShutdown(), NVML_ERROR_UNINITIALIZED, "second shutdown"); + clean("healthy"); +} + +/* nvmlInit/nvmlShutdown keep a reference count; only the last shutdown tears down (nvml.h). */ +static void refcount(void) { + unsigned n = 0; + fake_reset(0); + RC(nvmlInit(), NVML_SUCCESS, "unversioned nvmlInit"); + uint64_t opens = fake_get(8); + CHECK(opens == 2, "init opened %llu files, want 2", (unsigned long long)opens); + RC(nvmlInit_v2(), NVML_SUCCESS, "second init"); + CHECK(fake_get(8) == opens, "second init reopened a device (%llu opens)", + (unsigned long long)fake_get(8)); + RC(nvmlShutdown(), NVML_SUCCESS, "first shutdown"); + RC(nvmlDeviceGetCount(&n), NVML_SUCCESS, "count while one reference remains"); + CHECK(fake_get(9) == 0, "first shutdown closed a device"); + RC(nvmlShutdown(), NVML_SUCCESS, "last shutdown"); + RC(nvmlDeviceGetCount_v2(&n), NVML_ERROR_UNINITIALIZED, "count after last shutdown"); + clean("refcount"); + RC(nvmlInit_v2(), NVML_SUCCESS, "re-init"); + RC(nvmlShutdown(), NVML_SUCCESS, "re-init shutdown"); + clean("re-init"); +} + +enum call { NONE, COUNT, NAME, UUID, TEMP, MEM, UTIL, PROCS }; + +struct fault { + char letter; + nvmlReturn_t init; + enum call call; + nvmlReturn_t rc; +}; + +static const struct fault FAULTS[] = { + {'o', NVML_ERROR_DRIVER_NOT_LOADED, NONE, 0}, + {'a', NVML_ERROR_NO_PERMISSION, NONE, 0}, + {'d', NVML_ERROR_DRIVER_NOT_LOADED, NONE, 0}, + {'P', NVML_ERROR_NO_PERMISSION, NONE, 0}, + {'A', NVML_ERROR_NO_PERMISSION, NONE, 0}, + {'9', NVML_ERROR_UNKNOWN, NONE, 0}, + {'0', NVML_SUCCESS, COUNT, NVML_SUCCESS}, + {'2', NVML_SUCCESS, COUNT, NVML_SUCCESS}, + {'c', NVML_SUCCESS, NAME, NVML_ERROR_NOT_SUPPORTED}, + {'G', NVML_SUCCESS, NAME, NVML_ERROR_GPU_IS_LOST}, + {'n', NVML_SUCCESS, NAME, NVML_ERROR_UNKNOWN}, + {'E', NVML_SUCCESS, NAME, NVML_ERROR_UNKNOWN}, + {'S', NVML_SUCCESS, NAME, NVML_ERROR_UNKNOWN}, + {'g', NVML_SUCCESS, UUID, NVML_ERROR_UNKNOWN}, + {'t', NVML_SUCCESS, TEMP, NVML_ERROR_UNKNOWN}, + {'h', NVML_SUCCESS, TEMP, NVML_ERROR_UNKNOWN}, + {'v', NVML_SUCCESS, TEMP, NVML_ERROR_NOT_SUPPORTED}, + {'z', NVML_SUCCESS, MEM, NVML_ERROR_NOT_SUPPORTED}, + {'x', NVML_SUCCESS, MEM, NVML_ERROR_NOT_SUPPORTED}, + {'m', NVML_SUCCESS, MEM, NVML_ERROR_UNKNOWN}, + {'w', NVML_SUCCESS, UTIL, NVML_ERROR_NOT_SUPPORTED}, + {'y', NVML_SUCCESS, UTIL, NVML_ERROR_NO_PERMISSION}, + {'e', NVML_SUCCESS, UTIL, NVML_ERROR_UNKNOWN}, + {'r', NVML_SUCCESS, UTIL, NVML_ERROR_UNKNOWN}, + {'Z', NVML_SUCCESS, UTIL, NVML_ERROR_UNKNOWN}, + {'X', NVML_SUCCESS, UTIL, NVML_ERROR_UNKNOWN}, + {'k', NVML_SUCCESS, PROCS, NVML_ERROR_NOT_SUPPORTED}, + {'l', NVML_SUCCESS, PROCS, NVML_SUCCESS}, + {'p', NVML_SUCCESS, PROCS, NVML_ERROR_UNKNOWN}, + {'b', NVML_SUCCESS, PROCS, NVML_SUCCESS}, + {'i', NVML_SUCCESS, PROCS, NVML_SUCCESS}, + {'j', NVML_SUCCESS, PROCS, NVML_ERROR_UNKNOWN}, + {'f', NVML_SUCCESS, NONE, 0}, +}; + +static nvmlProcessInfo_t procs[256]; + +static void one(const struct fault *f) { + char what[32], buf[96]; + unsigned n = 0, t = 0; + nvmlDevice_t d = NULL; + nvmlMemory_t m; + nvmlUtilization_t u; + snprintf(what, sizeof what, "fault %c", f->letter); + fake_reset(f->letter); + nvmlReturn_t r = nvmlInit_v2(); + CHECK(r == f->init, "%s: init rc %d, want %d", what, (int)r, (int)f->init); + if (r != NVML_SUCCESS) { + RC(nvmlDeviceGetCount_v2(&n), NVML_ERROR_UNINITIALIZED, what); + clean(what); + return; + } + if (f->call != COUNT) RC(nvmlDeviceGetHandleByIndex_v2(0, &d), NVML_SUCCESS, what); + switch (f->call) { + case NONE: + break; + case COUNT: + RC(nvmlDeviceGetCount_v2(&n), f->rc, what); + if (f->letter == '0') { + CHECK(n == 0, "%s: count %u, want 0", what, n); + RC(nvmlDeviceGetHandleByIndex_v2(0, &d), NVML_ERROR_INVALID_ARGUMENT, what); + } else { + CHECK(n == 2, "%s: count %u, want 2", what, n); + nvmlDevice_t d0 = NULL, d1 = NULL; + RC(nvmlDeviceGetHandleByIndex_v2(0, &d0), NVML_SUCCESS, what); + RC(nvmlDeviceGetHandleByIndex_v2(1, &d1), NVML_SUCCESS, what); + CHECK(d0 != d1, "%s: distinct handles", what); + RC(nvmlDeviceGetUUID(d1, buf, sizeof buf), NVML_SUCCESS, what); + CHECK(strcmp(buf, UUID1) == 0, "%s: uuid 1 \"%s\"", what, buf); + RC(nvmlDeviceGetUUID(d0, buf, sizeof buf), NVML_SUCCESS, what); + CHECK(strcmp(buf, UUID0) == 0, "%s: uuid 0 \"%s\"", what, buf); + RC(nvmlDeviceGetTemperature(d1, NVML_TEMPERATURE_GPU, &t), NVML_SUCCESS, what); + CHECK(t == 41, "%s: temperature 1 %u, want 41", what, t); + RC(nvmlDeviceGetHandleByIndex_v2(2, &d), NVML_ERROR_INVALID_ARGUMENT, what); + } + break; + case NAME: + RC(nvmlDeviceGetName(d, buf, sizeof buf), f->rc, what); + break; + case UUID: + RC(nvmlDeviceGetUUID(d, buf, sizeof buf), f->rc, what); + break; + case TEMP: + RC(nvmlDeviceGetTemperature(d, NVML_TEMPERATURE_GPU, &t), f->rc, what); + break; + case MEM: + RC(nvmlDeviceGetMemoryInfo(d, &m), f->rc, what); + break; + case UTIL: + RC(nvmlDeviceGetUtilizationRates(d, &u), f->rc, what); + break; + case PROCS: + n = 256; + memset(procs, 0, sizeof procs); + RC(nvmlDeviceGetComputeRunningProcesses_v3(d, &n, procs), f->rc, what); + if (f->letter == 'l') CHECK(n == 0, "%s: procs %u, want 0", what, n); + if (f->letter == 'b') { + CHECK(n == 250, "%s: procs %u, want 250", what, n); + unsigned bad = 0; + for (unsigned i = 0; i < 250; i++) + if (procs[i].pid != 1000 + i || + procs[i].usedGpuMemory != (unsigned long long)(1000 + i) * 65536ull) + bad++; + CHECK(bad == 0, "%s: %u of 250 entries wrong", what, bad); + n = 249; + RC(nvmlDeviceGetComputeRunningProcesses_v3(d, &n, procs), NVML_ERROR_INSUFFICIENT_SIZE, + what); + CHECK(n == 250, "%s: needed %u, want 250", what, n); + } + if (f->letter == 'i') { + CHECK(n == 2 && procs[0].usedGpuMemory == 351272960ull && + procs[1].pid == 4242 && + procs[1].usedGpuMemory == (unsigned long long)NVML_VALUE_NOT_AVAILABLE, + "%s: procs %u, memory %llu %llu", what, n, + (unsigned long long)procs[0].usedGpuMemory, + (unsigned long long)procs[1].usedGpuMemory); + } + break; + } + if (f->letter == 'f') { + RC(nvmlShutdown(), NVML_ERROR_UNKNOWN, what); + RC(nvmlDeviceGetCount_v2(&n), NVML_ERROR_UNINITIALIZED, what); + CHECK(fake_get(14) == 0, "%s: fds left open %llx", what, (unsigned long long)fake_get(14)); + CHECK(fake_get(13) == 0, "%s: violations %llu", what, (unsigned long long)fake_get(13)); + return; + } + RC(nvmlShutdown(), NVML_SUCCESS, what); + clean(what); +} + +int main(int argc, char **argv) { + if (argc != 2) { + fprintf(stderr, "usage: nvml_test ERRSTR_ORACLE.tsv\n"); + return 2; + } + errstrings(argv[1]); + healthy(); + refcount(); + for (unsigned i = 0; i < sizeof FAULTS / sizeof FAULTS[0]; i++) one(&FAULTS[i]); + healthy(); + CHECK(fake_trapped() == 0, "fake trapped %llu times", (unsigned long long)fake_trapped()); + if (fails) { + printf("CUDAPP-NVML HOST FAIL (%u of %u checks)\n", fails, checks); + return 1; + } + printf("CUDAPP-NVML HOST PASS (%u checks)\n", checks); + return 0; +} diff --git a/tests/nvml/rmfake.om b/tests/nvml/rmfake.om new file mode 100644 index 00000000..950fbd41 --- /dev/null +++ b/tests/nvml/rmfake.om @@ -0,0 +1,724 @@ +note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +note rmfake.om: host-only stand-in for the NVIDIA resource manager behind compat/nvml. Pure unit +note nvml_fake, lowered by tests/nvml/run.sh and called by tests/nvml/transport.c in place of +note omega2_nvrm_open_file, omega2_nvrm_close_file and omega2_nvrm_ioctl. No device file is opened. +note Replies imitate a GB10 (one GPU, or two with fault 2); they are synthetic, not a hardware record. +note +note st (ulong 64): 0 kind (1 ioctl, 2 open, 3 close), 1 fd, 2 nr, 3 header bytes, 4 params bytes, +note 5 fault letter, 6 result (signed), 7 path bytes (open; the path is in p). +note Counters: 8 opens, 9 closes, 10 allocs, 11 frees, 12 controls, 13 violations (a request the real +note RM would refuse or a wrong layout), 14 open-fd mask (bit fd-10), 15 live objects, 16 root client. +note Objects: 32..47 live handles, 48+i device and 50+i subdevice of GPU i. +note Faults (st 5, ASCII): o a d control open ENOENT, control open EACCES, device open ENXIO; +note P root alloc EPERM; A device alloc 0x1B; 0 no GPU; 9 nine GPUs; 2 two GPUs; +note c name 0x56; G name 0x0F; n name without zero; E empty name; g GID length 20; +note t thermal not executed; h negative reading; v no GPU-type target; +note z no framebuffer; x FB info 0x56; m free above total; +note w util 0x56; y util 0x1B; e empty ring; r tracker 72; Z newest timestamp 0; X gr.util 10001; +note k no compute class; l no PIDs; p 951 PIDs; b 250 PIDs; i PID 4242 info fails; j wrong pid echoed; +note f subdevice free 0x1F. +note Healthy replies: name NVIDIA GB10, GID fb8e53f0-3207-e89b-d02f-acdfe2695b59 (GPU 1 ends 5a), +note reading 40 (GPU 1 41), total 128000000 KiB, free 100000000 KiB, newest util sample (index 4 of +note tracker 5) gr 4200 fb 1300 while sample k holds gr 100k fb 50k, PIDs 68451 (351272960 bytes) +note and 4242 (pid*65536). Constants: evidence/NVML-2026-11-06/wolfram.txt. + +const HN ulong 4608 +const PN ulong 55888 +const RT ulong 3251634177 + +fn hg h edit uchar HN o ulong to ulong +v = ulong 0 +for i ulong 4 +v = or v shl ulong get h add o i mul i 8 +end +ret v +end + +fn hp h edit uchar HN o ulong v ulong to void +for i ulong 4 +put h add o i uchar and shr v mul i 8 255 +end +end + +fn pn p edit uchar PN o ulong n ulong to ulong +v = ulong 0 +for i ulong n +v = or v shl ulong get p add o i mul i 8 +end +ret v +end + +fn pg p edit uchar PN o ulong to ulong +ret pn p o 4 +end + +fn pp p edit uchar PN o ulong v ulong to void +for i ulong 4 +put p add o i uchar and shr v mul i 8 255 +end +end + +fn pq p edit uchar PN o ulong v ulong to void +for i ulong 8 +put p add o i uchar and shr v mul i 8 255 +end +end + +fn bad st edit ulong 64 to void +put st 13 add get st 13 1 +end + +fn flt st edit ulong 64 c ulong to bool +ret eq get st 5 c +end + +note A request on fd with the given header and params bytes; anything else is a violation. +fn want st edit ulong 64 fd ulong hl ulong pl ulong to bool +if and eq get st 1 fd and eq get st 3 hl eq get st 4 pl +ret true +end +bad st +ret false +end + +note A control with params bytes n on an acceptable object (ok); anything else is a violation. +fn need st edit ulong 64 n ulong ok bool to bool +if and ok eq get st 4 n +ret true +end +bad st +ret false +end + +fn ngpu st edit ulong 64 to ulong +if flt st 50 +ret 2 +end +ret 1 +end + +fn isopen st edit ulong 64 fd ulong to bool +if or lt fd 10 gt fd 12 +ret false +end +ret ne and shr get st 14 sub fd 10 1 0 +end + +fn slot st edit ulong 64 x ulong to ulong +for i ulong 16 +if eq get st add 32 i x +ret add i 1 +end +end +ret 0 +end + +fn keep st edit ulong 64 x ulong to void +i = slot st 0 +if or eq x 0 or eq i 0 ne slot st x 0 +bad st +ret +end +put st add 31 i x +put st 10 add get st 10 1 +put st 15 add get st 15 1 +end + +fn gpu st edit ulong 64 x ulong to ulong +for i ulong 2 +if and ne x 0 or eq get st add 48 i x eq get st add 50 i x +ret i +end +end +ret 9 +end + +fn isdev st edit ulong 64 x ulong to bool +ret and ne x 0 or eq get st 48 x eq get st 49 x +end + +fn issub st edit ulong 64 x ulong to bool +ret and ne x 0 or eq get st 50 x eq get st 51 x +end + +note Open: /dev/nvidiactl is fd 10, /dev/nvidia is fd 11+m. +fn fkopen st edit ulong 64 p edit uchar PN to long +n = get st 7 +fd = long neg long 2 +if and eq n 14 and eq pn p 0 8 7599382571363165231 eq pn p 8 6 119247139334500 +if flt st 111 +ret neg long 2 +end +if flt st 97 +ret neg long 13 +end +fd = long 10 +end +if and eq n 12 and eq pn p 0 8 7599382571363165231 eq pn p 8 3 6383972 +m = ulong get p 11 +if and ge m 48 lt m add 48 ngpu st +if flt st 100 +ret neg long 6 +end +fd = long add 11 sub m 48 +end +end +if lt fd 0 +bad st +ret fd +end +if isopen st ulong fd +bad st +ret neg long 16 +end +put st 14 or get st 14 shl 1 sub ulong fd 10 +put st 8 add get st 8 1 +ret fd +end + +fn fkclose st edit ulong 64 to long +fd = get st 1 +if not isopen st fd +bad st +ret neg long 9 +end +put st 14 and get st 14 not shl 1 sub fd 10 +put st 9 add get st 9 1 +ret 0 +end + +note NV_ESC_CARD_INFO: entries of 72 bytes, valid 0, gpu_id 16 (256+i), minor_number 56 (i). +fn fkcard st edit ulong 64 h edit uchar HN to long +if not want st 10 HN 0 +ret neg long 22 +end +if not isopen st 10 +bad st +ret neg long 22 +end +for i ulong HN +put h i 0 +end +n = ngpu st +if flt st 48 +n = 0 +end +if flt st 57 +n = 9 +end +for i ulong n +o = mul i 72 +put h o 1 +hp h add o 16 add 256 i +hp h add o 56 i +end +ret 0 +end + +fn fkreg st edit ulong 64 h edit uchar HN to long +fd = get st 1 +if not want st fd 4 0 +ret neg long 22 +end +if or lt fd 11 or not isopen st fd ne hg h 0 10 +bad st +ret neg long 22 +end +ret 0 +end + +fn fkdev st edit ulong 64 h edit uchar HN p edit uchar PN to ulong +x = hg h 8 +i = pg p 0 +r = get st 16 +if not need st 56 and eq hg h 4 r and eq pg p 4 r lt i ngpu st +ret 86 +end +if ne get st add 48 i 0 +bad st +ret 86 +end +if flt st 65 +ret 27 +end +keep st x +put st add 48 i x +ret 0 +end + +fn fksub st edit ulong 64 h edit uchar HN to ulong +x = hg h 8 +d = hg h 4 +if not need st 4 isdev st d +ret 86 +end +i = gpu st d +if ne get st add 50 i 0 +bad st +ret 86 +end +keep st x +put st add 50 i x +ret 0 +end + +note NV_ESC_RM_ALLOC: NVOS21 hRoot 0, parent 4, hObjectNew 8, hClass 12, status 28. +fn fkalloc st edit ulong 64 h edit uchar HN p edit uchar PN to long +if or ne get st 1 10 ne get st 3 32 +bad st +ret neg long 22 +end +c = hg h 12 +v = ulong 86 +if eq c 65 +if flt st 80 +ret neg long 1 +end +if or ne get st 4 0 ne get st 16 0 +bad st +else +if or ne hg h 0 0 ne hg h 4 0 +bad st +else +hp h 8 RT +put st 16 RT +keep st RT +v = 0 +end +end +hp h 28 v +ret 0 +end +if ne hg h 0 get st 16 +bad st +v = 86 +else +if eq c 128 +v = fkdev st h p +end +if eq c 8320 +v = fksub st h +end +end +hp h 28 v +ret 0 +end + +fn unmap st edit ulong 64 x ulong to void +for i ulong 4 +if eq get st add 48 i x +put st add 48 i 0 +end +end +end + +note NV_ESC_RM_FREE: NVOS00 hRoot 0, parent 4, hObjectOld 8, status 12. A freed parent must have no +note live child (the caller frees bottom-up). +fn fkfree st edit ulong 64 h edit uchar HN to long +if not want st 10 16 0 +ret neg long 22 +end +r = hg h 0 +q = hg h 4 +x = hg h 8 +i = slot st x +ok = and ne i 0 eq r get st 16 +if eq x r +ok = and ok and eq q r eq get st 15 1 +end +if isdev st x +ok = and ok eq q r +if ne get st add 50 gpu st x 0 +ok = false +end +end +if issub st x +if ne get st add 48 gpu st x q +ok = false +end +end +if not ok +bad st +hp h 12 86 +ret 0 +end +put st add 31 i 0 +put st 11 add get st 11 1 +put st 15 sub get st 15 1 +if eq x r +put st 16 0 +end +f = issub st x +unmap st x +v = ulong 0 +if and f flt st 102 +v = 31 +end +hp h 12 v +ret 0 +end + +fn c517 st edit ulong 64 p edit uchar PN o ulong to ulong +i = sub pg p 0 256 +if not need st 32 and eq o get st 16 lt i ngpu st +ret 86 +end +pp p 8 i +ret 0 +end + +fn cclass st edit ulong 64 p edit uchar PN o ulong to ulong +if not need st 804 isdev st o +ret 86 +end +pp p 0 3 +pp p 4 41141 +if flt st 107 +pp p 8 50880 +else +pp p 8 52928 +end +pp p 12 51311 +ret 0 +end + +fn cname st edit ulong 64 p edit uchar PN o ulong to ulong +if not need st 132 and issub st o eq pg p 0 0 +ret 86 +end +if flt st 99 +ret 86 +end +if flt st 71 +ret 15 +end +if flt st 69 +ret 0 +end +if flt st 110 +for i ulong 128 +put p add 4 i 65 +end +ret 0 +end +pq p 4 5125168158881699406 +pp p 12 3158338 +ret 0 +end + +fn cgid st edit ulong 64 p edit uchar PN o ulong to ulong +if not need st 268 and issub st o eq pg p 4 2 +ret 86 +end +if flt st 103 +pp p 8 20 +else +pp p 8 16 +end +pq p 12 11234237185837469435 +if eq gpu st o 1 +pq p 20 6510914109430312912 +else +pq p 20 6438856515392384976 +end +ret 0 +end + +fn cthop st edit ulong 64 p edit uchar PN o ulong k ulong g ulong to bool +op = pg p add o 8 +a = pg p add o 12 +if or eq op 256 eq op 1280 +pp p add o 12 1 +ret true +end +if ne a 0 +ret false +end +if eq op 257 +if flt st 118 +pp p add o 16 2 +else +pp p add o 16 1 +end +ret true +end +if eq op 1312 +pp p add o 16 0 +ret true +end +if eq op 5376 +if flt st 104 +pp p add o 16 4294967286 +else +pp p add o 16 add 40 g +end +ret true +end +ret false +end + +fn ctherm st edit ulong 64 p edit uchar PN o ulong to ulong +n = pg p 20 +if not need st 1432 issub st o +ret 86 +end +if or ne pg p 0 1 or ne pg p 8 44 gt n 32 +bad st +ret 86 +end +g = gpu st o +for k ulong n +q = add 24 mul k 44 +if not cthop st p q k g +bad st +ret 86 +end +pp p q 0 +if and flt st 116 eq k 0 +pp p add q 4 0 +else +pp p add q 4 1 +end +end +ret 0 +end + +fn cfb st edit ulong 64 p edit uchar PN o ulong to ulong +n = pg p 0 +if not need st 1028 and issub st o le n 128 +ret 86 +end +if flt st 120 +ret 86 +end +for i ulong n +q = add 4 mul i 8 +x = pg p q +v = ulong 0 +if eq x 54 +if flt st 122 +v = 1 +end +else +if eq x 8 +v = 128000000 +else +if eq x 22 +if flt st 109 +v = 200000000 +else +v = 100000000 +end +else +bad st +ret 86 +end +end +end +pp p add q 4 v +end +ret 0 +end + +fn cutil st edit ulong 64 p edit uchar PN o ulong to ulong +if not need st PN issub st o +ret 86 +end +if or ne get p 0 2 ne pg p 4 55872 +bad st +ret 86 +end +if flt st 119 +ret 86 +end +if flt st 121 +ret 27 +end +if flt st 101 +pp p 8 0 +else +pp p 8 72 +end +if flt st 114 +pp p 12 72 +else +pp p 12 5 +end +for k ulong 72 +q = add 16 mul k 776 +f = mul k 50 +g = mul k 100 +t = add 1000 k +if eq k 4 +f = 1300 +g = 4200 +if flt st 88 +g = 10001 +end +if flt st 90 +t = 0 +end +end +pq p q t +pp p add q 8 f +pp p add q 136 g +end +ret 0 +end + +fn cpids st edit ulong 64 p edit uchar PN o ulong to ulong +if not need st 3812 issub st o +ret 86 +end +if or ne pg p 0 0 ne pg p 4 52928 +bad st +ret 86 +end +n = ulong 2 +if flt st 108 +n = 0 +end +if flt st 112 +n = 951 +end +if flt st 98 +n = 250 +end +pp p 8 n +if eq n 2 +pp p 12 68451 +pp p 16 4242 +end +if eq n 250 +for i ulong n +pp p add 12 mul i 4 add 1000 i +end +end +ret 0 +end + +fn cpinfo st edit ulong 64 p edit uchar PN o ulong to ulong +m = pg p 0 +if not need st 14408 and issub st o le m 200 +ret 86 +end +for i ulong m +q = add 8 mul i 72 +d = pg p q +if ne pg p add q 4 0 +bad st +ret 86 +end +r = ulong 0 +v = mul d 65536 +if eq d 68451 +v = 351272960 +end +if and flt st 105 eq d 4242 +r = 1 +v = 0 +end +if and flt st 106 eq i 0 +pp p q add d 1 +end +pp p add q 8 r +pq p add q 16 v +end +ret 0 +end + +fn cdisp st edit ulong 64 p edit uchar PN o ulong c ulong to ulong +if eq c 517 +ret c517 st p o +end +if eq c 8389266 +ret cclass st p o +end +if eq c 545259792 +ret cname st p o +end +if eq c 545259850 +ret cgid st p o +end +if eq c 545260819 +ret ctherm st p o +end +if eq c 545264387 +ret cfb st p o +end +if eq c 545267862 +ret cutil st p o +end +if eq c 545259917 +ret cpids st p o +end +if eq c 545259918 +ret cpinfo st p o +end +bad st +ret 86 +end + +note NV_ESC_RM_CONTROL: NVOS54 hClient 0, hObject 4, cmd 8, status 28. +fn fkctl st edit ulong 64 h edit uchar HN p edit uchar PN to long +if not want st 10 32 get st 4 +ret neg long 22 +end +if ne hg h 0 get st 16 +bad st +ret neg long 22 +end +o = hg h 4 +if eq slot st o 0 +bad st +hp h 28 86 +ret 0 +end +put st 12 add get st 12 1 +hp h 28 cdisp st p o hg h 8 +ret 0 +end + +fn fkioctl st edit ulong 64 h edit uchar HN p edit uchar PN to long +nr = get st 2 +if eq nr 200 +ret fkcard st h +end +if eq nr 201 +ret fkreg st h +end +if eq nr 43 +ret fkalloc st h p +end +if eq nr 41 +ret fkfree st h +end +if eq nr 42 +ret fkctl st h p +end +bad st +ret neg long 22 +end + +fn nvml_fake st edit ulong 64 h edit uchar HN p edit uchar PN to ulong +k = get st 0 +r = neg long 22 +if eq k 1 +r = fkioctl st h p +end +if eq k 2 +r = fkopen st p +end +if eq k 3 +r = fkclose st +end +if or lt k 1 gt k 3 +bad st +end +if lt r 0 +put st 6 sub 18446744073709551615 ulong sub neg r 1 +else +put st 6 ulong r +end +ret 0 +end diff --git a/tests/nvml/run.sh b/tests/nvml/run.sh new file mode 100755 index 00000000..3b443423 --- /dev/null +++ b/tests/nvml/run.sh @@ -0,0 +1,167 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# CUDA++ NVML host tier: the libnvidia-ml C ABI subset in compat/nvml against the resource-manager +# fake tests/nvml/rmfake.om, plus an ABI comparison with the CUDA toolkit's nvml.h, the thin-shell +# guard, checker negative controls and mutants of the Omega sources. +# Device-free: tests/nvml/transport.c replaces the #281 omega2_nvrm_* transport with the fake; nothing +# opens /dev/nvidia*. libnvidia-ml is never linked. +# Usage: tests/nvml/run.sh (needs OMEGA_OMC, the omega-mv e5b32567 pin, and OMEGA_BRIDGE) +set -u +omc=${OMEGA_OMC:-} +br=${OMEGA_BRIDGE:-} +if [ -z "$omc" ] || [ ! -x "$omc" ] || [ -z "$br" ] || [ ! -f "$br/tools/bridge-seeded" ]; then + echo 'NOT_RUN: set OMEGA_OMC (omega-mv e5b32567 omc) and OMEGA_BRIDGE (omega-bridge checkout)' >&2 + exit 77 +fi +pin=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f +got=$(sha256sum < "$omc" | cut -c1-64) || exit 74 +if [ "$got" != "$pin" ]; then + echo "REFUSED: omc digest $got is not the omega-mv e5b32567 pin" >&2 + exit 69 +fi +root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) || exit 74 +# The frontend pin is read from om/units.sh, the one place it is recorded, so a bridge repin cannot leave +# this copy stale (it still named an older bridge-seeded, 23ff7a23, after om/units.sh moved to a3a455bd). +fpin=$(sed -n 's/^FRONTEND_PIN=\([0-9a-f]\{64\}\)$/\1/p' "$root/om/units.sh") +[ "${#fpin}" -eq 64 ] || { echo "REFUSED: no FRONTEND_PIN in om/units.sh" >&2; exit 74; } +got=$(sha256sum < "$br/tools/bridge-seeded" | cut -c1-64) || exit 74 +if [ "$got" != "$fpin" ]; then + echo "REFUSED: bridge-seeded digest $got is not the om/units.sh frontend pin" >&2 + exit 69 +fi +t=$root/tests/nvml +nv=$root/native/nvml +out=$(mktemp -d "${TMPDIR:-/tmp}/cudapp-nvml.XXXXXX") || exit 74 +trap 'rm -rf "$out"' EXIT +CC=${CC:-cc} +CFLAGS="-std=gnu11 -O1 -Wall -Wextra -Werror" +fails=0 +fail() { echo "FAIL: $*" >&2; fails=$((fails + 1)); } +bridge() { OMEGA_SEEDED_OMC="$omc" sh "$br/tools/bridge-seeded" "$@"; } + +# Composes a unit exactly as om/units.sh does: each part followed by one newline. +compose() { # dir out + : > "$2" + for f in nvml query step; do cat "$1/$f.om" >> "$2" && printf '\n' >> "$2" || return 1; done +} + +compose "$nv" "$out/nvml_step.om" || exit 74 +{ cat "$nv/errstr.om"; printf '\n'; } > "$out/nvml_errstr.om" +for u in nvml_step nvml_errstr; do + bridge c "$out/$u.om" > "$out/$u.c" 2> "$out/$u.log" || { cat "$out/$u.log" >&2; fail "$u did not bridge"; } + if cmp -s "$out/$u.c" "$root/src/cudapp_om_$u.c"; then + echo "PASS committed src/cudapp_om_$u.c is the bridge output of native/nvml" + else + fail "src/cudapp_om_$u.c is stale; rerun om/units.sh" + fi + bridge h "$out/$u.om" > "$out/$u.h" 2>/dev/null + if grep -qxF -f "$out/$u.h" "$root/src/cudapp_native.h"; then :; else fail "src/cudapp_native.h lacks the $u prototype"; fi +done +bridge c "$t/rmfake.om" > "$out/fake.c" 2> "$out/fake.log" || { cat "$out/fake.log" >&2; fail 'rmfake.om did not bridge'; exit 1; } + +link() { # step.c errstr.c exe + $CC $CFLAGS -I"$root/src" -I"$root/compat/nvml" -I"$t" "$root/compat/nvml/cudapp_nvml.c" "$1" "$2" \ + "$out/fake.c" "$t/transport.c" "$t/nvml_test.c" -lpthread -o "$3" +} +link "$root/src/cudapp_om_nvml_step.c" "$root/src/cudapp_om_nvml_errstr.c" "$out/nvml_test" \ + || { fail 'host test did not build'; exit 1; } +"$out/nvml_test" "$t/errstr-oracle.tsv" > "$out/test.out" 2>&1; rc=$? +last=$(tail -n 1 "$out/test.out") +case "$rc:$last" in + 0:'CUDAPP-NVML HOST PASS ('*' checks)') echo "PASS fake tier: $last" ;; + *) cat "$out/test.out" >&2; fail "fake tier rc=$rc: $last" ;; +esac + +# Checker negative control: an oracle with one altered string must fail. +sed '2s/ .*/ Successful/' "$t/errstr-oracle.tsv" > "$out/bad.tsv" +if cmp -s "$out/bad.tsv" "$t/errstr-oracle.tsv"; then + fail 'oracle negative control: the edit changed nothing' +elif "$out/nvml_test" "$out/bad.tsv" > "$out/bad.out" 2>&1; then + fail 'oracle negative control: altered oracle passed' +else + echo "PASS oracle negative control (altered string rejected: $(tail -n 1 "$out/bad.out"))" +fi + +# ABI: compat/nvml/nvml.h must describe the same sizes, offsets and values as NVIDIA's header, and the +# shell must compile against NVIDIA's prototypes. Header only; nothing NVIDIA is linked. +cuda=${CUDA_NVML_INCLUDE:-/usr/local/cuda/include} +if [ -f "$cuda/nvml.h" ]; then + $CC $CFLAGS -I"$root/compat/nvml" "$t/abi.c" -o "$out/abi-ours" && "$out/abi-ours" > "$out/abi-ours.txt" \ + && $CC $CFLAGS -I"$cuda" "$t/abi.c" -o "$out/abi-cuda" && "$out/abi-cuda" > "$out/abi-cuda.txt" || fail 'abi probe did not build' + if [ -s "$out/abi-ours.txt" ] && cmp -s "$out/abi-ours.txt" "$out/abi-cuda.txt"; then + echo "PASS abi: $(wc -l < "$out/abi-ours.txt") facts equal to $cuda/nvml.h" + else + diff "$out/abi-ours.txt" "$out/abi-cuda.txt" >&2; fail 'abi differs from the CUDA nvml.h' + fi + if $CC $CFLAGS -c -I"$cuda" -I"$root/src" "$root/compat/nvml/cudapp_nvml.c" -o "$out/shell-cuda.o"; then + echo 'PASS shell compiles against the CUDA nvml.h prototypes' + else + fail 'shell does not compile against the CUDA nvml.h prototypes' + fi +else + echo "NOT_RUN abi comparison ($cuda/nvml.h absent; set CUDA_NVML_INCLUDE)" +fi + +# Thin shell: the C reaches the OS only through omega2_nvrm_* and makes no decisions about RM replies. +thin() { + awk '/^[ \t]*(\/\*|\*)/ { next } + /[^_a-z](open|ioctl|close|mmap|read|write)\(|\/dev\/|NV0|NV2080|0x2080/ { print FILENAME ":" NR ": " $0; bad = 1 } + END { exit bad }' "$1" +} +if thin "$root/compat/nvml/cudapp_nvml.c"; then echo 'PASS thin-shell guard'; else fail 'shell holds OS calls or RM knowledge'; fi +printf 'static int x(void) { return ioctl(3, 0x20800110); }\n' > "$out/fat.c" +if thin "$out/fat.c" > /dev/null; then fail 'thin-shell guard negative control passed'; else echo 'PASS thin-shell guard negative control'; fi + +# Mutants: each edits one line that must occur exactly once in its file, and must be caught. +# file|search|replacement +mutants=' +nvml|if eq v 86|if eq v 87 +nvml|if eq v 27|if eq v 28 +nvml|if or or eq x 18446744073709551614 eq x 18446744073709551610 eq x 18446744073709551597|if false +nvml|put b n uchar add 48 rem minor 10|put b n uchar add 49 rem minor 10 +nvml|if gt get s 16 0|if false +nvml|if gt get s 16 1|if false +nvml|for t ulong 26|for t ulong 2 +nvml|if eq g32 b add add PO 4 mul i 4 52928|if eq g32 b add add PO 4 mul i 4 52929 +query|if ge get s 1 get s 21|if gt get s 1 get s 21 +query|put b add OO 3 45|put b add OO 3 46 +query|put b n 45|put b n 95 +query|if eq g32 b add add add PO 24 mul tg 44 16 1|if eq g32 b add add add PO 24 mul tg 44 16 2 +query|if ge v 2147483648|if false +query|if ne g32 b add PO 8 0|if false +query|p64 b add OO 16 mul sub t f 1024|p64 b add OO 16 mul t 1024 +query|o = add add PO 16 mul rem add r 71 72 776|o = add add PO 16 mul rem r 72 776 +query|p32 b OO div g 100|p32 b OO g +query|p64 b add q 8 18446744073709551615|p64 b add q 8 0 +query|p32 b add q 16 4294967295|p32 b add q 16 0 +query|if or gt c 72 ge r 72|if false +query|if gt f t|if false +errstr|n = w8 o n 32496501618079059|n = w8 o n 32496501618079058 +' +mk=0; caught=0 +printf '%s\n' "$mutants" | { while IFS='|' read -r file from to; do + [ -n "$file" ] || continue + mk=$((mk + 1)) + n=$(grep -cxF "$from" "$nv/$file.om") + if [ "$n" != 1 ]; then echo "FAIL: mutant site '$from' found $n times in $file.om" >&2; continue; fi + rm -rf "$out/m" && mkdir "$out/m" && cp "$nv"/*.om "$out/m/" || exit 74 + awk -v f="$from" -v r="$to" '$0 == f { print r; next } { print }' "$nv/$file.om" > "$out/m/$file.om" + compose "$out/m" "$out/m/step.u.om" && { cat "$out/m/errstr.om"; printf '\n'; } > "$out/m/errstr.u.om" + if ! bridge c "$out/m/step.u.om" > "$out/m/step.c" 2>/dev/null || ! bridge c "$out/m/errstr.u.om" > "$out/m/errstr.c" 2>/dev/null \ + || ! link "$out/m/step.c" "$out/m/errstr.c" "$out/m/t" 2>/dev/null; then + echo "FAIL: mutant '$from' did not build; it proves nothing" >&2; continue + fi + if "$out/m/t" "$t/errstr-oracle.tsv" > "$out/m/out" 2>&1; then + echo "FAIL: mutant survived: $file: $from -> $to" >&2 + else + caught=$((caught + 1)); echo " mutant $file '$from': caught ($(tail -n 1 "$out/m/out"))" + fi +done +echo "mutants caught $caught/$mk" +[ "$caught" -eq "$mk" ]; } || fail 'mutants' + +if [ "$fails" -ne 0 ]; then + echo "CUDAPP-NVML HOST FAIL ($fails)" + exit 1 +fi +echo 'CUDAPP-NVML HOST PASS' diff --git a/tests/nvml/transport.c b/tests/nvml/transport.c new file mode 100644 index 00000000..258f10d4 --- /dev/null +++ b/tests/nvml/transport.c @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* Test transport for the CUDA++ NVML shell: the three omega2_nvrm_* entry points of + * native/nvrm/transport.om (aien-dev/CUDApp#281), answered by the Omega RM fake + * tests/nvml/rmfake.om instead of /dev/nvidia*. Each call copies the request into the fake's + * views, runs one omega_nvml_fake step and copies the reply back. No device file is opened. */ +#include +#include + +#include "transport.h" + +enum { FAKE_HN = 4608, FAKE_PN = 55888 }; + +uint32_t omega_nvml_fake(uint64_t *result, void *p0, uint64_t p0_n, void *p1, uint64_t p1_n, + void *p2, uint64_t p2_n); + +static uint64_t fake_st[64]; +static uint8_t fake_h[FAKE_HN]; +static uint8_t fake_p[FAKE_PN]; +static uint64_t fake_traps; + +void fake_reset(int fault) { + memset(fake_st, 0, sizeof fake_st); + fake_st[5] = (uint64_t)(unsigned char)fault; + fake_traps = 0; +} + +uint64_t fake_get(unsigned i) { return i < 64 ? fake_st[i] : UINT64_MAX; } + +uint64_t fake_trapped(void) { return fake_traps; } + +/* One fake step; a trap or refusal counts as a violation and reads as transport status 1. */ +static uint32_t fake_step(uint64_t *result) { + uint64_t r = 1; + if (omega_nvml_fake(&r, fake_st, 64, fake_h, FAKE_HN, fake_p, FAKE_PN) != 0 || r != 0) { + fake_traps++; + fake_st[13]++; + return 1; + } + *result = fake_st[6]; + return 0; +} + +uint32_t omega2_nvrm_open_file(uint64_t *result, const uint8_t *o_path, uint64_t o_path_len) { + if (o_path_len == 0 || o_path_len > FAKE_PN) return 32; + memcpy(fake_p, o_path, o_path_len); + fake_st[0] = 2; + fake_st[7] = o_path_len; + return fake_step(result); +} + +uint32_t omega2_nvrm_close_file(uint64_t *result, uint64_t o_fd) { + fake_st[0] = 3; + fake_st[1] = o_fd; + return fake_step(result); +} + +uint32_t omega2_nvrm_ioctl(uint64_t *result, uint64_t o_fd, uint64_t o_nr, uint8_t *o_h, + uint64_t o_h_len, uint8_t *o_p, uint64_t o_p_len) { + if (o_h_len > FAKE_HN || o_p_len > FAKE_PN) return 32; + /* Fault S: the transport itself refuses the GPU name control (omega2 status 1). */ + if (fake_st[5] == 'S' && o_nr == 42 && o_h_len >= 12) { + uint32_t cmd; + memcpy(&cmd, o_h + 8, 4); + if (cmd == 0x20800110u) return 1; + } + memcpy(fake_h, o_h, o_h_len); + memcpy(fake_p, o_p, o_p_len); + fake_st[0] = 1; + fake_st[1] = o_fd; + fake_st[2] = o_nr; + fake_st[3] = o_h_len; + fake_st[4] = o_p_len; + uint32_t st = fake_step(result); + memcpy(o_h, fake_h, o_h_len); + memcpy(o_p, fake_p, o_p_len); + return st; +} diff --git a/tests/nvml/transport.h b/tests/nvml/transport.h new file mode 100644 index 00000000..3ba9adc6 --- /dev/null +++ b/tests/nvml/transport.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* Control surface of the test transport (tests/nvml/transport.c). fake_get indexes the + * tests/nvml/rmfake.om state: 8 opens, 9 closes, 10 allocs, 11 frees, 12 controls, + * 13 violations, 14 open-fd mask, 15 live objects, 16 root handle. */ +#ifndef CUDAPP_NVML_TEST_TRANSPORT_H +#define CUDAPP_NVML_TEST_TRANSPORT_H + +#include + +void fake_reset(int fault); +uint64_t fake_get(unsigned i); +uint64_t fake_trapped(void); + +#endif diff --git a/tools/extract/.crumb b/tools/extract/.crumb index 5dbaf6b6..36185f0b 100644 --- a/tools/extract/.crumb +++ b/tools/extract/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-11-05T17:26:33Z", + "compiled_at": "2026-11-06T20:46:08Z", "compiler": "crumb-compile/1", - "digest": "sha256:465bf113f5d6a567341bfc033c682346c4f4507749bbd5cf17ec1be0c12485bc", + "digest": "sha256:44628d1109b41188a09f6ef5fd65519c607395d851bcd7abd1e6e601e5cf8724", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 30, - "generated_at_commit": "afc6ff5af097c67bbf9b337b153c11a47b599276", - "source_tree": "sha256:e1df5a9540d67fab3dea33f76b0a0c25718b277a2fa0fb4fde2a3aa3794a7541" + "generated_at_commit": "fb7f885f2dbbdb336ae53a69eb4889648dcd9c8c", + "source_tree": "sha256:756500954d0ed9311f6cc61298f20d6fe4a4c357d1346680f403c56fa064b9fe" } }, "name": "extract", diff --git a/tools/extract/drift-baseline.tsv b/tools/extract/drift-baseline.tsv index 5ad90ea4..9b887893 100644 --- a/tools/extract/drift-baseline.tsv +++ b/tools/extract/drift-baseline.tsv @@ -30,11 +30,12 @@ # The nine rows below that CUDApp#266 synced byte-equal from omega d3d1b1bc7e3b are that commit's blobs (src/omega_blackwell_codegen.h, src/omega_path_check.h, src/runtime/rx_costmodel.{c,h}, tests/bw_warp_sim{,_k,_pa}.h, tests/runtime/rx_costmodel_unit.c, tests/test_omega_gpu_decode_attn_maxpos.c). # CUDA++ differs only in the SPDX line (Apache-2.0 WITH LLVM-exception, #263); any later omega edit to them must still fail. # mk/omega-gpu-engine.mk is omega 37fa50340345's blob (omega-mv #966). #966 swaps omega's freestanding C SHA-256 (src/omega_sha256_fs.c, test-sha256-fs-parity) for the bridge's freestanding Omega binding (src/omega_om_units_fs.c, test-sha256-freestanding-parity). CUDA++ never carried that C path: its GPU_FS_SRCS link src/sha256.c beside CUDAPP_FS_BINDING from its own om/units.sh at bridge 3dc4a00e, so the delta is not ported here; adopting the Omega SHA-256 binding needs that bridge pin moved. Any later omega edit to the file must still fail. +# docs/runtime/PORTABILITY.md and docs/runtime/portability_table.tsv are omega a64e6705's blobs (omega-mv #596: rows for the trainer's bf16 GEMM). CUDA++'s table already carries those four tgemm rows and its own Ampere-inclusive totals, so the blobs differ on purpose; any later omega edit to them must still fail. Makefile 7e1426b3be2281979d00ac550a9397f913a38c30 docs/runtime/API.md 9f5f34321bfb3f8623623ca9a174b68e3ff3c3ed -docs/runtime/PORTABILITY.md 7b923a91e12f7f2e5c5954d80293517e19e8c959 +docs/runtime/PORTABILITY.md fb0d5f0ff5278a662934f79027aa5f398d9a4abe docs/runtime/omega_runtime_api.manifest d02c0ebe0b6df7d4d8f52b51942dccd76cc8ec2d -docs/runtime/portability_table.tsv 7d927220d172fafa6135fbb9069683c5a3030119 +docs/runtime/portability_table.tsv 798227e5bcf362a92cd303bc817b15a89738935d evidence/C3-GEMM/01-host-only.log c581c5126718bc24ef10ed1b1637528018a260e5 evidence/C3-GEMM/02-sim.log fd97da9f29871abfc16fb2ed938c38a4d3c2314f evidence/C3-GEMM/README.md 0e730a9bf2072f34d59d9cdc1961f4112a7ff90e ```