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_graph_headscale.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_graph_headscale.c` 30 lines · 1351 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #include "cudapp_native.h" 3 #include 4 #include 5 #include 6 static uint32_t bits(float x) { uint32_t u; memcpy(&u,&x,4); return u; } 7 static float value(uint32_t u) { float x; memcpy(&x,&u,4); return x; } 8 int main(void) { 9 float x[4096], ref[4096]; 10 uint64_t cases=0; 11 /* Every exponent, sign, and the rounding boundaries of each mantissa. */ 12 const uint32_t mant[]={0,1,2,0x3fffff,0x400000,0x400001,0x7ffffe,0x7fffff}; 13 for (unsigned sign=0;sign<2;sign++) for(unsigned e=0;e<256;e++) { 14 for(unsigned i=0;i<8;i++) { x[i]=value((sign<<31)|(e<<23)|mant[i]); ref[i]=x[i]*0x1p-64f; } 15 uint64_t r=99; 16 if(omega_ghscale(&r,x,8)||r) return 1; 17 for(unsigned i=0;i<8;i++) { 18 uint32_t a=bits(x[i]),b=bits(ref[i]); 19 if ((b&0x7fffffff)>0x7f800000) { if((a&0x7fffffff)<=0x7f800000) return 2; } 20 else if(a!=b) return 3; 21 cases++; 22 } 23 } 24 for(unsigned i=0;i<4096;i++) { x[i]=value(0x3f800000+i); ref[i]=x[i]*0x1p-64f; } 25 uint64_t r=99; 26 if(omega_ghscale(&r,x,4096)||r||memcmp(x,ref,sizeof x)) return 4; 27 if(omega_ghscale(&r,x,0)||r) return 5; 28 printf("PASS graph head scaling float classes cases=%llu vector=4096 empty=0\n",(unsigned long long)cases); 29 return 0; 30 }