interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / gpu / nvidia / om / codegen / cg_tern_policy.om

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