2015-04-26 15:51:09 +01:00
|
|
|
#include <Grid.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Grid;
|
|
|
|
using namespace Grid::QCD;
|
|
|
|
|
|
|
|
template<class d>
|
|
|
|
struct scal {
|
|
|
|
d internal;
|
|
|
|
};
|
|
|
|
|
2015-04-27 13:45:07 +01:00
|
|
|
Gamma::GammaMatrix Gmu [] = {
|
|
|
|
Gamma::GammaX,
|
|
|
|
Gamma::GammaY,
|
|
|
|
Gamma::GammaZ,
|
|
|
|
Gamma::GammaT
|
|
|
|
};
|
2015-04-26 15:51:09 +01:00
|
|
|
|
|
|
|
int main (int argc, char ** argv)
|
|
|
|
{
|
|
|
|
Grid_init(&argc,&argv);
|
|
|
|
|
2015-05-11 12:43:10 +01:00
|
|
|
std::vector<int> latt_size;
|
|
|
|
std::vector<int> simd_layout;
|
|
|
|
std::vector<int> mpi_layout;
|
|
|
|
|
2015-05-11 14:36:48 +01:00
|
|
|
GridParseLayout(argv,argc,latt_size,simd_layout,mpi_layout);
|
2015-04-26 15:51:09 +01:00
|
|
|
|
|
|
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
|
|
|
std::vector<int> seeds({1,2,3,4});
|
|
|
|
|
|
|
|
GridParallelRNG pRNG(&Grid);
|
2015-04-28 08:11:59 +01:00
|
|
|
// std::vector<int> seeds({1,2,3,4});
|
2015-04-26 15:51:09 +01:00
|
|
|
// pRNG.SeedFixedIntegers(seeds);
|
|
|
|
pRNG.SeedRandomDevice();
|
|
|
|
|
|
|
|
LatticeFermion src(&Grid); random(pRNG,src);
|
|
|
|
LatticeFermion result(&Grid); result=zero;
|
|
|
|
LatticeFermion ref(&Grid); ref=zero;
|
2015-05-02 23:42:30 +01:00
|
|
|
LatticeFermion err(&Grid);
|
2015-04-27 13:45:07 +01:00
|
|
|
LatticeFermion tmp(&Grid); tmp=zero;
|
2015-04-26 15:51:09 +01:00
|
|
|
LatticeGaugeField Umu(&Grid); random(pRNG,Umu);
|
|
|
|
std::vector<LatticeColourMatrix> U(4,&Grid);
|
|
|
|
|
2015-04-29 06:50:18 +01:00
|
|
|
double volume=1;
|
|
|
|
for(int mu=0;mu<Nd;mu++){
|
|
|
|
volume=volume*latt_size[mu];
|
|
|
|
}
|
|
|
|
|
2015-04-26 15:51:09 +01:00
|
|
|
for(int mu=0;mu<Nd;mu++){
|
2015-04-30 16:39:06 +01:00
|
|
|
U[mu] = peekIndex<LorentzIndex>(Umu,mu);
|
2015-04-26 15:51:09 +01:00
|
|
|
}
|
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
std::vector<int> mask({1,1,1,1,1,1,1,1});
|
2015-04-27 13:45:07 +01:00
|
|
|
{ // Naive wilson implementation
|
|
|
|
ref = zero;
|
|
|
|
for(int mu=0;mu<Nd;mu++){
|
|
|
|
|
|
|
|
// ref = src + Gamma(Gamma::GammaX)* src ; // 1-gamma_x
|
|
|
|
if( mask[mu] ) {
|
|
|
|
tmp = U[mu]*Cshift(src,mu,1);
|
|
|
|
for(int i=0;i<ref._odata.size();i++){
|
|
|
|
ref._odata[i]+= tmp._odata[i] + Gamma(Gmu[mu])*tmp._odata[i]; ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( mask[mu+4] ){
|
|
|
|
tmp =adj(U[mu])*src;
|
|
|
|
tmp =Cshift(tmp,mu,-1);
|
|
|
|
for(int i=0;i<ref._odata.size();i++){
|
|
|
|
ref._odata[i]+= tmp._odata[i] - Gamma(Gmu[mu])*tmp._odata[i]; ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-26 15:51:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RealD mass=0.1;
|
|
|
|
WilsonMatrix Dw(Umu,mass);
|
2015-04-29 06:50:18 +01:00
|
|
|
|
2015-04-26 15:51:09 +01:00
|
|
|
std::cout << "Calling Dw"<<std::endl;
|
2015-05-06 06:37:21 +01:00
|
|
|
int ncall=10000;
|
2015-04-29 06:50:18 +01:00
|
|
|
double t0=usecond();
|
|
|
|
for(int i=0;i<ncall;i++){
|
|
|
|
Dw.multiply(src,result);
|
|
|
|
}
|
|
|
|
double t1=usecond();
|
|
|
|
double flops=1320*volume*ncall;
|
|
|
|
|
2015-04-26 15:51:09 +01:00
|
|
|
std::cout << "Called Dw"<<std::endl;
|
|
|
|
std::cout << "norm result "<< norm2(result)<<std::endl;
|
|
|
|
std::cout << "norm ref "<< norm2(ref)<<std::endl;
|
2015-05-02 23:42:30 +01:00
|
|
|
std::cout << "mflop/s = "<< flops/(t1-t0)<<std::endl;
|
|
|
|
err = ref -result;
|
|
|
|
std::cout << "norm diff "<< norm2(err)<<std::endl;
|
|
|
|
|
2015-04-26 15:51:09 +01:00
|
|
|
|
2015-04-29 06:23:56 +01:00
|
|
|
// for(int ss=0;ss<10;ss++ ){
|
|
|
|
for(int ss=0;ss<0;ss++ ){
|
2015-04-26 15:51:09 +01:00
|
|
|
for(int i=0;i<Ns;i++){
|
|
|
|
for(int j=0;j<Nc;j++){
|
|
|
|
ComplexF * ref_p = (ComplexF *)&ref._odata[ss]()(i)(j);
|
|
|
|
ComplexF * res_p = (ComplexF *)&result._odata[ss]()(i)(j);
|
|
|
|
std::cout << ss<< " "<<i<<" "<<j<<" "<< (*ref_p)<<" " <<(*res_p)<<std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Grid_finalize();
|
|
|
|
}
|