yang
This project has not described itself yet.
Brought by drakestapleton
yang / src / ufbi_check3_kernels.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note src/ufbi_check3_kernels.om: Pure Seeded-OM-2 SM121 Direct SASS Emitter for Check #3 |
| 3 | note (4D SU(2) Quaternion Lattice Monte Carlo: 6-Staple Sum, Exact 4-FMA Overrelaxation, |
| 4 | note and Exact Trigonometric-Free Kennedy-Pendleton Heatbath on GB10). |
| 5 | note Composed after om/encoder/bw_enc_sm121.om. |
| 6 | note Honors all SM121 silicon laws (Antibodies #13-#15: 6-cycle ALU floor, disjoint |
| 7 | note LDG/STG address registers before uW0/uW1, 4-aligned LDG.E.128, zero B0 nesting). |
| 8 | |
| 9 | const UZ ulong 255 |
| 10 | global uPc ulong 1 |
| 11 | global uGuard ulong 1 |
| 12 | global uCodeBuf ulong 16384 |
| 13 | |
| 14 | fn ucw st ulong wb ulong rbar ulong wt ulong yld ulong to ulong |
| 15 | a = or shl st 9 shl yld 13 |
| 16 | b = or shl wb 14 shl rbar 17 |
| 17 | ret or or a b shl wt 20 |
| 18 | end |
| 19 | |
| 20 | fn uAlu4 to ulong |
| 21 | ret ucw 6 7 7 0 0 |
| 22 | end |
| 23 | fn uCmp to ulong |
| 24 | ret ucw 14 7 7 0 0 |
| 25 | end |
| 26 | fn uLd to ulong |
| 27 | ret ucw 2 0 1 0 1 |
| 28 | end |
| 29 | fn uSt to ulong |
| 30 | ret ucw 4 7 1 0 1 |
| 31 | end |
| 32 | fn uW0 to ulong |
| 33 | ret ucw 6 7 7 1 0 |
| 34 | end |
| 35 | fn uW1 to ulong |
| 36 | ret ucw 6 7 7 2 0 |
| 37 | end |
| 38 | fn uWall to ulong |
| 39 | ret ucw 6 7 7 7 0 |
| 40 | end |
| 41 | fn uMufu to ulong |
| 42 | ret ucw 4 0 7 0 1 |
| 43 | end |
| 44 | fn uSafe to ulong |
| 45 | ret ucw 6 7 7 7 0 |
| 46 | end |
| 47 | |
| 48 | fn uEmitRaw o edit ulong 16 atPc ulong to void |
| 49 | w = new ulong 4 0 |
| 50 | if ne get uGuard 0 0 |
| 51 | put o 9 1 |
| 52 | end |
| 53 | if eq get uGuard 0 2 |
| 54 | put o 10 1 |
| 55 | end |
| 56 | put uGuard 0 0 |
| 57 | if ne get o 2 UZ |
| 58 | put o 12 1 |
| 59 | end |
| 60 | if ne get o 3 UZ |
| 61 | put o 13 1 |
| 62 | end |
| 63 | if ne enc1 o w 0 |
| 64 | exit 3 |
| 65 | end |
| 66 | base = mul atPc 4 |
| 67 | for i ulong 4 |
| 68 | put uCodeBuf add base i get w i |
| 69 | end |
| 70 | end |
| 71 | |
| 72 | fn uic op ulong dst ulong a ulong b ulong imm ulong ctrl ulong to void |
| 73 | o = new ulong 16 0 |
| 74 | put o 0 op |
| 75 | put o 1 dst |
| 76 | put o 2 a |
| 77 | put o 3 b |
| 78 | put o 4 UZ |
| 79 | put o 5 4 |
| 80 | put o 6 and imm 0xffffffff |
| 81 | put o 7 ctrl |
| 82 | pc = get uPc 0 |
| 83 | uEmitRaw o pc |
| 84 | put uPc 0 add pc 1 |
| 85 | end |
| 86 | |
| 87 | fn uic4 op ulong dst ulong a ulong b ulong c ulong ctrl ulong to void |
| 88 | o = new ulong 16 0 |
| 89 | put o 0 op |
| 90 | put o 1 dst |
| 91 | put o 2 a |
| 92 | put o 3 b |
| 93 | put o 4 c |
| 94 | put o 5 4 |
| 95 | put o 6 0 |
| 96 | put o 7 ctrl |
| 97 | pc = get uPc 0 |
| 98 | uEmitRaw o pc |
| 99 | put uPc 0 add pc 1 |
| 100 | end |
| 101 | |
| 102 | fn uicImm op ulong dst ulong a ulong c ulong imm ulong ctrl ulong to void |
| 103 | o = new ulong 16 0 |
| 104 | put o 0 op |
| 105 | put o 1 dst |
| 106 | put o 2 a |
| 107 | put o 3 UZ |
| 108 | put o 4 c |
| 109 | put o 5 4 |
| 110 | put o 6 and imm 0xffffffff |
| 111 | put o 7 ctrl |
| 112 | pc = get uPc 0 |
| 113 | uEmitRaw o pc |
| 114 | put uPc 0 add pc 1 |
| 115 | end |
| 116 | |
| 117 | fn uBraFwd gd ulong to ulong |
| 118 | pos = get uPc 0 |
| 119 | put uGuard 0 gd |
| 120 | uic 46 UZ UZ UZ 0 uAlu4 |
| 121 | ret pos |
| 122 | end |
| 123 | |
| 124 | fn uBraBack targetPc ulong gd ulong to void |
| 125 | pos = get uPc 0 |
| 126 | put uGuard 0 gd |
| 127 | delta = and sub targetPc pos 0xffffffff |
| 128 | uic 46 UZ UZ UZ delta uAlu4 |
| 129 | end |
| 130 | |
| 131 | fn uPatch pos ulong gd ulong to void |
| 132 | o = new ulong 16 0 |
| 133 | put o 0 46 |
| 134 | put o 1 UZ |
| 135 | put o 2 UZ |
| 136 | put o 3 UZ |
| 137 | put o 4 UZ |
| 138 | put o 5 4 |
| 139 | put o 6 and sub get uPc 0 pos 0xffffffff |
| 140 | put o 7 uAlu4 |
| 141 | put uGuard 0 gd |
| 142 | uEmitRaw o pos |
| 143 | end |
| 144 | |
| 145 | fn uLit d ulong x ulong to void |
| 146 | uic 2 d UZ UZ x uAlu4 |
| 147 | end |
| 148 | |
| 149 | fn uNum d ulong x f32 to void |
| 150 | uLit d ulong bitcast uint x |
| 151 | end |
| 152 | |
| 153 | fn uParam d ulong off ulong to void |
| 154 | uic 4 d UZ UZ add 896 off ucw 4 0 7 0 1 |
| 155 | uic 0 UZ UZ UZ 0 uW0 |
| 156 | end |
| 157 | |
| 158 | fn uStart ptrs ulong to void |
| 159 | uic 7 4 UZ UZ 856 ucw 4 2 7 0 1 |
| 160 | for i ulong ptrs bound 8 |
| 161 | uic 5 mul i 2 UZ UZ add 896 mul i 8 ucw 4 0 7 0 1 |
| 162 | end |
| 163 | uic 3 14 UZ UZ 33 ucw 4 0 7 0 1 |
| 164 | uic 3 15 UZ UZ 37 ucw 4 0 7 0 1 |
| 165 | uic 0 UZ UZ UZ 0 uWall |
| 166 | end |
| 167 | |
| 168 | fn uDone to void |
| 169 | uic 0 UZ UZ UZ 0 uWall |
| 170 | uic 45 UZ UZ UZ 0 uSafe |
| 171 | while or lt get uPc 0 32 ne rem get uPc 0 8 0 bound 4096 |
| 172 | uic 0 UZ UZ UZ 0 uSafe |
| 173 | end |
| 174 | w = new ulong 4 0 |
| 175 | n = get uPc 0 |
| 176 | for pc ulong n bound 4096 |
| 177 | base = mul pc 4 |
| 178 | for i ulong 4 |
| 179 | put w i get uCodeBuf add base i |
| 180 | end |
| 181 | uCodeWrite w |
| 182 | end |
| 183 | end |
| 184 | |
| 185 | note ========================================================================= |
| 186 | note SM121 Quaternion Macro Helpers |
| 187 | note All quaternions are 4 consecutive GPRs: q0, q1, q2, q3 |
| 188 | note ========================================================================= |
| 189 | |
| 190 | note Emit Hamilton product dst[0..3] = a[0..3] * b[0..3] using tmp reg t |
| 191 | note Requires dst disjoint from a, b, and t. |
| 192 | fn uEmitQMul dst ulong a ulong b ulong t ulong to void |
| 193 | note dst0 = a0*b0 - a1*b1 - a2*b2 - a3*b3 |
| 194 | uic 32 dst a b 0 uAlu4 |
| 195 | uic 32 t add a 1 add b 1 0 uAlu4 |
| 196 | uic 31 dst dst t 0 uAlu4 |
| 197 | uic 32 t add a 2 add b 2 0 uAlu4 |
| 198 | uic 31 dst dst t 0 uAlu4 |
| 199 | uic 32 t add a 3 add b 3 0 uAlu4 |
| 200 | uic 31 dst dst t 0 uAlu4 |
| 201 | note dst1 = a0*b1 + a1*b0 + a2*b3 - a3*b2 |
| 202 | uic 32 add dst 1 a add b 1 0 uAlu4 |
| 203 | uic4 33 add dst 1 add a 1 b add dst 1 uAlu4 |
| 204 | uic4 33 add dst 1 add a 2 add b 3 add dst 1 uAlu4 |
| 205 | uic 32 t add a 3 add b 2 0 uAlu4 |
| 206 | uic 31 add dst 1 add dst 1 t 0 uAlu4 |
| 207 | note dst2 = a0*b2 - a1*b3 + a2*b0 + a3*b1 |
| 208 | uic 32 add dst 2 a add b 2 0 uAlu4 |
| 209 | uic 32 t add a 1 add b 3 0 uAlu4 |
| 210 | uic 31 add dst 2 add dst 2 t 0 uAlu4 |
| 211 | uic4 33 add dst 2 add a 2 b add dst 2 uAlu4 |
| 212 | uic4 33 add dst 2 add a 3 add b 1 add dst 2 uAlu4 |
| 213 | note dst3 = a0*b3 + a1*b2 - a2*b1 + a3*b0 |
| 214 | uic 32 add dst 3 a add b 3 0 uAlu4 |
| 215 | uic4 33 add dst 3 add a 1 add b 2 add dst 3 uAlu4 |
| 216 | uic 32 t add a 2 add b 1 0 uAlu4 |
| 217 | uic 31 add dst 3 add dst 3 t 0 uAlu4 |
| 218 | uic4 33 add dst 3 add a 3 b add dst 3 uAlu4 |
| 219 | end |
| 220 | |
| 221 | note Emit quaternion conjugate in-place: q1 = -q1, q2 = -q2, q3 = -q3 (using zero reg zReg) |
| 222 | fn uEmitQConj q ulong zReg ulong to void |
| 223 | uic 31 add q 1 zReg add q 1 0 uAlu4 |
| 224 | uic 31 add q 2 zReg add q 2 0 uAlu4 |
| 225 | uic 31 add q 3 zReg add q 3 0 uAlu4 |
| 226 | end |
| 227 | |
| 228 | note Load link quaternion (siteReg, dirReg) from links ptr (R0:R1) into 4-aligned dst (LDG.E.128) |
| 229 | note Clobbers tmpIdx and addrPair (even register) |
| 230 | fn uEmitLoadLink dst ulong siteReg ulong dirReg ulong tmpIdx ulong addrPair ulong to void |
| 231 | uicImm 8 tmpIdx siteReg dirReg 4 uAlu4 |
| 232 | uicImm 9 addrPair tmpIdx 0 16 uAlu4 |
| 233 | uic 57 dst addrPair UZ 0 uLd |
| 234 | end |
| 235 | |
| 236 | note Load nb_site[siteReg * 8 + dirOffReg] from nb_site ptr (R6:R7) into dstSite |
| 237 | fn uEmitLoadNb dstSite ulong siteReg ulong dirOffReg ulong tmpIdx ulong addrPair ulong to void |
| 238 | uicImm 8 tmpIdx siteReg dirOffReg 8 uAlu4 |
| 239 | uicImm 9 addrPair tmpIdx 6 4 uAlu4 |
| 240 | uic 11 dstSite addrPair UZ 0 uLd |
| 241 | end |
| 242 | |
| 243 | note ========================================================================= |
| 244 | note Kernel 0: k_su2_staple (Compute 6-staple conjugate sum A_mu(x) on checkerboard) |
| 245 | note Args: |
| 246 | note ptr0 (R0:R1) = links (f32[N * 16]) |
| 247 | note ptr1 (R2:R3) = staples (f32[N * 16]) |
| 248 | note ptr2 (R4:R5) = flags (u32[N * 4]: 0=even, 1=odd, 2=frozen) |
| 249 | note ptr3 (R6:R7) = nb_site (u32[N * 8]: 0=+0,1=-0,2=+1,3=-1,4=+2,5=-2,6=+3,7=-3) |
| 250 | note off 32 = N |
| 251 | note off 36 = mu |
| 252 | note off 40 = parity (0 or 1) |
| 253 | note off 44 = nu0 |
| 254 | note off 48 = nu1 |
| 255 | note off 52 = nu2 |
| 256 | note ========================================================================= |
| 257 | fn uEmitStapleOneDir nuReg ulong to void |
| 258 | note Uses: R16=s, R17=mu, R18=xp (s+mu), R19=zero_f32 |
| 259 | note R24..27=t1, R28..31=t2, R32..35=t3, R36..39=p1, R40..43=acc, R44..47=p2 |
| 260 | note R48..57=scratch indices/addrs, R58=one_u32, R59=mul_tmp |
| 261 | note Forward staple: U_nu(s) * U_mu(s+nu) * U_nu^dag(s+mu) |
| 262 | note plus_off = nu * 2 (R48), minus_off = nu * 2 + 1 (R49) |
| 263 | uicImm 8 48 nuReg UZ 2 uAlu4 |
| 264 | uic 14 49 48 58 0 uAlu4 |
| 265 | note Load xn = nb[s, +nu] into R50 |
| 266 | uEmitLoadNb 50 16 48 52 54 |
| 267 | uic 0 UZ UZ UZ 0 uW0 |
| 268 | note Batch load t1=U(s,nu), t2=U(xn,mu), t3=U(xp,nu) |
| 269 | uEmitLoadLink 24 16 nuReg 52 54 |
| 270 | uic 0 UZ UZ UZ 0 uW1 |
| 271 | uEmitLoadLink 28 50 17 52 54 |
| 272 | uic 0 UZ UZ UZ 0 uW1 |
| 273 | uEmitLoadLink 32 18 nuReg 52 54 |
| 274 | uic 0 UZ UZ UZ 0 uW0 |
| 275 | uEmitQConj 32 19 |
| 276 | uEmitQMul 36 24 28 59 |
| 277 | uEmitQMul 44 36 32 59 |
| 278 | for c ulong 4 |
| 279 | uic 30 add 40 c add 40 c add 44 c 0 uAlu4 |
| 280 | end |
| 281 | |
| 282 | note Backward staple: U_nu^dag(s-nu) * U_mu(s-nu) * U_nu(s+mu-nu) |
| 283 | note Load xm = nb[s, -nu] (R50) and xpm = nb[xp, -nu] (R51) |
| 284 | uEmitLoadNb 50 16 49 52 54 |
| 285 | uic 0 UZ UZ UZ 0 uW1 |
| 286 | uEmitLoadNb 51 18 49 52 56 |
| 287 | uic 0 UZ UZ UZ 0 uW0 |
| 288 | uEmitLoadLink 24 50 nuReg 52 54 |
| 289 | uic 0 UZ UZ UZ 0 uW1 |
| 290 | uEmitLoadLink 28 50 17 52 54 |
| 291 | uic 0 UZ UZ UZ 0 uW1 |
| 292 | uEmitLoadLink 32 51 nuReg 52 54 |
| 293 | uic 0 UZ UZ UZ 0 uW0 |
| 294 | uEmitQConj 24 19 |
| 295 | uEmitQMul 36 24 28 59 |
| 296 | uEmitQMul 44 36 32 59 |
| 297 | for c ulong 4 |
| 298 | uic 30 add 40 c add 40 c add 44 c 0 uAlu4 |
| 299 | end |
| 300 | end |
| 301 | |
| 302 | fn uEmitSu2Staple to bool |
| 303 | uStart 4 |
| 304 | uParam 20 32 |
| 305 | uParam 17 36 |
| 306 | uParam 21 40 |
| 307 | uParam 22 44 |
| 308 | uParam 23 48 |
| 309 | uParam 60 52 |
| 310 | note s (R16) = CTAID.X * 256 + TID.X |
| 311 | uicImm 8 16 15 14 256 uAlu4 |
| 312 | uic 28 UZ 16 20 0 uCmp |
| 313 | bOob = uBraFwd 1 |
| 314 | |
| 315 | note Check flags[s * 4 + mu] == parity |
| 316 | uicImm 8 52 16 17 4 uAlu4 |
| 317 | uicImm 9 54 52 4 4 uAlu4 |
| 318 | uic 11 53 54 UZ 0 uLd |
| 319 | uic 0 UZ UZ UZ 0 uW0 |
| 320 | note XOR flags with parity: 0 iff equal; if >= 1 then skip! |
| 321 | uic 29 53 53 21 0 uAlu4 |
| 322 | uLit 58 1 |
| 323 | uic 28 UZ 53 58 0 uCmp |
| 324 | bSkip = uBraFwd 1 |
| 325 | |
| 326 | note Load xp = nb[s, +mu] into R18 |
| 327 | uicImm 8 48 17 UZ 2 uAlu4 |
| 328 | uEmitLoadNb 18 16 48 52 54 |
| 329 | uic 0 UZ UZ UZ 0 uW0 |
| 330 | |
| 331 | note Zero accumulator acc (R40..43) and zero_f32 (R19) |
| 332 | uic 1 19 UZ UZ 0 uAlu4 |
| 333 | uic 1 40 UZ UZ 0 uAlu4 |
| 334 | uic 1 41 UZ UZ 0 uAlu4 |
| 335 | uic 1 42 UZ UZ 0 uAlu4 |
| 336 | uic 1 43 UZ UZ 0 uAlu4 |
| 337 | |
| 338 | note Sum all 3 orthogonal staple pairs (nu0=R22, nu1=R23, nu2=R60) |
| 339 | uEmitStapleOneDir 22 |
| 340 | uEmitStapleOneDir 23 |
| 341 | uEmitStapleOneDir 60 |
| 342 | |
| 343 | note Store acc[0..3] to staples[s * 4 + mu] (ptr1 = R2:R3) |
| 344 | uicImm 8 52 16 17 4 uAlu4 |
| 345 | uicImm 9 54 52 2 16 uAlu4 |
| 346 | uic 12 UZ 54 40 0 uSt |
| 347 | uic 12 UZ 54 41 4 uSt |
| 348 | uic 12 UZ 54 42 8 uSt |
| 349 | uic 12 UZ 54 43 12 uSt |
| 350 | uic 0 UZ UZ UZ 0 uW1 |
| 351 | |
| 352 | uPatch bSkip 1 |
| 353 | uPatch bOob 1 |
| 354 | ret true |
| 355 | end |
| 356 | |
| 357 | note ========================================================================= |
| 358 | note Kernel 1: k_su2_overrelax (Exact 4-FMA Microcanonical Reflection U' = 2(U.V)V - U) |
| 359 | note Args: |
| 360 | note ptr0 (R0:R1) = links |
| 361 | note ptr1 (R2:R3) = staples |
| 362 | note ptr2 (R4:R5) = flags |
| 363 | note off 24 = N, off 28 = mu, off 32 = parity |
| 364 | note ========================================================================= |
| 365 | fn uEmitSu2Overrelax to bool |
| 366 | uStart 3 |
| 367 | uParam 20 24 |
| 368 | uParam 17 28 |
| 369 | uParam 21 32 |
| 370 | uicImm 8 16 15 14 256 uAlu4 |
| 371 | uic 28 UZ 16 20 0 uCmp |
| 372 | bOob = uBraFwd 1 |
| 373 | |
| 374 | uicImm 8 52 16 17 4 uAlu4 |
| 375 | uicImm 9 54 52 4 4 uAlu4 |
| 376 | uic 11 53 54 UZ 0 uLd |
| 377 | uic 0 UZ UZ UZ 0 uW0 |
| 378 | uic 29 53 53 21 0 uAlu4 |
| 379 | uLit 58 1 |
| 380 | uic 28 UZ 53 58 0 uCmp |
| 381 | bSkip = uBraFwd 1 |
| 382 | |
| 383 | note Load U (R24..27) and A (R28..31) |
| 384 | uicImm 9 54 52 0 16 uAlu4 |
| 385 | uicImm 9 56 52 2 16 uAlu4 |
| 386 | uic 57 24 54 UZ 0 uLd |
| 387 | uic 57 28 56 UZ 0 uLd |
| 388 | uic 0 UZ UZ UZ 0 uW0 |
| 389 | |
| 390 | note k2 = A.A (R32) |
| 391 | uic 32 32 28 28 0 uAlu4 |
| 392 | uic4 33 32 29 29 32 uAlu4 |
| 393 | uic4 33 32 30 30 32 uAlu4 |
| 394 | uic4 33 32 31 31 32 uAlu4 |
| 395 | uNum 33 0.0000000001f32 |
| 396 | uic 34 0 33 32 0 uCmp |
| 397 | bTiny = uBraFwd 1 |
| 398 | |
| 399 | note invK = rsqrt(k2), V = A * invK (in-place R28..31) |
| 400 | uic 41 34 32 UZ 0 uMufu |
| 401 | uic 0 UZ UZ UZ 0 uW0 |
| 402 | for c ulong 4 |
| 403 | uic 32 add 28 c add 28 c 34 0 uAlu4 |
| 404 | end |
| 405 | |
| 406 | note dot = U.V (R35), d2 = 2.0 * dot (R35) |
| 407 | uic 32 35 24 28 0 uAlu4 |
| 408 | uic4 33 35 25 29 35 uAlu4 |
| 409 | uic4 33 35 26 30 35 uAlu4 |
| 410 | uic4 33 35 27 31 35 uAlu4 |
| 411 | uic 30 35 35 35 0 uAlu4 |
| 412 | |
| 413 | note U' = d2 * V - U (R36..39) |
| 414 | for c ulong 4 |
| 415 | uic 32 add 36 c 35 add 28 c 0 uAlu4 |
| 416 | uic 31 add 36 c add 36 c add 24 c 0 uAlu4 |
| 417 | end |
| 418 | |
| 419 | note Renormalize U' once for f32 stability |
| 420 | uic 32 32 36 36 0 uAlu4 |
| 421 | uic4 33 32 37 37 32 uAlu4 |
| 422 | uic4 33 32 38 38 32 uAlu4 |
| 423 | uic4 33 32 39 39 32 uAlu4 |
| 424 | uic 41 34 32 UZ 0 uMufu |
| 425 | uic 0 UZ UZ UZ 0 uW0 |
| 426 | for c ulong 4 |
| 427 | uic 32 add 36 c add 36 c 34 0 uAlu4 |
| 428 | end |
| 429 | |
| 430 | note Store U' back to links[s*4+mu] |
| 431 | uic 12 UZ 54 36 0 uSt |
| 432 | uic 12 UZ 54 37 4 uSt |
| 433 | uic 12 UZ 54 38 8 uSt |
| 434 | uic 12 UZ 54 39 12 uSt |
| 435 | uic 0 UZ UZ UZ 0 uW1 |
| 436 | |
| 437 | uPatch bTiny 1 |
| 438 | uPatch bSkip 1 |
| 439 | uPatch bOob 1 |
| 440 | ret true |
| 441 | end |
| 442 | |
| 443 | note ========================================================================= |
| 444 | note Kernel 2: k_su2_heatbath (Exact Trigonometric-Free Kennedy-Pendleton Heatbath) |
| 445 | note Args: |
| 446 | note ptr0 (R0:R1) = links |
| 447 | note ptr1 (R2:R3) = staples |
| 448 | note ptr2 (R4:R5) = flags |
| 449 | note ptr3 (R6:R7) = rng (u32[N]) |
| 450 | note off 32 = N, off 36 = mu, off 40 = parity, off 44 = beta_f32_bits |
| 451 | note ========================================================================= |
| 452 | note Advance xorshift32 state in rSt, produce u in (0, 1) in rOut (clobbers rTmp, rSh) |
| 453 | fn uEmitRand01 rSt ulong rOut ulong rTmp ulong rSh ulong rScale ulong rEps ulong to void |
| 454 | uLit rSh 13 |
| 455 | uic 52 rTmp rSt rSh 0 uAlu4 |
| 456 | uic 29 rSt rSt rTmp 0 uAlu4 |
| 457 | uic 17 rTmp rSt UZ 17 uAlu4 |
| 458 | uic 29 rSt rSt rTmp 0 uAlu4 |
| 459 | uLit rSh 5 |
| 460 | uic 52 rTmp rSt rSh 0 uAlu4 |
| 461 | uic 29 rSt rSt rTmp 0 uAlu4 |
| 462 | note Convert top 24 bits (non-negative s32) to f32 in [eps, 1.0) |
| 463 | uic 17 rTmp rSt UZ 8 uAlu4 |
| 464 | uic 38 rOut rTmp UZ 0 uAlu4 |
| 465 | uic4 33 rOut rOut rScale rEps uAlu4 |
| 466 | end |
| 467 | |
| 468 | note The plaquette measurement retries rejected proposals until accepted. |
| 469 | note Older calibration binaries retain their original bounded sampler by default. |
| 470 | global uStrictRejection uint 1 |
| 471 | |
| 472 | fn uEmitHbDisk to void |
| 473 | uLit 48 0 |
| 474 | uLit 49 16 |
| 475 | uNum 37 0.5f32 |
| 476 | lblDisk = get uPc 0 |
| 477 | uEmitRand01 18 38 50 51 19 23 |
| 478 | uEmitRand01 18 39 50 51 19 23 |
| 479 | uic4 33 38 45 38 44 uAlu4 |
| 480 | uic 31 38 38 45 0 uAlu4 |
| 481 | uic4 33 39 45 39 44 uAlu4 |
| 482 | uic 31 39 39 45 0 uAlu4 |
| 483 | uic 32 38 38 38 0 uAlu4 |
| 484 | uic4 33 39 39 39 38 uAlu4 |
| 485 | uic 34 0 39 44 0 uCmp |
| 486 | bR1 = uBraFwd 1 |
| 487 | uic 34 0 23 39 0 uCmp |
| 488 | bR2 = uBraFwd 1 |
| 489 | uic 40 39 39 UZ 0 uMufu |
| 490 | uic 0 UZ UZ UZ 0 uW0 |
| 491 | uic 32 37 38 39 0 uAlu4 |
| 492 | bDone = uBraFwd 0 |
| 493 | uPatch bR1 1 |
| 494 | uPatch bR2 1 |
| 495 | uic 14 48 48 58 0 uAlu4 |
| 496 | uic 28 UZ 48 49 0 uCmp |
| 497 | if ne get uStrictRejection 0 0 |
| 498 | uBraBack lblDisk 0 |
| 499 | else |
| 500 | uBraBack lblDisk 2 |
| 501 | end |
| 502 | uPatch bDone 0 |
| 503 | end |
| 504 | |
| 505 | fn uEmitHbKpLoop to void |
| 506 | uLit 47 0 |
| 507 | uLit 59 48 |
| 508 | uNum 36 0.0f32 |
| 509 | lblKp = get uPc 0 |
| 510 | uEmitHbDisk |
| 511 | uEmitRand01 18 38 50 51 19 23 |
| 512 | uEmitRand01 18 39 50 51 19 23 |
| 513 | uEmitRand01 18 40 50 51 19 23 |
| 514 | uic 59 38 38 UZ 0 uMufu |
| 515 | uic 0 UZ UZ UZ 0 uW0 |
| 516 | uic 59 39 39 UZ 0 uMufu |
| 517 | uic 0 UZ UZ UZ 0 uW0 |
| 518 | uic4 33 38 37 39 38 uAlu4 |
| 519 | uic 32 36 46 38 0 uAlu4 |
| 520 | uic 31 38 44 36 0 uAlu4 |
| 521 | uic 32 40 40 40 0 uAlu4 |
| 522 | uic 34 0 38 40 0 uCmp |
| 523 | bKpOk = uBraFwd 1 |
| 524 | uic 14 47 47 58 0 uAlu4 |
| 525 | uic 28 UZ 47 59 0 uCmp |
| 526 | if ne get uStrictRejection 0 0 |
| 527 | uBraBack lblKp 0 |
| 528 | else |
| 529 | uBraBack lblKp 2 |
| 530 | end |
| 531 | uNum 36 0.0f32 |
| 532 | uPatch bKpOk 1 |
| 533 | end |
| 534 | |
| 535 | fn uEmitHbSphere to void |
| 536 | uLit 47 0 |
| 537 | uLit 59 32 |
| 538 | uNum 25 1.0f32 |
| 539 | uNum 26 0.0f32 |
| 540 | uNum 27 0.0f32 |
| 541 | lblSph = get uPc 0 |
| 542 | uEmitRand01 18 38 50 51 19 23 |
| 543 | uEmitRand01 18 39 50 51 19 23 |
| 544 | uEmitRand01 18 40 50 51 19 23 |
| 545 | uic4 33 38 45 38 44 uAlu4 |
| 546 | uic 31 38 38 45 0 uAlu4 |
| 547 | uic4 33 39 45 39 44 uAlu4 |
| 548 | uic 31 39 39 45 0 uAlu4 |
| 549 | uic4 33 40 45 40 44 uAlu4 |
| 550 | uic 31 40 40 45 0 uAlu4 |
| 551 | uic 32 41 38 38 0 uAlu4 |
| 552 | uic4 33 41 39 39 41 uAlu4 |
| 553 | uic4 33 41 40 40 41 uAlu4 |
| 554 | uic 34 0 41 44 0 uCmp |
| 555 | bR1 = uBraFwd 1 |
| 556 | uic 34 0 23 41 0 uCmp |
| 557 | bR2 = uBraFwd 1 |
| 558 | uic 41 42 41 UZ 0 uMufu |
| 559 | uic 0 UZ UZ UZ 0 uW0 |
| 560 | uic 32 42 42 37 0 uAlu4 |
| 561 | uic 32 25 38 42 0 uAlu4 |
| 562 | uic 32 26 39 42 0 uAlu4 |
| 563 | uic 32 27 40 42 0 uAlu4 |
| 564 | bDone = uBraFwd 0 |
| 565 | uPatch bR1 1 |
| 566 | uPatch bR2 1 |
| 567 | uic 14 47 47 58 0 uAlu4 |
| 568 | uic 28 UZ 47 59 0 uCmp |
| 569 | if ne get uStrictRejection 0 0 |
| 570 | uBraBack lblSph 0 |
| 571 | else |
| 572 | uBraBack lblSph 2 |
| 573 | end |
| 574 | uPatch bDone 0 |
| 575 | end |
| 576 | |
| 577 | fn uEmitSu2Heatbath to bool |
| 578 | uStart 4 |
| 579 | uParam 20 32 |
| 580 | uParam 17 36 |
| 581 | uParam 21 40 |
| 582 | uParam 22 44 |
| 583 | uicImm 8 16 15 14 256 uAlu4 |
| 584 | uic 28 UZ 16 20 0 uCmp |
| 585 | bOob = uBraFwd 1 |
| 586 | |
| 587 | uicImm 8 52 16 17 4 uAlu4 |
| 588 | uicImm 9 54 52 4 4 uAlu4 |
| 589 | uic 11 53 54 UZ 0 uLd |
| 590 | uic 0 UZ UZ UZ 0 uW0 |
| 591 | uic 29 53 53 21 0 uAlu4 |
| 592 | uLit 58 1 |
| 593 | uic 28 UZ 53 58 0 uCmp |
| 594 | bSkip = uBraFwd 1 |
| 595 | |
| 596 | uicImm 9 56 52 2 16 uAlu4 |
| 597 | uicImm 9 54 16 6 4 uAlu4 |
| 598 | uic 57 28 56 UZ 0 uLd |
| 599 | uic 11 18 54 UZ 0 uLd |
| 600 | uic 0 UZ UZ UZ 0 uW0 |
| 601 | |
| 602 | uic 32 32 28 28 0 uAlu4 |
| 603 | uic4 33 32 29 29 32 uAlu4 |
| 604 | uic4 33 32 30 30 32 uAlu4 |
| 605 | uic4 33 32 31 31 32 uAlu4 |
| 606 | uNum 35 0.0000000001f32 |
| 607 | uic 34 0 35 32 0 uCmp |
| 608 | bTiny = uBraFwd 1 |
| 609 | |
| 610 | uic 41 33 32 UZ 0 uMufu |
| 611 | uic 0 UZ UZ UZ 0 uW0 |
| 612 | uic 32 34 32 33 0 uAlu4 |
| 613 | for c ulong 4 |
| 614 | uic 32 add 28 c add 28 c 33 0 uAlu4 |
| 615 | end |
| 616 | |
| 617 | uNum 19 0.000000059604645f32 |
| 618 | uNum 23 0.0000001f32 |
| 619 | uNum 44 1.0f32 |
| 620 | uNum 45 2.0f32 |
| 621 | uic 32 35 22 34 0 uAlu4 |
| 622 | uic 30 35 35 35 0 uAlu4 |
| 623 | uic 40 35 35 UZ 0 uMufu |
| 624 | uic 0 UZ UZ UZ 0 uW0 |
| 625 | uNum 46 neg 0.69314718f32 |
| 626 | uic 32 46 46 35 0 uAlu4 |
| 627 | |
| 628 | uEmitHbKpLoop |
| 629 | |
| 630 | uic 30 36 36 36 0 uAlu4 |
| 631 | uic 31 24 44 36 0 uAlu4 |
| 632 | uic 32 37 24 24 0 uAlu4 |
| 633 | uic 31 37 44 37 0 uAlu4 |
| 634 | uNum 38 0.00000001f32 |
| 635 | uic 37 37 37 38 0 uAlu4 |
| 636 | uic 41 38 37 UZ 0 uMufu |
| 637 | uic 0 UZ UZ UZ 0 uW0 |
| 638 | uic 32 37 37 38 0 uAlu4 |
| 639 | |
| 640 | uEmitHbSphere |
| 641 | |
| 642 | uEmitQMul 36 24 28 50 |
| 643 | uic 32 32 36 36 0 uAlu4 |
| 644 | uic4 33 32 37 37 32 uAlu4 |
| 645 | uic4 33 32 38 38 32 uAlu4 |
| 646 | uic4 33 32 39 39 32 uAlu4 |
| 647 | uic 41 33 32 UZ 0 uMufu |
| 648 | uic 0 UZ UZ UZ 0 uW0 |
| 649 | for c ulong 4 |
| 650 | uic 32 add 36 c add 36 c 33 0 uAlu4 |
| 651 | end |
| 652 | |
| 653 | uicImm 9 56 52 0 16 uAlu4 |
| 654 | uic 12 UZ 56 36 0 uSt |
| 655 | uic 12 UZ 56 37 4 uSt |
| 656 | uic 12 UZ 56 38 8 uSt |
| 657 | uic 12 UZ 56 39 12 uSt |
| 658 | uic 12 UZ 54 18 0 uSt |
| 659 | uic 0 UZ UZ UZ 0 uW1 |
| 660 | |
| 661 | uPatch bTiny 1 |
| 662 | uPatch bSkip 1 |
| 663 | uPatch bOob 1 |
| 664 | ret true |
| 665 | end |