/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./tests/Test_dwf_compressed_lanczos_reorg.cc Copyright (C) 2017 Author: Leans heavily on Christoph Lehner's code Author: Peter Boyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ /* * Reimplement the badly named "multigrid" lanczos as compressed Lanczos using the features * in Grid that were intended to be used to support blocked Aggregates, from */ #include #include #include using namespace std; using namespace Grid; template class LocalCoherenceLanczosScidac : public LocalCoherenceLanczos { public: typedef iVector CoarseSiteVector; typedef Lattice CoarseField; typedef Lattice CoarseScalar; // used for inner products on fine field typedef Lattice FineField; LocalCoherenceLanczosScidac(GridBase *FineGrid,GridBase *CoarseGrid, LinearOperatorBase &FineOp, int checkerboard) // Base constructor : LocalCoherenceLanczos(FineGrid,CoarseGrid,FineOp,checkerboard) {}; void checkpointFine(std::string evecs_file,std::string evals_file) { #ifdef HAVE_LIME assert(this->subspace.size()==nbasis); emptyUserRecord record; Grid::ScidacWriter WR(this->_FineGrid->IsBoss()); WR.open(evecs_file); for(int k=0;ksubspace[k],record); } WR.close(); XmlWriter WRx(evals_file); write(WRx,"evals",this->evals_fine); #else assert(0); #endif } void checkpointFineRestore(std::string evecs_file,std::string evals_file) { #ifdef HAVE_LIME this->evals_fine.resize(nbasis); this->subspace.resize(nbasis,this->_FineGrid); std::cout << GridLogIRL<< "checkpointFineRestore: Reading evals from "<evals_fine); assert(this->evals_fine.size()==nbasis); std::cout << GridLogIRL<< "checkpointFineRestore: Reading evecs from "<subspace[k].checkerboard=this->_checkerboard; RD.readScidacFieldRecord(this->subspace[k],record); } RD.close(); #else assert(0); #endif } void checkpointCoarse(std::string evecs_file,std::string evals_file) { #ifdef HAVE_LIME int n = this->evec_coarse.size(); emptyUserRecord record; Grid::ScidacWriter WR(this->_CoarseGrid->IsBoss()); WR.open(evecs_file); for(int k=0;kevec_coarse[k],record); } WR.close(); XmlWriter WRx(evals_file); write(WRx,"evals",this->evals_coarse); #else assert(0); #endif } void checkpointCoarseRestore(std::string evecs_file,std::string evals_file,int nvec) { #ifdef HAVE_LIME std::cout << "resizing coarse vecs to " << nvec<< std::endl; this->evals_coarse.resize(nvec); this->evec_coarse.resize(nvec,this->_CoarseGrid); std::cout << GridLogIRL<< "checkpointCoarseRestore: Reading evals from "<evals_coarse); assert(this->evals_coarse.size()==nvec); emptyUserRecord record; std::cout << GridLogIRL<< "checkpointCoarseRestore: Reading evecs from "<evec_coarse[k],record); } RD.close(); #else assert(0); #endif } }; int main (int argc, char ** argv) { Grid_init(&argc,&argv); GridLogIRL.TimingMode(1); LocalCoherenceLanczosParams Params; { Params.omega.resize(10); Params.blockSize.resize(5); XmlWriter writer("Params_template.xml"); write(writer,"Params",Params); std::cout << GridLogMessage << " Written Params_template.xml" < blockSize = Params.blockSize; std::vector latt({32,32,32,32}); uint64_t vol = Ls*latt[0]*latt[1]*latt[2]*latt[3]; // double mat_flop= 2.0*1320.0*vol; // Grids GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(latt, GridDefaultSimd(Nd,vComplex::Nsimd()), GridDefaultMpi()); GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid); std::vector fineLatt = latt; int dims=fineLatt.size(); assert(blockSize.size()==dims+1); std::vector coarseLatt(dims); std::vector coarseLatt5d ; for (int d=0;d seeds4({1,2,3,4}); GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); LatticeGaugeField Umu(UGrid); SU::HotConfiguration(RNG4,Umu); // FieldMetaData header; // NerscIO::readConfiguration(Umu,header,Params.config); std::cout << GridLogMessage << "Lattice dimensions: " << latt << " Ls: " << Ls << std::endl; // ZMobius EO Operator ZMobiusFermionD Ddwf(Umu, *FGrid, *FrbGrid, *UGrid, *UrbGrid, mass, M5, Params.omega,1.,0.); SchurDiagTwoOperator HermOp(Ddwf); // Eigenvector storage LanczosParams fine =Params.FineParams; LanczosParams coarse=Params.CoarseParams; const int Ns1 = fine.Nstop; //const int Ns2 = coarse.Nstop; const int Nk1 = fine.Nk; //const int Nk2 = coarse.Nk; const int Nm1 = fine.Nm; const int Nm2 = coarse.Nm; std::cout << GridLogMessage << "Keep " << fine.Nstop << " fine vectors" << std::endl; std::cout << GridLogMessage << "Keep " << coarse.Nstop << " coarse vectors" << std::endl; assert(Nm2 >= Nm1); const int nbasis= 60; assert(nbasis==Ns1); LocalCoherenceLanczosScidac _LocalCoherenceLanczos(FrbGrid,CoarseGrid5,HermOp,Odd); std::cout << GridLogMessage << "Constructed LocalCoherenceLanczos" << std::endl; assert( (Params.doFine)||(Params.doFineRead)); if ( Params.doFine ) { std::cout << GridLogMessage << "Performing fine grid IRL Nstop "<< Ns1 << " Nk "<