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/226754d23bdbc1c9 # 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 ## Make the portable host suite run from a fresh x86-64 checkout merged `226754d23bdbc1c9` #192 · opened 2026-10-30 12:14 UTC · closed 2026-10-30 14:40 UTC · merged 2026-10-30 14:40 UTC Imported from GitHub aien-dev/CUDApp#192, by drakestapleton Base `b4f0480799a52b7c96a36de674f9f6d401775ea0` · Head `ba53e3bd1f9380cb63b60935a0365194b8b1c20b` Merged on GitHub as `522ee0d063cbc93672091a0edd00a0866634b981`; reachable from main `21d8de285f713adf09e0d6ba6db2b37139d0674e` (observed 2026-11-18T16:38:26Z) drakestapleton wrote on 2026-10-30 12:14 UTC ## Purpose and scope A fresh x86-64 checkout could not build the host suite. `src/omega_blackwell_engine.c` emitted unguarded `dsb sy`, and `tests/omega/run.sh` assumed a sibling compiler at `$HOME/workspace/omega-osc-cubin`. `make test` is now the portable suite on x86-64 and on AArch64. It needs no NVIDIA tool and no sibling checkout. Target-only checks name their requirement and exit 2. Production AArch64 ordering stays `dsb sy`. Refs #15. This pull request does not close the issue. What landed: - `nvrm/cpu_barrier.h`. AArch64 executes `dsb sy`. Any other host executes `__atomic_thread_fence(__ATOMIC_SEQ_CST)`. `nvrm_cpu_relax` is `yield` on AArch64 and a compiler barrier elsewhere. The publication barrier is a real fence on both hosts. - Production Blackwell open, and the direct vector and matmul entries, return `ENOTSUP` and the text `requires AArch64 Linux` on a non-AArch64 host. They do not call the driver. A translation unit built with `OMEGA_BLACKWELL_HOST_SIMULATOR` keeps the simulator path. Simulator and mutation builds set that macro. The x86-64 architecture-guard binary does not. On AArch64, `make test-omega-arch-guard` prints `NOT_RUN` and does not build that binary. - On a non-AArch64 host the library links `src/cudapp_binding_portable.c` and compiles the C encoder and the C cubin writer (`CUDAPP_MIGRATION_PENDING_C_ENCODER`, `CUDAPP_MIGRATION_PENDING_C_CUBIN`). `src/cudapp_om_units.c` and `src/cudapp_freest_units.c` are unchanged and are not assembled. `omega_native_revision` and `omega_native_epoch` follow the freestanding units. Every other seeded entry returns status 34 and does not write its result. That path is how the portable suite produces instruction words and cubin images. It is a run of the C bodies. It is not a run of `bw_enc_sm121.om` or `cubin_elf.om`, and it is not a pass of the `.om` versus C differential. - On x86-64 these targets exit 2 and are outside `make test`: `test-om-encoder`, `test-om-cubin`, `test-gpu-native-runtime`, `test-om-spec-encoder`, `test-portable-receipts`, `test-model-capacity`. `make test-omega-target-only` prints the same lines and exits 0. That exit is the report. On AArch64 those six targets stay inside `make test`. - The OSC compiler is `OMEGA_OSC_COMPILER_DIR` or the directory argument of `tests/omega/run.sh`. There is no `$HOME` default. The checkout must be clean and must be source commit `1accb93164ce68a2ac2e2c680acf54782f260d62`. Missing compiler, missing slice, and a wrong pin each print a specific diagnostic. `make test-omega-slices` is outside `make test`. - On x86-64, GNU make's built-in `CC=cc` is replaced with gcc when `CC` was not set. An explicit `CC=` still wins. On AArch64, `CC ?= gcc` leaves make's built-in `CC=cc` in place. - The freestanding x86-64 build converts fp32 to fp16 with `omega_fp32_to_fp16_rne`, so the link does not call libgcc `__truncsfhf2`. AArch64 keeps the hardware cast. Docs that separate the portable commands from the target-only ones: `docs/OMEGA_HOST_TESTS.md`, `README.md`, `AGENTS.md`, `docs/START_HERE.md`, `CONTRIBUTING.md`, `AUDIT_SCOPE.md`. The seeded `.om` replacement of this shell runner remains #52. This pull request does not do that migration, and it does not include the CI work tracked by #90. Open pull request #170 also edits barrier call sites and several of these makefiles for an Ampere port. This branch does not take that port. Expect conflicts in `nvrm/nvrm.c`, `m16/`, and the makefiles if both land. ## ADR 0043 Decision 0 Shared-file edits are build and portability guards. `aarch64-linux-gnu-gcc` 13.3.0 cross-compiled each edited C file from this tree and from main `78fea51d6f8859ec8cc5e5561295fd5583b92c19` with the production flags and without `CUDAPP_PORTABLE_DEFS` or `OMEGA_BLACKWELL_HOST_SIMULATOR`. Every object in `evidence/HOST-X86-20261030/aarch64-objects.tsv` is byte-identical. GB10 runs stay NOT RUN. Commit `1b2ca5c` does not edit those C files. With `uname -m` forced to `aarch64`, `CC` stays `cc`, the portable defs stay empty, and the binding sources stay the two generated units. Each new C file links the filed Omega extension proposal: - `nvrm/cpu_barrier.h`: https://github.com/aien-dev/omega-mv/issues/939 (`evidence/HOST-X86-20261030/proposal-cpu-barrier.md`) - `src/cudapp_binding_portable.c`: https://github.com/aien-dev/omega-mv/issues/940 (`evidence/HOST-X86-20261030/proposal-binding-portable.md`) Main `b4f0480` (#194) is merged here. `drift` on `ba53e3b` passed: `DRIFT-GATE: PASS (754 GPU paths, omega 62d1d0d668f8, none moved away from CUDA++ since the baseline)` (https://github.com/aien-dev/CUDApp/actions/runs/`41070699255` ). ## Evidence on the exact commit Code commit `0d8084b26d6183ebac8f12861801aae733a4b67c`. Receipt commit `00950065b48062ae48b8e890b7f3ad5215d184d2`. ADR and drift note `c96fc6010d6d2540e8dc10caf74723edaf1c2508`. AArch64 arch-guard compile fix `1b2ca5c7be163f6c5b3aa7375d096089058f845c`. Filed-issue links `6235ac1cd27edd34777aa156e8f94c462c878101`. After that comment-only edit, the same AArch64 cross compile kept every hash in `evidence/HOST-X86-20261030/aarch64-objects.tsv`. Merge of main `b4f0480` is `7e6abe3`. Head `ba53e3bd1f9380cb63b60935a0365194b8b1c20b`. x86-64 `CUDAPP_MEM_RESERVE_MIB=0 make CC=gcc -j4 test` exited 0: `CUDA++ HOST TESTS PASS (57 targets)`, including `test-gpu-imadhi-rc` and `test-dagsim`. AArch64 CI `host-tests` ended `CUDA++ HOST TESTS PASS (62 targets)` (https://github.com/aien-dev/CUDApp/actions/runs/`41070699078` ). Linux 6.12.94+ x86_64, gcc 13.3.0, 4 cores. Receipt: `evidence/HOST-X86-20261030/`. `/dev/nvidia*` and `/dev/aien-gpu` were absent. No GPU device was opened. - `make test` (host-only). `CUDAPP_MEM_RESERVE_MIB=0 make CC=gcc -j4 test` exited 0. Last line: `CUDA++ HOST TESTS PASS (55 targets)`. The same command with the default reserve exited 2 on this VM: the serving test refused a 741.9 MiB upload because 4.6 GiB was free and the runtime keeps 4.0 GiB free (`CUDAPP_MEM_RESERVE_MIB=4096`). The default was not changed. After the merge of main the same command exited 0 with `CUDA++ HOST TESTS PASS (57 targets)`. - `make test-native-artifact` (host-only). Inside that suite: `test_gpu_artifact_export: 47 checks, 0 failed`. - `make zero-cuda-gate` exited 0. The CUDA probe is rejected. `build/hello_gpu` needs `libm` and `libc`. `build/gpu_matmul_api_test` needs `libc`. - `build/hello_gpu --sim` exited 0 and printed `PASS`. The suite's wrapper printed `hello --sim tests: 12 passed, 0 failed`. The program's existing ceiling sentence names a GB10 bandwidth figure; this run did not measure it. - `make doctor` exited 1 and printed `NOT READY: 5 problems above`. The kernel module, the three device nodes, and the PCI GPU are absent. That is the expected report. The doctor checks nodes with `access` and did not open one. Its seeded target-table row is `NOT_RUN` (pinned `omc` absent). - GB10 hardware tests. NOT RUN. This VM has no GB10 and no NVIDIA device node. `make hello-gpu` was not run. Also inside the passing suite: engine simulator `SUMMARY passed=334 failed=0`; matmul bounds `SUMMARY passed=6 failed=0`; backend mutants `120 total, 107 killed, 13 survived as redundant, 0 survived as test gaps`; `barrier-contract: PASS` including `aarch64-linux-gnu-gcc cross compile emits dsb sy`; `binding-portable: PASS`; `omega-runner-test: PASS (missing harness, missing slice, wrong source pin)`; Blackwell open `ENOTSUP` and the fake driver was not entered. `make test-om-encoder` alone exited 2 with the AArch64 `NOT_RUN` line. `make test-omega-slices` with no harness exited 2 and named the pin. `make test-omega-target-only` exited 0 after printing the refusals. After `1b2ca5c`, `make CC=gcc test-omega-arch-guard` on this VM still exits 0 and prints the two `ENOTSUP` lines. Host cross checks, labeled as such in the receipt, and not GB10 results: - qemu-aarch64 8.2.2 executed `src/cudapp_freest_units.c` (cross compiled with `aarch64-linux-gnu-gcc` 13.3.0). revision(0)=1, revision(1)=2, revision(UINT64_MAX)=0, epoch(0)=1, epoch(3)=4, epoch(UINT64_MAX)=UINT64_MAX, null or misaligned returns 32. - `omega_fp32_to_fp16_rne` matched gcc's `_Float16` cast on `4294967296` inputs, 0 mismatches. CI `host-tests` on `ba53e3b` (https://github.com/aien-dev/CUDApp/actions/runs/`41070699078` ) is the native AArch64 `make test`. It exited 0. Last line: `CUDA++ HOST TESTS PASS (62 targets)`. The count is 62 because AArch64 keeps the six target-only rows inside `make test`, plus `test-gpu-imadhi-rc` and `test-dagsim`. The x86-64 VM suite is 57. That run does not open a GPU. ## Correctness, compatibility and provenance - Negative controls are in the suite: an unguarded `dsb sy` fixture must fail; a missing harness, a missing `launch.osc`, and a wrong source pin must fail; the architecture guard requires `ENOTSUP` and zero driver calls; the portable binding's other entries return 34 and leave the result unchanged. - Public runtime headers, `docs/runtime/omega_runtime_api.manifest`, and `docs/runtime/API.md` are unchanged. The AArch64 library still links the generated units and still executes `dsb sy`. On x86-64, production Blackwell open returns `ENOTSUP` where the previous tree failed to assemble. A host or simulator pass is not a chip qualification. - New source files are Apache-2.0 WITH LLVM-exception. `tests/omega/run.sh` keeps its existing Apache-2.0 header. No NVIDIA binary, cubin, PTX, firmware, or vendor listing was added. - No secrets, personal machine paths, or private addresses. The old receipt path under a home directory was not copied. - Receipts outside `evidence/HOST-X86-20261030/` were not edited. That receipt records the filed issue URLs and the repeated object hashes. ## Known limitations - GB10 device behavior is NOT RUN / hardware-unverified. The AArch64 object match is a cross compile. CI `host-tests` does not open a GPU. - The eight-slice gate is NOT RUN. `gh api repos/aien-dev/omega-osc-cubin` returned HTTP 404. Source pin `1accb93164ce68a2ac2e2c680acf54782f260d62` was not checked out. The historical AArch64 binary SHA-256 `a007283780347dd4a4b024844dc0c81fc09e0926f27f83e50c07d42508886f23` was not re-measured. - The six seeded-binding and pinned-`omc` targets were not executed on the x86-64 VM. Their x86-64 result is exit 2. On AArch64 they stay inside `make test`, and CI `host-tests` is that run. - Passing `make test` on this VM required `CUDAPP_MEM_RESERVE_MIB=0`. A machine with enough free memory still uses the default 4096 MiB reserve. - `drift` is green on this head after the merge of #194. GB10 device behavior stays NOT RUN. drakestapleton reviewed (COMMENTED) on 2026-10-30 12:15 UTC Triage at head `0095006`: needs-changes. The idea is sound and the evidence is honestly labelled. Before merge, the red drift check and the overlap with #170 need answers. State. Open, not a draft, base `main` (not stacked), mergeable but `unstable`. Checks: `drift` failed, and `host-tests`, `runtime-api`, one `build` and CodeQL c-cpp/python were still running. Everything else is green. drift. The job log for run `41053836447` shows `DRIFT-GATE: FAIL (7 of 739 GPU paths changed in omega 089e5b05350e and not in CUDA++)`. Of those paths only `Makefile` is touched here. The rest (`src/omega_blackwell_codegen.h`, `tests/bw_warp_sim*.h`, `tests/gpu_imadhi_rc_test.c`) are not. `drift` passed on main at `78fea51` at 06:45 CT, so this may be upstream omega movement, not this diff. Please re-run, or show that main fails the same way, before treating it as unrelated. Overlap with #170 (`3b6ca6f`, held under ADR 0043/0044). 14 files: `Makefile`, `README.md`, `m16/m16_concurrent.c`, `m16/m16_native.c`, `mk/om-cubin.mk`, `mk/om-encoder.mk`, `mk/omega-gpu-engine.mk`, `nvrm/nvrm.c`, `src/omega_blackwell_engine.c`, `src/omega_blackwell_matmul.c`, `src/omega_blackwell_submit.c`, `src/omega_gpu_elementwise_api.c`, `src/omega_gpu_platform_linux.c`, `tools/gpu_engine_backend_mutations.sh`. The PR body already warns about this. Since #170 must be reworked under ADR 0044 anyway, landing #192 first looks like the lower-cost order. That is the maintainers' call. ADR 0043 Decision 0 (aien-architecture-mv `docs/adr/0043-gpu-stack-portable-top-thin-backend.md`). This is not P2–P4 backend work: no new backend, ABI or `backend//`. It is build portability of the existing C stack, so I don't read it as gated code. It is not a "host-only experiment that touches no shared file" either: it edits shared driver and engine files (`nvrm/nvrm.c`, `m16/*`, `src/omega_blackwell_{engine,submit,matmul}.c`, `src/omega_gpu_platform_linux.c`). It also adds new C (`nvrm/cpu_barrier.h`, `src/cudapp_binding_portable.c`, 221 lines). The ADR's language rule asks that "any new C needs a missing-feature reason with an extension proposal filed, behind a `migration-pending` build switch." The `CUDAPP_MIGRATION_PENDING_C_*` switches are there. Please add the missing-feature reason and the extension-proposal reference for `cudapp_binding_portable.c` and `cpu_barrier.h`, and have an architecture owner confirm that Decision 0 doesn't apply. ADR 0044. `src/omega_cubin.c` and `om/cubin/cubin_elf.om` are not modified. The x86-64 path only compiles the frozen C writer behind `CUDAPP_MIGRATION_PENDING_C_CUBIN`. That is consistent, and the body is clear that this is not a `cubin_elf.om` run or an `.om`↔C differential. GPU claims. None are unsupported. GB10, native AArch64 and the eight-slice gate are all marked NOT RUN, and `dsb sy` is evidenced only by an aarch64 cross-compile. One caveat: `make test` passed only with `CUDAPP_MEM_RESERVE_MIB=0`, and with the default reserve it exits 2 (`evidence/HOST-X86-20261030/default-reserve.txt`). So "`make test` is now the portable suite" holds only on hosts with more than about 4.7 GiB free. Please state that in `docs/OMEGA_HOST_TESTS.md`. To reach ready: drift green or shown pre-existing on main, pending checks green, the new-C reason and proposal reference added, and the reserve caveat documented. — Grokbot drakestapleton wrote on 2026-10-30 12:17 UTC Architecture's ruling on ADR 0043: ADR 0043 Decision 0 applies. OK before the gate only if the shared-file edits change nothing on GB10 (aarch64 build/receipts unchanged at head) and both new C files carry a missing-feature reason, a filed extension proposal and migration-pending. Otherwise split. (Architecture) The frozen imported C stack in ADR 0043's Consequences includes `nvrm/`, `m16/` and the `omega_blackwell_{engine,submit}` bypasses. So every edit to `Makefile`, `mk/*`, `nvrm/nvrm.c`, `m16/*`, `src/omega_blackwell_{engine,submit,matmul}.c` and `omega_gpu_platform_linux.c` must be a build or portability guard, with an unchanged aarch64 build, or re-run GB10 gate receipts, at head to prove it. If that can't be shown, split out the x86-64 host-suite parts that touch no shared file, and land the rest after the gate. — Grokbot cursor[bot] wrote on 2026-10-30 12:24 UTC Review answers are on `c96fc6010d6d2540e8dc10caf74723edaf1c2508`. Drift. The seven paths fail the same way on CUDA++ main `78fea51d6f8859ec8cc5e5561295fd5583b92c19`. `tools/extract/drift.sh` against omega-mv `089e5b05350ee61cc1439f17d3d3052a18a3e0a5` exits 1 on both trees and prints the same seven omega blobs (`evidence/HOST-X86-20261030/drift-main-and-pr.txt`). Main's green run `41050251136` used omega `4c60d6baf5f1`, where `Makefile` was still the baseline blob `4e068c1de5026d2ac4f6c2463fbb4292e6c26ec0`. Omega commit `089e5b05350e` (2026-10-30T12:10:11Z, "Warp simulators refuse IMAD.HI.U32 with a register Rc") changed `Makefile`, `src/omega_blackwell_codegen.h`, the four `tests/bw_warp_sim*.h` files, and added `tests/gpu_imadhi_rc_test.c`. This branch does not touch those six sources. Main's `Makefile` blob `c1c714d3` and this branch's `ee85035` both differ from omega's new blob `a42b2b1f`, so the Makefile row is upstream too. `drift` will stay red until CUDA++ holds those bytes. This pull request does not import them. ADR 0043. `nvrm/cpu_barrier.h` and `src/cudapp_binding_portable.c` each state the missing-feature reason and say the extension proposal is drafted, not yet filed on omega-mv. Drafts: `evidence/HOST-X86-20261030/proposal-cpu-barrier.md` and `evidence/HOST-X86-20261030/proposal-binding-portable.md`. The `CUDAPP_MIGRATION_PENDING_C_ENCODER` and `CUDAPP_MIGRATION_PENDING_C_CUBIN` switches stay. The binding file refuses to compile without one of those or `BINDING_PORTABLE`. AArch64 objects. `aarch64-linux-gnu-gcc` 13.3.0 compiled the shared C files from this tree and from main `78fea51`. Every object is byte-identical (`evidence/HOST-X86-20261030/aarch64-objects.tsv`): `nvrm.o`, `m16_native.o`, `m16_concurrent.o`, `lifecycle_gates.o`, `submission_visibility_gates.o`, `omega_blackwell_engine.o`, `omega_blackwell_submit.o`, `omega_blackwell_matmul.o`, freestanding `matmul_fs.o`, `omega_gpu_platform_linux.o`, `omega_gpu_elementwise_api.o`. With `uname -m` forced to `aarch64`, `CC` stays `cc` on this tree and on main. GB10 device runs stay NOT RUN. Reserve. `docs/OMEGA_HOST_TESTS.md`, `README.md`, and the receipt now say this VM's `make test` passes only with `CUDAPP_MEM_RESERVE_MIB=0` and exits 2 at the default 4096. The default is unchanged. — Grokbot cursor[bot] wrote on 2026-10-30 12:48 UTC AArch64 `make test` on `c96fc60` stopped in `tests/test_omega_blackwell_arch_guard.c`. `refuse_ok` is only called off AArch64, and `-Werror=unused-function` failed the compile (run https://github.com/aien-dev/CUDApp/actions/runs/`41055132444` ). `1b2ca5c` keeps that helper under `#if !defined(__aarch64__)`. On AArch64, `test-omega-arch-guard` prints `NOT_RUN` and does not build the binary. On this x86-64 VM, `make CC=gcc test-omega-arch-guard` still prints the `ENOTSUP` lines and exits 0. `aarch64-linux-gnu-gcc -Wall -Wextra -Werror -c` of that test file exits 0. A `make -n` with `uname -m` forced to `aarch64` shows only the shell script. That Makefile edit is the test target only. With `uname -m` forced to `aarch64`, `CC` stays `cc`, `CUDAPP_PORTABLE_DEFS` stays empty, and the binding sources stay `src/cudapp_om_units.c` and `src/cudapp_freest_units.c`. The shared objects in `evidence/HOST-X86-20261030/aarch64-objects.tsv` stay byte-identical to main `78fea51`; those C files were not edited in `1b2ca5c`. GB10 stays NOT RUN. `drift` remains the upstream failure against omega `089e5b05350e` (the same seven paths as main). This commit changes the CUDA++ Makefile blob to `13ca78007340e4e01741f5a280fa1c176637dbda`, which still does not equal omega's blob `a42b2b1f4cd7ffb683d1f54cadbceebde45d5e15`, so that row stays red for the same reason. — Grokbot drakestapleton reviewed (COMMENTED) on 2026-10-30 13:10 UTC Re-check at head `1b2ca5c`: needs-changes (one item left). Everything else from my review at `0095006` is resolved. CI. 14 of 15 checks are green: host-tests, runtime-api, both builds, library, sim, hello-sim, om-units, sbom, audit-scanner and CodeQL. `drift` is red. That failure is upstream: main `78fea51` re-ran at 08:00 CT and also failed, with the same 7 paths against omega `089e5b05350e` (Makefile, `src/omega_blackwell_codegen.h`, `tests/bw_warp_sim{,_k,_pa,_tc}.h`, `tests/gpu_imadhi_rc_test.c`). This PR's run `41058056845` prints the same lines. So it doesn't block this PR, but it has to be fixed on main. #170 overlap. Still 14 files, the same list as before. Architecture's Decision 0 conditions (the ruling quoted in the 12:17Z comment): - (a) aarch64 unchanged: met, by cross-compile. `evidence/HOST-X86-20261030/aarch64-objects.tsv:2-12` lists 11 shared objects (`nvrm.o`, `m16_*.o`, `omega_blackwell_{engine,submit,matmul}.o`, `matmul_fs.o`, `omega_gpu_platform_linux.o`, `omega_gpu_elementwise_api.o`, both gate objects). Each is IDENTICAL by sha256 to main `78fea51`. This is `aarch64-linux-gnu-gcc` on x86-64, not a native AArch64 build or a GB10 receipt. The `1b2ca5c` change (`tests/test_omega_blackwell_arch_guard.c` under `#if !defined(__aarch64__)`) is test-only. - (b) New C files. - `nvrm/cpu_barrier.h`: the missing-feature reason is at L12-14. The draft proposal note is at L18-19 (`proposal-cpu-barrier.md`). The migration-pending switch is named at L15-17. The non-AArch64 body is selected by `#if defined(__aarch64__)` at L23. The header itself has no switch guard, and on AArch64 it is the production `dsb sy` path, which is fine because the objects are identical. - `src/cudapp_binding_portable.c`: the reason is at L7-9, the switches at L9-12, and the draft proposal note at L12-14. An `#error` at L30-31 stops the build unless `CUDAPP_MIGRATION_PENDING_C_ENCODER`, `_C_CUBIN` or `BINDING_PORTABLE` is defined. Remaining item. Architecture's ruling asks for a filed extension proposal. Both files say "drafted, not yet filed on omega-mv", and the drafts are in `evidence/` (`proposal-cpu-barrier.md:17`). Either file the two proposals on omega-mv and replace the evidence-path pointers with the issue links, or get Architecture to accept a drafted-not-filed note. Once that's done, I'd rank this ready-to-merge. ADR 0044. `src/omega_cubin.c` and `om/cubin/cubin_elf.om` are still untouched. GPU claims. GB10 and native AArch64 `make test` are still NOT RUN, and the PR labels them that way. The reserve caveat is now in `docs/OMEGA_HOST_TESTS.md` and `README.md`. — Grokbot cursor[bot] wrote on 2026-10-30 13:12 UTC CI on `1b2ca5c`: `host-tests` passed. Run https://github.com/aien-dev/CUDApp/actions/runs/`41058056753` finished in 14m48s. Last line: `CUDA++ HOST TESTS PASS (60 targets)`. The count is 60 because AArch64 keeps the six target-only rows inside `make test`. The x86-64 VM suite stays 55. The arch-guard line was `x86-64 production refusal: NOT_RUN (this host is aarch64; the check runs on x86-64 Linux and does not open a device)`, and the log shows `sh tests/omega/test-arch-guard.sh` with no compile of that binary. `drift` is still red: https://github.com/aien-dev/CUDApp/actions/runs/`41058056845` . `DRIFT-GATE: FAIL (7 of 739 GPU paths changed in omega 089e5b05350e and not in CUDA++)`. The seven omega blobs are the same ones that fail on main `78fea51`. Every other check on this head passed. GB10 stays NOT RUN. — Grokbot drakestapleton reviewed (COMMENTED) on 2026-10-30 13:37 UTC Re-check at `6235ac1` (expected head, confirmed): ready-to-merge. The only red check is drift, which comes from upstream and is tracked in #193. What changed since `1b2ca5c7`. One commit touching 5 files, all comments and docs: - In both new C files, the "drafted, not yet filed" line is now a link to the filed issue. The line count is unchanged. - The two proposal notes now say "Filed as …". - The evidence README gained a "Filed extension proposals" section (+9 lines). There is no code change. The filed proposals exist. - aien-dev/omega-mv#939, an open issue: "Seed a host CPU publication barrier: `dsb sy` on AArch64, a real fence elsewhere". - aien-dev/omega-mv#940, an open issue: "Emit a host-assembleable native binding, or keep a migration-pending portable stand-in". Both were filed today. Neither is a PR. ADR 0043 Decision 0, per Architecture's ruling: met. - (a) aarch64 unchanged. `evidence/HOST-X86-20261030/aarch64-objects.tsv` is not touched in this commit. The README's new section, L13 of the added hunk, records a re-run of the aarch64-linux-gnu-gcc 13.3.0 cross build: all 11 objects keep their SHA-256. The edits replace comment lines one for one, so no line numbers move. This is a cross-compile from an x86 host. Native AArch64 and GB10 are NOT_RUN, and nothing ran on the Spark. - (b) `nvrm/cpu_barrier.h`: - Reason: L12-14. - Switches: L14-17 (migration-pending, `CUDAPP_MIGRATION_PENDING_C_ENCODER` / `_C_CUBIN`). - Filed link: L18 (omega-mv#939), with the drafted text kept at L19. - The `__aarch64__` split is at L23. As before, the switches are applied to the callers' compilation, not inside the header. - (b) `src/cudapp_binding_portable.c`: - Reason: L7-9. - Switches: L9-12. - Filed link: L13 (omega-mv#940), with the drafted text at L14. - `#error` guard: L30-31. The item from my last re-check, proposals filed rather than only drafted, is now resolved. CI. 14 of 15 checks are green: build ×2, library, host-tests, om-units, sim, hello-sim, runtime-api, sbom, audit-scanner, and CodeQL with Analyze for actions, python and c-cpp. The one failure is `drift`. Drift, reported separately and not counted against #192. - This head's drift job (`124083255422`) reports `DRIFT-GATE: FAIL (7 of 739 GPU paths changed in omega 62d1d0d668f8)`. - Main `78fea51`'s drift job at 08:00 CT (`124075795636`) fails against the same omega revision on the identical 7 paths, with identical blob SHAs: `Makefile`, `src/omega_blackwell_codegen.h`, `tests/bw_warp_sim{,_k,_pa,_tc}.h`, and `tests/gpu_imadhi_rc_test.c` (omega-only). - The only difference is the denominator, 739 vs 730, because this PR adds GPU-scoped paths. None of them drift. - #193 exists, but it is an open issue tracking this upstream drift, not a fix PR. Drift stays red on main until that work lands. Still true. `src/omega_cubin.c` is untouched (ADR 0044). The 14-file overlap with #170 means one of the two will need a rebase after the other merges. — Grokbot cursor[bot] wrote on 2026-10-30 14:36 UTC Merged main `b4f0480` (#194) into this branch with a merge commit. No rebase. Head is `ba53e3bd1f9380cb63b60935a0365194b8b1c20b`. `HOST_TESTS` keeps both lists: this branch's portable omega targets and main's `test-gpu-imadhi-rc` and `test-dagsim`, then the x86 `CUDAPP_TARGET_ONLY_TESTS` filter. `test-gpu-imadhi-rc` stays in the x86-64 suite. On this VM, `CUDAPP_MEM_RESERVE_MIB=0 make CC=gcc -j4 test` exited 0 and ended `CUDA++ HOST TESTS PASS (57 targets)`. The four simulators each printed PASS for Rc=RZ, the encode, and the Rc=R6 refusal. `test-dagsim` printed `dagsim_unit: 171 checks, 0 failed`. Neither opens a device. GB10 stays NOT RUN. `drift` passed: https://github.com/aien-dev/CUDApp/actions/runs/`41070699255` `DRIFT-GATE: PASS (754 GPU paths, omega 62d1d0d668f8, none moved away from CUDA++ since the baseline)` `host-tests` passed: https://github.com/aien-dev/CUDApp/actions/runs/`41070699078` `CUDA++ HOST TESTS PASS (62 targets)` The count is 62 on AArch64 because the six target-only rows stay inside `make test`. The log also has `PASS bw_warp_sim.h` and `dagsim_unit: 171 checks, 0 failed`. — Grokbot drakestapleton reviewed (COMMENTED) on 2026-10-30 14:39 UTC Re-review at `ba53e3bd1f9380cb63b60935a0365194b8b1c20b`. Classification: ready-to-merge. History. Merge `7e6abe3` has parents `6235ac1` (the previously reviewed head) and `b4f0480` (main, #194). All 5 earlier branch commits are still in the history, so there was no force-push. Beyond the merge, #192 adds 2 commits, `5d186bb` and `ba53e3b`. `7e6abe3...ba53e3b` touches only `mk/omega-gpu-engine.mk` (+7) and `docs/OMEGA_HOST_TESTS.md` (+10). GitHub reports mergeable_state `clean`. Checks at head (15/15 success). - drift: run `41070699255` - ci run `41070699078`: host-tests, om-units, sbom, audit-scanner - CodeQL: run `41070691805` (c-cpp, python, actions), "No new alerts" - hello-sim: `41070699119` - library: `41070699710` - sim: `41070699392` - build: `41070699165` and `41070699231` - runtime-api: `41070699216` HOST_TESTS (`Makefile:418-431`). Both sets of names are kept: this branch's `test-omega-slice-runner test-omega-arch-guard test-omega-barrier-contract test-omega-binding-portable` and main's `test-gpu-imadhi-rc test-dagsim`. After them, the `filter-out $(CUDAPP_TARGET_ONLY_TESTS)` runs, and only when that list is non-empty (x86). `test-gpu-imadhi-rc` and `test-dagsim` are not in `CUDAPP_TARGET_ONLY_TESTS` (`Makefile:40`), so they stay portable. Evidence: CI host-tests is native AArch64 only. The x86-64 pass (57 targets, dagsim 171 checks) is the author's VM receipt, and no CI job runs on x86. New rule (`mk/omega-gpu-engine.mk:147-152`). It adds `$(CUDAPP_PORTABLE_DEFS)` when compiling `cudapp_binding_portable.o`. That object is in `GPU_FS_OBJS` only through `CUDAPP_FS_BINDING`: - x86: `CUDAPP_FS_BINDING` = `src/cudapp_binding_portable.c` (`Makefile:37`). - AArch64: it is `src/cudapp_freest_units.c` (`Makefile:52`) and `CUDAPP_PORTABLE_DEFS` is empty (`Makefile:54`). On AArch64 the new rule is never reached, and the freestanding units link unchanged. The new commits don't touch the GB10/sm_121 path or any C source, so ADR 0043 Decision 0 (a) still holds. Note that CI never builds the x86 freestanding link (host-tests is AArch64), so this fix is exercised only on the author's VM. GPU claims. GB10 is NOT_RUN. The AArch64 object match is cross-compile evidence and CI host-tests opens no device. The IMAD.HI "PASS for all four warp simulators" result is a host simulator run, not on-hardware evidence. Merge. Nothing blocks the merge. #194 is already in via `b4f0480`. #195 should rebase after this and update its gcc/CC lines. — Grokbot ### Fetch it A git bundle of the pull request's head, 47596 bytes. ``` curl -fsSL https://interplane.io/drakestapleton/CUDApp/patches/226754d23bdbc1c9.bundle -o 226754d23bdbc1c9.bundle git fetch 226754d23bdbc1c9.bundle refs/pull/192/head ``` Raw bundle · 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 192 ba53e3bd1f9380cb63b60935a0365194b8b1c20b ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"CUDApp","number":192,"url":"https://github.com/aien-dev/CUDApp/pull/192","export_sha256":"0aafd51b77ff5776d6baaf9b88b48c8b36a6e27c8d829ae8ded561b71712b17a","imported_utc":"2026-11-18T16:38:26Z"} ``` ### Changes ``` diff --git a/AGENTS.md b/AGENTS.md index 244f0dc7..479c406e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -37,19 +37,22 @@ Needs Linux, `git`, `make` and `gcc` (the `Makefile` uses `CC ?= gcc` and builds Host commands (no GPU opened): ```bash -make test # every host-only check: about 7 minutes +make test # portable host suite, x86-64 and AArch64: about 7 minutes make test-native-artifact # offline native artifact export test make zero-cuda-gate # the built programs need no CUDA library (self-test first) make doctor # is this machine ready? reads /proc, /sys and /dev only build/hello_gpu --sim # the first kernel on the host warp simulator +make test-omega-slices # eight OSC slices; needs OMEGA_OSC_COMPILER_DIR; not part of make test python3 tools/figures/make_figures.py --check # README figures match the code python3 tools/figures/test_stack_legend.py -v # rendered legend check; needs Inkscape ``` +- `docs/OMEGA_HOST_TESTS.md` separates portable commands from target-only ones. `make test` needs no NVIDIA tool and no sibling checkout. On x86-64 the production Blackwell open returns `ENOTSUP` and names AArch64, and the seeded AArch64 binding is not assembled: the C encoder and C cubin writer are the portable bodies, and `make test-om-encoder`, `make test-om-cubin`, `make test-gpu-native-runtime`, `make test-om-spec-encoder`, `make test-portable-receipts` and `make test-model-capacity` exit 2. AArch64 keeps `dsb sy` and keeps those rows in `make test`. `make test-omega-arch-guard` prints `NOT_RUN` on AArch64 and does not build the binary. + - Judge `make test` by its exit code and its last line, `CUDA++ HOST TESTS PASS ( targets)`, where `` is computed from the current `HOST_TESTS` manifest in `Makefile`. The log contains many `FAIL` and `ERROR` lines by design (mutation tests and negative controls that must fail). Do not grep the log for them. - `make test` already runs the host-only `test-gpu-*` targets listed in `HOST_TESTS` in the `Makefile`. Run those through `make test`, not by hand. - `make zero-cuda-gate` reads ELF metadata only (`tools/zero-cuda-gate.sh`). -- `test-portable-receipts` is included in `make test`. It needs full Git history plus the pinned `OMEGA_OMC` and `OMEGA_BRIDGE` used by `test-om-units`. The `.om` checker verifies original and scrubbed-payload SHA-256, exact HOME-substitution reversal, original Git-blob identity, and independent refusal controls. The TSV separately pins each complete derived file. These are portable derivatives, never rewritten original receipts or qualification authority. +- `test-portable-receipts` is included in `make test` on AArch64. It needs full Git history plus the pinned `OMEGA_OMC` and `OMEGA_BRIDGE` used by `test-om-units`. On x86-64 it is outside `make test` and exits 2: the pinned compiler is not part of the portable suite. The `.om` checker verifies original and scrubbed-payload SHA-256, exact HOME-substitution reversal, original Git-blob identity, and independent refusal controls. The TSV separately pins each complete derived file. These are portable derivatives, never rewritten original receipts or qualification authority. - `python3 tools/figures/make_figures.py --check` must print `figures current: `. Regenerate figures only when you change the data they are drawn from, and commit the regenerated SVGs with that change. GPU commands (need a GB10; do not run from an agent session unless the maintainer has given you a GPU window on the DGX Spark): diff --git a/AUDIT_SCOPE.md b/AUDIT_SCOPE.md index 0dd8fd45..fb7a043e 100644 --- a/AUDIT_SCOPE.md +++ b/AUDIT_SCOPE.md @@ -89,7 +89,7 @@ make -j8 ``` Build variables: `CC`, `OUT_DIR` (default `build`), `PHYSICS_DIR` (default `.`). The host build -needs no GPU. Fresh x86-64 portability is tracked in issue #15 (`docs/START_HERE.md`). +needs no GPU. On x86-64, `make test` is the portable suite: it uses the C encoder and C cubin writer and does not assemble the seeded AArch64 binding. Target-only commands are in `docs/OMEGA_HOST_TESTS.md` (issue #15). ## Run every test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 425c869b..5c17f0f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ A failing test means the work is wrong. Find the cause; do not skip the test, lo ## What you need -For a host-only start, use Linux with `git`, `make`, a C compiler and the build tools described in [START_HERE.md](docs/START_HERE.md). The documented, fully qualified native GPU path is Linux on the GB10 (DGX Spark, sm_121) with NVIDIA's 580.173.02 kernel module. The CUDA toolkit is not needed for the normal runtime or host tests. A fresh x86-64 host checkout is not yet a validated target for the entire suite (see [#15](https://github.com/aien-dev/CUDApp/issues/15)). +For a host-only start, use Linux with `git`, `make`, a C compiler and the build tools described in [START_HERE.md](docs/START_HERE.md). The documented, fully qualified native GPU path is Linux on the GB10 (DGX Spark, sm_121) with NVIDIA's 580.173.02 kernel module. The CUDA toolkit is not needed for the normal runtime or host tests. A fresh x86-64 checkout runs the portable host suite (`make test`) with gcc, no NVIDIA tools and no sibling checkout. Target-only checks name their requirement (`docs/OMEGA_HOST_TESTS.md`, [#15](https://github.com/aien-dev/CUDApp/issues/15)). The GB10 device path and the eight-slice OSC gate stay outside that suite. ```sh git clone https://github.com/aien-dev/CUDApp.git diff --git a/Makefile b/Makefile index 050e736b..ee8af9cd 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,46 @@ # this repository, so PHYSICS_DIR is "." here. Omega is meant to build the same sources # with PHYSICS_DIR pointing at a pinned CUDA++ checkout (cudapp.lock); that pin does not # exist yet and Omega main still takes nvrm/m16 from physics-mv (#106, #107). -CC ?= gcc .DEFAULT_GOAL := all PHYSICS_DIR ?= . +# The seeded bindings src/cudapp_om_units.c and src/cudapp_freest_units.c are +# AArch64 machine code. A non-AArch64 host links src/cudapp_binding_portable.c +# instead and compiles the migration-pending C encoder and C cubin writer. +# That is the portable host path. It is not a run of the seeded units. +# CUDAPP_ENCODER=diff still requires the seeded binding and is refused here. +# On AArch64, CC stays make's built-in (CC ?= gcc does not replace it), so a +# GB10 `make` invokes the same compiler it did before this portability guard. +CUDAPP_HOST_ARCH := $(shell uname -m) +ifeq ($(filter aarch64 arm64,$(CUDAPP_HOST_ARCH)),) +# GNU make defines CC as cc before this file is read, and ?= does not replace +# that built-in. The documented x86-64 compiler is gcc. An explicit CC= on the +# command line or in the environment still wins. +ifeq ($(origin CC),default) +CC := gcc +endif +CUDAPP_HOST_IS_AARCH64 := +CUDAPP_HOST_BINDING := src/cudapp_binding_portable.c +CUDAPP_HOST_FREEST_BINDING := +CUDAPP_FS_BINDING := src/cudapp_binding_portable.c +CUDAPP_BINDING_SRCS := src/cudapp_binding_portable.c +CUDAPP_PORTABLE_DEFS := -DCUDAPP_MIGRATION_PENDING_C_ENCODER -DCUDAPP_MIGRATION_PENDING_C_CUBIN +CUDAPP_TARGET_ONLY_TESTS := test-om-encoder test-om-cubin test-gpu-native-runtime test-om-spec-encoder test-portable-receipts test-model-capacity +ifeq ($(CUDAPP_ENCODER),diff) +$(error CUDAPP_ENCODER=diff executes the AArch64 seeded binding; this host is $(CUDAPP_HOST_ARCH)) +endif +$(info CUDA++ host $(CUDAPP_HOST_ARCH): seeded AArch64 binding is not assembled; C encoder and C cubin writer are the portable bodies; other seeded units refuse with status 34) +else +# Same assignment as before this branch. Make's built-in CC=cc wins, because ?= +# does not replace a variable make already defined. +CC ?= gcc +CUDAPP_HOST_IS_AARCH64 := 1 +CUDAPP_HOST_BINDING := src/cudapp_om_units.c +CUDAPP_HOST_FREEST_BINDING := src/cudapp_freest_units.c +CUDAPP_FS_BINDING := src/cudapp_freest_units.c +CUDAPP_BINDING_SRCS := src/cudapp_om_units.c src/cudapp_freest_units.c +CUDAPP_PORTABLE_DEFS := +CUDAPP_TARGET_ONLY_TESTS := +endif OUT_DIR ?= build GPU_PROD_TARGET ?= $(OUT_DIR)/libomega_gpu.a NVIDIA_OPEN := $(PHYSICS_DIR)/third_party/nvidia-open-580.173.02 @@ -42,7 +79,7 @@ endif # binding of the seeded Omega units (om/units.sh). SRCS := $(sort $(wildcard src/omega_blackwell_*.c src/omega_gpu_*.c)) \ src/omega_cubin.c src/omega_native_artifact.c src/omega_sm121_disasm.c \ - src/sha256.c src/omega_canonical.c src/omega_core.c src/omega_vector.c src/cudapp_om_units.c src/cudapp_freest_units.c \ + src/sha256.c src/omega_canonical.c src/omega_core.c src/omega_vector.c $(CUDAPP_BINDING_SRCS) \ $(PHYSICS_DIR)/m16/m16_native.c $(PHYSICS_DIR)/nvrm/nvrm.c OBJS = $(patsubst %.c,$(OUT_DIR)/%.o,$(notdir $(SRCS))) DEPS = $(OBJS:.o=.d) @@ -52,7 +89,7 @@ vpath %.c src $(PHYSICS_DIR)/m16 $(PHYSICS_DIR)/nvrm $(OUT_DIR): mkdir -p $@ $(OUT_DIR)/%.o: %.c | $(OUT_DIR) - $(CC) $(CFLAGS) $(CUDAPP_ENCODER_DEFS) -c $< -o $@ + $(CC) $(CFLAGS) $(CUDAPP_ENCODER_DEFS) $(CUDAPP_PORTABLE_DEFS) -c $< -o $@ .PHONY: all libcudapp test clean all: $(OUT_DIR)/libomega_gpu.a $(OUT_DIR)/libcudapp.a @@ -71,10 +108,13 @@ clean: ARTIFACT_EXPORT = $(OUT_DIR)/artifact-export artifact-export: $(ARTIFACT_EXPORT) ARTIFACT_TEST = $(OUT_DIR)/gpu_artifact_export_test +# These two recipes compile omega_cubin.c on the command line, which overrides the +# archive member. On a non-AArch64 host that must be the C cubin writer +# (CUDAPP_PORTABLE_DEFS). On AArch64 the variable is empty and the .om packer stays. $(ARTIFACT_EXPORT): tools/artifact_export.c src/omega_native_artifact.c src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a - $(CC) $(CFLAGS) -o $@ tools/artifact_export.c src/omega_native_artifact.c src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm + $(CC) $(CFLAGS) $(CUDAPP_PORTABLE_DEFS) -o $@ tools/artifact_export.c src/omega_native_artifact.c src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm $(ARTIFACT_TEST): tests/gpu_artifact_export_test.c src/omega_native_artifact.c src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a - $(CC) $(CFLAGS) -o $@ tests/gpu_artifact_export_test.c src/omega_native_artifact.c src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm + $(CC) $(CFLAGS) $(CUDAPP_PORTABLE_DEFS) -o $@ tests/gpu_artifact_export_test.c src/omega_native_artifact.c src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm # cubin-probe is the only target that links NVIDIA's libcuda: an interop check that NVIDIA's own loader accepts # CUDA++'s cubin. It is not in `make test`; zero-cuda-gate (in HOST_TESTS) checks hello_gpu and the API test link no CUDA. CUDA_INC ?= /usr/local/cuda/include @@ -88,8 +128,8 @@ test-native-artifact: $(ARTIFACT_EXPORT) $(ARTIFACT_TEST) ./$(ARTIFACT_TEST) $(OUT_DIR)/artifact-test # Pure artifact-format boundary: portable host test, no driver or device objects. .PHONY: test-native-artifact-manifest -$(OUT_DIR)/native_artifact_manifest_test: tests/native_artifact_manifest_test.c src/omega_native_artifact.c src/omega_cubin.c src/omega_blackwell_realize.c src/sha256.c src/cudapp_om_units.c | $(OUT_DIR) - $(CC) $(CFLAGS) -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--wrap=fopen -o $@ $^ -lpthread +$(OUT_DIR)/native_artifact_manifest_test: tests/native_artifact_manifest_test.c src/omega_native_artifact.c src/omega_cubin.c src/omega_blackwell_realize.c src/sha256.c $(CUDAPP_HOST_BINDING) | $(OUT_DIR) + $(CC) $(CFLAGS) $(CUDAPP_PORTABLE_DEFS) -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--wrap=fopen -o $@ $^ -lpthread test-native-artifact-manifest: $(OUT_DIR)/native_artifact_manifest_test ./$(OUT_DIR)/native_artifact_manifest_test .PHONY: libomega_gpu test-gpu-matmul-api @@ -341,7 +381,38 @@ test-gpu-qmd-shared-clean-build: +@set -eu; out=$$(mktemp -d); trap 'rm -rf "$$out"' EXIT; \ $(MAKE) --no-print-directory OUT_DIR="$$out/new" test-gpu-qmd-shared +# Fresh-checkout contract for issue 15. The slice runner and the barrier contract +# need no sibling compiler. The architecture guard runs on x86-64. On AArch64 +# the target prints NOT_RUN and does not build the binary, so this check never +# asks the production path to open a device. test-omega-slices is the +# eight-slice gate and is not part of `make test`. +.PHONY: test-omega-slice-runner test-omega-arch-guard test-omega-barrier-contract test-omega-binding-portable test-omega-target-only test-omega-slices +ARCH_GUARD_TEST = $(OUT_DIR)/omega_blackwell_arch_guard_test +$(ARCH_GUARD_TEST): tests/test_omega_blackwell_arch_guard.c tests/fake_m16_native.c tests/fake_m16_native.h \ + $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_wait.c | $(OUT_DIR) + $(CC) -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffunction-sections -fdata-sections \ + $(CUDAPP_PORTABLE_DEFS) -Isrc -Itests $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_omega_blackwell_arch_guard.c tests/fake_m16_native.c \ + $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_wait.c -Wl,--gc-sections -lm +ifeq ($(CUDAPP_HOST_IS_AARCH64),1) +test-omega-arch-guard: + OUT_DIR=$(OUT_DIR) sh tests/omega/test-arch-guard.sh +else +test-omega-arch-guard: $(ARCH_GUARD_TEST) + OUT_DIR=$(OUT_DIR) sh tests/omega/test-arch-guard.sh $(ARCH_GUARD_TEST) +endif +test-omega-slice-runner: + sh tests/omega/test-runner.sh +test-omega-barrier-contract: + sh tests/omega/test-barrier-contract.sh +test-omega-binding-portable: + CC=$(CC) OUT_DIR=$(OUT_DIR) sh tests/omega/test-binding-portable.sh +test-omega-target-only: + sh tests/omega/test-target-only.sh +test-omega-slices: + sh tests/omega/run.sh $(or $(OMEGA_SLICE_FUZZ),120) + # Every host-only check: no GPU, no device opened. The chip gates are listed in README.md. +# Portable commands and the AArch64-only rows are separated in docs/OMEGA_HOST_TESTS.md. HOST_TESTS = test-drift test-gpu-matmul-api test-gpu-elementwise test-gpu-reconv test-gpu-attention test-gpu-moe-window \ test-gpu-fp8 test-gpu-decode-attn test-gpu-router test-gpu-bf16-gemv test-gpu-fp8gemm test-gpu-tern-sched test-gpu-gpr-boundary \ test-gpu-cmdlist test-gpu-decode-graph test-gpu-code-alloc test-gpu-engine-compile test-gpu-engine \ @@ -351,13 +422,23 @@ HOST_TESTS = test-drift test-gpu-matmul-api test-gpu-elementwise test-gpu-reconv test-runtime-api test-runtime-portability test-doctor test-hello-sim test-native-artifact-manifest test-gemm-selectors \ test-native-artifact zero-cuda-gate verify-vendored test-swap-cli test-om-encoder test-om-spec-encoder test-om-cubin \ test-portable-receipts test-gpu-qmd-shared test-model-capacity test-gpu-qmd-shared-clean-build \ + test-omega-slice-runner test-omega-arch-guard test-omega-barrier-contract test-omega-binding-portable \ test-gpu-imadhi-rc test-dagsim $(CARRIED_HOST_TESTS) +ifneq ($(CUDAPP_TARGET_ONLY_TESTS),) +HOST_TESTS := $(filter-out $(CUDAPP_TARGET_ONLY_TESTS),$(HOST_TESTS)) test-omega-target-only +endif test: $(HOST_TESTS) @echo "CUDA++ HOST TESTS PASS ($(words $(HOST_TESTS)) targets)" .PHONY: test-model-capacity +ifeq ($(CUDAPP_HOST_IS_AARCH64),1) test-model-capacity: OMEGA_OMC="$(OMEGA_OMC)" sh tests/models/capacity.sh +else +test-model-capacity: + @echo "test-model-capacity: NOT_RUN (requires the pinned omc; not part of the portable host suite)" + @exit 2 +endif .PHONY: test-drift test-drift: @@ -365,6 +446,7 @@ test-drift: # Original Git blobs are read-only verification oracles, not a replacement receipt authority. .PHONY: test-portable-receipts +ifeq ($(CUDAPP_HOST_IS_AARCH64),1) test-portable-receipts: test-om-units tests/portable_receipts.om tests/portable_receipts.tsv om/cache/digest.om @mkdir -p build/portable_receipts cat om/cache/digest.om tests/portable_receipts.om > build/portable_receipts.source.om @@ -377,6 +459,11 @@ test-portable-receipts: test-om-units tests/portable_receipts.om tests/portable_ GIT_NO_REPLACE_OBJECTS=1 git cat-file blob "$$blob" > build/portable_receipts/original; \ ./build/portable_receipts_check build/portable_receipts/original "$$path" "$$blob"; \ done < tests/portable_receipts.tsv +else +test-portable-receipts: + @echo "test-portable-receipts: NOT_RUN (requires the pinned omc; not part of the portable host suite)" + @exit 2 +endif # The vendored NVIDIA headers match THIRD_PARTY.md's SHA256SUMS; the self-test (flipped byte, extra file) must FAIL. .PHONY: verify-vendored test-swap-cli diff --git a/README.md b/README.md index 66d02f6c..559e60a4 100644 --- a/README.md +++ b/README.md @@ -426,12 +426,25 @@ On a shared machine, hold the GPU lock your operator uses around these commands ```bash make # build/libomega_gpu.a (also as build/libcudapp.a) -make test # every host-only check: encoder goldens, simulators, refusals, mutation tests +make test # portable host suite: x86-64 and AArch64, no NVIDIA tools, no sibling checkout python3 tools/figures/make_figures.py --check # the figures on this page match the code they are drawn from make doctor # is this machine ready? one line per check, each problem with its fix; opens no device ``` -`make test` opens no device. The chip gates (`./build/gpu_*_test --out receipt.json`) need a GB10; each test's comment in the `Makefile` says how it is run. +`make test` opens no device. It is the portable suite: the same command is the +x86-64 host gate and the AArch64 host gate. On the x86-64 VM in +`evidence/HOST-X86-20261030`, that command exits 2 at the default +`CUDAPP_MEM_RESERVE_MIB` of 4096 and passes only with +`CUDAPP_MEM_RESERVE_MIB=0`. The default is unchanged. Production ordering on AArch64 +stays `dsb sy` (`nvrm/cpu_barrier.h`). On x86-64 the Blackwell device open +returns `ENOTSUP` and names AArch64; the fake-driver simulator is a separate +compile. `docs/OMEGA_HOST_TESTS.md` lists the portable commands and the +target-only ones. + +The chip gates (`./build/gpu_*_test --out receipt.json`) and `make hello-gpu` +need a GB10. `make test-omega-slices` needs `OMEGA_OSC_COMPILER_DIR` pointing +at the pinned OSC compiler checkout. None of those are inside `make test`. +Each chip test's comment in the `Makefile` says how it is run. `make test-gemm-selectors` is the focused host-only CLI regression for PFGEMM, QGEMM and FP8GEMM. Each validates `--shape` before host/simulator/chip work or diff --git a/docs/OMEGA_HOST_TESTS.md b/docs/OMEGA_HOST_TESTS.md new file mode 100644 index 00000000..dd155bae --- /dev/null +++ b/docs/OMEGA_HOST_TESTS.md @@ -0,0 +1,192 @@ +# Portable host checks and target-only commands + +`make test` is the portable host suite. It does not need a CUDA toolkit, NVIDIA +userspace tools, a GPU device node, or a sibling Omega checkout. It builds and +runs on x86-64 Linux and on AArch64 Linux. It does not open `/dev/nvidia*` or +`/dev/aien-gpu`. + +On x86-64, when you did not set `CC`, `make` uses gcc. GNU make's built-in +`CC=cc` is left alone on AArch64, so a GB10 `make` still invokes `cc`. +`make CC=clang test` still uses the compiler you named. Engine simulator +recipes that name `gcc` directly keep that compiler. + +The default `CUDAPP_MEM_RESERVE_MIB` is 4096. It is not changed. On the x86-64 +VM in `evidence/HOST-X86-20261030`, `make CC=gcc -j4 test` exits 2 at that +default and passes only with `CUDAPP_MEM_RESERVE_MIB=0`. The failing check +refuses a 741.9 MiB serving upload because 4.6 GiB is free and the runtime +keeps 4.0 GiB free. A host that cannot keep 4096 MiB free fails the same way. + +On x86-64, `make test` does not count checks that execute the seeded AArch64 +binding or the pinned `omc`. Those targets still exist. Invoking one directly +exits 2 and names the requirement. `make test-omega-target-only` prints the +same lines and exits 0; that exit is the report, not a pass of the named +checks. On AArch64 those checks stay inside `make test`. + +`test-gpu-imadhi-rc` and `test-dagsim` stay in `make test` on x86-64. They are +host programs and do not open a device. On the VM in +`evidence/HOST-X86-20261030`, after main `b4f0480` was merged, +`CUDAPP_MEM_RESERVE_MIB=0 make CC=gcc -j4 test` exited 0 and ended +`CUDA++ HOST TESTS PASS (57 targets)`. Inside that run `test-gpu-imadhi-rc` +printed PASS for `bw_warp_sim.h`, `bw_warp_sim_tc.h`, `bw_warp_sim_k.h` and +`bw_warp_sim_pa.h`. `test-dagsim` printed `dagsim_unit: 171 checks, 0 failed`. +The same `make CC=gcc test-gpu-imadhi-rc` command by itself also exited 0. +GB10 stays NOT RUN. + +Three targets in that suite are the fresh-checkout contract: + +```sh +make test-omega-slice-runner # missing compiler, missing slice, wrong pin +make test-omega-arch-guard # x86-64 production refusal +make test-omega-barrier-contract # dsb sy stays on AArch64; x86-64 keeps a real fence +make test-omega-binding-portable # revision and epoch vectors +make test-omega-target-only # names the checks this host does not run +``` + +## Memory ordering + +`nvrm/cpu_barrier.h` is the publication barrier. + +- On AArch64 the instruction is `dsb sy`. That is the GB10 host barrier. The + production backend is not rebuilt with a no-op, an empty `asm`, or a dropped + fence. +- On x86-64 the instruction is a sequentially consistent fence. The object + contains that fence. It is how the portable host suite compiles the same + sources. +- `OMEGA_BLACKWELL_HOST_SIMULATOR` is a compile definition for the fake-driver + engine tests (`test-gpu-engine-sim` and `test-gpu-engine-backend-mutants`). + It lets those tests call the backend on a non-AArch64 host. It does not + enable a real device. The production library is built without it. On x86-64 + that library's Blackwell open and the direct matmul and vector entries return + `ENOTSUP` and the text `requires AArch64 Linux`, and they do not call the + driver. + +`make test-omega-arch-guard` runs that refusal on x86-64. On AArch64 the same +target prints `NOT_RUN` and does not build the binary, because a cross +compile is not an x86-64 runtime result and the production path must not be +asked to open a device from this check. `CROSS_COMPILE_ONLY=1` records the +same `NOT_RUN` after a cross compile. + +`make test-omega-barrier-contract` rejects a raw `dsb sy` outside +`#if defined(__aarch64__)`, checks the header split, and disassembles a tiny +caller. A one-line unguarded fixture must fail. If `aarch64-linux-gnu-gcc` is +absent on an x86-64 host, the AArch64 object row prints `NOT_RUN`. The source +contract still runs. + +## Seeded binding on a non-AArch64 host + +`src/cudapp_om_units.c` and `src/cudapp_freest_units.c` are generated AArch64 +machine code (`om/units.sh`). They are not edited. A host that is not AArch64 +does not assemble them. + +That host links `src/cudapp_binding_portable.c` and compiles the C encoder and +the C cubin writer (`CUDAPP_MIGRATION_PENDING_C_ENCODER`, +`CUDAPP_MIGRATION_PENDING_C_CUBIN`). `make` says so. This is how the portable +suite produces instruction words and cubin images. It is not a run of +`bw_enc_sm121.om` or `cubin_elf.om`, and it is not a pass of the `.om` versus C +differential. + +`omega_native_revision` and `omega_native_epoch` in the portable file follow +the committed freestanding units. The vectors were taken by executing +`src/cudapp_freest_units.c` under `qemu-aarch64` 8.2.2 on an x86-64 host +(cross compile with `aarch64-linux-gnu-gcc`). That qemu run is not a GB10 +result. `make test-omega-binding-portable` checks the same vectors against +whichever file this host links. Every other seeded entry returns status 34 +(`OMEGA_BAD_RT`) and does not write its result. + +These commands exit 2 on x86-64. They run for real on AArch64 when their other +tools are present: + +```sh +make test-om-encoder +make test-om-cubin +make test-gpu-native-runtime +make test-om-spec-encoder +make test-portable-receipts +make test-model-capacity +``` + +`make test-codegen-freestanding` on x86-64 still runs the freestanding C +encoder checks. The hosted `.om` comparison prints `NOT_RUN` and is not +performed. `CUDAPP_ENCODER=diff` on x86-64 is an error: that mode executes the +seeded binding. + +## Omega slice gate + +The eight slices stay in `omega/slices/`: `doorbell.osc`, `sequencer.osc`, +`nvrm.osc`, `va.osc`, `open_plan.osc`, `kmod.osc`, `mesa.osc`, `launch.osc`. +A missing name fails before any compiler is required. + +The compiler checkout is explicit. There is no default directory. + +```sh +OMEGA_OSC_COMPILER_DIR=/path/to/omega-osc-cubin tests/omega/run.sh 120 +# or: tests/omega/run.sh 120 /path/to/omega-osc-cubin +# or: make test-omega-slices OMEGA_OSC_COMPILER_DIR=/path/to/omega-osc-cubin +``` + +`make test-omega-slices` is not part of `make test`. A fresh checkout has no +sibling compiler, so the portable suite only runs the refusal checks. + +The harness must be a clean Git checkout of source commit +`1accb93164ce68a2ac2e2c680acf54782f260d62` (the pin recorded on +`roadmap/15-reproducible-host`). The runner then uses +`build/compiler/test_osc_compiler` and builds that target when the binary is +absent. Failures: + +| Condition | Exit | Diagnostic | +|---|---|---| +| `OMEGA_OSC_COMPILER_DIR` unset and no directory argument | 2 | `compiler harness not configured` plus the required commit | +| Directory is not a Git checkout | 2 | `harness directory is not a Git checkout` | +| `HEAD` is a different commit | 2 | `wrong harness source` with expected and found revisions | +| Tracked or untracked changes | 2 | `harness checkout is modified` | +| A named slice file is absent | 1 | `missing required slice` and the path | +| Binary still absent after the build | 2 | `compiler binary still missing` | + +The 2026-10-22 receipt on that branch recorded an AArch64 binary SHA-256 of +`a007283780347dd4a4b024844dc0c81fc09e0926f27f83e50c07d42508886f23` and a +passing eight-slice run. This tree does not re-measure that binary. A run +prints the source commit and the binary SHA-256 of whatever it actually +executed. + +## What is portable, and what is not + +Portable, included in `make test`: + +```sh +make +make test +make test-omega-slice-runner +make test-omega-arch-guard +make test-omega-barrier-contract +make test-omega-binding-portable +build/hello_gpu --sim +make doctor +``` + +`make doctor` reads `/proc`, `/sys` and `/dev`. It does not open a GPU. On a +machine that is not a DGX Spark it reports the missing pieces. That report is +the result. + +Target-only, not a silent pass inside `make test`: + +```sh +make test-omega-slices # needs the pinned OSC compiler above +make test-om-encoder # AArch64; seeded encoder binding +make test-om-cubin # AArch64; seeded cubin packer +make test-gpu-native-runtime # AArch64; seeded native units +make test-om-spec-encoder # pinned omc and nvdisasm +make test-portable-receipts # pinned omc +make test-model-capacity # pinned omc +make hello-gpu # GB10, opens the NVIDIA device nodes +./build/gpu__test --out receipt.json +``` + +`make test-gpu-engine-gb10-compile` only compiles the Phase B chip source. It +does not run it. `make test-gpu-scan` compiles `src/omega_numeric.c`, whose +host reference uses AArch64 FP instructions (`mrs fpcr`, `fmadd`). On x86-64 +that compile fails in the assembler. It is not in `make test`. `make test-gpu-gemm` +is the separate GEMM host and simulator target and is also outside `make test`. + +An AArch64 host build of this tree keeps `dsb sy` in `nvrm_cpu_barrier`. A +GB10 run of the device path is a separate receipt. A host or simulator pass +does not qualify it. diff --git a/docs/START_HERE.md b/docs/START_HERE.md index d4200b5f..24ad2112 100644 --- a/docs/START_HERE.md +++ b/docs/START_HERE.md @@ -6,7 +6,7 @@ This is the shortest route for someone who has not worked on AIEN. The repositor | Path | What it establishes | Current boundary | | --- | --- | --- | -| Build and host tests | Compiles the library and checks host references, simulators, negative controls and API contracts. | Linux is the documented build environment. The full suite has previously passed on the DGX Spark host; fresh x86-64 portability remains tracked in [#15](https://github.com/aien-dev/CUDApp/issues/15). | +| Build and host tests | Compiles the library and checks host references, simulators, negative controls and API contracts. | Linux with gcc. `make test` is the portable suite on x86-64 and on AArch64. It needs no NVIDIA tool and no sibling checkout. Target-only checks name their requirement (`docs/OMEGA_HOST_TESTS.md`, [#15](https://github.com/aien-dev/CUDApp/issues/15)). | | `build/hello_gpu --sim` | Runs the example through the **host simulator** and checks its answers. | No GPU is opened; this is **not** hardware qualification or a performance result. | | `make doctor` | Reports whether the current Linux host matches the supported native GPU path. | Read-only diagnostic; a non-GB10 host is expected to report NOT READY. | | `make hello-gpu` | Runs the vector-add example on the actual GPU and checks output against the CPU. | Qualified target: NVIDIA GB10 (DGX Spark, sm_121), Linux, kernel driver 580.173.02. Requires safe, authorized GPU access. | @@ -34,7 +34,8 @@ build/hello_gpu --sim The code-allocation source scan inside `make test` expands only existing source files and refuses an empty readset, a missing/unreadable input, or any scanner error. Its negative controls also require the intended refusal diagnostic, so a setup failure cannot count as detecting forbidden allocation sizing. A clean scan is only a check of the selected source idioms, not GPU execution evidence. -`make test-gpu-native-runtime` extends the existing session-platform fixture +On x86-64, `make test-gpu-native-runtime` is outside `make test` and exits 2. +On AArch64 it extends the existing session-platform fixture with generated native Quant, Composer, encoder, residency and selector calls, then the actual FP8 cache and command-list integration. Platform handles are synthetic host fixtures, not live GPU handles. Recorded/inflight references @@ -49,7 +50,7 @@ not mistaken for error status. Paired submission has independent per-buffer QMD-publication controls: omission for either queue must refuse. No synthetic completion or handle is hardware or full-model evidence. -`make test-portable-receipts` is part of the full host suite and needs full Git +`make test-portable-receipts` is part of `make test` on AArch64 and needs full Git history, `OMEGA_OMC`, and `OMEGA_BRIDGE`. Public derived receipts substitute `$AIEN_RECEIPT_HOME` for the producer's HOME prefix. Their metadata states the original Git blob, original SHA-256, exact substitution rule, and scrubbed @@ -58,6 +59,8 @@ inserted metadata line removed; `tests/portable_receipts.tsv` also pins the complete derived-file SHA-256. The `.om` checker reconstructs original bytes from each derivative and compares both hashes and the immutable original Git blob, with refusal controls. Originals and historical commits are unchanged. +On x86-64 the same target is outside `make test` and exits 2, because the +pinned compiler is not part of the portable suite. Canonical consumer integration uses the existing single-commit `cudapp.lock`, not a second artifact or qualification registry. The isolated Omega consumer @@ -87,7 +90,7 @@ maps and receipts remain unchanged. The obsolete [consumer PR #618](https://github.com/aien-dev/omega-mv/pull/618) used an older pin and different source-check contract; it is not the canonical cutover base. -If an x86-64 checkout fails on an architecture-specific instruction, record the full error and compare with [the existing reproducibility issue #15](https://github.com/aien-dev/CUDApp/issues/15). Do not suppress the memory-ordering instruction or call a partial host run a passing full suite. +On x86-64, `make test` is the portable host suite. Production `dsb sy` stays on AArch64 (`nvrm/cpu_barrier.h`). The x86-64 publication barrier is a real sequentially consistent fence. A target-only check that names its requirement and exits 2 is not a pass of that check. The two lists are in [docs/OMEGA_HOST_TESTS.md](OMEGA_HOST_TESTS.md) ([#15](https://github.com/aien-dev/CUDApp/issues/15)). Optional: `python3 tools/figures/make_figures.py --check` verifies that README diagrams match the generator. Check it on your exact commit. diff --git a/evidence/HOST-X86-20261030/README.md b/evidence/HOST-X86-20261030/README.md new file mode 100644 index 00000000..22dbf81d --- /dev/null +++ b/evidence/HOST-X86-20261030/README.md @@ -0,0 +1,154 @@ +# x86-64 portable host suite + +On this VM, `make test` passes only with `CUDAPP_MEM_RESERVE_MIB=0` and exits 2 at the default 4096 MiB. The default was not changed. The refusing line is in [default-reserve.txt](default-reserve.txt). + +Measured 2026-10-30 on Linux 6.12.94+ x86_64, gcc 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04.1), 4 cores. +`MemTotal` was 16387280 kB. `MemAvailable` during `make doctor` was 4.8 GiB. +`/dev/nvidiactl`, `/dev/nvidia0`, `/dev/nvidia-uvm` and `/dev/aien-gpu` were absent. +No GPU device was opened. `make hello-gpu` was not run. + +`make test` and the commands in the sections below ran on the working tree recorded by +`0d8084b26d6183ebac8f12861801aae733a4b67c`. This directory was added afterwards. +It is not an input to `make`. The qemu command was then repeated with the probe +source stored here. `cmp` showed that copy identical to the source of the first run. + +## Portable suite + +`CUDAPP_MEM_RESERVE_MIB=0 make CC=gcc -j4 test` exited 0. +Last line: `CUDA++ HOST TESTS PASS (55 targets)`. +Selected lines are in [make-test-pass-lines.txt](make-test-pass-lines.txt). +The log also contains intentional `FAIL` lines from mutation tests and negative controls. +The exit code and the last line are the result. + +An earlier `make CC=gcc -j4 test` with the default reserve (4096 MiB) exited 2. +The serving allocation test refused a 741.9 MiB upload because 4.6 GiB was free and the runtime keeps 4.0 GiB free. +That line is in [default-reserve.txt](default-reserve.txt). The default was not changed. +The passing suite sets the reserve to 0 because this machine does not have the free memory the default requires. + +Inside the passing suite: + +- `omega-runner-test: PASS (missing harness, missing slice, wrong source pin)` +- `Blackwell backend refusal: ENOTSUP, requires AArch64 Linux, driver not entered` +- `direct Blackwell entry points: ENOTSUP` +- `barrier codegen: PASS (x86_64 seq_cst fence, no dsb)` +- `barrier codegen: PASS (aarch64-linux-gnu-gcc cross compile emits dsb sy)` +- `barrier-contract: PASS` +- `binding-portable: PASS` +- `hello --sim tests: 12 passed, 0 failed` +- engine simulator `SUMMARY passed=334 failed=0` +- matmul bounds `SUMMARY passed=6 failed=0` +- `test_gpu_artifact_export: 47 checks, 0 failed` +- `PASS: freestanding codegen contract (14 fixtures, 0 failing checks)` +- `mutants: 120 total, 107 killed, 13 survived as redundant, 0 survived as test gaps` +- `allowlist control: a malloc caller is refused by the nm -u check (as required)` + +`nm -u build/gpu_fs/omega_gpu_freestanding.o` on the object that suite used lists `memcmp memcpy memset strcmp strlen`. +The recipe's own line, from the build of that object in this tree, was `freestanding GPU link (15 files): only memcmp memcpy memset strcmp strlen undefined`. + +`env -u CC make -n test-omega-binding-portable` prints `CC=gcc`. GNU make's built-in `CC=cc` is replaced when `CC` was not set. + +## Separate commands + +`make zero-cuda-gate` exited 0. [zero-cuda.txt](zero-cuda.txt). +The self-test rejects a CUDA probe. `build/hello_gpu` and `build/gpu_matmul_api_test` link `libm` and `libc` only. + +`./build/hello_gpu --sim` exited 0 and printed `PASS`. [hello-sim.txt](hello-sim.txt). +That is the host warp simulator. The program's existing ceiling sentence names a GB10 bandwidth figure; this run did not measure it. + +`make doctor` exited 1 and printed `NOT READY: 5 problems above`. [doctor.txt](doctor.txt). +The kernel module is absent, the three device nodes are absent, and `/sys` shows no NVIDIA GPU. +The doctor checks device nodes with `access`. It did not open one. +The seeded target table row is `NOT_RUN` because the pinned `omc` is not on this machine. + +## Refusals + +[refusals.txt](refusals.txt): + +- `make test-om-encoder` exited 2 and printed `test-om-encoder: NOT_RUN (requires AArch64 Linux; src/cudapp_om_units.c is AArch64 machine code and was not executed)`. +- `make test-omega-slices` with no `OMEGA_OSC_COMPILER_DIR` exited 2. It named `compiler harness not configured` and source commit `1accb93164ce68a2ac2e2c680acf54782f260d62`. +- `make test-omega-target-only` exited 0 after printing the seven refusal lines. That exit is the report. It is not a pass of those checks. +- `gh api repos/aien-dev/omega-osc-cubin` returned HTTP 404. + +## Host cross checks, not GB10 results + +`aarch64-linux-gnu-gcc` 13.3.0 compiled `nvrm/cpu_barrier.h` during `make test`. +`aarch64-linux-gnu-objdump` showed `dsb sy`. That is a cross compile on this x86-64 host. + +`src/cudapp_freest_units.c` was linked by: + +```sh +aarch64-linux-gnu-gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o /tmp/rev_epoch_probe evidence/HOST-X86-20261030/rev_epoch_probe.c src/cudapp_freest_units.c +qemu-aarch64 -L /usr/aarch64-linux-gnu /tmp/rev_epoch_probe +``` + +The source file in this directory is the file that was compiled. `qemu-aarch64` is 8.2.2. +The run exited 0 and printed: + +``` +rev0 st=0 r=1 +rev1 st=0 r=2 +revmax-1 st=0 r=18446744073709551615 +revmax st=0 r=0 +revmis st=32 +revnull st=32 +ep0 st=0 r=1 +ep3 st=0 r=4 +epmax-1 st=0 r=18446744073709551615 +epmax st=0 r=18446744073709551615 +epnull st=32 +``` + +Status 0 is `OMEGA_OK`. Status 32 is `OMEGA_BAD_ARG`. This is qemu-user on x86-64, not a GB10 run. + +`omega_fp32_to_fp16_rne` was compared with gcc's `_Float16` cast for every `uint32_t` bit pattern. +The program included `src/omega_blackwell_matmul.h`, compiled with `gcc -O2 -Wall -Wextra -Werror`. +A fresh rebuild of that source was byte-identical to the binary that ran. +The run exited 0 and printed `compared 4294967296 mismatches 0 first u=00000000 got=0000 want=0000`. +That comparison is not a GB10 result. AArch64 still uses the hardware cast. + +## Drift gate, same failure on main + +`tools/extract/drift.sh /tmp/omega-mv HEAD` against omega-mv main `089e5b05350ee61cc1439f17d3d3052a18a3e0a5` ("Warp simulators refuse IMAD.HI.U32 with a register Rc, which the chip reads as a 64-bit pair (#514)", committer date 2026-10-30T12:10:11Z) exits 1 on this branch and on CUDA++ main `78fea51d6f8859ec8cc5e5561295fd5583b92c19`. Both name the same seven paths and the same omega blobs. The lines are in [drift-main-and-pr.txt](drift-main-and-pr.txt). + +That omega commit is the one that moved the seven paths. The previous omega main, `4c60d6baf5f1`, was the pin in the green main run [41050251136](https://github.com/aien-dev/CUDApp/actions/runs/41050251136) at 2026-10-30T11:45:16Z: `DRIFT-GATE: PASS (729 GPU paths, omega 4c60d6baf5f1, none moved away from CUDA++ since the baseline)`. At `4c60d6baf5f1` and at `b3dca0f1e28d`, the omega `Makefile` blob is the baseline blob `4e068c1de5026d2ac4f6c2463fbb4292e6c26ec0`. At `089e5b05350e` it is `a42b2b1f4cd7ffb683d1f54cadbceebde45d5e15`. + +CUDA++ main `Makefile` blob is `c1c714d34dc57cb251bc5e2f948b4430cb73b51e`. This branch's `Makefile` blob is `ee85035b395b6cdef53e51661fb43b5bf6bd146c`. Neither equals omega's new blob, so the Makefile row fails on main as well. This branch did not introduce it. + +The other six paths are untouched here. Their CUDA++ blobs match main, and `tests/gpu_imadhi_rc_test.c` is absent on both: + +| Path | CUDA++ main and this branch | omega `089e5b05350e` | +|---|---|---| +| `src/omega_blackwell_codegen.h` | `9dd4f62116ed66ff12c60c06e9070f5aa8ead679` | `1f0b70eecd3860da68bbe013860f27ca01da0d2f` | +| `tests/bw_warp_sim.h` | `8652710eeaed8de86375a1c9eb46b1a0d5946463` | `6d93828f3979b3a7223ebe0f1952b53e1d414764` | +| `tests/bw_warp_sim_k.h` | `2b040ed7756ddcffe716e198b266efa3c276dd54` | `993875647985cc99ce27a78003df26df91fd18e1` | +| `tests/bw_warp_sim_pa.h` | `cee1061ba9d8cf88bd80ae80295863105e2d0810` | `157e396cde9d942cc0bfff02fd057ed393c52a0a` | +| `tests/bw_warp_sim_tc.h` | `16699a135bc1c7bf3a3faffdb0116c223ad83390` | `a08e38b6a05d815448fe8b4546d204aff6f3e166` | +| `tests/gpu_imadhi_rc_test.c` | absent | `179596a27cd1c24e02ec8459a45f2e7216ca2424` | + +The path count is 739 here and 730 on main because this branch adds CUDA++ files to the map. The drift count stays 7. CI on this pull request stays red on `drift` until CUDA++ holds omega `089e5b05350e`'s bytes for those seven paths. That import is not part of this change. + +## AArch64 objects match main + +GB10 runs stay **NOT RUN**. There is no GB10 and no `/dev/aien-gpu` here. + +Method: `aarch64-linux-gnu-gcc` 13.3.0 (`Ubuntu 13.3.0-6ubuntu2~24.04.1`) compiled each shared C file from this tree and from main `78fea51d6f8859ec8cc5e5561295fd5583b92c19` (`/tmp/cudapp-main`). Production flags were `-std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2` plus the `Makefile` include path, without `CUDAPP_PORTABLE_DEFS` and without `OMEGA_BLACKWELL_HOST_SIMULATOR`. `src/omega_blackwell_matmul.c` was also compiled freestanding (`-ffreestanding -fno-builtin -fno-stack-protector -DOMEGA_GPU_NO_POSIX`). `cmp` was byte-identical for every object. SHA-256 values are in [aarch64-objects.tsv](aarch64-objects.tsv). One hash is enough per row because the two files matched. + +With `uname -m` forced to `aarch64`, `make` on this tree and on main both leave `CC` as `cc`. The production recipe adds an empty `$(CUDAPP_PORTABLE_DEFS)`. The shell collapses that extra space. The compiler arguments otherwise match main, and the objects above are the outputs. + +On x86-64, `make` with no `CC` in the environment sets `CC := gcc`. + +## Filed extension proposals + +Omega filed the two drafts: + +- Host CPU publication barrier: https://github.com/aien-dev/omega-mv/issues/939 (`nvrm/cpu_barrier.h`, [proposal-cpu-barrier.md](proposal-cpu-barrier.md)) +- Portable native binding: https://github.com/aien-dev/omega-mv/issues/940 (`src/cudapp_binding_portable.c`, [proposal-binding-portable.md](proposal-binding-portable.md)) + +After those comment links replaced the drafted-not-filed sentences, the same `aarch64-linux-gnu-gcc` 13.3.0 command was run again. All eleven objects in [aarch64-objects.tsv](aarch64-objects.tsv) kept the same SHA-256. `src/cudapp_binding_portable.c` is not in that list. The AArch64 library does not compile it. + +## NOT RUN + +- Native AArch64 `make test`. This machine is x86-64. The AArch64 barrier object above is a cross compile. +- GB10 device behavior, `make hello-gpu`, and `./build/gpu_*_test` on a chip. +- The eight-slice gate. `aien-dev/omega-osc-cubin` is not available (HTTP 404). Source pin `1accb93164ce68a2ac2e2c680acf54782f260d62` was not checked out, and the historical binary SHA-256 `a007283780347dd4a4b024844dc0c81fc09e0926f27f83e50c07d42508886f23` was not re-measured. +- `make test-om-encoder`, `make test-om-cubin`, `make test-gpu-native-runtime`, `make test-om-spec-encoder`, `make test-portable-receipts` and `make test-model-capacity` as real runs. On this host each exits 2. The lines inside `make test` are the report from `make test-omega-target-only`. diff --git a/evidence/HOST-X86-20261030/aarch64-objects.tsv b/evidence/HOST-X86-20261030/aarch64-objects.tsv new file mode 100644 index 00000000..55721003 --- /dev/null +++ b/evidence/HOST-X86-20261030/aarch64-objects.tsv @@ -0,0 +1,12 @@ +object bytes result sha256_main sha256_pr +lifecycle_gates.o 18832 IDENTICAL 592cb58ef00caf53522cfe2d37f5b0a219f062533813987c9d6fcf09cc34fcfc 592cb58ef00caf53522cfe2d37f5b0a219f062533813987c9d6fcf09cc34fcfc +m16_concurrent.o 11384 IDENTICAL a72f5e1a72c41c09031dafac19e90f6df5c3295e34c1a966dca81614b5c995c1 a72f5e1a72c41c09031dafac19e90f6df5c3295e34c1a966dca81614b5c995c1 +m16_native.o 4560 IDENTICAL 6bcba26dc64db68522fd6bbf87cc7ea6f75d45cf40b7034887bab6c8c5d7a986 6bcba26dc64db68522fd6bbf87cc7ea6f75d45cf40b7034887bab6c8c5d7a986 +matmul_fs.o 3728 IDENTICAL 7fd77f40eb686b8f80df9642f2b0aeab96fe7298a6b1ebee8602bf7afa52dbf8 7fd77f40eb686b8f80df9642f2b0aeab96fe7298a6b1ebee8602bf7afa52dbf8 +nvrm.o 29968 IDENTICAL 0e9b1c36866793fe661475ddc59730d156114c0513a15e66008ba8f466c562c8 0e9b1c36866793fe661475ddc59730d156114c0513a15e66008ba8f466c562c8 +omega_blackwell_engine.o 15224 IDENTICAL 06ebe2e2f2a0064a9ee35b3c778890209d038f033179ec49667c6ad8466ce37f 06ebe2e2f2a0064a9ee35b3c778890209d038f033179ec49667c6ad8466ce37f +omega_blackwell_matmul.o 4680 IDENTICAL d55dd4ba90a79e50f59c374ae89ccd892bfd0dadc290c62ccdf513fcccc5fe02 d55dd4ba90a79e50f59c374ae89ccd892bfd0dadc290c62ccdf513fcccc5fe02 +omega_blackwell_submit.o 17016 IDENTICAL 6c23d8c3fb6c70a4bc8c5ef64f2eecd64dd7f34e5d8144ab888fb5435a3ccf3c 6c23d8c3fb6c70a4bc8c5ef64f2eecd64dd7f34e5d8144ab888fb5435a3ccf3c +omega_gpu_elementwise_api.o 48744 IDENTICAL 818b716c4913ee54eb7d3877f3b29f6ed3eed9656eadfa9560e648e3d83d4298 818b716c4913ee54eb7d3877f3b29f6ed3eed9656eadfa9560e648e3d83d4298 +omega_gpu_platform_linux.o 22256 IDENTICAL d12f7aa921cb6fb16e8e7318e2c53c0983a4a5f0ad2baacc323610a6e3297e05 d12f7aa921cb6fb16e8e7318e2c53c0983a4a5f0ad2baacc323610a6e3297e05 +submission_visibility_gates.o 4856 IDENTICAL 2e832b4c184519ad20769c177aefec6ac7e11e66e4f675bdb3f8487bbf7b1f95 2e832b4c184519ad20769c177aefec6ac7e11e66e4f675bdb3f8487bbf7b1f95 diff --git a/evidence/HOST-X86-20261030/default-reserve.txt b/evidence/HOST-X86-20261030/default-reserve.txt new file mode 100644 index 00000000..b2e2065c --- /dev/null +++ b/evidence/HOST-X86-20261030/default-reserve.txt @@ -0,0 +1,3 @@ +808:FAIL tests/gpu_serving_alloc_count_test.c:73: upload 2560x151936 rc=-4 dma_alloc: refused 741.9 MiB: 4.6 GiB of memory is free and CUDA++ keeps 4.0 GiB free (CUDAPP_MEM_RESERVE_MIB=4096), because the CPU and GPU share it and running it out freezes the machine. Free buffers or use a smaller batch. +1129:EXIT:2 +command: make CC=gcc -j4 test diff --git a/evidence/HOST-X86-20261030/doctor.txt b/evidence/HOST-X86-20261030/doctor.txt new file mode 100644 index 00000000..4c409ff5 --- /dev/null +++ b/evidence/HOST-X86-20261030/doctor.txt @@ -0,0 +1,28 @@ +CUDA++ host x86_64: seeded AArch64 binding is not assembled; C encoder and C cubin writer are the portable bodies; other seeded units refuse with status 34 +build/cudapp-doctor; rc=$?; sh tools/multitarget/targets-doctor.sh '' build/multitarget || rc=1; exit $rc +cudapp doctor: is this machine ready for CUDA++? +Diagnostic only: direct library use has no driver-version or PCI-ID admission guard. + info system: Linux 6.12.94+ x86_64 + FAIL NVIDIA kernel module: not loaded (/proc/driver/nvidia/version does not exist) + CUDA++ uses no NVIDIA user-space software, but it talks to NVIDIA's kernel module. + Do this: sudo modprobe nvidia && sudo modprobe nvidia-uvm + If modprobe finds no module, install NVIDIA's open kernel module 580.173.02 (the open-gpu-kernel-modules release of that number), then run make doctor again. + FAIL device files: /dev/nvidiactl is missing + Do this: sudo modprobe nvidia (or run nvidia-modprobe once, which creates the device files) + FAIL device files: /dev/nvidia0 is missing + Do this: sudo modprobe nvidia (or run nvidia-modprobe once, which creates the device files) + FAIL device files: /dev/nvidia-uvm is missing + Do this: sudo modprobe nvidia-uvm (creates /dev/nvidia-uvm; CUDA++ maps GPU memory through it) + FAIL GPU: no NVIDIA GPU found in /sys/bus/pci/devices + Do this: check the GPU is seated and powered (lspci | grep -i nvidia). + info memory: 15.6 GiB system memory, 4.8 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +NOT READY: 5 problems above. Fix the first FAIL line and run make doctor again. + +GPU targets (backend/targets.om): + NOT_RUN: the target table is seeded Omega and needs the pinned omc. + Fix: make doctor OMC=/absolute/path/to/omega-mv/seed/out/omc (omega-mv 369dbc96, sha256 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f) +make: *** [mk/dx-doctor.mk:14: doctor] Error 1 + +exit 1 (make reported Error 1; NOT READY is the expected result on this machine) diff --git a/evidence/HOST-X86-20261030/drift-main-and-pr.txt b/evidence/HOST-X86-20261030/drift-main-and-pr.txt new file mode 100644 index 00000000..8d72e214 --- /dev/null +++ b/evidence/HOST-X86-20261030/drift-main-and-pr.txt @@ -0,0 +1,22 @@ +omega HEAD +089e5b05350ee61cc1439f17d3d3052a18a3e0a5 + +=== this branch === +DRIFT Makefile differs a42b2b1f4cd7ffb683d1f54cadbceebde45d5e15 +DRIFT src/omega_blackwell_codegen.h differs 1f0b70eecd3860da68bbe013860f27ca01da0d2f +DRIFT tests/bw_warp_sim.h differs 6d93828f3979b3a7223ebe0f1952b53e1d414764 +DRIFT tests/bw_warp_sim_k.h differs 993875647985cc99ce27a78003df26df91fd18e1 +DRIFT tests/bw_warp_sim_pa.h differs 157e396cde9d942cc0bfff02fd057ed393c52a0a +DRIFT tests/bw_warp_sim_tc.h differs a08e38b6a05d815448fe8b4546d204aff6f3e166 +DRIFT tests/gpu_imadhi_rc_test.c omega-only 179596a27cd1c24e02ec8459a45f2e7216ca2424 +DRIFT-GATE: FAIL (7 of 739 GPU paths changed in omega 089e5b05350e and not in CUDA++) + +=== CUDA++ main 78fea51 === +DRIFT Makefile differs a42b2b1f4cd7ffb683d1f54cadbceebde45d5e15 +DRIFT src/omega_blackwell_codegen.h differs 1f0b70eecd3860da68bbe013860f27ca01da0d2f +DRIFT tests/bw_warp_sim.h differs 6d93828f3979b3a7223ebe0f1952b53e1d414764 +DRIFT tests/bw_warp_sim_k.h differs 993875647985cc99ce27a78003df26df91fd18e1 +DRIFT tests/bw_warp_sim_pa.h differs 157e396cde9d942cc0bfff02fd057ed393c52a0a +DRIFT tests/bw_warp_sim_tc.h differs a08e38b6a05d815448fe8b4546d204aff6f3e166 +DRIFT tests/gpu_imadhi_rc_test.c omega-only 179596a27cd1c24e02ec8459a45f2e7216ca2424 +DRIFT-GATE: FAIL (7 of 730 GPU paths changed in omega 089e5b05350e and not in CUDA++) diff --git a/evidence/HOST-X86-20261030/hello-sim.txt b/evidence/HOST-X86-20261030/hello-sim.txt new file mode 100644 index 00000000..4e36ca85 --- /dev/null +++ b/evidence/HOST-X86-20261030/hello-sim.txt @@ -0,0 +1,9 @@ +hello_gpu: c = a + b over 1048576 floats on the host simulator (no GPU), built with Omega's own kernel builder +kernel built in 42 us: 32 instructions, 12 registers, no compiler run, no cache +machine code sha256 9e28bd9c46f80584d77238a752e99cecddbc8d622ffbe320885ed2f499e1f075 +checked 1048576 of 1048576 elements: 0 wrong, 0 never written +work: 12582912 bytes moved (8388608 read, 4194304 written), 1048576 floating-point operations + at the GB10's measured 195.1 GB/s read ceiling this needs at least 64.5 us +output sha256 72d0c1b2928779e83518f0b4c7d101d933cf89f210cd4627e138c33c9ce9b6a6 +PASS +EXIT:0 diff --git a/evidence/HOST-X86-20261030/make-test-pass-lines.txt b/evidence/HOST-X86-20261030/make-test-pass-lines.txt new file mode 100644 index 00000000..b82333c2 --- /dev/null +++ b/evidence/HOST-X86-20261030/make-test-pass-lines.txt @@ -0,0 +1,25 @@ +SUMMARY passed=334 failed=0 +SUMMARY passed=6 failed=0 +gpu_serving_alloc_count_test plain: PASS (0 failed checks) +allowlist control: a malloc caller is refused by the nm -u check (as required) +hello --sim tests: 12 passed, 0 failed +test_gpu_artifact_export: 47 checks, 0 failed +omega-runner-test: PASS (missing harness, missing slice, wrong source pin) +Blackwell backend refusal: ENOTSUP, requires AArch64 Linux, driver not entered +direct Blackwell entry points: ENOTSUP +barrier codegen: PASS (x86_64 seq_cst fence, no dsb) +barrier codegen: PASS (aarch64-linux-gnu-gcc cross compile emits dsb sy) +barrier-contract: PASS +binding-portable: PASS +test-om-encoder: NOT_RUN (requires AArch64 Linux; src/cudapp_om_units.c is AArch64 machine code and was not executed) +test-om-cubin: NOT_RUN (requires AArch64 Linux; the seeded cubin packer was not executed) +test-codegen-freestanding hosted comparison: NOT_RUN (requires AArch64 Linux; the .om versus C differential was not run) +test-gpu-native-runtime: NOT_RUN (requires AArch64 Linux; the seeded native units were not executed) +test-om-spec-encoder: NOT_RUN (requires the pinned omc and nvdisasm; not part of the portable host suite) +test-portable-receipts: NOT_RUN (requires the pinned omc; not part of the portable host suite) +test-model-capacity: NOT_RUN (requires the pinned omc; not part of the portable host suite) +target-only report: the lines above are refusals. make test-om-encoder and the other named targets exit 2. This report exiting 0 is not a pass of them. +test-codegen-freestanding hosted comparison: NOT_RUN (requires AArch64 Linux; the .om versus C differential was not run) +PASS: freestanding codegen contract (14 fixtures, 0 failing checks) +mutants: 120 total, 107 killed, 13 survived as redundant, 0 survived as test gaps (receipt /tmp/mutrun.CyYB0c/out.json) +CUDA++ HOST TESTS PASS (55 targets) diff --git a/evidence/HOST-X86-20261030/proposal-binding-portable.md b/evidence/HOST-X86-20261030/proposal-binding-portable.md new file mode 100644 index 00000000..f64ea6fe --- /dev/null +++ b/evidence/HOST-X86-20261030/proposal-binding-portable.md @@ -0,0 +1,13 @@ +# Title + +Emit a host-assembleable native binding, or keep a migration-pending portable stand-in + +# Body + +ADR 0043 missing feature. `src/cudapp_om_units.c` and `src/cudapp_freest_units.c` are generated AArch64 machine code. Seeded Omega does not yet emit a binding the build host can assemble. An x86-64 checkout cannot compile those two files. + +`src/cudapp_binding_portable.c` is the migration-pending C stand-in. The AArch64 library does not link it. A non-AArch64 host links it only when the build passes `CUDAPP_MIGRATION_PENDING_C_ENCODER` and `CUDAPP_MIGRATION_PENDING_C_CUBIN`, the switches that select the C encoder and the C cubin writer. The host vector test defines `BINDING_PORTABLE`. The file refuses to compile if none of those three macros is set. + +`omega_native_revision` and `omega_native_epoch` follow the committed freestanding units. Every other entry returns status 34 and does not write its result. That refusal is not a result from the seeded unit. The C encoder and the C cubin writer do the portable codegen. This is not a run of `bw_enc_sm121.om` or `cubin_elf.om`, and it is not a pass of the `.om` versus C differential. + +Filed as https://github.com/aien-dev/omega-mv/issues/940. The source comment links there. This file is the text that was drafted. diff --git a/evidence/HOST-X86-20261030/proposal-cpu-barrier.md b/evidence/HOST-X86-20261030/proposal-cpu-barrier.md new file mode 100644 index 00000000..7b2a015f --- /dev/null +++ b/evidence/HOST-X86-20261030/proposal-cpu-barrier.md @@ -0,0 +1,17 @@ +# Title + +Seed a host CPU publication barrier: `dsb sy` on AArch64, a real fence elsewhere + +# Body + +ADR 0043 missing feature. Seeded Omega has no host CPU publication barrier. + +CUDA++ needs one. On the GB10 host the production instruction is `dsb sy`. On any other host the same driver sources have to compile, and the publication barrier has to be a real sequentially consistent fence. A no-op is not that barrier. + +`nvrm/cpu_barrier.h` is the C stand-in. The AArch64 body is `dsb sy`. The other body is `__atomic_thread_fence(__ATOMIC_SEQ_CST)`. `nvrm_cpu_relax` is `yield` on AArch64 and a compiler barrier elsewhere. Callers in `nvrm/`, `m16/` and the Blackwell engine use `nvrm_cpu_barrier()`. + +The non-AArch64 fence is migration-pending C. The portable library compiles those callers with the existing switches `CUDAPP_MIGRATION_PENDING_C_ENCODER` and `CUDAPP_MIGRATION_PENDING_C_CUBIN`. + +An AArch64 cross build of the shared objects that include this header is byte-identical to CUDA++ main. That comparison is not a GB10 run. GB10 device behavior stays NOT RUN. + +Filed as https://github.com/aien-dev/omega-mv/issues/939. The header comment links there. This file is the text that was drafted. diff --git a/evidence/HOST-X86-20261030/refusals.txt b/evidence/HOST-X86-20261030/refusals.txt new file mode 100644 index 00000000..713c8aca --- /dev/null +++ b/evidence/HOST-X86-20261030/refusals.txt @@ -0,0 +1,30 @@ +=== make test-om-encoder === +CUDA++ host x86_64: seeded AArch64 binding is not assembled; C encoder and C cubin writer are the portable bodies; other seeded units refuse with status 34 +test-om-encoder: NOT_RUN (requires AArch64 Linux; src/cudapp_om_units.c is AArch64 machine code and was not executed) +make: *** [mk/om-encoder.mk:53: test-om-encoder] Error 2 +EXIT:2 + +=== make test-omega-slices === +CUDA++ host x86_64: seeded AArch64 binding is not assembled; C encoder and C cubin writer are the portable bodies; other seeded units refuse with status 34 +sh tests/omega/run.sh 120 +omega-slices: compiler harness not configured; set OMEGA_OSC_COMPILER_DIR to an Omega checkout +omega-slices: required source commit: 1accb93164ce68a2ac2e2c680acf54782f260d62 +make: *** [Makefile:401: test-omega-slices] Error 2 +EXIT:2 + +=== make test-omega-target-only === +CUDA++ host x86_64: seeded AArch64 binding is not assembled; C encoder and C cubin writer are the portable bodies; other seeded units refuse with status 34 +sh tests/omega/test-target-only.sh +test-om-encoder: NOT_RUN (requires AArch64 Linux; src/cudapp_om_units.c is AArch64 machine code and was not executed) +test-om-cubin: NOT_RUN (requires AArch64 Linux; the seeded cubin packer was not executed) +test-codegen-freestanding hosted comparison: NOT_RUN (requires AArch64 Linux; the .om versus C differential was not run) +test-gpu-native-runtime: NOT_RUN (requires AArch64 Linux; the seeded native units were not executed) +test-om-spec-encoder: NOT_RUN (requires the pinned omc and nvdisasm; not part of the portable host suite) +test-portable-receipts: NOT_RUN (requires the pinned omc; not part of the portable host suite) +test-model-capacity: NOT_RUN (requires the pinned omc; not part of the portable host suite) +target-only report: the lines above are refusals. make test-om-encoder and the other named targets exit 2. This report exiting 0 is not a pass of them. +EXIT:0 + +=== gh api repos/aien-dev/omega-osc-cubin === +{"message":"Not Found","documentation_url":"https://docs.github.com/rest/repos/repos#get-a-repository","status":"404"}gh: Not Found (HTTP 404) +EXIT:1 diff --git a/evidence/HOST-X86-20261030/rev_epoch_probe.c b/evidence/HOST-X86-20261030/rev_epoch_probe.c new file mode 100644 index 00000000..155c7fac --- /dev/null +++ b/evidence/HOST-X86-20261030/rev_epoch_probe.c @@ -0,0 +1,26 @@ +#include +#include +#include +/* declarations */ +uint32_t omega_native_revision(uint64_t *result, uint64_t o_previous); +uint32_t omega_native_epoch(uint64_t *result, uint64_t o_previous); +static void show(const char *n, uint32_t st, uint64_t r) { + printf("%s st=%u r=%" PRIu64 "\n", n, st, r); +} +int main(void) { + uint64_t r = 42; + show("rev0", omega_native_revision(&r, 0), r); + show("rev1", omega_native_revision(&r, 1), r); + show("revmax-1", omega_native_revision(&r, UINT64_MAX - 1), r); + show("revmax", omega_native_revision(&r, UINT64_MAX), r); + uint64_t *bad = (uint64_t *)(uintptr_t)1; + printf("revmis st=%u\n", omega_native_revision(bad, 0)); + printf("revnull st=%u\n", omega_native_revision(0, 0)); + r = 7; + show("ep0", omega_native_epoch(&r, 0), r); + show("ep3", omega_native_epoch(&r, 3), r); + show("epmax-1", omega_native_epoch(&r, UINT64_MAX - 1), r); + show("epmax", omega_native_epoch(&r, UINT64_MAX), r); + printf("epnull st=%u\n", omega_native_epoch(0, 0)); + return 0; +} diff --git a/evidence/HOST-X86-20261030/zero-cuda.txt b/evidence/HOST-X86-20261030/zero-cuda.txt new file mode 100644 index 00000000..bcc9d084 --- /dev/null +++ b/evidence/HOST-X86-20261030/zero-cuda.txt @@ -0,0 +1,9 @@ +CUDA++ host x86_64: seeded AArch64 binding is not assembled; C encoder and C cubin writer are the portable bodies; other seeded units refuse with status 34 +tools/zero-cuda-gate.sh --self-test +ZERO_CUDA FAIL /tmp/tmp.2cbrpKemb7/probe.so needs: libcudart.so.13 +ZERO_CUDA FAIL /tmp/tmp.2cbrpKemb7/probe.so imports: cudaMalloc +ZERO_CUDA SELF-TEST PASS (CUDA probe rejected, clean library accepted) +tools/zero-cuda-gate.sh build/hello_gpu build/gpu_matmul_api_test +ZERO_CUDA PASS build/hello_gpu needs=[libm.so.6 libc.so.6] +ZERO_CUDA PASS build/gpu_matmul_api_test needs=[libc.so.6] +EXIT:0 diff --git a/m16/m16_concurrent.c b/m16/m16_concurrent.c index a85b82dd..97349e43 100644 --- a/m16/m16_concurrent.c +++ b/m16/m16_concurrent.c @@ -41,6 +41,7 @@ * shows up as no_progress. */ #include "m16_native.h" +#include "cpu_barrier.h" #include "m16_gpu_wait.h" #include #include @@ -54,7 +55,7 @@ #define WAIT_TOTAL_MS 2000u /* hard deadline: same 2 s window as the old wait */ #define WAIT_STALL_MS 2000u /* >= hard bound so the pass window is not narrower than the old wait */ -static void fence(void) { __asm__ volatile("dsb sy" ::: "memory"); } +static void fence(void) { nvrm_cpu_barrier(); } /* Marker stream: bind class, WFI release of payload at marker_va, L2_FLUSH_DIRTY * mem-op (NVC96F_MEM_OP_A..D = 0x28..0x34, D bits 31:27 = 0x10), then a second WFI diff --git a/m16/m16_native.c b/m16/m16_native.c index eb3ee96a..08172002 100644 --- a/m16/m16_native.c +++ b/m16/m16_native.c @@ -6,6 +6,7 @@ * any closed NVIDIA userspace libraries or hardcoded addresses. */ #include "m16_native.h" +#include "cpu_barrier.h" #include #include #include @@ -72,7 +73,7 @@ int m16_native_enqueue_methods(M16NativeContext *ctx, const uint32_t *methods, s if (!ctx || !methods || count == 0) return -1; if (count > UINT32_MAX || count > ctx->pb_mem.size / sizeof(uint32_t)) return -1; memcpy(ctx->pb_mem.cpu, methods, count * sizeof(uint32_t)); - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); return nvrm_enqueue(&ctx->rm, &ctx->pb_mem, 0, (uint32_t)count); } @@ -104,7 +105,7 @@ int m16_native_wait_marker_ge(volatile uint32_t *marker, uint32_t target, uint64 while (now_ns() < end) { if ((int32_t)(*marker - target) >= 0) return 0; usleep(50); - __asm__ volatile("yield"); + nvrm_cpu_relax(); } return ((int32_t)(*marker - target) >= 0) ? 0 : -1; } diff --git a/mk/om-cubin.mk b/mk/om-cubin.mk index 6f6f62ce..c730f5a3 100644 --- a/mk/om-cubin.mk +++ b/mk/om-cubin.mk @@ -33,6 +33,7 @@ $(OM_CUBIN_DIR)/manifest_diff: tests/native_artifact_manifest_test.c src/omega_n tests/native_artifact_manifest_test.c src/omega_native_artifact.c \ src/omega_cubin.c src/omega_blackwell_realize.c src/sha256.c src/cudapp_om_units.c -lpthread +ifeq ($(CUDAPP_HOST_IS_AARCH64),1) test-om-cubin: $(ARTIFACT_TEST) $(OUT_DIR)/native_artifact_manifest_test $(OM_CUBIN_DIR)/artifact_diff \ $(OM_CUBIN_DIR)/manifest_diff $(OM_CUBIN_DIR)/sweep_diff $(OM_CUBIN_DIR)/sweep_diff_red rm -rf $(OM_CUBIN_DIR)/artifact-om $(OM_CUBIN_DIR)/artifact-diff $(OM_CUBIN_DIR)/diff.log @@ -48,6 +49,11 @@ test-om-cubin: $(ARTIFACT_TEST) $(OUT_DIR)/native_artifact_manifest_test $(OM_CU @if $(OM_CUBIN_DIR)/sweep_diff_red > /dev/null 2>&1; then \ echo "RED CHECK BROKEN: a flipped bit passed the cubin diff"; exit 1; \ else echo "red check: one flipped image bit aborts the cubin diff, as it must"; fi +else +test-om-cubin: + @echo "test-om-cubin: NOT_RUN (requires AArch64 Linux; the seeded cubin packer was not executed)" + @exit 2 +endif # Each mutant is one edit of the .om source, compiled by the pinned omc into its own binding; the sweep linked # with it (diff mode) must abort or fail. diff --git a/mk/om-encoder.mk b/mk/om-encoder.mk index a4f4cabb..325a2ce5 100644 --- a/mk/om-encoder.mk +++ b/mk/om-encoder.mk @@ -35,6 +35,7 @@ $(OM_ENC_DIR)/codegen_diff_red: $(OM_ENC_TEST_DEPS) $(OM_ENC_SRCS) src/cudapp_om $(OM_ENC_BUILD) -DCUDAPP_MIGRATION_PENDING_ENCODER_DIFF -DCUDAPP_ENCODER_DIFF_SELFTEST -o $@ \ tests/test_omega_codegen_freestanding.c $(OM_ENC_SRCS) src/cudapp_om_units.c +ifeq ($(CUDAPP_HOST_IS_AARCH64),1) test-om-encoder: $(OM_ENC_DIR)/codegen_om $(OM_ENC_DIR)/codegen_diff $(OM_ENC_DIR)/codegen_diff_red $(OM_ENC_DIR)/codegen_om --golden rm -f $(OM_ENC_DIR)/diff.log @@ -46,6 +47,11 @@ test-om-encoder: $(OM_ENC_DIR)/codegen_om $(OM_ENC_DIR)/codegen_diff $(OM_ENC_DI @if CUDAPP_ENCODER_DIFF_LOG=$(OM_ENC_DIR)/diff_red.log $(OM_ENC_DIR)/codegen_diff_red --dump > /dev/null 2>&1; then \ echo "RED CHECK BROKEN: a flipped bit passed the encoder diff"; exit 1; \ else echo "red check: one flipped bit aborts the encoder diff, as it must"; fi +else +test-om-encoder: + @echo "test-om-encoder: NOT_RUN (requires AArch64 Linux; src/cudapp_om_units.c is AArch64 machine code and was not executed)" + @exit 2 +endif test-om-encoder-corpus: $(MAKE) OUT_DIR=$(OUT_DIR) CUDAPP_ENCODER=om sm121dis-corpus-bins @@ -62,8 +68,14 @@ test-om-encoder-corpus: @echo "encoder corpus: $$(ls $(OM_ENC_DIR)/k-om/*.bin | wc -l) distinct kernels identical .om vs C; diff build $$(grep -c '^program ' $(OM_ENC_DIR)/corpus-diff.log) program encodes and $$(grep -c '^insn ' $(OM_ENC_DIR)/corpus-diff.log) single-instruction encodes, all SAME" .PHONY: test-om-spec-encoder +ifeq ($(CUDAPP_HOST_IS_AARCH64),1) test-om-spec-encoder: sh tools/test_bw_spec_encoder.sh +else +test-om-spec-encoder: + @echo "test-om-spec-encoder: NOT_RUN (requires the pinned omc and nvdisasm; not part of the portable host suite)" + @exit 2 +endif test-om-units: OMEGA_OMC="$(OMEGA_OMC)" OMEGA_BRIDGE="$(OMEGA_BRIDGE)" sh om/units.sh --check diff --git a/mk/omega-gpu-engine.mk b/mk/omega-gpu-engine.mk index 39c734fb..950b7864 100644 --- a/mk/omega-gpu-engine.mk +++ b/mk/omega-gpu-engine.mk @@ -52,24 +52,25 @@ test-gpu-engine-prod-build: # A3b2: simulated-driver host test. Links the sources of the Makefile RX_COMPOSE_GPU_SRCS list (plus the # three core files the vector builder needs) with tests/fake_m16_native.c in place of the physics -# m16_native.c and nvrm.c. Opens no device. +# m16_native.c and nvrm.c. Opens no device. OMEGA_BLACKWELL_HOST_SIMULATOR opts this +# binary into the fake driver. The production library build does not set it. GPU_ENGINE_SIM_SRCS = src/omega_blackwell_submit.c src/omega_blackwell_engine.c src/omega_gpu_engine.c \ - src/omega_blackwell_matmul.c src/omega_blackwell_codegen.c src/cudapp_om_units.c src/omega_blackwell_encoder.c \ + src/omega_blackwell_matmul.c src/omega_blackwell_codegen.c $(CUDAPP_HOST_BINDING) src/omega_blackwell_encoder.c \ src/omega_blackwell_qmd.c src/omega_blackwell_realize.c src/omega_vector.c \ src/omega_core.c src/omega_canonical.c src/sha256.c build/test_omega_blackwell_engine: tests/test_omega_blackwell_engine.c tests/fake_m16_native.c tests/fake_m16_native.h \ $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_engine.h src/omega_blackwell_engine.h @mkdir -p build - gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffunction-sections -fdata-sections \ - -Isrc -Itests $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_omega_blackwell_engine.c tests/fake_m16_native.c \ + gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -DOMEGA_BLACKWELL_HOST_SIMULATOR -pthread -ffunction-sections -fdata-sections \ + $(CUDAPP_PORTABLE_DEFS) -Isrc -Itests $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_omega_blackwell_engine.c tests/fake_m16_native.c \ $(GPU_ENGINE_SIM_SRCS) -Wl,--gc-sections -lm # The matmul wrappers' dimension and code-size refusals (they also need the fixed-deadline wait). build/test_omega_blackwell_matmul_bounds: tests/test_omega_blackwell_matmul_bounds.c tests/fake_m16_native.c \ tests/fake_m16_native.h $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_wait.c src/omega_blackwell_submit.h @mkdir -p build - gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffunction-sections -fdata-sections \ - -Isrc -Itests $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_omega_blackwell_matmul_bounds.c tests/fake_m16_native.c \ + gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -DOMEGA_BLACKWELL_HOST_SIMULATOR -pthread -ffunction-sections -fdata-sections \ + $(CUDAPP_PORTABLE_DEFS) -Isrc -Itests $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_omega_blackwell_matmul_bounds.c tests/fake_m16_native.c \ $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_wait.c -Wl,--gc-sections -lm test-gpu-engine-sim: build/test_omega_blackwell_engine build/test_omega_blackwell_matmul_bounds ./build/test_omega_blackwell_engine @@ -89,11 +90,11 @@ test-gpu-engine-gb10-compile: build/test_omega_gpu_engine_gb10.o # APIs while serving a Qwen3-4B-shaped sequence, against the simulated driver. Host only, no device. # Prints MEASURE lines; asserts only bookkeeping. Links no physics C sources, only its headers. GPU_SERVE_ALLOC_SRCS = src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c src/omega_gpu_fmt.c src/omega_gpu_matmul_api.c src/omega_gpu_attention_api.c src/omega_gpu_serving.c \ - src/omega_gpu_wait.c src/omega_blackwell_codegen.c src/cudapp_om_units.c src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c \ - src/omega_blackwell_matmul.c src/sha256.c src/cudapp_freest_units.c + src/omega_gpu_wait.c src/omega_blackwell_codegen.c $(CUDAPP_HOST_BINDING) src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c \ + src/omega_blackwell_matmul.c src/sha256.c $(CUDAPP_HOST_FREEST_BINDING) build/gpu_serving_alloc_count_test: tests/gpu_serving_alloc_count_test.c tests/fake_m16_native.c tests/fake_m16_native.h $(GPU_SERVE_ALLOC_SRCS) @mkdir -p build - gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffp-contract=off -Isrc -Itests $(GPU_ENGINE_PHYS_INC) \ + gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffp-contract=off $(CUDAPP_PORTABLE_DEFS) -Isrc -Itests $(GPU_ENGINE_PHYS_INC) \ -o $@ tests/gpu_serving_alloc_count_test.c tests/fake_m16_native.c $(GPU_SERVE_ALLOC_SRCS) -lm .PHONY: test-gpu-serving-alloc test-gpu-serving-alloc: build/gpu_serving_alloc_count_test @@ -129,7 +130,7 @@ GPU_FS_CFLAGS = -std=gnu11 -O2 -Wall -Wextra -Werror -ffreestanding -fno-builtin GPU_FS_SRCS = src/omega_gpu_engine.c src/omega_gpu_platform.c src/omega_blackwell_encoder.c src/omega_blackwell_codegen.c \ src/omega_blackwell_matmul.c src/omega_blackwell_qmd.c src/omega_blackwell_realize.c src/sha256.c \ src/omega_gpu_session.c src/omega_gpu_fmt.c src/omega_gpu_matmul_api.c src/omega_gpu_attention_api.c \ - src/omega_gpu_serving.c src/omega_gpu_wait.c src/cudapp_freest_units.c + src/omega_gpu_serving.c src/omega_gpu_wait.c $(CUDAPP_FS_BINDING) GPU_FS_HDRS = src/omega_gpu_engine.h src/omega_gpu_platform.h src/omega_blackwell_codegen.h src/omega_blackwell_matmul.h \ src/omega_gpu_session.h src/omega_gpu_fmt.h src/omega_gpu_matmul_api.h src/omega_gpu_attention_api.h \ src/omega_gpu_serving.h src/omega_gpu_wait.h @@ -141,6 +142,13 @@ $(GPU_FS_DIR)/%.o: src/%.c $(GPU_FS_HDRS) @mkdir -p $(GPU_FS_DIR) gcc $(GPU_FS_CFLAGS) -c -o $@ $< +# src/cudapp_binding_portable.c is migration-pending C. The freestanding x86-64 +# link uses it as $(CUDAPP_FS_BINDING) and must pass the same switches as the +# library. AArch64 links src/cudapp_freest_units.c, so this rule is unused there. +$(GPU_FS_DIR)/cudapp_binding_portable.o: src/cudapp_binding_portable.c $(GPU_FS_HDRS) + @mkdir -p $(GPU_FS_DIR) + gcc $(GPU_FS_CFLAGS) $(CUDAPP_PORTABLE_DEFS) -c -o $@ $< + $(GPU_FS_LINK): $(GPU_FS_OBJS) gcc -r -nostdlib -o $@ $(GPU_FS_OBJS) @bad=$$(nm -u $@ | awk '{print $$NF}' | grep -Ev '^(_GLOBAL_OFFSET_TABLE_|($(GPU_FS_ALLOWED)))$$' || true); \ @@ -179,12 +187,18 @@ build/test_codegen_freestanding: $(CODEGEN_FS_TEST_DEPS) $(GPU_FS_LINK) @mkdir -p build gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_GPU_NO_POSIX -o $@ tests/test_omega_codegen_freestanding.c \ $(GPU_FS_DIR)/omega_blackwell_codegen.o $(GPU_FS_DIR)/omega_blackwell_matmul.o $(GPU_FS_DIR)/sha256.o +ifeq ($(CUDAPP_HOST_IS_AARCH64),1) test-codegen-freestanding: build/test_codegen_hosted build/test_codegen_freestanding test-gpu-fs-allowlist-control ./build/test_codegen_hosted --dump > build/codegen_dump_hosted.txt ./build/test_codegen_freestanding --dump > build/codegen_dump_freestanding.txt cmp build/codegen_dump_hosted.txt build/codegen_dump_freestanding.txt @echo "codegen dumps byte-identical: $$(grep -c '^fixture ' build/codegen_dump_hosted.txt) fixtures, $$(grep -v -E '^(fixture|digest) ' build/codegen_dump_hosted.txt | tr -d '\n' | wc -c | awk '{print $$1/2}') code bytes" ./build/test_codegen_freestanding +else +test-codegen-freestanding: build/test_codegen_freestanding test-gpu-fs-allowlist-control + @echo "test-codegen-freestanding hosted comparison: NOT_RUN (requires AArch64 Linux; the .om versus C differential was not run)" + ./build/test_codegen_freestanding +endif test-gpu-fs-allowlist-control: $(GPU_FS_LINK) @mkdir -p $(GPU_FS_DIR)/control @@ -213,7 +227,7 @@ build/test_omega_gpu_session_platform: tests/test_omega_gpu_session_platform.c $ GPU_NATIVE_RUNTIME_SRCS = src/omega_gpu_cmdlist.c src/omega_gpu_fp8_api.c \ src/omega_gpu_fp8gemm_api.c src/omega_blackwell_codegen_moe.c src/omega_blackwell_codegen_moe2.c \ src/omega_blackwell_codegen_gemm.c src/omega_gpu_fp8_pack.c src/omega_gpu_mem_cached.c \ - src/omega_gpu_hostmath.c src/omega_native_artifact.c src/omega_cubin.c src/cudapp_om_units.c \ + src/omega_gpu_hostmath.c src/omega_native_artifact.c src/omega_cubin.c $(CUDAPP_HOST_BINDING) \ src/omega_gpu_q36_graph.c src/omega_gpu_decode_graph.c src/omega_gpu_router_api.c .PHONY: test-gpu-native-runtime build/test_omega_gpu_native_runtime: tests/test_omega_gpu_session_platform.c tests/native_runtime_controls.h \ @@ -223,17 +237,25 @@ build/test_omega_gpu_native_runtime: tests/test_omega_gpu_session_platform.c tes gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_GPU_NO_POSIX -DOMEGA_NATIVE_RUNTIME_TEST \ -DCUDAPP_NATIVE_RUNTIME_TEST -ffunction-sections -fdata-sections -Wl,--gc-sections \ -o $@ tests/test_omega_gpu_session_platform.c $(GPU_FS_LINK) $(GPU_NATIVE_RUNTIME_SRCS) -lpthread -lm +ifeq ($(CUDAPP_HOST_IS_AARCH64),1) test-gpu-native-runtime: build/test_omega_gpu_native_runtime ./build/test_omega_gpu_native_runtime -GPU_LINUX_REF_SRCS = src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c src/omega_gpu_fmt.c src/omega_blackwell_qmd.c src/cudapp_freest_units.c +else +test-gpu-native-runtime: + @echo "test-gpu-native-runtime: NOT_RUN (requires AArch64 Linux; the seeded native units were not executed)" + @exit 2 +endif +# On a non-AArch64 host the command-list list already links the portable binding, +# which defines the scalar counters. Linking it twice would duplicate symbols. +GPU_LINUX_REF_SRCS = src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c src/omega_gpu_fmt.c src/omega_blackwell_qmd.c $(if $(CUDAPP_HOST_IS_AARCH64),$(CUDAPP_FS_BINDING),) # omega #459: the command list over the reference (near-full ring with the #457 L2 invalidate prefix pending) needs the # cached allocation, the command list and the codegen behind its nop kernel. -GPU_LINUX_REF_CMDLIST_SRCS = src/omega_gpu_mem_cached.c src/omega_gpu_cmdlist.c src/omega_blackwell_codegen.c src/cudapp_om_units.c src/omega_blackwell_encoder.c \ +GPU_LINUX_REF_CMDLIST_SRCS = src/omega_gpu_mem_cached.c src/omega_gpu_cmdlist.c src/omega_blackwell_codegen.c $(CUDAPP_HOST_BINDING) src/omega_blackwell_encoder.c \ src/omega_blackwell_matmul.c src/omega_blackwell_realize.c src/sha256.c build/test_omega_gpu_platform_linux: tests/test_omega_gpu_platform_linux.c tests/fake_m16_native.c tests/fake_m16_native.h $(GPU_LINUX_REF_SRCS) $(GPU_FS_HDRS) src/omega_gpu_platform_linux.h \ src/omega_gpu_cmdlist.h src/omega_gpu_mem_cached.h $(GPU_LINUX_REF_CMDLIST_SRCS) @mkdir -p build - gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -Isrc -Itests $(GPU_ENGINE_PHYS_INC) \ + gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread $(CUDAPP_PORTABLE_DEFS) -Isrc -Itests $(GPU_ENGINE_PHYS_INC) \ -o $@ tests/test_omega_gpu_platform_linux.c tests/fake_m16_native.c $(GPU_LINUX_REF_SRCS) $(GPU_LINUX_REF_CMDLIST_SRCS) -lm # The driver client's VA slots and close path on the host (no device opened, nvrm_open never called). build/test_nvrm_va_slots: tests/test_nvrm_va_slots.c $(PHYSICS_DIR)/nvrm/nvrm.c $(PHYSICS_DIR)/nvrm/nvrm.h diff --git a/nvrm/cpu_barrier.h b/nvrm/cpu_barrier.h new file mode 100644 index 00000000..776e2c52 --- /dev/null +++ b/nvrm/cpu_barrier.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +#ifndef NVRM_CPU_BARRIER_H +#define NVRM_CPU_BARRIER_H + +/* CPU publication order for memory the device reads or the host reads back. + * + * AArch64, including the GB10 host, executes `dsb sy`. That system barrier + * is the production ordering primitive. A portable host build executes a + * sequentially consistent fence, which is a real instruction, so the same + * sources compile on x86-64. Opening the Blackwell device stays AArch64-only. + * + * ADR 0043 missing feature: seeded Omega has no host CPU publication barrier + * that is `dsb sy` on AArch64 and a real fence on every other host. This + * header is that barrier in C. The non-AArch64 fence is migration-pending C. + * The portable library compiles the callers with the existing + * CUDAPP_MIGRATION_PENDING_C_ENCODER and CUDAPP_MIGRATION_PENDING_C_CUBIN + * switches, which select the C encoder and the C cubin writer. Extension + * proposal: https://github.com/aien-dev/omega-mv/issues/939 + * evidence/HOST-X86-20261030/proposal-cpu-barrier.md + */ +static inline void nvrm_cpu_barrier(void) +{ +#if defined(__aarch64__) + __asm__ volatile("dsb sy" ::: "memory"); +#else + __atomic_thread_fence(__ATOMIC_SEQ_CST); +#endif +} + +/* Spin hint between polls. AArch64 keeps `yield`. Other hosts keep the + * compiler barrier already used by src/omega_gpu_wait.c. This is not the + * publication barrier above. + */ +static inline void nvrm_cpu_relax(void) +{ +#if defined(__aarch64__) + __asm__ volatile("yield"); +#else + __asm__ volatile("" ::: "memory"); +#endif +} + +#endif diff --git a/nvrm/lifecycle_gates.c b/nvrm/lifecycle_gates.c index f28d065c..fc034ca9 100644 --- a/nvrm/lifecycle_gates.c +++ b/nvrm/lifecycle_gates.c @@ -8,6 +8,7 @@ * modify m16_requalify.c / m16_concurrent.c or any existing test. */ #include "nvrm.h" +#include "cpu_barrier.h" #include "m16_native.h" #include @@ -291,7 +292,7 @@ static int gate_gpu_submit_after_churn(Nvrm *rm) { return -1; } memcpy(pb.cpu, methods, (size_t)nwords * sizeof(uint32_t)); - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); if (nvrm_submit(rm, &pb, 0, (uint32_t)nwords) != 0) { fprintf(stderr, " submit: nvrm_submit failed: %s\n", rm->err); diff --git a/nvrm/nvrm.c b/nvrm/nvrm.c index 474f8946..6c422d7a 100644 --- a/nvrm/nvrm.c +++ b/nvrm/nvrm.c @@ -7,6 +7,7 @@ */ #include "nvrm.h" +#include "cpu_barrier.h" #include #include @@ -946,9 +947,9 @@ int nvrm_enqueue(Nvrm *rm, const NvrmMem *pb, uint32_t off, uint32_t nwords) { volatile uint64_t *ring = (volatile uint64_t *)rm->fifo.cpu; ring[rm->put % rm->entries] = nvrm_gp_entry(pb->va + off, nwords); rm->put++; - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); *nvrm_userd_gpput(rm) = rm->put % rm->entries; - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); return 0; } @@ -978,9 +979,9 @@ int nvrm_chan_submit(Nvrm *rm, uint32_t ch, const NvrmMem *pb, uint32_t off, uin volatile uint64_t *ring = (volatile uint64_t *)c->fifo.cpu; ring[c->put % c->entries] = nvrm_gp_entry(pb->va + off, nwords); c->put++; - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); *(volatile uint32_t *)((uint8_t *)c->fifo.cpu + c->userd_off + offsetof(Nvc96fControl, GPPut)) = c->put % c->entries; - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); *rm->doorbell = c->token; /* NVC361_NOTIFY_CHANNEL_PENDING: one doorbell page, the token names the channel */ return 0; } diff --git a/nvrm/submission_visibility_gates.c b/nvrm/submission_visibility_gates.c index c0067f31..7e844f66 100644 --- a/nvrm/submission_visibility_gates.c +++ b/nvrm/submission_visibility_gates.c @@ -4,6 +4,7 @@ * The unfixed allocator stalls on the second submission on GB10. */ #include "m16_native.h" +#include "cpu_barrier.h" #include #include @@ -22,7 +23,7 @@ static int run_sequence(int reuse) { goto finish; volatile uint32_t *marker = completion.cpu; *marker = 0; - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); uint32_t count = reuse ? ctx.rm.entries * 2 + 3 : 2; for (uint32_t payload = 1; payload <= count; ++payload) { uint32_t methods[32]; @@ -38,7 +39,7 @@ static int run_sequence(int reuse) { uint32_t offset = (payload - 1) * 128; memcpy((unsigned char *)ctx.pb_mem.cpu + offset, methods, (size_t)words * sizeof(uint32_t)); - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); if (nvrm_enqueue(&ctx.rm, &ctx.pb_mem, offset, (uint32_t)words) != 0) goto finish; } diff --git a/src/cudapp_binding_portable.c b/src/cudapp_binding_portable.c new file mode 100644 index 00000000..b1003984 --- /dev/null +++ b/src/cudapp_binding_portable.c @@ -0,0 +1,233 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* Portable host stand-in used only when the host cannot assemble the seeded + * bindings. src/cudapp_om_units.c and src/cudapp_freest_units.c stay as + * om/units.sh wrote them. This file is not that regeneration, and the AArch64 + * library does not link it. + * + * ADR 0043 missing feature: those generated units are AArch64 machine code, and + * seeded Omega does not yet emit a binding the build host can assemble. This + * file is migration-pending C. The library compiles it only on a non-AArch64 + * host, and only with CUDAPP_MIGRATION_PENDING_C_ENCODER and + * CUDAPP_MIGRATION_PENDING_C_CUBIN, the switches that select the C encoder and + * the C cubin writer. The host test defines BINDING_PORTABLE. Extension + * proposal: https://github.com/aien-dev/omega-mv/issues/940 + * evidence/HOST-X86-20261030/proposal-binding-portable.md + * + * omega_native_revision and omega_native_epoch follow the committed + * freestanding units. Those units were executed on an x86-64 host with + * qemu-aarch64 8.2.2 and aarch64-linux-gnu-gcc 13, linking src/cudapp_freest_units.c. + * Observed: revision(0)=1, revision(1)=2, revision(UINT64_MAX-1)=UINT64_MAX, + * revision(UINT64_MAX)=0; epoch(0)=1, epoch(3)=4, epoch(UINT64_MAX)=UINT64_MAX; + * a null or misaligned result pointer returns 32. The same vectors are checked + * by tests/omega/test-binding-portable.sh. + * + * Every other entry returns 34 (OMEGA_BAD_RT) and does not write *result. + * That refusal is not a result from the seeded unit. Callers that need the + * seeded encoder, cubin packer, or the other units are target-only on AArch64. + * On this host the C encoder and the C cubin writer are selected instead, so + * those two entries are not on the portable codegen path. + */ +#if !defined(CUDAPP_MIGRATION_PENDING_C_ENCODER) && !defined(CUDAPP_MIGRATION_PENDING_C_CUBIN) && !defined(BINDING_PORTABLE) +#error src/cudapp_binding_portable.c is migration-pending C for a non-AArch64 host +#endif +#include +#include +#include "cudapp_native.h" + +static int result_refused(const uint64_t *result) +{ + uintptr_t p = (uintptr_t)result; + return result == 0 || (p % 8u) != 0u || p > UINTPTR_MAX - 8u; +} + +uint32_t omega_native_revision(uint64_t *result, uint64_t o_previous) +{ + if (result_refused(result)) + return OMEGA_BAD_ARG; + *result = o_previous == UINT64_MAX ? 0u : o_previous + 1u; + return OMEGA_OK; +} + +uint32_t omega_native_epoch(uint64_t *result, uint64_t o_previous) +{ + if (result_refused(result)) + return OMEGA_BAD_ARG; + *result = o_previous == UINT64_MAX ? UINT64_MAX : o_previous + 1u; + return OMEGA_OK; +} + +uint32_t omega_bw_enc_sm121(uint64_t *result, const void *o_ins, uint64_t o_ins_len, const void *o_phys, uint64_t o_phys_len, uint64_t o_n, uint64_t o_pad, void *o_code, uint64_t o_code_len) +{ + (void)result; (void)o_ins; (void)o_ins_len; (void)o_phys; (void)o_phys_len; (void)o_n; (void)o_pad; (void)o_code; (void)o_code_len; + return OMEGA_BAD_RT; +} +uint32_t omega_cubin_elf(uint64_t *result, const void *o_m, uint64_t o_m_len, const void *o_nm, uint64_t o_nm_len, const void *o_tx, uint64_t o_tx_len, void *o_o, uint64_t o_o_len) +{ + (void)result; (void)o_m; (void)o_m_len; (void)o_nm; (void)o_nm_len; (void)o_tx; (void)o_tx_len; (void)o_o; (void)o_o_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_repack(uint64_t *result, const void *o_d, uint64_t o_d_len, const void *o_src, uint64_t o_src_len, const void *o_sc, uint64_t o_sc_len, void *o_dst, uint64_t o_dst_len, void *o_ds, uint64_t o_ds_len) +{ + (void)result; (void)o_d; (void)o_d_len; (void)o_src; (void)o_src_len; (void)o_sc; (void)o_sc_len; (void)o_dst; (void)o_dst_len; (void)o_ds; (void)o_ds_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_quant(uint64_t *result, uint64_t o_op, void *o_d, uint64_t o_d_len, void *o_wire, uint64_t o_wire_len) +{ + (void)result; (void)o_op; (void)o_d; (void)o_d_len; (void)o_wire; (void)o_wire_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_compose(uint64_t *result, const void *o_cfg, uint64_t o_cfg_len, void *o_ins, uint64_t o_ins_len, void *o_meta, uint64_t o_meta_len, void *o_phys, uint64_t o_phys_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_cfg; (void)o_cfg_len; (void)o_ins; (void)o_ins_len; (void)o_meta; (void)o_meta_len; (void)o_phys; (void)o_phys_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_bc_encode(uint64_t *result, const void *o_ins, uint64_t o_ins_len, const void *o_phys, uint64_t o_phys_len, uint64_t o_n, uint64_t o_pad, void *o_code, uint64_t o_code_len) +{ + (void)result; (void)o_ins; (void)o_ins_len; (void)o_phys; (void)o_phys_len; (void)o_n; (void)o_pad; (void)o_code; (void)o_code_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_cache(uint64_t *result, void *o_p, uint64_t o_p_len, const void *o_req, uint64_t o_req_len, const void *o_tok, uint64_t o_tok_len, uint64_t o_op) +{ + (void)result; (void)o_p; (void)o_p_len; (void)o_req; (void)o_req_len; (void)o_tok; (void)o_tok_len; (void)o_op; + return OMEGA_BAD_RT; +} +uint32_t omega_native_lease(uint64_t *result, void *o_p, uint64_t o_p_len, const void *o_req, uint64_t o_req_len, const void *o_tok, uint64_t o_tok_len, uint64_t o_op) +{ + (void)result; (void)o_p; (void)o_p_len; (void)o_req; (void)o_req_len; (void)o_tok; (void)o_tok_len; (void)o_op; + return OMEGA_BAD_RT; +} +uint32_t omega_native_slotrev(uint64_t *result, const void *o_p, uint64_t o_p_len, uint64_t o_slot, uint64_t o_gen) +{ + (void)result; (void)o_p; (void)o_p_len; (void)o_slot; (void)o_gen; + return OMEGA_BAD_RT; +} +uint32_t omega_native_event(uint64_t *result, void *o_p, uint64_t o_p_len, void *o_lease, uint64_t o_lease_len, uint64_t o_epoch, uint64_t o_op) +{ + (void)result; (void)o_p; (void)o_p_len; (void)o_lease; (void)o_lease_len; (void)o_epoch; (void)o_op; + return OMEGA_BAD_RT; +} +uint32_t omega_native_validate(uint64_t *result, const void *o_rec, uint64_t o_rec_len, const void *o_sizes, uint64_t o_sizes_len, const void *o_code, uint64_t o_code_len, const void *o_launch, uint64_t o_launch_len, const void *o_expected, uint64_t o_expected_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_rec; (void)o_rec_len; (void)o_sizes; (void)o_sizes_len; (void)o_code; (void)o_code_len; (void)o_launch; (void)o_launch_len; (void)o_expected; (void)o_expected_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_key(uint64_t *result, const void *o_data, uint64_t o_data_len, uint64_t o_n, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_data; (void)o_data_len; (void)o_n; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_codekey(uint64_t *result, const void *o_data, uint64_t o_data_len, uint64_t o_n, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_data; (void)o_data_len; (void)o_n; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_templates(uint64_t *result, const void *o_launch, uint64_t o_launch_len, const void *o_cubin, uint64_t o_cubin_len, const void *o_observed, uint64_t o_observed_len, const void *o_sizes, uint64_t o_sizes_len) +{ + (void)result; (void)o_launch; (void)o_launch_len; (void)o_cubin; (void)o_cubin_len; (void)o_observed; (void)o_observed_len; (void)o_sizes; (void)o_sizes_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_graph(uint64_t *result, const void *o_q, uint64_t o_q_len, const void *o_rows, uint64_t o_rows_len, void *o_p, uint64_t o_p_len, const void *o_want, uint64_t o_want_len, const void *o_records, uint64_t o_records_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_q; (void)o_q_len; (void)o_rows; (void)o_rows_len; (void)o_p; (void)o_p_len; (void)o_want; (void)o_want_len; (void)o_records; (void)o_records_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_context_lookup(uint64_t *result, const void *o_keys, uint64_t o_keys_len, uint64_t o_count, const void *o_actual, uint64_t o_actual_len) +{ + (void)result; (void)o_keys; (void)o_keys_len; (void)o_count; (void)o_actual; (void)o_actual_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_binding(uint64_t *result, const void *o_real, uint64_t o_real_len, const void *o_launch, uint64_t o_launch_len, const void *o_call, uint64_t o_call_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_real; (void)o_real_len; (void)o_launch; (void)o_launch_len; (void)o_call; (void)o_call_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_moe_plan(uint64_t *result, const void *o_c, uint64_t o_c_len, const void *o_ids, uint64_t o_ids_len, void *o_w, uint64_t o_w_len, void *o_sg, uint64_t o_sg_len, void *o_mp, uint64_t o_mp_len, void *o_m, uint64_t o_m_len) +{ + (void)result; (void)o_c; (void)o_c_len; (void)o_ids; (void)o_ids_len; (void)o_w; (void)o_w_len; (void)o_sg; (void)o_sg_len; (void)o_mp; (void)o_mp_len; (void)o_m; (void)o_m_len; + return OMEGA_BAD_RT; +} +uint32_t omega_moe_group(uint64_t *result, const void *o_r, uint64_t o_r_len, void *o_o, uint64_t o_o_len) +{ + (void)result; (void)o_r; (void)o_r_len; (void)o_o; (void)o_o_len; + return OMEGA_BAD_RT; +} +uint32_t omega_moe_ids32(uint64_t *result, const void *o_src, uint64_t o_src_len, uint64_t o_n, void *o_ids, uint64_t o_ids_len) +{ + (void)result; (void)o_src; (void)o_src_len; (void)o_n; (void)o_ids; (void)o_ids_len; + return OMEGA_BAD_RT; +} +uint32_t omega_moe_maps32(uint64_t *result, const void *o_m, uint64_t o_m_len, const void *o_mp, uint64_t o_mp_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_m; (void)o_m_len; (void)o_mp; (void)o_mp_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_moe_segs32(uint64_t *result, const void *o_sg, uint64_t o_sg_len, const void *o_m, uint64_t o_m_len, const void *o_dir, uint64_t o_dir_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_sg; (void)o_sg_len; (void)o_m; (void)o_m_len; (void)o_dir; (void)o_dir_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_moe_windows(uint64_t *result, const void *o_c, uint64_t o_c_len, void *o_o, uint64_t o_o_len, void *o_m, uint64_t o_m_len) +{ + (void)result; (void)o_c; (void)o_c_len; (void)o_o; (void)o_o_len; (void)o_m; (void)o_m_len; + return OMEGA_BAD_RT; +} +uint32_t omega_moe_admit(uint64_t *result, const void *o_r, uint64_t o_r_len, const void *o_q, uint64_t o_q_len, const void *o_a, uint64_t o_a_len, void *o_p, uint64_t o_p_len, void *o_o, uint64_t o_o_len, void *o_lease, uint64_t o_lease_len) +{ + (void)result; (void)o_r; (void)o_r_len; (void)o_q; (void)o_q_len; (void)o_a; (void)o_a_len; (void)o_p; (void)o_p_len; (void)o_o; (void)o_o_len; (void)o_lease; (void)o_lease_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mcpack(uint64_t *result, const void *o_s, uint64_t o_s_len, const void *o_h, uint64_t o_h_len, const void *o_w, uint64_t o_w_len, void *o_o, uint64_t o_o_len) +{ + (void)result; (void)o_s; (void)o_s_len; (void)o_h; (void)o_h_len; (void)o_w; (void)o_w_len; (void)o_o; (void)o_o_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mcbind(uint64_t *result, const void *o_e, uint64_t o_e_len, const void *o_a, uint64_t o_a_len, const void *o_q, uint64_t o_q_len, const void *o_r, uint64_t o_r_len, uint64_t o_role, void *o_o, uint64_t o_o_len) +{ + (void)result; (void)o_e; (void)o_e_len; (void)o_a; (void)o_a_len; (void)o_q; (void)o_q_len; (void)o_r; (void)o_r_len; (void)o_role; (void)o_o; (void)o_o_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mcblob(uint64_t *result, const void *o_w, uint64_t o_w_len, const void *o_a, uint64_t o_a_len, const void *o_c, uint64_t o_c_len, uint64_t o_n, const void *o_l, uint64_t o_l_len, uint64_t o_role) +{ + (void)result; (void)o_w; (void)o_w_len; (void)o_a; (void)o_a_len; (void)o_c; (void)o_c_len; (void)o_n; (void)o_l; (void)o_l_len; (void)o_role; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mccover(uint64_t *result, const void *o_c, uint64_t o_c_len, const void *o_roles, uint64_t o_roles_len, const void *o_counts, uint64_t o_counts_len, const void *o_owner, uint64_t o_owner_len) +{ + (void)result; (void)o_c; (void)o_c_len; (void)o_roles; (void)o_roles_len; (void)o_counts; (void)o_counts_len; (void)o_owner; (void)o_owner_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mcintent(uint64_t *result, const void *o_m, uint64_t o_m_len, const void *o_bank, uint64_t o_bank_len, const void *o_qmd, uint64_t o_qmd_len, const void *o_s, uint64_t o_s_len, const void *o_seal, uint64_t o_seal_len) +{ + (void)result; (void)o_m; (void)o_m_len; (void)o_bank; (void)o_bank_len; (void)o_qmd; (void)o_qmd_len; (void)o_s; (void)o_s_len; (void)o_seal; (void)o_seal_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mcseal(uint64_t *result, const void *o_bank, uint64_t o_bank_len, const void *o_qmd, uint64_t o_qmd_len, uint64_t o_n, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_bank; (void)o_bank_len; (void)o_qmd; (void)o_qmd_len; (void)o_n; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mccode(uint64_t *result, const void *o_code, uint64_t o_code_len, uint64_t o_n, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_code; (void)o_code_len; (void)o_n; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mclaunch(uint64_t *result, const void *o_meta, uint64_t o_meta_len, const void *o_bank, uint64_t o_bank_len, const void *o_qmdslot, uint64_t o_qmdslot_len, const void *o_submit, uint64_t o_submit_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_meta; (void)o_meta_len; (void)o_bank; (void)o_bank_len; (void)o_qmdslot; (void)o_qmdslot_len; (void)o_submit; (void)o_submit_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mcdir(uint64_t *result, const void *o_meta, uint64_t o_meta_len, const void *o_entries, uint64_t o_entries_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_meta; (void)o_meta_len; (void)o_entries; (void)o_entries_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mcalloc(uint64_t *result, const void *o_meta, uint64_t o_meta_len, const void *o_records, uint64_t o_records_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_meta; (void)o_meta_len; (void)o_records; (void)o_records_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} +uint32_t omega_native_mcseries(uint64_t *result, const void *o_meta, uint64_t o_meta_len, const void *o_hashes, uint64_t o_hashes_len, const void *o_ordinals, uint64_t o_ordinals_len, void *o_out, uint64_t o_out_len) +{ + (void)result; (void)o_meta; (void)o_meta_len; (void)o_hashes; (void)o_hashes_len; (void)o_ordinals; (void)o_ordinals_len; (void)o_out; (void)o_out_len; + return OMEGA_BAD_RT; +} diff --git a/src/omega_blackwell_engine.c b/src/omega_blackwell_engine.c index bc053f13..645bf9d0 100644 --- a/src/omega_blackwell_engine.c +++ b/src/omega_blackwell_engine.c @@ -38,6 +38,7 @@ #include "omega_blackwell_qmd.h" #include "omega_blackwell_submit.h" #include "m16_native.h" +#include "cpu_barrier.h" #include #include @@ -210,6 +211,15 @@ static int be_open_device(void *ctx) { BeCtx *c = (BeCtx *)ctx; int rc; +#if !defined(__aarch64__) && !defined(OMEGA_BLACKWELL_HOST_SIMULATOR) + /* The production device is the GB10 on AArch64 Linux. A portable host + * compiles this file and refuses to open it. The fake-driver tests define + * OMEGA_BLACKWELL_HOST_SIMULATOR. That define does not create an x86 GPU. */ + c->last_rc = -1; + note(c, "Blackwell GPU backend requires AArch64 Linux"); + errno = ENOTSUP; + return -1; +#endif if (atomic_flag_test_and_set(&g_busy)) return -1; /* another run is active; touch nothing */ memset(c, 0, sizeof *c); c->native_open = 1; @@ -390,7 +400,7 @@ static int be_build(void *ctx, const OmegaGpuJob *job) *c->hmarker = 0; *c->hmarker2 = 0; if (!c->c3) c->hmarker2 = NULL; /* never waited for, never reported */ - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); /* AArch64: dsb sy. See nvrm/cpu_barrier.h. */ /* ---- unified pushbuffer, SUB@676f16f lines 130-195 ---- */ c->pb_len = 0; @@ -555,7 +565,7 @@ static int be_barrier(void *ctx, uint64_t timeout_ms) BeCtx *c = (BeCtx *)ctx; (void)timeout_ms; begin(c); - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); /* AArch64: dsb sy before readback. */ return 0; } diff --git a/src/omega_blackwell_matmul.c b/src/omega_blackwell_matmul.c index e0375f14..115ec7d7 100644 --- a/src/omega_blackwell_matmul.c +++ b/src/omega_blackwell_matmul.c @@ -92,10 +92,16 @@ float omega_bf16_to_fp32(uint16_t b) { } uint16_t omega_fp32_to_fp16(float f) { +#if defined(OMEGA_GPU_NO_POSIX) && !defined(__aarch64__) + /* x86-64 freestanding: the _Float16 cast is libgcc __truncsfhf2, which the + * freestanding allowlist rejects. The integer form is the same rounding. */ + return omega_fp32_to_fp16_rne(f); +#else _Float16 h = (_Float16)f; uint16_t u; memcpy(&u, &h, 2); return u; +#endif } uint16_t omega_fp32_to_bf16(float f) { diff --git a/src/omega_blackwell_matmul.h b/src/omega_blackwell_matmul.h index 6802d769..3680e22e 100644 --- a/src/omega_blackwell_matmul.h +++ b/src/omega_blackwell_matmul.h @@ -71,6 +71,50 @@ static inline uint16_t omega_fp32_to_bf16_rne(float f) { return (uint16_t)((u + 0x7fffu + ((u >> 16) & 1u)) >> 16); } +/* Integer form of a default-rounding fp32 to fp16 cast. The freestanding x86-64 + * build uses it so the link does not call libgcc __truncsfhf2. AArch64 keeps the + * hardware cast. Compared with gcc's _Float16 cast on all 2^32 inputs on an + * x86-64 host (0 mismatches). That comparison is not a GB10 result. */ +static inline uint16_t omega_fp32_to_fp16_rne(float f) { + union { float f; uint32_t u; } v = {f}; + const uint32_t x = v.u; + const uint32_t sign = (x >> 16) & 0x8000u; + const uint32_t mant = x & 0x7fffffu; + const int32_t exp = (int32_t)((x >> 23) & 0xffu) - 127 + 15; + uint32_t half; + if ((x & 0x7f800000u) == 0x7f800000u) { + if (mant) { + half = 0x7e00u | (mant >> 13); + if ((half & 0x03ffu) == 0u) + half |= 0x0200u; + return (uint16_t)(sign | half); + } + return (uint16_t)(sign | 0x7c00u); + } + if (exp >= 0x1f) + return (uint16_t)(sign | 0x7c00u); + if (exp <= 0) { + uint32_t shift, rem, cut; + if (exp < -10) + return (uint16_t)sign; + half = mant | 0x800000u; + shift = (uint32_t)(14 - exp); + rem = half & ((1u << shift) - 1u); + cut = 1u << (shift - 1); + half >>= shift; + if (rem > cut || (rem == cut && (half & 1u))) + half++; + return (uint16_t)(sign | half); + } + half = ((uint32_t)exp << 10) | (mant >> 13); + { + const uint32_t rem = mant & 0x1fffu; + if (rem > 0x1000u || (rem == 0x1000u && (half & 1u))) + half++; + } + return (uint16_t)(sign | (half & 0x7fffu)); +} + /* Dynamic sm_121 code generator: transforms G_S semantic spec into machine code */ int omega_blackwell_codegen_matmul(const OmegaMatMulSpec *spec, OmegaBlackwellKernel *kernel); diff --git a/src/omega_blackwell_submit.c b/src/omega_blackwell_submit.c index 8ec564e3..d435dd99 100644 --- a/src/omega_blackwell_submit.c +++ b/src/omega_blackwell_submit.c @@ -7,6 +7,8 @@ #include "omega_gpu_engine.h" #include "m16_native.h" #include "omega_gpu_wait.h" +#include "cpu_barrier.h" +#include #include #include #include @@ -29,12 +31,25 @@ static uint64_t current_time_ns(void) { return (uint64_t)t.tv_sec * 1000000000ULL + (uint64_t)t.tv_nsec; } +/* Production entry points run on AArch64. The host simulator defines + * OMEGA_BLACKWELL_HOST_SIMULATOR and keeps the argument checks below. */ +static int bw_refuse_non_aarch64(void) +{ +#if !defined(__aarch64__) && !defined(OMEGA_BLACKWELL_HOST_SIMULATOR) + errno = ENOTSUP; + return -1; +#else + return 0; +#endif +} + int omega_blackwell_execute_vector(const OmegaVectorSpec *spec, const OmegaBlackwellRealization *real, const uint32_t *h_a, const uint32_t *h_b, uint32_t *h_c_out, OmegaBlackwellVectorExecution *exec_info) { + if (bw_refuse_non_aarch64() != 0) return -1; if (!spec || !real || !h_a || !h_b || !h_c_out) return -1; uint32_t n = spec->element_count; if (n == 0) return -1; @@ -165,6 +180,7 @@ int omega_blackwell_execute_matmul(const OmegaMatMulSpec *spec, const uint32_t *h_b, uint32_t *h_c_out, OmegaBlackwellMatMulExecution *exec_info) { + if (bw_refuse_non_aarch64() != 0) return -1; if (!spec || !kernel || !h_a || !h_b || !h_c_out) return -1; if (!kernel->code || kernel->code_size == 0) return -1; if (spec->m == 0 || spec->k == 0 || spec->n == 0) return -1; @@ -281,7 +297,7 @@ int omega_blackwell_execute_matmul(const OmegaMatMulSpec *spec, *hsem = 0; *hmarker = 0; *hmarker2 = 0; - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); /* Assemble unified pushbuffer */ uint32_t pb[1024]; @@ -374,7 +390,7 @@ int omega_blackwell_execute_matmul(const OmegaMatMulSpec *spec, /* Wait for hardware completion marker */ /* CHIPWAIT-2: marker with marker2 required (C3: the second release lands only after the L2 flush). */ if (bw_wait_one(__func__, "marker", hmarker, OMEGA_BW_MARKER_COMPLETION_PAYLOAD, hmarker2, OMEGA_BW_MARKER2_PAYLOAD) != 0) { m16_native_close(&ctx); return -1; } - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); uint64_t t_end = current_time_ns(); /* Validate intermediate semaphore updated to 6 */ @@ -420,6 +436,7 @@ int omega_blackwell_execute_matmul_tensor(const OmegaMatMulSpec *spec, OmegaBlackwellMatMulExecution *exec_info, float *out_max_abs_err, float *out_max_rel_err) { + if (bw_refuse_non_aarch64() != 0) return -1; if (!spec || !kernel || !h_a || !h_b || !h_c_out) return -1; if (!kernel->code || kernel->code_size == 0) return -1; if (spec->m == 0 || spec->k == 0 || spec->n == 0) return -1; @@ -538,7 +555,7 @@ int omega_blackwell_execute_matmul_tensor(const OmegaMatMulSpec *spec, *hsem = 0; *hmarker = 0; *hmarker2 = 0; - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); uint32_t pb[1024]; size_t pb_len = 0; @@ -619,7 +636,7 @@ int omega_blackwell_execute_matmul_tensor(const OmegaMatMulSpec *spec, /* CHIPWAIT-2: marker with marker2 required (C3: the second release lands only after the L2 flush). */ if (bw_wait_one(__func__, "marker", hmarker, OMEGA_BW_MARKER_COMPLETION_PAYLOAD, hmarker2, OMEGA_BW_MARKER2_PAYLOAD) != 0) { m16_native_close(&ctx); return -1; } - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); uint64_t t_end = current_time_ns(); if (*hsem != OMEGA_BW_SEMAPHORE_INTERMEDIATE_DONE) { m16_native_close(&ctx); return -1; } diff --git a/src/omega_gpu_elementwise_api.c b/src/omega_gpu_elementwise_api.c index 3df511ce..6877c864 100644 --- a/src/omega_gpu_elementwise_api.c +++ b/src/omega_gpu_elementwise_api.c @@ -25,6 +25,7 @@ #include "omega_blackwell_submit.h" #include "omega_gpu_session.h" #include "sha256.h" +#include "cpu_barrier.h" #include #include #include @@ -930,7 +931,7 @@ static int kernel_for(OmegaGpuEwOp op, bool upload, Slot **out, bool *hit) { if (upload && !s->code.cpu) { if (omega_gpu_session_alloc_code(s->kernel.code_size, &s->code) != 0) return OMEGA_GPU_EW_CHIP_FAIL; memcpy(s->code.cpu, s->kernel.code, s->kernel.code_size); - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); } *out = s; return OMEGA_GPU_EW_OK; @@ -983,7 +984,7 @@ static int run_abc(const Slot *ks, const void *a, size_t a_bytes, const void *b, size_t c_words = c_bytes / 4; uint32_t *c_dev = (uint32_t *)g_c.mem.cpu; for (size_t i = 0; i < c_words; i++) c_dev[i] = EW_POISON; - __asm__ volatile("dsb sy" ::: "memory"); + nvrm_cpu_barrier(); uint32_t args[OMEGA_BW_CBANK_MATMUL_ARGS_WORDS]; args[0] = (uint32_t)g_a.mem.va; args[1] = (uint32_t)(g_a.mem.va >> 32); diff --git a/src/omega_gpu_platform_linux.c b/src/omega_gpu_platform_linux.c index 33ae827b..70bb2311 100644 --- a/src/omega_gpu_platform_linux.c +++ b/src/omega_gpu_platform_linux.c @@ -18,6 +18,7 @@ * the caller observed completion covers everything submitted. */ #include "omega_gpu_platform_linux.h" +#include "cpu_barrier.h" #include "m16_native.h" #include "nvrm.h" @@ -342,11 +343,7 @@ static int ref_dma_free(void *ctx, OmegaGpuBufferHandle b) { } static void barrier(void) { -#if defined(__aarch64__) - __asm__ volatile("dsb sy" ::: "memory"); -#else - __sync_synchronize(); -#endif + nvrm_cpu_barrier(); } static int ref_sync(void *ctx, OmegaGpuBufferHandle b, uint64_t off, uint64_t len, const char *stage, int to_gpu) { @@ -449,7 +446,7 @@ static int ref_queue_submit(void *ctx, OmegaGpuQueueHandle q, const uint32_t *wo uint32_t *dst = ring->cpu; if (xpre) memcpy(dst, L2_INVAL_PREFIX, sizeof L2_INVAL_PREFIX); memcpy(dst + xpre, words, (size_t)nwords * 4u); - __asm__ volatile("dsb sy" ::: "memory"); + barrier(); if (nvrm_chan_submit(&r->m16.rm, (uint32_t)slot + 1u, ring, 0, nwords + xpre) != 0) rc = OMEGA_GPU_PLAT_REFUSED_DEVICE; else { r->x_l2_pending[slot] = 0; r->xinflight[slot]++; } } diff --git a/tests/omega/binding_portable_test.c b/tests/omega/binding_portable_test.c new file mode 100644 index 00000000..54c66157 --- /dev/null +++ b/tests/omega/binding_portable_test.c @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* Same revision and epoch vectors on the freestanding seeded units and on the + * portable stand-in. With BINDING_PORTABLE, one seeded entry must refuse + * without writing the result. */ +#include "cudapp_native.h" + +#include +#include + +static int expect_u(const char *name, uint32_t st, uint64_t got, uint32_t want_st, uint64_t want) +{ + if (st == want_st && got == want) + return 0; + fprintf(stderr, "FAIL %s st=%u got=%llu want_st=%u want=%llu\n", name, st, + (unsigned long long)got, want_st, (unsigned long long)want); + return 1; +} + +int main(void) +{ + int bad = 0; + uint64_t r = 42; + uint32_t st; + st = omega_native_revision(&r, 0); + bad |= expect_u("rev0", st, r, OMEGA_OK, 1); + st = omega_native_revision(&r, 1); + bad |= expect_u("rev1", st, r, OMEGA_OK, 2); + st = omega_native_revision(&r, UINT64_MAX - 1); + bad |= expect_u("revmax-1", st, r, OMEGA_OK, UINT64_MAX); + st = omega_native_revision(&r, UINT64_MAX); + bad |= expect_u("revmax", st, r, OMEGA_OK, 0); + if (omega_native_revision(0, 0) != OMEGA_BAD_ARG) { + fprintf(stderr, "FAIL revnull\n"); + bad = 1; + } + if (omega_native_revision((uint64_t *)(uintptr_t)1, 0) != OMEGA_BAD_ARG) { + fprintf(stderr, "FAIL revmisaligned\n"); + bad = 1; + } + st = omega_native_epoch(&r, 0); + bad |= expect_u("ep0", st, r, OMEGA_OK, 1); + st = omega_native_epoch(&r, 3); + bad |= expect_u("ep3", st, r, OMEGA_OK, 4); + st = omega_native_epoch(&r, UINT64_MAX - 1); + bad |= expect_u("epmax-1", st, r, OMEGA_OK, UINT64_MAX); + st = omega_native_epoch(&r, UINT64_MAX); + bad |= expect_u("epmax", st, r, OMEGA_OK, UINT64_MAX); + if (omega_native_epoch(0, 0) != OMEGA_BAD_ARG) { + fprintf(stderr, "FAIL epnull\n"); + bad = 1; + } +#ifdef BINDING_PORTABLE + r = 99; + if (omega_bw_enc_sm121(&r, 0, 0, 0, 0, 0, 0, 0, 0) != OMEGA_BAD_RT || r != 99) { + fprintf(stderr, "FAIL encoder refusal wrote a result or returned another status\n"); + bad = 1; + } +#endif + if (bad) + return 1; + puts("binding-portable: PASS"); + return 0; +} diff --git a/tests/omega/run.sh b/tests/omega/run.sh index 08a8b646..68b7fd8f 100755 --- a/tests/omega/run.sh +++ b/tests/omega/run.sh @@ -14,23 +14,62 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Run the omega compiler harness against this repo's omega/slices. -# Usage: tests/omega/run.sh [FUZZ] (default 120) +# Run the pinned Omega OSC compiler against this checkout's eight slices. +# Usage: tests/omega/run.sh [FUZZ [HARNESS_DIR]] +# or: OMEGA_OSC_COMPILER_DIR=/path/to/omega-osc-cubin tests/omega/run.sh [FUZZ] +# There is no default harness path. The checkout must be exactly PINNED_SOURCE +# and clean. Docs: docs/OMEGA_HOST_TESTS.md. set -eu -W=$HOME/workspace/omega-osc-cubin # the compiler harness build -R=$(cd "$(dirname "$0")/../.." && pwd) # this repo checkout +PINNED_SOURCE=1accb93164ce68a2ac2e2c680acf54782f260d62 FUZZ=${1:-120} -# Every slice must be present by name: a deleted file is a loud failure here, -# not a silently smaller keyed count in the harness summary. +W=${2:-${OMEGA_OSC_COMPILER_DIR:-}} +R=$(cd "$(dirname "$0")/../.." && pwd) SLICES="doorbell.osc sequencer.osc nvrm.osc va.osc open_plan.osc kmod.osc mesa.osc launch.osc" + for f in $SLICES; do - [ -f "$R/omega/slices/$f" ] || { echo "missing slice: omega/slices/$f" >&2; exit 1; } + [ -f "$R/omega/slices/$f" ] || { + echo "omega-slices: missing required slice $R/omega/slices/$f" >&2 + exit 1 + } done + +if [ -z "$W" ]; then + echo "omega-slices: compiler harness not configured; set OMEGA_OSC_COMPILER_DIR to an Omega checkout" >&2 + echo "omega-slices: required source commit: $PINNED_SOURCE" >&2 + exit 2 +fi +if [ ! -d "$W/.git" ] && [ ! -f "$W/.git" ]; then + echo "omega-slices: harness directory is not a Git checkout: $W" >&2 + echo "omega-slices: required source commit: $PINNED_SOURCE" >&2 + exit 2 +fi +SOURCE=$(env -u GIT_DIR -u GIT_WORK_TREE git -C "$W" rev-parse --verify HEAD 2>/dev/null || true) +if [ "$SOURCE" != "$PINNED_SOURCE" ]; then + echo "omega-slices: wrong harness source at $W (expected $PINNED_SOURCE, found ${SOURCE:-unavailable})" >&2 + exit 2 +fi +if [ -n "$(env -u GIT_DIR -u GIT_WORK_TREE git -C "$W" status --porcelain)" ]; then + echo "omega-slices: harness checkout is modified or has untracked files; use a clean $PINNED_SOURCE checkout" >&2 + exit 2 +fi + +BIN=$W/build/compiler/test_osc_compiler +if [ ! -x "$BIN" ]; then + echo "omega-slices: compiler binary missing; build it with: make -C '$W' build/compiler/test_osc_compiler" >&2 + make -C "$W" build/compiler/test_osc_compiler +fi +if [ ! -x "$BIN" ]; then + echo "omega-slices: compiler binary still missing after the build: $BIN" >&2 + exit 2 +fi +BIN_SHA=$(sha256sum "$BIN" | awk '{print $1}') +printf 'omega harness source=%s binary_sha256=%s\n' "$SOURCE" "$BIN_SHA" + T=$(mktemp -d) -trap 'rm -rf "$T"' EXIT +trap 'rm -rf "$T"' EXIT HUP INT TERM mkdir -p "$T/slices" ln -s "$W/tests/compiler/progs" "$T/progs" ln -s "$W/tests/compiler/neg" "$T/neg" for f in $SLICES; do cp "$R/omega/slices/$f" "$T/slices/"; done cd "$W" -./build/compiler/test_osc_compiler "$FUZZ" "$T" +"$BIN" "$FUZZ" "$T" diff --git a/tests/omega/test-arch-guard.sh b/tests/omega/test-arch-guard.sh new file mode 100755 index 00000000..da5f8e95 --- /dev/null +++ b/tests/omega/test-arch-guard.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Run the production architecture refusal. On AArch64 this row is NOT_RUN: +# the binary is not executed, so a device is not opened. A cross compile is +# not a runtime result. +set -eu +host=${TARGET_ARCH:-$(uname -m)} +case "$host" in + aarch64|arm64) + echo "x86-64 production refusal: NOT_RUN (this host is $host; the check runs on x86-64 Linux and does not open a device)" + exit 0 + ;; +esac +bin=${1:?architecture-guard binary} +if [ "${CROSS_COMPILE_ONLY:-0}" = 1 ]; then + echo "x86-64 production refusal: NOT_RUN (cross compile only, binary $bin)" + exit 0 +fi +[ -x "$bin" ] || { + echo "x86-64 production refusal: binary is missing or not executable: $bin" >&2 + exit 1 +} +"$bin" diff --git a/tests/omega/test-barrier-contract.sh b/tests/omega/test-barrier-contract.sh new file mode 100755 index 00000000..bf87d1af --- /dev/null +++ b/tests/omega/test-barrier-contract.sh @@ -0,0 +1,112 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# The production barrier is dsb sy on AArch64 and a real fence on other hosts. +# A raw dsb sy outside an __aarch64__ region fails this check. A fixture with +# an unguarded dsb sy is the negative control. +set -eu +R=$(cd "$(dirname "$0")/../.." && pwd) +T=$(mktemp -d) +trap 'rm -rf "$T"' EXIT HUP INT TERM +fail() { echo "barrier-contract: $*" >&2; exit 1; } + +# shellcheck disable=SC2016 +scan() { + awk ' + function in_aarch64( i) { + for (i = 1; i <= sp; i++) if (st[i]) return 1 + return 0 + } + /^[[:space:]]*#[[:space:]]*if/ { + sp++ + st[sp] = ($0 ~ /__aarch64__/) ? 1 : 0 + next + } + /^[[:space:]]*#[[:space:]]*else/ { + if (sp >= 1) st[sp] = st[sp] ? 0 : 1 + next + } + /^[[:space:]]*#[[:space:]]*elif/ { + if (sp >= 1) st[sp] = ($0 ~ /__aarch64__/) ? 1 : 0 + next + } + /^[[:space:]]*#[[:space:]]*endif/ { + if (sp >= 1) sp-- + next + } + /__asm__ volatile\("dsb sy"/ { + if (!in_aarch64()) { + printf "%s:%d: dsb sy is outside #if defined(__aarch64__)\n", FILENAME, FNR + bad = 1 + } + } + END { exit bad ? 1 : 0 } + ' "$@" +} + +hdr=$R/nvrm/cpu_barrier.h +[ -f "$hdr" ] || fail "missing $hdr" +awk ' + /#if defined\(__aarch64__\)/ { arm=1; other=0; next } + /#else/ { if (arm) { arm=0; other=1 } next } + /#endif/ { arm=0; other=0; next } + arm && /dsb sy/ { saw_dsb=1 } + other && /__atomic_thread_fence\(__ATOMIC_SEQ_CST\)/ { saw_fence=1 } + other && /\(void\)0/ { saw_nop=1 } + END { + if (!saw_dsb) { print "AArch64 branch has no dsb sy"; exit 1 } + if (!saw_fence) { print "portable branch has no seq_cst fence"; exit 1 } + if (saw_nop) { print "portable branch contains (void)0"; exit 1 } + } +' "$hdr" || fail "nvrm/cpu_barrier.h broke the production split" +grep -q 'nvrm_cpu_barrier();' "$R/src/omega_blackwell_engine.c" || fail "engine does not call nvrm_cpu_barrier" +grep -q 'nvrm_cpu_barrier();' "$R/src/omega_blackwell_submit.c" || fail "submit does not call nvrm_cpu_barrier" + +set -- +for dir in src nvrm m16; do + for f in $(find "$R/$dir" -type f \( -name '*.c' -o -name '*.h' \)); do + set -- "$@" "$f" + done +done +scan "$@" || fail "tree has an unguarded dsb sy" + +printf '%s\n' '__asm__ volatile("dsb sy" ::: "memory");' > "$T/unguarded.c" +if scan "$T/unguarded.c" >"$T/neg.log" 2>&1; then + fail "negative control accepted an unguarded dsb sy" +fi +grep -q 'outside #if defined(__aarch64__)' "$T/neg.log" || fail "negative control diagnostic" +printf '%s\n' '#if defined(__aarch64__)' '__asm__ volatile("dsb sy" ::: "memory");' '#endif' > "$T/guarded.c" +scan "$T/guarded.c" || fail "guarded fixture was rejected" + +cat > "$T/use.c" < "$T/use.s" +host=$(uname -m) +case "$host" in + x86_64) + grep -Eq 'mfence|[[:space:]]lock[[:space:]]' "$T/use.s" || fail "x86-64 object has no hardware fence" + if grep -q 'dsb' "$T/use.s"; then fail "x86-64 object contains dsb"; fi + echo "barrier codegen: PASS ($host seq_cst fence, no dsb)" + ;; + aarch64|arm64) + grep -Eq 'dsb[[:space:]]+sy' "$T/use.s" || fail "AArch64 object has no dsb sy" + echo "barrier codegen: PASS ($host dsb sy)" + ;; + *) + echo "barrier codegen: NOT_RUN (host is $host; source contract still checked)" + ;; +esac + +if command -v aarch64-linux-gnu-gcc >/dev/null 2>&1 && command -v aarch64-linux-gnu-objdump >/dev/null 2>&1; then + aarch64-linux-gnu-gcc -std=gnu11 -Wall -Wextra -Werror -c -I"$R/nvrm" -o "$T/use-arm.o" "$T/use.c" + aarch64-linux-gnu-objdump -d "$T/use-arm.o" > "$T/use-arm.s" + grep -Eq 'dsb[[:space:]]+sy' "$T/use-arm.s" || fail "AArch64 cross object has no dsb sy" + echo "barrier codegen: PASS (aarch64-linux-gnu-gcc cross compile emits dsb sy)" +elif [ "$host" != aarch64 ] && [ "$host" != arm64 ]; then + echo "AArch64 barrier codegen: NOT_RUN (aarch64-linux-gnu-gcc is not installed; source contract checked)" +fi + +echo "barrier-contract: PASS" diff --git a/tests/omega/test-binding-portable.sh b/tests/omega/test-binding-portable.sh new file mode 100755 index 00000000..cb5597dd --- /dev/null +++ b/tests/omega/test-binding-portable.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Revision and epoch vectors. On AArch64 they link the committed freestanding +# units. On any other host they link the portable stand-in, and one seeded +# entry must refuse without writing its result. +set -eu +ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) +cd "$ROOT" +OUT_DIR=${OUT_DIR:-build} +mkdir -p "$OUT_DIR" +host=$(uname -m) +cc=${CC:-gcc} +if [ "$host" = aarch64 ] || [ "$host" = arm64 ]; then + src=src/cudapp_freest_units.c + def= +else + src=src/cudapp_binding_portable.c + def=-DBINDING_PORTABLE +fi +"$cc" -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc $def \ + -o "$OUT_DIR/binding_portable_test" tests/omega/binding_portable_test.c "$src" +"$OUT_DIR/binding_portable_test" diff --git a/tests/omega/test-runner.sh b/tests/omega/test-runner.sh new file mode 100755 index 00000000..d2aa8e74 --- /dev/null +++ b/tests/omega/test-runner.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Refusal paths for tests/omega/run.sh. No compiler checkout is required. +set -eu +R=$(cd "$(dirname "$0")/../.." && pwd) +T=$(mktemp -d) +trap 'rm -rf "$T"' EXIT HUP INT TERM +fail() { echo "omega-runner-test: $*" >&2; exit 1; } +PIN=$(sed -n 's/^PINNED_SOURCE=//p' "$R/tests/omega/run.sh") +[ -n "$PIN" ] || fail "run.sh does not set PINNED_SOURCE" + +# A fresh checkout has no compiler harness configured. +if env -u OMEGA_OSC_COMPILER_DIR "$R/tests/omega/run.sh" >"$T/missing.log" 2>&1; then + fail "missing harness unexpectedly passed" +fi +grep -q 'compiler harness not configured' "$T/missing.log" || fail "missing harness diagnostic" +grep -q "$PIN" "$T/missing.log" || fail "missing harness did not name the pinned commit" + +# A missing named slice is reported before a compiler checkout is required. +mkdir -p "$T/missing/tests/omega" "$T/missing/omega/slices" +cp "$R/tests/omega/run.sh" "$T/missing/tests/omega/run.sh" +for f in doorbell.osc sequencer.osc nvrm.osc va.osc open_plan.osc kmod.osc mesa.osc; do + : >"$T/missing/omega/slices/$f" +done +if "$T/missing/tests/omega/run.sh" >"$T/slice.log" 2>&1; then + fail "missing named slice unexpectedly passed" +fi +grep -q 'missing required slice .*launch.osc' "$T/slice.log" || fail "missing-slice diagnostic" + +# A checkout at another commit fails with the expected and found revisions. +mkdir -p "$T/wrong/tests/omega" "$T/wrong/omega/slices" "$T/harness" +cp "$R/tests/omega/run.sh" "$T/wrong/tests/omega/run.sh" +cp "$R"/omega/slices/*.osc "$T/wrong/omega/slices/" +env -u GIT_DIR -u GIT_WORK_TREE git -C "$T/harness" init -q +env -u GIT_DIR -u GIT_WORK_TREE git -C "$T/harness" \ + -c user.name=test -c user.email=test@example.invalid -c commit.gpgsign=false \ + commit --allow-empty -qm wrong-pin +if env -u GIT_DIR -u GIT_WORK_TREE OMEGA_OSC_COMPILER_DIR="$T/harness" \ + "$T/wrong/tests/omega/run.sh" >"$T/version.log" 2>&1; then + fail "wrong harness source unexpectedly passed" +fi +grep -q "wrong harness source .*expected $PIN" "$T/version.log" || fail "wrong-version diagnostic" + +echo "omega-runner-test: PASS (missing harness, missing slice, wrong source pin)" diff --git a/tests/omega/test-target-only.sh b/tests/omega/test-target-only.sh new file mode 100755 index 00000000..d4c8dce3 --- /dev/null +++ b/tests/omega/test-target-only.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Report host checks that this machine does not run. Exit 0 means the report +# was printed. It is not a pass of those checks. Invoking one of them directly +# exits 2. +set -eu +host=$(uname -m) +if [ "$host" = aarch64 ] || [ "$host" = arm64 ]; then + echo "target-only report: NOT_RUN (this host is $host; make test runs the seeded binding and the pinned-compiler rows)" + exit 0 +fi +cat < +#include +#include + +#if !defined(__aarch64__) +static int refuse_ok(const char *what, int rc) +{ + if (rc == 0 || errno != ENOTSUP) { + fprintf(stderr, "%s: expected ENOTSUP, rc=%d errno=%d\n", what, rc, errno); + return 1; + } + return 0; +} +#endif + +int main(void) +{ +#if defined(__aarch64__) + puts("x86-64 production refusal: NOT_RUN (this binary is AArch64; production barriers stay dsb sy; device open is not attempted)"); + return 0; +#else + const OmegaGpuBackend *b = omega_blackwell_engine_backend(); + OmegaGpuBackendDiag d; + int failed = 0; + + fake_reset(); + errno = 0; + int rc = b->open_device(b->ctx); + memset(&d, 0, sizeof d); + b->diagnostics(b->ctx, &d); + if (rc == 0 || errno != ENOTSUP || d.drv_rc == 0 || + strstr(d.drv_text, "requires AArch64 Linux") == NULL) { + fprintf(stderr, "architecture guard failed: rc=%d errno=%d drv_rc=%d text=%s\n", + rc, errno, d.drv_rc, d.drv_text); + failed = 1; + } + if (fk.open_calls != 0 || fk.alloc_calls != 0 || fk.submit_calls != 0) { + fprintf(stderr, "architecture guard entered the driver: open=%d alloc=%d submit=%d\n", + fk.open_calls, fk.alloc_calls, fk.submit_calls); + failed = 1; + } + if (!failed) puts("Blackwell backend refusal: ENOTSUP, requires AArch64 Linux, driver not entered"); + + errno = 0; + failed |= refuse_ok("direct vector path", + omega_blackwell_execute_vector(NULL, NULL, NULL, NULL, NULL, NULL)); + errno = 0; + failed |= refuse_ok("direct matmul path", + omega_blackwell_execute_matmul(NULL, NULL, NULL, NULL, NULL, NULL)); + errno = 0; + failed |= refuse_ok("direct tensor matmul path", + omega_blackwell_execute_matmul_tensor(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)); + if (fk.open_calls != 0) { + fprintf(stderr, "direct paths entered the driver: open=%d\n", fk.open_calls); + failed = 1; + } + if (!failed) puts("direct Blackwell entry points: ENOTSUP"); + return failed ? 1 : 0; +#endif +} diff --git a/tools/gpu_engine_backend_mutations.sh b/tools/gpu_engine_backend_mutations.sh index 6bbc6be0..90f90980 100755 --- a/tools/gpu_engine_backend_mutations.sh +++ b/tools/gpu_engine_backend_mutations.sh @@ -36,8 +36,18 @@ PHYS=$(cd "${PHYSICS_DIR:-../physics}" 2>/dev/null && pwd -P) || { } TP=$PHYS/third_party/nvidia-open-580.173.02 INC="-I$PHYS/m16 -I$PHYS/nvrm -I$TP/src/common/sdk/nvidia/inc -I$TP/kernel-open/common/inc -I$TP/kernel-open/nvidia-uvm -I$TP/src/nvidia/arch/nvalloc/unix/include" -SRCS="src/omega_blackwell_submit.c src/omega_blackwell_engine.c src/omega_gpu_engine.c src/omega_blackwell_matmul.c src/omega_blackwell_codegen.c src/cudapp_om_units.c src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c src/omega_blackwell_realize.c src/omega_vector.c src/omega_core.c src/omega_canonical.c src/sha256.c" -BUILD="gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffunction-sections -fdata-sections -Isrc -Itests $INC -o .gpu_engine_bt tests/test_omega_blackwell_engine.c tests/fake_m16_native.c $SRCS -Wl,--gc-sections -lm" +case $(uname -m) in +aarch64|arm64) + BIND_SRC=src/cudapp_om_units.c + PORTABLE_DEFS= + ;; +*) + BIND_SRC=src/cudapp_binding_portable.c + PORTABLE_DEFS="-DCUDAPP_MIGRATION_PENDING_C_ENCODER -DCUDAPP_MIGRATION_PENDING_C_CUBIN" + ;; +esac +SRCS="src/omega_blackwell_submit.c src/omega_blackwell_engine.c src/omega_gpu_engine.c src/omega_blackwell_matmul.c src/omega_blackwell_codegen.c $BIND_SRC src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c src/omega_blackwell_realize.c src/omega_vector.c src/omega_core.c src/omega_canonical.c src/sha256.c" +BUILD="gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -DOMEGA_BLACKWELL_HOST_SIMULATOR -pthread -ffunction-sections -fdata-sections $PORTABLE_DEFS -Isrc -Itests $INC -o .gpu_engine_bt tests/test_omega_blackwell_engine.c tests/fake_m16_native.c $SRCS -Wl,--gc-sections -lm" OUT=${GPU_ENGINE_BMUT_OUT:-} set -- -k table -m - -t ./.gpu_engine_bt -b "$BUILD" \ @@ -113,7 +123,7 @@ BE_FLUSH_OP_DROPPED~src/omega_blackwell_engine.c~R:pb_put(c, 0x10u << 27);@>@pb_ BE_FLUSH_METHOD_CHANGED~src/omega_blackwell_engine.c~R:pb_put(c, nvrm_mthd(0, 0x0028, 4));@>@pb_put(c, nvrm_mthd(0, 0x002c, 4));~the flush uses the memory-operation method BE_WFI_FLAG_RELEASE1~src/omega_blackwell_engine.c~/pb_put(c, OMEGA_BW_MARKER_COMPLETION_PAYLOAD);/,+2 s/0x1u | (1u << 20)/0x1u/~the first release waits for idle (WFI) BE_WFI_FLAG_RELEASE2~src/omega_blackwell_engine.c~/pb_put(c, BE_MARKER2_PAYLOAD);/,+2 s/0x1u | (1u << 20)/0x1u/~the second release waits for idle (WFI) -BE_BARRIER_IN_BUILD~src/omega_blackwell_engine.c~/^static int be_build/,/^}/ s/__asm__ volatile("dsb sy" ::: "memory");/(void)0;/~dsb sy after zeroing the sync words~redundant~a CPU barrier instruction has no effect a host test can observe (the fake driver runs on the same core); it is verified on the chip only (Phase B) +BE_BARRIER_IN_BUILD~src/omega_blackwell_engine.c~/^static int be_build/,/^}/ s/nvrm_cpu_barrier();/(void)0;/~CPU barrier after zeroing the sync words~redundant~a CPU barrier instruction has no effect a host test can observe (the fake driver runs on the same core); it is verified on the chip only (Phase B) BE_QMD_RELEASE_CHECK~src/omega_blackwell_engine.c~R:if (qmd1_words[9] != 3u ||@>@if (0 ||~extra QMD1 release-word checks~redundant~the real descriptor builder always produces these words (src/omega_blackwell_qmd.c), so no input makes the check fire; it guards a future change of the builder, which tests/test_omega_blackwell_qmd.c style checks cover BE_PB_OVERFLOW~src/omega_blackwell_engine.c~R:if (c->pb_overflow) {@>@if (0) {~pushbuffer word-capacity guard~redundant~the vector pushbuffer is a fixed 492 words against a 1024-word capacity, so it cannot overflow for any job # ---- submit, waits, diagnostics ------------------------------------------------------ ```