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_gdn_shape.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note GDN shape (omega_gdn_shape), shared by the builder unit cg_gdn and the policy unit cg_gdn_policy. |
| 3 | fn omega_gd_pick c bool a ulong b ulong to ulong |
| 4 | if c |
| 5 | ret a |
| 6 | end |
| 7 | ret b |
| 8 | end |
| 9 | note The shape: ratio 0 means 3; 1..3 are valid; 0 returned for an invalid ratio. |
| 10 | fn omega_gd_rr ra ulong to ulong |
| 11 | r = ra |
| 12 | if eq r 0 |
| 13 | r = 3 |
| 14 | end |
| 15 | if or lt r 1 gt r 3 |
| 16 | ret 0 |
| 17 | end |
| 18 | ret r |
| 19 | end |
| 20 | note Queries: 0 valid 1 r 2 vh 3 vdim 4 conv 5 par_scal 6 par_norm 7 par_bytes 8 tail_bytes 9 state_bytes 10 post_grid_y. |
| 21 | fn omega_gd_shq q ulong ra ulong bf ulong to ulong |
| 22 | r = omega_gd_rr ra |
| 23 | if eq r 0 |
| 24 | ret 0 |
| 25 | end |
| 26 | if eq q 0 |
| 27 | ret 1 |
| 28 | end |
| 29 | vh = mul 16 r |
| 30 | vdim = mul 128 vh |
| 31 | conv = add 4096 vdim |
| 32 | ps = mul 16 conv |
| 33 | pn = add ps mul 8 vh |
| 34 | if eq q 1 |
| 35 | ret r |
| 36 | end |
| 37 | if eq q 2 |
| 38 | ret vh |
| 39 | end |
| 40 | if eq q 3 |
| 41 | ret vdim |
| 42 | end |
| 43 | if eq q 4 |
| 44 | ret conv |
| 45 | end |
| 46 | if eq q 5 |
| 47 | ret ps |
| 48 | end |
| 49 | if eq q 6 |
| 50 | ret pn |
| 51 | end |
| 52 | if eq q 7 |
| 53 | ret add pn 512 |
| 54 | end |
| 55 | if eq q 8 |
| 56 | ret mul 6144 vh |
| 57 | end |
| 58 | if eq q 9 |
| 59 | ret mul omega_gd_pick ne bf 0 32768 65536 vh |
| 60 | end |
| 61 | if eq q 10 |
| 62 | ret div vh 8 |
| 63 | end |
| 64 | ret 0 |
| 65 | end |