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

197 lines · 4534 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/streams.om: the check of gpu/nvidia/om/streams/streams.om (streams_words) and
3note gpu/nvidia/om/streams/xq.om (streams_xq) against the C oracle of CUDApp tests/streams_diff_test.c, as
4note gpu/nvidia/checks/streams.tsv (written outside the tree by the C, see README.md, Oracles). Composed after those
5note two units and lib.om (gpu/nvidia/checks/checks.tsv).
6note Case 0 WM IM MODE BAR CHUNKS WORDS HASH: the chunks of the C sweep over a 4-launch list (launch i waits when bit i
7note of WM is set, is independent when bit i of IM is set), assembled as the C binding emit_chunk_om assembles them:
8note op 0 setup, op 1 per launch, and in inline mode (o 31 = 2) op 2 then the 96 QMD words for the second-level QMD
9note (+0x200) and the QMD, then op 3. Over stamps 0..1, first_barrier_none 0..1, skip 0..4, done 0..1 in that order
10note the chunk count, the word total and the FNV-1a-64 over (word count, words...) of each chunk must equal the C.
11note A word count above what the C binding accepts for the op (18, 30, 3, 25) fails the case.
12note Case 1 PAGE K VA CLR0 CLR1: op 5. Case 2 PRESENT LEN C0 MAX R: op 4. Case 3 I OPEN R: streams_xq.
13text t_name "STREAMS"
14fn cname to void
15for i ulong len t_name bound 64
16ckoc ulong get t_name i
17end
18end
19note sd_s: 0 pass (0 count, 1 hash), 1 chunk word count, 2 hash
20global sd_s ulong 4
21fn sdfnv h ulong v ulong to ulong
22ret mul xor h v 1099511628211
23end
24fn sdw v ulong to void
25if eq get sd_s 0 0
26put sd_s 1 add get sd_s 1 1
27else
28put sd_s 2 sdfnv get sd_s 2 v
29end
30end
31fn sdput o view ulong 32 k ulong max ulong to bool
32if gt k max
33ret false
34end
35for j ulong k bound 32
36sdw get o j
37end
38ret true
39end
40note the sweep's QMD bytes: word j of the list's QMD area is j * 2654435761 mod 2^32 (1024 bytes per launch)
41fn sdqmd w ulong to void
42for t ulong 96 bound 96
43sdw and mul add w t 2654435761 4294967295
44end
45end
46note sd_p: the chunk being assembled: 0 WM, 1 IM, 2 mode, 3 barrier, 4 stamps, 5 first_barrier_none, 6 skip, 7 done
47note (globals, so that no function needs more than six parameters or sixteen live values)
48global sd_p ulong 8
49note the inline header of QMD h (0 the second-level QMD at q1 + 0x200, 1 the QMD at q1) of launch i, then its words
50fn sdinl i ulong h ulong to bool
51a = new ulong 16 0
52o = new ulong 32 0
53q1 = add 20015998341120 mul i 1024
54if eq h 0
55put a 0 add q1 512
56else
57put a 0 q1
58end
59if not sdput o streams_words 2 a o 3
60ret false
61end
62if eq h 0
63sdqmd add mul i 256 128
64else
65sdqmd mul i 256
66end
67ret true
68end
69note launch i: op 1 in the call form of emit_chunk_om, then the inline QMDs when o 31 is 2
70fn sdlaunch i ulong to bool
71a = new ulong 16 0
72o = new ulong 32 0
73put a 0 i
74put a 1 get sd_p 7
75if ne and shr get sd_p 0 i 1 0
76put a 2 add 280220846264880 mul 16 i
77end
78put a 3 and shr get sd_p 1 i 1
79put a 4 get sd_p 6
80put a 5 get sd_p 5
81put a 6 get sd_p 3
82put a 7 get sd_p 4
83put a 8 35187254427648
84put a 9 get sd_p 2
85put a 10 add 20015998341120 mul i 1024
86if not sdput o streams_words 1 a o 30
87ret false
88end
89if ne get o 31 2
90ret true
91end
92if not sdinl i 0
93ret false
94end
95ret sdinl i 1
96end
97note one pass over the chunk's words; false when the generator refused or overran
98fn sdpass to bool
99a = new ulong 16 0
100o = new ulong 32 0
101if not sdput o streams_words 0 a o 18
102ret false
103end
104done = get sd_p 7
105for t ulong sub 4 done bound 4
106if not sdlaunch add done t
107ret false
108end
109end
110put a 0 get sd_p 4
111put a 1 35187254427648
112put a 2 4
113put a 3 123148505645328
114ret sdput o streams_words 3 a o 25
115end
116fn sdchunks to bool
117for f ulong 4
118put sd_p f cknum add f 1
119end
120put sd_s 2 14695981039346656037
121nc = ulong 0
122nw = ulong 0
123for st ulong 2
124for fb ulong 2
125for skip ulong 5
126for done ulong 2
127put sd_p 4 st
128put sd_p 5 fb
129put sd_p 6 skip
130put sd_p 7 done
131put sd_s 0 0
132put sd_s 1 0
133if not sdpass
134ret false
135end
136n = get sd_s 1
137put sd_s 0 1
138put sd_s 2 sdfnv get sd_s 2 n
139if not sdpass
140ret false
141end
142nc = add nc 1
143nw = add nw n
144end
145end
146end
147end
148if ne nc cknum 5
149ret false
150end
151if ne nw cknum 6
152ret false
153end
154ret eq get sd_s 2 cknum 7
155end
156fn crow to bool
157k = cknum 0
158a = new ulong 16 0
159o = new ulong 32 0
160if eq k 0
161if ne ckcnt 8
162ckbad
163end
164ret sdchunks
165end
166if eq k 1
167if ne ckcnt 6
168ckbad
169end
170put a 0 cknum 1
171put a 1 cknum 2
172if ne streams_words 5 a o cknum 3
173ret false
174end
175if ne get o 0 cknum 4
176ret false
177end
178ret eq get o 1 cknum 5
179end
180if eq k 2
181if ne ckcnt 6
182ckbad
183end
184for j ulong 4
185put a j cknum add j 1
186end
187ret eq streams_words 4 a o cknum 5
188end
189if eq k 3
190if ne ckcnt 4
191ckbad
192end
193ret eq streams_xq cknum 1 cknum 2 cknum 3
194end
195ckbad
196ret false
197end