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/yang/blob/main/src/ufbi_check1_gb10.om # yang This project has not described itself yet. 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 `yang / src / ufbi_check1_gb10.om` 904 lines ยท 17674 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note src/ufbi_check1_gb10.om: Pure Seeded-OM-2 Zero-CUDA GB10 Runner for UFBI Check #1 3 note (4D Massive Free Scalar UV-Divergence Test: Exact 4D DST-I Oracle + Native SM121 CG). 4 note 5 note Composed after: 6 note gpu/nvidia/native/nvrm/context.om 7 note gpu/nvidia/native/blackwell/vector.om 8 note gpu/nvidia/native/blackwell/launch.om 9 note gpu/nvidia/native/blackwell/batch.om 10 note om/encoder/bw_enc_sm121.om 11 note src/ufbi_math.om 12 note src/ufbi_check1_kernels.om 13 14 global uCodePos ulong 1 15 global uEntry ulong 8 16 global uSmem ulong 8 17 global uCodeMap long 1 18 global uCodeFail uint 1 19 global uBind uint 32 20 global uBindN ulong 1 21 global uDirty uint 1 22 23 note Device unified-memory buffers (allocated for max N = 64^4 = 16,777,216 floats = 64 MiB each) 24 global dX long 1 25 global dB long 1 26 global dR long 1 27 global dP long 1 28 global dAp long 1 29 global dMaskFull long 1 30 global dMaskInt long 1 31 global dMaskOut long 1 32 global dEta long 1 33 global dH long 1 34 global dObs long 1 35 global dPart long 1 36 global uStaging uchar 65536 37 38 note Exact 4D DST-I CPU Oracle buffers for L=8 (interior M = 6, M^4 = 1296 sites) 39 global dstSin f64 64 40 global dstEig f64 16 41 global dstB f64 1296 42 global dstT f64 1296 43 global dstH f64 1296 44 45 text tHdr "=== UFBI CHECK #1: 4D MASSIVE FREE SCALAR UV-DIVERGENCE (PURE OM-2 ZERO-CUDA GB10) ===\n" 46 text tOpenErr "FAIL: GB10 native NVRM open/alloc error stage=" 47 text tSubErr "FAIL: GB10 kernel submit error stage=" 48 text tOracleOk "ORACLE_4D_DST1_L8: PASS max_abs_err=" 49 text tOracleBad "ORACLE_4D_DST1_L8: FAIL max_abs_err=" 50 text tCols "L\tml\tcollar\tcg_h_it\tcg_w_it\tDelta_raw\tTV_raw\tBlockAvg_d\tBlockAvg_TV\tGauss_d\tGauss_TV\tDipole_d\tDipole_TV\tQuad_d\tQuad_TV\tSite_d\tSite_TV\tus_total\n" 51 text tTab "\t" 52 text tNl "\n" 53 text tC0 "const" 54 text tC1 "sin1" 55 text tC2 "uv_chk" 56 text tC3 "rand_N01" 57 text tDone "CHECK1_GB10_DONE status=PASS\n" 58 59 fn uCodeWrite w view ulong 4 to void 60 p = get uCodePos 0 61 b = new uchar 16 0 62 if gt get uCodeMap 0 0 63 for i ulong 16 64 put b i uchar and shr get w div i 4 mul rem i 4 8 255 65 end 66 if ne mapwrite get uCodeMap 0 p b 0 16 16 67 put uCodeFail 0 1 68 end 69 end 70 put uCodePos 0 add p 16 71 end 72 73 fn uEmitAllKernels to void 74 put uCodePos 0 0 75 for id ulong 4 76 p = mul div add get uCodePos 0 255 256 256 77 put uEntry id p 78 put uCodePos 0 p 79 put uPc 0 0 80 put uGuard 0 0 81 ok = false 82 if eq id 0 83 ok = uEmitHelm4d 84 end 85 if eq id 1 86 ok = uEmitDotCta 87 end 88 if eq id 2 89 ok = uEmitAxpy 90 end 91 if eq id 3 92 ok = uEmitMaskCopy 93 end 94 if not ok 95 exit 4 96 end 97 uDone 98 end 99 put uSmem 0 0 100 put uSmem 1 256 101 put uSmem 2 0 102 put uSmem 3 0 103 end 104 105 fn uArg u uint to void 106 i = get uBindN 0 107 put uBind i u 108 put uBindN 0 add i 1 109 end 110 111 fn uPtr va ulong to void 112 uArg gblo va 113 uArg gbhi va 114 end 115 116 fn uRecord id ulong gx uint bx uint to bool 117 gbqmd 1 118 a = add mapaddr get uCodeMap 0 get uEntry id 119 put gbq1 32 gblo shr a 4 120 put gbq1 33 or uint and shr a 36 `2097151` `20971520` 121 put gbq1 59 gblo shr a 8 122 put gbq1 34 or uint 65536 bx 123 put gbq1 35 or uint 131073 shl uint 64 8 124 sm = get uSmem id 125 s7 = ulong 8 126 if ne sm 0 127 s7 = div add sm 127 128 128 end 129 put gbq1 36 uint or `78923776` s7 130 put gbq1 37 0 131 put gbq1 39 gx 132 put gbq1 40 1 133 put gbq1 41 1 134 put gbcb 216 bx 135 put gbcb 220 gx 136 put gbcb 221 1 137 put gbcb 222 1 138 cb = mapaddr get gbmem 1 139 words = get uBindN 0 140 endva = add cb add 896 mul words 4 141 put gbcb 212 gbhi endva 142 put gbcb 213 gblo endva 143 put gbused 0 0 144 gbsetup 145 if ne get uDirty 0 0 146 gbmth 0 40 4 147 gbemit 0 148 gbemit 0 149 gbemit 0 150 gbemit `2281701376` 151 put uDirty 0 0 152 end 153 gbdma cb 224 154 for j ulong 224 155 gbemit get gbcb j 156 end 157 gbdma add cb 896 uint words 158 for j ulong words bound 32 159 gbemit get uBind j 160 end 161 q = mapaddr get gbmem 2 162 gbinline q false 163 gbdma add q 8192 1 164 gbemit 1 165 gbinline add q 4096 true 166 gbrel add mapaddr get gbmem 3 32 6 167 put uBindN 0 0 168 ret gbappend id get gbst 1 169 end 170 171 fn uRunKernel id ulong gx uint bx uint to bool 172 put uDirty 0 1 173 if not gbbegin 1 174 ret false 175 end 176 if not uRecord id gx bx 177 ret false 178 end 179 ret gbbsubmit `2000000000` 180 end 181 182 note Fast zero-fill of a GPU buffer via 64 KiB chunks 183 fn uZeroBuf m long nFloats ulong to bool 184 bytes = mul nFloats 4 185 for i ulong 65536 186 put uStaging i 0 187 end 188 off = ulong 0 189 while lt off bytes bound 4096 190 n = sub bytes off 191 if gt n 65536 192 n = ulong 65536 193 end 194 if ne mapwrite m off uStaging 0 n long n 195 ret false 196 end 197 off = add off n 198 end 199 ret true 200 end 201 202 note Write f32 value to staging buffer at float slot k (0..16383) 203 fn uStagePut k ulong v f32 to void 204 bits = bitcast uint v 205 base = mul k 4 206 put uStaging base uchar and bits 255 207 put uStaging add base 1 uchar and shr bits 8 255 208 put uStaging add base 2 uchar and shr bits 16 255 209 put uStaging add base 3 uchar and shr bits 24 255 210 end 211 212 fn uStageFlush m long offBytes ulong nFloats ulong to bool 213 nb = mul nFloats 4 214 ret eq mapwrite m offBytes uStaging 0 nb long nb 215 end 216 217 note GPU primitives wrapped cleanly 218 fn gpuHelm4d xM long yM long mM long L ulong diag f32 to bool 219 L2 = mul L L 220 L3 = mul L2 L 221 N = mul L3 L 222 gx = uint div add N 255 256 223 uPtr mapaddr xM 224 uPtr mapaddr yM 225 uPtr mapaddr mM 226 uArg uint N 227 uArg uint L 228 uArg uint L2 229 uArg uint L3 230 uArg uint sub `4294967296` L 231 uArg uint sub `4294967296` L2 232 uArg uint sub `4294967296` L3 233 uArg bitcast uint diag 234 ret uRunKernel 0 gx 256 235 end 236 237 fn gpuAxpy xM long yM long N ulong a f32 b f32 to bool 238 gx = uint div add N 255 256 239 uPtr mapaddr xM 240 uPtr mapaddr yM 241 uArg uint N 242 uArg bitcast uint a 243 uArg bitcast uint b 244 ret uRunKernel 2 gx 256 245 end 246 247 fn gpuMaskCopy xM long yM long mM long N ulong to bool 248 gx = uint div add N 255 256 249 uPtr mapaddr xM 250 uPtr mapaddr yM 251 uPtr mapaddr mM 252 uArg uint N 253 ret uRunKernel 3 gx 256 254 end 255 256 note Exact f64 reduction on Grace CPU over CTA partial sums from GB10 257 fn gpuDot64 uM long vM long N ulong to f64 258 gx = div add N 255 256 259 uPtr mapaddr uM 260 uPtr mapaddr vM 261 uPtr mapaddr get dPart 0 262 uArg uint N 263 if not uRunKernel 1 uint gx 256 264 exit 21 265 end 266 acc = f64 0.0f64 267 pm = get dPart 0 268 for i ulong gx bound 131072 269 v = bitcast f32 uint mapget pm mul i 4 4 270 acc = add acc f64 v 271 end 272 ret acc 273 end 274 275 note Solve masked A x = b on GB10 via Conjugate Gradient with f64 dot products 276 global cgCfg ulong 4 277 global cgTol f64 2 278 279 fn cgStep xM long mM long L ulong diag f32 to bool 280 N = get cgCfg 0 281 if not gpuHelm4d get dP 0 get dAp 0 mM L diag 282 exit 25 283 end 284 pAp = gpuDot64 get dP 0 get dAp 0 N 285 if le pAp bitcast f64 ulong 0x39b0692313b315d2 286 ret false 287 end 288 rr = get cgTol 0 289 alpha = div rr pAp 290 if not gpuAxpy get dP 0 xM N f32 alpha 1.0f32 291 exit 26 292 end 293 if not gpuAxpy get dAp 0 get dR 0 N f32 neg alpha 1.0f32 294 exit 27 295 end 296 rrNew = gpuDot64 get dR 0 get dR 0 N 297 put cgTol 0 rrNew 298 if le rrNew get cgTol 1 299 ret false 300 end 301 beta = div rrNew rr 302 if not gpuAxpy get dR 0 get dP 0 N 1.0f32 f32 beta 303 exit 28 304 end 305 ret true 306 end 307 308 fn gpuSolveCG bM long xM long mM long L ulong diag f32 maxIt ulong to ulong 309 N = mul mul L L mul L L 310 put cgCfg 0 N 311 if not uZeroBuf xM N 312 exit 22 313 end 314 if not gpuAxpy bM get dR 0 N 1.0f32 0.0f32 315 exit 23 316 end 317 if not gpuAxpy bM get dP 0 N 1.0f32 0.0f32 318 exit 24 319 end 320 rr = gpuDot64 get dR 0 get dR 0 N 321 if le rr bitcast f64 ulong 0x3af3017d8a34c436 322 ret 0 323 end 324 put cgTol 0 rr 325 put cgTol 1 mul rr bitcast f64 ulong 0x3d719799812dea11 326 it = ulong 0 327 while lt it maxIt bound 4096 328 it = add it 1 329 if not cgStep xM mM L diag 330 break 331 end 332 end 333 ret it 334 end 335 336 note ========================================================================= 337 note Populate 4D region masks on GPU in 64 KiB streaming chunks 338 note ========================================================================= 339 fn coordIsFull idx ulong L ulong to bool 340 x3 = rem idx L 341 t = div idx L 342 x2 = rem t L 343 t = div t L 344 x1 = rem t L 345 x0 = div t L 346 lm1 = sub L 1 347 if or eq x0 0 eq x0 lm1 348 ret false 349 end 350 if or eq x1 0 eq x1 lm1 351 ret false 352 end 353 if or eq x2 0 eq x2 lm1 354 ret false 355 end 356 if or eq x3 0 eq x3 lm1 357 ret false 358 end 359 ret true 360 end 361 362 fn coordIsInt idx ulong L ulong to bool 363 lo = div L 4 364 hi = sub L lo 365 x3 = rem idx L 366 t = div idx L 367 x2 = rem t L 368 t = div t L 369 x1 = rem t L 370 x0 = div t L 371 if or lt x0 lo ge x0 hi 372 ret false 373 end 374 if or lt x1 lo ge x1 hi 375 ret false 376 end 377 if or lt x2 lo ge x2 hi 378 ret false 379 end 380 if or lt x3 lo ge x3 hi 381 ret false 382 end 383 ret true 384 end 385 386 fn buildMasks L ulong to bool 387 N = mul mul L L mul L L 388 for pass ulong 3 389 tgt = get dMaskFull 0 390 if eq pass 1 391 tgt = get dMaskInt 0 392 end 393 if eq pass 2 394 tgt = get dMaskOut 0 395 end 396 off = ulong 0 397 while lt off N bound 2048 398 cnt = sub N off 399 if gt cnt 16384 400 cnt = ulong 16384 401 end 402 for k ulong cnt bound 16384 403 idx = add off k 404 isF = coordIsFull idx L 405 isI = coordIsInt idx L 406 val = f32 0.0f32 407 if eq pass 0 408 if isF 409 val = f32 1.0f32 410 end 411 end 412 if eq pass 1 413 if isI 414 val = f32 1.0f32 415 end 416 end 417 if eq pass 2 418 if and isF not isI 419 val = f32 1.0f32 420 end 421 end 422 uStagePut k val 423 end 424 if not uStageFlush tgt mul off 4 cnt 425 ret false 426 end 427 off = add off cnt 428 end 429 end 430 ret true 431 end 432 433 note Populate boundary collar eta on dEta (0 on interior, collar pattern on boundary) 434 note mode: 0=const(1.0), 1=sin1, 2=uv_checkerboard, 3=rand_N01 435 fn collarVal idx ulong L ulong mode ulong to f32 436 if coordIsFull idx L 437 ret 0.0f32 438 end 439 if eq mode 0 440 ret 1.0f32 441 end 442 if eq mode 3 443 ret f32 uRngNorm64 444 end 445 x3 = rem idx L 446 t = div idx L 447 x2 = rem t L 448 t = div t L 449 x1 = rem t L 450 x0 = div t L 451 if eq mode 2 452 if eq and add add x0 x1 add x2 x3 1 0 453 ret 1.0f32 454 end 455 ret neg 1.0f32 456 end 457 pf = div uPi f64 sub L 1 458 acc = uSin64 mul pf f64 x0 459 acc = add acc uSin64 mul pf f64 x1 460 acc = add acc uSin64 mul pf f64 x2 461 acc = add acc uSin64 mul pf f64 x3 462 ret f32 acc 463 end 464 465 fn buildCollar L ulong mode ulong to bool 466 N = mul mul L L mul L L 467 uRngSeed add 0x517cc1b727220a95 mul L 131 468 off = ulong 0 469 while lt off N bound 2048 470 cnt = sub N off 471 if gt cnt 16384 472 cnt = ulong 16384 473 end 474 for k ulong cnt bound 16384 475 uStagePut k collarVal add off k L mode 476 end 477 if not uStageFlush get dEta 0 mul off 4 cnt 478 ret false 479 end 480 off = add off cnt 481 end 482 ret true 483 end 484 485 note Populate linear CentralObs probe K(x) supported inside Lambda_int onto dObs 486 note obsKind: 0=BlockAvg, 1=GaussSmear(sigma=L/8), 2=Dipole, 3=Quadrupole, 4=SingleSite 487 fn obsGauss x0 ulong x1 ulong x2 ulong x3 ulong L ulong obsKind ulong to f32 488 ctr = mul 0.5f64 f64 sub L 1 489 sig = div f64 L 8.0f64 490 d = sub f64 x0 ctr 491 r2 = mul d d 492 d = sub f64 x1 ctr 493 r2 = add r2 mul d d 494 d = sub f64 x2 ctr 495 r2 = add r2 mul d d 496 d = sub f64 x3 ctr 497 r2 = add r2 mul d d 498 g = uExp64 neg div mul 0.5f64 r2 mul sig sig 499 if eq obsKind 1 500 ret f32 g 501 end 502 if eq obsKind 2 503 ret f32 mul sub f64 x0 ctr g 504 end 505 d = sub f64 x0 ctr 506 sig = sub f64 x1 ctr 507 ret f32 mul sub mul d d mul sig sig g 508 end 509 510 fn obsVal idx ulong L ulong obsKind ulong to f32 511 if not coordIsInt idx L 512 ret 0.0f32 513 end 514 if eq obsKind 0 515 ret 1.0f32 516 end 517 x3 = rem idx L 518 t = div idx L 519 x2 = rem t L 520 t = div t L 521 x1 = rem t L 522 x0 = div t L 523 if eq obsKind 4 524 mid = div L 2 525 if and and and eq x0 mid eq x1 mid eq x2 mid eq x3 mid 526 ret 1.0f32 527 end 528 ret 0.0f32 529 end 530 ret obsGauss x0 x1 x2 x3 L obsKind 531 end 532 533 fn buildObs L ulong obsKind ulong to bool 534 N = mul mul L L mul L L 535 off = ulong 0 536 while lt off N bound 2048 537 cnt = sub N off 538 if gt cnt 16384 539 cnt = ulong 16384 540 end 541 for k ulong cnt bound 16384 542 uStagePut k obsVal add off k L obsKind 543 end 544 if not uStageFlush get dObs 0 mul off 4 cnt 545 ret false 546 end 547 off = add off cnt 548 end 549 ret true 550 end 551 552 note ========================================================================= 553 note Exact 4D DST-I Spectral Oracle on L=8 (M = L-2 = 6 interior sites/axis) 554 note ========================================================================= 555 fn idx4 a ulong b ulong c ulong d ulong M ulong to ulong 556 r = add mul a M b 557 r = add mul r M c 558 ret add mul r M d 559 end 560 561 fn dst1dOne ax ulong idx ulong to f64 562 i3 = rem idx 6 563 i2 = rem div idx 6 6 564 i1 = rem div idx 36 6 565 i0 = div idx 216 566 acc = f64 0.0f64 567 for j ulong 6 568 if eq ax 0 569 s = get dstSin add mul i0 6 j 570 k = idx4 j i1 i2 i3 6 571 acc = add acc mul s get dstB k 572 end 573 if eq ax 1 574 s = get dstSin add mul i1 6 j 575 k = idx4 i0 j i2 i3 6 576 acc = add acc mul s get dstB k 577 end 578 if eq ax 2 579 s = get dstSin add mul i2 6 j 580 k = idx4 i0 i1 j i3 6 581 acc = add acc mul s get dstB k 582 end 583 if eq ax 3 584 s = get dstSin add mul i3 6 j 585 k = idx4 i0 i1 i2 j 6 586 acc = add acc mul s get dstB k 587 end 588 end 589 ret acc 590 end 591 592 fn dst1dAxis4 to void 593 for ax ulong 4 594 for idx ulong 1296 595 put dstT idx dst1dOne ax idx 596 end 597 for idx ulong 1296 598 put dstB idx get dstT idx 599 end 600 end 601 end 602 603 fn dstBuildTables to void 604 pi = uPi 605 norm = uSqrt64 div 2.0f64 7.0f64 606 for k ulong 6 607 kf = f64 add k 1 608 sn = uSin64 div mul pi kf 14.0f64 609 put dstEig k mul 4.0f64 mul sn sn 610 for j ulong 6 611 jf = f64 add j 1 612 put dstSin add mul k 6 j mul norm uSin64 div mul pi mul kf jf 7.0f64 613 end 614 end 615 end 616 617 fn dstBuildRhs to void 618 for idx ulong 1296 619 i3 = rem idx 6 620 t = div idx 6 621 i2 = rem t 6 622 t = div t 6 623 i1 = rem t 6 624 i0 = div t 6 625 bc = f64 0.0f64 626 if eq i0 0 627 bc = add bc 1.0f64 628 end 629 if eq i0 5 630 bc = add bc 1.0f64 631 end 632 if eq i1 0 633 bc = add bc 1.0f64 634 end 635 if eq i1 5 636 bc = add bc 1.0f64 637 end 638 if eq i2 0 639 bc = add bc 1.0f64 640 end 641 if eq i2 5 642 bc = add bc 1.0f64 643 end 644 if eq i3 0 645 bc = add bc 1.0f64 646 end 647 if eq i3 5 648 bc = add bc 1.0f64 649 end 650 put dstB idx bc 651 end 652 end 653 654 fn dstDivEig ma2 f64 to void 655 for idx ulong 1296 656 lam = add ma2 get dstEig div idx 216 657 lam = add lam get dstEig rem div idx 36 6 658 lam = add lam get dstEig rem div idx 6 6 659 lam = add lam get dstEig rem idx 6 660 put dstB idx div get dstB idx lam 661 end 662 end 663 664 fn dstMaxErrL8 to f64 665 maxErr = f64 0.0f64 666 hm = get dH 0 667 for idx ulong 1296 668 a = add div idx 216 1 669 b = add rem div idx 36 6 1 670 c = add rem div idx 6 6 1 671 d = add rem idx 6 1 672 gIdx = idx4 a b c d 8 673 gpuV = f64 bitcast f32 uint mapget hm mul gIdx 4 4 674 err = uAbs64 sub gpuV get dstH idx 675 if gt err maxErr 676 maxErr = err 677 end 678 end 679 ret maxErr 680 end 681 682 fn runDst1OracleL8 ml f64 to bool 683 ma = div ml 8.0f64 684 ma2 = mul ma ma 685 diag = f32 add 8.0f64 ma2 686 dstBuildTables 687 dstBuildRhs 688 dst1dAxis4 689 dstDivEig ma2 690 dst1dAxis4 691 for k ulong 1296 692 put dstH k get dstB k 693 end 694 if not buildMasks 8 695 ret false 696 end 697 if not buildCollar 8 0 698 ret false 699 end 700 if not gpuHelm4d get dEta 0 get dB 0 get dMaskFull 0 8 diag 701 ret false 702 end 703 if not gpuAxpy get dB 0 get dB 0 4096 neg 1.0f32 0.0f32 704 ret false 705 end 706 it = gpuSolveCG get dB 0 get dH 0 get dMaskFull 0 8 diag 500 707 maxErr = dstMaxErrL8 708 if le maxErr 0.`0001f64` 709 uPrint tOracleOk 710 uPrintF64 maxErr 711 uPrint tNl 712 ret true 713 end 714 uPrint tOracleBad 715 uPrintF64 maxErr 716 uPrint tNl 717 ret false 718 end 719 720 note ========================================================================= 721 note Run one (L, m*ell, collarMode) experiment on GB10 722 note ========================================================================= 723 fn runObsProbes L ulong diag f32 to bool 724 N = mul mul L L mul L L 725 for obsKind ulong 5 726 if not buildObs L obsKind 727 ret false 728 end 729 dMu = uAbs64 gpuDot64 get dObs 0 get dH 0 N 730 itO = gpuSolveCG get dObs 0 get dX 0 get dMaskFull 0 L diag 1200 731 sig2 = gpuDot64 get dObs 0 get dX 0 N 732 dObsVal = f64 0.0f64 733 if gt sig2 bitcast f64 ulong 0x3af3017d8a34c436 734 dObsVal = div dMu uSqrt64 sig2 735 end 736 uPrint tTab 737 uPrintF64 dObsVal 738 uPrint tTab 739 uPrintF64 uGaussTv dObsVal 740 end 741 ret true 742 end 743 744 fn printCollarName collarMode ulong to void 745 if eq collarMode 0 746 uPrint tC0 747 end 748 if eq collarMode 1 749 uPrint tC1 750 end 751 if eq collarMode 2 752 uPrint tC2 753 end 754 if eq collarMode 3 755 uPrint tC3 756 end 757 end 758 759 fn runExperiment L ulong ml f64 collarMode ulong to bool 760 t0 = monons 761 N = mul mul L L mul L L 762 ma = div ml f64 L 763 diag = f32 add 8.0f64 mul ma ma 764 if not buildCollar L collarMode 765 ret false 766 end 767 if not gpuHelm4d get dEta 0 get dB 0 get dMaskFull 0 L diag 768 ret false 769 end 770 if not gpuAxpy get dB 0 get dB 0 N neg 1.0f32 0.0f32 771 ret false 772 end 773 itH = gpuSolveCG get dB 0 get dH 0 get dMaskFull 0 L diag 1200 774 if not gpuMaskCopy get dH 0 get dObs 0 get dMaskInt 0 N 775 ret false 776 end 777 if not gpuHelm4d get dObs 0 get dB 0 get dMaskOut 0 L diag 778 ret false 779 end 780 if not gpuAxpy get dB 0 get dB 0 N neg 1.0f32 0.0f32 781 ret false 782 end 783 itW = gpuSolveCG get dB 0 get dX 0 get dMaskOut 0 L diag 1200 784 if not gpuAxpy get dObs 0 get dX 0 N 1.0f32 1.0f32 785 ret false 786 end 787 if not gpuHelm4d get dX 0 get dB 0 get dMaskInt 0 L diag 788 ret false 789 end 790 dRaw = uSqrt64 gpuDot64 get dObs 0 get dB 0 N 791 uPrintU L 792 uPrint tTab 793 uPrintF64 ml 794 uPrint tTab 795 printCollarName collarMode 796 uPrint tTab 797 uPrintU itH 798 uPrint tTab 799 uPrintU itW 800 uPrint tTab 801 uPrintF64 dRaw 802 uPrint tTab 803 uPrintF64 uGaussTv dRaw 804 if not runObsProbes L diag 805 ret false 806 end 807 us = div ulong sub monons t0 1000 808 uPrint tTab 809 uPrintU us 810 uPrint tNl 811 ret true 812 end 813 814 fn allocField bytes ulong cached bool to long 815 m = nvalloc bytes cached 816 if le m 0 817 uPrint tOpenErr 818 uPrintU ulong get nvstage 0 819 uPrint tNl 820 exit 6 821 end 822 ret m 823 end 824 825 fn main to int 826 uPrint tHdr 827 if not gbopen 1 828 uPrint tOpenErr 829 uPrintU ulong get nvstage 0 830 uPrint tNl 831 ret 2 832 end 833 if not gbbopen 834 uPrint tOpenErr 835 uPrintU ulong get nvstage 0 836 uPrint tNl 837 ret 3 838 end 839 put uCodeMap 0 0 840 uEmitAllKernels 841 csize = mul div add get uCodePos 0 4095 4096 4096 842 cm = nvalloc csize false 843 if le cm 0 844 ret 4 845 end 846 put uCodeMap 0 cm 847 put uCodeFail 0 0 848 uEmitAllKernels 849 if ne get uCodeFail 0 0 850 ret 5 851 end 852 853 note Max lattice L=64 -> 16,777,216 floats = 67,108,864 bytes (64 MiB) per buffer 854 note Total 11 buffers x 64 MiB = 704 MiB (< 0.6% of GB10 128 GB unified memory!) 855 maxBytes = ulong `67108864` 856 put dX 0 allocField maxBytes true 857 put dB 0 allocField maxBytes true 858 put dR 0 allocField maxBytes true 859 put dP 0 allocField maxBytes true 860 put dAp 0 allocField maxBytes true 861 put dMaskFull 0 allocField maxBytes true 862 put dMaskInt 0 allocField maxBytes true 863 put dMaskOut 0 allocField maxBytes true 864 put dEta 0 allocField maxBytes true 865 put dH 0 allocField maxBytes true 866 put dObs 0 allocField maxBytes true 867 note Partial sums: up to 65536 CTAs x 4 B = 262,144 B (uncached for instant CPU f64 sum) 868 put dPart 0 allocField 262144 false 869 870 note 1. Self-verify GB10 CG solver against exact 4D DST-I spectral oracle on L=8 871 if not runDst1OracleL8 2.0f64 872 rc = nvmclose 873 ret 10 874 end 875 876 note 2. Run UV-divergence scaling sweep across L = 8, 16, 32, 64 877 uPrint tCols 878 ls = new ulong 4 8 879 put ls 1 16 880 put ls 2 32 881 put ls 3 64 882 for li ulong 4 883 L = get ls li 884 if not buildMasks L 885 rc = nvmclose 886 ret 11 887 end 888 for mi ulong 2 889 ml = f64 2.0f64 890 if eq mi 1 891 ml = f64 4.0f64 892 end 893 for cmode ulong 4 894 if not runExperiment L ml cmode 895 rc = nvmclose 896 ret 12 897 end 898 end 899 end 900 end 901 uPrint tDone 902 rc = nvmclose 903 ret 0 904 end