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/attn_views_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 / attn_views_diff.c` 85 lines · 4266 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #include "cudapp_native.h" 3 #include "attn_views_fixture.h" 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 static void oracle(uint32_t *a,const uint64_t *p,size_t na,size_t nw){ 11 memset(a,0,32*sizeof *a); 12 for(size_t i=0;i>32);} 13 for(size_t i=0;iff,b->ff,AV_N)&&floats_equal(a->rope,b->rope,1024)&& 30 floats_equal(a->fold,b->fold,32)&& 31 !memcmp((const char*)a+tail,(const char*)b+tail,sizeof *a-tail); 32 } 33 int main(void){ 34 uint64_t p[32],r=99;uint32_t got[32],want[32]; 35 for(size_t na=0;na<=16;na++)for(size_t nw=2*na;nw<=32;nw++){ 36 for(size_t i=0;i<32;i++)p[i]=UINT64_C(0xdeadbeef12345678)^((uint64_t)i<<40); 37 oracle(want,p,na,nw); 38 if(omega_av_pack(&r,p,32,got,32,na,nw)||r||memcmp(got,want,sizeof got))return 1; 39 } 40 if(omega_av_pack(&r,p,32,got,32,17,32)||r!=1)return 2; 41 if(omega_av_pack(&r,p,32,got,32,2,3)||r!=1)return 3; 42 if(omega_av_pack(&r,p,32,got,32,0,33)||r!=1)return 4; 43 if(omega_av_pack(&r,p,31,got,32,0,0)==0)return 5; 44 if(omega_av_pack(&r,p,32,(uint32_t*)p,32,0,0)==0)return 6; 45 oracle(want,p,4,16);want[1]^=1; 46 if(omega_av_pack(&r,p,32,got,32,4,16)||!memcmp(got,want,sizeof got))return 7; 47 AttnViewsFixture *a=calloc(1,sizeof *a),*b=calloc(1,sizeof *b); 48 if(!a||!b)return 8; 49 attn_omega(a);attn_oracle(b); 50 if(!fixture_equal(a,b)){ 51 for(size_t i=0;iresult[i]!=b->result[i]) 55 fprintf(stderr,"result[%zu]: %llu != %llu\n",i,(unsigned long long)a->result[i],(unsigned long long)b->result[i]); 56 fputs("FAIL host-data fixture differential\n",stderr);return 9; 57 } 58 b->args[1]^=1; 59 if(fixture_equal(a,b))return 10; 60 free(a);free(b); 61 unsigned char bytes[32]={0};uint64_t q[16]={0}; 62 if(omega_av_copy(&r,NULL,0,NULL,0,0)||r)return 11; 63 if(omega_av_copy(&r,bytes,16,bytes+1,16,16)!=32)return 12; 64 if(omega_av_copy(&r,bytes,16,bytes+16,16,16)||r)return 13; 65 if(omega_av_copy((uint64_t*)bytes,bytes,8,bytes+16,8,8)!=32)return 14; 66 if(omega_av_copy(&r,(void*)(UINTPTR_MAX-1),3,bytes,3,3)!=32)return 15; 67 if(omega_av_copy(&r,bytes,2,bytes+16,2,3)!=3)return 16; 68 if(omega_av_gath(&r,bytes,8,bytes+16,8,q,2)!=3)return 17; 69 /* Admission above the former fixed capacity, backed by a real unread mapping. */ 70 size_t large_bytes=(size_t)`16777217`*sizeof(uint32_t); 71 void *large=mmap(NULL,large_bytes,PROT_NONE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0); 72 if(large==MAP_FAILED)return 18; 73 int large_ok=omega_av_max(&r,large,`16777217`,0)==0 && r==1; 74 munmap(large,large_bytes);if(!large_ok)return 18; 75 if(omega_av_bfexp(&r,bytes+1,1,got,1,1)!=32)return 19; 76 uint16_t nanbf[2]={0x7f81,0xffc1};float nanout[2],nanwant[2]; 77 uint32_t nanbits[2]={0x7fc00000,0xffc00000}; 78 memcpy(nanwant,nanbits,sizeof nanbits); 79 if(omega_av_bfexp(&r,nanbf,2,nanout,2,2)||r||!floats_equal(nanout,nanwant,2))return 20; 80 q[0]=0;q[3]=0; 81 if(omega_av_table(&r,got,1,got,1,q,16,0)!=32)return 21; 82 if(omega_av_touch(&r,got,1,got+2,1,got,1,0)!=32)return 22; 83 puts("PASS attention host typed views differential; red check rejected; runtime bounds and aliases refused"); 84 return 0; 85 }