omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / gpu / nvidia / om / codegen / cg_tc_emit.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Tensor-core instruction records: omega_gpu_om_ir.h (22ebf8f). |
| 3 | note m[7] holds deferred scoreboards; m[8] loop start, m[16..17] closed loop. |
| 4 | const NR ulong 18446744073709551615 |
| 5 | fn tc_v m edit ulong 512 k ulong to ulong |
| 6 | v = get m 1 |
| 7 | if ge v 256 |
| 8 | put m 4 1 |
| 9 | ret NR |
| 10 | end |
| 11 | put m add 64 v k |
| 12 | put m 1 add v 1 |
| 13 | ret v |
| 14 | end |
| 15 | fn tc_i x edit ulong 16 op ulong to void |
| 16 | for q ulong 16 |
| 17 | put x q 0 |
| 18 | end |
| 19 | put x 0 op |
| 20 | for q ulong 5 |
| 21 | put x add q 1 NR |
| 22 | end |
| 23 | end |
| 24 | fn tc_cw st ulong wb ulong rb ulong wt ulong to ulong |
| 25 | ret or or shl st 9 shl wb 14 or shl rb 17 shl wt 20 |
| 26 | end |
| 27 | fn tc_pack b edit ulong 8192 m edit ulong 512 x view ulong 16 to void |
| 28 | n = get m 0 |
| 29 | if ge n 1024 |
| 30 | put m 4 2 |
| 31 | ret |
| 32 | end |
| 33 | p = mul n 8 |
| 34 | for q ulong 6 |
| 35 | put b add p q get x q |
| 36 | end |
| 37 | put b add p 6 or and get x 6 4294967295 shl get x 7 32 |
| 38 | fl = or get x 8 shl get x 9 1 |
| 39 | fl = or fl shl get x 10 2 |
| 40 | fl = or fl shl get x 11 16 |
| 41 | fl = or fl shl get x 12 24 |
| 42 | fl = or fl shl get x 13 32 |
| 43 | fl = or fl shl get x 14 40 |
| 44 | put b add p 7 or fl shl get x 15 48 |
| 45 | put m 0 add n 1 |
| 46 | end |
| 47 | fn tc_emit b edit ulong 8192 m edit ulong 512 x edit ulong 16 k ulong to void |
| 48 | wt = get m 3 |
| 49 | st = ulong 6 |
| 50 | wb = ulong 7 |
| 51 | rb = ulong 7 |
| 52 | pn = ulong 0 |
| 53 | yld = ulong 0 |
| 54 | if eq k 1 |
| 55 | st = 14 |
| 56 | end |
| 57 | if or eq k 2 eq k 3 |
| 58 | st = 4 |
| 59 | wb = 0 |
| 60 | rb = 1 |
| 61 | pn = or get m 3 3 |
| 62 | yld = 8192 |
| 63 | if eq k 2 |
| 64 | pn = 3 |
| 65 | else |
| 66 | wt = and wt 2 |
| 67 | end |
| 68 | end |
| 69 | if eq k 4 |
| 70 | st = 4 |
| 71 | wb = 2 |
| 72 | pn = 4 |
| 73 | yld = 8192 |
| 74 | end |
| 75 | if eq k 5 |
| 76 | st = 4 |
| 77 | rb = 1 |
| 78 | pn = 2 |
| 79 | yld = 8192 |
| 80 | end |
| 81 | if or eq k 7 eq k 8 |
| 82 | st = 5 |
| 83 | if ne get x 9 0 |
| 84 | pn = wt |
| 85 | end |
| 86 | end |
| 87 | if eq k 9 |
| 88 | st = 1 |
| 89 | yld = 8192 |
| 90 | end |
| 91 | if eq k 10 |
| 92 | st = 5 |
| 93 | yld = 8192 |
| 94 | end |
| 95 | if eq k 11 |
| 96 | st = get x 7 |
| 97 | end |
| 98 | if eq k 12 |
| 99 | st = 4 |
| 100 | wb = get x 7 |
| 101 | rb = 1 |
| 102 | wt = and wt 2 |
| 103 | pn = or get m 3 2 |
| 104 | put m 7 or get m 7 shl ulong 1 wb |
| 105 | yld = 8192 |
| 106 | end |
| 107 | put x 7 or tc_cw st wb rb wt yld |
| 108 | put m 3 pn |
| 109 | tc_pack b m x |
| 110 | end |
| 111 | fn tc_patch b edit ulong 8192 at ulong target ulong to void |
| 112 | p = add mul at 8 6 |
| 113 | put b p or and get b p 18446744069414584320 and sub target at 4294967295 |
| 114 | end |