interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / bridge / cuda / README.md

79 lines · 7943 bytes Raw Blame History Rendered
1# bridge/cuda: the CUDA compatibility profile slice, in Omega
2
3This directory is one slice of CUDApp's `compat/` (CUDApp main `84b524ca`): the CUDA compatibility
4profile of `compat/cuda/`, written only in Omega. It decides whether one CUDA application, built by
5an ordinary C compiler, uses exactly the CUDA surface we have frozen for it, and nothing more. It
6never runs that application and never opens a GPU. The NVML part of `compat/` is not in this slice
7(below).
8
9## What the old directory did
10
11CUDApp `compat/` held C files, shell scripts and a set of tables.
12
13| Old file | What it does | Where it is now |
14|---|---|---|
15| `compat/cuda/fixture/vadd_drv.c` | A small CUDA Driver API program written as the test subject: one context, one PTX module, three buffers, one kernel launch, and a check of the result on the host. | Stays in CUDApp. It is the foreign application under test, not part of Omega; the gate's oracle tier compiles it with gcc outside the tree. |
16| `compat/nvml/libnvidia-ml.c` (with `nvml.h`, `libnvidia-ml.map`) | A replacement for part of NVIDIA's monitoring library. It is generated C, emitted by the omega-bridge C-ABI emitter from the Omega unit that is already in this tree as `gpu/nvidia/native/nvml/api.om`. | Not copied: the Omega source is already here. The C exists only because `omc` cannot yet emit a shared library; see `EXTENSION-PROPOSAL.md`. |
17| `compat/cuda/build.sh` | Builds the test program for AArch64 and x86-64 with gcc. To link it, it makes a placeholder `libcuda.so.1` that defines every `cu*` name the program uses as 0, with no code. | The placeholder library is written by `fixture.om` (mode `stub`), byte-exact with what `ld` makes, so the old gcc build linked against it gives the same executables. The gcc compile itself stays outside, run by the gate's oracle tier. |
18| `compat/cuda/test.sh` | Rebuilds twice and requires the same bytes, checks the three profile generations list the same CUDA calls, admits both current profiles, then makes broken variants and requires each to be refused. | `gate.om`, with the same checks in the same order and two differences: "rebuild twice with gcc" becomes "synthesize twice with `fixture.om`", and the two "built ISA" lines (transcript lines 1 and 2, which name gcc's executable hashes) are not reproduced; only the oracle tier compares them. |
19| `compat/cuda/fixture/vadd_u32.ptx` | The GPU kernel (a vector add), written by hand in PTX. | Inside `fixture.om` (mode `ptx`), written out byte for byte; the gate checks its SHA-256 against the profiles. |
20| `compat/cuda/profile-c0-{aarch64,x86_64}-v{1,2,3}.tsv` | The frozen profiles: which libraries, versioned C symbols, CUDA calls, PTX instructions and file hashes are allowed. v3 is current; v1 and v2 are kept unchanged as history. | Here, byte for byte (same git blob ids), pinned by `copied.tsv`. |
21| `compat/cuda/c0_check.om` | The checker that reads a profile, an executable and a PTX file and admits or refuses. Already Omega. | Here, unchanged, pinned by `copied.tsv`. |
22
23## Files
24
25| File | Role |
26|---|---|
27| `c0_check.om` | The checker: `c0_check check PROFILE EXE PTX RUNISA` (exit 0 admitted, 1 refused) and `c0_check emit PROFILE EXE PTX` (prints what it read). Build: `cat gpu/nvidia/om/cache/digest.om bridge/cuda/c0_check.om \| seed/out/omc`. |
28| `fixture.om` | Writes the test inputs. `fixture ptx OUT` writes the kernel. `fixture stub PROFILE OUT` writes the link-only `libcuda.so.1` for the profile's ISA, with its symbol table in the order GNU `ld` uses (GNU-hash bucket, then ld's own hash slot), which is what makes gcc's link reproduce the frozen hashes. `fixture exe TABLE PROFILE full\|nolib OUT` writes a small executable that the checker reads exactly as it reads gcc's (built from a `fixture-*.tsv` table), so the gate does not need a C compiler. Build: `seed/out/omc < bridge/cuda/fixture.om`. |
29| `fixture-aarch64.tsv`, `fixture-x86_64.tsv` | What `c0_check emit` reads from the real gcc executables. They are derived, not typed: the gate's oracle tier recomputes them from gcc's output and refuses any difference. |
30| `copied.tsv` | SHA-256 and name of each file copied unchanged from CUDApp `compat/cuda/` (the profiles and `c0_check.om`). Made by `sha256sum` over the CUDApp files, not typed. Every run checks the files here against it; the oracle tier checks the CUDApp files against it, so a stale table or an edited copy fails. |
31| `gate.om` | The gate (below). Build: `{ printf 'om2\n'; cat seed/ng/sha256.om bridge/cuda/gate.om; } \| seed/out/omc`. |
32| `test-sh-84b524ca.txt` | The output of CUDApp's `test.sh` at `84b524ca`, run with omc `2c824805`. The gate's own transcript must equal it from line 3 on. Lines 1 and 2 are the gcc build hashes, which only the oracle tier can reproduce: an edit of lines 1 or 2 is caught only by the oracle tier, never by a default run. |
33| `EXTENSION-PROPOSAL.md` | What `omc` would need to emit the NVML library itself. |
34
35## The gate
36
37`tests/gates/run.sh bridge-cuda` (manifest `tests/gates/omega-bridge-cuda.gate`) builds the three
38programs with the in-tree `seed/out/omc` after checking its digest, and runs:
39
40`gate SCRATCH C0CHECK FIXTURE [CUDAPP OLDOMC CC_AARCH64 CC_X86_64]`
41
42Always, with no C compiler: writes the PTX; synthesises each executable twice and requires the
43same bytes; requires the checker to read them as the `fixture-*.tsv` tables; checks the no-libcuda
44variant has no CUDA import; pins copies of the v3 profiles to the synthetic hashes; checks the
45v1/v2/v3 CUDA import lists are equal; admits both profiles; and refuses the broken variants of
46`test.sh` (wrong ISA, wrong executable, edited hash, dropped or added import, unsupported status,
47wrong schema, libc floor, `dlsym`-style lookup, missing library, missing libcuda, barrier and
48two-statement PTX). The lines it records must equal `test-sh-84b524ca.txt` from line 3. It then
49checks the import-list limit at its edge (below) and the `copied.tsv` digests.
50
51With `BRIDGE_CUDA_CUDAPP` (a CUDApp checkout at `84b524ca`) and `BRIDGE_CUDA_OLDOMC` (omc
52`2c824805…`) set, it also runs the old `test.sh` and requires its whole output to equal the
53stored file, lines 1 and 2 included; links gcc's objects against the Omega `libcuda.so.1` stub
54and requires the frozen v3 executable hashes; requires the checker's reading of gcc's executables
55to equal the `fixture-*.tsv` tables; and requires CUDApp's own `compat/cuda` files to have the
56`copied.tsv` digests. Only this tier shows that gcc links against the stub to the frozen
57executables. The log of the last oracle run (fresh clone of this branch, `oracle=PASS`) is kept
58outside the repository by the lane and named in the landing receipt; it is identified by its
59sha256, `659277abfd5fa20d661fadda82d6f623e6e83f35d7aadc26a3bf47af3227e69f`.
60
61The run then rebuilds `c0_check` with its "missing row" refusal removed and requires the gate to
62fail with it. The last line is `BRIDGE-CUDA PASS checks=N failed=0 oracle=NOT_RUN|PASS
63hardware=NOT_RUN`; `run.sh` pins N for each tier.
64
65| Tier | Verdict |
66|---|---|
67| Admission and refusal on synthetic executables | gated, every run |
68| Old `test.sh`, gcc builds against the Omega stub | gated when the oracle inputs are given |
69| Running the kernel on a GPU (`VADD_U32 PASS n=4099 …`) | NOT_RUN |
70
71## Limits
72
73The checker refuses, rather than truncates, a profile or PTX over 64 KiB and an executable over
741 MiB (exit 3), as the C-era checker did. The fixture writer and the gate refuse files of 16 MiB
75or more. The gate reads the three profile versions of one ISA into one 16 MiB buffer, so that is
76the limit that binds the import comparison: every run writes three versions totalling one byte
77under 16 MiB, which must be read and compared, and exactly 16 MiB, which must be refused. The same
78check requires that 16 MiB divided by the shortest indexed import row is under the size of the
79name table behind it, so the table cannot fill under that buffer.