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 / tests / device-trace / address-test.om

270 lines · 5448 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Host-only semantic regression, not a GPU emulator or hardware receipt.
3note Compose after trace-emit.om. Decode the two address instructions independently of
4note the emitter helpers/golden, then model each STG effective address in a guarded extent.
5note Restoring the original base-low multiplication must fail, even if a golden is updated.
6note Field formats: src/omega_blackwell_codegen.c BW_IR_S2R/BW_IR_STG_E at
7note bba6da8045ba5baaf0a81f7152af44d52e24f563, the existing frozen reference.
8note Selector 82 is class B: nvdisasm 13.0 decoded our own PR84 words as GLOBALTIMERLO.
9note Historical tool receipt: evidence/device-trace/emitter-host-20261026/receipt.json.
10note These field checks are host models; chip qualification remains NOT_RUN.
11
12global Aregs ulong 256
13global Amem uchar 256
14
15fn aword byteoff ulong to ulong
16v = ulong 0
17for j ulong 4
18v = or v shl ulong get gbout add byteoff j mul j 8
19end
20ret v
21end
22
23fn ainsn pos ulong to bool
24w = aword pos
25op = and w 65535
26dst = and shr w 16 255
27src = shr w 24
28imm = aword add pos 4
29rc = and aword add pos 8 255
30if eq op 30722
31put Aregs dst imm
32ret true
33end
34if eq op 30756
35v = add mul get Aregs src imm get Aregs rc
36put Aregs dst and v 4294967295
37ret true
38end
39if eq op 30757
40base = get Aregs rc
41if ne rc 255
42base = or base shl get Aregs add rc 1 32
43end
44v = add mul get Aregs src imm base
45put Aregs dst and v 4294967295
46put Aregs add dst 1 shr v 32
47ret true
48end
49ret false
50end
51
52fn astore p ulong base ulong to bool
53w = aword p
54breg = shr w 24
55off = aword add p 4
56note STG.E has a signed 24-bit byte offset. This marker uses only nonnegative offsets.
57off = and shr off 8 16777215
58if ge off 8388608
59ret false
60end
61note Contract v1 fields at offsets 0/4/8 use R6; stamp uses R2; IDs use R10:R13.
62note Decode the low byte of word 1 independently of gtstg (frozen C encoder BW_IR_STG_E).
63if or gt off 28 ne rem off 4 0
64ret false
65end
66want = ulong 6
67if eq off 12
68want = ulong 2
69end
70if ge off 16
71want = add ulong 10 div sub off 16 4
72end
73val = and aword add p 4 255
74if ne val want
75ret false
76end
77dst = get Aregs breg
78dst = or dst shl get Aregs add breg 1 32
79dst = add dst off
80if lt dst base
81ret false
82end
83rel = sub dst base
84if gt rel 188
85ret false
86end
87for j ulong 4
88put Amem add add rel j 32 90
89end
90ret true
91end
92
93fn amark start ulong base ulong want ulong to bool
94note S2R fields from frozen C encoder BW_IR_S2R; no producer constants or helpers used.
95note Register 82 is GLOBALTIMERLO, as independently decoded in the historical host receipt.
96clock = aword add start 48
97if ne and clock 65535 31001
98ret false
99end
100if ne and shr clock 16 255 2
101ret false
102end
103clock = aword add start 56
104if ne and shr clock 8 255 82
105ret false
106end
107for i ulong 256
108put Aregs i 0
109end
110put Aregs 4 and base 4294967295
111put Aregs 5 shr base 32
112ok = ainsn add start 112
113if not ok
114ret false
115end
116ok = ainsn add start 128
117if not ok
118ret false
119end
120addr = or get Aregs 8 shl get Aregs 9 32
121if ne addr want
122ret false
123end
124stores = ulong 0
125for i ulong 20
126p = add start mul i 16
127w = aword p
128if eq and w 65535 31110
129ok = astore p base
130if not ok
131ret false
132end
133stores = add stores 1
134end
135end
136ret eq stores 8
137end
138
139fn aextent base ulong first ulong second ulong to bool
140for i ulong 256
141put Amem i 165
142end
143ok = amark 0 base first
144if not ok
145ret false
146end
147ok = amark 320 base second
148if not ok
149ret false
150end
151note The header, unused record bytes, and both 32-byte canaries remain untouched.
152for i ulong 256
153touched = or and ge i 96 lt i 128 and ge i 160 lt i 192
154want = uchar 165
155if touched
156want = uchar 90
157end
158if ne get Amem i want
159ret false
160end
161end
162ret true
163end
164
165fn abranch p ulong to int
166note Predicate-insensitive branch opcode, @P0, rel18: index1 +1 +18 =20.
167w = aword p
168if ne and w 4095 2375
169ret 6
170end
171if ne and shr w 12 15 0
172ret 7
173end
174if ne shr w 18 18
175ret 8
176end
177if ne aword add p 4 0
178ret 9
179end
180if ne aword add p 8 58720256
181ret 10
182end
183ret 0
184end
185
186fn aneg pos ulong value uchar to bool
187note Test the model itself: a changed field must be refused, then restore the stream.
188old = get gbout pos
189put gbout pos value
190ok = aextent 4096 4160 4224
191for i ulong 2
192rc = abranch add mul i 320 16
193if ne rc 0
194ok = false
195end
196end
197put gbout pos old
198ret not ok
199end
200
201fn main to int
202put gbinlen 0 0
203put gtchecks 0 1
204ok = gtewrap 1 2
205if not ok
206ret 1
207end
208if ne get gboutlen 0 640
209ret 2
210end
211ok = aextent 4294971392 4294971456 4294971520
212if not ok
213ret 3
214end
215note Low-half carry must not wrap the pointer into an unrelated allocation.
216ok = aextent 8589934528 8589934592 8589934656
217if not ok
218ret 4
219end
220ok = aextent 4096 4160 4224
221if not ok
222ret 5
223end
224for i ulong 2
225p = add mul i 320 16
226rc = abranch p
227if ne rc 0
228ret rc
229end
230end
231note Each marker must sample GLOBALTIMERLO into R2, not thread identity or another register.
232for i ulong 2
233start = mul i 320
234note Byte 18 changes the branch displacement; byte 309 is the last store offset.
235ok = aneg add start 18 0
236if not ok
237ret 15
238end
239ok = aneg add start 309 60
240if not ok
241ret 16
242end
243ok = aneg add start 57 33
244if not ok
245ret 11
246end
247ok = aneg add start 50 0
248if not ok
249ret 12
250end
251note Every record field has a named source register, not just an in-bounds destination.
252for j ulong 20
253p = add start mul j 16
254w = aword p
255if eq and w 65535 31110
256old = get gbout add p 4
257ok = aneg add p 4 uchar xor old 1
258if not ok
259ret 13
260end
261end
262end
263end
264note Negative controls restored all bytes and the positive stream remains valid.
265ok = aextent 4096 4160 4224
266if not ok
267ret 14
268end
269ret 0
270end