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/runtime/host_policy_unit.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 / runtime / host_policy_unit.c` 48 lines · 3083 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #include 3 #include 4 #include 5 #include 6 #define CUDAPP_MIGRATION_PENDING_C_API_POLICY 1 7 #define omega_host_shape oracle_shape 8 #include "omega_host_policy.h" 9 #undef omega_host_shape 10 #undef OMEGA_HOST_POLICY_H 11 #undef CUDAPP_MIGRATION_PENDING_C_API_POLICY 12 #define CUDAPP_MIGRATION_PENDING_C_API_POLICY 0 13 #include "omega_host_policy.h" 14 static uint64_t rng = 0x67687374657374ULL; 15 static uint32_t next(void) { rng ^= rng << 13; rng ^= rng >> 7; rng ^= rng << 17; return (uint32_t)rng; } 16 static void check(int ok) { if (!ok) { fputs("HOST POLICY differential FAIL\n", stderr); exit(1); } } 17 static int templ(const uint32_t *q0,const uint32_t *q1) { 18 if(q0[12] || q1[12] || q1[15] || q1[16])return 0; 19 if(q1[32] || (q1[33] & ~(0xau<<21)))return 0; 20 if(q1[42] || (q1[43]&0x7ffffu))return 0; 21 if(q1[44] || (q1[45]&0x7ffffu))return 0; 22 if(q1[52] != (0x300u>>6) || (q1[53]&0x7ffffu))return 0; 23 return !(q1[56] || (q1[57]&0x7ffffu) || q1[59]); 24 } 25 static int launch(const uint32_t *q,const uint64_t *s) { 26 uint32_t gx=s[0],gy=s[1],bx=s[2],by=s[3],bz=s[4],shared=s[5],gpr=s[6]; 27 uint32_t wg=gpr<16?16:gpr, ws=shared?(shared+127u)/128u:8u; 28 if(!gx||!gy||!bx||!by||!bz||bx>0xffffu||by>0xffffu||bz>0xffu||wg>0x1ffu||ws>0x7ffu)return 0; 29 return q[34]==(bx|(by<<16)) && (q[35]&0xffu)==bz && ((q[35]>>8)&0x1ffu)==wg && (q[36]&0x7ffu)==ws && q[39]==gx && q[40]==gy && q[41]==1; 30 } 31 static void qcheck(uint32_t *a,uint32_t *b,uint64_t *s) { 32 uint64_t r; 33 check(omega_artifact_policy(&r,0,a,256,b,256,s,7)==OMEGA_OK);check(r==(uint64_t)templ(a,b)); 34 check(omega_artifact_policy(&r,1,b,256,b,256,s,7)==OMEGA_OK);check(r==(uint64_t)launch(b,s)); 35 } 36 int main(void) { 37 const uint32_t edge[]={0,1,2,3,63,64,65,127,128,129,255,256,257,511,512,1023,1024,1025,2047,2048,2049,8191,8192,8193,16383,16384,16385,262143,262144,262145,UINT32_MAX}; 38 for(unsigned mode=0;mode<8;mode++)for(size_t i=0;i>6;b[34]=32|(1u<<16);b[35]=1|(16u<<8);b[36]=8;b[39]=1;b[40]=1;b[41]=1; 43 qcheck(a,b,s); 44 for(unsigned which=0;which<2;which++)for(unsigned word=0;word<96;word++)for(unsigned bit=0;bit<32;bit++){uint32_t *q=which?a:b;q[word]^=1u<