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_check6_gb10.om

1274 lines · 26498 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note src/ufbi_check6_gb10.om: Pure Seeded-OM-2 Zero-CUDA GB10 Runner for UFBI Check #6
3note (High-Statistics 512-Sweep 3-Point Physically-Scaled SU(2) Continuum Ladder L in {8, 12, 16}
4note + Beta=6.0 Gapless Control + Out-of-Sample Scaled Wave-3 Symanzik-Like Observable Test).
5note
6note Upgrades over Check #5 (src/ufbi_check5_gb10.om):
7note 1. 3-Point Non-Perturbative a*sqrt(sigma) Matched Ladder (l*sqrt(sigma) ~ 2.95..2.98):
8note L=8, beta=2.300: r_mode=0 (1x1, area=1), n_s=1 (alpha=0.50 -> sqrt(1)*a8 = 1.00 a8)
9note L=12, beta=2.426: r_mode=1 (1x2, area=2), n_s=2 (alpha=0.50 -> sqrt(2)*a12 = 0.94 a8)
10note L=16, beta=2.500: r_mode=2 (2x2, area=4), n_s=4 (alpha=0.50 -> sqrt(4)*a16 = 1.00 a8)
11note 2. 3.2x-4x higher statistics: 512 measurement sweeps (16-block jackknife = 32 sweeps/block),
12note 2 GPU sweeps between measurements (1024 sweeps/arm), using halo-only link downloads
13note for fast turnaround on GB10.
14note 3. Out-of-sample scaled Wave-3 Symanzik-like observable test:
15note O2 = W3_sym_scaled = P(t1) - (R1x2(0) - Chair6(t2)) with EXACT physical APE flow-time
16note matching t_flow = (alpha/6)*n_s*a^2 held constant across all 3 spacings:
17note L=8: alpha_w3=0.25000, (n1=1, n2=2) -> t1=(1/24)*a8^2, t2=(2/24)*a8^2
18note L=12: alpha_w3=0.28125, (n1=2, n2=4) -> t1=(1/24)*a8^2, t2=(2/24)*a8^2
19note L=16: alpha_w3=0.50000, (n1=2, n2=4) -> t1=(1/24)*a8^2, t2=(2/24)*a8^2
20note O3 = W3_sym_fixed (unscaled lattice-unit control: alpha=0.50, n1=1, n2=2) to directly
21note distinguish continuum stability from finite-a cancellation!
22note 4. Runtime ZERO_CONTACT_ASSERT verifies max_direct_err == 0.000000 across ALL 5 observables
23note on ALL 6 geometries before running MC.
24note
25note Composed after:
26note gpu/nvidia/native/nvrm/context.om
27note gpu/nvidia/native/blackwell/vector.om
28note gpu/nvidia/native/blackwell/launch.om
29note gpu/nvidia/native/blackwell/batch.om
30note om/encoder/bw_enc_sm121.om
31note src/ufbi_math.om
32note src/ufbi_check3_kernels.om
33
34global uCodePos ulong 1
35global uEntry ulong 8
36global uCodeMap long 1
37global uCodeFail uint 1
38global uBind uint 32
39global uBindN ulong 1
40global uDirty uint 1
41
42global dLinks long 1
43global dStaples long 1
44global dFlags long 1
45global dNbSite long 1
46global dRng long 1
47
48note Host link buffers (L<=16 -> 65536 sites x 16 f32 = 1048576 f32 each)
49global hLinks f32 1048576
50global hSm1 f32 1048576
51global hSm2 f32 1048576
52global hNb uint 524288
53global hStage uchar 65536
54
55note 5 observables x 512 sweeps = 2560 f64
56global tsData f64 2560
57global baseMean f64 5
58global baseErr f64 5
59global baseSig f64 5
60global curMean f64 5
61global curErr f64 5
62global curSig f64 5
63global curDelta f64 5
64global curZ f64 5
65global curRBulk f64 5
66global mcAcc f64 8
67global mcCnt ulong 2
68global armBeta f32 1
69global armSeed ulong 1
70global armC1 ulong 1
71global armC2 ulong 1
72global armRMode ulong 1
73global armNSmear ulong 1
74global apeAlpha f32 1
75
76text tC6Hdr "=== UFBI CHECK #6: HIGH-STATS 512-SWEEP 3-POINT SCALED CONTINUUM LADDER & WAVE-3 TEST (PURE OM-2 GB10) ===\n"
77text tC6Err "FAIL: GB10 native NVRM/kernel error stage="
78text tC6ZcFail "FAIL: ZERO_CONTACT_ASSERT violated! err="
79text tC6ZcOk "ZERO_CONTACT_ASSERT L="
80text tC6ZcR " r_mode="
81text tC6ZcN " n_smear="
82text tC6ZcE " max_direct_err="
83text tC6ZcP " status=PASS\n"
84text tC6Cols "exp\tL\tbeta\tr_mode\tn_s\tcollar\tsweeps\tO0_d\tO0_Z\tO0_Rbulk\tO1_d\tO1_Z\tO1_Rbulk\tO2_d\tO2_Z\tO2_Rbulk\tO3_d\tO3_Z\tO3_Rbulk\tO4_d\tO4_Z\tO4_Rbulk\tO0_m\tO0_sig\tO2_m\tO2_sig\tus\n"
85text tTab "\t"
86text tNl "\n"
87text tE6B "phys_scaled_su2"
88text tE6C "gapless_ctrl_b6"
89text tK0 "C0_cold"
90text tK3 "C3_hot_haar"
91text tK6 "C6_trick_vort"
92text tC6Done "CHECK6_GB10_DONE status=PASS zero_contact_verified=1\n"
93
94fn uCodeWrite w view ulong 4 to void
95p = get uCodePos 0
96b = new uchar 16 0
97if gt get uCodeMap 0 0
98for i ulong 16
99put b i uchar and shr get w div i 4 mul rem i 4 8 255
100end
101if ne mapwrite get uCodeMap 0 p b 0 16 16
102put uCodeFail 0 1
103end
104end
105put uCodePos 0 add p 16
106end
107
108fn uEmitAllKernels to void
109put uCodePos 0 0
110for id ulong 3
111p = mul div add get uCodePos 0 255 256 256
112put uEntry id p
113put uCodePos 0 p
114put uPc 0 0
115put uGuard 0 0
116ok = false
117if eq id 0
118ok = uEmitSu2Staple
119end
120if eq id 1
121ok = uEmitSu2Overrelax
122end
123if eq id 2
124ok = uEmitSu2Heatbath
125end
126if not ok
127exit 4
128end
129uDone
130end
131end
132
133fn uArg u uint to void
134i = get uBindN 0
135put uBind i u
136put uBindN 0 add i 1
137end
138
139fn uPtr va ulong to void
140uArg gblo va
141uArg gbhi va
142end
143
144fn uRecord id ulong gx uint bx uint to bool
145gbqmd 1
146a = add mapaddr get uCodeMap 0 get uEntry id
147put gbq1 32 gblo shr a 4
148put gbq1 33 or uint and shr a 36 2097151 20971520
149put gbq1 59 gblo shr a 8
150put gbq1 34 or uint 65536 bx
151put gbq1 35 or uint 131073 shl uint 64 8
152put gbq1 36 78923784
153put gbq1 37 0
154put gbq1 39 gx
155put gbq1 40 1
156put gbq1 41 1
157put gbcb 216 bx
158put gbcb 220 gx
159put gbcb 221 1
160put gbcb 222 1
161cb = mapaddr get gbmem 1
162words = get uBindN 0
163endva = add cb add 896 mul words 4
164put gbcb 212 gbhi endva
165put gbcb 213 gblo endva
166put gbused 0 0
167gbsetup
168if ne get uDirty 0 0
169gbmth 0 40 4
170gbemit 0
171gbemit 0
172gbemit 0
173gbemit 2281701376
174put uDirty 0 0
175end
176gbdma cb 224
177for j ulong 224
178gbemit get gbcb j
179end
180gbdma add cb 896 uint words
181for j ulong words bound 32
182gbemit get uBind j
183end
184q = mapaddr get gbmem 2
185gbinline q false
186gbdma add q 8192 1
187gbemit 1
188gbinline add q 4096 true
189gbrel add mapaddr get gbmem 3 32 6
190put uBindN 0 0
191ret gbappend id get gbst 1
192end
193
194fn uRunKernel id ulong gx uint bx uint to bool
195put uDirty 0 1
196if not gbbegin 1
197ret false
198end
199if not uRecord id gx bx
200ret false
201end
202ret gbbsubmit 2000000000
203end
204
205fn stageU32 k ulong v uint to void
206b = mul k 4
207put hStage b uchar and v 255
208put hStage add b 1 uchar and shr v 8 255
209put hStage add b 2 uchar and shr v 16 255
210put hStage add b 3 uchar and shr v 24 255
211end
212
213fn stageF32 k ulong v f32 to void
214stageU32 k bitcast uint v
215end
216
217fn flushStage m long offBytes ulong nWords ulong to bool
218nb = mul nWords 4
219ret eq mapwrite m offBytes hStage 0 nb long nb
220end
221
222fn uploadLinks N ulong to bool
223totalF = mul N 16
224off = ulong 0
225while lt off totalF bound 128
226cnt = sub totalF off
227if gt cnt 16384
228cnt = ulong 16384
229end
230for k ulong cnt bound 16384
231stageF32 k get hLinks add off k
232end
233if not flushStage get dLinks 0 mul off 4 cnt
234ret false
235end
236off = add off cnt
237end
238ret true
239end
240
241fn coordIdx c0 ulong c1 ulong c2 ulong c3 ulong L ulong to ulong
242r = add mul c0 L c1
243r = add mul r L c2
244ret add mul r L c3
245end
246
247fn buildNbTable L ulong to bool
248N = mul mul L L mul L L
249for s ulong N bound 65536
250c3 = rem s L
251t = div s L
252c2 = rem t L
253t = div t L
254c1 = rem t L
255c0 = div t L
256b = mul s 8
257put hNb b uint coordIdx rem add c0 1 L c1 c2 c3 L
258put hNb add b 1 uint coordIdx rem add c0 sub L 1 L c1 c2 c3 L
259put hNb add b 2 uint coordIdx c0 rem add c1 1 L c2 c3 L
260put hNb add b 3 uint coordIdx c0 rem add c1 sub L 1 L c2 c3 L
261put hNb add b 4 uint coordIdx c0 c1 rem add c2 1 L c3 L
262put hNb add b 5 uint coordIdx c0 c1 rem add c2 sub L 1 L c3 L
263put hNb add b 6 uint coordIdx c0 c1 c2 rem add c3 1 L L
264put hNb add b 7 uint coordIdx c0 c1 c2 rem add c3 sub L 1 L L
265end
266totalW = mul N 8
267off = ulong 0
268while lt off totalW bound 64
269cnt = sub totalW off
270if gt cnt 16384
271cnt = ulong 16384
272end
273for k ulong cnt bound 16384
274stageU32 k get hNb add off k
275end
276if not flushStage get dNbSite 0 mul off 4 cnt
277ret false
278end
279off = add off cnt
280end
281ret true
282end
283
284fn isBdryL s ulong L ulong to bool
285c3 = rem s L
286t = div s L
287c2 = rem t L
288t = div t L
289c1 = rem t L
290c0 = div t L
291lm1 = sub L 1
292if or eq c0 0 eq c0 lm1
293ret true
294end
295if or eq c1 0 eq c1 lm1
296ret true
297end
298if or eq c2 0 eq c2 lm1
299ret true
300end
301if or eq c3 0 eq c3 lm1
302ret true
303end
304ret false
305end
306
307fn isBox4 s ulong L ulong lo ulong hi ulong to bool
308c3 = rem s L
309t = div s L
310c2 = rem t L
311t = div t L
312c1 = rem t L
313c0 = div t L
314if or lt c0 lo ge c0 hi
315ret false
316end
317if or lt c1 lo ge c1 hi
318ret false
319end
320if or lt c2 lo ge c2 hi
321ret false
322end
323if or lt c3 lo ge c3 hi
324ret false
325end
326ret true
327end
328
329note Fast halo-only link download from GPU dLinks into host hLinks for sites in [lo, hi)^4
330fn downloadHalo L ulong lo ulong hi ulong to void
331N = mul mul L L mul L L
332lm = get dLinks 0
333for s ulong N bound 65536
334if isBox4 s L lo hi
335base = mul s 16
336for k ulong 16
337put hLinks add base k bitcast f32 uint mapget lm mul add base k 4 4
338end
339end
340end
341end
342
343fn siteFlag s ulong L ulong freezeCollar bool to uint
344if and freezeCollar isBdryL s L
345ret uint 2
346end
347c3 = rem s L
348t = div s L
349c2 = rem t L
350t = div t L
351c1 = rem t L
352c0 = div t L
353ret uint and add add c0 c1 add c2 c3 1
354end
355
356fn buildFlags L ulong freezeCollar bool to bool
357N = mul mul L L mul L L
358totalW = mul N 4
359off = ulong 0
360while lt off totalW bound 32
361cnt = sub totalW off
362if gt cnt 16384
363cnt = ulong 16384
364end
365for k ulong cnt bound 16384
366stageU32 k siteFlag div add off k 4 L freezeCollar
367end
368if not flushStage get dFlags 0 mul off 4 cnt
369ret false
370end
371off = add off cnt
372end
373ret true
374end
375
376fn seedGpuRng N ulong seed ulong to bool
377uRngSeed seed
378off = ulong 0
379while lt off N bound 16
380cnt = sub N off
381if gt cnt 16384
382cnt = ulong 16384
383end
384for k ulong cnt bound 16384
385r = uint and uRngNext 0xffffffff
386if eq r 0
387r = uint 0x9e3779b9
388end
389stageU32 k r
390end
391if not flushStage get dRng 0 mul off 4 cnt
392ret false
393end
394off = add off cnt
395end
396ret true
397end
398
399fn qNormHost base ulong to void
400a0 = get hLinks base
401a1 = get hLinks add base 1
402a2 = get hLinks add base 2
403a3 = get hLinks add base 3
404n2 = add add mul a0 a0 mul a1 a1 add mul a2 a2 mul a3 a3
405if le n2 0.0000000001f32
406put hLinks base 1.0f32
407put hLinks add base 1 0.0f32
408put hLinks add base 2 0.0f32
409put hLinks add base 3 0.0f32
410ret
411end
412inv = f32 div 1.0f64 uSqrt64 f64 n2
413put hLinks base mul a0 inv
414put hLinks add base 1 mul a1 inv
415put hLinks add base 2 mul a2 inv
416put hLinks add base 3 mul a3 inv
417end
418
419fn setCollarLink s ulong mu ulong L ulong cid ulong to void
420base = mul add mul s 4 mu 4
421put hLinks base 1.0f32
422put hLinks add base 1 0.0f32
423put hLinks add base 2 0.0f32
424put hLinks add base 3 0.0f32
425if eq cid 0
426ret
427end
428if eq cid 3
429put hLinks base f32 uRngNorm64
430put hLinks add base 1 f32 uRngNorm64
431put hLinks add base 2 f32 uRngNorm64
432put hLinks add base 3 f32 uRngNorm64
433qNormHost base
434ret
435end
436c3 = rem s L
437c2 = rem div s L L
438c1 = rem div s mul L L L
439c0 = div s mul mul L L L
440if eq cid 6
441if eq and add c0 c1 1 1
442put hLinks base neg 0.5f32
443put hLinks add base 1 0.5f32
444put hLinks add base 2 neg 0.5f32
445put hLinks add base 3 0.5f32
446else
447put hLinks base 0.0f32
448put hLinks add base 1 neg 0.70710678f32
449put hLinks add base 2 0.70710678f32
450put hLinks add base 3 0.0f32
451end
452end
453end
454
455fn initLatticeHost L ulong cid ulong freezeCollar bool seed ulong to void
456N = mul mul L L mul L L
457uRngSeed seed
458for s ulong N bound 65536
459isB = and freezeCollar isBdryL s L
460for mu ulong 4
461if isB
462setCollarLink s mu L cid
463else
464base = mul add mul s 4 mu 4
465put hLinks base 0.85f32
466put hLinks add base 1 mul 0.25f32 f32 uRngNorm64
467put hLinks add base 2 mul 0.25f32 f32 uRngNorm64
468put hLinks add base 3 mul 0.25f32 f32 uRngNorm64
469qNormHost base
470end
471end
472end
473end
474
475fn initLattice L ulong cid ulong freezeCollar bool seed ulong to bool
476N = mul mul L L mul L L
477initLatticeHost L cid freezeCollar seed
478ret uploadLinks N
479end
480
481fn gpuRunStaple N ulong mu ulong par ulong to bool
482gx = uint div add N 255 256
483nu0 = ulong 0
484nu1 = ulong 1
485nu2 = ulong 2
486if eq mu 0
487nu0 = ulong 1
488nu1 = ulong 2
489nu2 = ulong 3
490end
491if eq mu 1
492nu0 = ulong 0
493nu1 = ulong 2
494nu2 = ulong 3
495end
496if eq mu 2
497nu0 = ulong 0
498nu1 = ulong 1
499nu2 = ulong 3
500end
501uPtr mapaddr get dLinks 0
502uPtr mapaddr get dStaples 0
503uPtr mapaddr get dFlags 0
504uPtr mapaddr get dNbSite 0
505uArg uint N
506uArg uint mu
507uArg uint par
508uArg uint nu0
509uArg uint nu1
510uArg uint nu2
511ret uRunKernel 0 gx 256
512end
513
514fn gpuRunOverrelax N ulong mu ulong par ulong to bool
515gx = uint div add N 255 256
516uPtr mapaddr get dLinks 0
517uPtr mapaddr get dStaples 0
518uPtr mapaddr get dFlags 0
519uArg uint N
520uArg uint mu
521uArg uint par
522ret uRunKernel 1 gx 256
523end
524
525fn gpuRunHeatbath N ulong mu ulong par ulong beta f32 to bool
526gx = uint div add N 255 256
527uPtr mapaddr get dLinks 0
528uPtr mapaddr get dStaples 0
529uPtr mapaddr get dFlags 0
530uPtr mapaddr get dRng 0
531uArg uint N
532uArg uint mu
533uArg uint par
534uArg bitcast uint beta
535ret uRunKernel 2 gx 256
536end
537
538fn gpuSweep N ulong beta f32 nOr ulong to bool
539for mu ulong 4
540for par ulong 2
541if not gpuRunStaple N mu par
542ret false
543end
544if not gpuRunHeatbath N mu par beta
545ret false
546end
547for r ulong nOr bound 8
548if not gpuRunStaple N mu par
549ret false
550end
551if not gpuRunOverrelax N mu par
552ret false
553end
554end
555end
556end
557ret true
558end
559
560note =========================================================================
561note Host Quaternion Helpers + Parameterized-Alpha Exact-Box APE Smearing
562note =========================================================================
563fn hQMul a view f32 4 b view f32 4 o edit f32 4 to void
564v = mul get a 0 get b 0
565v = sub v mul get a 1 get b 1
566v = sub v mul get a 2 get b 2
567v = sub v mul get a 3 get b 3
568put o 0 v
569v = mul get a 0 get b 1
570v = add v mul get a 1 get b 0
571v = add v mul get a 2 get b 3
572v = sub v mul get a 3 get b 2
573put o 1 v
574v = mul get a 0 get b 2
575v = sub v mul get a 1 get b 3
576v = add v mul get a 2 get b 0
577v = add v mul get a 3 get b 1
578put o 2 v
579v = mul get a 0 get b 3
580v = add v mul get a 1 get b 2
581v = sub v mul get a 2 get b 1
582v = add v mul get a 3 get b 0
583put o 3 v
584end
585
586fn hQConj q edit f32 4 to void
587put q 1 neg get q 1
588put q 2 neg get q 2
589put q 3 neg get q 3
590end
591
592fn hQNorm q edit f32 4 to void
593n2 = mul get q 0 get q 0
594n2 = add n2 mul get q 1 get q 1
595n2 = add n2 mul get q 2 get q 2
596n2 = add n2 mul get q 3 get q 3
597if le n2 0.0000000001f32
598put q 0 1.0f32
599put q 1 0.0f32
600put q 2 0.0f32
601put q 3 0.0f32
602ret
603end
604inv = f32 div 1.0f64 uSqrt64 f64 n2
605for c ulong 4
606put q c mul get q c inv
607end
608end
609
610fn hLoadS slot ulong s ulong mu ulong dst edit f32 4 to void
611b = mul add mul s 4 mu 4
612if eq slot 0
613put dst 0 get hLinks b
614put dst 1 get hLinks add b 1
615put dst 2 get hLinks add b 2
616put dst 3 get hLinks add b 3
617ret
618end
619if eq slot 1
620put dst 0 get hSm1 b
621put dst 1 get hSm1 add b 1
622put dst 2 get hSm1 add b 2
623put dst 3 get hSm1 add b 3
624ret
625end
626put dst 0 get hSm2 b
627put dst 1 get hSm2 add b 1
628put dst 2 get hSm2 add b 2
629put dst 3 get hSm2 add b 3
630end
631
632fn hStoreS slot ulong s ulong mu ulong src view f32 4 to void
633b = mul add mul s 4 mu 4
634if eq slot 1
635put hSm1 b get src 0
636put hSm1 add b 1 get src 1
637put hSm1 add b 2 get src 2
638put hSm1 add b 3 get src 3
639ret
640end
641put hSm2 b get src 0
642put hSm2 add b 1 get src 1
643put hSm2 add b 2 get src 2
644put hSm2 add b 3 get src 3
645end
646
647fn getNb s ulong dir ulong isMinus ulong to ulong
648ret ulong get hNb add mul s 8 add mul dir 2 isMinus
649end
650
651fn hStapleAdd slot ulong s ulong mu ulong nu ulong isBack bool dst edit f32 4 to void
652t1 = new f32 4 0.0f32
653t2 = new f32 4 0.0f32
654t3 = new f32 4 0.0f32
655p1 = new f32 4 0.0f32
656p2 = new f32 4 0.0f32
657xp = getNb s mu 0
658if not isBack
659hLoadS slot s nu t1
660hLoadS slot getNb s nu 0 mu t2
661hLoadS slot xp nu t3
662hQConj t3
663else
664xm = getNb s nu 1
665hLoadS slot xm nu t1
666hQConj t1
667hLoadS slot xm mu t2
668hLoadS slot getNb xp nu 1 nu t3
669end
670hQMul t1 t2 p1
671hQMul p1 t3 p2
672for c ulong 4
673put dst c add get dst c get p2 c
674end
675end
676
677fn hApeLink srcSlot ulong dstSlot ulong s ulong mu ulong to void
678st = new f32 4 0.0f32
679u = new f32 4 0.0f32
680al = get apeAlpha 0
681w0 = sub 1.0f32 al
682w1 = div al 6.0f32
683for nu ulong 4
684if ne nu mu
685hStapleAdd srcSlot s mu nu false st
686hStapleAdd srcSlot s mu nu true st
687end
688end
689hLoadS srcSlot s mu u
690for c ulong 4
691put u c add mul w0 get u c mul w1 get st c
692end
693hQNorm u
694hStoreS dstSlot s mu u
695end
696
697fn hApeBox L ulong srcSlot ulong dstSlot ulong lo ulong hi ulong to void
698N = mul mul L L mul L L
699for s ulong N bound 65536
700if isBox4 s L lo hi
701for mu ulong 4
702hApeLink srcSlot dstSlot s mu
703end
704end
705end
706end
707
708fn runApeChain L ulong nSmear ulong needLo ulong needHi ulong to ulong
709if eq nSmear 0
710ret ulong 0
711end
712src = ulong 0
713dst = ulong 1
714for step ulong nSmear bound 8
715remSteps = sub sub nSmear 1 step
716lo = sub needLo remSteps
717hi = add needHi remSteps
718hApeBox L src dst lo hi
719src = dst
720if eq dst 1
721dst = ulong 2
722else
723dst = ulong 1
724end
725end
726ret src
727end
728
729fn hPlaqS slot ulong s ulong mu ulong nu ulong to f64
730a = new f32 4 0.0f32
731b = new f32 4 0.0f32
732p = new f32 4 0.0f32
733q = new f32 4 0.0f32
734hLoadS slot s mu a
735hLoadS slot getNb s mu 0 nu b
736hQMul a b p
737hLoadS slot getNb s nu 0 mu a
738hQConj a
739hQMul p a q
740hLoadS slot s nu b
741hQConj b
742hQMul q b p
743ret f64 get p 0
744end
745
746fn hRect1x2S slot ulong s ulong mu ulong nu ulong to f64
747a = new f32 4 0.0f32
748b = new f32 4 0.0f32
749p = new f32 4 0.0f32
750q = new f32 4 0.0f32
751s1 = getNb s mu 0
752s2 = getNb s1 mu 0
753hLoadS slot s mu a
754hLoadS slot s1 mu b
755hQMul a b p
756hLoadS slot s2 nu a
757hQMul p a q
758hLoadS slot getNb s1 nu 0 mu a
759hQConj a
760hQMul q a p
761hLoadS slot getNb s nu 0 mu a
762hQConj a
763hQMul p a q
764hLoadS slot s nu b
765hQConj b
766hQMul q b p
767ret f64 get p 0
768end
769
770fn hRect2x2S slot ulong s ulong mu ulong nu ulong to f64
771a = new f32 4 0.0f32
772p = new f32 4 0.0f32
773q = new f32 4 0.0f32
774cur = s
775hLoadS slot cur mu p
776cur = getNb cur mu 0
777hLoadS slot cur mu a
778hQMul p a q
779cur = getNb cur mu 0
780hLoadS slot cur nu a
781hQMul q a p
782cur = getNb cur nu 0
783hLoadS slot cur nu a
784hQMul p a q
785cur = getNb cur nu 0
786cur = getNb cur mu 1
787hLoadS slot cur mu a
788hQConj a
789hQMul q a p
790cur = getNb cur mu 1
791hLoadS slot cur mu a
792hQConj a
793hQMul p a q
794cur = getNb cur nu 1
795hLoadS slot cur nu a
796hQConj a
797hQMul q a p
798cur = getNb cur nu 1
799hLoadS slot cur nu a
800hQConj a
801hQMul p a q
802ret f64 get q 0
803end
804
805fn hChair6S slot ulong s ulong d0 ulong d1 ulong d2 ulong to f64
806a = new f32 4 0.0f32
807p = new f32 4 0.0f32
808q = new f32 4 0.0f32
809cur = s
810hLoadS slot cur d0 p
811cur = getNb cur d0 0
812hLoadS slot cur d1 a
813hQMul p a q
814cur = getNb cur d1 0
815hLoadS slot cur d2 a
816hQMul q a p
817cur = getNb cur d2 0
818cur = getNb cur d0 1
819hLoadS slot cur d0 a
820hQConj a
821hQMul p a q
822cur = getNb cur d1 1
823hLoadS slot cur d1 a
824hQConj a
825hQMul q a p
826cur = getNb cur d2 1
827hLoadS slot cur d2 a
828hQConj a
829hQMul p a q
830ret f64 get q 0
831end
832
833note =========================================================================
834note Measurement Engine for Check #6:
835note O0: W_phys (scaled smeared loop: L=8 1x1 n=1; L=12 1x2 n=2; L=16 2x2 n=4)
836note O1: Adj_phys (4*W_phys^2 - 1)
837note O2: W3_sym_scaled (Wave-3 Symanzik-like P(t1) - (R1x2(0) - Chair6(t2)), flow-time matched!)
838note O3: W3_sym_fixed (Wave-3 Symanzik-like at fixed lattice steps alpha=0.50, n1=1, n2=2)
839note O4: W_bare_phys (unsmeared scaled loop: L=8 1x1; L=12 1x2; L=16 2x2)
840note =========================================================================
841fn accumMainSite s ulong sl ulong rMode ulong to void
842for mu ulong 4
843for nu ulong 4
844if lt mu nu
845vs = f64 0.0f64
846vb = f64 0.0f64
847if eq rMode 0
848vs = hPlaqS sl s mu nu
849vb = hPlaqS 0 s mu nu
850end
851if eq rMode 1
852vs = hRect1x2S sl s mu nu
853vb = hRect1x2S 0 s mu nu
854end
855if eq rMode 2
856vs = hRect2x2S sl s mu nu
857vb = hRect2x2S 0 s mu nu
858end
859put mcAcc 0 add get mcAcc 0 vs
860put mcAcc 1 add get mcAcc 1 sub mul 4.0f64 mul vs vs 1.0f64
861put mcAcc 2 add get mcAcc 2 vb
862put mcCnt 0 add get mcCnt 0 1
863end
864end
865end
866end
867
868fn evalCtrPlaq sl ulong ctrSite ulong to f64
869s = f64 0.0f64
870for mu ulong 4
871for nu ulong 4
872if lt mu nu
873s = add s hPlaqS sl ctrSite mu nu
874end
875end
876end
877ret div s 6.0f64
878end
879
880fn evalCtrRect0 ctrSite ulong to f64
881s = f64 0.0f64
882for mu ulong 4
883for nu ulong 4
884if lt mu nu
885s = add s hRect1x2S 0 ctrSite mu nu
886end
887end
888end
889ret div s 6.0f64
890end
891
892fn evalCtrChair sl ulong ctrSite ulong to f64
893c = hChair6S sl ctrSite 0 1 2
894c = add c hChair6S sl ctrSite 0 1 3
895c = add c hChair6S sl ctrSite 0 2 3
896c = add c hChair6S sl ctrSite 1 2 3
897ret mul 0.25f64 c
898end
899
900note Evaluate Wave-3 Symanzik-like P(n1) - (R1x2(0) - Chair6(n2)) at exact center site lo
901fn evalWave3Sym L ulong lo ulong al f32 n1 ulong n2 ulong to f64
902ctrSite = coordIdx lo lo lo lo L
903r0 = evalCtrRect0 ctrSite
904put apeAlpha 0 al
905sl1 = runApeChain L n1 lo add lo 2
906p1 = evalCtrPlaq sl1 ctrSite
907sl2 = runApeChain L n2 lo add lo 2
908ch2 = evalCtrChair sl2 ctrSite
909ret sub p1 sub r0 ch2
910end
911
912fn evalHost6Main L ulong rMode ulong nSmear ulong res edit f64 5 to void
913lo = ulong 3
914hi = ulong 5
915needHi = ulong 6
916if eq L 12
917lo = ulong 5
918hi = ulong 7
919needHi = ulong 9
920end
921if eq L 16
922lo = ulong 6
923hi = ulong 8
924needHi = ulong 10
925end
926put apeAlpha 0 0.50f32
927sl = runApeChain L nSmear lo needHi
928put mcAcc 0 0.0f64
929put mcAcc 1 0.0f64
930put mcAcc 2 0.0f64
931put mcCnt 0 0
932N = mul mul L L mul L L
933for s ulong N bound 65536
934if isBox4 s L lo hi
935accumMainSite s sl rMode
936end
937end
938fc = f64 get mcCnt 0
939put res 0 div get mcAcc 0 fc
940put res 1 div get mcAcc 1 fc
941put res 4 div get mcAcc 2 fc
942end
943
944fn evalHost6W3 L ulong res edit f64 5 to void
945ctrLo = ulong 3
946w3Al = f32 0.25f32
947w3N1 = ulong 1
948w3N2 = ulong 2
949if eq L 12
950ctrLo = ulong 5
951w3Al = f32 0.28125f32
952w3N1 = ulong 2
953w3N2 = ulong 4
954end
955if eq L 16
956ctrLo = ulong 7
957w3Al = f32 0.50f32
958w3N1 = ulong 2
959w3N2 = ulong 4
960end
961put res 2 evalWave3Sym L ctrLo w3Al w3N1 w3N2
962put res 3 evalWave3Sym L ctrLo 0.50f32 1 2
963end
964
965fn evalHost6 L ulong rMode ulong nSmear ulong res edit f64 5 to void
966evalHost6Main L rMode nSmear res
967evalHost6W3 L res
968end
969
970fn assertZeroContact6 L ulong rMode ulong nSmear ulong to void
971N = mul mul L L mul L L
972initLatticeHost L 0 true 0x77771234
973v0 = new f64 5 0.0f64
974v1 = new f64 5 0.0f64
975evalHost6 L rMode nSmear v0
976uRngSeed 0x99995678
977for s ulong N bound 65536
978if isBdryL s L
979for mu ulong 4
980setCollarLink s mu L 3
981end
982end
983end
984evalHost6 L rMode nSmear v1
985maxE = f64 0.0f64
986for o ulong 5
987e = uAbs64 sub get v1 o get v0 o
988if gt e maxE
989maxE = e
990end
991end
992if gt maxE 0.000000000001f64
993uPrint tC6ZcFail
994uPrintF64 maxE
995uPrint tNl
996exit 99
997end
998uPrint tC6ZcOk
999uPrintU L
1000uPrint tC6ZcR
1001uPrintU rMode
1002uPrint tC6ZcN
1003uPrintU nSmear
1004uPrint tC6ZcE
1005uPrintF64 maxE
1006uPrint tC6ZcP
1007end
1008
1009fn storeMeas6 L ulong rMode ulong nSmear ulong k ulong to void
1010downloadHalo L 1 sub L 1
1011v = new f64 5 0.0f64
1012evalHost6 L rMode nSmear v
1013b = mul k 5
1014for o ulong 5
1015put tsData add b o get v o
1016end
1017end
1018
1019fn sumBlk6 o ulong st ulong blkSz ulong to f64
1020s = f64 0.0f64
1021for j ulong blkSz bound 64
1022s = add s get tsData add mul add st j 5 o
1023end
1024ret s
1025end
1026
1027note 16-block jackknife over 512 sweeps (32 sweeps per block) + within-arm sweep std
1028fn summarizeOne6 o ulong nMeas ulong to void
1029blkSz = div nMeas 16
1030tot = f64 0.0f64
1031for k ulong nMeas bound 512
1032tot = add tot get tsData add mul k 5 o
1033end
1034mean = div tot f64 nMeas
1035put curMean o mean
1036vSum = f64 0.0f64
1037for k ulong nMeas bound 512
1038dv = sub get tsData add mul k 5 o mean
1039vSum = add vSum mul dv dv
1040end
1041put curSig o uSqrt64 div vSum f64 sub nMeas 1
1042jkSum = f64 0.0f64
1043for b ulong 16
1044bs = sumBlk6 o mul b blkSz blkSz
1045d = sub div sub tot bs f64 sub nMeas blkSz mean
1046jkSum = add jkSum mul d d
1047end
1048put curErr o uSqrt64 mul 0.9375f64 jkSum
1049end
1050
1051fn summarizeTs6 nMeas ulong to void
1052for o ulong 5
1053summarizeOne6 o nMeas
1054end
1055end
1056
1057fn computeDiffZR6 cid ulong to void
1058if eq cid 0
1059for o ulong 5
1060put baseMean o get curMean o
1061put baseErr o get curErr o
1062put baseSig o get curSig o
1063put curDelta o 0.0f64
1064put curZ o 0.0f64
1065put curRBulk o 0.0f64
1066end
1067ret
1068end
1069for o ulong 5
1070diff = uAbs64 sub get curMean o get baseMean o
1071se = uSqrt64 add mul get curErr o get curErr o mul get baseErr o get baseErr o
1072z = f64 0.0f64
1073if gt se 0.0000001f64
1074z = div diff se
1075end
1076rBulk = f64 0.0f64
1077sb = get baseSig o
1078if gt sb 0.0000001f64
1079rBulk = div diff sb
1080end
1081put curDelta o diff
1082put curZ o z
1083put curRBulk o rBulk
1084end
1085end
1086
1087fn printRow6 expId ulong L ulong cid ulong nMeas ulong us ulong to void
1088if eq expId 1
1089uPrint tE6B
1090else
1091uPrint tE6C
1092end
1093uPrint tTab
1094uPrintU L
1095uPrint tTab
1096uPrintF64 f64 get armBeta 0
1097uPrint tTab
1098uPrintU get armRMode 0
1099uPrint tTab
1100uPrintU get armNSmear 0
1101uPrint tTab
1102if eq cid 0
1103uPrint tK0
1104end
1105if eq cid 3
1106uPrint tK3
1107end
1108if eq cid 6
1109uPrint tK6
1110end
1111uPrint tTab
1112uPrintU nMeas
1113for o ulong 5
1114uPrint tTab
1115uPrintF64 get curDelta o
1116uPrint tTab
1117uPrintF64 get curZ o
1118uPrint tTab
1119uPrintF64 get curRBulk o
1120end
1121uPrint tTab
1122uPrintF64 get curMean 0
1123uPrint tTab
1124uPrintF64 get curSig 0
1125uPrint tTab
1126uPrintF64 get curMean 2
1127uPrint tTab
1128uPrintF64 get curSig 2
1129uPrint tTab
1130uPrintU us
1131uPrint tNl
1132end
1133
1134fn runArm6 expId ulong L ulong beta f32 cid ulong nTherm ulong nMeas ulong to void
1135t0 = monons
1136put armBeta 0 beta
1137seed = get armSeed 0
1138N = mul mul L L mul L L
1139if not seedGpuRng N add seed mul cid 7919
1140exit 31
1141end
1142if not initLattice L cid true add seed mul cid 104729
1143exit 32
1144end
1145for sw ulong nTherm bound 128
1146if not gpuSweep N beta 3
1147exit 33
1148end
1149end
1150rm = get armRMode 0
1151ns = get armNSmear 0
1152for k ulong nMeas bound 512
1153if not gpuSweep N beta 2
1154exit 34
1155end
1156if not gpuSweep N beta 2
1157exit 35
1158end
1159storeMeas6 L rm ns k
1160end
1161summarizeTs6 nMeas
1162computeDiffZR6 cid
1163us = div ulong sub monons t0 1000
1164printRow6 expId L cid nMeas us
1165end
1166
1167fn runBox6 expId ulong L ulong beta f32 nTh ulong nMs ulong to bool
1168if not buildNbTable L
1169ret false
1170end
1171if not buildFlags L true
1172ret false
1173end
1174assertZeroContact6 L get armRMode 0 get armNSmear 0
1175runArm6 expId L beta 0 nTh nMs
1176runArm6 expId L beta get armC1 0 nTh nMs
1177runArm6 expId L beta get armC2 0 nTh nMs
1178ret true
1179end
1180
1181fn allocBuf bytes ulong cached bool to long
1182m = nvalloc bytes cached
1183if le m 0
1184uPrint tC6Err
1185uPrintU ulong get nvstage 0
1186uPrint tNl
1187exit 6
1188end
1189ret m
1190end
1191
1192fn main to int
1193uPrint tC6Hdr
1194if not gbopen 1
1195uPrint tC6Err
1196uPrintU ulong get nvstage 0
1197uPrint tNl
1198ret 2
1199end
1200if not gbbopen
1201ret 3
1202end
1203put uCodeMap 0 0
1204uEmitAllKernels
1205csize = mul div add get uCodePos 0 4095 4096 4096
1206cm = nvalloc csize false
1207if le cm 0
1208ret 4
1209end
1210put uCodeMap 0 cm
1211put uCodeFail 0 0
1212uEmitAllKernels
1213if ne get uCodeFail 0 0
1214ret 5
1215end
1216
1217put dLinks 0 allocBuf 4194304 true
1218put dStaples 0 allocBuf 4194304 true
1219put dFlags 0 allocBuf 1048576 true
1220put dNbSite 0 allocBuf 2097152 true
1221put dRng 0 allocBuf 262144 true
1222
1223uPrint tC6Cols
1224
1225note Experiment 6B: High-Stats 512-Sweep 3-Point Confining SU(2) Continuum Ladder (l*sqrt(sigma) ~ 2.95)
1226put armSeed 0 0x6b6b0001
1227put armC1 0 3
1228put armC2 0 6
1229put armRMode 0 0
1230put armNSmear 0 1
1231if not runBox6 1 8 2.300f32 80 512
1232rc = nvmclose
1233ret 15
1234end
1235put armRMode 0 1
1236put armNSmear 0 2
1237if not runBox6 1 12 2.426f32 80 512
1238rc = nvmclose
1239ret 16
1240end
1241put armRMode 0 2
1242put armNSmear 0 4
1243if not runBox6 1 16 2.500f32 80 512
1244rc = nvmclose
1245ret 17
1246end
1247
1248note Experiment 6C: High-Stats 512-Sweep 3-Point Weak-Coupling Negative Control (beta=6.00, xi >> L)
1249put armSeed 0 0x6c6c0001
1250put armC1 0 3
1251put armC2 0 6
1252put armRMode 0 0
1253put armNSmear 0 1
1254if not runBox6 2 8 6.000f32 80 512
1255rc = nvmclose
1256ret 18
1257end
1258put armRMode 0 1
1259put armNSmear 0 2
1260if not runBox6 2 12 6.000f32 80 512
1261rc = nvmclose
1262ret 19
1263end
1264put armRMode 0 2
1265put armNSmear 0 4
1266if not runBox6 2 16 6.000f32 80 512
1267rc = nvmclose
1268ret 20
1269end
1270
1271uPrint tC6Done
1272rc = nvmclose
1273ret 0
1274end