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/api_kgen_ew_diff_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 / api_kgen_ew_diff_test.c` 77 lines · 4704 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* Independent retained emitter oracle; never opens a device. The production 3 * source is included so its static legacy generator remains test-only. */ 4 #define CUDAPP_MIGRATION_PENDING_C_API_KGEN 1 5 #define OMEGA_API_PLAN_ORACLE 1 6 #include "../src/omega_gpu_elementwise_api.c" 7 #include "omega_cubin.h" 8 9 static int cubin_same(const uint8_t *a, size_t na, const uint8_t *b, size_t nb) { 10 static const OmegaCubinParam params[] = { 11 {0x380,8,1},{0x388,8,1},{0x390,8,1}, 12 {0x398,4,0},{0x39c,4,0},{0x3a0,4,0},{0x3a4,4,0},{0x3a8,4,0} 13 }; 14 uint8_t *ca=NULL,*cb=NULL; size_t nca=0,ncb=0; char err[128]; 15 int ra=omega_cubin_pack("api_kgen",a,na,params,8,0x3ac,64,4096,&ca,&nca,err,sizeof err); 16 int rb=omega_cubin_pack("api_kgen",b,nb,params,8,0x3ac,64,4096,&cb,&ncb,err,sizeof err); 17 int same=ra==0 && rb==0 && nca==ncb && memcmp(ca,cb,nca)==0; 18 omega_cubin_free(ca);omega_cubin_free(cb);return same; 19 } 20 static int shape_partition(void) { 21 /* om/components/api_ew_plan.om: zero admission; even/128 divisibility; 22 * 1024-row and 131072-element clamps; 2048/16384 dimension caps; 23 * reconvergence lower/upper bound and the mutant 0..3 enum. */ 24 static const uint64_t ns[]={0,1,2,3,4,127,128,129,1023,1024,1025,131071,131072,131073, 25 9223372036854775806ull,9223372036854775807ull,9223372036854775808ull,UINT64_MAX}; 26 static const uint64_t ds[]={0,1,2,3,127,128,129,2047,2048,2049,16383,16384,16385}; 27 unsigned admitted=0,refused=0; 28 for(unsigned mode=0;mode<=6;mode++)for(size_t n=0;nregalloc.peak_gpr_usage<=EW_GPR_BUDGET; 60 if((cr==0)!=ok){fprintf(stderr,"FAIL disposition op=%d mut=%d path=%d c=%d om=%d err=%llu peak=%u\n",op,mut,path,cr,orc,(unsigned long long)err,om->regalloc.peak_gpr_usage);return 1;} 61 if(cr!=0){refused++;continue;} 62 #ifdef CUDAPP_API_KGEN_RED 63 om->insns[0].imm^=1u; 64 #endif 65 if(c->count!=om->count || memcmp(c->insns,om->insns,c->count*sizeof c->insns[0])!=0){ 66 for(size_t i=0;icount && icount;i++)if(memcmp(&c->insns[i],&om->insns[i],sizeof c->insns[i])) { 67 fprintf(stderr,"FAIL IR op=%d mut=%d path=%d at=%zu c_op=%d om_op=%d c_ctl=%x om_ctl=%x c_imm=%x om_imm=%x\n",op,mut,path,i,c->insns[i].op,om->insns[i].op,c->insns[i].control,om->insns[i].control,c->insns[i].imm,om->insns[i].imm);break; 68 }return 1; 69 } 70 if(memcmp(&c->regalloc,&om->regalloc,sizeof c->regalloc)!=0){fprintf(stderr,"FAIL allocation op=%d mut=%d path=%d\n",op,mut,path);return 1;} 71 if(omega_bw_encode_program(om,text,BW_MAX_IR_INSNS*16u,&ntext)!=0 || ntext!=k.code_size || memcmp(text,k.code,ntext)!=0){fprintf(stderr,"FAIL text op=%d mut=%d path=%d\n",op,mut,path);return 1;} 72 if(!cubin_same(k.code,k.code_size,text,ntext)){fprintf(stderr,"FAIL cubin op=%d mut=%d path=%d\n",op,mut,path);return 1;} 73 accepted++;free(k.code); 74 } 75 printf("PASS API EW complete spec IR, allocation, text and cubin: accepted=%u refused=%u\n",accepted,refused); 76 free(text);free(om);free(c);return 0; 77 }