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

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