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_tern_policy.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Query 0 valid, 1 chunks, 2 steps, 3 coalesced, 4 output slot, 5 shared, 6 packed-word offset. |
| 3 | fn omega_ct_offset l ulong r ulong k ulong row ulong c ulong to ulong |
| 4 | kw = div k 16 |
| 5 | if eq l 0 |
| 6 | ret mul add mul row kw c 4 |
| 7 | end |
| 8 | rr = mul 2 r |
| 9 | blk = div row rr |
| 10 | j = rem row rr |
| 11 | off = mul mul mul blk rr kw 4 |
| 12 | off = add off mul mul c rr 4 |
| 13 | ret add off mul j 4 |
| 14 | end |
| 15 | fn omega_ct_derived q ulong k ulong r ulong w ulong to ulong |
| 16 | if eq q 2 |
| 17 | ret div k 256 |
| 18 | end |
| 19 | co = omega_ct_coal k r w |
| 20 | if eq q 3 |
| 21 | ret co |
| 22 | end |
| 23 | n = div add k 8191 8192 |
| 24 | xb = mul div k n 2 |
| 25 | slots = mul mul 16 r w |
| 26 | ret add xb mul co slots |
| 27 | end |
| 28 | fn cg_tern_policy q ulong k ulong a ulong b ulong c ulong d ulong to ulong |
| 29 | if eq q 6 |
| 30 | ret omega_ct_offset k a b c d |
| 31 | end |
| 32 | if eq q 1 |
| 33 | if eq k 0 |
| 34 | ret 0 |
| 35 | end |
| 36 | ret div and add k 8191 4294967295 8192 |
| 37 | end |
| 38 | if eq q 4 |
| 39 | ret and mul mul mul 2 shr a 32 and b 4294967295 4 4294967295 |
| 40 | end |
| 41 | l = and a 4294967295 |
| 42 | r = shr a 32 |
| 43 | w = and b 4294967295 |
| 44 | dep = shr b 32 |
| 45 | ok = omega_ct_valid k l r w dep c |
| 46 | if eq q 0 |
| 47 | ret ok |
| 48 | end |
| 49 | if eq ok 0 |
| 50 | ret 0 |
| 51 | end |
| 52 | ret omega_ct_derived q k r w |
| 53 | end |