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 / core / sovereign-core / om / qwen-native / linear / standalone.om

197 lines · 2926 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2global lqio uchar 65536
3global lqhead ulong 9
4fn lqread n ulong to bool
5i = ulong 0
6while lt i n
7r = read 0 lqio i sub n i
8if le r 0
9ret false
10end
11i = add i ulong r
12end
13ret true
14end
15fn lqload h long off ulong n ulong to uint
16r = mapread h off lqio 0 n
17if ne r long n
18exit 5
19end
20v = uint get lqio 0
21if eq n 2
22v = or v shl uint get lqio 1 8
23end
24ret v
25end
26fn lqwgt fmt uint idx ulong si ulong to f32
27if eq fmt 0
28u = lqload get lqmap 0 mul idx 2 2
29ret bitcast f32 shl u 16
30end
31u = lqbits lqload get lqmap 0 idx 1
32w = bitcast f32 u
33u = lqload get lqmap 1 mul si 2 2
34ret mul w bitcast f32 shl u 16
35end
36fn lqrow fmt uint row ulong k uint sc uint to f32
37sumv = f64 0
38base = mul row ulong k
39sb = mul div row 128 ulong sc
40for col ulong ulong k
41w = lqwgt fmt add base col add sb div col 128
42u = uint mapget get lqmap 2 mul col 4 4
43v = bitcast f32 u
44sumv = add sumv mul f64 v f64 w
45end
46ret f32 sumv
47end
48fn lqref fmt uint m uint k uint sc uint to void
49for row ulong ulong m
50v = lqrow fmt row k sc
51r = mapset get lqmap 3 mul row 4 4 ulong bitcast uint v
52end
53end
54fn lqcase gpu bool shape bool to int
55if not lqread 72
56ret 2
57end
58for i ulong 9
59v = ulong 0
60for j ulong 8
61v = or v shl ulong get lqio add mul i 8 j mul j 8
62end
63put lqhead i v
64if and lt i 5 gt v 4294967295
65ret 2
66end
67end
68fmt = uint get lqhead 0
69m = uint get lqhead 1
70k = uint get lqhead 2
71sr = uint get lqhead 3
72sc = uint get lqhead 4
73for i ulong 4
74put lqlen i get lqhead add i 5
75end
76if not lqgeom fmt m k sr sc
77ret 2
78end
79if shape
80if ne read 0 lqio 0 1 0
81ret 2
82end
83ret 0
84end
85if gpu
86if not lqopen
87ret 3
88end
89end
90for i ulong 4
91n = get lqlen i
92if gt n 0
93h = long 0
94if gpu
95h = nvalloc n true
96else
97h = mapnew neg int 1 0 n 3 34
98end
99if le h 0
100ret 3
101end
102put lqmap i h
103off = ulong 0
104while and lt i 3 lt off n
105sz = sub n off
106if gt sz len lqio
107sz = len lqio
108end
109if not lqread sz
110ret 2
111end
112if ne mapwrite h off lqio 0 sz long sz
113ret 3
114end
115off = add off sz
116end
117end
118end
119if ne read 0 lqio 0 1 0
120ret 2
121end
122if gpu
123if not lqrun fmt m k sr sc
124ret 4
125end
126else
127lqref fmt m k sc
128end
129off = ulong 0
130while lt off get lqlen 3
131sz = sub get lqlen 3 off
132if gt sz len lqio
133sz = len lqio
134end
135if ne mapread get lqmap 3 off lqio 0 sz long sz
136ret 5
137end
138pos = ulong 0
139while lt pos sz
140r = write 1 lqio pos sub sz pos
141if le r 0
142ret 5
143end
144pos = add pos ulong r
145end
146off = add off sz
147end
148ret 0
149end
150fn main to int
151if ne argcnt 2
152exit 2
153end
154if ne argread 1 lqio 0 4 1
155exit 2
156end
157c = get lqio 0
158if or eq c 98 eq c 102
159fmt = uint 0
160if eq c 102
161fmt = 1
162end
163n = lqemit fmt
164r = write 1 gkcode mul ulong fmt 16384 n
165if ne r long n
166exit 5
167end
168exit 0
169end
170if eq c 116
171for b uint 256
172v = lqbits b
173for j uint 4
174put lqio add mul b 4 j uchar and shr v mul j 8 255
175end
176end
177r = write 1 lqio 0 1024
178if ne r 1024
179exit 5
180end
181exit 0
182end
183if eq c 114
184exit lqcase false false
185end
186if eq c 115
187exit lqcase false true
188end
189if ne c 103
190exit 2
191end
192rc = lqcase true false
193if not lqclose
194exit 6
195end
196exit rc
197end