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
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Blackwell QMD and constant-bank packing. Host memcpy and null checks stay in the C shell. |
| 3 | note Field values are the constants src/omega_blackwell_qmd.c cites. |
| 4 | note QMD words: clcdc0qmd.h via that file. Constant bank: empirical GB10 capture in the same file. |
| 5 | note WolframLanguageEvaluator: 16^^39c -> 924, 2^32-1 -> 4294967295, 16^^00800002 -> 8388610, 16^^2f5003a4 -> 793772964. |
| 6 | note WolframLanguageEvaluator: 16^^00230000 -> 2293760, 16^^00500200 -> 5243392, 16^^013f0000 -> 20905984. |
| 7 | note WolframLanguageEvaluator: 16^^00190000 -> 1638400, 16^^81810000 -> 2172715008, 16^^04b44808 -> 78923784. |
| 8 | note WolframLanguageEvaluator: BitAnd[16^^04b44808, BitNot[16^^7ff]] -> 78923776, 16^^1fffff -> 2097151, 10*2^21 -> 20971520. |
| 9 | note WolframLanguageEvaluator: 64*2^19 -> 33554432, 144*2^19 -> 75497472, 16*2^19 -> 8388608, 4096*2^19 -> 2147483648. |
| 10 | note WolframLanguageEvaluator: 16^^10300011 -> 271581201, 2^17 -> 131072, 16^^380 -> 896. |
| 11 | |
| 12 | fn qlo32 v ulong to ulong |
| 13 | ret and v 4294967295 |
| 14 | end |
| 15 | |
| 16 | fn qz96 q edit ulong 224 to void |
| 17 | for i ulong 96 |
| 18 | put q i 0 |
| 19 | end |
| 20 | end |
| 21 | |
| 22 | fn qz224 q edit ulong 224 to void |
| 23 | for i ulong 224 |
| 24 | put q i 0 |
| 25 | end |
| 26 | end |
| 27 | |
| 28 | fn qthrx m view ulong 16 to ulong |
| 29 | if ne get m 1 0 |
| 30 | ret get m 1 |
| 31 | end |
| 32 | if ne get m 3 0 |
| 33 | ret get m 3 |
| 34 | end |
| 35 | ret 64 |
| 36 | end |
| 37 | |
| 38 | fn qthry m view ulong 16 to ulong |
| 39 | if ne get m 2 0 |
| 40 | ret get m 2 |
| 41 | end |
| 42 | ret 1 |
| 43 | end |
| 44 | |
| 45 | fn qgrdx m view ulong 16 tx ulong to ulong |
| 46 | if ne get m 4 0 |
| 47 | ret get m 4 |
| 48 | end |
| 49 | if ne get m 6 0 |
| 50 | ret get m 6 |
| 51 | end |
| 52 | s = and add get m 7 tx 4294967295 |
| 53 | g = div and sub s 1 4294967295 tx |
| 54 | if eq g 0 |
| 55 | ret 1 |
| 56 | end |
| 57 | ret g |
| 58 | end |
| 59 | |
| 60 | fn qgprc n ulong to ulong |
| 61 | if eq n 0 |
| 62 | ret 16 |
| 63 | end |
| 64 | if lt n 16 |
| 65 | ret 16 |
| 66 | end |
| 67 | ret n |
| 68 | end |
| 69 | |
| 70 | fn qmd0w q edit ulong 224 va ulong to void |
| 71 | qz96 q |
| 72 | put q 4 8388610 |
| 73 | put q 10 2293760 |
| 74 | put q 12 qlo32 shr va 8 |
| 75 | put q 14 5243392 |
| 76 | put q 34 65537 |
| 77 | put q 35 2049 |
| 78 | end |
| 79 | |
| 80 | fn qmd1a m view ulong 16 q edit ulong 224 to void |
| 81 | qz96 q |
| 82 | put q 4 20905984 |
| 83 | put q 9 3 |
| 84 | put q 10 1638400 |
| 85 | put q 12 qlo32 shr get m 14 8 |
| 86 | put q 14 793772964 |
| 87 | put q 15 qlo32 get m 13 |
| 88 | put q 16 qlo32 shr get m 13 32 |
| 89 | put q 17 6 |
| 90 | put q 19 2172715008 |
| 91 | put q 20 56 |
| 92 | put q 22 67108864 |
| 93 | put q 32 qlo32 shr get m 10 4 |
| 94 | put q 33 or and shr get m 10 36 2097151 20971520 |
| 95 | end |
| 96 | |
| 97 | fn qmd1b m view ulong 16 q edit ulong 224 to ulong |
| 98 | tx = qthrx m |
| 99 | ty = qthry m |
| 100 | put q 34 or and tx 65535 shl and ty 65535 16 |
| 101 | gpr = qgprc get m 9 |
| 102 | put q 35 or or 1 shl and gpr 511 8 131072 |
| 103 | sm = get m 8 |
| 104 | if gt sm 32768 |
| 105 | ret 1 |
| 106 | end |
| 107 | s7 = ulong 8 |
| 108 | if ne sm 0 |
| 109 | s7 = div add sm 127 128 |
| 110 | end |
| 111 | put q 36 or 78923776 s7 |
| 112 | put q 37 0 |
| 113 | gx = qgrdx m tx |
| 114 | put q 39 gx |
| 115 | gy = get m 5 |
| 116 | if eq gy 0 |
| 117 | gy = ulong 1 |
| 118 | end |
| 119 | put q 40 gy |
| 120 | put q 41 1 |
| 121 | ret 0 |
| 122 | end |
| 123 | |
| 124 | fn qmd1c m view ulong 16 q edit ulong 224 to void |
| 125 | cb = get m 11 |
| 126 | sc = get m 12 |
| 127 | code = get m 10 |
| 128 | put q 42 qlo32 shr cb 6 |
| 129 | put q 43 or and shr cb 38 524287 33554432 |
| 130 | put q 44 qlo32 shr sc 6 |
| 131 | put q 45 or and shr sc 38 524287 75497472 |
| 132 | put q 52 qlo32 shr add cb 768 6 |
| 133 | put q 53 or and shr add cb 768 38 524287 8388608 |
| 134 | put q 56 qlo32 shr sc 6 |
| 135 | put q 57 or and shr sc 38 524287 2147483648 |
| 136 | put q 58 271581201 |
| 137 | put q 59 qlo32 shr code 8 |
| 138 | end |
| 139 | |
| 140 | fn qmd1w m view ulong 16 q edit ulong 224 to ulong |
| 141 | qmd1a m q |
| 142 | r = qmd1b m q |
| 143 | if ne r 0 |
| 144 | ret 1 |
| 145 | end |
| 146 | qmd1c m q |
| 147 | ret 0 |
| 148 | end |
| 149 | |
| 150 | fn qmdvw q view ulong 224 to ulong |
| 151 | if ne and shr get q 14 20 15 5 |
| 152 | ret 1 |
| 153 | end |
| 154 | if ne and shr get q 4 23 7 2 |
| 155 | ret 1 |
| 156 | end |
| 157 | if ne get q 37 0 |
| 158 | ret 1 |
| 159 | end |
| 160 | if eq get q 17 0 |
| 161 | ret 1 |
| 162 | end |
| 163 | if ne and shr get q 33 21 511 10 |
| 164 | ret 1 |
| 165 | end |
| 166 | if eq and get q 58 1 0 |
| 167 | ret 1 |
| 168 | end |
| 169 | ret 0 |
| 170 | end |
| 171 | |
| 172 | fn cb0a q edit ulong 224 to void |
| 173 | put q 0 641859584 |
| 174 | put q 1 3 |
| 175 | put q 48 2499697920 |
| 176 | put q 49 3893478299 |
| 177 | put q 62 1048575 |
| 178 | put q 64 536870912 |
| 179 | put q 65 3 |
| 180 | put q 66 570425344 |
| 181 | put q 67 3 |
| 182 | put q 70 604045312 |
| 183 | put q 71 3 |
| 184 | put q 80 1 |
| 185 | put q 82 67158016 |
| 186 | put q 83 2 |
| 187 | put q 91 1024 |
| 188 | end |
| 189 | |
| 190 | fn cb0b q edit ulong 224 to void |
| 191 | put q 108 79311560 |
| 192 | put q 114 1 |
| 193 | put q 118 288 |
| 194 | put q 126 632711424 |
| 195 | put q 127 3 |
| 196 | put q 128 1 |
| 197 | put q 129 1 |
| 198 | put q 130 1 |
| 199 | put q 132 1065353216 |
| 200 | put q 133 1065353216 |
| 201 | put q 134 1065353216 |
| 202 | put q 135 1024 |
| 203 | put q 136 1 |
| 204 | put q 137 1 |
| 205 | put q 138 1 |
| 206 | put q 139 1 |
| 207 | end |
| 208 | |
| 209 | fn cb0c q edit ulong 224 to void |
| 210 | put q 148 79311560 |
| 211 | put q 154 1 |
| 212 | put q 158 288 |
| 213 | put q 166 632711424 |
| 214 | put q 167 3 |
| 215 | put q 168 1 |
| 216 | put q 169 1 |
| 217 | put q 170 1 |
| 218 | put q 172 1065353216 |
| 219 | put q 173 1065353216 |
| 220 | put q 174 1065353216 |
| 221 | put q 175 1024 |
| 222 | put q 176 1 |
| 223 | put q 177 1 |
| 224 | put q 178 1 |
| 225 | put q 179 1 |
| 226 | put q 180 48 |
| 227 | put q 183 16777216 |
| 228 | put q 185 59840 |
| 229 | put q 189 59840 |
| 230 | put q 190 16777216 |
| 231 | put q 191 59839 |
| 232 | end |
| 233 | |
| 234 | fn cb0d q edit ulong 224 to void |
| 235 | put q 216 64 |
| 236 | put q 217 1 |
| 237 | put q 218 1 |
| 238 | put q 220 1 |
| 239 | put q 221 1 |
| 240 | put q 222 1 |
| 241 | put q 223 16776640 |
| 242 | end |
| 243 | |
| 244 | fn cbpch q edit ulong 224 va ulong to void |
| 245 | put q 68 qlo32 shr va 32 |
| 246 | put q 69 qlo32 va |
| 247 | put q 210 qlo32 shr add va 896 32 |
| 248 | put q 211 qlo32 add va 896 |
| 249 | put q 212 qlo32 shr add va 924 32 |
| 250 | put q 213 qlo32 add va 924 |
| 251 | end |
| 252 | |
| 253 | fn cb2d q edit ulong 224 m view ulong 16 to void |
| 254 | if ne get m 2 0 |
| 255 | put q 216 get m 2 |
| 256 | end |
| 257 | if ne get m 3 0 |
| 258 | put q 217 get m 3 |
| 259 | end |
| 260 | if ne get m 4 0 |
| 261 | put q 220 get m 4 |
| 262 | end |
| 263 | if ne get m 5 0 |
| 264 | put q 221 get m 5 |
| 265 | end |
| 266 | end |
| 267 | |
| 268 | fn cbnkw m view ulong 16 q edit ulong 224 two ulong to void |
| 269 | qz224 q |
| 270 | cb0a q |
| 271 | cb0b q |
| 272 | cb0c q |
| 273 | cb0d q |
| 274 | cbpch q get m 1 |
| 275 | if ne two 0 |
| 276 | cb2d q m |
| 277 | end |
| 278 | end |
| 279 | |
| 280 | fn argsw m view ulong 16 q edit ulong 224 mat ulong to void |
| 281 | put q 0 qlo32 get m 1 |
| 282 | put q 1 qlo32 shr get m 1 32 |
| 283 | put q 2 qlo32 get m 2 |
| 284 | put q 3 qlo32 shr get m 2 32 |
| 285 | put q 4 qlo32 get m 3 |
| 286 | put q 5 qlo32 shr get m 3 32 |
| 287 | put q 6 get m 4 |
| 288 | if ne mat 0 |
| 289 | put q 7 get m 5 |
| 290 | put q 8 get m 6 |
| 291 | put q 9 0 |
| 292 | end |
| 293 | end |
| 294 | |
| 295 | fn bw_qmd op ulong m view ulong 16 q edit ulong 224 to ulong |
| 296 | if eq op 0 |
| 297 | qmd0w q get m 1 |
| 298 | ret 0 |
| 299 | end |
| 300 | if eq op 1 |
| 301 | ret qmd1w m q |
| 302 | end |
| 303 | if eq op 2 |
| 304 | ret qmdvw q |
| 305 | end |
| 306 | if eq op 3 |
| 307 | cbnkw m q 0 |
| 308 | ret 0 |
| 309 | end |
| 310 | if eq op 4 |
| 311 | cbnkw m q 1 |
| 312 | ret 0 |
| 313 | end |
| 314 | if eq op 5 |
| 315 | argsw m q 0 |
| 316 | ret 0 |
| 317 | end |
| 318 | if eq op 6 |
| 319 | argsw m q 1 |
| 320 | ret 0 |
| 321 | end |
| 322 | ret 2 |
| 323 | end |