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/cmdlist_sim_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 / cmdlist_sim_test.c` 61 lines · 2965 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* Queue epochs may complete in reverse order until an emitted WFI drains them. 3 * Each dispatch executes real IR in the existing warp simulator. No fake values 4 * are injected on hazards: missing ordering changes the computed buffer data. */ 5 #include "cudapp_native.h" 6 #include "bw_warp_sim.h" 7 #define fadd em_fadd 8 #define ffma em_ffma 9 #include "omega_bw_em.h" 10 #include 11 #include 12 #include 13 #define N 32u 14 #define BUFS 6u 15 #define LAUNCHES 7u 16 static uint64_t descriptors[200704],barriers[4096]; 17 static const unsigned ins[LAUNCHES]={0,2,1,3,4,0,5}; 18 static const unsigned outs[LAUNCHES]={1,3,4,5,0,0,2}; 19 static BlackwellIRProgram kernel; 20 static int build(void) { 21 omega_bw_ir_init(&kernel);Em em={0};em.p=&kernel;Em *e=&em; 22 int ud=UV64(e),pi=V64(e),po=V64(e),a=V64(e),tid=V(e),v=V(e),one=V(e); 23 ldcu64(e,ud,0x358);ldc64(e,pi,0x380);ldc64(e,po,0x388); 24 s2r(e,tid,BW_SR_TID_X);movi(e,one,0x3f800000u); 25 imadw(e,a,tid,4u,pi);ldg32(e,v,a,ud,1);fadd(e,v,v,one); 26 imadw(e,a,tid,4u,po);stg(e,a,0,v,ud);tail(e); 27 return em.err || omega_bw_regalloc_solve(&kernel); 28 } 29 static int dispatch(float data[BUFS][N],unsigned i,int order) { 30 static WsSim s; memset(&s,0,sizeof s);s.p=&kernel;s.threads=N;s.order=order; 31 uint64_t pi=(uintptr_t)data[ins[i]],po=(uintptr_t)data[outs[i]]; 32 s.cbank[0x380/4]=(uint32_t)pi;s.cbank[0x384/4]=(uint32_t)(pi>>32); 33 s.cbank[0x388/4]=(uint32_t)po;s.cbank[0x38c/4]=(uint32_t)(po>>32); 34 s.nranges=1;s.ranges[0]=(WsRange){(uintptr_t)data,(uintptr_t)(data+BUFS)}; 35 if(ws_run(&s,1,1)) { fprintf(stderr,"FAIL warp simulator: %s\n",s.msg);return 1; } 36 return 0; 37 } 38 int main(void) { 39 if(build()) return 2; 40 for(unsigned i=0;ibegin;i--) if(dispatch(queued,i-1,order)) return 2; 55 begin=end; 56 } 57 if(memcmp(serial,queued,sizeof serial)) { fprintf(stderr,"FAIL sim data: queue epochs differ from serialized execution (warp order %d)\n",order);return 1; } 58 } 59 printf("PASS sim data: seven dispatches, independent overlap and nonadjacent RAW/WAR/WAW, two warp orders\n"); 60 return 0; 61 }