From 5403445343a5e83ea446efeb8a895fcd321ac9cc Mon Sep 17 00:00:00 2001 From: James Osborn Date: Thu, 19 Dec 2024 16:24:43 -0600 Subject: [PATCH] fix phasing in hisq_force --- src/examples/hisq_force.nim | 52 +++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/src/examples/hisq_force.nim b/src/examples/hisq_force.nim index cbbef15..ca6b1ad 100644 --- a/src/examples/hisq_force.nim +++ b/src/examples/hisq_force.nim @@ -1,5 +1,5 @@ # C.T. Peterson: force test inspired from conversation with Peter Boyle -# See Grid implementation here: +# See Grid implementation here: # -https://github.com/paboyle/Grid/blob/develop/tests/forces/Test_bdy.cc import qex import gauge/[hisqsmear] @@ -18,12 +18,12 @@ var psi = lo.ColorVector() r = lo.newRNGField(RngMilc6,123456789) mass = 0.1 - eps = 0.001 + eps = floatParam("eps", 1e-4) spa = initSolverParams() spf = initSolverParams() info: PerfInfo -let hisq = newHisq() +let stag = newStag3(sg,sgl) arsq = 1e-20 frsq = 1e-12 @@ -34,15 +34,18 @@ spf.r2req = frsq spf.maxits = 10000 spf.verbosity = 1 -# -- Generic +# -- Generic + +template rephase(g: auto) = + g.setBC + threadBarrier() + g.stagPhase proc smearRephase(g: auto, sg,sgl: auto): auto {.discardable.} = tic() + threads: g.rephase let smearedForce = hisq.smearGetForce(g,sg,sgl) - threads: - sg.setBC; sgl.setBC; - threadBarrier() - sg.stagPhase; sgl.stagPhase; + threads: g.rephase smearedForce proc reTrMul(x,y:auto):auto = @@ -55,7 +58,7 @@ proc reTrMul(x,y:auto):auto = proc action(): float = var s: float - stag.solve(psi, phi, -mass, spa) + stag.solve(psi, phi, mass, spa) threads: var st = psi.norm2 threadMaster: s = st @@ -66,7 +69,7 @@ proc action(): float = proc smearedOneAndThreeLinkForce(f: auto, smearedForce: proc, p: auto, g:auto) = # reverse accumulation of the derivative # 1. Dslash - var + var f1 = f.newOneOf() f3 = f.newOneOf() ff = f.newOneOf() @@ -76,9 +79,6 @@ proc smearedOneAndThreeLinkForce(f: auto, smearedForce: proc, p: auto, g:auto) = discard t[mu] ^* p t3[mu] = newShifter(p,mu,3) discard t3[mu] ^* p - #for i in 0..<4: - # if (i == 0): discard t3[mu] ^* p - # else: discard t3[mu] ^* t3[mu].field const n = p[0].len threads: for mu in 0..