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
CUDApp / om / api / attn_tables.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note The caller acquires native table pointers; Omega walks each plain table. |
| 3 | note Preserve the cut-F float polynomial, scalar order and empty-split handling. |
| 4 | fn av_ex2 x f32 to f32 |
| 5 | if le x f32 -127.0 |
| 6 | ret f32 0.0 |
| 7 | end |
| 8 | if gt x f32 127.0 |
| 9 | x = f32 127.0 |
| 10 | end |
| 11 | adj = f32 0.5 |
| 12 | if lt x f32 0.0 |
| 13 | adj = f32 -0.5 |
| 14 | end |
| 15 | n = int add x adj |
| 16 | f = sub x f32 n |
| 17 | px = f32 1.535336188319500e-4 |
| 18 | px = add mul px f f32 1.339887440266574e-3 |
| 19 | px = add mul px f f32 9.618437357674640e-3 |
| 20 | px = add mul px f f32 5.550332471162809e-2 |
| 21 | px = add mul px f f32 2.402264791363012e-1 |
| 22 | px = add mul px f f32 6.931472028550421e-1 |
| 23 | px = add f32 1.0 mul f px |
| 24 | if lt n -126 |
| 25 | px = mul px f32 0.5 |
| 26 | n = int -126 |
| 27 | end |
| 28 | ret mul px bitcast f32 shl uint add n 127 23 |
| 29 | end |
| 30 | fn av_fw p view f32 * q view ulong 16 row ulong w edit f32 18 to ulong |
| 31 | pw = add get q 2 2 |
| 32 | base = mul row get q 1 |
| 33 | base = mul base pw |
| 34 | mx = bitcast f32 uint 4286578688 |
| 35 | for s ulong get q 1 |
| 36 | idx = mul s pw |
| 37 | idx = add idx base |
| 38 | idx = add idx get q 2 |
| 39 | v = get p idx |
| 40 | if gt v mx |
| 41 | mx = v |
| 42 | end |
| 43 | end |
| 44 | put w 17 f32 0.0 |
| 45 | if not gt mx bitcast f32 uint 4286578688 |
| 46 | ret 0 |
| 47 | end |
| 48 | put w 17 f32 1.0 |
| 49 | lsum = f32 0.0 |
| 50 | for s ulong get q 1 |
| 51 | idx = mul s pw |
| 52 | idx = add idx base |
| 53 | idx = add idx get q 2 |
| 54 | v = get p idx |
| 55 | v = av_ex2 sub v mx |
| 56 | put w s v |
| 57 | idx = add idx 1 |
| 58 | v = mul v get p idx |
| 59 | lsum = add lsum v |
| 60 | end |
| 61 | put w 16 div f32 1.0 lsum |
| 62 | ret 0 |
| 63 | end |
| 64 | fn av_fval p view f32 * w view f32 18 q view ulong 4 d ulong to f32 |
| 65 | if not gt get w 17 f32 0.0 |
| 66 | ret f32 0.0 |
| 67 | end |
| 68 | base = mul get q 3 get q 1 |
| 69 | base = mul base add get q 2 2 |
| 70 | a = f32 0.0 |
| 71 | for s ulong get q 1 |
| 72 | idx = mul s add get q 2 2 |
| 73 | idx = add idx base |
| 74 | idx = add idx d |
| 75 | v = get p idx |
| 76 | v = mul get w s v |
| 77 | a = add a v |
| 78 | end |
| 79 | ret mul a get w 16 |
| 80 | end |
| 81 | fn av_fout p view f32 * dest edit f32 * w view f32 18 q view ulong 4 to void |
| 82 | for d ulong get q 2 |
| 83 | v = av_fval p w q d |
| 84 | idx = mul get q 3 get q 2 |
| 85 | idx = add idx d |
| 86 | put dest idx v |
| 87 | end |
| 88 | end |
| 89 | fn vc_fold p view f32 * dest edit f32 * q view ulong 16 to ulong |
| 90 | w = new f32 18 0.0 |
| 91 | r = new ulong 4 0 |
| 92 | put r 0 get q 0 |
| 93 | put r 1 get q 1 |
| 94 | put r 2 get q 2 |
| 95 | for jj ulong get q 7 |
| 96 | row = add get q 6 jj |
| 97 | rc = av_fw p q row w |
| 98 | if ne rc 0 |
| 99 | ret rc |
| 100 | end |
| 101 | put r 3 row |
| 102 | av_fout p dest w r |
| 103 | end |
| 104 | ret 0 |
| 105 | end |
| 106 | fn av_fold p view f32 * dest edit f32 * q view ulong 16 to ulong |
| 107 | z = new ulong 16 0 |
| 108 | for j ulong 16 |
| 109 | put z j get q j |
| 110 | end |
| 111 | for bb ulong add div get q 0 1000000 1 |
| 112 | put z 6 mul bb 1000000 |
| 113 | cnt = sub get q 0 get z 6 |
| 114 | if gt cnt 1000000 |
| 115 | cnt = ulong 1000000 |
| 116 | end |
| 117 | put z 7 cnt |
| 118 | rc = vc_fold p dest z |
| 119 | if ne rc 0 |
| 120 | ret rc |
| 121 | end |
| 122 | end |
| 123 | ret 0 |
| 124 | end |