interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / om / encoder / bw_spec_corpus.om

248 lines · 3699 bytes Raw Blame History
1note bw_spec_corpus.om: generates authoritative sm_121 boundary test corpus (461 cases)
2
3fn set_o_field role ulong word ulong val ulong op ulong o edit ulong 16 to void
4if or eq role 1 eq role 5
5put o 1 val
6ret
7end
8if or eq role 2 eq role 6
9put o 2 val
10put o 12 1
11ret
12end
13if or eq role 3 eq role 7
14if and eq role 7 or eq op 6 eq op 7
15put o 1 val
16ret
17end
18if eq role 7
19put o 5 val
20put o 14 1
21ret
22end
23put o 3 val
24put o 13 1
25ret
26end
27if eq role 4
28put o 4 val
29ret
30end
31if eq role 21
32if eq word 0
33put o 1 val
34else
35put o 4 val
36end
37ret
38end
39if eq role 8
40if eq val 0
41put o 9 1
42put o 10 0
43else
44if eq val 8
45put o 9 1
46put o 10 1
47end
48end
49ret
50end
51if eq role 12
52put o 11 val
53ret
54end
55put o 6 and val 4294967295
56end
57
58fn get_fld_val min_v ulong max_v ulong v_idx ulong to ulong
59if eq v_idx 0
60ret min_v
61end
62if eq v_idx 1
63ret add min_v 1
64end
65if eq v_idx 2
66ret sub max_v 1
67end
68ret max_v
69end
70
71fn get_v_idx c_i ulong f_i ulong nf ulong to ulong
72if eq c_i 0
73ret 0
74end
75if eq c_i 1
76ret 3
77end
78last_f = sub nf 1
79if eq f_i last_f
80if eq c_i 2
81ret 1
82end
83if eq c_i 3
84ret 2
85end
86if eq c_i 4
87ret 3
88end
89if eq c_i 5
90ret 0
91end
92if eq c_i 6
93ret 1
94end
95ret 2
96end
97prev_f = sub nf 2
98if eq f_i prev_f
99if ge c_i 5
100ret 1
101end
102ret 0
103end
104ret 0
105end
106
107fn finalize_o op ulong var ulong o edit ulong 16 to void
108if eq op 8
109if eq var 0
110put o 13 1
111else
112if eq var 1
113put o 8 1
114put o 14 1
115end
116end
117else
118if eq op 10
119if eq var 0
120put o 8 1
121put o 14 1
122end
123end
124end
125end
126
127fn clear_o o edit ulong 16 op ulong to void
128for k ulong 16
129put o k 0
130end
131put o 0 op
132end
133
134fn write_case o view ulong 16 buf edit uchar 128 to int
135for i ulong 16
136v = get o i
137off = mul i 8
138for b ulong 8
139sh = mul b 8
140put buf add off b uchar and shr v sh 255
141end
142end
143sent = ulong 0
144while lt sent 128 bound 128
145w = write int 1 buf sent sub 128 sent
146if le w 0
147ret 1
148end
149sent = add sent ulong w
150end
151ret 0
152end
153
154fn emit_one_field sp_tbl view ulong 3001 fbase ulong c_i ulong f_i ulong nf ulong o edit ulong 16 to void
155op = get o 0
156role = get sp_tbl fbase
157word = get sp_tbl add fbase 1
158min_v = get sp_tbl add fbase 5
159max_v = get sp_tbl add fbase 6
160v_idx = get_v_idx c_i f_i nf
161val = get_fld_val min_v max_v v_idx
162note Fixtures deliberately choose representable special-layout immediates.
163note Refusal tests separately retain the raw nonrepresentable boundaries.
164if eq role R_LDC
165shift = get sp_tbl add fbase 2
166step = shr ulong 256 shift
167val = mul div val step step
168end
169if eq role R_BSSY
170val = add and sub val 1 268435455 1
171end
172set_o_field role word val op o
173end
174
175fn emit_form_multi sp_tbl view ulong 3001 base ulong o edit ulong 16 buf edit uchar 128 to int
176op = get sp_tbl base
177var = get sp_tbl add base 1
178nf = get sp_tbl add base 9
179for c_i ulong 8
180clear_o o op
181for f_i ulong nf
182fbase = add add base 10 mul f_i 7
183emit_one_field sp_tbl fbase c_i f_i nf o
184end
185finalize_o op var o
186st = write_case o buf
187if ne sp_find sp_tbl o div base 45
188ret 2
189end
190if ne st 0
191ret 1
192end
193end
194ret 0
195end
196
197fn emit_form sp_tbl view ulong 3001 idx ulong o edit ulong 16 buf edit uchar 128 to int
198base = mul idx 45
199op = get sp_tbl base
200var = get sp_tbl add base 1
201nf = get sp_tbl add base 9
202
203if eq nf 0
204clear_o o op
205finalize_o op var o
206if ne sp_find sp_tbl o idx
207ret 2
208end
209ret write_case o buf
210end
211
212if eq nf 1
213fbase = add base 10
214for c_i ulong 4
215clear_o o op
216emit_one_field sp_tbl fbase c_i 0 1 o
217finalize_o op var o
218st1 = write_case o buf
219if ne sp_find sp_tbl o idx
220ret 2
221end
222if ne st1 0
223ret 1
224end
225end
226ret 0
227end
228
229ret emit_form_multi sp_tbl base o buf
230end
231
232fn main to int
233sp_tbl = new ulong 3001 0
234sp_init sp_tbl
235o = new ulong 16 0
236buf = new uchar 128 0
237for idx ulong 63
238st = emit_form sp_tbl idx o buf
239if ne st 0
240ret 1
241end
242end
243note Fault control: a complete valid stream followed by producer failure.
244if ge argcnt 2
245ret 7
246end
247ret 0
248end