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 / checks / nartf.om

407 lines · 8322 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/nartf.om: the Omega port of the artifacts() block of CUDApp tests/api_attn_rest_diff.c.
3note Composed after gpu/nvidia/om/api/attn_art.om (it starts with om2), the roots gpu/nvidia/om/api/na_json.om,
4note na_ver.om, na_layout.om, na_cubin.om and na_read.om, gpu/nvidia/checks/lib.om and gpu/nvidia/checks/lib-om2.om;
5note run with gpu/nvidia/checks/nartf.tsv. Rows, tab separated; bytes are lowercase hex, "-" for none:
6note j C BYTES the JSON string of the one-byte C string C (empty for C 0) is BYTES, quotes included
7note v H N R H >= N as the C semver_ge says: R 1, 0, or -1 when either is not a strict A.B.C
8note k BYTES the key list the C binding of manifest_layout_ok passes na_layout (kept for later rows)
9note b BYTES the base manifest of the test (kept for later rows)
10note L N R na_layout of the first N bytes of the base manifest (zero beyond it) is R
11note M I V R na_layout of the base manifest with byte I set to V is R
12note c BYTES TEXT the test's base cubin and its text (kept for later rows)
13note C N R na_cubin of the first N bytes of the base cubin, function foo, is R
14note X I V R na_cubin of the base cubin with byte I set to V is R
15note F N R na_cubin of the base cubin for a function name of N bytes f is R
16note T I V R na_cubin of the base cubin with byte I of the text xored with V is R
17note r N W na_read of the first N bytes of the base cubin is W (hex)
18note K CUBIN TEXT FUNCTION C OMEGA WHY
19note a known difference: the pending C answers C and na_cubin answers OMEGA for this cubin, text
20note and function name. The row passes only when OMEGA is still na_cubin's answer and C still
21note differs from it, so a change on either side fails the gate. C comes from the oracle (no C
22note runs here); OMEGA was recorded when the check first met the input. WHY says what differs.
23note The kept rows live in fixed arrays: a manifest of at most 8192 bytes (the binding's MANIFEST_CAP; one byte
24note more so that the test's 8192-byte refusal case reads zeros), a key list and a cubin of at most 4096 bytes and
25note a text of at most 64. A longer row is refused as a malformed table (exit 2), never cut. The units take views
26note and a pool that grows cannot be passed (docs/RUNTIME-POOLS.md), so each row copies what it needs into its
27note frame. The strict A.B.C parse of the v rows is the C binding's parse_semver, ported here: na_ver compares
28note parsed versions.
29text t_name "NARTF"
30text t_foo "foo"
31global nt_m uchar 8193
32global nt_k uchar 4096
33global nt_c uchar 4096
34global nt_t uchar 64
35note nt_n: 0 manifest length, 1 key length, 2 cubin length, 3 text length, 4 manifest and keys kept, 5 cubin kept
36global nt_n ulong 6
37fn cname to void
38for i ulong len t_name bound 64
39ckoc ulong get t_name i
40end
41end
42fn ntx i ulong to ulong
43n = cklen i
44if or eq n 0 gt n 16
45ckbad
46end
47v = ulong 0
48for j ulong n bound 16
49v = or shl v 4 cknib ckch i j
50end
51ret v
52end
53note field i as 0, 1, or 2 for -1
54fn ntr i ulong to ulong
55if and eq cklen i 2 eq ckch i 0 45
56if eq ckch i 1 49
57ret 2
58end
59end
60v = cknum i
61if gt v 1
62ckbad
63end
64ret v
65end
66note the C binding's parse_semver: three decimal components of 1 to 9 digits split by dots, nothing more
67fn ntsv s view uchar * v edit uint 3 to bool
68p = ulong 0
69for k ulong 3
70x = uint 0
71d = ulong 0
72while lt p len s bound 4096
73c = get s p
74if or lt c 48 gt c 57
75break
76end
77d = add d 1
78if gt d 9
79ret false
80end
81x = add mul x uint 10 uint sub c 48
82p = add p 1
83end
84if eq d 0
85ret false
86end
87put v k x
88if lt k 2
89if ge p len s
90ret false
91end
92if ne get s p 46
93ret false
94end
95p = add p 1
96end
97end
98ret eq p len s
99end
100note copy hex field i into global array k of the kept rows (0 manifest, 1 keys, 2 cubin, 3 text)
101fn ntkeep i ulong k ulong to void
102n = ckhexn i
103if eq k 0
104if ge n len nt_m
105ckbad
106end
107for j ulong n bound 8193
108put nt_m j uchar ckhex i j
109end
110end
111if eq k 1
112if gt n len nt_k
113ckbad
114end
115for j ulong n bound 4096
116put nt_k j uchar ckhex i j
117end
118end
119if eq k 2
120if gt n len nt_c
121ckbad
122end
123for j ulong n bound 4096
124put nt_c j uchar ckhex i j
125end
126end
127if eq k 3
128if gt n len nt_t
129ckbad
130end
131for j ulong n bound 64
132put nt_t j uchar ckhex i j
133end
134end
135put nt_n k n
136end
137note j rows
138fn ntj to bool
139js = new uchar 6 0
140if ne ckcnt 3
141ckbad
142end
143c = ntx 1
144if gt c 255
145ckbad
146end
147w = ckhexn 2
148o = ulong 0
149if ne c 0
150o = na_json uchar c edit js
151end
152if ne w add o 2
153ret false
154end
155if ne ckhex 2 0 34
156ret false
157end
158if ne ckhex 2 add o 1 34
159ret false
160end
161for j ulong o bound 6
162if ne ckhex 2 add j 1 ulong get js j
163ret false
164end
165end
166ret true
167end
168note v rows
169fn ntv to bool
170hv = new uchar 4096 0
171nv = new uchar 4096 0
172h3 = new uint 3 0
173n3 = new uint 3 0
174if ne ckcnt 4
175ckbad
176end
177a = ckhexn 1
178b = ckhexn 2
179if or gt a len hv gt b len nv
180ckbad
181end
182for j ulong a bound 4096
183put hv j uchar ckhex 1 j
184end
185for j ulong b bound 4096
186put nv j uchar ckhex 2 j
187end
188got = ulong 2
189if ntsv part hv 0 a edit h3
190if ntsv part nv 0 b edit n3
191got = 0
192if na_ver view h3 view n3
193got = 1
194end
195end
196end
197ret eq got ntr 3
198end
199note L and M rows (k is the row letter)
200fn ntl k ulong to bool
201m = new uchar 8193 0
202ky = new uchar 4096 0
203if ne get nt_n 4 3
204ckbad
205end
206for j ulong len nt_m bound 8193
207put m j get nt_m j
208end
209kl = get nt_n 1
210for j ulong kl bound 4096
211put ky j get nt_k j
212end
213n = get nt_n 0
214want = ulong 0
215if eq k 76
216if ne ckcnt 3
217ckbad
218end
219n = cknum 1
220if ge n len m
221ckbad
222end
223want = ntr 2
224else
225if ne ckcnt 4
226ckbad
227end
228i = cknum 1
229v = cknum 2
230if or ge i n gt v 255
231ckbad
232end
233put m i uchar v
234want = ntr 3
235end
236got = ulong 0
237if na_layout part m 0 n part ky 0 kl 8192
238got = 1
239end
240ret eq got want
241end
242note r, C, X, F and T rows (k is the row letter)
243fn ntc k ulong to bool
244cb = new uchar 4096 0
245tx = new uchar 64 0
246if ne get nt_n 5 1
247ckbad
248end
249cl = get nt_n 2
250tl = get nt_n 3
251for j ulong cl bound 4096
252put cb j get nt_c j
253end
254for j ulong tl bound 64
255put tx j get nt_t j
256end
257if eq k 114
258if ne ckcnt 3
259ckbad
260end
261n = cknum 1
262if or gt n 8 gt n cl
263ckbad
264end
265ret eq na_read part cb 0 n n ntx 2
266end
267ret ntcm k edit cb edit tx
268end
269note X and T rows: set byte I of the cubin copy, or xor byte I of the text copy, with V
270fn ntmut k ulong cb edit uchar * tx edit uchar * to void
271if ne ckcnt 4
272ckbad
273end
274i = cknum 1
275v = cknum 2
276if gt v 255
277ckbad
278end
279if eq k 88
280if ge i get nt_n 2
281ckbad
282end
283put cb i uchar v
284else
285if ge i get nt_n 3
286ckbad
287end
288put tx i xor get tx i uchar v
289end
290end
291note F rows: na_cubin for a function name of fl bytes f (the test's names of 120 to 129 bytes and shorter)
292fn ntff cb view uchar * fl ulong tx view uchar * to bool
293fb = new uchar 130 102
294if gt fl len fb
295ckbad
296end
297ret na_cubin cb part fb 0 fl tx
298end
299note C, X, F and T rows on the frame copies of the kept cubin cb and text tx
300fn ntcm k ulong cb edit uchar * tx edit uchar * to bool
301if or lt ckcnt 3 gt ckcnt 4
302ckbad
303end
304n = get nt_n 2
305if eq k 67
306n = cknum 1
307if or gt n get nt_n 2 ne ckcnt 3
308ckbad
309end
310end
311if or eq k 88 eq k 84
312ntmut k edit cb edit tx
313end
314got = false
315if eq k 70
316if ne ckcnt 3
317ckbad
318end
319got = ntff part cb 0 n cknum 1 part tx 0 get nt_n 3
320else
321got = na_cubin part cb 0 n t_foo part tx 0 get nt_n 3
322end
323r = ulong 0
324if got
325r = 1
326end
327ret eq r ntr sub ckcnt 1
328end
329note K rows: a recorded known difference between the pending C and na_cubin
330fn ntk to bool
331cb = new uchar 4096 0
332tx = new uchar 64 0
333nm = new uchar 4096 0
334if ne ckcnt 7
335ckbad
336end
337a = ckhexn 1
338b = ckhexn 2
339f = ckhexn 3
340if or or gt a len cb gt b len tx gt f len nm
341ckbad
342end
343for j ulong a bound 4096
344put cb j uchar ckhex 1 j
345end
346for j ulong b bound 64
347put tx j uchar ckhex 2 j
348end
349for j ulong f bound 4096
350put nm j uchar ckhex 3 j
351end
352if eq ntr 4 ntr 5
353ret false
354end
355got = ulong 0
356if na_cubin part cb 0 a part nm 0 f part tx 0 b
357got = 1
358end
359ret eq got ntr 5
360end
361fn crow to bool
362if ne cklen 0 1
363ckbad
364end
365k = ckch 0 0
366if eq k 106
367ret ntj
368end
369if eq k 118
370ret ntv
371end
372if eq k 107
373if ne ckcnt 2
374ckbad
375end
376ntkeep 1 1
377put nt_n 4 or get nt_n 4 1
378ret true
379end
380if eq k 98
381if ne ckcnt 2
382ckbad
383end
384ntkeep 1 0
385put nt_n 4 or get nt_n 4 2
386ret true
387end
388if eq k 99
389if ne ckcnt 3
390ckbad
391end
392ntkeep 1 2
393ntkeep 2 3
394put nt_n 5 1
395ret true
396end
397if eq k 75
398ret ntk
399end
400if or eq k 76 eq k 77
401ret ntl k
402end
403if not or or or or eq k 67 eq k 88 eq k 84 eq k 70 eq k 114
404ckbad
405end
406ret ntc k
407end