yang
This project has not described itself yet.
Brought by drakestapleton
yang / src / ufbi_check4_gb10.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note src/ufbi_check4_gb10.om: Pure Seeded-OM-2 Zero-CUDA GB10 Runner for UFBI Check #4 |
| 3 | note (Out-of-Sample CentralObs Validation, Fixed-Beta Exponential Decay Mass-Gap Extraction |
| 4 | note L in {6,8,10,12,16}, and Exact 2-Loop SU(2) Fixed-Physical-Box Continuum Scaling |
| 5 | note L*a(beta) = const across (L=8,b=2.3000) -> (L=12,b=2.4612) -> (L=16,b=2.5752)). |
| 6 | note |
| 7 | note Measures 8 gauge-invariant observables simultaneously per sweep (with 8-block jackknife): |
| 8 | note O0: P1x1_S0 (bare 1x1 plaquette) |
| 9 | note O1: W2x2_S0 (bare 2x2 Wilson loop) |
| 10 | note O2: AdjP_S0 (bare adjoint plaquette 4*P^2 - 1) |
| 11 | note O3: P1x1_S2 (2-step APE smeared 1x1 plaquette) |
| 12 | note O4: W1x2_S2 (2-step APE smeared 1x2 rectangle) |
| 13 | note O5: W2x2_S2 (2-step APE smeared 2x2 loop) |
| 14 | note O6: W2_CHAMP (Wave-2 discovered: ratio(ratio(AdjP_S0, P1x1_S2), chi1(AdjP_S0))) |
| 15 | note O7: CREUTZ_2x2 (perimeter-UV-cancelled Creutz ratio: (P1x1_S2*W2x2_S2)/(W1x2_S2)^2) |
| 16 | note |
| 17 | note Composed after: |
| 18 | note gpu/nvidia/native/nvrm/context.om |
| 19 | note gpu/nvidia/native/blackwell/vector.om |
| 20 | note gpu/nvidia/native/blackwell/launch.om |
| 21 | note gpu/nvidia/native/blackwell/batch.om |
| 22 | note om/encoder/bw_enc_sm121.om |
| 23 | note src/ufbi_math.om |
| 24 | note src/ufbi_check3_kernels.om |
| 25 | |
| 26 | global uCodePos ulong 1 |
| 27 | global uEntry ulong 8 |
| 28 | global uCodeMap long 1 |
| 29 | global uCodeFail uint 1 |
| 30 | global uBind uint 32 |
| 31 | global uBindN ulong 1 |
| 32 | global uDirty uint 1 |
| 33 | |
| 34 | global dLinks long 1 |
| 35 | global dStaples long 1 |
| 36 | global dFlags long 1 |
| 37 | global dNbSite long 1 |
| 38 | global dRng long 1 |
| 39 | |
| 40 | note Host link buffers (L<=16 -> 65536 sites x 16 f32 = 1048576 f32 each): |
| 41 | note hLinks = raw S0, hSm1 = APE-1, hSm2 = APE-2 |
| 42 | global hLinks f32 1048576 |
| 43 | global hSm1 f32 1048576 |
| 44 | global hSm2 f32 1048576 |
| 45 | global hNb uint 524288 |
| 46 | global hStage uchar 65536 |
| 47 | |
| 48 | note Time series: up to 160 sweeps x 8 observables = 1280 f64 |
| 49 | global tsData f64 1280 |
| 50 | global baseMean f64 8 |
| 51 | global baseErr f64 8 |
| 52 | global curMean f64 8 |
| 53 | global curErr f64 8 |
| 54 | global curDelta f64 8 |
| 55 | global curZ f64 8 |
| 56 | global mcAcc f64 8 |
| 57 | global mcCnt ulong 1 |
| 58 | global armBeta f32 1 |
| 59 | global armSeed ulong 1 |
| 60 | global armC1 ulong 1 |
| 61 | global armC2 ulong 1 |
| 62 | |
| 63 | text tC4Hdr "=== UFBI CHECK #4: 4D SU(2) CENTRALOBS EXPONENTIAL DECAY & CONTINUUM CONTRACTION (PURE OM-2 GB10) ===\n" |
| 64 | text tC4Err "FAIL: GB10 native NVRM/kernel error stage=" |
| 65 | text tC4Cols "exp\tL\tbeta\tcollar\tsweeps\tdP0\tdP0_Z\tdW2_0\tdW2_0_Z\tdAdj0\tdAdj0_Z\tdP2\tdP2_Z\tdW2_2\tdW2_2_Z\tdW2Ch\tdW2Ch_Z\tdCr22\tdCr22_Z\tP0_m\tW2Ch_m\tCr22_m\tus\n" |
| 66 | text tTab "\t" |
| 67 | text tNl "\n" |
| 68 | text tE4A "decay_b230" |
| 69 | text tE4B "fixed_ell" |
| 70 | text tK0 "C0_cold" |
| 71 | text tK3 "C3_hot_haar" |
| 72 | text tK5 "C5_nonab_twist" |
| 73 | text tK6 "C6_trick_vort" |
| 74 | text tC4Done "CHECK4_GB10_DONE status=PASS\n" |
| 75 | |
| 76 | fn uCodeWrite w view ulong 4 to void |
| 77 | p = get uCodePos 0 |
| 78 | b = new uchar 16 0 |
| 79 | if gt get uCodeMap 0 0 |
| 80 | for i ulong 16 |
| 81 | put b i uchar and shr get w div i 4 mul rem i 4 8 255 |
| 82 | end |
| 83 | if ne mapwrite get uCodeMap 0 p b 0 16 16 |
| 84 | put uCodeFail 0 1 |
| 85 | end |
| 86 | end |
| 87 | put uCodePos 0 add p 16 |
| 88 | end |
| 89 | |
| 90 | fn uEmitAllKernels to void |
| 91 | put uCodePos 0 0 |
| 92 | for id ulong 3 |
| 93 | p = mul div add get uCodePos 0 255 256 256 |
| 94 | put uEntry id p |
| 95 | put uCodePos 0 p |
| 96 | put uPc 0 0 |
| 97 | put uGuard 0 0 |
| 98 | ok = false |
| 99 | if eq id 0 |
| 100 | ok = uEmitSu2Staple |
| 101 | end |
| 102 | if eq id 1 |
| 103 | ok = uEmitSu2Overrelax |
| 104 | end |
| 105 | if eq id 2 |
| 106 | ok = uEmitSu2Heatbath |
| 107 | end |
| 108 | if not ok |
| 109 | exit 4 |
| 110 | end |
| 111 | uDone |
| 112 | end |
| 113 | end |
| 114 | |
| 115 | fn uArg u uint to void |
| 116 | i = get uBindN 0 |
| 117 | put uBind i u |
| 118 | put uBindN 0 add i 1 |
| 119 | end |
| 120 | |
| 121 | fn uPtr va ulong to void |
| 122 | uArg gblo va |
| 123 | uArg gbhi va |
| 124 | end |
| 125 | |
| 126 | fn uRecord id ulong gx uint bx uint to bool |
| 127 | gbqmd 1 |
| 128 | a = add mapaddr get uCodeMap 0 get uEntry id |
| 129 | put gbq1 32 gblo shr a 4 |
| 130 | put gbq1 33 or uint and shr a 36 2097151 20971520 |
| 131 | put gbq1 59 gblo shr a 8 |
| 132 | put gbq1 34 or uint 65536 bx |
| 133 | put gbq1 35 or uint 131073 shl uint 64 8 |
| 134 | put gbq1 36 78923784 |
| 135 | put gbq1 37 0 |
| 136 | put gbq1 39 gx |
| 137 | put gbq1 40 1 |
| 138 | put gbq1 41 1 |
| 139 | put gbcb 216 bx |
| 140 | put gbcb 220 gx |
| 141 | put gbcb 221 1 |
| 142 | put gbcb 222 1 |
| 143 | cb = mapaddr get gbmem 1 |
| 144 | words = get uBindN 0 |
| 145 | endva = add cb add 896 mul words 4 |
| 146 | put gbcb 212 gbhi endva |
| 147 | put gbcb 213 gblo endva |
| 148 | put gbused 0 0 |
| 149 | gbsetup |
| 150 | if ne get uDirty 0 0 |
| 151 | gbmth 0 40 4 |
| 152 | gbemit 0 |
| 153 | gbemit 0 |
| 154 | gbemit 0 |
| 155 | gbemit 2281701376 |
| 156 | put uDirty 0 0 |
| 157 | end |
| 158 | gbdma cb 224 |
| 159 | for j ulong 224 |
| 160 | gbemit get gbcb j |
| 161 | end |
| 162 | gbdma add cb 896 uint words |
| 163 | for j ulong words bound 32 |
| 164 | gbemit get uBind j |
| 165 | end |
| 166 | q = mapaddr get gbmem 2 |
| 167 | gbinline q false |
| 168 | gbdma add q 8192 1 |
| 169 | gbemit 1 |
| 170 | gbinline add q 4096 true |
| 171 | gbrel add mapaddr get gbmem 3 32 6 |
| 172 | put uBindN 0 0 |
| 173 | ret gbappend id get gbst 1 |
| 174 | end |
| 175 | |
| 176 | fn uRunKernel id ulong gx uint bx uint to bool |
| 177 | put uDirty 0 1 |
| 178 | if not gbbegin 1 |
| 179 | ret false |
| 180 | end |
| 181 | if not uRecord id gx bx |
| 182 | ret false |
| 183 | end |
| 184 | ret gbbsubmit 2000000000 |
| 185 | end |
| 186 | |
| 187 | fn stageU32 k ulong v uint to void |
| 188 | b = mul k 4 |
| 189 | put hStage b uchar and v 255 |
| 190 | put hStage add b 1 uchar and shr v 8 255 |
| 191 | put hStage add b 2 uchar and shr v 16 255 |
| 192 | put hStage add b 3 uchar and shr v 24 255 |
| 193 | end |
| 194 | |
| 195 | fn stageF32 k ulong v f32 to void |
| 196 | stageU32 k bitcast uint v |
| 197 | end |
| 198 | |
| 199 | fn flushStage m long offBytes ulong nWords ulong to bool |
| 200 | nb = mul nWords 4 |
| 201 | ret eq mapwrite m offBytes hStage 0 nb long nb |
| 202 | end |
| 203 | |
| 204 | fn uploadLinks N ulong to bool |
| 205 | totalF = mul N 16 |
| 206 | off = ulong 0 |
| 207 | while lt off totalF bound 128 |
| 208 | cnt = sub totalF off |
| 209 | if gt cnt 16384 |
| 210 | cnt = ulong 16384 |
| 211 | end |
| 212 | for k ulong cnt bound 16384 |
| 213 | stageF32 k get hLinks add off k |
| 214 | end |
| 215 | if not flushStage get dLinks 0 mul off 4 cnt |
| 216 | ret false |
| 217 | end |
| 218 | off = add off cnt |
| 219 | end |
| 220 | ret true |
| 221 | end |
| 222 | |
| 223 | fn downloadLinks N ulong to void |
| 224 | totalF = mul N 16 |
| 225 | lm = get dLinks 0 |
| 226 | for i ulong totalF bound 1048576 |
| 227 | put hLinks i bitcast f32 uint mapget lm mul i 4 4 |
| 228 | end |
| 229 | end |
| 230 | |
| 231 | fn coordIdx c0 ulong c1 ulong c2 ulong c3 ulong L ulong to ulong |
| 232 | r = add mul c0 L c1 |
| 233 | r = add mul r L c2 |
| 234 | ret add mul r L c3 |
| 235 | end |
| 236 | |
| 237 | fn buildNbTable L ulong to bool |
| 238 | N = mul mul L L mul L L |
| 239 | for s ulong N bound 65536 |
| 240 | c3 = rem s L |
| 241 | t = div s L |
| 242 | c2 = rem t L |
| 243 | t = div t L |
| 244 | c1 = rem t L |
| 245 | c0 = div t L |
| 246 | b = mul s 8 |
| 247 | put hNb b uint coordIdx rem add c0 1 L c1 c2 c3 L |
| 248 | put hNb add b 1 uint coordIdx rem add c0 sub L 1 L c1 c2 c3 L |
| 249 | put hNb add b 2 uint coordIdx c0 rem add c1 1 L c2 c3 L |
| 250 | put hNb add b 3 uint coordIdx c0 rem add c1 sub L 1 L c2 c3 L |
| 251 | put hNb add b 4 uint coordIdx c0 c1 rem add c2 1 L c3 L |
| 252 | put hNb add b 5 uint coordIdx c0 c1 rem add c2 sub L 1 L c3 L |
| 253 | put hNb add b 6 uint coordIdx c0 c1 c2 rem add c3 1 L L |
| 254 | put hNb add b 7 uint coordIdx c0 c1 c2 rem add c3 sub L 1 L L |
| 255 | end |
| 256 | totalW = mul N 8 |
| 257 | off = ulong 0 |
| 258 | while lt off totalW bound 64 |
| 259 | cnt = sub totalW off |
| 260 | if gt cnt 16384 |
| 261 | cnt = ulong 16384 |
| 262 | end |
| 263 | for k ulong cnt bound 16384 |
| 264 | stageU32 k get hNb add off k |
| 265 | end |
| 266 | if not flushStage get dNbSite 0 mul off 4 cnt |
| 267 | ret false |
| 268 | end |
| 269 | off = add off cnt |
| 270 | end |
| 271 | ret true |
| 272 | end |
| 273 | |
| 274 | fn isBdryL s ulong L ulong to bool |
| 275 | c3 = rem s L |
| 276 | t = div s L |
| 277 | c2 = rem t L |
| 278 | t = div t L |
| 279 | c1 = rem t L |
| 280 | c0 = div t L |
| 281 | lm1 = sub L 1 |
| 282 | if or eq c0 0 eq c0 lm1 |
| 283 | ret true |
| 284 | end |
| 285 | if or eq c1 0 eq c1 lm1 |
| 286 | ret true |
| 287 | end |
| 288 | if or eq c2 0 eq c2 lm1 |
| 289 | ret true |
| 290 | end |
| 291 | if or eq c3 0 eq c3 lm1 |
| 292 | ret true |
| 293 | end |
| 294 | ret false |
| 295 | end |
| 296 | |
| 297 | note Central measurement box: strictly interior 2x2x2x2 core around L/2 (constant physical core size!) |
| 298 | note For L=6: [2,3]; L=8: [3,4]; L=10: [4,5]; L=12: [5,6]; L=16: [7,8] -> distance to boundary = L/2 - 1! |
| 299 | fn isCore2 s ulong L ulong to bool |
| 300 | lo = sub div L 2 1 |
| 301 | hi = add lo 2 |
| 302 | c3 = rem s L |
| 303 | t = div s L |
| 304 | c2 = rem t L |
| 305 | t = div t L |
| 306 | c1 = rem t L |
| 307 | c0 = div t L |
| 308 | if or lt c0 lo ge c0 hi |
| 309 | ret false |
| 310 | end |
| 311 | if or lt c1 lo ge c1 hi |
| 312 | ret false |
| 313 | end |
| 314 | if or lt c2 lo ge c2 hi |
| 315 | ret false |
| 316 | end |
| 317 | if or lt c3 lo ge c3 hi |
| 318 | ret false |
| 319 | end |
| 320 | ret true |
| 321 | end |
| 322 | |
| 323 | note Halo box around central core needed for 2-step APE smearing + 2x2 loops: margin pad around core |
| 324 | fn isHalo s ulong L ulong pad ulong to bool |
| 325 | lo = sub div L 2 1 |
| 326 | hi = add lo 2 |
| 327 | mlo = ulong 0 |
| 328 | if gt lo pad |
| 329 | mlo = sub lo pad |
| 330 | end |
| 331 | mhi = add hi pad |
| 332 | if gt mhi L |
| 333 | mhi = L |
| 334 | end |
| 335 | c3 = rem s L |
| 336 | t = div s L |
| 337 | c2 = rem t L |
| 338 | t = div t L |
| 339 | c1 = rem t L |
| 340 | c0 = div t L |
| 341 | if or lt c0 mlo ge c0 mhi |
| 342 | ret false |
| 343 | end |
| 344 | if or lt c1 mlo ge c1 mhi |
| 345 | ret false |
| 346 | end |
| 347 | if or lt c2 mlo ge c2 mhi |
| 348 | ret false |
| 349 | end |
| 350 | if or lt c3 mlo ge c3 mhi |
| 351 | ret false |
| 352 | end |
| 353 | ret true |
| 354 | end |
| 355 | |
| 356 | fn siteFlag s ulong L ulong freezeCollar bool to uint |
| 357 | if and freezeCollar isBdryL s L |
| 358 | ret uint 2 |
| 359 | end |
| 360 | c3 = rem s L |
| 361 | t = div s L |
| 362 | c2 = rem t L |
| 363 | t = div t L |
| 364 | c1 = rem t L |
| 365 | c0 = div t L |
| 366 | ret uint and add add c0 c1 add c2 c3 1 |
| 367 | end |
| 368 | |
| 369 | fn buildFlags L ulong freezeCollar bool to bool |
| 370 | N = mul mul L L mul L L |
| 371 | totalW = mul N 4 |
| 372 | off = ulong 0 |
| 373 | while lt off totalW bound 32 |
| 374 | cnt = sub totalW off |
| 375 | if gt cnt 16384 |
| 376 | cnt = ulong 16384 |
| 377 | end |
| 378 | for k ulong cnt bound 16384 |
| 379 | stageU32 k siteFlag div add off k 4 L freezeCollar |
| 380 | end |
| 381 | if not flushStage get dFlags 0 mul off 4 cnt |
| 382 | ret false |
| 383 | end |
| 384 | off = add off cnt |
| 385 | end |
| 386 | ret true |
| 387 | end |
| 388 | |
| 389 | fn seedGpuRng N ulong seed ulong to bool |
| 390 | uRngSeed seed |
| 391 | off = ulong 0 |
| 392 | while lt off N bound 16 |
| 393 | cnt = sub N off |
| 394 | if gt cnt 16384 |
| 395 | cnt = ulong 16384 |
| 396 | end |
| 397 | for k ulong cnt bound 16384 |
| 398 | r = uint and uRngNext 0xffffffff |
| 399 | if eq r 0 |
| 400 | r = uint 0x9e3779b9 |
| 401 | end |
| 402 | stageU32 k r |
| 403 | end |
| 404 | if not flushStage get dRng 0 mul off 4 cnt |
| 405 | ret false |
| 406 | end |
| 407 | off = add off cnt |
| 408 | end |
| 409 | ret true |
| 410 | end |
| 411 | |
| 412 | fn qNormHost base ulong to void |
| 413 | a0 = get hLinks base |
| 414 | a1 = get hLinks add base 1 |
| 415 | a2 = get hLinks add base 2 |
| 416 | a3 = get hLinks add base 3 |
| 417 | n2 = add add mul a0 a0 mul a1 a1 add mul a2 a2 mul a3 a3 |
| 418 | if le n2 0.0000000001f32 |
| 419 | put hLinks base 1.0f32 |
| 420 | put hLinks add base 1 0.0f32 |
| 421 | put hLinks add base 2 0.0f32 |
| 422 | put hLinks add base 3 0.0f32 |
| 423 | ret |
| 424 | end |
| 425 | inv = f32 div 1.0f64 uSqrt64 f64 n2 |
| 426 | put hLinks base mul a0 inv |
| 427 | put hLinks add base 1 mul a1 inv |
| 428 | put hLinks add base 2 mul a2 inv |
| 429 | put hLinks add base 3 mul a3 inv |
| 430 | end |
| 431 | |
| 432 | fn setCollarLink s ulong mu ulong L ulong cid ulong to void |
| 433 | base = mul add mul s 4 mu 4 |
| 434 | put hLinks base 1.0f32 |
| 435 | put hLinks add base 1 0.0f32 |
| 436 | put hLinks add base 2 0.0f32 |
| 437 | put hLinks add base 3 0.0f32 |
| 438 | if eq cid 0 |
| 439 | ret |
| 440 | end |
| 441 | if eq cid 3 |
| 442 | put hLinks base f32 uRngNorm64 |
| 443 | put hLinks add base 1 f32 uRngNorm64 |
| 444 | put hLinks add base 2 f32 uRngNorm64 |
| 445 | put hLinks add base 3 f32 uRngNorm64 |
| 446 | qNormHost base |
| 447 | ret |
| 448 | end |
| 449 | c3 = rem s L |
| 450 | c2 = rem div s L L |
| 451 | c1 = rem div s mul L L L |
| 452 | c0 = div s mul mul L L L |
| 453 | if eq cid 5 |
| 454 | if eq mu 0 |
| 455 | put hLinks base 0.0f32 |
| 456 | put hLinks add base 1 1.0f32 |
| 457 | end |
| 458 | if eq mu 1 |
| 459 | put hLinks base 0.0f32 |
| 460 | put hLinks add base 2 1.0f32 |
| 461 | end |
| 462 | if eq mu 2 |
| 463 | put hLinks base 0.0f32 |
| 464 | put hLinks add base 3 1.0f32 |
| 465 | end |
| 466 | if eq mu 3 |
| 467 | put hLinks base 0.5f32 |
| 468 | put hLinks add base 1 0.5f32 |
| 469 | put hLinks add base 2 0.5f32 |
| 470 | put hLinks add base 3 0.5f32 |
| 471 | end |
| 472 | ret |
| 473 | end |
| 474 | if eq cid 6 |
| 475 | if eq and add c0 c1 1 1 |
| 476 | put hLinks base neg 0.5f32 |
| 477 | put hLinks add base 1 0.5f32 |
| 478 | put hLinks add base 2 neg 0.5f32 |
| 479 | put hLinks add base 3 0.5f32 |
| 480 | else |
| 481 | put hLinks base 0.0f32 |
| 482 | put hLinks add base 1 neg 0.70710678f32 |
| 483 | put hLinks add base 2 0.70710678f32 |
| 484 | put hLinks add base 3 0.0f32 |
| 485 | end |
| 486 | end |
| 487 | end |
| 488 | |
| 489 | fn initLattice L ulong cid ulong freezeCollar bool seed ulong to bool |
| 490 | N = mul mul L L mul L L |
| 491 | uRngSeed seed |
| 492 | for s ulong N bound 65536 |
| 493 | isB = and freezeCollar isBdryL s L |
| 494 | for mu ulong 4 |
| 495 | if isB |
| 496 | setCollarLink s mu L cid |
| 497 | else |
| 498 | base = mul add mul s 4 mu 4 |
| 499 | put hLinks base 0.85f32 |
| 500 | put hLinks add base 1 mul 0.25f32 f32 uRngNorm64 |
| 501 | put hLinks add base 2 mul 0.25f32 f32 uRngNorm64 |
| 502 | put hLinks add base 3 mul 0.25f32 f32 uRngNorm64 |
| 503 | qNormHost base |
| 504 | end |
| 505 | end |
| 506 | end |
| 507 | ret uploadLinks N |
| 508 | end |
| 509 | |
| 510 | fn gpuRunStaple N ulong mu ulong par ulong to bool |
| 511 | gx = uint div add N 255 256 |
| 512 | nu0 = ulong 0 |
| 513 | nu1 = ulong 1 |
| 514 | nu2 = ulong 2 |
| 515 | if eq mu 0 |
| 516 | nu0 = ulong 1 |
| 517 | nu1 = ulong 2 |
| 518 | nu2 = ulong 3 |
| 519 | end |
| 520 | if eq mu 1 |
| 521 | nu0 = ulong 0 |
| 522 | nu1 = ulong 2 |
| 523 | nu2 = ulong 3 |
| 524 | end |
| 525 | if eq mu 2 |
| 526 | nu0 = ulong 0 |
| 527 | nu1 = ulong 1 |
| 528 | nu2 = ulong 3 |
| 529 | end |
| 530 | uPtr mapaddr get dLinks 0 |
| 531 | uPtr mapaddr get dStaples 0 |
| 532 | uPtr mapaddr get dFlags 0 |
| 533 | uPtr mapaddr get dNbSite 0 |
| 534 | uArg uint N |
| 535 | uArg uint mu |
| 536 | uArg uint par |
| 537 | uArg uint nu0 |
| 538 | uArg uint nu1 |
| 539 | uArg uint nu2 |
| 540 | ret uRunKernel 0 gx 256 |
| 541 | end |
| 542 | |
| 543 | fn gpuRunOverrelax N ulong mu ulong par ulong to bool |
| 544 | gx = uint div add N 255 256 |
| 545 | uPtr mapaddr get dLinks 0 |
| 546 | uPtr mapaddr get dStaples 0 |
| 547 | uPtr mapaddr get dFlags 0 |
| 548 | uArg uint N |
| 549 | uArg uint mu |
| 550 | uArg uint par |
| 551 | ret uRunKernel 1 gx 256 |
| 552 | end |
| 553 | |
| 554 | fn gpuRunHeatbath N ulong mu ulong par ulong beta f32 to bool |
| 555 | gx = uint div add N 255 256 |
| 556 | uPtr mapaddr get dLinks 0 |
| 557 | uPtr mapaddr get dStaples 0 |
| 558 | uPtr mapaddr get dFlags 0 |
| 559 | uPtr mapaddr get dRng 0 |
| 560 | uArg uint N |
| 561 | uArg uint mu |
| 562 | uArg uint par |
| 563 | uArg bitcast uint beta |
| 564 | ret uRunKernel 2 gx 256 |
| 565 | end |
| 566 | |
| 567 | fn gpuSweep N ulong beta f32 nOr ulong to bool |
| 568 | for mu ulong 4 |
| 569 | for par ulong 2 |
| 570 | if not gpuRunStaple N mu par |
| 571 | ret false |
| 572 | end |
| 573 | if not gpuRunHeatbath N mu par beta |
| 574 | ret false |
| 575 | end |
| 576 | for r ulong nOr bound 8 |
| 577 | if not gpuRunStaple N mu par |
| 578 | ret false |
| 579 | end |
| 580 | if not gpuRunOverrelax N mu par |
| 581 | ret false |
| 582 | end |
| 583 | end |
| 584 | end |
| 585 | end |
| 586 | ret true |
| 587 | end |
| 588 | |
| 589 | note ========================================================================= |
| 590 | note Host Quaternion Helpers + Halo 2-Step APE Smearing + 8-Observable Measure |
| 591 | note slot: 0=hLinks(S0), 1=hSm1(S1), 2=hSm2(S2) |
| 592 | note ========================================================================= |
| 593 | fn hQMul a view f32 4 b view f32 4 o edit f32 4 to void |
| 594 | v = mul get a 0 get b 0 |
| 595 | v = sub v mul get a 1 get b 1 |
| 596 | v = sub v mul get a 2 get b 2 |
| 597 | v = sub v mul get a 3 get b 3 |
| 598 | put o 0 v |
| 599 | v = mul get a 0 get b 1 |
| 600 | v = add v mul get a 1 get b 0 |
| 601 | v = add v mul get a 2 get b 3 |
| 602 | v = sub v mul get a 3 get b 2 |
| 603 | put o 1 v |
| 604 | v = mul get a 0 get b 2 |
| 605 | v = sub v mul get a 1 get b 3 |
| 606 | v = add v mul get a 2 get b 0 |
| 607 | v = add v mul get a 3 get b 1 |
| 608 | put o 2 v |
| 609 | v = mul get a 0 get b 3 |
| 610 | v = add v mul get a 1 get b 2 |
| 611 | v = sub v mul get a 2 get b 1 |
| 612 | v = add v mul get a 3 get b 0 |
| 613 | put o 3 v |
| 614 | end |
| 615 | |
| 616 | fn hQConj q edit f32 4 to void |
| 617 | put q 1 neg get q 1 |
| 618 | put q 2 neg get q 2 |
| 619 | put q 3 neg get q 3 |
| 620 | end |
| 621 | |
| 622 | fn hQNorm q edit f32 4 to void |
| 623 | n2 = mul get q 0 get q 0 |
| 624 | n2 = add n2 mul get q 1 get q 1 |
| 625 | n2 = add n2 mul get q 2 get q 2 |
| 626 | n2 = add n2 mul get q 3 get q 3 |
| 627 | if le n2 0.0000000001f32 |
| 628 | put q 0 1.0f32 |
| 629 | put q 1 0.0f32 |
| 630 | put q 2 0.0f32 |
| 631 | put q 3 0.0f32 |
| 632 | ret |
| 633 | end |
| 634 | inv = f32 div 1.0f64 uSqrt64 f64 n2 |
| 635 | for c ulong 4 |
| 636 | put q c mul get q c inv |
| 637 | end |
| 638 | end |
| 639 | |
| 640 | fn hLoadS slot ulong s ulong mu ulong dst edit f32 4 to void |
| 641 | b = mul add mul s 4 mu 4 |
| 642 | if eq slot 0 |
| 643 | put dst 0 get hLinks b |
| 644 | put dst 1 get hLinks add b 1 |
| 645 | put dst 2 get hLinks add b 2 |
| 646 | put dst 3 get hLinks add b 3 |
| 647 | ret |
| 648 | end |
| 649 | if eq slot 1 |
| 650 | put dst 0 get hSm1 b |
| 651 | put dst 1 get hSm1 add b 1 |
| 652 | put dst 2 get hSm1 add b 2 |
| 653 | put dst 3 get hSm1 add b 3 |
| 654 | ret |
| 655 | end |
| 656 | put dst 0 get hSm2 b |
| 657 | put dst 1 get hSm2 add b 1 |
| 658 | put dst 2 get hSm2 add b 2 |
| 659 | put dst 3 get hSm2 add b 3 |
| 660 | end |
| 661 | |
| 662 | fn hStoreS slot ulong s ulong mu ulong src view f32 4 to void |
| 663 | b = mul add mul s 4 mu 4 |
| 664 | if eq slot 1 |
| 665 | put hSm1 b get src 0 |
| 666 | put hSm1 add b 1 get src 1 |
| 667 | put hSm1 add b 2 get src 2 |
| 668 | put hSm1 add b 3 get src 3 |
| 669 | ret |
| 670 | end |
| 671 | put hSm2 b get src 0 |
| 672 | put hSm2 add b 1 get src 1 |
| 673 | put hSm2 add b 2 get src 2 |
| 674 | put hSm2 add b 3 get src 3 |
| 675 | end |
| 676 | |
| 677 | fn getNb s ulong dir ulong isMinus ulong to ulong |
| 678 | ret ulong get hNb add mul s 8 add mul dir 2 isMinus |
| 679 | end |
| 680 | |
| 681 | fn hStapleAdd slot ulong s ulong mu ulong nu ulong isBack bool dst edit f32 4 to void |
| 682 | t1 = new f32 4 0.0f32 |
| 683 | t2 = new f32 4 0.0f32 |
| 684 | t3 = new f32 4 0.0f32 |
| 685 | p1 = new f32 4 0.0f32 |
| 686 | p2 = new f32 4 0.0f32 |
| 687 | xp = getNb s mu 0 |
| 688 | if not isBack |
| 689 | hLoadS slot s nu t1 |
| 690 | hLoadS slot getNb s nu 0 mu t2 |
| 691 | hLoadS slot xp nu t3 |
| 692 | hQConj t3 |
| 693 | else |
| 694 | xm = getNb s nu 1 |
| 695 | hLoadS slot xm nu t1 |
| 696 | hQConj t1 |
| 697 | hLoadS slot xm mu t2 |
| 698 | hLoadS slot getNb xp nu 1 nu t3 |
| 699 | end |
| 700 | hQMul t1 t2 p1 |
| 701 | hQMul p1 t3 p2 |
| 702 | for c ulong 4 |
| 703 | put dst c add get dst c get p2 c |
| 704 | end |
| 705 | end |
| 706 | |
| 707 | fn hApeLink srcSlot ulong dstSlot ulong s ulong mu ulong to void |
| 708 | st = new f32 4 0.0f32 |
| 709 | u = new f32 4 0.0f32 |
| 710 | w1 = div 0.5f32 6.0f32 |
| 711 | for nu ulong 4 |
| 712 | if ne nu mu |
| 713 | hStapleAdd srcSlot s mu nu false st |
| 714 | hStapleAdd srcSlot s mu nu true st |
| 715 | end |
| 716 | end |
| 717 | hLoadS srcSlot s mu u |
| 718 | for c ulong 4 |
| 719 | put u c add mul 0.5f32 get u c mul w1 get st c |
| 720 | end |
| 721 | hQNorm u |
| 722 | hStoreS dstSlot s mu u |
| 723 | end |
| 724 | |
| 725 | fn hApeHalo L ulong srcSlot ulong dstSlot ulong pad ulong to void |
| 726 | N = mul mul L L mul L L |
| 727 | for s ulong N bound 65536 |
| 728 | if isHalo s L pad |
| 729 | for mu ulong 4 |
| 730 | hApeLink srcSlot dstSlot s mu |
| 731 | end |
| 732 | end |
| 733 | end |
| 734 | end |
| 735 | |
| 736 | fn hPlaqS slot ulong s ulong mu ulong nu ulong to f64 |
| 737 | a = new f32 4 0.0f32 |
| 738 | b = new f32 4 0.0f32 |
| 739 | p = new f32 4 0.0f32 |
| 740 | q = new f32 4 0.0f32 |
| 741 | hLoadS slot s mu a |
| 742 | hLoadS slot getNb s mu 0 nu b |
| 743 | hQMul a b p |
| 744 | hLoadS slot getNb s nu 0 mu a |
| 745 | hQConj a |
| 746 | hQMul p a q |
| 747 | hLoadS slot s nu b |
| 748 | hQConj b |
| 749 | hQMul q b p |
| 750 | ret f64 get p 0 |
| 751 | end |
| 752 | |
| 753 | fn hRect1x2S slot ulong s ulong mu ulong nu ulong to f64 |
| 754 | a = new f32 4 0.0f32 |
| 755 | b = new f32 4 0.0f32 |
| 756 | p = new f32 4 0.0f32 |
| 757 | q = new f32 4 0.0f32 |
| 758 | s1 = getNb s mu 0 |
| 759 | s2 = getNb s1 mu 0 |
| 760 | hLoadS slot s mu a |
| 761 | hLoadS slot s1 mu b |
| 762 | hQMul a b p |
| 763 | hLoadS slot s2 nu a |
| 764 | hQMul p a q |
| 765 | hLoadS slot getNb s1 nu 0 mu a |
| 766 | hQConj a |
| 767 | hQMul q a p |
| 768 | hLoadS slot getNb s nu 0 mu a |
| 769 | hQConj a |
| 770 | hQMul p a q |
| 771 | hLoadS slot s nu b |
| 772 | hQConj b |
| 773 | hQMul q b p |
| 774 | ret f64 get p 0 |
| 775 | end |
| 776 | |
| 777 | fn hRect2x2S slot ulong s ulong mu ulong nu ulong to f64 |
| 778 | a = new f32 4 0.0f32 |
| 779 | p = new f32 4 0.0f32 |
| 780 | q = new f32 4 0.0f32 |
| 781 | cur = s |
| 782 | hLoadS slot cur mu p |
| 783 | cur = getNb cur mu 0 |
| 784 | hLoadS slot cur mu a |
| 785 | hQMul p a q |
| 786 | cur = getNb cur mu 0 |
| 787 | hLoadS slot cur nu a |
| 788 | hQMul q a p |
| 789 | cur = getNb cur nu 0 |
| 790 | hLoadS slot cur nu a |
| 791 | hQMul p a q |
| 792 | cur = getNb cur nu 0 |
| 793 | cur = getNb cur mu 1 |
| 794 | hLoadS slot cur mu a |
| 795 | hQConj a |
| 796 | hQMul q a p |
| 797 | cur = getNb cur mu 1 |
| 798 | hLoadS slot cur mu a |
| 799 | hQConj a |
| 800 | hQMul p a q |
| 801 | cur = getNb cur nu 1 |
| 802 | hLoadS slot cur nu a |
| 803 | hQConj a |
| 804 | hQMul q a p |
| 805 | cur = getNb cur nu 1 |
| 806 | hLoadS slot cur nu a |
| 807 | hQConj a |
| 808 | hQMul p a q |
| 809 | ret f64 get q 0 |
| 810 | end |
| 811 | |
| 812 | fn storeMeas8 k ulong to void |
| 813 | fc = f64 get mcCnt 0 |
| 814 | b = mul k 8 |
| 815 | for o ulong 6 |
| 816 | put tsData add b o div get mcAcc o fc |
| 817 | end |
| 818 | adj0 = get tsData add b 2 |
| 819 | p2 = get tsData add b 3 |
| 820 | chiAdj = sub mul 4.0f64 mul adj0 adj0 1.0f64 |
| 821 | w2ch = f64 0.0f64 |
| 822 | if and gt uAbs64 p2 0.05f64 gt uAbs64 chiAdj 0.05f64 |
| 823 | w2ch = div div adj0 p2 chiAdj |
| 824 | end |
| 825 | put tsData add b 6 w2ch |
| 826 | w12 = get tsData add b 4 |
| 827 | den = mul w12 w12 |
| 828 | cr22 = f64 0.0f64 |
| 829 | if gt uAbs64 den 0.05f64 |
| 830 | cr22 = div mul p2 get tsData add b 5 den |
| 831 | end |
| 832 | put tsData add b 7 cr22 |
| 833 | end |
| 834 | |
| 835 | fn measureCore8 L ulong k ulong to void |
| 836 | N = mul mul L L mul L L |
| 837 | downloadLinks N |
| 838 | hApeHalo L 0 1 3 |
| 839 | hApeHalo L 1 2 2 |
| 840 | for o ulong 8 |
| 841 | put mcAcc o 0.0f64 |
| 842 | end |
| 843 | put mcCnt 0 0 |
| 844 | for s ulong N bound 65536 |
| 845 | if isCore2 s L |
| 846 | for mu ulong 4 |
| 847 | for nu ulong 4 |
| 848 | if lt mu nu |
| 849 | vp0 = hPlaqS 0 s mu nu |
| 850 | put mcAcc 0 add get mcAcc 0 vp0 |
| 851 | put mcAcc 1 add get mcAcc 1 hRect2x2S 0 s mu nu |
| 852 | put mcAcc 2 add get mcAcc 2 sub mul 4.0f64 mul vp0 vp0 1.0f64 |
| 853 | put mcAcc 3 add get mcAcc 3 hPlaqS 2 s mu nu |
| 854 | put mcAcc 4 add get mcAcc 4 hRect1x2S 2 s mu nu |
| 855 | put mcAcc 5 add get mcAcc 5 hRect2x2S 2 s mu nu |
| 856 | put mcCnt 0 add get mcCnt 0 1 |
| 857 | end |
| 858 | end |
| 859 | end |
| 860 | end |
| 861 | end |
| 862 | storeMeas8 k |
| 863 | end |
| 864 | |
| 865 | fn sumBlk8 o ulong st ulong blkSz ulong to f64 |
| 866 | s = f64 0.0f64 |
| 867 | for j ulong blkSz bound 32 |
| 868 | s = add s get tsData add mul add st j 8 o |
| 869 | end |
| 870 | ret s |
| 871 | end |
| 872 | |
| 873 | fn summarizeOne8 o ulong nMeas ulong to void |
| 874 | blkSz = div nMeas 8 |
| 875 | tot = f64 0.0f64 |
| 876 | for k ulong nMeas bound 160 |
| 877 | tot = add tot get tsData add mul k 8 o |
| 878 | end |
| 879 | mean = div tot f64 nMeas |
| 880 | put curMean o mean |
| 881 | jkSum = f64 0.0f64 |
| 882 | for b ulong 8 |
| 883 | bs = sumBlk8 o mul b blkSz blkSz |
| 884 | d = sub div sub tot bs f64 sub nMeas blkSz mean |
| 885 | jkSum = add jkSum mul d d |
| 886 | end |
| 887 | put curErr o uSqrt64 mul 0.875f64 jkSum |
| 888 | end |
| 889 | |
| 890 | fn summarizeTs8 nMeas ulong to void |
| 891 | for o ulong 8 |
| 892 | summarizeOne8 o nMeas |
| 893 | end |
| 894 | end |
| 895 | |
| 896 | fn computeDiffZ cid ulong to void |
| 897 | if eq cid 0 |
| 898 | for o ulong 8 |
| 899 | put baseMean o get curMean o |
| 900 | put baseErr o get curErr o |
| 901 | put curDelta o 0.0f64 |
| 902 | put curZ o 0.0f64 |
| 903 | end |
| 904 | ret |
| 905 | end |
| 906 | for o ulong 8 |
| 907 | diff = uAbs64 sub get curMean o get baseMean o |
| 908 | se = uSqrt64 add mul get curErr o get curErr o mul get baseErr o get baseErr o |
| 909 | z = f64 0.0f64 |
| 910 | if gt se 0.000001f64 |
| 911 | z = div diff se |
| 912 | end |
| 913 | put curDelta o diff |
| 914 | put curZ o z |
| 915 | end |
| 916 | end |
| 917 | |
| 918 | fn printRow4 expId ulong L ulong cid ulong nMeas ulong us ulong to void |
| 919 | if eq expId 0 |
| 920 | uPrint tE4A |
| 921 | else |
| 922 | uPrint tE4B |
| 923 | end |
| 924 | uPrint tTab |
| 925 | uPrintU L |
| 926 | uPrint tTab |
| 927 | uPrintF64 f64 get armBeta 0 |
| 928 | uPrint tTab |
| 929 | if eq cid 0 |
| 930 | uPrint tK0 |
| 931 | end |
| 932 | if eq cid 3 |
| 933 | uPrint tK3 |
| 934 | end |
| 935 | if eq cid 5 |
| 936 | uPrint tK5 |
| 937 | end |
| 938 | if eq cid 6 |
| 939 | uPrint tK6 |
| 940 | end |
| 941 | uPrint tTab |
| 942 | uPrintU nMeas |
| 943 | note Print (Delta, Z) for O0(P0), O1(W2_0), O2(Adj0), O3(P2), O5(W2_2), O6(W2Ch), O7(Cr22) |
| 944 | uPrint tTab |
| 945 | uPrintF64 get curDelta 0 |
| 946 | uPrint tTab |
| 947 | uPrintF64 get curZ 0 |
| 948 | uPrint tTab |
| 949 | uPrintF64 get curDelta 1 |
| 950 | uPrint tTab |
| 951 | uPrintF64 get curZ 1 |
| 952 | uPrint tTab |
| 953 | uPrintF64 get curDelta 2 |
| 954 | uPrint tTab |
| 955 | uPrintF64 get curZ 2 |
| 956 | uPrint tTab |
| 957 | uPrintF64 get curDelta 3 |
| 958 | uPrint tTab |
| 959 | uPrintF64 get curZ 3 |
| 960 | uPrint tTab |
| 961 | uPrintF64 get curDelta 5 |
| 962 | uPrint tTab |
| 963 | uPrintF64 get curZ 5 |
| 964 | uPrint tTab |
| 965 | uPrintF64 get curDelta 6 |
| 966 | uPrint tTab |
| 967 | uPrintF64 get curZ 6 |
| 968 | uPrint tTab |
| 969 | uPrintF64 get curDelta 7 |
| 970 | uPrint tTab |
| 971 | uPrintF64 get curZ 7 |
| 972 | uPrint tTab |
| 973 | uPrintF64 get curMean 0 |
| 974 | uPrint tTab |
| 975 | uPrintF64 get curMean 6 |
| 976 | uPrint tTab |
| 977 | uPrintF64 get curMean 7 |
| 978 | uPrint tTab |
| 979 | uPrintU us |
| 980 | uPrint tNl |
| 981 | end |
| 982 | |
| 983 | fn runArm4 expId ulong L ulong beta f32 cid ulong nTherm ulong nMeas ulong to void |
| 984 | t0 = monons |
| 985 | put armBeta 0 beta |
| 986 | seed = get armSeed 0 |
| 987 | N = mul mul L L mul L L |
| 988 | if not seedGpuRng N add seed mul cid 7919 |
| 989 | exit 31 |
| 990 | end |
| 991 | if not initLattice L cid true add seed mul cid 104729 |
| 992 | exit 32 |
| 993 | end |
| 994 | for sw ulong nTherm bound 128 |
| 995 | if not gpuSweep N beta 3 |
| 996 | exit 33 |
| 997 | end |
| 998 | end |
| 999 | for k ulong nMeas bound 160 |
| 1000 | if not gpuSweep N beta 2 |
| 1001 | exit 34 |
| 1002 | end |
| 1003 | measureCore8 L k |
| 1004 | end |
| 1005 | summarizeTs8 nMeas |
| 1006 | computeDiffZ cid |
| 1007 | us = div ulong sub monons t0 1000 |
| 1008 | printRow4 expId L cid nMeas us |
| 1009 | end |
| 1010 | |
| 1011 | fn runBox4 expId ulong L ulong beta f32 nTh ulong nMs ulong to bool |
| 1012 | if not buildNbTable L |
| 1013 | ret false |
| 1014 | end |
| 1015 | if not buildFlags L true |
| 1016 | ret false |
| 1017 | end |
| 1018 | runArm4 expId L beta 0 nTh nMs |
| 1019 | runArm4 expId L beta get armC1 0 nTh nMs |
| 1020 | runArm4 expId L beta get armC2 0 nTh nMs |
| 1021 | ret true |
| 1022 | end |
| 1023 | |
| 1024 | fn allocBuf bytes ulong cached bool to long |
| 1025 | m = nvalloc bytes cached |
| 1026 | if le m 0 |
| 1027 | uPrint tC4Err |
| 1028 | uPrintU ulong get nvstage 0 |
| 1029 | uPrint tNl |
| 1030 | exit 6 |
| 1031 | end |
| 1032 | ret m |
| 1033 | end |
| 1034 | |
| 1035 | fn main to int |
| 1036 | uPrint tC4Hdr |
| 1037 | if not gbopen 1 |
| 1038 | uPrint tC4Err |
| 1039 | uPrintU ulong get nvstage 0 |
| 1040 | uPrint tNl |
| 1041 | ret 2 |
| 1042 | end |
| 1043 | if not gbbopen |
| 1044 | ret 3 |
| 1045 | end |
| 1046 | put uCodeMap 0 0 |
| 1047 | uEmitAllKernels |
| 1048 | csize = mul div add get uCodePos 0 4095 4096 4096 |
| 1049 | cm = nvalloc csize false |
| 1050 | if le cm 0 |
| 1051 | ret 4 |
| 1052 | end |
| 1053 | put uCodeMap 0 cm |
| 1054 | put uCodeFail 0 0 |
| 1055 | uEmitAllKernels |
| 1056 | if ne get uCodeFail 0 0 |
| 1057 | ret 5 |
| 1058 | end |
| 1059 | |
| 1060 | put dLinks 0 allocBuf 4194304 true |
| 1061 | put dStaples 0 allocBuf 4194304 true |
| 1062 | put dFlags 0 allocBuf 1048576 true |
| 1063 | put dNbSite 0 allocBuf 2097152 true |
| 1064 | put dRng 0 allocBuf 262144 true |
| 1065 | |
| 1066 | uPrint tC4Cols |
| 1067 | |
| 1068 | note Experiment 4A: Fixed beta=2.30 exponential distance decay L in {6, 8, 10, 12, 16} |
| 1069 | put armSeed 0 0x4a4a0001 |
| 1070 | put armC1 0 3 |
| 1071 | put armC2 0 5 |
| 1072 | if not runBox4 0 6 2.30f32 48 96 |
| 1073 | rc = nvmclose |
| 1074 | ret 10 |
| 1075 | end |
| 1076 | if not runBox4 0 8 2.30f32 48 96 |
| 1077 | rc = nvmclose |
| 1078 | ret 11 |
| 1079 | end |
| 1080 | if not runBox4 0 10 2.30f32 48 96 |
| 1081 | rc = nvmclose |
| 1082 | ret 12 |
| 1083 | end |
| 1084 | if not runBox4 0 12 2.30f32 48 96 |
| 1085 | rc = nvmclose |
| 1086 | ret 13 |
| 1087 | end |
| 1088 | if not runBox4 0 16 2.30f32 48 96 |
| 1089 | rc = nvmclose |
| 1090 | ret 14 |
| 1091 | end |
| 1092 | |
| 1093 | note Experiment 4B: Exact 2-loop SU(2) Fixed Physical Box L*a(beta) = 4.731e-2 Continuum Ladder! |
| 1094 | note (L=8, beta=2.300000) -> (L=12, beta=2.461245) -> (L=16, beta=2.575210) |
| 1095 | put armSeed 0 0x4b4b0001 |
| 1096 | put armC1 0 3 |
| 1097 | put armC2 0 6 |
| 1098 | if not runBox4 1 8 2.300000f32 64 96 |
| 1099 | rc = nvmclose |
| 1100 | ret 15 |
| 1101 | end |
| 1102 | if not runBox4 1 12 2.461245f32 64 96 |
| 1103 | rc = nvmclose |
| 1104 | ret 16 |
| 1105 | end |
| 1106 | if not runBox4 1 16 2.575210f32 64 96 |
| 1107 | rc = nvmclose |
| 1108 | ret 17 |
| 1109 | end |
| 1110 | |
| 1111 | uPrint tC4Done |
| 1112 | rc = nvmclose |
| 1113 | ret 0 |
| 1114 | end |