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 / tc_host.om

113 lines · 1896 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note TC host queries. All public u32 fields arrive widened without sign conversion.
3note s: k rt ct warps mutant n aqn epi direct; unused slots zero.
4fn tch_ok s view ulong 16 v2 bool to bool
5k = get s 0
6rt = get s 1
7ct = get s 2
8w = get s 3
9mut = get s 4
10if or lt k 128 ne rem k 128 0
11ret false
12end
13if v2
14if gt k 16384
15ret false
16end
17if or and and ne rt 2 ne rt 4 ne rt 8 ne ct 2
18ret false
19end
20if and and ne w 4 ne w 8 ne w 16
21ret false
22end
23if and ne get s 6 1 ne get s 6 2
24ret false
25end
26if or gt get s 7 1 gt get s 8 1
27ret false
28end
29n = get s 5
30if eq n 0
31ret false
32end
33if ne rem n mul w 16 0
34ret false
35end
36if ge mul n mul rt 64 8388608
37ret false
38end
39else
40if and and ne rt 1 ne rt 2 ne rt 4
41ret false
42end
43if gt k 32768
44ret false
45end
46if and and ne ct 1 ne ct 2 ne ct 4
47ret false
48end
49if and and and ne w 1 ne w 2 ne w 4 ne w 8
50ret false
51end
52end
53if lt mul rt ct 4
54ret false
55end
56if ne rem mul rt 128 mul w 32 0
57ret false
58end
59if or gt mut 4 and eq mut 3 lt rt 2
60ret false
61end
62ret true
63end
64fn tch_scale u ulong to ulong
65sign = and u 2147483648
66e = and shr u 23 255
67f = and u 8388607
68if eq e 255
69ret u
70end
71if eq e 0
72if eq f 0
73ret u
74end
75e = 65
76while lt f 8388608 bound 23
77f = shl f 1
78e = sub e 1
79end
80f = and f 8388607
81else
82e = add e 64
83end
84if ge e 255
85ret or sign 2139095040
86end
87ret or or sign shl e 23 f
88end
89fn tch_bf u ulong to ulong
90ret narrow tch_scale u 7 127 255
91end
92note Public dispatcher: 0/1/2 TC queries, 3/4/5 TC2 queries, 6 packed conversion, 7 weight.
93fn tc_host op ulong s view ulong 16 to ulong
94if eq op 6
95ret or or tch_bf get s 0 shl tch_bf get s 2 16 or shl tch_bf get s 1 32 shl tch_bf get s 3 48
96end
97if eq op 7
98ret or shl and get s 0 127 4 shl and get s 0 128 8
99end
100if gt op 5
101ret 0
102end
103if not tch_ok s ge op 3
104ret 0
105end
106if eq rem op 3 0
107ret 1
108end
109if eq rem op 3 1
110ret mul get s 1 4096
111end
112ret mul mul get s 3 8 get s 2
113end