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_conv2d_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_conv2d_test.c` 104 lines · 6796 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #include "omega_gpu_conv2d_api.h" 3 #include "omega_gpu_gemm.h" 4 #include "omega_gpu_session.h" 5 #include "bw_warp_sim_k.h" 6 #include "gpu_conv2d_ref.h" 7 #include 8 static int failed,checks,opened,allocations,open_success,shell_contract,chip; 9 #define CHECK(x) do {checks++;if(!(x)){failed++;fprintf(stderr,"conv2d FAIL line %d: %s\n",__LINE__,#x);}}while(0) 10 OmegaGpuSession *__wrap_omega_gpu_session_open(void) {static OmegaGpuSession dummy;if(!shell_contract)abort();opened++;return open_success?&dummy:NULL;} 11 int __wrap_omega_gpu_session_alloc(size_t n,OmegaGpuMem *m) {(void)n;(void)m;if(!shell_contract)abort();allocations++;return -1;} 12 void __wrap_omega_gpu_session_lock(void) {if(!shell_contract)abort();} 13 void __wrap_omega_gpu_session_unlock(void) {if(!shell_contract)abort();} 14 void __wrap_omega_gpu_session_free(OmegaGpuMem *m) {(void)m;if(!shell_contract)abort();} 15 static void ptr(uint32_t *p,uintptr_t x){p[0]=(uint32_t)x;p[1]=(uint32_t)((uint64_t)x>>32);} 16 static void *input(size_t n,unsigned t,unsigned salt) { 17 void *p=calloc(n,t?2:4);if(!p)abort(); 18 for(size_t i=0;i>16);} 23 else {unsigned a=(unsigned)(z<0?-z:z),e=0,m=0;if(a){unsigned k=0;while((a>>(k+1))!=0)k++;e=k+11;m=(a-(1u<gamma*mag[i]+0x1p-126)equal=0; 45 if(!wrong)CHECK(equal); 46 free(a);free(b);free(out);free(ref);free(mag);free(p);free(code);return equal; 47 } 48 static int dense_launch(void *ctx,OmegaGemmKind kind,const uint32_t *args,uint32_t gx,uint32_t gy,uint32_t nt) { 49 WsSim *sim=ctx;(void)kind;memcpy(sim->cbank+0x380/4,args,OMEGA_GPU_GEMM_ARGS_WORDS*4);sim->threads=nt; 50 int rc=ws_run(sim,gx,gy);if(rc)fprintf(stderr,"dense sim: %s pc%d\n",sim->msg,sim->err_pc);return rc; 51 } 52 static void dense(void) { 53 const unsigned shapes[][3]={{1,1,1},{2,3,9},{3,129,7},{5,131,17},{7,33,27}};uint64_t digest=1469598103934665603ull; 54 for(unsigned v=0;v<5;v++) { 55 unsigned M=shapes[v][0],N=shapes[v][1],K=shapes[v][2]; 56 float *a=input(M*K,0,v+1),*b=input(K*N,0,v+7),*out=calloc(M*N,4); 57 OmegaGemmCfg cfg;omega_gpu_gemm_default_cfg(OMEGA_GPU_GEMM_F32_FFMA,&cfg); 58 BlackwellIRProgram *p=malloc(sizeof *p);CHECK(!omega_gpu_gemm_codegen(&cfg,OMEGA_GEMM_K_MAIN,p)); 59 WsSim sim={0};sim.p=p;sim.ranges[0]=(WsRange){(uintptr_t)a,(uintptr_t)(a+M*K)};sim.ranges[1]=(WsRange){(uintptr_t)b,(uintptr_t)(b+K*N)};sim.ranges[2]=(WsRange){(uintptr_t)out,(uintptr_t)(out+M*N)};sim.nranges=3; 60 int rc=omega_gpu_gemm_drive(&cfg,0,M,N,K,(uintptr_t)a,(uintptr_t)b,0,0,(uintptr_t)out,dense_launch,&sim);CHECK(!rc); 61 for(unsigned m=0;m