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_rest_diff.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_rest_diff.c` 137 lines · 8258 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* Source-derived partitions for the REST continuation. The retained C fragment 3 * packers are independent verification oracles, not production dependencies. */ 4 #include "cudapp_native.h" 5 #define CUDAPP_MIGRATION_PENDING_C_API_SHELLS 1 6 #include "omega_api_shells.h" 7 #include "omega_api_views_rest.h" 8 #include "omega_blackwell_matmul.h" 9 #include "omega_blackwell_codegen.h" 10 #include 11 #include 12 #include 13 static unsigned checks; 14 #define EQ(a,b) do { uint64_t aa=(a),bb=(b); ++checks; if(aa!=bb){fprintf(stderr,"FAIL line %u: %llu != %llu\n",__LINE__,(unsigned long long)aa,(unsigned long long)bb);exit(1);} } while(0) 15 static void launch(void) { 16 const uint64_t v[]={0,1,UINT32_MAX-1,UINT32_MAX,(uint64_t)UINT32_MAX+1,UINT64_MAX}; 17 for(size_t i=0;i>32;b[2]=255;b[3]=32;b[4]=1;b[5]=17;b[6]=3; 21 b[8]=(uint32_t)v[i];b[9]=v[i]>>32;b[10]=(uint32_t)v[i];b[11]=v[i]>>32;b[12]=20; 22 b[14]=(uint32_t)v[i];b[15]=v[i]>>32;b[16]=96;b[17]=5;b[18]=7; 23 EQ(omega_arlaunch(&r,q,16,a,20),0);EQ(r,0);EQ(memcmp(a,b,sizeof a),0); 24 b[0]^=1; EQ(memcmp(a,b,sizeof a)!=0,1); /* red: low-half corruption */ 25 uint64_t va[5]={v[i],v[i],v[i],v[i],v[i]},inf[16]={0};uint32_t sc[2]={7,9},ga[12],gi[22]; 26 EQ(omega_argargs(&r,va,5,sc,2,ga,12),0);EQ(r,0); 27 for(unsigned j=0;j<5;j++){unsigned off=j<3?j*2:8+(j-3)*2;EQ(ga[off],(uint32_t)v[i]);EQ(ga[off+1],v[i]>>32);} 28 EQ(ga[6],7);EQ(ga[7],9);inf[10]=v[i];inf[11]=v[i]; 29 EQ(omega_arginfo(&r,inf,16,gi,22),0);EQ(r,0);EQ(gi[10],(uint32_t)v[i]);EQ(gi[11],v[i]>>32);EQ(gi[12],(uint32_t)v[i]);EQ(gi[13],v[i]>>32); 30 EQ(omega_arargsx(&r,va,5,sc,2,ga,12),0);EQ(r,0); 31 for(unsigned j=0;j<5;j++){EQ(ga[j*2],(uint32_t)v[i]);EQ(ga[j*2+1],v[i]>>32);} 32 EQ(ga[10],7);EQ(ga[11],9); 33 EQ(omega_arargsx(&r,va,5,sc,2,ga,11),0);EQ(r,1); 34 uint32_t spec[8]={(uint32_t)v[i],128,0,0,0,5,7,9},out[24],rr,cc; 35 omega_api_tcsp(0,0,128,&rr,&cc); 36 EQ(omega_artcsp(&r,spec,8,out,5),0);EQ(r,0);EQ(out[0],spec[0]);EQ(out[1],rr);EQ(out[2],cc);EQ(out[3],8);EQ(out[4],5); 37 omega_api_tgspec(0,0,128,&rr,&cc); 38 EQ(omega_artspec(&r,spec,8,out,10),0);EQ(r,0);EQ(out[0],spec[0]);EQ(out[1],128);EQ(out[2],rr);EQ(out[3],2);EQ(out[4],cc);EQ(out[5],32);EQ(out[6],1);EQ(out[7],5);EQ(out[8],7);EQ(out[9],9); 39 uint64_t ti[16]={(uint32_t)v[i],65537,65539,65541,4,2,0,0,3,11,13}; 40 EQ(omega_artcinfo(&r,ti,16,out,24),0);EQ(r,0); 41 uint64_t products[]={ti[1]*ti[3]*ti[4],ti[2]*ti[3]*ti[4],ti[2]*ti[8]*ti[5]*ti[4]*32}; 42 for(unsigned j=0;j<3;j++){EQ(out[12+j*2],(uint32_t)products[j]);EQ(out[13+j*2],products[j]>>32);} 43 } 44 } 45 static void cache(void) { 46 struct Rec {unsigned char valid,pinned,pad[2];uint32_t key;} a[17]; 47 const uint32_t vals[]={0,1,15,16,17,UINT32_MAX}; 48 for(unsigned n=0;n<=17;n++)for(unsigned z=0;z=nt[j]){EQ(r,0);break;} 64 unsigned last=nt[j]-next<64?nt[j]:next+64;EQ(r,1);EQ(q[8],next);EQ(q[9],last);EQ(q[10],(uint64_t)next*32*8);EQ(q[11],(uint64_t)(last-next)*32*8);EQ(q[12],q[11]*2);next=last; 65 } 66 } 67 const uint32_t rows[]={0,1,15,16,17,31,32,33}; 68 for(unsigned j=0;j=rows[j]){EQ(r,0);break;} 71 unsigned n=rows[j]-next<32?rows[j]-next:32;EQ(r,1);EQ(q[8],n);EQ(q[9],n/16);EQ(q[10],4096+(uint64_t)next*16*2);EQ(q[11],8192+(uint64_t)next*8*4);next+=32; 72 } 73 } 74 uint32_t cols[]={0,8,16}; 75 for(int skew=-1;skew<=1;skew++) { 76 uint64_t q[16]={0,3,16,2,8,8192,(uint64_t)(int64_t)skew},r=0;q[15]=1; 77 for(unsigned i=0;i<3;i++){EQ(omega_armstep(&r,q,16,cols,3),0);EQ(r,1);EQ(q[8],i);EQ(q[9],8192+(uint64_t)((int64_t)(cols[i]/8)+skew)*16*16);EQ(q[10],i*2*8);} 78 EQ(omega_armstep(&r,q,16,cols,3),0);EQ(r,0); 79 } 80 } 81 static void packing(void) { 82 const uint32_t dims[]={0,1,7,8,9,15,16,17}; 83 for(unsigned mi=0;mi=3?(void*)fs:(void*)src; 91 EQ(omega_cg_pkh(&r,q,12,in,q[8],actual,q[9]),0);EQ(r,0); 92 if(kind>=3)omega_matmul_frag_pack_a_f32(fs,m,k,mp,kp,expect);else omega_matmul_frag_pack_a(src,m,k,mp,kp,expect); 93 EQ(memcmp(actual,expect,q[9]*2),0); 94 } 95 } 96 for(unsigned ki=1;ki