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