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/evidence/chip-gates-shared-20261112/resident-bisect/resident_dbg.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 / evidence / chip-gates-shared-20261112 / resident-bisect / resident_dbg.c` 74 lines · 5006 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #include "omega_gpu_resident.h" 3 #include "omega_gpu_cmdlist.h" 4 #include "gpu_resident_fixture.h" 5 #include 6 #include 7 #include 8 /* No device open without exact --chip argument and an operator-supplied window label. */ 9 static const uint32_t model_v[4][40]={ 10 {5,0,0,32,4,1,0,0, 5,32,0,36,4,1,0,0, 5,36,0,40,4,1,0,0, 5,40,0,44,4,1,0,0, 5,44,0,48,4,1,0,0}, 11 {1,0,16,32,4,4,0,0, 2,32,20,36,4,1,0,0, 2,36,20,40,4,1,0,0, 2,40,20,44,4,1,0,0, 2,44,20,48,4,1,0,0}, 12 {3,0,24,32,4,1,0,0, 1,0,16,36,4,4,0,0, 2,36,20,40,4,1,0,0, 2,40,20,44,4,1,0,0, 2,44,20,48,4,1,0,0}, 13 {1,0,16,32,4,4,0,0, 2,32,20,36,4,1,0,0, 3,36,24,40,4,1,0,0, 4,40,0,44,1,4,0,0, 5,44,0,45,1,1,0,0}}; 14 int main(int argc,char **argv) { 15 const uint32_t *MODEL=getenv("RMODEL")?model_v[atoi(getenv("RMODEL"))&3]:resident_model; 16 if(argc!=2||strcmp(argv[1],"--chip")||!getenv("SPARK_WINDOW")||!*getenv("SPARK_WINDOW")) { 17 fprintf(stderr,"NOT_RUN: --chip and an authorized SPARK_WINDOW are required\n");return 2; 18 } 19 static BlackwellIRProgram p; 20 OmegaGpuMem code[2]; OmegaGpuMem dm={0},xm={0},sm={0}; 21 memset(code,0,sizeof code); 22 uint32_t gpr[2]={0}; 23 OmegaGpuCmdList *cl=NULL; 24 int rc=1; 25 omega_gpu_session_lock(); 26 if(!omega_gpu_session_open()) goto unlock; 27 if(omega_gpu_session_alloc(sizeof resident_model,&dm)||omega_gpu_session_alloc(64*sizeof(float),&xm)||omega_gpu_session_alloc(10*sizeof(uint32_t),&sm)) goto unlock; 28 memcpy(dm.cpu,MODEL,sizeof resident_model); 29 if(omega_gpu_session_sync_to_gpu(&dm)) goto unlock; 30 for(unsigned i=0;i<2;i++) { 31 uint64_t err=0; OmegaBlackwellKernel k; 32 if(omega_gpu_resident_build(MODEL,i?1:(getenv("RLAYERS")?atoi(getenv("RLAYERS")):5),64,getenv("RCTAS")?atoi(getenv("RCTAS")):2,&p,&err)) goto unlock; 33 size_t bytes=omega_bw_program_code_bytes(&p); 34 if(omega_gpu_session_alloc_code(bytes,&code[i])||omega_blackwell_kernel_encode_into(&p,code[i].cpu,bytes,&k)||omega_gpu_session_sync_to_gpu(&code[i])) goto unlock; 35 gpr[i]=omega_bw_gpr_declared(p.regalloc.peak_gpr_usage); 36 if(gpr[i]<64) gpr[i]=64; 37 } 38 omega_gpu_session_unlock(); 39 if(omega_gpu_cmdlist_create(5,&cl)) goto free_buffers; 40 omega_gpu_session_lock(); 41 unsigned m0=getenv("RMODE")?(unsigned)atoi(getenv("RMODE")):0; for(unsigned witness=0;witness<2;witness++) for(unsigned mode=m0;mode>32);} 50 OmegaGpuLaunch L={.code_va=code[mode].va,.gpr_count=gpr[mode],.threads_x=(getenv("RTHREADS")?atoi(getenv("RTHREADS")):32),.threads_y=1,.grid_x=(getenv("RCTAS")?atoi(getenv("RCTAS")):2),.grid_y=1,.num_elements=64,.args=args,.n_args=6,.timeout_ms=20000}; 51 if(omega_gpu_cmdlist_add(cl,&L)<0) goto unlock; 52 } 53 OmegaGpuCmdListOpts opts={.mode=OMEGA_GPU_CMDLIST_PCAS,.barrier=OMEGA_GPU_CMDLIST_BARRIER_WFI,.timeout_ms=20000}; 54 OmegaGpuCmdListStats st={0}; 55 int src=omega_gpu_cmdlist_submit(cl,&opts,&st); 56 { uint32_t *sy=sm.cpu; float *xo=xm.cpu; printf("DBG submit rc=%d witness=%u mode=%u sync:",src,witness,mode); for(int q=0;q<10;q++) printf(" %u",sy[q]); printf("\nDBG x:"); for(int q=0;q<64;q++) printf(" %a",xo[q]); printf("\nDBG want:"); for(int q=0;q<64;q++) printf(" %a",expected[q]); printf("\n"); fflush(stdout); } 57 if(src||omega_gpu_session_sync_to_cpu(&xm)||omega_gpu_session_sync_to_cpu(&sm)) goto unlock; 58 if(st.launches!=count||st.sems_done!=count||memcmp(xm.cpu,expected,sizeof expected)) goto unlock; 59 uint32_t *sync=sm.cpu; 60 for(unsigned l=0;l