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/mathlibs_host_om_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 / mathlibs_host_om_test.c` 234 lines · 14769 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* The default-OFF C branch is compiled in this TU under distinct public names. 3 * The production archive must still resolve every default Omega entry strongly. */ 4 #include "../src/omega_gpu_mathlibs_host.h" 5 #define CUDAPP_MIGRATION_PENDING_C_MATHLIBS_HOST 1 6 #define omega_gpu_mathlibs_cache_clear oracle_cache_clear 7 #define omega_gpu_mathlibs_test_set_mutant oracle_set_mutant 8 #define omega_gpu_mathlibs_last_error oracle_last_error 9 #define omega_gpu_rng_codegen oracle_rng_codegen 10 #define omega_gpu_rng_generate oracle_rng_generate 11 #define omega_gpu_fft_codegen oracle_fft_codegen 12 #define omega_gpu_fft_twiddles oracle_fft_twiddles 13 #define omega_gpu_fft_c2c oracle_fft_c2c 14 #define omega_gpu_philox_codegen oracle_philox_codegen 15 #define omega_gpu_philox_generate_dist oracle_philox_dist 16 #define omega_gpu_philox_generate oracle_philox_generate 17 #define omega_gpu_fft_plan_walk oracle_walk 18 #define omega_gpu_fft_r2c oracle_r2c 19 #define omega_gpu_fft_c2r oracle_c2r 20 #define omega_gpu_fft_c2c_nd oracle_nd 21 #define omega_gpu_fft_many_walk oracle_many_walk 22 #define omega_gpu_fft_many oracle_many 23 #include "../src/omega_gpu_mathlibs_api.c" 24 #undef omega_gpu_fft_plan_walk 25 #undef omega_gpu_fft_many_walk 26 #undef omega_gpu_fft_c2c 27 #undef omega_gpu_fft_r2c 28 #undef omega_gpu_fft_c2r 29 #undef omega_gpu_fft_c2c_nd 30 #undef omega_gpu_fft_many 31 #undef omega_gpu_rng_generate 32 #undef omega_gpu_philox_generate_dist 33 extern __typeof__(oracle_rng_generate) omega_gpu_rng_generate; 34 extern __typeof__(oracle_philox_dist) omega_gpu_philox_generate_dist; 35 extern __typeof__(oracle_walk) omega_gpu_fft_plan_walk; 36 extern __typeof__(oracle_many_walk) omega_gpu_fft_many_walk; 37 extern __typeof__(oracle_fft_c2c) omega_gpu_fft_c2c; 38 extern __typeof__(oracle_r2c) omega_gpu_fft_r2c; 39 extern __typeof__(oracle_c2r) omega_gpu_fft_c2r; 40 extern __typeof__(oracle_nd) omega_gpu_fft_c2c_nd; 41 extern __typeof__(oracle_many) omega_gpu_fft_many; 42 #include 43 44 static unsigned cases; 45 #define CHECK(c) do { if (!(c)) { fprintf(stderr,"FAIL line %d case %u: %s\n",__LINE__,cases,#c); exit(1); } } while (0) 46 typedef struct { OmegaGpuFftManyLaunch *v; size_t n,cap; unsigned char *table; size_t bytes; } MC; 47 static int mc(void *ctx, const OmegaGpuFftManyLaunch *p) { 48 MC *c=ctx; 49 if (!c->table && c->bytes) { c->table=malloc(c->bytes); CHECK(c->table); memcpy(c->table,p->table,c->bytes); } 50 if (c->n==c->cap) { c->cap=c->cap?2*c->cap:64; c->v=realloc(c->v,c->cap*sizeof *c->v); CHECK(c->v); } 51 c->v[c->n]=*p; c->v[c->n++].table=NULL; 52 return 0; 53 } 54 static void plan(const OmegaGpuFftMany *p,int ip) { 55 cases++; 56 size_t a[8]={0},b[8]={0}; 57 int ra=oracle_many_walk(p,ip,a,NULL,NULL),rb=omega_gpu_fft_many_walk(p,ip,b,NULL,NULL); 58 if (ra!=rb) fprintf(stderr,"plan rank %u n %u,%u,%u batch %u type %u ip %d rc %d/%d\n",p->rank,p->n[0],p->n[1],p->n[2],p->batch,p->type,ip,ra,rb); 59 CHECK(ra==rb); 60 if (ra) return; 61 CHECK(!memcmp(a,b,sizeof a)); 62 MC x={.bytes=a[7]},y={.bytes=b[7]}; 63 CHECK(!oracle_many_walk(p,ip,a,mc,&x)); CHECK(!omega_gpu_fft_many_walk(p,ip,b,mc,&y)); 64 CHECK(x.n==y.n); CHECK(x.bytes==y.bytes); CHECK(!memcmp(x.table,y.table,x.bytes)); 65 for (size_t i=0;irank,p->n[0],p->n[1],p->n[2],p->type,x.v[i].kind,y.v[i].kind,x.v[i].a,y.v[i].a,x.v[i].b,y.v[i].b,x.v[i].nptr,y.v[i].nptr,x.v[i].nwords,y.v[i].nwords,x.v[i].elements,y.v[i].elements); 68 for(int k=0;k<18;k++) if(x.v[i].words[k]!=y.v[i].words[k]) fprintf(stderr,"word%d %u/%u\n",k,x.v[i].words[k],y.v[i].words[k]); 69 for(int k=0;k<3;k++) if(x.v[i].buf[k]!=y.v[i].buf[k]||x.v[i].off[k]!=y.v[i].off[k]) fprintf(stderr,"buf%d %u/%u off %llu/%llu\n",k,x.v[i].buf[k],y.v[i].buf[k],(unsigned long long)x.v[i].off[k],(unsigned long long)y.v[i].off[k]); 70 CHECK(0); 71 } 72 } 73 free(x.v);free(y.v);free(x.table);free(y.table); 74 } 75 typedef struct { OmegaGpuFftLaunch *v; size_t n,cap; } LC; 76 static int lc(void *ctx,const OmegaGpuFftLaunch *p) { 77 LC *c=ctx; 78 if(c->n==c->cap){ c->cap=c->cap?2*c->cap:16;c->v=realloc(c->v,c->cap*sizeof *c->v);CHECK(c->v); } 79 c->v[c->n]=*p;c->v[c->n++].tw=NULL; 80 if(p->tw_n) { float *t=malloc(8*p->tw_n);CHECK(t);memcpy(t,p->tw,8*p->tw_n);c->v[c->n-1].tw=t; } 81 return 0; 82 } 83 static void walk(unsigned mode,unsigned rank,const uint32_t *n,unsigned batch,int inv) { 84 cases++; size_t a[3]={0},b[3]={0};LC x={0},y={0}; 85 int ra=oracle_walk(mode,rank,n,batch,inv,a,lc,&x),rb=omega_gpu_fft_plan_walk(mode,rank,n,batch,inv,b,lc,&y); 86 CHECK(ra==rb); 87 if(!ra){CHECK(!memcmp(a,b,sizeof a));CHECK(x.n==y.n);for(size_t i=0;i255); 126 uint64_t out[8]; CHECK(omega_mh_fft(4096,4128,4,1,0,out)==0);CHECK(omega_mh_fft(4096,4127,4,1,0,out)==1); 127 CHECK(omega_mh_fft(4096,8192,4,UINT32_MAX,0,out)==2);CHECK(omega_mh_fft(4096,8192,3,1,0,out)==4); 128 } 129 static int stop_many(void *ctx, const OmegaGpuFftManyLaunch *launch) { (void)ctx; (void)launch; return -91; } 130 static int stop_walk(void *ctx, const OmegaGpuFftLaunch *launch) { (void)ctx; (void)launch; return -92; } 131 static void admission(void) { 132 float a[8194]={0}; 133 uint32_t dims[3]={4,4,4}; 134 const uint32_t badns[]={0,131073,UINT32_MAX}; 135 for(size_t i=0;i1 && !strcmp(argv[1],"--red")){ uint64_t l[8]={0,1,1},e[4]={4,1,1,1};CHECK(omega_mh_index(l,e,1,1)==2); } 233 printf("MATHLIBS-HOST-OM PASS cases=%u\n",cases);return 0; 234 }