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

123 lines · 2682 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/sm121dis.om: the Omega port of CUDApp tests/sm121_dis_diff_test.c. Composed after
3note gpu/nvidia/om/disasm/sm121_dis.om and gpu/nvidia/checks/lib.om; run with gpu/nvidia/checks/sm121dis.tsv.
4note Rows (numbers in lowercase hex):
5note g LO HI TEXT a golden word: sm121_dis must print TEXT (what nvdisasm 13.0.85 -b SM121 printed for
6note it), and the same word with bit 16 flipped (the old test's corrupted-word control) must not
7note w LO HI PC RC TEXT one word of the old test's differential stream (per form of the C table, random, IMAD
8note immediates, the IMAD.SHL powers of two), with the status RC (0 decoded, -1 no form,
9note -2 did not fit; TEXT - then) and the text the retained C decoder c_sm121_disasm gave
10note The result word of sm121_dis is read as the C binding reads it: bits 0..15 the text length, 16 no form
11note matched (-1), 18 the text did not fit, or a length of 256 or more (-2). Bit 17 (EXIT) must be set exactly
12note when the opcode bits are 0x94d, as the binding requires.
13text t_name "SM121DIS"
14fn cname to void
15for i ulong len t_name bound 64
16ckoc ulong get t_name i
17end
18end
19fn dhx i ulong to ulong
20n = cklen i
21if or eq n 0 gt n 16
22ckbad
23end
24v = ulong 0
25for j ulong n bound 16
26v = or shl v 4 cknib ckch i j
27end
28ret v
29end
30note field i as 0, -1 or -2: the code 0, 1 or 2
31fn drc i ulong to ulong
32n = cklen i
33if and eq n 1 eq ckch i 0 48
34ret 0
35end
36if ne n 2
37ckbad
38end
39if ne ckch i 0 45
40ckbad
41end
42c = ckch i 1
43if or lt c 49 gt c 50
44ckbad
45end
46ret sub c 48
47end
48note the status code of a result word r
49fn dst r ulong to ulong
50n = and r 65535
51if or ne and shr r 18 1 0 ge n 256
52ret 2
53end
54ret and shr r 16 1
55end
56fn dtext o view uchar 256 r ulong i ulong to bool
57n = and r 65535
58if ge n 256
59ret false
60end
61if ne cklen i n
62ret false
63end
64for j ulong n bound 256
65if ne ulong get o j ckch i j
66ret false
67end
68end
69ret true
70end
71fn dgold lo ulong hi ulong to bool
72o = new uchar 256 0
73r = sm121_dis lo hi 0 edit o
74if ne dst r 0
75ret false
76end
77if not dtext view o r 3
78ret false
79end
80r = sm121_dis xor lo 65536 hi 0 edit o
81if eq dst r 0
82if dtext view o r 3
83ret false
84end
85end
86ret true
87end
88fn dword lo ulong hi ulong pc ulong rc ulong to bool
89o = new uchar 256 0
90r = sm121_dis lo hi pc edit o
91if ne dst r rc
92ret false
93end
94x = and shr r 17 1
95e = ulong 0
96if eq and lo 4095 2381
97e = 1
98end
99if ne x e
100ret false
101end
102if eq rc 2
103ret true
104end
105ret dtext view o r 5
106end
107fn crow to bool
108k = ckch 0 0
109nc = ckcnt
110if eq k 103
111if ne nc 4
112ckbad
113end
114ret dgold dhx 1 dhx 2
115end
116if ne k 119
117ckbad
118end
119if ne nc 6
120ckbad
121end
122ret dword dhx 1 dhx 2 dhx 3 drc 4
123end