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/src/omega_attn_host_policy.h # 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 / src / omega_attn_host_policy.h` 49 lines · 2143 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #ifndef OMEGA_ATTN_HOST_POLICY_H 3 #define OMEGA_ATTN_HOST_POLICY_H 4 #include "cudapp_native.h" 5 #include 6 #include 7 #ifndef CUDAPP_MIGRATION_PENDING_C_ATTENTION_HOST_POLICY 8 #define CUDAPP_MIGRATION_PENDING_C_ATTENTION_HOST_POLICY 0 9 #endif 10 #ifndef CUDAPP_MIGRATION_PENDING_C_SCAN_CHECK_REST 11 #define CUDAPP_MIGRATION_PENDING_C_SCAN_CHECK_REST 0 12 #endif 13 #ifndef CUDAPP_MIGRATION_PENDING_C_CLOCK_SCALARS 14 #define CUDAPP_MIGRATION_PENDING_C_CLOCK_SCALARS 0 15 #endif 16 /* Layout transport: rows, heads, dim, per, maxb, has_ids; output slots match attn_host.om. */ 17 static inline uint64_t ah_policy(uint64_t q[32],uint32_t op) { 18 #if CUDAPP_MIGRATION_PENDING_C_ATTENTION_HOST_POLICY 19 if(op==0){uint32_t t=((uint32_t)q[2]+31u)&~31u;q[8]=t;q[9]=(uint32_t)(16u*t);return 0;} 20 if(op==1){q[8]=q[1]*q[2];size_t idw=q[5]?q[3]*q[4]:1u;q[9]=q[3]*4u+q[1]+idw;q[10]=0;return 0;} 21 if(op==3){q[10]=q[22];return 0;} 22 if(q[10]>=q[0])return 0; 23 uint64_t nr=q[0]-q[10];if(nr>q[3])nr=q[3]; 24 q[11]=nr;q[12]=(uint32_t)(nr*4);q[13]=(uint32_t)(nr*4+q[1]);q[14]=q[13]+(q[5]?nr*q[4]:1u); 25 q[15]=q[10]*q[8];q[16]=nr*q[8]*4;q[17]=q[14]*4;q[18]=q[10]*q[4];q[19]=nr*q[4]*4; 26 q[20]=q[1]*4;q[21]=(uint32_t)(q[12]*4);q[22]=q[10]+q[3];return 1; 27 #else 28 uint64_t r=0;if(omega_ah_plan(&r,q,32,op)!=OMEGA_OK)__builtin_trap();return r; 29 #endif 30 } 31 static inline size_t ah_check(uint32_t op,const uint32_t *w,const uint32_t *x,size_t n) { 32 #if CUDAPP_MIGRATION_PENDING_C_SCAN_CHECK_REST 33 size_t bad=0; 34 if(op==0){for(size_t i=0;i