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/moe/caller.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 / moe / caller.c` 160 lines · 9147 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* Native ABI caller and unchanged-incumbent oracle comparison. Test logic's 3 * independent rank verifier lives in moe_verify.om; this is not production. */ 4 #include "cudapp_native.h" 5 #include 6 #include 7 #include 8 #include 9 uint32_t moe_incumbent(uint32_t, const uint32_t *, uint32_t *, uint32_t *, uint32_t *); 10 static uint64_t cfg[8], meta[8], req[16]; 11 static uint64_t ids[1024], work[10368], seg[1028], maps[2320]; 12 static uint32_t words[16], oi[1024], ox[1152], oy[1152], os[1028]; 13 static uint64_t dirs[514]; 14 static uint8_t mapwire[9280], segwire[8224], idwire[4096]; 15 static uint64_t window_cfg[8], windows[1024], window_meta[4]; 16 #define CHECK(x) do { if (!(x)) { fprintf(stderr,"FAIL line %d: %s\n",__LINE__,#x); exit(1); } } while (0) 17 static uint64_t plan(void) { 18 uint64_t r = 99; 19 CHECK(omega_moe_plan(&r,cfg,8,ids,1024,work,10368,seg,1028,maps,2320,meta,8)==0); 20 return r; 21 } 22 static uint64_t verify(void) { 23 uint64_t r = 99; 24 CHECK(omega_moe_verify(&r,cfg,8,ids,1024,work,10368,seg,1028,maps,2320,meta,8)==0); 25 return r; 26 } 27 static void setup(uint32_t n, uint32_t slots) { 28 uint64_t c[8] = {1,n,slots,256,256,1152,257,1160}; memcpy(cfg,c,sizeof c); 29 memset(ids,0,sizeof ids); memset(work,0x5a,sizeof work); memset(seg,0x5a,sizeof seg); 30 memset(maps,0x5a,sizeof maps); memset(meta,0x5a,sizeof meta); 31 } 32 static void dense(uint32_t n, unsigned mode) { 33 setup(n,8); 34 for (uint32_t t=0;t0 && v[2]==v[1]*9 && v[2]<=128); 133 CHECK(v[3]==first*2048*4 && v[4]==first*9*512*2*4); 134 CHECK(v[5]==first*9*512*4 && v[6]==first*9*2048*4 && v[7]==first*512); 135 first+=v[1]; 136 } 137 CHECK(first==n && window_meta[1]==n && window_meta[2]==n*9 && window_meta[3]==1); 138 } 139 uint64_t old_windows[1024],old_wmeta[4]; memcpy(old_windows,windows,sizeof windows); memcpy(old_wmeta,window_meta,sizeof window_meta); 140 window_cfg[6]=1; 141 CHECK(omega_moe_windows(&result,window_cfg,8,windows,1024,window_meta,4)==0 && result==2); 142 CHECK(!memcmp(old_windows,windows,sizeof windows) && !memcmp(old_wmeta,window_meta,sizeof window_meta)); 143 window_cfg[6]=128; window_cfg[7]=1; 144 CHECK(omega_moe_windows(&result,window_cfg,8,windows,1024,window_meta,4)==0 && result==1); 145 CHECK(!memcmp(old_windows,windows,sizeof windows) && !memcmp(old_wmeta,window_meta,sizeof window_meta)); 146 uint64_t q[16]={4096,8192,12288,65536,131072,196608,262144,512,14,126,134,9,1,1,1,256}; 147 memcpy(req,q,sizeof q); CHECK(group()==0); 148 for (unsigned i=0;i<7;i++) { CHECK(words[i*2]==req[i]); CHECK(words[i*2+1]==0); } 149 CHECK(words[14]==512 && words[15]==14); 150 uint32_t before[16]; memcpy(before,words,sizeof words); 151 #define BAD(field,value,rc) do { uint64_t save=req[field]; req[field]=value; CHECK(group()==rc); CHECK(!memcmp(before,words,sizeof words)); req[field]=save; } while(0) 152 BAD(8,15,1); BAD(8,0,1); BAD(11,8,1); BAD(15,255,1); 153 BAD(9,125,2); BAD(10,133,2); BAD(7,0,2); BAD(7,513,3); BAD(0,4097,3); 154 BAD(12,0,4); BAD(13,2,4); BAD(14,0,4); 155 BAD(3,4096,5); BAD(4,65536,5); BAD(5,65536,5); BAD(6,196608,5); 156 BAD(0,UINT64_MAX-7,5); BAD(3,UINT64_MAX-7,5); BAD(7,128,2); BAD(8,UINT64_MAX,1); 157 req[12]=0; req[13]=0; CHECK(group()==0); req[12]=1; req[13]=1; 158 puts("MOE-INDEX HOST PASS: native ABI, incumbent pf_group, GROUP format, sparse rank, refusals, mutants"); 159 return 0; 160 }