/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./benchmarks/Benchmark_wilson.cc Copyright (C) 2018 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 using namespace std; using namespace Grid; using namespace Grid::QCD; #include "Grid/util/Profiling.h" template void sliceInnerProductMesonField(std::vector< std::vector > &mat, const std::vector > &lhs, const std::vector > &rhs, int orthogdim) { typedef typename vobj::scalar_object sobj; typedef typename vobj::scalar_type scalar_type; typedef typename vobj::vector_type vector_type; int Lblock = lhs.size(); int Rblock = rhs.size(); GridBase *grid = lhs[0]._grid; const int Nd = grid->_ndimension; const int Nsimd = grid->Nsimd(); int Nt = grid->GlobalDimensions()[orthogdim]; assert(mat.size()==Lblock*Rblock); for(int t=0;t_fdimensions[orthogdim]; int ld=grid->_ldimensions[orthogdim]; int rd=grid->_rdimensions[orthogdim]; // will locally sum vectors first // sum across these down to scalars // splitting the SIMD std::vector > lvSum(rd*Lblock*Rblock); parallel_for (int r = 0; r < rd * Lblock * Rblock; r++){ lvSum[r] = zero; } std::vector lsSum(ld*Lblock*Rblock,scalar_type(0.0)); int e1= grid->_slice_nblock[orthogdim]; int e2= grid->_slice_block [orthogdim]; int stride=grid->_slice_stride[orthogdim]; std::cout << GridLogMessage << " Entering first parallel loop "<_ostride[orthogdim]; // base offset for start of plane for(int n=0;n icoor(Nd); for(int i=0;i temp; std::vector > extracted(Nsimd); temp._internal = lvSum[i+Lblock*j+Lblock*Rblock*rt]; extract(temp,extracted); for(int idx=0;idxiCoorFromIindex(icoor,idx); int ldx =rt+icoor[orthogdim]*rd; int ij_dx = i+Lblock*j+Lblock*Rblock*ldx; lsSum[ij_dx]=lsSum[ij_dx]+extracted[idx]._internal; } }} } std::cout << GridLogMessage << " Entering non parallel loop "<_processor_coor[orthogdim]){ int ij_dx = i + Lblock * j + Lblock * Rblock * lt; mat[i+j*Lblock][t] = lsSum[ij_dx]; } else{ mat[i+j*Lblock][t] = scalar_type(0.0); } }} } std::cout << GridLogMessage << " Done "< void sliceInnerProductMesonFieldGamma(std::vector< std::vector > &mat, const std::vector > &lhs, const std::vector > &rhs, int orthogdim, std::vector gammas) { typedef typename vobj::scalar_object sobj; typedef typename vobj::scalar_type scalar_type; typedef typename vobj::vector_type vector_type; int Lblock = lhs.size(); int Rblock = rhs.size(); GridBase *grid = lhs[0]._grid; const int Nd = grid->_ndimension; const int Nsimd = grid->Nsimd(); int Nt = grid->GlobalDimensions()[orthogdim]; int Ngamma = gammas.size(); assert(mat.size()==Lblock*Rblock*Ngamma); for(int t=0;t_fdimensions[orthogdim]; int ld=grid->_ldimensions[orthogdim]; int rd=grid->_rdimensions[orthogdim]; // will locally sum vectors first // sum across these down to scalars // splitting the SIMD int MFrvol = rd*Lblock*Rblock*Ngamma; int MFlvol = ld*Lblock*Rblock*Ngamma; std::vector > lvSum(MFrvol); parallel_for (int r = 0; r < MFrvol; r++){ lvSum[r] = zero; } std::vector lsSum(MFlvol); parallel_for (int r = 0; r < MFlvol; r++){ lsSum[r]=scalar_type(0.0); } int e1= grid->_slice_nblock[orthogdim]; int e2= grid->_slice_block [orthogdim]; int stride=grid->_slice_stride[orthogdim]; std::cout << GridLogMessage << " Entering first parallel loop "<_ostride[orthogdim]; // base offset for start of plane for(int n=0;n temp; std::vector icoor(Nd); std::vector > extracted(Nsimd); for(int i=0;iiCoorFromIindex(icoor,idx); int ldx =rt+icoor[orthogdim]*rd; int ij_ldx = mu+i*Ngamma+Ngamma*Lblock*j+Ngamma*Lblock*Rblock*ldx; lsSum[ij_ldx]=lsSum[ij_ldx]+extracted[idx]._internal; } }}} } std::cout << GridLogMessage << " Entering non parallel loop "<_processor_coor[orthogdim]){ int ij_dx = mu+i*Ngamma+Ngamma*Lblock*j+Ngamma*Lblock*Rblock* lt; mat[mu+i*Ngamma+j*Lblock*Ngamma][t] = lsSum[ij_dx]; } else{ mat[mu+i*Ngamma+j*Lblock*Ngamma][t] = scalar_type(0.0); } }}} } std::cout << GridLogMessage << " Done "< void sliceInnerProductMesonFieldGamma1(std::vector< std::vector > &mat, const std::vector > &lhs, const std::vector > &rhs, int orthogdim, std::vector gammas) { typedef typename vobj::scalar_object sobj; typedef typename vobj::scalar_type scalar_type; typedef typename vobj::vector_type vector_type; typedef iSpinMatrix SpinMatrix_v; typedef iSpinMatrix SpinMatrix_s; int Lblock = lhs.size(); int Rblock = rhs.size(); GridBase *grid = lhs[0]._grid; const int Nd = grid->_ndimension; const int Nsimd = grid->Nsimd(); int Nt = grid->GlobalDimensions()[orthogdim]; int Ngamma = gammas.size(); assert(mat.size()==Lblock*Rblock*Ngamma); for(int t=0;t_fdimensions[orthogdim]; int ld=grid->_ldimensions[orthogdim]; int rd=grid->_rdimensions[orthogdim]; // will locally sum vectors first // sum across these down to scalars // splitting the SIMD int MFrvol = rd*Lblock*Rblock; int MFlvol = ld*Lblock*Rblock; Vector lvSum(MFrvol); parallel_for (int r = 0; r < MFrvol; r++){ lvSum[r] = zero; } Vector lsSum(MFlvol); parallel_for (int r = 0; r < MFlvol; r++){ lsSum[r]=scalar_type(0.0); } int e1= grid->_slice_nblock[orthogdim]; int e2= grid->_slice_block [orthogdim]; int stride=grid->_slice_stride[orthogdim]; std::cout << GridLogMessage << " Entering first parallel loop "<_ostride[orthogdim]; // base offset for start of plane for(int n=0;n icoor(Nd); std::vector extracted(Nsimd); for(int i=0;iiCoorFromIindex(icoor,idx); int ldx = rt+icoor[orthogdim]*rd; int ij_ldx = i+Lblock*j+Lblock*Rblock*ldx; lsSum[ij_ldx]=lsSum[ij_ldx]+extracted[idx]; } }} } std::cout << GridLogMessage << " Entering third parallel loop "<_processor_coor[orthogdim]){ int ij_dx = i + Lblock * j + Lblock * Rblock * lt; for(int mu=0;mu void sliceInnerProductMesonFieldGammaMom(std::vector< std::vector > &mat, const std::vector > &lhs, const std::vector > &rhs, int orthogdim, std::vector gammas, const std::vector &mom) { typedef typename vobj::scalar_object sobj; typedef typename vobj::scalar_type scalar_type; typedef typename vobj::vector_type vector_type; typedef iSpinMatrix SpinMatrix_v; typedef iSpinMatrix SpinMatrix_s; int Lblock = lhs.size(); int Rblock = rhs.size(); GridBase *grid = lhs[0]._grid; const int Nd = grid->_ndimension; const int Nsimd = grid->Nsimd(); int Nt = grid->GlobalDimensions()[orthogdim]; int Ngamma = gammas.size(); int Nmom = mom.size(); assert(mat.size()==Lblock*Rblock*Ngamma*Nmom); for(int t=0;t_fdimensions[orthogdim]; int ld=grid->_ldimensions[orthogdim]; int rd=grid->_rdimensions[orthogdim]; // will locally sum vectors first // sum across these down to scalars // splitting the SIMD int MFrvol = rd*Lblock*Rblock*Nmom; int MFlvol = ld*Lblock*Rblock*Nmom; Vector lvSum(MFrvol); parallel_for (int r = 0; r < MFrvol; r++){ lvSum[r] = zero; } Vector lsSum(MFlvol); parallel_for (int r = 0; r < MFlvol; r++){ lsSum[r]=scalar_type(0.0); } int e1= grid->_slice_nblock[orthogdim]; int e2= grid->_slice_block [orthogdim]; int stride=grid->_slice_stride[orthogdim]; std::cout << GridLogMessage << " Entering first parallel loop "<_ostride[orthogdim]; // base offset for start of plane for(int n=0;n > phase(Nmom); for(int m=0;m icoor(Nd); std::vector extracted(Nsimd); for(int i=0;iiCoorFromIindex(icoor,idx); int ldx = rt+icoor[orthogdim]*rd; int ij_ldx = m+Nmom*i+Nmom*Lblock*j+Nmom*Lblock*Rblock*ldx; lsSum[ij_ldx]=lsSum[ij_ldx]+extracted[idx]; } }}} } std::cout << GridLogMessage << " Entering third parallel loop "<_processor_coor[orthogdim]){ for(int m=0;m(std::vector< std::vector > &mat, const std::vector > &lhs, const std::vector > &rhs, int orthogdim) ; */ std::vector Gmu4 ( { Gamma::Algebra::GammaX, Gamma::Algebra::GammaY, Gamma::Algebra::GammaZ, Gamma::Algebra::GammaT }); std::vector Gmu16 ( { Gamma::Algebra::Gamma5, Gamma::Algebra::GammaT, Gamma::Algebra::GammaTGamma5, Gamma::Algebra::GammaX, Gamma::Algebra::GammaXGamma5, Gamma::Algebra::GammaY, Gamma::Algebra::GammaYGamma5, Gamma::Algebra::GammaZ, Gamma::Algebra::GammaZGamma5, Gamma::Algebra::Identity, Gamma::Algebra::SigmaXT, Gamma::Algebra::SigmaXY, Gamma::Algebra::SigmaXZ, Gamma::Algebra::SigmaYT, Gamma::Algebra::SigmaYZ, Gamma::Algebra::SigmaZT }); int main (int argc, char ** argv) { Grid_init(&argc,&argv); std::vector latt_size = GridDefaultLatt(); std::vector simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd()); std::vector mpi_layout = GridDefaultMpi(); GridCartesian Grid(latt_size,simd_layout,mpi_layout); int Nmom=9; int nt = latt_size[Tp]; uint64_t vol = 1; for(int d=0;d seeds({1,2,3,4}); GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds); int Nm = atoi(argv[1]); // number of all modes (high + low) std::vector v(Nm,&Grid); std::vector w(Nm,&Grid); std::vector gammaV(Nm,&Grid); std::vector phases(Nmom,&Grid); for(int i=0;i ip(nt); std::vector > MesonFields (Nm*Nm); std::vector > MesonFields4 (Nm*Nm*4); std::vector > MesonFields16 (Nm*Nm*16); std::vector > MesonFields161(Nm*Nm*16); std::vector > MesonFields16mom (Nm*Nm*16*Nmom); std::vector > MesonFieldsRef(Nm*Nm); for(int i=0;i