From 0d63dce4e2168f80d7dbe2bc435353161517b09a Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Wed, 27 Sep 2023 16:21:14 -0400 Subject: [PATCH] Timing info --- Grid/algorithms/iterative/AdefGeneric.h | 156 +++++------------------- 1 file changed, 31 insertions(+), 125 deletions(-) diff --git a/Grid/algorithms/iterative/AdefGeneric.h b/Grid/algorithms/iterative/AdefGeneric.h index dd9cef05..207e38d0 100644 --- a/Grid/algorithms/iterative/AdefGeneric.h +++ b/Grid/algorithms/iterative/AdefGeneric.h @@ -83,8 +83,8 @@ class TwoLevelFlexiblePcg : public LinearFunction coarsegrid = Aggregates.CoarseGrid; grid = Aggregates.FineGrid; }; - - void Inflexible(Field &src,Field &psi) + + void Inflexible(const Field &src,Field &psi) { Field resid(grid); RealD f; @@ -99,11 +99,13 @@ class TwoLevelFlexiblePcg : public LinearFunction Field r (grid); Field mu (grid); Field rp (grid); - + //Initial residual computation & set up RealD guess = norm2(psi); double tn; + GridStopWatch HDCGTimer; + HDCGTimer.Start(); ////////////////////////// // x0 = Vstart -- possibly modify guess ////////////////////////// @@ -168,7 +170,8 @@ class TwoLevelFlexiblePcg : public LinearFunction // Stopping condition if ( rn <= rsq ) { - std::cout< return ; } - // The Pcg routine is common to all, but the various matrices differ from derived - // implementation to derived implmentation - void operator() (const Field &src, Field &psi){ - - psi.Checkerboard() = src.Checkerboard(); - grid = src.Grid(); - - RealD f; - RealD rtzp,rtz,a,d,b; - RealD rptzp; - RealD tn; - RealD guess = norm2(psi); - RealD ssq = norm2(src); - RealD rsq = ssq*Tolerance*Tolerance; - - ///////////////////////////// - // Set up history vectors - ///////////////////////////// - std::vector p (mmax,grid); - std::vector mmp(mmax,grid); - std::vector pAp(mmax); - - Field x (grid); - Field z (grid); - Field tmp(grid); - Field r (grid); - Field mu (grid); - - ////////////////////////// - // x0 = Vstart -- possibly modify guess - ////////////////////////// - x=Zero(); - Vstart(x,src); - - // r0 = b -A x0 - _FineLinop.HermOp(x,mmp[0]); // Fine operator - axpy (r, -1.0,mmp[0], src); // Recomputes r=src-Ax0 - - ////////////////////////////////// - // Compute z = M1 r - ////////////////////////////////// - PcgM1(r,z); - rtzp =real(innerProduct(r,z)); - - /////////////////////////////////////// - // Solve for Mss mu = P A z and set p = z-mu - /////////////////////////////////////// - PcgM2(z,p[0]); - - for (int k=0;k<=MaxIterations;k++){ - - int peri_k = k % mmax; - int peri_kp = (k+1) % mmax; - - rtz=rtzp; - d= PcgM3(p[peri_k],mmp[peri_k]); - a = rtz/d; - - // Memorise this - pAp[peri_k] = d; - std::cout << GridLogMessage << " pCG d "<< d< z + b p - b = (rtzp)/rtz; - std::cout << GridLogMessage << " pCG b "<< b<mmax-1)?(mmax-1):k; // This is the fCG-Tr(mmax-1) algorithm - - for(int back=0; back < northog; back++){ - int peri_back = (k-back)%mmax; - RealD pbApk= real(innerProduct(mmp[peri_back],p[peri_kp])); - RealD beta = -pbApk/pAp[peri_back]; - axpy(p[peri_kp],beta,p[peri_back],p[peri_kp]); - } - // std::cout << GridLogMessage << " pCG p[peri_kp] orthog "<< norm2(p[peri_kp])<Inflexible(in,out); } public: @@ -322,17 +208,37 @@ class TwoLevelFlexiblePcg : public LinearFunction CoarseField PleftProj(coarsegrid); CoarseField PleftMss_proj(coarsegrid); + GridStopWatch SmootherTimer; + GridStopWatch MatrixTimer; + SmootherTimer.Start(); _Smoother(in,Min); + SmootherTimer.Stop(); + MatrixTimer.Start(); _FineLinop.HermOp(Min,out); + MatrixTimer.Stop(); axpy(tmp,-1.0,out,in); // tmp = in - A Min + GridStopWatch ProjTimer; + GridStopWatch CoarseTimer; + GridStopWatch PromTimer; + ProjTimer.Start(); _Aggregates.ProjectToSubspace(PleftProj,tmp); + ProjTimer.Stop(); + CoarseTimer.Start(); _CoarseSolver(PleftProj,PleftMss_proj); // Ass^{-1} [in - A Min]_s + CoarseTimer.Stop(); + PromTimer.Start(); _Aggregates.PromoteFromSubspace(PleftMss_proj,tmp);// tmp = Q[in - A Min] + PromTimer.Stop(); + std::cout << GridLogMessage << "PcgM1 breakdown "<