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/tests/gpu_codegen_rest_test.c # 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 / tests / gpu_codegen_rest_test.c` 190 lines · 18339 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #include "omega_codegen_rest_wire.h" 3 #include 4 #include 5 #include 6 static BlackwellIRProgram oldp, newp, defp; 7 static int flip_record; 8 static OmegaOmIrUnit unflipped; 9 static uint32_t flipped(uint64_t *ret,uint64_t k,uint64_t a,uint64_t b,uint64_t c,void *words,uint64_t nw,void *metadata,uint64_t nm) { 10 uint64_t *w=words,*m=metadata; 11 uint32_t rc=unflipped(ret,k,a,b,c,w,nw,m,nm); 12 if(!rc && !*ret && m[0])w[6]^=1; 13 return rc; 14 } 15 int legacy_omega_dattn256_shape(const OmegaDecodeAttn256Spec *spec, OmegaDattn256Shape *s); 16 int legacy_omega_blackwell_codegen_decode_attn256_prog(const OmegaDecodeAttn256Spec *spec, BlackwellIRProgram *prog); 17 int legacy_omega_decode_attn256_prog_stats(const OmegaDecodeAttn256Spec *spec, uint32_t *insns, uint32_t *gprs); 18 int legacy_omega_pattn256_shape(const OmegaPrefillAttn256Spec *spec, OmegaPattn256Shape *s); 19 int legacy_omega_pattn256_spec_ok(const OmegaPrefillAttn256Spec *s); 20 int legacy_omega_blackwell_codegen_prefill_attn256_prog(const OmegaPrefillAttn256Spec *spec, BlackwellIRProgram *prog); 21 int legacy_omega_prefill_attn256_prog_stats(const OmegaPrefillAttn256Spec *spec, uint32_t *insns, uint32_t *gprs); 22 int legacy_omega_router_smem(const OmegaRouterSpec *spec, OmegaRouterSmem *m); 23 int legacy_omega_blackwell_codegen_router_prog(const OmegaRouterSpec *spec, BlackwellIRProgram *prog); 24 int legacy_omega_router_prog_stats(const OmegaRouterSpec *spec, uint32_t *insns, uint32_t *gprs); 25 uint32_t legacy_omega_fp8gemm_steps(const OmegaFp8GemmSpec *spec); 26 uint32_t legacy_omega_fp8gemm_shared_bytes(const OmegaFp8GemmSpec *spec); 27 int legacy_omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, BlackwellIRProgram *prog); 28 int legacy_omega_fp8gemm_prog_stats(const OmegaFp8GemmSpec *spec, uint32_t *insns, uint32_t *gprs); 29 uint32_t legacy_omega_bf16_gemv_steps(const OmegaBf16GemvSpec *spec); 30 uint32_t legacy_omega_bf16_gemv_shared_bytes(const OmegaBf16GemvSpec *spec); 31 int legacy_omega_blackwell_codegen_bf16_gemv_prog(const OmegaBf16GemvSpec *spec, BlackwellIRProgram *prog); 32 int legacy_omega_bf16_gemv_prog_stats(const OmegaBf16GemvSpec *spec, uint32_t *insns, uint32_t *gprs); 33 int legacy_omega_pq_spec_ok(const OmegaPqSpec *s); 34 int legacy_omega_blackwell_codegen_pq_prog(const OmegaPqSpec *spec, BlackwellIRProgram *prog); 35 int legacy_omega_qg_spec_ok(const OmegaQgSpec *s); 36 uint32_t legacy_omega_qg_shared_bytes(const OmegaQgSpec *s); 37 uint32_t legacy_omega_qg_span(const OmegaQgSpec *s); 38 int legacy_omega_blackwell_codegen_qgemm_prog(const OmegaQgSpec *spec, BlackwellIRProgram *prog); 39 40 static unsigned long cases, accepted, maxinsns, maxvregs; 41 static int cmp(const char *name, int oldrc, OmegaOmIrUnit unit, uint64_t kind, const void *spec) { 42 uint64_t err=0; 43 unflipped=unit; 44 int rc=omega_gpu_om_ir_replay(flip_record?flipped:unit,kind,(uintptr_t)spec,0,0,&newp,&err); 45 cases++; 46 if(oldp.count>maxinsns)maxinsns=oldp.count; 47 if(oldp.regalloc.num_vregs>0&&(unsigned long)oldp.regalloc.num_vregs>maxvregs)maxvregs=(unsigned long)oldp.regalloc.num_vregs; 48 if ((oldrc==0)!=(rc==0)) { fprintf(stderr,"%s refusal mismatch C=%d OM=%d emit=%llu case=%lu\n",name,oldrc,rc,(unsigned long long)err,cases); return 1; } 49 if(oldrc) return 0; 50 accepted++; 51 if(oldp.count!=newp.count) {fprintf(stderr,"%s count %zu != %zu\n",name,oldp.count,newp.count);return 1;} 52 for(size_t i=0;i>17;rng^=rng<<5;return rng;} 125 static const uint32_t edges[]={0,1,2,3,4,7,8,15,16,31,32,63,64,127,128,255,256,511,512,1023,1024,16383,16384,32767,32768,65535,65536,0x7fffffffu,0x80000000u,0xfffffffeu,0xffffffffu}; 126 /* Refusal constants from the six C admission functions and qg shape policy. 127 * Each center is checked on both sides, separately in every scalar field. */ 128 static const uint32_t bounds[]={1,2,4,5,6,8,16,32,64,120,128,256,512,1024,2048,4096,8192,16384,32768,65536,`8388607`,UINT32_C(1)<<23,UINT32_C(1)<<28,UINT32_C(1)<<31}; 129 #define CHECK(n,s) do{if(check_##n(&(s))) {fprintf(stderr,#n " spec:");for(size_t zz=0;zzUINT32_MAX)continue;OmegaDecodeAttn256Spec s=a;s.q_heads=(uint32_t)qh;s.kv_heads=(uint32_t)kv;s.q_per_cta=h;CHECK(attn256,s);}RANDOM(attn256,a); 147 const uint32_t wide[]={3,(UINT32_C(1)<<31)-1u,UINT32_C(1)<<31,(UINT32_C(1)<<31)+1u,UINT32_MAX}; 148 for(unsigned wi=0;wi1?argv[1]:"all";int full=argc<=2||strcmp(argv[2],"--smoke");flip_record=argc>3&&!strcmp(argv[3],"--record-flip"); 187 const char *all[]={"attn256","pattn256","router","gemm","bf16","qg"}; 188 for(unsigned i=0;i<6;i++)if(!strcmp(family,"all")||!strcmp(family,all[i])){cases=accepted=maxinsns=maxvregs=0;if(run(all[i],full))return 1;printf("PASS codegen-rest %s cases=%lu accepted=%lu max-insns=%lu max-vregs=%lu IR/regalloc/bytes/refusals/default-shell\n",all[i],cases,accepted,maxinsns,maxvregs);fflush(stdout);} 189 return 0; 190 }