From 8c6bcddbabbf64a0a021b17cf8c07581b9340a92 Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Mon, 24 Aug 2026 19:40:27 -0400 Subject: [PATCH] Coefficent of GCR printing for poly recording --- ...recGeneralisedConjugateResidualNonHermitian.h | 16 ++++++++++++++++ ...Example_pvdagm_v2_3level_DenseCoarseMatrix.cc | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/Grid/algorithms/iterative/PrecGeneralisedConjugateResidualNonHermitian.h b/Grid/algorithms/iterative/PrecGeneralisedConjugateResidualNonHermitian.h index 5e24a5eb1..8a3bc1ef4 100644 --- a/Grid/algorithms/iterative/PrecGeneralisedConjugateResidualNonHermitian.h +++ b/Grid/algorithms/iterative/PrecGeneralisedConjugateResidualNonHermitian.h @@ -72,6 +72,13 @@ public: void Level(int n) { Name("Level " + std::to_string(n)); level = n; } void SetZeroGuess(int z) { ZeroGuess = z; }; + // Coefficient logging: one line per step with the step length a_k and the + // orthogonalisation coefficients b_{k,j}. These are the data from which a + // FIXED polynomial smoother can be harvested: if they are stable from call + // to call, the adaptive GCR can be replaced by a stationary p(A) with the + // same applies and no reductions. Off by default; boss rank prints. + int LogCoeffs = 0; + void LogCoefficients(int l) { LogCoeffs = l; }; PrecGeneralisedConjugateResidualNonHermitian(RealD tol,Integer maxit,LinearOperatorBase &_Linop,LinearFunction &Prec,int _mmax,int _nstep) : Tolerance(tol), @@ -229,6 +236,10 @@ public: cp = axpy_norm(r,-a,q[peri_k],r); LinalgTimer.Stop(); + if ( LogCoeffs ) { + GCRLogLevel<<"coeff["<(mmax-1))?(mmax-1):(kp); // if more than mmax done, we orthog all mmax history. + std::ostringstream bs; for(int back=0;back=0); @@ -259,8 +271,12 @@ public: b=-real(innerProduct(q[peri_back],Az))/qq[peri_back]; p[peri_kp]=p[peri_kp]+b*p[peri_back]; q[peri_kp]=q[peri_kp]+b*q[peri_back]; + if ( LogCoeffs ) bs<<" b["< stationary p(A), no reductions). +int SmootherCoeffLog = 0; std::function SetFineSloppy = [](int){}; void ParseEnvironment(void) @@ -125,6 +129,7 @@ void ParseEnvironment(void) if(getenv("OuterTol")) OuterTol = atof(getenv("OuterTol")); if(getenv("OuterMmax")) OuterMmax = atoi(getenv("OuterMmax")); if(getenv("FineSloppyComms")) FineSloppyComms = atoi(getenv("FineSloppyComms")); + if(getenv("SmootherCoeffLog")) SmootherCoeffLog = atoi(getenv("SmootherCoeffLog")); if(getenv("OuterNstep")) OuterNstep = atoi(getenv("OuterNstep")); if(getenv("LATT")){ Coordinate l; @@ -850,6 +855,8 @@ int main (int argc, char ** argv) FineSmoother_t SmootherGCR(0.0,1,ShiftedPVdagM,simple_fine,FineSmootherOrder,FineSmootherOrder); SmootherGCR.Level(1); SmootherGCR.Name("Fsmoother"); SmootherGCR.SetZeroGuess(1); + SmootherGCR.LogCoefficients(SmootherCoeffLog); + CoarseSmootherGCR.LogCoefficients(SmootherCoeffLog); MrhsTwoLevelMG ThreeLevelPrecon(PVdagM, SmootherGCR, MrhsProjector, L2PGCR, Coarse5d, CMrhs);