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

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