interplane.Get Omega
Read in your language

yang

This project has not described itself yet.

Brought by drakestapleton

branch main Branches Tags History

yang / src / ufbi_check9_gb10.om

1118 lines · 23386 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note src/ufbi_check9_gb10.om: Pure Seeded-OM-2 Zero-CUDA GB10 Runner for UFBI Check #9
3note (Phase II Blocked-Action Tomography + Extended 12-Point Calibration beta=0.10..10.0
4note + k=3 Deep RG Blocking 32^4 -> 16^4 -> 8^4 -> 4^4 at beta=2.00, 2.30).
5note
6note Directly answers all three Check #8 referee questions on live GB10 silicon:
7note 1. Extended 12-point periodic 8^4 bulk calibration (beta in {0.10, 0.25, 0.50, 1.00,
8note 1.50, 2.00, 2.30, 2.50, 3.00, 4.00, 6.00, 10.00}) measuring P_bulk, Adj_bulk,
9note R1x2_bulk, and W2x2_bulk — removing Check #8's beta=6.0 upper clamp AND providing
10note exact pure-Wilson multi-loop reference curves.
11note 2. Blocked-Action Tomography (16^4 -> 8^4 -> 4^4 at beta in {1.50, 2.00, 2.30, 2.50, 6.00}):
12note Measures P^(k), Adj^(k), R1x2^(k), W2x2^(k) at k=0, 1, 2 and computes exact
13note non-plaquette coupling leakage relative to a pure Wilson action at matched beta_eff(k):
14note dAdj^(k) = Adj^(k) - Adj_Wilson(beta_eff(k))
15note dR1x2^(k) = R1x2^(k) - R1x2_Wilson(beta_eff(k))
16note dW2x2^(k) = W2x2^(k) - W2x2_Wilson(beta_eff(k))
17note 3. k=3 Deep RG Blocking on 32^4 (N=1,048,576 sites on GB10 GPU -> 16^4 -> 8^4 -> 4^4)
18note at beta=2.00 and beta=2.30, testing whether beta_eff(k=3) crosses directly inside
19note the unconditionally Lean-certified 4D SU(2) Dobrushin basin (< 0.111 / < 0.0556)!
20note
21note Composed after:
22note gpu/nvidia/native/nvrm/context.om
23note gpu/nvidia/native/blackwell/vector.om
24note gpu/nvidia/native/blackwell/launch.om
25note gpu/nvidia/native/blackwell/batch.om
26note om/encoder/bw_enc_sm121.om
27note src/ufbi_math.om
28note src/ufbi_check3_kernels.om
29
30global uCodePos ulong 1
31global uEntry ulong 8
32global uCodeMap long 1
33global uCodeFail uint 1
34global uBind uint 32
35global uBindN ulong 1
36global uDirty uint 1
37
38global dLinks long 1
39global dStaples long 1
40global dFlags long 1
41global dNbSite long 1
42global dRng long 1
43
44note Host link levels (max 16^4 = 1,048,576 f32; 32^4 reads directly from GPU cached dLinks!)
45note lvl 0 = hL1 (16^4, 65536 sites), lvl 1 = hL2 (8^4, 4096 sites), lvl 2 = hL3 (4^4, 256 sites)
46note lvl 3 = direct GPU dLinks read for 32^4!
47global hL1 f32 1048576
48global hL2 f32 65536
49global hL3 f32 4096
50global hStage uchar 65536
51
52note 12-point extended bulk calibration tables (beta, P, Adj, R1x2, W2x2)
53global calBeta f64 12
54global calP f64 12
55global calAdj f64 12
56global calR12 f64 12
57global calW22 f64 12
58
59note Tomography accumulators: 4 scales x 4 obs (P, Adj, R12, W22) = 16 f64
60global tomAcc f64 16
61global tomCur f64 4
62global tomCnt ulong 1
63global rgSrcLvl ulong 1
64global rgDstLvl ulong 1
65global rgLf ulong 1
66
67text tC9Hdr "=== UFBI CHECK #9: PHASE-II BLOCKED-ACTION TOMOGRAPHY & k=3 32^4 RG FLOW (PURE OM-2 GB10) ===\n"
68text tC9Err "FAIL: GB10 native NVRM/kernel error stage="
69text tC9CalHdr "=== EXTENDED 12-POINT PERIODIC 8^4 SU(2) PURE-WILSON MULTI-LOOP CALIBRATION ===\n"
70text tC9CalCols "cal_beta\tP_bulk\tAdj_bulk\tR1x2_bulk\tW2x2_bulk\n"
71text tC9TomHdr "=== BLOCKED-ACTION TOMOGRAPHY (16^4 -> 8^4 -> 4^4, PERIODIC BULK, 64 MEAS) ===\n"
72text tC9TomCols "L_base\tbeta\tk\tP_k\tbeta_eff\tAdj_k\tdAdj_nonW\tR1x2_k\tdR1x2_nonW\tW2x2_k\tdW2x2_nonW\tus\n"
73text tC9K3Hdr "=== DEEP k=3 BLOCK-SPIN RG FLOW ON 32^4 (1,048,576 SITES: 32^4 -> 16^4 -> 8^4 -> 4^4) ===\n"
74text tTab "\t"
75text tNl "\n"
76text tC9Done "CHECK9_GB10_DONE status=PASS\n"
77
78fn uCodeWrite w view ulong 4 to void
79p = get uCodePos 0
80b = new uchar 16 0
81if gt get uCodeMap 0 0
82for i ulong 16
83put b i uchar and shr get w div i 4 mul rem i 4 8 255
84end
85if ne mapwrite get uCodeMap 0 p b 0 16 16
86put uCodeFail 0 1
87end
88end
89put uCodePos 0 add p 16
90end
91
92fn uEmitAllKernels to void
93put uCodePos 0 0
94for id ulong 3
95p = mul div add get uCodePos 0 255 256 256
96put uEntry id p
97put uCodePos 0 p
98put uPc 0 0
99put uGuard 0 0
100ok = false
101if eq id 0
102ok = uEmitSu2Staple
103end
104if eq id 1
105ok = uEmitSu2Overrelax
106end
107if eq id 2
108ok = uEmitSu2Heatbath
109end
110if not ok
111exit 4
112end
113uDone
114end
115end
116
117fn uArg u uint to void
118i = get uBindN 0
119put uBind i u
120put uBindN 0 add i 1
121end
122
123fn uPtr va ulong to void
124uArg gblo va
125uArg gbhi va
126end
127
128fn uRecord id ulong gx uint bx uint to bool
129gbqmd 1
130a = add mapaddr get uCodeMap 0 get uEntry id
131put gbq1 32 gblo shr a 4
132put gbq1 33 or uint and shr a 36 2097151 20971520
133put gbq1 59 gblo shr a 8
134put gbq1 34 or uint 65536 bx
135put gbq1 35 or uint 131073 shl uint 64 8
136put gbq1 36 78923784
137put gbq1 37 0
138put gbq1 39 gx
139put gbq1 40 1
140put gbq1 41 1
141put gbcb 216 bx
142put gbcb 220 gx
143put gbcb 221 1
144put gbcb 222 1
145cb = mapaddr get gbmem 1
146words = get uBindN 0
147endva = add cb add 896 mul words 4
148put gbcb 212 gbhi endva
149put gbcb 213 gblo endva
150put gbused 0 0
151gbsetup
152if ne get uDirty 0 0
153gbmth 0 40 4
154gbemit 0
155gbemit 0
156gbemit 0
157gbemit 2281701376
158put uDirty 0 0
159end
160gbdma cb 224
161for j ulong 224
162gbemit get gbcb j
163end
164gbdma add cb 896 uint words
165for j ulong words bound 32
166gbemit get uBind j
167end
168q = mapaddr get gbmem 2
169gbinline q false
170gbdma add q 8192 1
171gbemit 1
172gbinline add q 4096 true
173gbrel add mapaddr get gbmem 3 32 6
174put uBindN 0 0
175ret gbappend id get gbst 1
176end
177
178fn uRunKernel id ulong gx uint bx uint to bool
179put uDirty 0 1
180if not gbbegin 1
181ret false
182end
183if not uRecord id gx bx
184ret false
185end
186ret gbbsubmit 2000000000
187end
188
189fn stageU32 k ulong v uint to void
190b = mul k 4
191put hStage b uchar and v 255
192put hStage add b 1 uchar and shr v 8 255
193put hStage add b 2 uchar and shr v 16 255
194put hStage add b 3 uchar and shr v 24 255
195end
196
197fn stageF32 k ulong v f32 to void
198stageU32 k bitcast uint v
199end
200
201fn flushStage m long offBytes ulong nWords ulong to bool
202nb = mul nWords 4
203ret eq mapwrite m offBytes hStage 0 nb long nb
204end
205
206fn coordIdx c0 ulong c1 ulong c2 ulong c3 ulong L ulong to ulong
207r = add mul c0 L c1
208r = add mul r L c2
209ret add mul r L c3
210end
211
212fn stepCoord s ulong L ulong dir ulong delta ulong to ulong
213c3 = rem s L
214t = div s L
215c2 = rem t L
216t = div t L
217c1 = rem t L
218c0 = div t L
219if eq dir 0
220c0 = rem add c0 delta L
221end
222if eq dir 1
223c1 = rem add c1 delta L
224end
225if eq dir 2
226c2 = rem add c2 delta L
227end
228if eq dir 3
229c3 = rem add c3 delta L
230end
231ret coordIdx c0 c1 c2 c3 L
232end
233
234fn isBox4 s ulong L ulong lo ulong hi ulong to bool
235c3 = rem s L
236t = div s L
237c2 = rem t L
238t = div t L
239c1 = rem t L
240c0 = div t L
241if or lt c0 lo ge c0 hi
242ret false
243end
244if or lt c1 lo ge c1 hi
245ret false
246end
247if or lt c2 lo ge c2 hi
248ret false
249end
250if or lt c3 lo ge c3 hi
251ret false
252end
253ret true
254end
255
256note Streaming neighbor-table builder (supports up to L=32 -> 1,048,576 sites x 8 = 8,388,608 u32!)
257fn stageSiteNb kSite ulong s ulong L ulong to void
258c3 = rem s L
259t = div s L
260c2 = rem t L
261t = div t L
262c1 = rem t L
263c0 = div t L
264b = mul kSite 8
265stageU32 b uint coordIdx rem add c0 1 L c1 c2 c3 L
266stageU32 add b 1 uint coordIdx rem add c0 sub L 1 L c1 c2 c3 L
267stageU32 add b 2 uint coordIdx c0 rem add c1 1 L c2 c3 L
268stageU32 add b 3 uint coordIdx c0 rem add c1 sub L 1 L c2 c3 L
269stageU32 add b 4 uint coordIdx c0 c1 rem add c2 1 L c3 L
270stageU32 add b 5 uint coordIdx c0 c1 rem add c2 sub L 1 L c3 L
271stageU32 add b 6 uint coordIdx c0 c1 c2 rem add c3 1 L L
272stageU32 add b 7 uint coordIdx c0 c1 c2 rem add c3 sub L 1 L L
273end
274
275fn buildNbTableStream L ulong to bool
276N = mul mul L L mul L L
277off = ulong 0
278while lt off N bound 512
279cnt = sub N off
280if gt cnt 2048
281cnt = ulong 2048
282end
283for k ulong cnt bound 2048
284stageSiteNb k add off k L
285end
286if not flushStage get dNbSite 0 mul off 32 mul cnt 8
287ret false
288end
289off = add off cnt
290end
291ret true
292end
293
294fn siteParity s ulong L ulong to uint
295c3 = rem s L
296t = div s L
297c2 = rem t L
298t = div t L
299c1 = rem t L
300c0 = div t L
301ret uint and add add c0 c1 add c2 c3 1
302end
303
304fn buildFlagsStream L ulong to bool
305N = mul mul L L mul L L
306totalW = mul N 4
307off = ulong 0
308while lt off totalW bound 256
309cnt = sub totalW off
310if gt cnt 16384
311cnt = ulong 16384
312end
313for k ulong cnt bound 16384
314stageU32 k siteParity div add off k 4 L
315end
316if not flushStage get dFlags 0 mul off 4 cnt
317ret false
318end
319off = add off cnt
320end
321ret true
322end
323
324fn seedGpuRngStream N ulong seed ulong to bool
325uRngSeed seed
326off = ulong 0
327while lt off N bound 64
328cnt = sub N off
329if gt cnt 16384
330cnt = ulong 16384
331end
332for k ulong cnt bound 16384
333r = uint and uRngNext 0xffffffff
334if eq r 0
335r = uint 0x9e3779b9
336end
337stageU32 k r
338end
339if not flushStage get dRng 0 mul off 4 cnt
340ret false
341end
342off = add off cnt
343end
344ret true
345end
346
347note Streaming cold-perturbed SU(2) lattice initializer on GPU (supports L up to 32!)
348fn stageRandLink kLink ulong to void
349a0 = f32 0.85f32
350a1 = mul 0.25f32 f32 uRngNorm64
351a2 = mul 0.25f32 f32 uRngNorm64
352a3 = mul 0.25f32 f32 uRngNorm64
353n2 = add add mul a0 a0 mul a1 a1 add mul a2 a2 mul a3 a3
354inv = f32 div 1.0f64 uSqrt64 f64 n2
355b = mul kLink 4
356stageF32 b mul a0 inv
357stageF32 add b 1 mul a1 inv
358stageF32 add b 2 mul a2 inv
359stageF32 add b 3 mul a3 inv
360end
361
362fn initLatticeStream L ulong seed ulong to bool
363N = mul mul L L mul L L
364uRngSeed seed
365totalLinks = mul N 4
366off = ulong 0
367while lt off totalLinks bound 1024
368cnt = sub totalLinks off
369if gt cnt 4096
370cnt = ulong 4096
371end
372for k ulong cnt bound 4096
373stageRandLink k
374end
375if not flushStage get dLinks 0 mul off 16 mul cnt 4
376ret false
377end
378off = add off cnt
379end
380ret true
381end
382
383fn downloadAllToL1 N ulong to void
384totalF = mul N 16
385lm = get dLinks 0
386for i ulong totalF bound 1048576
387put hL1 i bitcast f32 uint mapget lm mul i 4 4
388end
389end
390
391fn gpuRunStaple N ulong mu ulong par ulong to bool
392gx = uint div add N 255 256
393nu0 = ulong 0
394nu1 = ulong 1
395nu2 = ulong 2
396if eq mu 0
397nu0 = ulong 1
398nu1 = ulong 2
399nu2 = ulong 3
400end
401if eq mu 1
402nu0 = ulong 0
403nu1 = ulong 2
404nu2 = ulong 3
405end
406if eq mu 2
407nu0 = ulong 0
408nu1 = ulong 1
409nu2 = ulong 3
410end
411uPtr mapaddr get dLinks 0
412uPtr mapaddr get dStaples 0
413uPtr mapaddr get dFlags 0
414uPtr mapaddr get dNbSite 0
415uArg uint N
416uArg uint mu
417uArg uint par
418uArg uint nu0
419uArg uint nu1
420uArg uint nu2
421ret uRunKernel 0 gx 256
422end
423
424fn gpuRunOverrelax N ulong mu ulong par ulong to bool
425gx = uint div add N 255 256
426uPtr mapaddr get dLinks 0
427uPtr mapaddr get dStaples 0
428uPtr mapaddr get dFlags 0
429uArg uint N
430uArg uint mu
431uArg uint par
432ret uRunKernel 1 gx 256
433end
434
435fn gpuRunHeatbath N ulong mu ulong par ulong beta f32 to bool
436gx = uint div add N 255 256
437uPtr mapaddr get dLinks 0
438uPtr mapaddr get dStaples 0
439uPtr mapaddr get dFlags 0
440uPtr mapaddr get dRng 0
441uArg uint N
442uArg uint mu
443uArg uint par
444uArg bitcast uint beta
445ret uRunKernel 2 gx 256
446end
447
448fn gpuSweep N ulong beta f32 nOr ulong to bool
449for mu ulong 4
450for par ulong 2
451if not gpuRunStaple N mu par
452ret false
453end
454if not gpuRunHeatbath N mu par beta
455ret false
456end
457for r ulong nOr bound 8
458if not gpuRunStaple N mu par
459ret false
460end
461if not gpuRunOverrelax N mu par
462ret false
463end
464end
465end
466end
467ret true
468end
469
470note =========================================================================
471note Quaternion Helpers + Multi-Level Storage (lvl 0=hL1, 1=hL2, 2=hL3, 3=dLinks)
472note =========================================================================
473fn hQMul a view f32 4 b view f32 4 o edit f32 4 to void
474v = mul get a 0 get b 0
475v = sub v mul get a 1 get b 1
476v = sub v mul get a 2 get b 2
477v = sub v mul get a 3 get b 3
478put o 0 v
479v = mul get a 0 get b 1
480v = add v mul get a 1 get b 0
481v = add v mul get a 2 get b 3
482v = sub v mul get a 3 get b 2
483put o 1 v
484v = mul get a 0 get b 2
485v = sub v mul get a 1 get b 3
486v = add v mul get a 2 get b 0
487v = add v mul get a 3 get b 1
488put o 2 v
489v = mul get a 0 get b 3
490v = add v mul get a 1 get b 2
491v = sub v mul get a 2 get b 1
492v = add v mul get a 3 get b 0
493put o 3 v
494end
495
496fn hQConj q edit f32 4 to void
497put q 1 neg get q 1
498put q 2 neg get q 2
499put q 3 neg get q 3
500end
501
502fn hQNorm q edit f32 4 to void
503n2 = mul get q 0 get q 0
504n2 = add n2 mul get q 1 get q 1
505n2 = add n2 mul get q 2 get q 2
506n2 = add n2 mul get q 3 get q 3
507if le n2 0.0000000001f32
508put q 0 1.0f32
509put q 1 0.0f32
510put q 2 0.0f32
511put q 3 0.0f32
512ret
513end
514inv = f32 div 1.0f64 uSqrt64 f64 n2
515for c ulong 4
516put q c mul get q c inv
517end
518end
519
520fn loadLvl lvl ulong s ulong mu ulong dst edit f32 4 to void
521b = mul add mul s 4 mu 4
522if eq lvl 0
523put dst 0 get hL1 b
524put dst 1 get hL1 add b 1
525put dst 2 get hL1 add b 2
526put dst 3 get hL1 add b 3
527ret
528end
529if eq lvl 1
530put dst 0 get hL2 b
531put dst 1 get hL2 add b 1
532put dst 2 get hL2 add b 2
533put dst 3 get hL2 add b 3
534ret
535end
536if eq lvl 2
537put dst 0 get hL3 b
538put dst 1 get hL3 add b 1
539put dst 2 get hL3 add b 2
540put dst 3 get hL3 add b 3
541ret
542end
543lm = get dLinks 0
544bo = mul b 4
545put dst 0 bitcast f32 uint mapget lm bo 4
546put dst 1 bitcast f32 uint mapget lm add bo 4 4
547put dst 2 bitcast f32 uint mapget lm add bo 8 4
548put dst 3 bitcast f32 uint mapget lm add bo 12 4
549end
550
551fn storeLvl lvl ulong s ulong mu ulong src view f32 4 to void
552b = mul add mul s 4 mu 4
553if eq lvl 0
554put hL1 b get src 0
555put hL1 add b 1 get src 1
556put hL1 add b 2 get src 2
557put hL1 add b 3 get src 3
558ret
559end
560if eq lvl 1
561put hL2 b get src 0
562put hL2 add b 1 get src 1
563put hL2 add b 2 get src 2
564put hL2 add b 3 get src 3
565ret
566end
567put hL3 b get src 0
568put hL3 add b 1 get src 1
569put hL3 add b 2 get src 2
570put hL3 add b 3 get src 3
571end
572
573fn addBlockStaple x ulong mu ulong nu ulong isBack bool dst edit f32 4 to void
574lvl = get rgSrcLvl 0
575Lf = get rgLf 0
576a = new f32 4 0.0f32
577b = new f32 4 0.0f32
578p = new f32 4 0.0f32
579q = new f32 4 0.0f32
580x2m = stepCoord stepCoord x Lf mu 1 Lf mu 1
581if not isBack
582xn = stepCoord x Lf nu 1
583loadLvl lvl x nu a
584loadLvl lvl xn mu b
585hQMul a b p
586loadLvl lvl stepCoord xn Lf mu 1 mu a
587hQMul p a q
588loadLvl lvl x2m nu a
589hQConj a
590hQMul q a p
591else
592xm = stepCoord x Lf nu sub Lf 1
593loadLvl lvl xm nu a
594hQConj a
595loadLvl lvl xm mu b
596hQMul a b p
597loadLvl lvl stepCoord xm Lf mu 1 mu a
598hQMul p a q
599loadLvl lvl stepCoord x2m Lf nu sub Lf 1 nu a
600hQMul q a p
601end
602for c ulong 4
603put dst c add get dst c get p c
604end
605end
606
607fn coarseToFine X ulong Lf ulong to ulong
608Lc = div Lf 2
609c3 = rem X Lc
610t = div X Lc
611c2 = rem t Lc
612t = div t Lc
613c1 = rem t Lc
614c0 = div t Lc
615ret coordIdx mul c0 2 mul c1 2 mul c2 2 mul c3 2 Lf
616end
617
618fn blockLinkOne X ulong mu ulong to void
619srcLvl = get rgSrcLvl 0
620Lf = get rgLf 0
621x = coarseToFine X Lf
622u1 = new f32 4 0.0f32
623u2 = new f32 4 0.0f32
624w0 = new f32 4 0.0f32
625st = new f32 4 0.0f32
626loadLvl srcLvl x mu u1
627loadLvl srcLvl stepCoord x Lf mu 1 mu u2
628hQMul u1 u2 w0
629for nu ulong 4
630if ne nu mu
631addBlockStaple x mu nu false st
632addBlockStaple x mu nu true st
633end
634end
635wS = div 0.5f32 6.0f32
636for c ulong 4
637put w0 c add mul 0.5f32 get w0 c mul wS get st c
638end
639hQNorm w0
640storeLvl get rgDstLvl 0 X mu w0
641end
642
643fn blockBox srcLvl ulong dstLvl ulong Lf ulong cLo ulong cHi ulong to void
644put rgSrcLvl 0 srcLvl
645put rgDstLvl 0 dstLvl
646put rgLf 0 Lf
647Lc = div Lf 2
648Nc = mul mul Lc Lc mul Lc Lc
649for X ulong Nc bound 65536
650if isBox4 X Lc cLo cHi
651for mu ulong 4
652blockLinkOne X mu
653end
654end
655end
656end
657
658note =========================================================================
659note Multi-Loop Wilson Observables: Plaq (1x1), Adj, Rect (1x2), Loop (2x2)
660note =========================================================================
661fn plaqLvl lvl ulong L ulong s ulong mu ulong nu ulong to f64
662a = new f32 4 0.0f32
663b = new f32 4 0.0f32
664p = new f32 4 0.0f32
665q = new f32 4 0.0f32
666loadLvl lvl s mu a
667loadLvl lvl stepCoord s L mu 1 nu b
668hQMul a b p
669loadLvl lvl stepCoord s L nu 1 mu a
670hQConj a
671hQMul p a q
672loadLvl lvl s nu b
673hQConj b
674hQMul q b p
675ret f64 get p 0
676end
677
678fn rect12Lvl lvl ulong L ulong s ulong mu ulong nu ulong to f64
679a = new f32 4 0.0f32
680b = new f32 4 0.0f32
681p = new f32 4 0.0f32
682q = new f32 4 0.0f32
683s1 = stepCoord s L mu 1
684s2 = stepCoord s1 L mu 1
685loadLvl lvl s mu a
686loadLvl lvl s1 mu b
687hQMul a b p
688loadLvl lvl s2 nu a
689hQMul p a q
690loadLvl lvl stepCoord s1 L nu 1 mu a
691hQConj a
692hQMul q a p
693loadLvl lvl stepCoord s L nu 1 mu a
694hQConj a
695hQMul p a q
696loadLvl lvl s nu b
697hQConj b
698hQMul q b p
699ret f64 get p 0
700end
701
702fn rect22Lvl lvl ulong L ulong s ulong mu ulong nu ulong to f64
703a = new f32 4 0.0f32
704p = new f32 4 0.0f32
705q = new f32 4 0.0f32
706cur = s
707loadLvl lvl cur mu p
708cur = stepCoord cur L mu 1
709loadLvl lvl cur mu a
710hQMul p a q
711cur = stepCoord cur L mu 1
712loadLvl lvl cur nu a
713hQMul q a p
714cur = stepCoord cur L nu 1
715loadLvl lvl cur nu a
716hQMul p a q
717cur = stepCoord cur L nu 1
718cur = stepCoord cur L mu sub L 1
719loadLvl lvl cur mu a
720hQConj a
721hQMul q a p
722cur = stepCoord cur L mu sub L 1
723loadLvl lvl cur mu a
724hQConj a
725hQMul p a q
726cur = stepCoord cur L nu sub L 1
727loadLvl lvl cur nu a
728hQConj a
729hQMul q a p
730cur = stepCoord cur L nu sub L 1
731loadLvl lvl cur nu a
732hQConj a
733hQMul p a q
734ret f64 get q 0
735end
736
737fn accumTomSite lvl ulong L ulong s ulong to void
738for mu ulong 4
739for nu ulong 4
740if lt mu nu
741vp = plaqLvl lvl L s mu nu
742put tomCur 0 add get tomCur 0 vp
743put tomCur 1 add get tomCur 1 sub mul 4.0f64 mul vp vp 1.0f64
744put tomCur 2 add get tomCur 2 rect12Lvl lvl L s mu nu
745put tomCur 3 add get tomCur 3 rect22Lvl lvl L s mu nu
746put tomCnt 0 add get tomCnt 0 1
747end
748end
749end
750end
751
752fn evalTomBox lvl ulong L ulong lo ulong hi ulong kIdx ulong to void
753for c ulong 4
754put tomCur c 0.0f64
755end
756put tomCnt 0 0
757N = mul mul L L mul L L
758for s ulong N bound 65536
759if isBox4 s L lo hi
760accumTomSite lvl L s
761end
762end
763fc = f64 get tomCnt 0
764base = mul kIdx 4
765for d ulong 4
766idx = add base d
767nv = add get tomAcc idx div get tomCur d fc
768put tomAcc idx nv
769end
770end
771
772note Direct 32^4 fine-level sampling on central [14, 18)^4 (256 sites)
773fn evalTom32Center kIdx ulong to void
774for c ulong 4
775put tomCur c 0.0f64
776end
777put tomCnt 0 0
778for c0 ulong 4
779for c1 ulong 4
780for c2 ulong 4
781for c3 ulong 4
782s = coordIdx add c0 14 add c1 14 add c2 14 add c3 14 32
783accumTomSite 3 32 s
784end
785end
786end
787end
788fc = f64 get tomCnt 0
789base = mul kIdx 4
790for d ulong 4
791idx = add base d
792nv = add get tomAcc idx div get tomCur d fc
793put tomAcc idx nv
794end
795end
796
797note =========================================================================
798note 12-Point Calibration & Piecewise-Linear Pure-Wilson Reference Interpolation
799note =========================================================================
800fn runCal9 idx ulong beta f32 to void
801N = ulong 4096
802if not seedGpuRngStream N add 0xc9000001 mul idx 7919
803exit 21
804end
805if not initLatticeStream 8 add 0xc9000001 mul idx 104729
806exit 22
807end
808for sw ulong 48
809if not gpuSweep N beta 3
810exit 23
811end
812end
813for c ulong 4
814put tomAcc c 0.0f64
815end
816for m ulong 32
817if not gpuSweep N beta 2
818exit 24
819end
820downloadAllToL1 N
821evalTomBox 0 8 2 6 0
822end
823pM = div get tomAcc 0 32.0f64
824aM = div get tomAcc 1 32.0f64
825rM = div get tomAcc 2 32.0f64
826wM = div get tomAcc 3 32.0f64
827put calBeta idx f64 beta
828put calP idx pM
829put calAdj idx aM
830put calR12 idx rM
831put calW22 idx wM
832uPrintF64 f64 beta
833uPrint tTab
834uPrintF64 pM
835uPrint tTab
836uPrintF64 aM
837uPrint tTab
838uPrintF64 rM
839uPrint tTab
840uPrintF64 wM
841uPrint tNl
842end
843
844fn invertBeta9 p f64 to f64
845if le p get calP 0
846ret mul get calBeta 0 div p get calP 0
847end
848for i ulong 11
849p0 = get calP i
850p1 = get calP add i 1
851if le p p1
852b0 = get calBeta i
853b1 = get calBeta add i 1
854dp = sub p1 p0
855if le dp 0.000001f64
856ret b0
857end
858ret add b0 mul sub b1 b0 div sub p p0 dp
859end
860end
861ret get calBeta 11
862end
863
864fn interpRef which ulong beta f64 to f64
865if le beta get calBeta 0
866if eq which 1
867ret get calAdj 0
868end
869if eq which 2
870ret get calR12 0
871end
872ret get calW22 0
873end
874for i ulong 11
875b0 = get calBeta i
876b1 = get calBeta add i 1
877if le beta b1
878t = div sub beta b0 sub b1 b0
879v0 = f64 0.0f64
880v1 = f64 0.0f64
881if eq which 1
882v0 = get calAdj i
883v1 = get calAdj add i 1
884end
885if eq which 2
886v0 = get calR12 i
887v1 = get calR12 add i 1
888end
889if eq which 3
890v0 = get calW22 i
891v1 = get calW22 add i 1
892end
893ret add v0 mul sub v1 v0 t
894end
895end
896if eq which 1
897ret get calAdj 11
898end
899if eq which 2
900ret get calR12 11
901end
902ret get calW22 11
903end
904
905fn printTomRow Lbase ulong beta f64 k ulong nMeas ulong us ulong to void
906fnM = f64 nMeas
907base = mul k 4
908pK = div get tomAcc base fnM
909aK = div get tomAcc add base 1 fnM
910rK = div get tomAcc add base 2 fnM
911wK = div get tomAcc add base 3 fnM
912bEff = invertBeta9 pK
913uPrintU Lbase
914uPrint tTab
915uPrintF64 beta
916uPrint tTab
917uPrintU k
918uPrint tTab
919uPrintF64 pK
920uPrint tTab
921uPrintF64 bEff
922uPrint tTab
923uPrintF64 aK
924uPrint tTab
925uPrintF64 sub aK interpRef 1 bEff
926uPrint tTab
927uPrintF64 rK
928uPrint tTab
929uPrintF64 sub rK interpRef 2 bEff
930uPrint tTab
931uPrintF64 wK
932uPrint tTab
933uPrintF64 sub wK interpRef 3 bEff
934uPrint tTab
935uPrintU us
936uPrint tNl
937end
938
939note Run Blocked-Action Tomography on Periodic 16^4 -> 8^4 -> 4^4 (64 measurements)
940fn runTom16 beta f32 seed ulong to void
941t0 = monons
942N = ulong 65536
943if not seedGpuRngStream N seed
944exit 31
945end
946if not initLatticeStream 16 add seed 104729
947exit 32
948end
949for sw ulong 64
950if not gpuSweep N beta 3
951exit 33
952end
953end
954for c ulong 16
955put tomAcc c 0.0f64
956end
957for m ulong 64
958if not gpuSweep N beta 2
959exit 34
960end
961if not gpuSweep N beta 2
962exit 35
963end
964downloadAllToL1 N
965evalTomBox 0 16 6 10 0
966blockBox 0 1 16 0 8
967evalTomBox 1 8 2 6 1
968blockBox 1 2 8 0 4
969evalTomBox 2 4 0 4 2
970end
971us = div ulong sub monons t0 1000
972printTomRow 16 f64 beta 0 64 us
973printTomRow 16 f64 beta 1 64 us
974printTomRow 16 f64 beta 2 64 us
975end
976
977note Run Deep k=3 Block-Spin RG on Periodic 32^4 (1,048,576 sites -> 16^4 -> 8^4 -> 4^4, 16 measurements)
978fn runTom32 beta f32 seed ulong to void
979t0 = monons
980N = ulong 1048576
981if not seedGpuRngStream N seed
982exit 41
983end
984if not initLatticeStream 32 add seed 104729
985exit 42
986end
987for sw ulong 32
988if not gpuSweep N beta 3
989exit 43
990end
991end
992for c ulong 16
993put tomAcc c 0.0f64
994end
995for m ulong 16
996if not gpuSweep N beta 2
997exit 44
998end
999if not gpuSweep N beta 2
1000exit 45
1001end
1002evalTom32Center 0
1003blockBox 3 0 32 0 16
1004evalTomBox 0 16 6 10 1
1005blockBox 0 1 16 0 8
1006evalTomBox 1 8 2 6 2
1007blockBox 1 2 8 0 4
1008evalTomBox 2 4 0 4 3
1009end
1010us = div ulong sub monons t0 1000
1011printTomRow 32 f64 beta 0 16 us
1012printTomRow 32 f64 beta 1 16 us
1013printTomRow 32 f64 beta 2 16 us
1014printTomRow 32 f64 beta 3 16 us
1015end
1016
1017fn allocBuf bytes ulong cached bool to long
1018m = nvalloc bytes cached
1019if le m 0
1020uPrint tC9Err
1021uPrintU ulong get nvstage 0
1022uPrint tNl
1023exit 6
1024end
1025ret m
1026end
1027
1028fn main to int
1029uPrint tC9Hdr
1030if not gbopen 1
1031uPrint tC9Err
1032uPrintU ulong get nvstage 0
1033uPrint tNl
1034ret 2
1035end
1036if not gbbopen
1037ret 3
1038end
1039put uCodeMap 0 0
1040uEmitAllKernels
1041csize = mul div add get uCodePos 0 4095 4096 4096
1042cm = nvalloc csize false
1043if le cm 0
1044ret 4
1045end
1046put uCodeMap 0 cm
1047put uCodeFail 0 0
1048uEmitAllKernels
1049if ne get uCodeFail 0 0
1050ret 5
1051end
1052
1053note Allocate GPU buffers for up to 32^4 = 1,048,576 sites (189 MB total on GB10!)
1054put dLinks 0 allocBuf 67108864 true
1055put dStaples 0 allocBuf 67108864 true
1056put dFlags 0 allocBuf 16777216 true
1057put dNbSite 0 allocBuf 33554432 true
1058put dRng 0 allocBuf 4194304 true
1059
1060note Step 1: Extended 12-point periodic 8^4 bulk calibration (0.10 .. 10.0)
1061uPrint tC9CalHdr
1062uPrint tC9CalCols
1063if not buildNbTableStream 8
1064rc = nvmclose
1065ret 10
1066end
1067if not buildFlagsStream 8
1068rc = nvmclose
1069ret 11
1070end
1071runCal9 0 0.10f32
1072runCal9 1 0.25f32
1073runCal9 2 0.50f32
1074runCal9 3 1.00f32
1075runCal9 4 1.50f32
1076runCal9 5 2.00f32
1077runCal9 6 2.30f32
1078runCal9 7 2.50f32
1079runCal9 8 3.00f32
1080runCal9 9 4.00f32
1081runCal9 10 6.00f32
1082runCal9 11 10.00f32
1083
1084note Step 2: Blocked-Action Tomography on 16^4 -> 8^4 -> 4^4
1085uPrint tC9TomHdr
1086uPrint tC9TomCols
1087if not buildNbTableStream 16
1088rc = nvmclose
1089ret 12
1090end
1091if not buildFlagsStream 16
1092rc = nvmclose
1093ret 13
1094end
1095runTom16 1.50f32 0x91010001
1096runTom16 2.00f32 0x91020001
1097runTom16 2.30f32 0x91030001
1098runTom16 2.50f32 0x91040001
1099runTom16 6.00f32 0x91060001
1100
1101note Step 3: Deep k=3 Block-Spin RG on 32^4 (1,048,576 sites -> 16^4 -> 8^4 -> 4^4!)
1102uPrint tC9K3Hdr
1103uPrint tC9TomCols
1104if not buildNbTableStream 32
1105rc = nvmclose
1106ret 14
1107end
1108if not buildFlagsStream 32
1109rc = nvmclose
1110ret 15
1111end
1112runTom32 2.00f32 0x93020001
1113runTom32 2.30f32 0x93030001
1114
1115uPrint tC9Done
1116rc = nvmclose
1117ret 0
1118end