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_tgemm_spec.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Spec order is the public OmegaTgemmSpec field order, widened without truncation. |
| 3 | fn tg_spec_ok s view ulong 10 to ulong |
| 4 | if or lt get s 0 128 gt get s 0 65536 |
| 5 | ret 0 |
| 6 | end |
| 7 | if ne rem get s 0 128 0 |
| 8 | ret 0 |
| 9 | end |
| 10 | if and and ne get s 2 2 ne get s 2 4 ne get s 2 8 |
| 11 | ret 0 |
| 12 | end |
| 13 | if ne get s 3 2 |
| 14 | ret 0 |
| 15 | end |
| 16 | if and ne get s 4 8 ne get s 4 16 |
| 17 | ret 0 |
| 18 | end |
| 19 | if ne get s 5 32 |
| 20 | ret 0 |
| 21 | end |
| 22 | if and ne get s 6 1 ne get s 6 2 |
| 23 | ret 0 |
| 24 | end |
| 25 | if or ne get s 7 0 ne get s 8 0 |
| 26 | ret 0 |
| 27 | end |
| 28 | span = mul mul get s 4 8 get s 3 |
| 29 | if or eq get s 1 0 ge get s 1 131072 |
| 30 | ret 0 |
| 31 | end |
| 32 | if ne rem get s 1 span 0 |
| 33 | ret 0 |
| 34 | end |
| 35 | t = mul 32 get s 4 |
| 36 | if true |
| 37 | pieces = mul mul 16 get s 2 div get s 5 4 |
| 38 | if ne rem pieces t 0 |
| 39 | ret 0 |
| 40 | end |
| 41 | rj = div t div get s 5 4 |
| 42 | nj = div pieces t |
| 43 | if ne rem rj 16 0 |
| 44 | ret 0 |
| 45 | end |
| 46 | off = mul mul mul sub nj 1 rj get s 0 2 |
| 47 | extra = sub div 128 get s 5 1 |
| 48 | extra = mul extra get s 5 |
| 49 | extra = mul extra 2 |
| 50 | off = add off extra |
| 51 | if ge off 8388608 |
| 52 | ret 0 |
| 53 | end |
| 54 | end |
| 55 | shared = mul mul mul mul ulong 2 16 get s 2 get s 5 2 |
| 56 | if gt shared 16384 |
| 57 | ret 0 |
| 58 | end |
| 59 | if gt mul 32 span shared |
| 60 | ret 0 |
| 61 | end |
| 62 | if ne rem mul 8 span t 0 |
| 63 | ret 0 |
| 64 | end |
| 65 | if gt get s 9 5 |
| 66 | ret 0 |
| 67 | end |
| 68 | ret 1 |
| 69 | end |
| 70 | fn cg_tgemm_spec s view ulong 10 kind ulong to ulong |
| 71 | if eq tg_spec_ok s 0 |
| 72 | ret 0 |
| 73 | end |
| 74 | if eq kind 0 |
| 75 | ret 1 |
| 76 | end |
| 77 | if eq kind 1 |
| 78 | ret mul mul mul mul ulong 2 16 get s 2 get s 5 2 |
| 79 | end |
| 80 | if eq kind 2 |
| 81 | ret mul mul get s 4 8 get s 3 |
| 82 | end |
| 83 | if eq kind 3 |
| 84 | ret mul 16 get s 2 |
| 85 | end |
| 86 | ret 0 |
| 87 | end |