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

173 lines · 4094 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/api_ew.om: the Omega port of CUDApp tests/api_kgen_ew_diff_test.c.
3note Composed after gpu/nvidia/om/components/api_ew_plan.om, the ew_ir unit (gpu/nvidia/om/kgen/ew_emit.om,
4note ew_scalar.om, ew_reconv.om, ew_prime.om, ew_ir.om), gpu/nvidia/om/codegen/cg_fields.om, cg_replay.om and
5note gpu/nvidia/checks/lib.om; run with gpu/nvidia/checks/api_ew.tsv, the answers of the retained C generator and
6note C shape plan over the C test's whole domain. Word digests: h = (h xor w) * 1099511628211 from
7note 14695981039346656037, one step per 64-bit word.
8note Cases (fields split by tabs):
9note d D... the C test's dimension list; every p row reads it, so it comes first
10note e MAXOP the last IR opcode of the C enum (BW_IR_LAST), the bound cg_replay admits; before k
11note p MODE N ADM DIGEST api_ew_plan MODE on (N, D, LO, 3) for each D of the d row and LO 0..4, in that
12note order: ADM cases return 0, and DIGEST folds each return code and, when it is 0,
13note the 16 words after the call
14note k OP MUT PATH ACC COUNT DIGEST NV NU WIDTHS
15note ew_ir OP MUT PATH 0: ACC 1 when the C generator accepted the spec, so ew_ir must
16note return 0 and cg_replay must admit its records; then COUNT records, DIGEST over the
17note 16 fields cg_fields unpacks from each, NV and NU virtual registers and WIDTHS over
18note their widths (each vreg: a width word 4 or 2 is that size, any other is 1; then
19note each uvreg: 2 for a width word 2, else 1; as the C replay allocates them).
20note ACC 0: ew_ir must not return 0.
21text t_name "API_EW"
22global ae_g ulong 4
23note ae_g: 0 MAXOP, 1 an e row was read, 2 a d row was read
24global ae_d ulong *
25fn cname to void
26for i ulong len t_name bound 64
27ckoc ulong get t_name i
28end
29end
30fn ae_f h ulong v ulong to ulong
31ret mul xor h v 1099511628211
32end
33fn ae_dims to bool
34n = sub ckcnt 1
35r = enlarge ae_d n
36if lt r 0
37ckrefuse 1
38end
39for i ulong n bound 4294967296
40put ae_d i cknum add i 1
41end
42put ae_g 2 1
43ret true
44end
45fn ae_plan to bool
46if ne ckcnt 5
47ckbad
48end
49if eq get ae_g 2 0
50ret false
51end
52mode = cknum 1
53an = cknum 2
54a = new ulong 16 0
55h = ulong 14695981039346656037
56adm = ulong 0
57for di ulong len ae_d bound 4294967296
58for lo ulong 5
59for i ulong 16
60put a i 0
61end
62put a 0 an
63put a 1 get ae_d di
64put a 2 lo
65put a 3 3
66r = api_ew_plan mode a
67h = ae_f h r
68if eq r 0
69adm = add adm 1
70for i ulong 16
71h = ae_f h get a i
72end
73end
74end
75end
76if ne adm cknum 3
77ret false
78end
79ret eq h cknum 4
80end
81fn ae_wid w ulong to ulong
82if or eq w 4 eq w 2
83ret w
84end
85ret 1
86end
87note the accepted spec's records, unpacked by cg_fields, against the C generator's instructions
88fn ae_ir ins view ulong 8192 meta view ulong 512 to bool
89n = get meta 0
90if ne n cknum 5
91ret false
92end
93raw = new ulong 16 0
94rec = new ulong 8 0
95h = ulong 14695981039346656037
96for i ulong n bound 1024
97for j ulong 8
98put rec j get ins add mul i 8 j
99end
100if ne cg_fields 1 raw rec 0
101ret false
102end
103for j ulong 16
104h = ae_f h get raw j
105end
106end
107if ne h cknum 6
108ret false
109end
110vn = get meta 1
111nu = get meta 2
112if or ne vn cknum 7 ne nu cknum 8
113ret false
114end
115w = ulong 14695981039346656037
116for v ulong vn bound 256
117w = ae_f w ae_wid get meta add 64 v
118end
119for u ulong nu bound 32
120k = ulong 1
121if eq get meta add 320 u 2
122k = 2
123end
124w = ae_f w k
125end
126ret eq w cknum 9
127end
128fn ae_kern to bool
129if ne ckcnt 10
130ckbad
131end
132if eq get ae_g 1 0
133ret false
134end
135ins = new ulong 8192 0
136meta = new ulong 512 0
137r = ew_ir cknum 1 cknum 2 cknum 3 0 ins meta
138acc = cknum 4
139if eq acc 0
140ret ne r 0
141end
142if or ne acc 1 ne r 0
143ret false
144end
145if ne cg_replay ins meta get ae_g 0 0
146ret false
147end
148ret ae_ir ins meta
149end
150fn crow to bool
151if ne cklen 0 1
152ckbad
153end
154k = ckch 0 0
155if eq k 101
156if ne ckcnt 2
157ckbad
158end
159put ae_g 0 cknum 1
160put ae_g 1 1
161ret true
162end
163if eq k 100
164ret ae_dims
165end
166if eq k 112
167ret ae_plan
168end
169if ne k 107
170ckbad
171end
172ret ae_kern
173end