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
CUDApp / om / codegen / TERN.md
| 1 | # Seeded Omega ternary IR builder |
| 2 | |
| 3 | The default implementation of `omega_blackwell_codegen_tern.c` is seeded Omega. |
| 4 | `CUDAPP_MIGRATION_PENDING_C_CODEGEN_TERN=1` selects the retained C differential |
| 5 | oracle. The switch is private to the C file. The public header and API are unchanged. |
| 6 | |
| 7 | ## Units and host boundary |
| 8 | |
| 9 | - `cg_tern_common.om`: the accepted configuration domain and coalesced-output policy. |
| 10 | - `cg_tern.om`: allocation requests, instruction construction, branch patching, |
| 11 | nested loop intervals, all layout/depth/chunk/epilogue/mutant variants, and the |
| 12 | existing generic eight-word replay format. |
| 13 | - `cg_tern_policy.om`: the public shape, staging, and packed-word-offset queries. |
| 14 | - `cg_tern_sched.om`: fixed-latency scheduling over allocated physical register |
| 15 | spans, branch target timing, and the I2FP consumer checker. Scheduling happens |
| 16 | after generic replay/register allocation, as it did in the C oracle. |
| 17 | |
| 18 | The C shell performs API/null handling and memory serialization. Register |
| 19 | allocation and record replay use `omega_gpu_om_ir_replay`; there is no second IR |
| 20 | replay convention. The scheduler's separate temporary view contains opcode, |
| 21 | control, immediate, destination and three sources in eight-word records. Its |
| 22 | map view contains physical register numbers followed by bundle widths. These |
| 23 | are a private scheduling view, not another construction/replay protocol. |
| 24 | |
| 25 | The builder's explicit state-slot notes name every retained scalar and array. |
| 26 | Phase `pN` corresponds to top-level statement N after the C oracle's entry guard; |
| 27 | phases are split only to satisfy the seeded compiler's live-name bound. The |
| 28 | flat state preserves the original interleaved allocation and instruction order. |
| 29 | In particular, wide-register allocation is conditional, not an eagerly evaluated |
| 30 | choice between two allocation calls. Signed immediates are truncated to their |
| 31 | 32-bit record field before packing the adjacent control word. |
| 32 | |
| 33 | ## Verification |
| 34 | |
| 35 | Use the pinned compiler and bridge already checked by `om/units.sh`. Run host, |
| 36 | simulator, differential and mutant gates in the device-free namespace below. |
| 37 | A missing device node is a host-path defect to fix, not permission to rerun |
| 38 | without the wrapper. |
| 39 | |
| 40 | ```sh |
| 41 | export OMEGA_OMC=/path/to/omega-mv/seed/out/omc |
| 42 | export OMEGA_BRIDGE=/path/to/omega-bridge |
| 43 | export OMEGA_MV=/path/to/omega-mv |
| 44 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 sh om/units.sh --check |
| 45 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 make -j3 test-codegen-tern-diff |
| 46 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 python3 om/codegen/tern_mutants.py |
| 47 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 make -j3 test-codegen-tern-sim |
| 48 | ``` |
| 49 | |
| 50 | The differential includes the independent C oracle in the test translation |
| 51 | unit. It enumerates the entire finite accepted configuration domain, including |
| 52 | all shipped mutation selectors, and compares emitted IR, register allocation, |
| 53 | encoded instruction bytes, public policies, and I2FP checker results. Expected |
| 54 | builder refusals remain refusals; a refusal is not an emitted kernel. A deliberately |
| 55 | flipped Omega output record must be detected independently of source mutation. |
| 56 | |
| 57 | The source-mutation gate changes Omega, regenerates it through the seeded bridge, |
| 58 | and requires the differential to kill each compiled mutant. Its point set spans |
| 59 | both layouts, gathered and direct output, integer and float epilogues, shallow and |
| 60 | deep staging, and chunked input. Temporary mutated sources/C/binaries are deleted. |
| 61 | Python and the retained C/algebra oracle are verification tools, not production |
| 62 | implementations or new build/runtime dependencies. |
| 63 | |
| 64 | The simulator target combines the pinned Omega ternary/algebra battery with |
| 65 | CUDApp's current `bw_warp_sim_k.h`. CUDApp's simulator honors scalar LDG immediate |
| 66 | offsets; the older simulator at the pinned Omega revision does not. The adapter |
| 67 | pre-includes the current simulator and calls only the simulator battery, while |
| 68 | the linker discards the original device-capable entry point. |
| 69 | |
| 70 | PR #229 was inspected before migration. Its ternary-header change only corrects |
| 71 | the QMD staging-cap comment from 32 KiB to 64 KiB. It changes no builder-read |
| 72 | field or accepted configuration. The untouched public header therefore supports |
| 73 | either merge order; the exhaustive builder domain is the same in both cases. |
| 74 | |
| 75 | ## Qualification boundary |
| 76 | |
| 77 | Host byte equality and warp-simulator parity are not GB10 qualification. No GPU |
| 78 | window is granted to this lane. In a separately authorized exclusive window, |
| 79 | first run the integrated CUDApp host and simulator gates, then use Omega's |
| 80 | existing `tests/gpu_tern_test.c` chip battery against a binary linked to the |
| 81 | integrated CUDApp library. Record the exact CUDApp/Omega revisions and binary |
| 82 | hash, run its correctness and shipped mutant controls before bandwidth, and save |
| 83 | its final verdict/receipt. Never run the pinned Omega checkout's old C builder |
| 84 | and call that qualification of this migration. Do not change live services, |
| 85 | chip locks, driver state or boot configuration as part of this host-only work. |
| 86 | Device access for an eventual chip battery requires its own explicit |
| 87 | authorization; this lane does not disable or bypass the host-test namespace. |