interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / om / encoder / atomg_min_test.om

170 lines · 3933 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note atomg_min_test.om: gate for BlackwellIR op 64, ATOMG.E.MIN.64.STRONG.SYS, of the seeded encoder (the Omega NG
3note kernel trap word). Concatenate after bw_enc_sm121.om; mk/om-encoder.mk test-om-encoder-atomg compiles it with
4note the pinned omc.
5note No arguments: three rows through enc1 must give exactly the words below. Exit 0, else 10+r for row r.
6note One argument: write the three instructions (48 bytes) on stdout for the ORACLE.
7note Two arguments: read the ORACLE's text on stdin and require the three lines of amnd in order.
8note Exit 0, 4 when a line is missing or out of order, 70 on a read error, 71 when the text is too long.
9note ORACLE (independent, not first-party, never shipped): NVIDIA nvdisasm 13.0.85 -b SM121 -hex. Its decode of the
10note type field (evidence/atomg-min-20261107/atomg_field_probe_nvdisasm.txt): 2 = .64, 3 = .S64.
11note Rows (dst, src1, src2, ureg; dst absent encodes RZ) and words, decimal by Wolfram:
12note R4, R2, R6, UR8: 33847720 = 0x020479a8, 2147483654 = 0x80000006, 144659720 = 0x089f5508
13note RZ, R2, R6, UR8: 50297256 = 0x02ff79a8, 2147483654 = 0x80000006, 144659720 = 0x089f5508
14note R10, R12, R14, UR4: 202013096 = 0x0c0a79a8, 2147483662 = 0x8000000e, 144659716 = 0x089f5504
15note w3 of every row: 3284480 = 0x00321e00.
16text amnd "ATOMG.E.MIN.64.STRONG.SYS PT, R4, desc[UR8][R2.64], R6 ;|ATOMG.E.MIN.64.STRONG.SYS PT, RZ, desc[UR8][R2.64], R6 ;|ATOMG.E.MIN.64.STRONG.SYS PT, R10, desc[UR4][R12.64], R14 ;|"
17global am_in ulong 15
18global am_w ulong 9
19
20fn am_init to void
21put am_in 0 4
22put am_in 1 2
23put am_in 2 6
24put am_in 3 8
25put am_in 4 1
26put am_in 5 0
27put am_in 6 2
28put am_in 7 6
29put am_in 8 8
30put am_in 9 0
31put am_in 10 10
32put am_in 11 12
33put am_in 12 14
34put am_in 13 4
35put am_in 14 1
36put am_w 0 33847720
37put am_w 1 2147483654
38put am_w 2 144659720
39put am_w 3 50297256
40put am_w 4 2147483654
41put am_w 5 144659720
42put am_w 6 202013096
43put am_w 7 2147483662
44put am_w 8 144659716
45end
46
47note encode row r (dst, src1, src2, ureg, dst present) into w; enc1's result (0 accepted)
48fn am_enc r ulong w edit ulong 4 to ulong
49o = new ulong 16 0
50b = mul r 5
51put o 0 64
52put o 1 get am_in b
53put o 2 get am_in add b 1
54put o 3 get am_in add b 2
55put o 5 get am_in add b 3
56put o 15 get am_in add b 4
57ret enc1 view o w
58end
59
60fn am_words w view ulong 4 r ulong to bool
61b = mul r 3
62if ne get w 0 get am_w b
63ret false
64end
65if ne get w 1 get am_w add b 1
66ret false
67end
68if ne get w 2 get am_w add b 2
69ret false
70end
71ret eq get w 3 3284480
72end
73
74fn am_rows to int
75w = new ulong 4 0
76for r ulong 3
77if ne am_enc r edit w 0
78ret int add 10 r
79end
80if not am_words view w r
81ret int add 10 r
82end
83end
84ret 0
85end
86
87fn am_bin to int
88w = new ulong 4 0
89code = new uchar 16384 0
90for r ulong 3
91if ne am_enc r edit w 0
92ret int add 10 r
93end
94store edit code r view w
95end
96off = ulong 0
97while lt off 48
98n = write 1 code off sub 48 off
99if le n 0
100ret 3
101end
102off = add off ulong n
103end
104ret 0
105end
106
107note does needle amnd[s..e) start at buf[i]? The caller keeps i + e - s within the text.
108fn am_at buf view uchar 65536 i ulong s ulong e ulong to bool
109for j ulong sub e s
110if ne get buf add i j get amnd add s j
111ret false
112end
113end
114ret true
115end
116
117note the end of the first match of amnd[s..e) in buf[i..n), or n+1 when absent
118fn am_find buf view uchar 65536 n ulong i ulong s ulong e ulong to ulong
119while le add i sub e s n
120if am_at buf i s e
121ret add i sub e s
122end
123i = add i 1
124end
125ret add n 1
126end
127
128fn am_check to int
129buf = new uchar 65536 0
130n = ulong 0
131while lt n 65536
132k = read 0 buf n sub 65536 n
133if lt k 0
134ret 70
135end
136if eq k 0
137break
138end
139n = add n ulong k
140end
141if eq n 65536
142ret 71
143end
144pos = ulong 0
145s = ulong 0
146for e ulong len amnd
147if eq get amnd e 124
148pos = am_find view buf n pos s e
149if gt pos n
150ret 4
151end
152s = add e 1
153end
154end
155ret 0
156end
157
158fn main to int
159am_init
160if gt argcnt 3
161ret 64
162end
163if eq argcnt 3
164ret am_check
165end
166if eq argcnt 2
167ret am_bin
168end
169ret am_rows
170end