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

82 lines · 1984 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/bwctl.om: the Omega port of CUDApp tests/bw_encode_control_test.c. Composed after
3note gpu/nvidia/om/encoder/bw_enc_sm121.om (bw_enc_sm121) and gpu/nvidia/checks/lib.om; run with
4note gpu/nvidia/checks/bwctl.tsv. Row, lowercase hex: e OP FORM CONTROL ACCEPTED W0 W1 W2 W3.
5note The check encodes the old test's instruction: op OP, dst 4, src1 6, src2 8, src3 10, ureg 4, imm 2,
6note predicate @P0 when FORM bit 0 is set, uniform when FORM bit 1 is set, control CONTROL, with every virtual
7note register on the physical register of its own number (omega_blackwell_encode_one). The encoder must accept
8note it exactly when ACCEPTED is 1 and give the four words W0..W3 of the C encoder; and, the old test's own
9note property, an accepted word 3 carries CONTROL's stall, yield, scoreboard and wait bits (0x03fffe00).
10text t_name "BWCTL"
11const CTLF ulong 67108352
12fn cname to void
13for i ulong len t_name bound 64
14ckoc ulong get t_name i
15end
16end
17fn bwx i ulong to ulong
18n = cklen i
19if or eq n 0 gt n 16
20ckbad
21end
22v = ulong 0
23for j ulong n bound 16
24v = or shl v 4 cknib ckch i j
25end
26ret v
27end
28fn bww code view uchar 16384 k ulong to ulong
29v = ulong 0
30for j ulong 4
31v = or v shl ulong get code add mul k 4 j mul j 8
32end
33ret v
34end
35fn crow to bool
36if or ne ckcnt 9 ne cklen 0 1
37ckbad
38end
39if ne ckch 0 0 101
40ckbad
41end
42form = bwx 2
43cw = bwx 3
44acc = bwx 4
45if or gt form 3 gt acc 1
46ckbad
47end
48ins = new ulong 8192 0
49phys = new ulong 288 0
50code = new uchar 16384 0
51for i ulong 256
52put phys i i
53end
54for i ulong 32
55put phys add 256 i i
56end
57put ins 0 bwx 1
58put ins 1 4
59put ins 2 6
60put ins 3 8
61put ins 4 10
62put ins 5 4
63put ins 6 or 2 shl cw 32
64put ins 7 or shr form 1 shl and form 1 1
65got = bw_enc_sm121 view ins view phys 1 0 edit code
66if eq acc 0
67ret ne got 16
68end
69if ne got 16
70ret false
71end
72ok = true
73for k ulong 4
74if ne bww view code k bwx add k 5
75ok = false
76end
77end
78if ne and bww view code 3 CTLF and cw CTLF
79ok = false
80end
81ret ok
82end