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/test_model_graphs_plans.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 / test_model_graphs_plans.c` 38 lines · 4144 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #include 3 #include 4 #include 5 #include "cudapp_native.h" 6 static uint64_t state=0x6a7d9421; 7 static uint64_t rnd(void){state^=state<<13;state^=state>>7;return state^=state<<17;} 8 static uint64_t align256(uint64_t x){return(x+255)&~UINT64_C(255);} 9 static void layout(const uint64_t c[32],uint64_t d[64]){ 10 uint64_t H=c[4],I=c[5],G=c[6],N=c[1],A=c[3],L=c[2],S=c[15],B=c[14],P=c[20],R=N*G,M=c[16],pad=c[17],lb=align256(c[13]); 11 uint64_t b[64]={0};unsigned count=18,split=64;memset(d,0,64*sizeof *d); 12 if(c[0]==0){uint64_t x[]={H*4,H*4,c[7]*4,c[8]*4,H*4,G*2*I*4,G*I*4,G*H*4,H*4,A*S*4,S*4,S*4,16,L*H*4,H*4,L*32,c[8]*4,H*4};memcpy(b,x,sizeof x);} 13 if(c[0]==1){uint64_t x[]={H*4*N,c[10]*4,H*4*N,A*S*4*N,S*4,S*4,c[19]*N,L*H*4,H*4,L*64+16,c[11]*4,c[18]*4,G*H*4,L*2*B,(H+c[12]+I)*4,H*4*N,c[9]*4,c[11]*4,c[12]*4,H*4,G*2*I*4,G*I*4,G*H*4,M*H*4,N*c[9]*4,N*c[10]*4,N*c[11]*4,N*c[12]*4,M*c[12]*4,N*H*4,N*lb,R*B,R*B,(R+pad)*4,(R+pad)*4,M*H*4,R*2*I*4,R*I*4,R*I*4,R*H*4};memcpy(b,x,sizeof x);count=40;split=15;} 14 if(c[0]==2){uint64_t x[]={H*4,c[10]*4,H*4,A*S*4,S*4,S*4,16,L*2*H*4,H*4,L*64+16,c[11]*4,c[18]*4,2*I*4,H*4,c[9]*4,c[11]*4,c[12]*4,H*4,2*I*4,I*4};memcpy(b,x,sizeof x);count=20;split=13;} 15 if(c[0]==3){R=P*G;uint64_t x[]={P*H*4,P*c[13],256*B,256*B,B,B,(R+pad)*4,(R+pad)*4,(P+pad)*4,(P+pad)*4,P*H*4,(P+pad)*H*4,P*c[9]*4,P*c[10]*4,P*c[11]*4,P*c[12]*4,(P+pad)*c[12]*4,P*H*4,(P+pad)*H*4,R*2*I*4,R*I*4,(R+pad)*I*4,R*H*4};memcpy(b,x,sizeof x);count=23;} 16 uint64_t off=0;for(unsigned i=0;i=q[2])expected=2;else{expected=1;uint64_t n=q[2]-q[3];if(n>q[4])n=q[4];want[0]=q[0]+q[3];want[1]=q[1]+q[3];want[2]=n;want[3]=n/16;want[4]=(n/16+q[5]-1)/q[5];}rc=omega_mg_copy(&r,q,16,got,16);} 21 else if(kind==1){if(((q[1]|q[2])&15)||q[1]+q[2]>q[3])expected=0;else if(q[4]>=q[2])expected=2;else{expected=1;uint64_t n=q[2]-q[4];if(n>`67108864`)n=`67108864`;want[2]=n;want[3]=q[4];want[0]=q[0]+q[1]+q[4];want[1]=q[5];if(!q[6]){want[1]=want[0];want[0]=q[5];}}rc=omega_mg_xfer(&r,q,16,got,16);} 22 else{if(!q[2]||!q[3]||!q[4])expected=0;else if(q[2]*q[1]>65536)expected=2;else if(q[1]%8||q[1]<(uint32_t)(q[7]+2))expected=3;else{expected=1;memcpy(want,q,sizeof want);want[8]=q[2]*q[3]*q[4];want[9]=20000;want[10]=200000;}rc=omega_mg_lauch(&r,q,16,got,16);} 23 if(rc||r!=expected||(expected==1&&memcmp(got,want,sizeof got))){fprintf(stderr,"FAIL graph plan kind=%u status=%llu/%llu rc=%d\n",kind,(unsigned long long)r,(unsigned long long)expected,rc);return 1;}return 0; 24 } 25 int main(void){ 26 for(unsigned i=0;i<10032;i++){ 27 uint64_t c[32]={0,1+rnd()%8,1+rnd()%64,1+rnd()%2048,1024*(1+rnd()%5),256*(1+rnd()%68),1+rnd()%9,5120,4096,12288,64,9216,4096,rnd()%65536,32,2048,8,8,256,256,1+rnd()%128},a[64],b[64],r=0; 28 for(unsigned m=0;m<4;m++){c[0]=m;layout(c,a);if(omega_mg_layout(&r,c,32,b,64)||r!=1||memcmp(a,b,sizeof a)){fprintf(stderr,"FAIL graph layout model=%u case=%u\n",m,i);return 1;}b[i%64]^=1;if(!memcmp(a,b,sizeof a))return 1;} 29 uint64_t q[16]={rnd()&UINT64_C(0xfffffffffff0),rnd()&65535,((rnd()%`134217728`)&~UINT64_C(15)),rnd()%`134217728`,`16777216`,256,rnd()&1,0}; 30 if(i<32){q[2]=UINT64_C(1)<>32))return 1; 35 q[1]=rnd()%513;q[2]=rnd()%1025;q[3]=rnd()%1025;q[4]=rnd()%129;q[7]=rnd()%513;if(plan(2,q))return 1; 36 } 37 puts("MODEL-GRAPHS plans PASS layouts=40128 prefill=30096 record-flip=CAUGHT");return 0; 38 }