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 / attn-any / emit.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Eight-word BlackwellIR record ABI; generic omega_gpu_om_ir_replay owns replay only. |
| 3 | note Scheduling follows mathlibs_ir.om: fixed stall 6; serialized loads/stores via pending barriers. |
| 4 | const AN ulong 65535 |
| 5 | const AX ulong 18446744073709551615 |
| 6 | fn aa_rg d ulong a ulong b ulong c ulong to ulong |
| 7 | ret or or d shl a 16 or shl b 32 shl c 48 |
| 8 | end |
| 9 | fn aa_f v ulong to ulong |
| 10 | if eq v AN |
| 11 | ret AX |
| 12 | end |
| 13 | ret v |
| 14 | end |
| 15 | fn aa_cw st ulong wb ulong rb ulong wt ulong to ulong |
| 16 | ret or or shl st 9 shl wb 14 or shl rb 17 shl wt 20 |
| 17 | end |
| 18 | fn aa_cc m edit ulong 512 kind ulong to ulong |
| 19 | wt = get m 3 |
| 20 | cc = aa_cw 6 7 7 wt |
| 21 | nx = ulong 0 |
| 22 | k = and kind 255 |
| 23 | if eq k 1 |
| 24 | cc = aa_cw 14 7 7 wt |
| 25 | end |
| 26 | if eq k 2 |
| 27 | cc = or aa_cw 4 0 1 wt 8192 |
| 28 | nx = ulong 3 |
| 29 | end |
| 30 | if eq k 3 |
| 31 | cc = or aa_cw 4 7 1 wt 8192 |
| 32 | nx = ulong 2 |
| 33 | end |
| 34 | if eq k 4 |
| 35 | cc = or aa_cw 4 2 7 wt 8192 |
| 36 | nx = ulong 4 |
| 37 | end |
| 38 | if eq k 5 |
| 39 | cc = aa_cw 5 7 7 wt |
| 40 | if ne shr kind 8 0 |
| 41 | nx = wt |
| 42 | end |
| 43 | end |
| 44 | put m 3 nx |
| 45 | ret cc |
| 46 | end |
| 47 | fn aa_i x edit ulong 8192 m edit ulong 512 op ulong rg ulong imm ulong kind ulong to void |
| 48 | n = get m 0 |
| 49 | if ge n 1024 |
| 50 | put m 4 1 |
| 51 | ret |
| 52 | end |
| 53 | b = mul n 8 |
| 54 | put x b op |
| 55 | put x add b 1 aa_f and rg 65535 |
| 56 | put x add b 2 aa_f and shr rg 16 65535 |
| 57 | put x add b 3 aa_f and shr rg 32 65535 |
| 58 | put x add b 4 aa_f shr rg 48 |
| 59 | put x add b 5 AX |
| 60 | if or or eq op 11 eq op 19 eq op 12 |
| 61 | put x add b 5 0 |
| 62 | end |
| 63 | put x add b 7 shr kind 8 |
| 64 | cc = aa_cc m kind |
| 65 | put x add b 6 or and imm 4294967295 shl cc 32 |
| 66 | put m 0 add n 1 |
| 67 | end |
| 68 | fn aa_v m edit ulong 512 k ulong to ulong |
| 69 | v = get m 1 |
| 70 | if ge v 256 |
| 71 | put m 4 2 |
| 72 | ret 0 |
| 73 | end |
| 74 | put m add 64 v k |
| 75 | put m 1 add v 1 |
| 76 | ret v |
| 77 | end |
| 78 | fn aa_mov x edit ulong 8192 m edit ulong 512 d ulong imm ulong to void |
| 79 | aa_i x m 2 aa_rg d AN AN AN imm 0 |
| 80 | end |
| 81 | fn aa_bin x edit ulong 8192 m edit ulong 512 op ulong d ulong a ulong b ulong to void |
| 82 | aa_i x m op aa_rg d a b AN 0 0 |
| 83 | end |
| 84 | fn aa_mad x edit ulong 8192 m edit ulong 512 d ulong a ulong imm ulong c ulong to void |
| 85 | aa_i x m 8 aa_rg d a AN c imm 0 |
| 86 | end |
| 87 | fn aa_addr x edit ulong 8192 m edit ulong 512 d ulong a ulong stride ulong base ulong to void |
| 88 | aa_i x m 9 aa_rg d a AN base stride 0 |
| 89 | end |
| 90 | fn aa_load x edit ulong 8192 m edit ulong 512 d ulong addr ulong off ulong mode ulong to void |
| 91 | op = ulong 11 |
| 92 | if ne and mode 255 0 |
| 93 | op = ulong 19 |
| 94 | if ne off 0 |
| 95 | tmp = aa_v m 2 |
| 96 | idx = aa_v m 1 |
| 97 | aa_mov x m idx off |
| 98 | aa_addr x m tmp idx 1 addr |
| 99 | addr = tmp |
| 100 | off = ulong 0 |
| 101 | end |
| 102 | end |
| 103 | aa_i x m op aa_rg d addr AN AN off or 2 and mode 65280 |
| 104 | if eq and mode 255 1 |
| 105 | aa_mad x m d d 65536 AN |
| 106 | end |
| 107 | if eq and mode 255 2 |
| 108 | note BlackwellIR F16_TO_F32 is op 67 since the #280 numbering move (it was 66 on integ) |
| 109 | aa_i x m 67 aa_rg d d AN AN 0 0 |
| 110 | end |
| 111 | end |
| 112 | fn aa_cmp x edit ulong 8192 m edit ulong 512 a ulong b ulong to void |
| 113 | aa_i x m 28 aa_rg AN a b AN 0 1 |
| 114 | end |
| 115 | fn aa_bra x edit ulong 8192 m edit ulong 512 delta ulong flags ulong to void |
| 116 | aa_i x m 46 aa_rg AN AN AN AN delta or 5 shl flags 8 |
| 117 | end |
| 118 | fn aa_pred x edit ulong 8192 m view ulong 512 flags ulong to void |
| 119 | at = sub get m 0 1 |
| 120 | put x add mul at 8 7 flags |
| 121 | end |