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/src/omega_gpu_om_ir.h # 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 / src / omega_gpu_om_ir.h` 76 lines · 4576 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #ifndef OMEGA_GPU_OM_IR_H 3 #define OMEGA_GPU_OM_IR_H 4 /* 5 * omega_gpu_om_ir: replay of BlackwellIR records emitted by a seeded Omega unit (om/mathlibs/mathlibs_ir.om, 6 * bound through src/cudapp_om_units.c) into a BlackwellIRProgram, then register allocation, the loop live-range 7 * check and encoding (the .om sm_121 encoder behind omega_blackwell_kernel_encode_into). 8 * 9 * ARCH-0042 C shell: pointers, ABI structs and the single replay dispatch stay here. Seeded Omega owns 10 * wire admission (om/codegen/cg_replay.om), field packing/unpacking (cg_fields.om), loop/exact-liveness 11 * policy (cg_life.om and cg_invar.om), register allocation (#309) and launch-budget arithmetic 12 * (cg_budget.om). CUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE selects the default-OFF historical C oracle. 13 * 14 * Record (8 x u64): op, dst, src1, src2, src3 (vreg, or all-ones for none), ureg (or all-ones), imm | control << 32, 15 * uniform | p0 << 1 | not << 2 | dst_sub << 16 | src1_sub << 24 | src2_sub << 32 | src3_sub << 40 | bar_reg << 48. 16 * Meta (512 x u64): 0 records, 1 vregs, 2 uvregs, 4 emitter error, 5 closed loops, 17 * 6 requested exclusive GPR limit at successful return (0 retains the initializer's historical default; 18 * otherwise BW_PHYS_GPR_MAX < limit <= BW_PHYS_GPR_HW_LIMIT). Emitters may use slot 6 as scratch before 19 * successful return, but must clear it unless requesting the extended allocator. 20 * 16 + 2L / 17 + 2L loop L first record / closing BRA, 64 + v vreg kind (1 scalar, 2 pair, 4 quad), 320 + u uvreg kind. 21 * 7 exact-liveness flag: 0 preserves the default wire; 1 enables last-use extensions for at most 160 vregs. 22 * Meta[352 + v], 0 <= v < 160: zero means absent, otherwise the requested instruction index. Every override 23 * must be >= the computed definition and last-use indices and < records; it never shortens or clamps. 24 * With flag 1, vreg count > 160 is refused, so index 512 (v=160) cannot be interpreted. Other flag values 25 * have a distinct refusal. Slots 0..7 are header fields; 16..63 contain at most 24 loop pairs; 26 * 64..319 contain 256 vreg widths; 320..351 contain 32 uniform widths; 352..511 fit META=512 exactly. 27 */ 28 #include 29 #include 30 #include "omega_blackwell_codegen.h" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #define OMEGA_OM_IR_WORDS 8192u /* record words: 1024 records */ 37 #define OMEGA_OM_IR_META 512u 38 39 enum { 40 OMEGA_OM_IR_OK = 0, 41 OMEGA_OM_IR_REFUSED = 1, /* the unit refused the arguments */ 42 OMEGA_OM_IR_EMIT = 2, /* the unit's emitter failed (meta[4] holds its code) */ 43 OMEGA_OM_IR_BRIDGE = 3, /* the bound call itself failed */ 44 OMEGA_OM_IR_REPLAY = 4, /* a record or register the IR rejects */ 45 OMEGA_OM_IR_REGALLOC = 5, /* the allocator failed */ 46 OMEGA_OM_IR_LOOP = 6, /* a value defined in a loop is read after it */ 47 OMEGA_OM_IR_BUDGET = 7, /* declared registers x threads past 65536, or past the allocation limit */ 48 OMEGA_OM_IR_ENCODE = 8, /* the encoder refused an instruction or the buffer */ 49 OMEGA_OM_IR_LIVE_FLAG = 9, /* exact-liveness flag is not 0 or 1 */ 50 OMEGA_OM_IR_LIVE_RANGE = 10 /* invalid extension, or flag 1 with more than 160 vregs */ 51 }; 52 53 /* Checked portable unit ABI. Replay does not encode or apply a launch budget. */ 54 typedef uint32_t (*OmegaOmIrUnit)(uint64_t *, uint64_t, uint64_t, uint64_t, uint64_t, 55 void *, uint64_t, void *, uint64_t); 56 int omega_gpu_om_ir_replay(OmegaOmIrUnit unit, uint64_t kind, uint64_t a, uint64_t b, uint64_t c, 57 BlackwellIRProgram *prog, uint64_t *emit_err); 58 59 #ifndef OMEGA_GPU_NO_POSIX 60 /* Calls the unit (kind, a, b, c), replays its records into *prog, allocates, checks and encodes into code 61 * (capacity code_cap) for a launch of `threads` threads per CTA. On success *kernel points into code and 62 * *declared holds the QMD register declaration (omega_bw_gpr_declared). *emit_err gets meta[4] (may be NULL). */ 63 int omega_gpu_om_ir_build(uint64_t kind, uint64_t a, uint64_t b, uint64_t c, uint32_t threads, 64 BlackwellIRProgram *prog, uint8_t *code, size_t code_cap, 65 OmegaBlackwellKernel *kernel, uint32_t *declared, uint64_t *emit_err); 66 67 /* Raw unit call for data kinds (kind 2: FFT twiddles): words receives OMEGA_OM_IR_WORDS u64. */ 68 int omega_gpu_om_ir_data(uint64_t kind, uint64_t a, uint64_t b, uint64_t c, uint64_t *words); 69 #endif 70 71 const char *omega_gpu_om_ir_rc_name(int rc); 72 73 #ifdef __cplusplus 74 } 75 #endif 76 #endif