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
omega-mv / bridge / nvml / README.md
| 1 | # bridge/nvml: the NVML library files of CUDApp `compat/`, as derived files |
| 2 | |
| 3 | One slice of CUDApp `compat/` (CUDApp commit `84b524cadaaa8bc9b556adfaea9d6dd2e0d67a66`): its |
| 4 | `compat/nvml/` directory. The three files there that are C or linker script, `libnvidia-ml.c`, |
| 5 | `nvml.h` and `libnvidia-ml.map`, are not written by hand. CUDApp makes them with omega-bridge from |
| 6 | the Omega library unit that this tree already holds, `gpu/nvidia/native/nvml/api.om`: |
| 7 | |
| 8 | tools/bridge-seeded lib-c native/nvml/api.om > compat/nvml/libnvidia-ml.c |
| 9 | tools/bridge-seeded lib-h native/nvml/api.om > compat/nvml/nvml.h |
| 10 | tools/bridge-seeded lib-map native/nvml/api.om > compat/nvml/libnvidia-ml.map |
| 11 | |
| 12 | So this tree does not store them. `derived.tsv` lists each one with its mode, its source and the |
| 13 | SHA-256 of the source, of the generator and of the output, and the gate shows that the generator, |
| 14 | compiled by this tree's `seed/out/omc`, makes those bytes from this tree's source. |
| 15 | |
| 16 | ## Files |
| 17 | |
| 18 | - `derived.tsv`: the table. Its header comment explains the columns and names the two generators |
| 19 | by omega-bridge commit. |
| 20 | - `gate.om`: the gate, seeded Omega, built with `seed/ng/sha256.om` in front of it. Usage: |
| 21 | `gate SCRATCH OMC TABLE [toc=TOC]... [cudapp=CUDAPP]...`. It prints one line per check and a |
| 22 | summary `BRIDGE-NVML PASS|FAIL checks=N failed=F emitter=… oracle=…`; exit 0 PASS, 1 FAIL, |
| 23 | 2 usage or setup. |
| 24 | |
| 25 | ## Running it |
| 26 | |
| 27 | tests/gates/run.sh bridge-nvml |
| 28 | |
| 29 | The step checks `seed/out/omc` against `seed/out/omc.sha256`, builds the gate and runs it. Tiers: |
| 30 | |
| 31 | - Default: the table is well formed, every source has its pinned digest, and every source compiles |
| 32 | with `seed/out/omc`. Emitter and oracle are `NOT_RUN`. |
| 33 | - Emitter, with `BRIDGE_NVML_TOC` set to one or more omega-bridge `src/toc.om` paths separated by |
| 34 | `:`. For each, the gate refuses a file whose SHA-256 is not a generator in the table, compiles it |
| 35 | with `seed/out/omc`, sends it every row of its generator (the request is the mode letter, the |
| 36 | source, and a line with the generator's and the source's digests, with `toc.om` on descriptor 3) |
| 37 | and requires the output to have the pinned digest. |
| 38 | - Oracle, with `BRIDGE_NVML_CUDAPP` set to a CUDApp checkout at `84b524ca`: each row that names a |
| 39 | CUDApp file requires that file to have the pinned output digest. |
| 40 | |
| 41 | Controls, run by the step: a table with one source digest changed (always caught); with |
| 42 | `BRIDGE_NVML_TOC`, `api.om` with one error value changed and its digest re-pinned in a copy of the |
| 43 | table, so only the emitted bytes can catch it; and the first `toc.om` with one line added, which |
| 44 | must be refused as not a generator. |
| 45 | |
| 46 | ## What is not in this tree, and why |
| 47 | |
| 48 | - The generator. omega-bridge is its own repository, so its `src/toc.om` is an input to the gate, |
| 49 | pinned by digest, and not a copy here. CUDApp's bytes come from `src/toc.om` at omega-bridge |
| 50 | commit `f6b7cc4042bdf55d8f9d866c97439bb7e53506f5` ("cabi-1: C ABI library emitter"), which is |
| 51 | on omega-bridge `main`: it is an ancestor of `0138839cc3e7aef1c77230505f757372b8ae6ad5`. The |
| 52 | `src/toc.om` of `0138839c` makes the same three files except for line 1, where the emitter |
| 53 | writes its own digest; the table pins both. In any clone of omega-bridge `main`, both |
| 54 | generators come out of history: |
| 55 | |
| 56 | git -C OMEGA_BRIDGE show f6b7cc4042bdf55d8f9d866c97439bb7e53506f5:src/toc.om > toc-cabi1.om |
| 57 | git -C OMEGA_BRIDGE show 0138839cc3e7aef1c77230505f757372b8ae6ad5:src/toc.om > toc-main.om |
| 58 | BRIDGE_NVML_TOC="$PWD/toc-cabi1.om:$PWD/toc-main.om" tests/gates/run.sh bridge-nvml |
| 59 | |
| 60 | - A launcher in Omega. The emitter reads `toc.om` from descriptor 3, and this compiler's exec |
| 61 | words close every descriptor from 3 up, so the gate starts the emitter through |
| 62 | `/bin/sh -c 'exec "$0" 3<"$1"'`. An exec word that keeps a chosen descriptor open would remove |
| 63 | the shell. |
| 64 | - The library. Turning `libnvidia-ml.c` into `libnvidia-ml.so.1` needs a C compiler; omc does not |
| 65 | yet write a shared object. `bridge/cuda/EXTENSION-PROPOSAL.md` describes the compiler change. |
| 66 | - Hardware. Nothing here opens a device; loading the library and calling it on a GPU is not run. |