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 / apirest / calc.om
| 1 | om2 |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | note Source-derived arithmetic plans; inputs 1..15, outputs 16..31. |
| 4 | fn ar_c1 q edit ulong 32 to ulong |
| 5 | put q 16 ulong div add uint get q 1 sub uint get q 2 1 uint get q 2 |
| 6 | put q 17 div get q 3 4 |
| 7 | ret 0 |
| 8 | end |
| 9 | fn ar_c2 q edit ulong 32 to ulong |
| 10 | nt = div get q 1 get q 4 |
| 11 | gx = div get q 2 get q 5 |
| 12 | th = mul 32 get q 6 |
| 13 | put q 16 nt |
| 14 | put q 17 gx |
| 15 | put q 18 th |
| 16 | put q 19 mul mul th gx nt |
| 17 | put q 20 and add mul nt 32 4095 18446744073709547520 |
| 18 | put q 21 div get q 3 128 |
| 19 | ret 0 |
| 20 | end |
| 21 | fn ar_c3 q edit ulong 32 to ulong |
| 22 | kb = div get q 3 128 |
| 23 | sc = mul div get q 2 128 kb |
| 24 | wb = mul get q 2 get q 3 |
| 25 | rb = mul mul div get q 2 8 add kb 1 4 |
| 26 | put q 16 sc |
| 27 | put q 17 wb |
| 28 | put q 18 rb |
| 29 | put q 19 mul get q 1 wb |
| 30 | put q 20 mul get q 1 rb |
| 31 | put q 21 and add mul get q 1 rb 15 18446744073709551600 |
| 32 | put q 22 mul get q 4 sc |
| 33 | put q 23 mul get q 4 wb |
| 34 | put q 24 mul get q 4 rb |
| 35 | put q 25 mul sc 4 |
| 36 | put q 26 div mul get q 4 rb 4 |
| 37 | put q 27 div rb 4 |
| 38 | put q 28 add mul get q 1 rb 16 |
| 39 | put q 29 and mul get q 1 wb 18446744073709551600 |
| 40 | ret 0 |
| 41 | end |
| 42 | fn ar_c4 q edit ulong 32 to ulong |
| 43 | r = mul uint get q 2 2 |
| 44 | if ne rem uint get q 1 r 0 |
| 45 | ret 1 |
| 46 | end |
| 47 | u = div uint get q 1 r |
| 48 | gx = div add u sub uint get q 3 1 uint get q 3 |
| 49 | if gt gx uint get q 4 |
| 50 | gx = uint get q 4 |
| 51 | end |
| 52 | if eq gx 0 |
| 53 | gx = 1 |
| 54 | end |
| 55 | put q 16 ulong u |
| 56 | put q 17 ulong gx |
| 57 | put q 18 ulong mul gx uint get q 3 |
| 58 | put q 19 ulong sub uint 0 uint get q 5 |
| 59 | put q 20 ulong sub uint 0 uint get q 6 |
| 60 | put q 21 ulong sub uint 0 uint get q 7 |
| 61 | put q 22 ulong sub uint 0 uint get q 8 |
| 62 | put q 23 mul 32 get q 3 |
| 63 | ret 0 |
| 64 | end |
| 65 | fn ar_c5 q edit ulong 32 to ulong |
| 66 | put q 16 mul 32 get q 1 |
| 67 | put q 17 mul mul get q 2 get q 3 get q 4 |
| 68 | put q 18 mul mul get q 1 get q 2 32 |
| 69 | ret 0 |
| 70 | end |
| 71 | fn ar_c6 q edit ulong 32 to ulong |
| 72 | put q 16 mul get q 1 add mul get q 2 get q 3 mul mul div get q 2 128 div get q 3 128 4 |
| 73 | ret 0 |
| 74 | end |
| 75 | fn ar_c7 q edit ulong 32 to ulong |
| 76 | bm = mul 16 get q 5 |
| 77 | span = mul mul get q 7 8 get q 6 |
| 78 | put q 16 bm |
| 79 | put q 17 span |
| 80 | put q 18 mul 32 get q 7 |
| 81 | put q 19 mul mul get q 8 get q 3 2 |
| 82 | put q 20 mul mul get q 1 get q 2 4 |
| 83 | put q 21 mul get q 4 32 |
| 84 | put q 22 mul add get q 1 bm 4 |
| 85 | put q 23 mul get q 1 get q 2 |
| 86 | put q 24 mul get q 8 get q 3 |
| 87 | put q 25 div get q 2 span |
| 88 | put q 26 mul bm 256 |
| 89 | put q 27 mul get q 4 4 |
| 90 | put q 28 add get q 1 bm |
| 91 | ret 0 |
| 92 | end |
| 93 | fn ar_c8 q edit ulong 32 to ulong |
| 94 | gx = div add uint get q 2 sub uint get q 5 1 uint get q 5 |
| 95 | if gt ulong gx get q 6 |
| 96 | gx = uint get q 6 |
| 97 | end |
| 98 | if eq gx 0 |
| 99 | gx = 1 |
| 100 | end |
| 101 | put q 16 ulong gx |
| 102 | put q 17 ulong mul gx uint get q 5 |
| 103 | put q 18 ulong mul 32 uint get q 5 |
| 104 | put q 19 mul get q 1 get q 2 |
| 105 | put q 20 mul add get q 1 get q 4 get q 3 |
| 106 | put q 21 mul mul add get q 1 get q 4 get q 3 4 |
| 107 | put q 22 mul mul get q 1 get q 2 4 |
| 108 | put q 23 mul get q 7 get q 3 |
| 109 | put q 24 mul mul get q 7 get q 3 4 |
| 110 | put q 25 mul get q 3 4 |
| 111 | put q 26 mul get q 1 get q 3 |
| 112 | put q 27 mul get q 4 get q 3 |
| 113 | put q 28 sub get q 9 get q 8 |
| 114 | put q 29 mul sub get q 9 get q 8 get q 3 |
| 115 | put q 30 mul get q 8 get q 2 |
| 116 | put q 31 mul mul get q 1 get q 3 4 |
| 117 | ret 0 |
| 118 | end |
| 119 | fn ar_c9 q edit ulong 32 to ulong |
| 120 | put q 16 div get q 1 16 |
| 121 | put q 17 div get q 2 8 |
| 122 | if eq get q 4 0 |
| 123 | ret 0 |
| 124 | end |
| 125 | rb = div get q 16 get q 4 |
| 126 | nb = div get q 17 get q 5 |
| 127 | rows = get q 1 |
| 128 | if gt rb get q 3 |
| 129 | rows = mul mul get q 3 16 get q 4 |
| 130 | end |
| 131 | gx = div get q 3 div div rows 16 get q 4 |
| 132 | if eq gx 0 |
| 133 | gx = 1 |
| 134 | end |
| 135 | if gt gx nb |
| 136 | gx = nb |
| 137 | end |
| 138 | put q 18 rows |
| 139 | put q 19 gx |
| 140 | put q 20 div div rows 16 get q 4 |
| 141 | ret 0 |
| 142 | end |
| 143 | fn ar_c10 q edit ulong 32 to ulong |
| 144 | put q 16 ulong mul mul uint get q 2 16 uint get q 3 |
| 145 | put q 17 mul mul get q 1 get q 2 128 |
| 146 | ret 0 |
| 147 | end |
| 148 | fn ar_c11 q edit ulong 32 to ulong |
| 149 | u = get q 2 |
| 150 | if ne get q 3 0 |
| 151 | for i ulong 32 |
| 152 | if le u 1 |
| 153 | break |
| 154 | end |
| 155 | if ge div div get q 1 16 u 2 |
| 156 | break |
| 157 | end |
| 158 | u = div u 2 |
| 159 | end |
| 160 | end |
| 161 | put q 16 u |
| 162 | ret 0 |
| 163 | end |
| 164 | fn ar_c12 q edit ulong 32 to ulong |
| 165 | mp = ulong mul div add uint get q 1 15 16 16 |
| 166 | kp = ulong mul div add uint get q 2 15 16 16 |
| 167 | np = ulong mul div add uint get q 3 7 8 8 |
| 168 | put q 16 mp |
| 169 | put q 17 kp |
| 170 | put q 18 np |
| 171 | put q 19 mul mul mp kp 2 |
| 172 | put q 20 mul mul mp np 4 |
| 173 | put q 21 mul mul kp np 2 |
| 174 | put q 22 mul get q 2 get q 3 |
| 175 | put q 23 mul mul get q 2 get q 3 2 |
| 176 | put q 24 div np 8 |
| 177 | put q 25 mul mul 64 kp 16 |
| 178 | ret 0 |
| 179 | end |
| 180 | fn ar_c13 q edit ulong 32 to ulong |
| 181 | kb = div get q 1 128 |
| 182 | g = get q 2 |
| 183 | gy = ulong 1 |
| 184 | if eq g 0 |
| 185 | g = kb |
| 186 | else |
| 187 | gy = div kb g |
| 188 | end |
| 189 | put q 16 kb |
| 190 | put q 17 g |
| 191 | put q 18 gy |
| 192 | put q 19 mul 32 g |
| 193 | ret 0 |
| 194 | end |
| 195 | fn arcalc q edit ulong 32 to ulong |
| 196 | if eq get q 0 1 |
| 197 | ret ar_c1 q |
| 198 | end |
| 199 | if eq get q 0 2 |
| 200 | ret ar_c2 q |
| 201 | end |
| 202 | if eq get q 0 3 |
| 203 | ret ar_c3 q |
| 204 | end |
| 205 | if eq get q 0 4 |
| 206 | ret ar_c4 q |
| 207 | end |
| 208 | if eq get q 0 5 |
| 209 | ret ar_c5 q |
| 210 | end |
| 211 | if eq get q 0 6 |
| 212 | ret ar_c6 q |
| 213 | end |
| 214 | if eq get q 0 7 |
| 215 | ret ar_c7 q |
| 216 | end |
| 217 | if eq get q 0 8 |
| 218 | ret ar_c8 q |
| 219 | end |
| 220 | if eq get q 0 9 |
| 221 | ret ar_c9 q |
| 222 | end |
| 223 | if eq get q 0 10 |
| 224 | ret ar_c10 q |
| 225 | end |
| 226 | if eq get q 0 11 |
| 227 | ret ar_c11 q |
| 228 | end |
| 229 | if eq get q 0 12 |
| 230 | ret ar_c12 q |
| 231 | end |
| 232 | if eq get q 0 13 |
| 233 | ret ar_c13 q |
| 234 | end |
| 235 | ret 1 |
| 236 | end |