diff --git a/benchmarks/Grid_wilson.cc b/benchmarks/Grid_wilson.cc index adfb6fd4..32255b3e 100644 --- a/benchmarks/Grid_wilson.cc +++ b/benchmarks/Grid_wilson.cc @@ -24,7 +24,8 @@ int main (int argc, char ** argv) std::vector latt_size = GridDefaultLatt(); std::vector simd_layout = GridDefaultSimd(Nd,vComplexF::Nsimd()); std::vector mpi_layout = GridDefaultMpi(); - GridCartesian Grid(latt_size,simd_layout,mpi_layout); + GridCartesian Grid(latt_size,simd_layout,mpi_layout); + GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout); int threads = GridThread::GetThreads(); std::cout << "Grid is setup to use "< U(4,&Grid); @@ -51,8 +52,11 @@ int main (int argc, char ** argv) // Only one non-zero (y) Umu=zero; + Complex cone(1.0,0.0); for(int nn=0;nn(Umu,U[nn],nn); } @@ -78,7 +82,7 @@ int main (int argc, char ** argv) } RealD mass=0.1; - WilsonMatrix Dw(Umu,mass); + WilsonMatrix Dw(Umu,Grid,RBGrid,mass); std::cout << "Calling Dw"< + +using namespace std; +using namespace Grid; +using namespace Grid::QCD; + +template +struct scal { + d internal; +}; + + Gamma::GammaMatrix Gmu [] = { + Gamma::GammaX, + Gamma::GammaY, + Gamma::GammaZ, + Gamma::GammaT + }; + +int main (int argc, char ** argv) +{ + Grid_init(&argc,&argv); + + + std::vector latt_size = GridDefaultLatt(); + std::vector simd_layout = GridDefaultSimd(Nd,vComplexF::Nsimd()); + std::vector mpi_layout = GridDefaultMpi(); + GridCartesian Grid(latt_size,simd_layout,mpi_layout); + GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout); + + std::vector seeds({1,2,3,4}); + GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds); + + LatticeFermion src(&Grid); random(pRNG,src); + RealD nrm = norm2(src); + LatticeFermion result(&Grid); result=zero; + LatticeGaugeField Umu(&Grid); random(pRNG,Umu); + + std::vector U(4,&Grid); + + for(int mu=0;mu(Umu,mu); + } + + RealD mass=0.5; + WilsonMatrix Dw(Umu,Grid,RBGrid,mass); + + // HermitianOperator HermOp(Dw); + // ConjugateGradient CG(1.0e-8,10000); + // CG(HermOp,src,result); + + LatticeFermion src_o(&RBGrid); + LatticeFermion result_o(&RBGrid); + pickCheckerboard(Odd,src_o,src); + result_o=zero; + + HermitianCheckerBoardedOperator HermOpEO(Dw); + ConjugateGradient CG(1.0e-8,10000); + CG(HermOpEO,src_o,result_o); + + Grid_finalize(); +} diff --git a/benchmarks/Grid_wilson_cg_schur.cc b/benchmarks/Grid_wilson_cg_schur.cc new file mode 100644 index 00000000..af630ae1 --- /dev/null +++ b/benchmarks/Grid_wilson_cg_schur.cc @@ -0,0 +1,48 @@ +#include + +using namespace std; +using namespace Grid; +using namespace Grid::QCD; + +template +struct scal { + d internal; +}; + + Gamma::GammaMatrix Gmu [] = { + Gamma::GammaX, + Gamma::GammaY, + Gamma::GammaZ, + Gamma::GammaT + }; + +int main (int argc, char ** argv) +{ + Grid_init(&argc,&argv); + + + std::vector latt_size = GridDefaultLatt(); + std::vector simd_layout = GridDefaultSimd(Nd,vComplexF::Nsimd()); + std::vector mpi_layout = GridDefaultMpi(); + GridCartesian Grid(latt_size,simd_layout,mpi_layout); + GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout); + + std::vector seeds({1,2,3,4}); + GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds); + + LatticeGaugeField Umu(&Grid); random(pRNG,Umu); + + LatticeFermion src(&Grid); random(pRNG,src); + LatticeFermion result(&Grid); result=zero; + LatticeFermion resid(&Grid); + + RealD mass=0.5; + WilsonMatrix Dw(Umu,Grid,RBGrid,mass); + + ConjugateGradient CG(1.0e-8,10000); + SchurRedBlackSolve SchurSolver(CG); + + SchurSolver(Dw,src,result); + + Grid_finalize(); +} diff --git a/benchmarks/Grid_wilson_cg_unprec.cc b/benchmarks/Grid_wilson_cg_unprec.cc index 93023534..15302aab 100644 --- a/benchmarks/Grid_wilson_cg_unprec.cc +++ b/benchmarks/Grid_wilson_cg_unprec.cc @@ -24,7 +24,8 @@ int main (int argc, char ** argv) std::vector latt_size = GridDefaultLatt(); std::vector simd_layout = GridDefaultSimd(Nd,vComplexF::Nsimd()); std::vector mpi_layout = GridDefaultMpi(); - GridCartesian Grid(latt_size,simd_layout,mpi_layout); + GridCartesian Grid(latt_size,simd_layout,mpi_layout); + GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout); std::vector seeds({1,2,3,4}); GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds); @@ -46,11 +47,11 @@ int main (int argc, char ** argv) } RealD mass=0.5; - WilsonMatrix Dw(Umu,mass); + WilsonMatrix Dw(Umu,Grid,RBGrid,mass); + HermitianOperator HermOp(Dw); ConjugateGradient CG(1.0e-8,10000); CG(HermOp,src,result); - Grid_finalize(); } diff --git a/benchmarks/Grid_wilson_evenodd.cc b/benchmarks/Grid_wilson_evenodd.cc new file mode 100644 index 00000000..4bc8c357 --- /dev/null +++ b/benchmarks/Grid_wilson_evenodd.cc @@ -0,0 +1,201 @@ +#include + +using namespace std; +using namespace Grid; +using namespace Grid::QCD; + +template +struct scal { + d internal; +}; + + Gamma::GammaMatrix Gmu [] = { + Gamma::GammaX, + Gamma::GammaY, + Gamma::GammaZ, + Gamma::GammaT + }; + +int main (int argc, char ** argv) +{ + Grid_init(&argc,&argv); + + std::vector latt_size = GridDefaultLatt(); + std::vector simd_layout = GridDefaultSimd(Nd,vComplexF::Nsimd()); + std::vector mpi_layout = GridDefaultMpi(); + GridCartesian Grid(latt_size,simd_layout,mpi_layout); + GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout); + + int threads = GridThread::GetThreads(); + std::cout << "Grid is setup to use "< seeds({1,2,3,4}); + + GridParallelRNG pRNG(&Grid); + // std::vector seeds({1,2,3,4}); + // pRNG.SeedFixedIntegers(seeds); + pRNG.SeedRandomDevice(); + + LatticeFermion src (&Grid); random(pRNG,src); + LatticeFermion phi (&Grid); random(pRNG,phi); + LatticeFermion chi (&Grid); random(pRNG,chi); + LatticeFermion result(&Grid); result=zero; + LatticeFermion ref(&Grid); ref=zero; + LatticeFermion tmp(&Grid); tmp=zero; + LatticeFermion err(&Grid); tmp=zero; + LatticeGaugeField Umu(&Grid); random(pRNG,Umu); + std::vector U(4,&Grid); + + double volume=1; + for(int mu=0;mu(Umu,U[nn],nn); + } + + RealD mass=0.1; + + WilsonMatrix Dw(Umu,Grid,RBGrid,mass); + + LatticeFermion src_e (&RBGrid); + LatticeFermion src_o (&RBGrid); + LatticeFermion r_e (&RBGrid); + LatticeFermion r_o (&RBGrid); + LatticeFermion r_eo (&Grid); + + const int Even=0; + const int Odd=1; + std::cout<<"=========================================================="< * = < chi | Deo^dag| phi> "< - struct RealPart { - typedef T type; - }; - template - struct RealPart< std::complex >{ + template struct RealPart { + typedef T type; + }; + template struct RealPart< std::complex >{ typedef T type; }; // type alias used to simplify the syntax of std::enable_if - template using Invoke = - typename T::type; - template using EnableIf = - Invoke>; - template using NotEnableIf = - Invoke>; + template using Invoke = typename T::type; + template using EnableIf = Invoke>; + template using NotEnableIf= Invoke>; //////////////////////////////////////////////////////// // Check for complexity with type traits - template - struct is_complex : std::false_type {}; - template < typename T > - struct is_complex< std::complex >: std::true_type {}; + template struct is_complex : std::false_type {}; + template < typename T > struct is_complex< std::complex >: std::true_type {}; //////////////////////////////////////////////////////// // Define the operation templates functors // general forms to allow for vsplat syntax @@ -86,8 +79,6 @@ namespace Grid { Grid_simd(Real a){ vsplat(*this,Scalar_type(a)); }; - - /////////////////////////////////////////////// // mac, mult, sub, add, adj @@ -126,10 +117,6 @@ namespace Grid { friend inline void vtrue (Grid_simd &ret){vsplat(ret,0xFFFFFFFF);} template < class S = Scalar_type, EnableIf, int> = 0 > friend inline void vfalse(vInteger &ret){vsplat(ret,0);} - - - - //////////////////////////////////// // Arithmetic operator overloads +,-,* @@ -165,7 +152,6 @@ namespace Grid { ret.v = binary(a.v,b.v, MultSIMD()); return ret; }; - //////////////////////////////////////////////////////////////////////// // FIXME: gonna remove these load/store, get, set, prefetch diff --git a/tests/Grid_main.cc b/tests/Grid_main.cc index 10e74099..1a761042 100644 --- a/tests/Grid_main.cc +++ b/tests/Grid_main.cc @@ -1,8 +1,9 @@ #include "Grid.h" //DEBUG +#ifdef SSE4 #include "simd/Grid_vector_types.h" - +#endif using namespace std; using namespace Grid;