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

134 lines · 3608 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/ldgmmio.om: the Omega port of CUDApp tests/bw_ldg_mmio_test.c. Composed after
3note gpu/nvidia/om/encoder/bw_enc_sm121.om (bw_enc_sm121), gpu/nvidia/om/disasm/sm121_dis.om (sm121_dis) and
4note gpu/nvidia/checks/lib.om; run with gpu/nvidia/checks/ldgmmio.tsv. Rows, tab separated, lowercase hex for
5note the words, decimal otherwise:
6note e OP W0 W1 W2 W3 TYPE ORDER EVICT CONTRACT RC TEXT the test's instruction with op OP
7note w W2 TYPE ORDER EVICT CONTRACT RC TEXT LDG_MMIO's instruction with word 2 replaced by W2
8note The test's instruction: dst 4, src1 8, no src2 or src3, ureg 2, imm 0, control 0 (the op's default), each
9note virtual register on the physical register of its own number. The check encodes it with bw_enc_sm121 and
10note requires the C encoder's four words; reads NAK's memory fields of the word (Mesa NAK sm70_encode.rs
11note set_mem_access, sm_80+: type bits 73..75, order bits 77..80, eviction bits 84..86) and requires the C's
12note values; computes the test's LDG_MMIO contract (32-bit, normal eviction, an order neither weak 0 nor
13note constant 4; CONTRACT 1 when broken) and requires the C's answer; and decodes the word with sm121_dis,
14note requiring the C decoder's text and its answer RC (1 when no form matched, the text is then ?? 0x<hi><lo>).
15text t_name "LDGMMIO"
16const NONE ulong 18446744073709551615
17fn cname to void
18for i ulong len t_name bound 64
19ckoc ulong get t_name i
20end
21end
22fn lmx i ulong to ulong
23n = cklen i
24if or eq n 0 gt n 8
25ckbad
26end
27v = ulong 0
28for j ulong n bound 8
29v = or shl v 4 cknib ckch i j
30end
31ret v
32end
33note bits [at, at + n) of the 128-bit word ww (four 32-bit words); every field read lies inside one word
34fn lmf ww view ulong 4 at ulong n ulong to ulong
35ret and shr get ww shr at 5 and at 31 sub shl ulong 1 n 1
36end
37note 1 when ww breaks the LDG_MMIO contract (mmio_contract of the test)
38fn lmbad ww view ulong 4 to ulong
39o = lmf ww 77 4
40if ne lmf ww 73 3 4
41ret 1
42end
43if ne lmf ww 84 3 1
44ret 1
45end
46if or eq o 0 eq o 4
47ret 1
48end
49ret 0
50end
51note encode op with the test's operands into ww; false when the encoder refuses
52fn lmenc op ulong ww edit ulong 4 to bool
53ins = new ulong 8192 0
54phys = new ulong 288 0
55code = new uchar 16384 0
56for i ulong 256
57put phys i i
58end
59for i ulong 32
60put phys add 256 i i
61end
62put ins 0 op
63put ins 1 4
64put ins 2 8
65put ins 3 NONE
66put ins 4 NONE
67put ins 5 2
68if ne bw_enc_sm121 view ins view phys 1 0 edit code 16
69ret false
70end
71for k ulong 4
72v = ulong 0
73for j ulong 4
74v = or v shl ulong get code add mul k 4 j mul j 8
75end
76put ww k v
77end
78ret true
79end
80note fields, contract and decoding of ww against the row's fields from f on: TYPE ORDER EVICT CONTRACT RC TEXT
81fn lmrest ww view ulong 4 f ulong to bool
82if or ne cknum f lmf ww 73 3 ne cknum add f 1 lmf ww 77 4
83ret false
84end
85if or ne cknum add f 2 lmf ww 84 3 ne cknum add f 3 lmbad ww
86ret false
87end
88o = new uchar 256 0
89r = sm121_dis or get ww 0 shl get ww 1 32 or get ww 2 shl get ww 3 32 0 edit o
90if ne cknum add f 4 and shr r 16 1
91ret false
92end
93t = add f 5
94n = and r 65535
95if or ne and shr r 18 1 0 ne n cklen t
96ret false
97end
98for j ulong n bound 256
99if ne ulong get o j ckch t j
100ret false
101end
102end
103ret true
104end
105fn crow to bool
106k = ckch 0 0
107ww = new ulong 4 0
108if eq k 101
109if or ne ckcnt 12 ne cklen 0 1
110ckbad
111end
112if not lmenc cknum 1 edit ww
113ret false
114end
115for i ulong 4
116if ne get ww i lmx add i 2
117ret false
118end
119end
120ret lmrest view ww 6
121end
122if eq k 119
123if or ne ckcnt 8 ne cklen 0 1
124ckbad
125end
126if not lmenc 21 edit ww
127ret false
128end
129put ww 2 lmx 1
130ret lmrest view ww 2
131end
132ckbad
133ret false
134end