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

97 lines · 2858 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/attnscan.om: the scan block of CUDApp tests/attn_host_diff.c (its other blocks are
3note gpu/nvidia/checks/attnhost.om; both units start with om2, so they cannot share one program). Composed
4note after gpu/nvidia/om/scan/scan_check.om (sc_check) and gpu/nvidia/checks/lib.om; run with
5note gpu/nvidia/checks/attnscan.tsv. Row, lowercase hex: s N CASE OP R: sc_check OP over the arrays the old
6note test builds for CASE, N elements, answers R. CASE 0 x[i] = 17 when i rem 3 is 0, else 4294967295, w the
7note running uint sums of x; 1 case 0 with bit 0 of w[N-1] flipped; 2 w[i] = i; 3 case 2 with w[0] = 1 and
8note w[N-1] = 0; 4 every w[i] = 2141195181 (0x7fa00bad); 5 case 4 with w[N-1] = 2141195180; 6 case 4 with
9note w[N-1] = 2141195182. Cases 2..6 pass w and a copy of w, as the old test passes w twice. The arrays are built here,
10note not stored in the table. They are local arrays of 1000001 elements, the old test's largest N: a view is
11note cut (part) only from a local array of constant size (a global is never an argument, error 19), and the
12note local arrays of one function are at most 4 MiB (error 23), so x lives in a helper. A row with a larger N
13note is refused as malformed (exit 2), never cut short.
14text t_name "ATTNSCAN"
15fn cname to void
16for i ulong len t_name bound 64
17ckoc ulong get t_name i
18end
19end
20fn asx i ulong to ulong
21n = cklen i
22if or eq n 0 gt n 16
23ckbad
24end
25v = ulong 0
26for j ulong n bound 16
27v = or shl v 4 cknib ckch i j
28end
29ret v
30end
31note cases 0 and 1: x lives in this frame, w in the caller's (4 MiB of local arrays per function)
32fn sums w edit uint * cs ulong op ulong to ulong
33sx = new uint 1000001 0
34n = len w
35sum = uint 0
36for i ulong n bound 1000001
37v = uint 4294967295
38if eq rem i 3 0
39v = uint 17
40end
41put sx i v
42sum = add sum v
43put w i sum
44end
45if and eq cs 1 gt n 0
46put w sub n 1 xor get w sub n 1 uint 1
47end
48ret sc_check w part sx 0 n uint op
49end
50note cases 2..6: the old test passes w as both arrays; one array is never passed twice in a call (error 19),
51note so x is a copy of w in this frame
52fn twin w view uint * op ulong to ulong
53sx = new uint 1000001 0
54n = len w
55for i ulong n bound 1000001
56put sx i get w i
57end
58ret sc_check w part sx 0 n uint op
59end
60fn crow to bool
61if or ne ckcnt 5 ne cklen 0 1
62ckbad
63end
64if ne ckch 0 0 115
65ckbad
66end
67sw = new uint 1000001 0
68n = asx 1
69cs = asx 2
70op = asx 3
71if or gt n len sw gt cs 6
72ckbad
73end
74if lt cs 2
75ret eq sums part sw 0 n cs op asx 4
76end
77if lt cs 4
78for i ulong n bound 1000001
79put sw i uint i
80end
81if and eq cs 3 gt n 1
82put sw 0 uint 1
83put sw sub n 1 uint 0
84end
85ret eq twin part sw 0 n op asx 4
86end
87for i ulong n bound 1000001
88put sw i uint 2141195181
89end
90if and eq cs 5 gt n 0
91put sw sub n 1 uint 2141195180
92end
93if and eq cs 6 gt n 0
94put sw sub n 1 uint 2141195182
95end
96ret eq twin part sw 0 n op asx 4
97end