interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / om / codegen / TERN.md

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