Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/om/codegen/REGALLOC.md # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / om / codegen / REGALLOC.md` 116 lines · 7187 bytes Raw Blame History Rendered 1 # Seeded core allocator and matmul builders 2 3 The default core allocator and five matmul IR builders are seeded Omega units. 4 The retained C differential oracles are selected only with 5 `CUDAPP_MIGRATION_PENDING_C_REGALLOC` and 6 `CUDAPP_MIGRATION_PENDING_C_CODEGEN_MATMUL`. The vecadd instruction writer also 7 uses the former switch. The existing `bw_enc_sm121.om` encoder is reused. 8 9 The register allocator preserves the old allocator's interval ordering, 10 strict last-use release rule, scalar/pair/quad alignment, uniform register 11 reservation, pressure refusals, partial refusal state, and allocation maps. The 12 C shell owns program memory and marshals the `ulong[4096]` wire documented in 13 `regalloc.om`; allocation choices belong to Omega. `regalloc_ir.om` owns the 14 capacity, interval, declared-GPR and limit decisions. 15 16 The matmul units emit the existing IR replay wire, not machine code. The sole 17 replay implementation handles allocation and encoding. Builder-specific 18 `keep_alive`, carried loop values, and accumulator lifetimes use extension-only 19 exact liveness in meta[7] and meta[352..511], documented next to meta[6] in 20 `src/omega_gpu_om_ir.h`. No instruction enum entries are renumbered. 21 22 ## Portable registration 23 24 All eleven units are registered in the default `UNITS` list of `om/units.sh` 25 and lowered by the pinned portable bridge (OM-1, no `om2` header) into checked 26 generated C. The declarations are in `src/cudapp_native.h`. The default build 27 needs only the pinned omc; `sh om/units.sh --check` proves the committed C 28 regenerates byte for byte. 29 30 | Source under om/codegen | Generated C | Export | 31 | --- | --- | --- | 32 | regalloc.om | src/cudapp_freest_regalloc.c | omega_ra_run | 33 | regalloc_ir.om | src/cudapp_om_regalloc_ir.c | omega_ra_ir | 34 | regalloc_live.om | src/cudapp_om_regalloc_live.c | omega_ra_live | 35 | cg_matmul.om | src/cudapp_om_cg_matmul.c | omega_cg_matmul | 36 | cg_matmul_params.om | src/cudapp_om_cg_matmul_params.c | omega_cg_par | 37 | cg_matmul_i32.om | src/cudapp_om_cg_matmul_i32.c | omega_cg_i32 | 38 | cg_matmul_tensor.om | src/cudapp_om_cg_matmul_tensor.c | omega_cg_tens | 39 | cg_matmul_loop.om | src/cudapp_om_cg_matmul_loop.c | omega_cg_loop | 40 | cg_matmul_frag.om | src/cudapp_om_cg_matmul_frag.c | omega_cg_frag | 41 | cg_matmul_block.om | src/cudapp_om_cg_matmul_block.c | omega_cg_block | 42 | cg_vecadd.om | src/cudapp_om_cg_vecadd.c | omega_cg_vec | 43 | bw_hazard.om | src/cudapp_om_bw_hazard.c | omega_hz_chk | 44 | bw_hazard.om + bw_hazard_dec.om | src/cudapp_om_bw_hazard_dec.c | omega_hz_dec | 45 | cg_bind.om | src/cudapp_om_cg_bind.c | omega_cg_bind | 46 | cg_fields.om | src/cudapp_freest_cg_fields.c | omega_cg_fields | 47 | cg_replay.om | src/cudapp_freest_cg_replay.c | omega_cg_replay | 48 | cg_life.om | src/cudapp_freest_cg_life.c | omega_cg_life | 49 | cg_invar.om | src/cudapp_freest_cg_invar.c | omega_cg_invar | 50 | cg_budget.om | src/cudapp_om_cg_budget.c | omega_cg_budget | 51 52 `bw_hazard.om` is the SM121 hazard decoder and checker behind 53 `src/omega_bw_hazard.c` (C oracle: `CUDAPP_MIGRATION_PENDING_C_HAZARD`). The 54 portable bridge needs fixed-size views, so the checker takes a 32768-byte code 55 view (2048 instructions) and a `3203584`-word state; longer code is refused, 56 where the C accepted it. `cg_bind.om` owns the matmul spec bytes, the 57 realization binding message, the machine descriptor, matmul dispatch, vector 58 launch geometry, program padding, buffer fit and the code-digest admission 59 used by `omega_blackwell_matmul.c`, `omega_blackwell_realize.c`, 60 `omega_blackwell_codegen.c` and `omega_blackwell_encoder.c` through 61 `src/omega_bw_bind.h` (C oracle: `CUDAPP_MIGRATION_PENDING_C_BIND`). The C 62 keeps memory, structs and buffer routing. Under NO_POSIX, `cg_bind.om` and 63 the shared `bw_id_native` wrapper over `cache/digest.om` and 64 `blackwell/identity.om` produce the canonical binding and identity, without 65 a C fallback. Kernel code-digest calls still route through `src/sha256.c`. 66 67 `cg_sentin.om` exposes a uint-bit view for the native integer ABI; its private 68 binary32 equality is unchanged, including signed zero and NaN behavior. 69 70 The portable bridge has no integer-to-integer bitcast. `regalloc.om` stores 71 signed words through `ra_u2l`/`ra_l2u`, a portable two's-complement 72 reinterpretation. Freestanding builds (`OMEGA_GPU_NO_POSIX`) use the existing 73 seeded allocator, five core matmul builders, scalar policies, fragment packers, 74 sentinels, vecadd writer and binding decisions through checked caller-stack 75 native units registered in `om/no-posix.sh`. They no longer select C computation 76 merely because POSIX is unavailable. C remains an explicit default-OFF oracle. 77 `make test-codegen-freestanding` compares hosted and native Omega instruction dumps. 78 `make test-om-encoder-primary` compares 1024 register/control/predicate samples 79 for each of eight operand forms of every opcode 0..79 against C, hosted Omega and native Omega; the conductor is 80 `om/encoder/primary_parity.om`, including a flipped-byte refusal control. 81 The operand-mode sweep also caught the seeded LDG.E encoder omitting its 82 existing C signed byte-offset field. Both seeded encoder and spec table now 83 use the same field as the existing wide-load forms. The dedicated LDG gate 84 checks signed extrema, range refusal and dropped-offset/bound mutants. 85 86 `tests/regalloc_om/run.sh` checks regeneration, then links the generated units. 87 It compiles the C oracle under renamed exports, compares the complete program 88 including maps and refusal state, compares successful encodings, exercises 89 exact-liveness boundaries, and runs existing encoder fixtures and BF16 warp 90 simulation. `mutants.py` lowers altered Omega source with the frontend, 91 converter and flags named by that unit's checked `src/cudapp_om_.ident` 92 (`bridge-freest` for `regalloc`, `cg_life` and `cg_replay`; `bridge-seeded` 93 otherwise), verifies those pins and the checked C digest, relinks only that 94 unit's generated C and requires semantic failures; compile or link failure is 95 not counted as detection. `bridge-freest` also needs `OMEGA_SEED` (the 96 bridge's baseline compiler). 97 98 Pinned seeded compiler: omega-mv `e5b32567`, omc SHA-256 99 ``2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f``. 100 101 See `evidence/regalloc-om/2026-11-06/README.md` and 102 `evidence/regalloc-om/2026-11-06-rest/README.md` for measured results and the 103 remaining unported assigned files. This is not a claim that all CUDApp CUDA 104 replacement work is complete. 105 106 The base/common-replay residue is now separate from the family emitters: 107 `cg_fields.om` owns instruction wire packing/decoding and little-endian words; 108 `cg_replay.om` owns metadata, width, operand and closure admission; 109 `cg_life.om` owns loop extension and exact hints; `cg_invar.om` owns 110 post-loop-use/redefinition policy; `cg_budget.om` owns the CTA register budget. 111 The single `omega_gpu_om_ir_replay` C entry remains the ABI/dispatch shell. 112 The old base computation is default-OFF 113 `CUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE`, without a C retry on Omega refusal. 114 See [the exhaustive function classification and host gate](../../tests/codegen_base/README.md), 115 [chip runbook](../../tests/codegen_base/CHIP.md), and 116 [dated host evidence](../../evidence/2026-11-06-codegen-base/README.md).