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 / tests / codegen_base / README.md

122 lines · 11237 bytes Raw Blame History Rendered
1# Base codegen and common IR replay migration
2
3Source baseline: CUDApp #309, `63d18a2cc92cb05f800d17e46b35f0cd6237b3b0`.
4The seeded compiler is omega-mv `e5b32567`, SHA-256
5`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`.
6Registration was committed before caller cutover (`79de6f9`).
7
8The production entry remains `omega_gpu_om_ir_replay`. No opcode was added.
9The baseline ends at `BW_IR_ATOMG_ADD_F32_STRONG_GPU`; #312's separately
10stacked f64 extension ends at 78, leaving 79 unused. When combining #312,
11the replay admission call must receive its `BW_IR_LAST` rather than the
12baseline enum maximum. This branch does not silently import that other PR.
13
14## Every function in the two target files
15
16Names in each row are exhaustive, including guarded alternate definitions.
17“Already ported” refers to the default hosted path, not a claim that the
18existing freestanding migration oracle has been removed. Verification
19oracles remain independent C; they are not production implementations.
20
21| Functions | Classification | Implementation / reason |
22|---|---|---|
23| `omega_bw_ir_alloc_vreg`, `omega_bw_ir_alloc_vreg64`, `omega_bw_ir_alloc_vreg128`, `omega_bw_ir_alloc_uvreg`, `omega_bw_ir_alloc_uvreg64`, `omega_bw_ir_append`, `bw_ra_decide`, `bw_ra_alloc`, `bw_ra_touch` | Already ported, #309 | `regalloc_ir.om`; C selects ABI fields, copies instructions and writes intervals. Guarded C alternatives remain the #309 oracle. |
24| `omega_bw_regalloc_c_oracle`, `omega_bw_regalloc_solve` | Already ported, #309 | `regalloc.om`; default solve serializes/deserializes the fixed wire arrays. |
25| `omega_bw_gpr_declared`, `omega_bw_gpr_declared_ok`, `omega_bw_ir_set_gpr_limit` | Already ported, #309 | `regalloc_ir.om`; existing oracle alternatives are unchanged. |
26| `bw_c_encode_insn` | Already ported, #79 and encoder extensions #301/#307 | `bw_enc_sm121.om` owns instruction packing, control/scheduling arithmetic, operand checks, branch deltas and padding. C is the independently selectable encoder oracle. |
27| `bw_om_encode` | Computation moved here | `cg_fields.om` packs instruction fields; C routes physical-register arrays, invokes the checked binding and copies output. |
28| `encode_single_insn` | Computation moved here | `cg_fields.om` assembles the four little-endian words. Its C-primary alternative remains the existing encoder oracle. |
29| `omega_bw_encode_program` | Computation moved here / existing #309 binding | `cg_bind.om` kind 6 now admits capacity and computes required bytes together; C checks pointers and dispatches the encoder. |
30| `bw_encode_program_bytes` | Already ported, #79/#309 | Omega encoder produces bytes; C copies the result or runs the explicitly enabled differential oracle. |
31| `bw_om_matprog`, `omega_blackwell_codegen_matmul_i32_prog`, `omega_blackwell_codegen_matmul_tensor_prog`, `omega_blackwell_codegen_matmul_tensor_loop_prog`, `omega_blackwell_codegen_matmul_frag_prog`, `omega_blackwell_codegen_matmul_frag_block_prog` | Already ported, #309; matmul excluded from this lane | `cg_matmul_params.om`, `cg_matmul_i32.om`, `cg_matmul_tensor.om`, `cg_matmul_loop.om`, `cg_matmul_frag.om`, `cg_matmul_block.om`; C packs scalar ABI arguments and calls the common replay entry. |
32| `bw_keep_alive`, `bw_live_until`, `frag_block_store_fits` | Already ported, #309 | Only in the existing guarded matmul oracle; corresponding lifetime/store-offset policies are Omega. |
33| `bw_mat_decide`, `omega_matmul_frag_block_shape`, `omega_matmul_frag_block_unroll`, `omega_matmul_frag_unroll` | Already ported, #309 | `cg_matmul.om`; pointer-output unpacking remains ABI glue. |
34| `frag_a_tab_init`, `frag_f32_to_bf16`, `omega_matmul_frag_pack_a`, `omega_matmul_frag_pack_a_f32`, `omega_matmul_frag_pack_a_row0`, `omega_matmul_frag_pack_a_row0_f32`, `omega_matmul_frag_pack_b`, `omega_matmul_result_sentinels` | Outside owned scope, #323 | ApiViewsElem owns these A/B packers and sentinel traversal. No competing edits. |
35| `omega_bw_ir_init`, `omega_blackwell_encode_one` | ARCH-0042 ABI shell | Object clearing, identity-map initialization, pointer checks and invocation. No encoding policy. |
36| `omega_bw_program_code_bytes`, `omega_blackwell_kernel_encode_into` | Already ported, #309 / ARCH-0042 shell | `cg_bind.om` makes size/count decisions; C routes caller-owned buffers, hashes bytes and populates the public descriptor. |
37| `bw_kernel_alloc_encode`, `omega_blackwell_codegen_matmul_i32`, `omega_blackwell_codegen_matmul_tensor`, `omega_blackwell_codegen_matmul_tensor_loop`, `omega_blackwell_codegen_matmul_frag`, `omega_blackwell_codegen_matmul_frag_block` | ARCH-0042 allocation shell | Pointer checks, stack object selection, malloc/free and existing program-generator dispatch. |
38| `omega_kernel_dump` | ARCH-0042 file shell | Optional environment-selected file writing and content hashing; no instruction computation. |
39| `bw_enc_diff_note` | Verification shell | Writes differential receipts and aborts on a disagreement; production encoder selection is unchanged. |
40| `omega_blackwell_verify_codegen_fixtures`, `omega_blackwell_verify_codegen_fixtures_intops`, `omega_blackwell_verify_codegen_fixtures_fragmm`, `omega_blackwell_verify_codegen_fixtures_reconv`, `omega_blackwell_verify_codegen_fixtures_bfly_f2fp`, `omega_blackwell_verify_codegen_fixtures_atomf32`, `omega_blackwell_verify_codegen_fixtures_fb1cut4`, `omega_blackwell_test_regalloc_bounds`, `omega_blackwell_test_codegen_variation` | Independent verification oracles | Golden-word comparisons, fixture construction, assertions and reporting intentionally remain C, not an adoption of a production C implementation. |
41| `field` (`omega_gpu_om_ir.c`) | Computation moved here | `cg_replay.om` admits each register field; `cg_fields.om` decodes it. Old helper is default-OFF `CUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE`. |
42| `extend_loop` | Computation moved here | `cg_life.om` extends signed live-in intervals to loop closure. |
43| `loop_invariant_ok` | Computation moved here | `cg_invar.om` checks each source, nonuniform redefinition and post-loop use. |
44| `omega_gpu_om_ir_replay` | Computation moved here; entry retained as ARCH-0042 shell | `cg_replay.om` checks record/metadata/width/operand/closure admission; `cg_fields.om` decodes; `cg_life.om` extends loops and validates exact hints; `cg_invar.om` checks invariants. C invokes the emitter, marshals objects and dispatches already-ported allocation. |
45| `omega_gpu_om_ir_build` | Computation moved here; buffer shell retained | `cg_budget.om` owns the declaration floor, declaration/peak constraint and CTA register budget. C retains pointer/zero-thread entry guards and encode dispatch. |
46| `call_unit`, `omega_gpu_om_ir_data`, `omega_gpu_om_ir_rc_name` | ARCH-0042 ABI/replay dispatch shell | Calls the selected bridge entry, checks its status/result, clears caller memory and returns the stable diagnostic string. |
47
48The prior family codegen PRs #274–#278 and #313–#316 implement separate
49translation units and are not duplicated or modified here. #312's f64 IR
50extension is likewise not overwritten. Cubin assembly remains in the existing
51`omega_cubin` path; this lane compares its exact output rather than adopting
52a different writer.
53
54## Default and oracle selection
55
56The newly removed C wire packing, word decoding, IR argument validation,
57lifetime extension/invariant checking and build-budget arithmetic are behind
58`CUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE`, undefined by default. The guard
59preserves the original computation for the differential build. There is no
60fallback from an Omega refusal to C.
61
62This does not rename or enable #309's separate `CUDAPP_MIGRATION_PENDING_C_REGALLOC`,
63`CUDAPP_MIGRATION_PENDING_C_CODEGEN_MATMUL`, `CUDAPP_MIGRATION_PENDING_C_BIND`, or the
64existing encoder oracle. The inherited `OMEGA_GPU_NO_POSIX` path selects those
65older C oracles because the pinned scalar-only freestanding bridge cannot
66convert their array views. This existing limitation is not evidence of a
67freestanding Omega cutover. No new host binary/library/runtime dependency is
68adopted by this lane; generated bindings use the repository's pinned bridge.
69
70## Source-derived partition and negative controls
71
72`differential.c` derives the partition from each admission predicate in the
73original common replay and from the field widths in its record layout:
74
75- Instruction count around 1, 8, 32 and 1024; vreg counts around 160/256;
76 uniform counts around 32; loop counts around 24; GPR limits around 128/246.
77- Each width tag, all opcode tags through the baseline maximum and one beyond,
78 all five operand positions around their bounds, sentinel and `UINT32_MAX`.
79- Every metadata flag value and emitter status/result class. Admission compares
80 the return code and emitter diagnostic; successful replay compares the whole
81 zero-initialized IR object. Error outputs do not promise partially mutated IR.
82- Every control/flag wire bit through real program encoding; each field against
83 the old source-derived pack/decode formula; little-endian byte-to-word checks.
84- Cross-product loop start/end values, unsorted and shared closures, undefined,
85 inside-loop and after-loop definitions, all three source positions,
86 nonuniform and uniform redefinitions, reads before/inside/after a loop,
87 and exact-live-hint bounds. Signed C `int` closure conversion and the -1
88 interval sentinel are preserved explicitly without checked-cast traps.
89- Peak/thread boundary cross product, including zero and `UINT32_MAX`, checks
90 the source budget formula against `cg_budget.om`.
91
92Each accepted encodable program compares the entire padded SASS byte stream
93against the original C encoder and packs both streams with identical cubin
94metadata, comparing the entire resulting cubin. No cubin, PTX or disassembly
95is written to evidence or committed. The red build flips one SASS bit before
96comparison and must fail. Five independent seeded-source mutants change field
97shift, opcode bound, loop extension, loop rejection and the budget boundary;
98all must be killed by the same executable.
99
100## Reproduction and tiers
101
102Run from the repository root. Every command below is host-only and must run
103inside the device-hidden wrapper, even the mutant and simulator paths:
104
105```sh
106export OMEGA_OMC=$HOME/work/cudastack/omega-mv/seed/out/omc
107export OMEGA_BRIDGE=$HOME/work/cudastack/omega-bridge
108export OMEGA_BRIDGE_DIR=$OMEGA_BRIDGE
109bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 \
110 make -j1 test-codegen-base-om-mutants test-regalloc-om test-om-encoder test-codegen-freestanding
111```
112
113`tests/codegen_base/run.sh` emits source coverage of the preserved C oracle in
114`build/codegen-base-om/`; generated mutant copies remain only in that ignored
115build directory. `CODEGEN_BASE_OUT` selects a separate build directory.
116See dated evidence for exercised results, coverage dispositions and exact
117commands. The full `make test` belongs to the integration owner, not this lane.
118Chip/live-RM/VFIO are **NOT_RUN**; see [CHIP.md](CHIP.md).
119
120The change adds no language, compiler, pin, bridge profile, public API or
121repository ownership rule. Existing omega-harness skill descriptions therefore
122remain applicable; there is no skill example to refresh.