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 / codegen / cg_tgemm_emit.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Reuses checked record packing from cg_qmma.om. Encoded register operands carry subregister in bits 8..15. |
| 3 | fn tg_reg v ulong to ulong |
| 4 | if eq v NR |
| 5 | ret NR |
| 6 | end |
| 7 | ret and v 255 |
| 8 | end |
| 9 | fn tg_sub v ulong to ulong |
| 10 | if eq v NR |
| 11 | ret 0 |
| 12 | end |
| 13 | ret shr v 8 |
| 14 | end |
| 15 | fn tg_u b edit ulong 8192 m edit ulong 512 op ulong d ulong a ulong imm ulong to void |
| 16 | x = new ulong 16 0 |
| 17 | omega_cg_qmma_i x op |
| 18 | put x 1 tg_reg d |
| 19 | put x 11 tg_sub d |
| 20 | put x 2 tg_reg a |
| 21 | put x 12 tg_sub a |
| 22 | put x 6 imm |
| 23 | kind = ulong 0 |
| 24 | if or eq op 3 eq op 5 |
| 25 | kind = 2 |
| 26 | end |
| 27 | if eq op 7 |
| 28 | put x 8 1 |
| 29 | kind = 4 |
| 30 | end |
| 31 | omega_cg_qmma_emit b m x kind |
| 32 | end |
| 33 | fn tg_ma b edit ulong 8192 m edit ulong 512 d ulong a ulong imm ulong c ulong to void |
| 34 | x = new ulong 16 0 |
| 35 | op = ulong 8 |
| 36 | if gt imm 4294967295 |
| 37 | op = 9 |
| 38 | end |
| 39 | omega_cg_qmma_i x op |
| 40 | put x 1 tg_reg d |
| 41 | put x 11 tg_sub d |
| 42 | put x 2 tg_reg a |
| 43 | put x 12 tg_sub a |
| 44 | put x 4 c |
| 45 | put x 6 and imm 4294967295 |
| 46 | omega_cg_qmma_emit b m x 0 |
| 47 | end |
| 48 | fn tg_bin b edit ulong 8192 m edit ulong 512 op ulong d ulong a ulong c ulong to void |
| 49 | x = new ulong 16 0 |
| 50 | omega_cg_qmma_i x op |
| 51 | put x 1 tg_reg d |
| 52 | put x 11 tg_sub d |
| 53 | put x 2 tg_reg a |
| 54 | put x 12 tg_sub a |
| 55 | put x 3 tg_reg c |
| 56 | put x 13 tg_sub c |
| 57 | omega_cg_qmma_emit b m x 0 |
| 58 | end |
| 59 | fn tg_load b edit ulong 8192 m edit ulong 512 ops ulong d ulong a ulong imm ulong to void |
| 60 | x = new ulong 16 0 |
| 61 | op = and ops 255 |
| 62 | kind = shr ops 8 |
| 63 | omega_cg_qmma_i x op |
| 64 | put x 1 d |
| 65 | put x 2 a |
| 66 | put x 6 imm |
| 67 | if or eq op 56 eq op 57 |
| 68 | put x 5 0 |
| 69 | end |
| 70 | if lt kind 16 |
| 71 | omega_cg_qmma_emit b m x kind |
| 72 | else |
| 73 | sb = sub kind 16 |
| 74 | put x 7 or omega_cg_qmma_cw 4 sb 1 and get m 3 2 8192 |
| 75 | put m 3 or get m 3 2 |
| 76 | put m 7 or get m 7 shl 1 sb |
| 77 | n = get m 0 |
| 78 | if ge n 1024 |
| 79 | put m 4 2 |
| 80 | ret |
| 81 | end |
| 82 | omega_cg_qmma_pack b x n |
| 83 | put m 0 add n 1 |
| 84 | end |
| 85 | end |
| 86 | fn tg_store b edit ulong 8192 m edit ulong 512 op ulong a ulong v ulong imm ulong to void |
| 87 | x = new ulong 16 0 |
| 88 | omega_cg_qmma_i x op |
| 89 | put x 2 a |
| 90 | put x 3 tg_reg v |
| 91 | put x 13 tg_sub v |
| 92 | put x 6 imm |
| 93 | if eq op 12 |
| 94 | put x 5 0 |
| 95 | end |
| 96 | omega_cg_qmma_emit b m x 5 |
| 97 | end |
| 98 | fn tg_hmma b edit ulong 8192 m edit ulong 512 d ulong a ulong v ulong stall ulong to void |
| 99 | x = new ulong 16 0 |
| 100 | omega_cg_qmma_i x 16 |
| 101 | put x 1 d |
| 102 | put x 2 a |
| 103 | put x 3 v |
| 104 | put x 4 d |
| 105 | put x 7 stall |
| 106 | omega_cg_qmma_emit b m x 11 |
| 107 | end |
| 108 | fn tg_sel b edit ulong 8192 m edit ulong 512 d ulong a ulong c ulong to void |
| 109 | x = new ulong 16 0 |
| 110 | omega_cg_qmma_i x 51 |
| 111 | put x 1 d |
| 112 | put x 2 a |
| 113 | put x 3 a |
| 114 | put x 13 1 |
| 115 | put x 4 c |
| 116 | put x 6 216 |
| 117 | omega_cg_qmma_emit b m x 0 |
| 118 | end |
| 119 | fn tg_bar b edit ulong 8192 m edit ulong 512 to void |
| 120 | x = new ulong 16 0 |
| 121 | omega_cg_qmma_i x 48 |
| 122 | omega_cg_qmma_emit b m x 0 |
| 123 | end |
| 124 | fn tg_nop b edit ulong 8192 m edit ulong 512 stall ulong to void |
| 125 | x = new ulong 16 0 |
| 126 | omega_cg_qmma_i x 0 |
| 127 | put x 7 stall |
| 128 | omega_cg_qmma_emit b m x 11 |
| 129 | end |
| 130 | fn tg_consume m edit ulong 512 sb ulong to void |
| 131 | mask = shl 1 sb |
| 132 | put m 3 or get m 3 and get m 7 mask |
| 133 | put m 7 and get m 7 not mask |
| 134 | end |