From 3d13fd56c5439c4c7d0e1d8be2d407d70e5d2df0 Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Mon, 22 Jan 2024 17:43:35 -0500 Subject: [PATCH] Precompute phases, save memory in hermitian --- .../multigrid/GeneralCoarsenedMatrix.h | 174 +++++++++++++++++- 1 file changed, 166 insertions(+), 8 deletions(-) diff --git a/Grid/algorithms/multigrid/GeneralCoarsenedMatrix.h b/Grid/algorithms/multigrid/GeneralCoarsenedMatrix.h index bedcf199..4fd2f0e0 100644 --- a/Grid/algorithms/multigrid/GeneralCoarsenedMatrix.h +++ b/Grid/algorithms/multigrid/GeneralCoarsenedMatrix.h @@ -50,6 +50,7 @@ public: typedef iVector Cvec; typedef Lattice< CComplex > CoarseScalar; // used for inner products on fine field typedef Lattice FineField; + typedef Lattice FineComplexField; typedef CoarseVector Field; //////////////////// // Data members @@ -79,7 +80,7 @@ public: for(int p=0;p &A,const CoarseVector &in, CoarseVector &out) { @@ -298,6 +301,7 @@ public: * * Where q_k = delta_k . (2*M_PI/global_nb[mu]) */ +#if 0 void CoarsenOperator(LinearOperatorBase > &linop, Aggregation & Subspace) { @@ -423,8 +427,8 @@ public: // Only needed if nonhermitian if ( ! hermitian ) { - std::cout << GridLogMessage<<"PopulateAdag "< > &linop, + Aggregation & Subspace) + { + std::cout << GridLogMessage<< "GeneralCoarsenMatrix "<< std::endl; + GridBase *grid = FineGrid(); + + RealD tproj=0.0; + RealD teigen=0.0; + RealD tmat=0.0; + RealD tphase=0.0; + RealD tphaseBZ=0.0; + RealD tinv=0.0; + + ///////////////////////////////////////////////////////////// + // Orthogonalise the subblocks over the basis + ///////////////////////////////////////////////////////////// + CoarseScalar InnerProd(CoarseGrid()); + blockOrthogonalise(InnerProd,Subspace.subspace); + + const int npoint = geom.npoint; + + Coordinate clatt = CoarseGrid()->GlobalDimensions(); + int Nd = CoarseGrid()->Nd(); + + /* + * Here, k,l index which possible momentum/shift within the N-points connected by MdagM. + * Matrix index i is mapped to this shift via + * geom.shifts[i] + * + * conj(pha[block]) proj[k (which mom)][j (basis vec cpt)][block] + * = \sum_{l in ball} e^{i q_k . delta_l} < phi_{block,j} | MdagM | phi_{(block+delta_l),i} > + * = \sum_{l in ball} e^{iqk.delta_l} A_ji^{b.b+l} + * = M_{kl} A_ji^{b.b+l} + * + * Must assemble and invert matrix M_k,l = e^[i q_k . delta_l] + * + * Where q_k = delta_k . (2*M_PI/global_nb[mu]) + * + * Then A{ji}^{b,b+l} = M^{-1}_{lm} ComputeProj_{m,b,i,j} + */ + teigen-=usecond(); + Eigen::MatrixXcd Mkl = Eigen::MatrixXcd::Zero(npoint,npoint); + Eigen::MatrixXcd invMkl = Eigen::MatrixXcd::Zero(npoint,npoint); + ComplexD ci(0.0,1.0); + for(int k=0;k phaF(npoint,grid); + std::vector pha(npoint,CoarseGrid()); + + CoarseVector coarseInner(CoarseGrid()); + + typedef typename CComplex::scalar_type SComplex; + FineComplexField one(grid); one=SComplex(1.0); + FineComplexField zz(grid); zz = Zero(); + tphase=-usecond(); + for(int p=0;p ComputeProj(npoint,CoarseGrid()); + std::vector FT(npoint,CoarseGrid()); + for(int i=0;ioSites(); + autoView( A_v , _A[k], AcceleratorWrite); + autoView( FT_v , FT[k], AcceleratorRead); + accelerator_for(sss, osites, 1, { + for(int j=0;j