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/om/codegen/cg_qmma.om # 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 / om / codegen / cg_qmma.om` 425 lines · 6717 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note Qmma builder records follow omega_gpu_om_ir.h; meta contains allocation and loop events. 3 note Scalars in spec: kind, mutant/niter, wait/chains, stall, threads. 4 const NR ulong `18446744073709551615` 5 fn omega_cg_qmma_offset c ulong q ulong to ulong 6 ret add mul c 16 mul q 4 7 end 8 fn omega_cg_qmma_cw st ulong wb ulong rb ulong wt ulong to ulong 9 ret or or shl st 9 shl wb 14 or shl rb 17 shl wt 20 10 end 11 fn omega_cg_qmma_v m edit ulong 512 k ulong to ulong 12 v = get m 1 13 if ge v 256 14 put m 4 1 15 ret NR 16 end 17 put m add 64 v k 18 put m 1 add v 1 19 ret v 20 end 21 fn omega_cg_qmma_i x edit ulong 16 op ulong to void 22 for i ulong 16 23 put x i 0 24 end 25 put x 0 op 26 for i ulong 5 27 put x add i 1 NR 28 end 29 end 30 fn omega_cg_qmma_emit b edit ulong 8192 m edit ulong 512 x edit ulong 16 k ulong to void 31 wt = get m 3 32 st = ulong 6 33 wb = ulong 7 34 rb = ulong 7 35 pn = ulong 0 36 yld = ulong 0 37 if eq k 1 38 st = 14 39 end 40 if or eq k 2 eq k 3 41 st = 4 42 wb = 0 43 rb = 1 44 pn = or get m 3 3 45 yld = 8192 46 if eq k 2 47 pn = 3 48 else 49 wt = and wt 2 50 end 51 end 52 if eq k 4 53 st = 4 54 wb = 2 55 pn = 4 56 yld = 8192 57 end 58 if eq k 5 59 st = 4 60 rb = 1 61 pn = 2 62 yld = 8192 63 end 64 if or eq k 7 eq k 8 65 st = 5 66 if ne get x 9 0 67 pn = wt 68 end 69 end 70 if eq k 11 71 st = get x 7 72 end 73 put x 7 or omega_cg_qmma_cw st wb rb wt yld 74 put m 3 pn 75 n = get m 0 76 if ge n 1024 77 put m 4 2 78 ret 79 end 80 omega_cg_qmma_pack b x n 81 put m 0 add n 1 82 end 83 fn omega_cg_qmma_build s view ulong 8 b edit ulong 8192 m edit ulong 512 to ulong 84 x = new ulong 16 0 85 r = new ulong 32 0 86 for i ulong 512 87 put m i 0 88 end 89 kind = get s 0 90 if gt kind 2 91 ret 1 92 end 93 if eq kind 0 94 if or gt get s 1 1 gt get s 2 16 95 ret 1 96 end 97 end 98 if eq kind 1 99 if eq get s 1 0 100 ret 1 101 end 102 if eq get s 2 0 103 ret 1 104 end 105 if gt get s 2 16 106 ret 1 107 end 108 if or eq get s 3 0 gt get s 3 15 109 ret 1 110 end 111 if eq get s 4 0 112 ret 1 113 end 114 if ne rem get s 4 32 0 115 ret 1 116 end 117 if gt get s 4 1024 118 ret 1 119 end 120 end 121 put m 2 1 122 put m 320 2 123 note All registers are allocated in the same order as the independent C oracle. 124 if eq kind 0 125 for i ulong 12 126 k = ulong 2 127 if or eq i 2 eq i 3 128 k = 1 129 end 130 if eq i 8 131 k = 4 132 end 133 if or eq i 10 eq i 11 134 k = 4 135 end 136 put r i omega_cg_qmma_v m k 137 end 138 else 139 if eq kind 1 140 for i ulong 7 141 k = ulong 1 142 if eq i 0 143 k = 2 144 end 145 if eq i 5 146 k = 4 147 end 148 if eq i 6 149 k = 2 150 end 151 put r i omega_cg_qmma_v m k 152 end 153 for i ulong get s 2 154 put r add i 8 omega_cg_qmma_v m 4 155 end 156 else 157 for i ulong 7 158 k = ulong 1 159 if or lt i 2 eq i 5 160 k = 2 161 end 162 put r i omega_cg_qmma_v m k 163 end 164 end 165 end 166 omega_cg_qmma_i x 7 167 put x 1 0 168 put x 6 856 169 put x 8 1 170 omega_cg_qmma_emit b m x 4 171 omega_cg_qmma_i x 5 172 put x 1 get r 0 173 put x 6 896 174 omega_cg_qmma_emit b m x 2 175 if ne kind 1 176 omega_cg_qmma_i x 5 177 put x 1 get r 1 178 put x 6 904 179 omega_cg_qmma_emit b m x 2 180 end 181 for i ulong 2 182 omega_cg_qmma_i x 3 183 put x 1 get r add i 2 184 if eq kind 1 185 put x 1 get r add i 1 186 end 187 put x 6 33 188 if eq i 1 189 put x 6 37 190 end 191 omega_cg_qmma_emit b m x 2 192 end 193 if eq kind 0 194 omega_cg_qmma_i x 9 195 put x 1 get r 6 196 put x 2 get r 3 197 put x 4 get r 0 198 put x 6 1280 199 omega_cg_qmma_emit b m x 0 200 omega_cg_qmma_i x 9 201 put x 1 get r 4 202 put x 2 get r 2 203 put x 4 get r 6 204 put x 6 16 205 omega_cg_qmma_emit b m x 0 206 omega_cg_qmma_i x 9 207 put x 1 get r 7 208 put x 2 get r 2 209 put x 4 get r 6 210 put x 6 8 211 omega_cg_qmma_emit b m x 0 212 omega_cg_qmma_i x 9 213 put x 1 get r 5 214 put x 2 get r 3 215 put x 4 get r 1 216 put x 6 512 217 omega_cg_qmma_emit b m x 0 218 omega_cg_qmma_i x 9 219 put x 1 get r 5 220 put x 2 get r 2 221 put x 4 get r 5 222 put x 6 16 223 omega_cg_qmma_emit b m x 0 224 for i ulong 3 225 omega_cg_qmma_i x 57 226 put x 1 get r 8 227 put x 2 get r 4 228 put x 5 0 229 if eq i 1 230 put x 1 get r 10 231 put x 6 768 232 end 233 if eq i 2 234 put x 0 56 235 put x 1 get r 9 236 put x 2 get r 7 237 put x 6 512 238 end 239 k = ulong 3 240 if eq i 0 241 k = 2 242 end 243 omega_cg_qmma_emit b m x k 244 end 245 omega_cg_qmma_i x 16 246 put x 1 get r 11 247 put x 2 get r 8 248 put x 3 get r 9 249 if eq get s 1 0 250 put x 4 get r 10 251 end 252 put x 6 `1362114610` 253 put x 7 15 254 omega_cg_qmma_emit b m x 11 255 for i ulong get s 2 256 omega_cg_qmma_i x 0 257 put x 7 15 258 omega_cg_qmma_emit b m x 11 259 end 260 for i ulong 4 261 omega_cg_qmma_i x 12 262 put x 2 get r 5 263 put x 3 get r 11 264 put x 13 i 265 put x 6 mul i 4 266 put x 5 0 267 omega_cg_qmma_emit b m x 5 268 end 269 end 270 if eq kind 1 271 omega_cg_qmma_i x 2 272 put x 1 get r 3 273 put x 6 1 274 omega_cg_qmma_emit b m x 0 275 for i ulong 6 276 omega_cg_qmma_i x 2 277 put x 1 get r 5 278 put x 11 i 279 if ge i 4 280 put x 1 get r 6 281 put x 11 sub i 4 282 end 283 put x 6 `943208504` 284 omega_cg_qmma_emit b m x 0 285 end 286 for c ulong get s 2 287 for q ulong 4 288 omega_cg_qmma_i x 1 289 put x 1 get r add c 8 290 put x 11 q 291 omega_cg_qmma_emit b m x 0 292 end 293 end 294 omega_cg_qmma_i x 2 295 put x 1 get r 4 296 put x 6 get s 1 297 omega_cg_qmma_emit b m x 0 298 put m 16 get m 0 299 for c ulong get s 2 300 omega_cg_qmma_i x 16 301 put x 1 get r add c 8 302 put x 2 get r 5 303 put x 3 get r 6 304 put x 4 get r add c 8 305 put x 6 `1362114610` 306 put x 7 get s 3 307 omega_cg_qmma_emit b m x 11 308 end 309 omega_cg_qmma_i x 8 310 put x 1 get r 4 311 put x 2 get r 3 312 put x 4 get r 4 313 put x 6 `4294967295` 314 omega_cg_qmma_emit b m x 0 315 omega_cg_qmma_i x 28 316 put x 2 get r 4 317 put x 3 get r 3 318 omega_cg_qmma_emit b m x 1 319 omega_cg_qmma_i x 46 320 put x 9 1 321 put x 6 and sub get m 16 get m 0 `4294967295` 322 omega_cg_qmma_emit b m x 8 323 put m 5 1 324 put m 17 sub get m 0 1 325 for i ulong 4 326 omega_cg_qmma_i x 0 327 put x 7 15 328 omega_cg_qmma_emit b m x 11 329 end 330 if true 331 t = omega_cg_qmma_v m 1 332 omega_cg_qmma_i x 8 333 put x 1 t 334 put x 2 get r 2 335 put x 4 get r 1 336 put x 6 get s 4 337 omega_cg_qmma_emit b m x 0 338 omega_cg_qmma_i x 9 339 put x 1 get r 0 340 put x 2 t 341 put x 4 get r 0 342 put x 6 mul get s 2 16 343 omega_cg_qmma_emit b m x 0 344 end 345 for c ulong get s 2 346 for q ulong 4 347 omega_cg_qmma_i x 12 348 put x 2 get r 0 349 put x 3 get r add c 8 350 put x 13 q 351 put x 6 omega_cg_qmma_offset c q 352 put x 5 0 353 omega_cg_qmma_emit b m x 5 354 end 355 end 356 end 357 if eq kind 2 358 omega_cg_qmma_i x 8 359 put x 1 get r 4 360 put x 2 get r 3 361 put x 4 get r 2 362 put x 6 128 363 omega_cg_qmma_emit b m x 0 364 for i ulong 2 365 omega_cg_qmma_i x 9 366 put x 1 get r i 367 put x 2 get r 4 368 put x 4 get r i 369 put x 6 8 370 if eq i 1 371 put x 6 4 372 end 373 omega_cg_qmma_emit b m x 0 374 end 375 omega_cg_qmma_i x 56 376 put x 1 get r 5 377 put x 2 get r 0 378 put x 5 0 379 omega_cg_qmma_emit b m x 2 380 omega_cg_qmma_i x 37 381 put x 1 get r 6 382 put x 2 get r 5 383 put x 3 get r 5 384 put x 13 1 385 put x 6 `1178940467` 386 omega_cg_qmma_emit b m x 0 387 omega_cg_qmma_i x 12 388 put x 2 get r 1 389 put x 3 get r 6 390 put x 5 0 391 omega_cg_qmma_emit b m x 5 392 end 393 omega_cg_qmma_i x 45 394 omega_cg_qmma_emit b m x 7 395 omega_cg_qmma_i x 46 396 n = get m 0 397 put x 7 `1032192` 398 omega_cg_qmma_pack b x n 399 put m 0 add n 1 400 ret 0 401 end 402 403 fn omega_cg_qmma_pack b edit ulong 8192 x view ulong 16 n ulong to void 404 off = mul n 8 405 for i ulong 6 406 put b add off i get x i 407 end 408 put b add off 6 or get x 6 shl get x 7 32 409 fl = or get x 8 or shl get x 9 1 shl get x 10 2 410 for i ulong 5 411 fl = or fl shl get x add i 11 add 16 mul i 8 412 end 413 put b add off 7 fl 414 end 415 416 fn cg_qmma kind ulong a ulong c ulong d ulong b edit ulong 8192 m edit ulong 512 to ulong 417 s = new ulong 8 0 418 put s 0 kind 419 put s 1 a 420 put s 2 c 421 put s 3 and d `4294967295` 422 put s 4 shr d 32 423 ret omega_cg_qmma_build s b m 424 end 425