/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./benchmarks/Benchmark_dwf.cc Copyright (C) 2015 Author: Peter Boyle Author: paboyle 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 */ #include #ifdef GRID_CUDA #define CUDA_PROFILE #endif #ifdef CUDA_PROFILE #include #endif using namespace std; using namespace Grid; //////////////////////// /// Move to domains //// //////////////////////// struct DomainDecomposition { Coordinate Block; DomainDecomposition(const Coordinate &_Block): Block(_Block){ assert(Block.size()==Nd);}; template void ProjectDomain(Field &f,Integer domain) { GridBase *grid = f.Grid(); int dims = grid->Nd(); int isDWF= (dims==Nd+1); assert((dims==Nd)||(dims==Nd+1)); Field zz(grid); zz = Zero(); LatticeInteger coor(grid); LatticeInteger domaincoor(grid); LatticeInteger mask(grid); mask = Integer(1); LatticeInteger zi(grid); zi = Integer(0); for(int d=0;d struct DirichletFilter: public MomentumFilterBase { Coordinate Block; DirichletFilter(const Coordinate &_Block): Block(_Block) {} // Edge detect using domain projectors void applyFilter (MomentaField &U) const override { DomainDecomposition Domains(Block); GridBase *grid = U.Grid(); LatticeInteger coor(grid); LatticeInteger face(grid); LatticeInteger one(grid); one = 1; LatticeInteger zero(grid); zero = 0; LatticeInteger omega(grid); LatticeInteger omegabar(grid); LatticeInteger tmp(grid); omega=one; Domains.ProjectDomain(omega,0); omegabar=one; Domains.ProjectDomain(omegabar,1); LatticeInteger nface(grid); nface=Zero(); MomentaField projected(grid); projected=Zero(); typedef decltype(PeekIndex(U,0)) MomentaLinkField; MomentaLinkField Umu(grid); MomentaLinkField zz(grid); zz=Zero(); int dims = grid->Nd(); Coordinate Global=grid->GlobalDimensions(); assert(dims==Nd); for(int mu=0;mu(U,mu); // Upper face tmp = Cshift(omegabar,mu,1); tmp = tmp + omega; face = where(tmp == Integer(2),one,zero ); tmp = Cshift(omega,mu,1); tmp = tmp + omegabar; face = where(tmp == Integer(2),one,face ); Umu = where(face,zz,Umu); PokeIndex(U, Umu, mu); } } } }; Gamma::Algebra Gmu [] = { Gamma::Algebra::GammaX, Gamma::Algebra::GammaY, Gamma::Algebra::GammaZ, Gamma::Algebra::GammaT }; void Benchmark(int Ls, std::vector Dirichlet); int main (int argc, char ** argv) { Grid_init(&argc,&argv); int threads = GridThread::GetThreads(); int Ls=16; for(int i=0;i> Ls; } } std::vector Dirichlet(5,0); Benchmark(Ls,Dirichlet); Coordinate latt4 = GridDefaultLatt(); Coordinate mpi = GridDefaultMpi(); Coordinate shm; GlobalSharedMemory::GetShmDims(mpi,shm); /* Dirichlet = std::vector({0, latt4[0]/mpi[0] * shm[0], latt4[1]/mpi[1] * shm[1], latt4[2]/mpi[2] * shm[2], latt4[3]/mpi[3] * shm[3]}); */ Dirichlet = std::vector({0, latt4[0]/mpi[0] , latt4[1]/mpi[1] , latt4[2]/mpi[2] , latt4[3]/mpi[3] }); std::cout << " Dirichlet block "<< Dirichlet<< std::endl; Benchmark(Ls,Dirichlet); Grid_finalize(); exit(0); } void Benchmark(int Ls, std::vector Dirichlet) { Coordinate latt4 = GridDefaultLatt(); GridLogLayout(); long unsigned int single_site_flops = 8*Nc*(7+16*Nc); GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplexF::Nsimd()),GridDefaultMpi()); GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid); GridCartesian * sUGrid = SpaceTimeGrid::makeFourDimDWFGrid(GridDefaultLatt(),GridDefaultMpi()); GridRedBlackCartesian * sUrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(sUGrid); GridCartesian * sFGrid = SpaceTimeGrid::makeFiveDimDWFGrid(Ls,UGrid); GridRedBlackCartesian * sFrbGrid = SpaceTimeGrid::makeFiveDimDWFRedBlackGrid(Ls,UGrid); std::vector seeds4({1,2,3,4}); std::vector seeds5({5,6,7,8}); std::cout << GridLogMessage << "Initialising 4d RNG" << std::endl; GridParallelRNG RNG4(UGrid); RNG4.SeedUniqueString(std::string("The 4D RNG")); std::cout << GridLogMessage << "Initialising 5d RNG" << std::endl; GridParallelRNG RNG5(FGrid); RNG5.SeedUniqueString(std::string("The 5D RNG")); LatticeFermionF src (FGrid); random(RNG5,src); RealD N2 = 1.0/::sqrt(norm2(src)); src = src*N2; LatticeFermionF result(FGrid); result=Zero(); LatticeFermionF ref(FGrid); ref=Zero(); LatticeFermionF tmp(FGrid); LatticeFermionF err(FGrid); std::cout << GridLogMessage << "Drawing gauge field" << std::endl; LatticeGaugeFieldF Umu(UGrid); SU::HotConfiguration(RNG4,Umu); std::cout << GridLogMessage << "Random gauge initialised " << std::endl; //////////////////////////////////// // Apply BCs //////////////////////////////////// std::cout << GridLogMessage << "Applying BCs " << std::endl; Coordinate Block(4); for(int d=0;d<4;d++) Block[d]= Dirichlet[d+1]; std::cout << GridLogMessage << "Dirichlet Block " << Block<< std::endl; DirichletFilter Filter(Block); Filter.applyFilter(Umu); //////////////////////////////////// // Naive wilson implementation //////////////////////////////////// // replicate across fifth dimension // LatticeGaugeFieldF Umu5d(FGrid); std::vector U(4,UGrid); for(int mu=0;mu(Umu,mu); } std::cout << GridLogMessage << "Setting up Cshift based reference " << std::endl; if (1) { ref = Zero(); for(int mu=0;muoSites();ss++){ for(int s=0;soSites();ss++){ for(int s=0;s_Nprocessors; RealD NN = UGrid->NodeCount(); std::cout << GridLogMessage<< "*****************************************************************" <Barrier(); Dw.Dhop(src,result,0); std::cout<Barrier(); double volume=Ls; for(int mu=0;mu1.0e-4) ) { std::cout<Barrier(); exit(-1); } assert (norm2(err)< 1.0e-4 ); } if (1) { // Naive wilson dag implementation ref = Zero(); for(int mu=0;muoSites();ss++){ for(int s=0;soSites();ss++){ for(int s=0;s 1.0e-4 ) { std::cout << "Error vector is\n" <Barrier(); Dw.DhopEO(src_o,r_e,DaggerNo); double t0=usecond(); for(int i=0;iBarrier(); double volume=Ls; for(int mu=0;mu