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/codegen_pfhost_diff.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 / codegen_pfhost_diff.c` 62 lines · 3245 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #include "omega_blackwell_codegen_pfhost.h" 3 #include "omega_gpu_om_ir.h" 4 #include "cudapp_native.h" 5 #include 6 #include 7 int omega_blackwell_codegen_rl_prog_c(const OmegaRlSpec *, BlackwellIRProgram *); 8 int omega_blackwell_codegen_mc_prog_c(const OmegaMcSpec *, BlackwellIRProgram *); 9 static BlackwellIRProgram c, o; 10 static uint8_t cb[BW_MAX_IR_INSNS * 16], ob[BW_MAX_IR_INSNS * 16]; 11 static int same(void) { 12 if (c.count != o.count || memcmp(c.insns, o.insns, c.count * sizeof c.insns[0]) || 13 memcmp(&c.regalloc, &o.regalloc, sizeof c.regalloc)) return 0; 14 OmegaBlackwellKernel ck, ok; 15 if (omega_blackwell_kernel_encode_into(&c, cb, sizeof cb, &ck) || 16 omega_blackwell_kernel_encode_into(&o, ob, sizeof ob, &ok)) return 0; 17 return memcmp(cb, ob, c.count * 16) == 0; 18 } 19 int main(int argc, char **argv) { 20 unsigned rl = 0, mc = 0, refused = 0; 21 int quick = argc > 1 && strcmp(argv[1], "--quick") == 0; 22 for (uint32_t k = 128; k <= 16384; k += 128) 23 for (uint32_t e = 32; e <= 1024; e += 32) 24 for (uint32_t t = 1; t <= 16; t++) 25 for (int m = 0; m <= 2; m++) { 26 OmegaRlSpec s = {k,e,t,m}; 27 if (!omega_rl_spec_ok(&s)) continue; 28 if (quick && (k != 256 || e != 32 || t != 1)) continue; 29 int cr = omega_blackwell_codegen_rl_prog_c(&s,&c); 30 int rc = omega_blackwell_codegen_rl_prog(&s,&o); 31 if (cr != rc || (!cr && !same())) { 32 printf("FAIL rl k=%u e=%u t=%u mutant=%d c=%d om=%d count=%zu/%zu\n",k,e,t,m,cr,rc,c.count,o.count); return 1; 33 } 34 if (cr) refused++; else rl++; 35 } 36 for (uint32_t h = 128; h <= 4096; h += 128) 37 for (uint32_t n = 4; n <= 16; n += 4) 38 for (int m = 0; m <= 2; m++) { 39 if (quick && (h != 128 || n != 4)) continue; 40 OmegaMcSpec s = {h,n,m}; 41 int cr = omega_blackwell_codegen_mc_prog_c(&s,&c); 42 int rc = omega_blackwell_codegen_mc_prog(&s,&o); 43 if (cr != rc || (!cr && !same())) { 44 printf("FAIL mc h=%u top_k=%u mutant=%d c=%d om=%d count=%zu/%zu\n",h,n,m,cr,rc,c.count,o.count); return 1; 45 } 46 if (cr) refused++; else mc++; 47 } 48 OmegaMcSpec s = {128,4,0}; 49 if (omega_blackwell_codegen_mc_prog_c(&s,&c) || omega_blackwell_codegen_mc_prog(&s,&o)) return 1; 50 o.insns[0].imm ^= 1u; 51 if (same()) { puts("FAIL flipped-record negative control survived"); return 1; } 52 OmegaRlSpec badrl = {127,32,1,0}; OmegaMcSpec badmc = {128,3,0}; 53 if (omega_blackwell_codegen_rl_prog(&badrl,&o) != -1 || omega_blackwell_codegen_mc_prog(&badmc,&o) != -1 || 54 omega_blackwell_codegen_rl_prog(NULL,&o) != -1 || omega_blackwell_codegen_mc_prog(NULL,&o) != -1 || 55 omega_blackwell_codegen_mc_prog(&s,NULL) != -1) return 1; 56 puts("PASS flipped-record negative control and invalid/null refusal"); 57 printf("PASS pfhost exhaustive IR, allocation and encoded-byte differential rl=%u mc=%u matching_refusals=%u\n",rl,mc,refused); 58 59 uint64_t ins[OMEGA_OM_IR_WORDS] = {0}, meta[OMEGA_OM_IR_META] = {0}, result = 0; 60 if (omega_cg_pfhost(&result, 2, 0, 0, 0, ins, OMEGA_OM_IR_WORDS, meta, OMEGA_OM_IR_META) != OMEGA_OK || result != 1) return 1; 61 return 0; 62 }