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 / tests / codegen_base / README.md
| 1 | # Base codegen and common IR replay migration |
| 2 | |
| 3 | Source baseline: CUDApp #309, `63d18a2cc92cb05f800d17e46b35f0cd6237b3b0`. |
| 4 | The seeded compiler is omega-mv `e5b32567`, SHA-256 |
| 5 | `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`. |
| 6 | Registration was committed before caller cutover (`79de6f9`). |
| 7 | |
| 8 | The production entry remains `omega_gpu_om_ir_replay`. No opcode was added. |
| 9 | The baseline ends at `BW_IR_ATOMG_ADD_F32_STRONG_GPU`; #312's separately |
| 10 | stacked f64 extension ends at 78, leaving 79 unused. When combining #312, |
| 11 | the replay admission call must receive its `BW_IR_LAST` rather than the |
| 12 | baseline enum maximum. This branch does not silently import that other PR. |
| 13 | |
| 14 | ## Every function in the two target files |
| 15 | |
| 16 | Names in each row are exhaustive, including guarded alternate definitions. |
| 17 | “Already ported” refers to the default hosted path, not a claim that the |
| 18 | existing freestanding migration oracle has been removed. Verification |
| 19 | oracles 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 | |
| 48 | The prior family codegen PRs #274–#278 and #313–#316 implement separate |
| 49 | translation units and are not duplicated or modified here. #312's f64 IR |
| 50 | extension is likewise not overwritten. Cubin assembly remains in the existing |
| 51 | `omega_cubin` path; this lane compares its exact output rather than adopting |
| 52 | a different writer. |
| 53 | |
| 54 | ## Default and oracle selection |
| 55 | |
| 56 | The newly removed C wire packing, word decoding, IR argument validation, |
| 57 | lifetime extension/invariant checking and build-budget arithmetic are behind |
| 58 | `CUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE`, undefined by default. The guard |
| 59 | preserves the original computation for the differential build. There is no |
| 60 | fallback from an Omega refusal to C. |
| 61 | |
| 62 | This 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 |
| 64 | existing encoder oracle. The inherited `OMEGA_GPU_NO_POSIX` path selects those |
| 65 | older C oracles because the pinned scalar-only freestanding bridge cannot |
| 66 | convert their array views. This existing limitation is not evidence of a |
| 67 | freestanding Omega cutover. No new host binary/library/runtime dependency is |
| 68 | adopted 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 |
| 73 | original 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 | |
| 92 | Each accepted encodable program compares the entire padded SASS byte stream |
| 93 | against the original C encoder and packs both streams with identical cubin |
| 94 | metadata, comparing the entire resulting cubin. No cubin, PTX or disassembly |
| 95 | is written to evidence or committed. The red build flips one SASS bit before |
| 96 | comparison and must fail. Five independent seeded-source mutants change field |
| 97 | shift, opcode bound, loop extension, loop rejection and the budget boundary; |
| 98 | all must be killed by the same executable. |
| 99 | |
| 100 | ## Reproduction and tiers |
| 101 | |
| 102 | Run from the repository root. Every command below is host-only and must run |
| 103 | inside the device-hidden wrapper, even the mutant and simulator paths: |
| 104 | |
| 105 | ```sh |
| 106 | export OMEGA_OMC=$HOME/work/cudastack/omega-mv/seed/out/omc |
| 107 | export OMEGA_BRIDGE=$HOME/work/cudastack/omega-bridge |
| 108 | export OMEGA_BRIDGE_DIR=$OMEGA_BRIDGE |
| 109 | bwrap --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 |
| 115 | build directory. `CODEGEN_BASE_OUT` selects a separate build directory. |
| 116 | See dated evidence for exercised results, coverage dispositions and exact |
| 117 | commands. The full `make test` belongs to the integration owner, not this lane. |
| 118 | Chip/live-RM/VFIO are **NOT_RUN**; see [CHIP.md](CHIP.md). |
| 119 | |
| 120 | The change adds no language, compiler, pin, bridge profile, public API or |
| 121 | repository ownership rule. Existing omega-harness skill descriptions therefore |
| 122 | remain applicable; there is no skill example to refresh. |