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 / components / direct-oracle.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | /* Verification only: existing C algorithm and independently retained C encoder. */ |
| 3 | #include "omega_blackwell_codegen_moe.h" |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <string.h> |
| 7 | static void word(uint64_t v) { for (unsigned j=0;j<8;j++) putchar((int)((v>>(j*8))&255)); } |
| 8 | static uint64_t reg(int v) { return v < 0 ? UINT64_MAX : (uint64_t)v; } |
| 9 | int main(int argc,char **argv) { |
| 10 | if(argc!=6) return 65; |
| 11 | OmegaFp8GemvSpec s={0}; |
| 12 | s.k=(uint32_t)strtoul(argv[1],NULL,10);s.lane_bytes=(uint32_t)strtoul(argv[2],NULL,10); |
| 13 | s.rows=(uint32_t)strtoul(argv[3],NULL,10);s.warps=(uint32_t)strtoul(argv[4],NULL,10); |
| 14 | s.wfirst=(uint32_t)strtoul(argv[5],NULL,10); |
| 15 | BlackwellIRProgram p; |
| 16 | omega_bw_ir_init(&p); |
| 17 | if(omega_blackwell_codegen_fp8_gemv_prog(&s,&p)!=0) return 66; |
| 18 | uint8_t code[16384]; size_t nbytes=0; |
| 19 | if(omega_bw_encode_program(&p,code,sizeof code,&nbytes)!=0) return 67; |
| 20 | word(p.count);word(p.regalloc.num_vregs);word(p.regalloc.num_uvregs);word(0); |
| 21 | word(p.regalloc.peak_gpr_usage);word(p.regalloc.peak_ugpr_usage); |
| 22 | for(int v=0;v<p.regalloc.num_vregs;v++) { |
| 23 | const OmegaLiveInterval *q=&p.regalloc.intervals[v]; |
| 24 | word(q->bundle_size?q->bundle_size:(q->is_pair?2:(q->is_quad?4:1))); |
| 25 | word(reg(p.regalloc.vreg_to_phys[v])); |
| 26 | } |
| 27 | for(int v=0;v<p.regalloc.num_uvregs;v++) { |
| 28 | word(p.regalloc.uintervals[v].is_pair?2:1);word(reg(p.regalloc.uvreg_to_phys[v])); |
| 29 | } |
| 30 | for(size_t k=0;k<p.count;k++) { |
| 31 | const BlackwellIRInsn *i=&p.insns[k]; |
| 32 | word(i->op);word(reg(i->dst_vreg));word(reg(i->src1_vreg));word(reg(i->src2_vreg)); |
| 33 | word(reg(i->src3_vreg));word(reg(i->ureg)); |
| 34 | word((uint64_t)i->imm|((uint64_t)i->control<<32)); |
| 35 | word((uint64_t)i->is_uniform|((uint64_t)i->predicate_p0<<1)|((uint64_t)i->predicate_not<<2)| |
| 36 | ((uint64_t)i->bar_reg<<8)|((uint64_t)i->dst_subreg<<16)|((uint64_t)i->src1_subreg<<24)| |
| 37 | ((uint64_t)i->src2_subreg<<32)|((uint64_t)i->src3_subreg<<40)); |
| 38 | } |
| 39 | if(fwrite(code,1,nbytes,stdout)!=nbytes) return 74; |
| 40 | return 0; |
| 41 | } |