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_resident_chip.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_resident_chip.c` 66 lines · 3864 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 int main(int argc,char **argv) { 10 if(argc!=2||strcmp(argv[1],"--chip")||!getenv("SPARK_WINDOW")||!*getenv("SPARK_WINDOW")) { 11 fprintf(stderr,"NOT_RUN: --chip and an authorized SPARK_WINDOW are required\n");return 2; 12 } 13 static BlackwellIRProgram p; 14 OmegaGpuMem code[2]; OmegaGpuMem dm={0},xm={0},sm={0}; 15 memset(code,0,sizeof code); 16 uint32_t gpr[2]={0}; 17 OmegaGpuCmdList *cl=NULL; 18 int rc=1; 19 omega_gpu_session_lock(); 20 if(!omega_gpu_session_open()) goto unlock; 21 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; 22 memcpy(dm.cpu,resident_model,sizeof resident_model); 23 if(omega_gpu_session_sync_to_gpu(&dm)) goto unlock; 24 for(unsigned i=0;i<2;i++) { 25 uint64_t err=0; OmegaBlackwellKernel k; 26 if(omega_gpu_resident_build(resident_model,i?1:5,64,2,&p,&err)) goto unlock; 27 size_t bytes=omega_bw_program_code_bytes(&p); 28 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; 29 gpr[i]=omega_bw_gpr_declared(p.regalloc.peak_gpr_usage); 30 if(gpr[i]<64) gpr[i]=64; 31 } 32 omega_gpu_session_unlock(); 33 if(omega_gpu_cmdlist_create(5,&cl)) goto free_buffers; 34 omega_gpu_session_lock(); 35 for(unsigned witness=0;witness<2;witness++) for(unsigned mode=0;mode<2;mode++) { 36 float expected[64];resident_input(expected,witness);memcpy(xm.cpu,expected,sizeof expected); 37 resident_reference(resident_model,5,expected);memset(sm.cpu,0,10*sizeof(uint32_t)); 38 if(omega_gpu_session_sync_to_gpu(&xm)||omega_gpu_session_sync_to_gpu(&sm)) goto unlock; 39 omega_gpu_cmdlist_reset(cl); 40 unsigned count=mode?5:1; 41 for(unsigned l=0;l>32);} 44 OmegaGpuLaunch L={.code_va=code[mode].va,.gpr_count=gpr[mode],.threads_x=32,.threads_y=1,.grid_x=2,.grid_y=1,.num_elements=64,.args=args,.n_args=6,.timeout_ms=20000}; 45 if(omega_gpu_cmdlist_add(cl,&L)<0) goto unlock; 46 } 47 OmegaGpuCmdListOpts opts={.mode=OMEGA_GPU_CMDLIST_PCAS,.barrier=OMEGA_GPU_CMDLIST_BARRIER_WFI,.timeout_ms=20000}; 48 OmegaGpuCmdListStats st={0}; 49 if(omega_gpu_cmdlist_submit(cl,&opts,&st)||omega_gpu_session_sync_to_cpu(&xm)||omega_gpu_session_sync_to_cpu(&sm)) goto unlock; 50 if(st.launches!=count||st.sems_done!=count||memcmp(xm.cpu,expected,sizeof expected)) goto unlock; 51 uint32_t *sync=sm.cpu; 52 for(unsigned l=0;l