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 / src / omega_blackwell_codegen_pf.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | /* omega_blackwell_codegen_pf.c: device-resident prefill helper kernels (OWN-30B T3b). See the header. */ |
| 3 | #include "omega_blackwell_codegen_pf.h" |
| 4 | #include "omega_bw_em.h" |
| 5 | #include "omega_gpu_om_ir.h" |
| 6 | #include "cudapp_native.h" |
| 7 | |
| 8 | int omega_cg_pf_copy_from_omega(BlackwellIRProgram *prog, int mutant) { |
| 9 | uint64_t err = 0; |
| 10 | int rc; |
| 11 | if (!prog) return -1; |
| 12 | rc = omega_gpu_om_ir_replay((OmegaOmIrUnit)omega_cg_pf_copy, 0, 0, 0, mutant ? 1u : 0u, prog, &err); |
| 13 | return rc == 0 ? 0 : -1; |
| 14 | } |
| 15 | |
| 16 | int omega_blackwell_codegen_pf_copy_prog(BlackwellIRProgram *prog) { |
| 17 | if (!prog) return -1; |
| 18 | #if defined(CUDAPP_MIGRATION_PENDING_C_CODEGEN_PF) |
| 19 | return omega_blackwell_codegen_pf_copy_prog_c(prog); |
| 20 | #else |
| 21 | return omega_cg_pf_copy_from_omega(prog, 0); |
| 22 | #endif |
| 23 | } |
| 24 | |
| 25 | int omega_blackwell_codegen_pf_copy_prog_c(BlackwellIRProgram *prog) { |
| 26 | if (!prog) return -1; |
| 27 | omega_bw_ir_init(prog); |
| 28 | Em em; memset(&em, 0, sizeof em); em.p = prog; Em *e = &em; |
| 29 | int udesc = UV64(e), pd = V64(e), ps = V64(e), units = V(e), tid = V(e), cta = V(e), i = V(e), v = V128(e); |
| 30 | if (e->err) return -1; |
| 31 | ldcu64(e, udesc, 0x358); ldc64(e, pd, 0x380); ldc64(e, ps, 0x388); ldc32(e, units, 0x390); |
| 32 | s2r(e, tid, BW_SR_TID_X); s2r(e, cta, BW_SR_CTAID_X); |
| 33 | imadi(e, i, cta, 0, OMEGA_PF_COPY_THREADS, tid); |
| 34 | isetp_ge_u32(e, i, units); |
| 35 | { BlackwellIRInsn x = I0(BW_IR_EXIT); x.predicate_p0 = true; emit(e, x, K_EXIT); } |
| 36 | imadw(e, ps, i, 16u, ps); imadw(e, pd, i, 16u, pd); |
| 37 | ldg_wide(e, BW_IR_LDG_E_128, v, ps, 0, udesc, 1); |
| 38 | for (unsigned q = 0; q < 4; q++) { BlackwellIRInsn st = I0(BW_IR_STG_E); st.src1_vreg = pd; st.src2_vreg = v; st.src2_subreg = (uint8_t)q; st.imm = 4u * q; st.ureg = udesc; emit(e, st, K_STORE); } |
| 39 | tail(e); |
| 40 | if (e->err) return -1; |
| 41 | return omega_bw_regalloc_solve(prog); |
| 42 | } |