From c0d8e4dce5d73ce3e13fce09cef47a461eb7018a Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Sat, 28 Dec 2019 10:32:15 -0500 Subject: [PATCH] Improved Multigrid for DWF --- Grid/algorithms/CoarsenedMatrix.h | 90 ++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/Grid/algorithms/CoarsenedMatrix.h b/Grid/algorithms/CoarsenedMatrix.h index 5e5bcbfa..68c820ca 100644 --- a/Grid/algorithms/CoarsenedMatrix.h +++ b/Grid/algorithms/CoarsenedMatrix.h @@ -117,8 +117,8 @@ public: CoarseScalar InnerProd(CoarseGrid); std::cout << GridLogMessage <<" Block Gramm-Schmidt pass 1"< &hermop,int nn=nbasis) { + virtual void CreateSubspaceChebyshev(GridParallelRNG &RNG,LinearOperatorBase &hermop, + int nn, + double hi, + std::vector &lo, + std::vector &order + ) { RealD scale; - const int dependent=16; - - Chebyshev ChebFilt (0.03,64.0,500); - Chebyshev ChebDependent(0.01,64.0,200); + const int dependent=lo.size(); FineField noise(FineGrid); FineField Mn(FineGrid); @@ -269,15 +271,12 @@ public: // Initial matrix element hermop.Op(noise,Mn); std::cout< "< Cheb(lo[bbb],hi,order[bbb]); bbb++; + Cheb(hermop,noise,Mn); // normalise scale = std::pow(norm2(Mn),-0.5); @@ -354,6 +353,7 @@ public: const int Nsimd = CComplex::Nsimd(); typedef decltype(coalescedRead(in_v[0])) calcVector; + typedef decltype(coalescedRead(in_v[0](0))) calcComplex; GridStopWatch ArithmeticTimer; int osites=Grid()->oSites(); @@ -361,17 +361,18 @@ public: double bytes = osites*nbasis*nbasis*geom.npoint*sizeof(CComplex); double usecs =-usecond(); - assert(geom.npoint==9); + // assert(geom.npoint==9); - accelerator_for(ss, Grid()->oSites(), Nsimd, { - - calcVector res = Zero(); + accelerator_for(sss, Grid()->oSites()*nbasis, Nsimd, { + int ss = sss/nbasis; + int b = sss%nbasis; + calcComplex res = Zero(); calcVector nbr; int ptype; StencilEntry *SE; int lane=SIMTlane(Nsimd); - for(int point=0;point<9;point++){ + for(int point=0;point compressor; Stencil.HaloExchange(in,compressor); - - auto point = [dir, disp](){ + + int ndim = in.Grid()->Nd(); + + ////////////// + // 4D action like wilson + // 0+ => 0 + // 0- => 1 + // 1+ => 2 + // 1- => 3 + // etc.. + ////////////// + // 5D action like DWF + // 1+ => 0 + // 1- => 1 + // 2+ => 2 + // 2- => 3 + // etc.. + + auto point = [dir, disp, ndim](){ if(dir == 0 and disp == 0) return 8; - else + else if ( ndim==4 ) { return (4 * dir + 1 - disp) / 2; + } else { + return (4 * (dir-1) + 1 - disp) / 2; + } }(); + typedef LatticeView Aview; + Vector AcceleratorViewContainer; + for(int p=0;poSites(),1,{ @@ -451,11 +479,11 @@ public: nbr = Stencil.CommBuf()[SE->_offset]; } - auto A_point = A[point].View(); - res = res + A_point[ss]*nbr; + res = res + Aview_p[point][ss]*nbr; - vstream(out_v[ss],res); + out_v[ss]=res; }); + }; void Mdiag(const CoarseVector &in, CoarseVector &out){ @@ -493,7 +521,7 @@ public: std::cout << GridLogMessage<< "CoarsenMatrix" << std::endl; // Orthogonalise the subblocks over the basis // blockOrthogonalise(InnerProd,Subspace.subspace); - std::cout << GridLogMessage<< "CoarsenMatrix orthogonalised" << std::endl; + // std::cout << GridLogMessage<< "CoarsenMatrix orthogonalised" << std::endl; // Compute the matrix elements of linop between this orthonormal // set of vectors. @@ -509,7 +537,7 @@ public: for(int i=0;i