2015-05-31 15:09:02 +01:00
|
|
|
#include <Grid.h>
|
|
|
|
|
|
|
|
using namespace Grid;
|
|
|
|
using namespace Grid::QCD;
|
|
|
|
|
|
|
|
int main (int argc, char ** argv)
|
|
|
|
{
|
|
|
|
Grid_init(&argc,&argv);
|
|
|
|
|
|
|
|
std::vector<int> latt_size = GridDefaultLatt();
|
|
|
|
int Nd = latt_size.size();
|
2015-07-01 22:45:15 +01:00
|
|
|
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
2015-05-31 15:09:02 +01:00
|
|
|
std::vector<int> mpi_layout = GridDefaultMpi();
|
|
|
|
|
|
|
|
std::vector<int> mask(Nd,1);
|
|
|
|
mask[0]=0;
|
|
|
|
|
|
|
|
GridCartesian Fine (latt_size,simd_layout,mpi_layout);
|
|
|
|
GridRedBlackCartesian RBFine(latt_size,simd_layout,mpi_layout,mask,1);
|
|
|
|
|
|
|
|
GridParallelRNG FineRNG(&Fine); FineRNG.SeedRandomDevice();
|
|
|
|
|
|
|
|
LatticeComplex U(&Fine);
|
|
|
|
LatticeComplex ShiftU(&Fine);
|
|
|
|
LatticeComplex rbShiftU(&Fine);
|
|
|
|
LatticeComplex Ue(&RBFine);
|
|
|
|
LatticeComplex Uo(&RBFine);
|
|
|
|
LatticeComplex ShiftUe(&RBFine);
|
|
|
|
LatticeComplex ShiftUo(&RBFine);
|
|
|
|
LatticeComplex lex(&Fine);
|
|
|
|
lex=zero;
|
|
|
|
Integer stride =1;
|
|
|
|
{
|
|
|
|
double nrm;
|
|
|
|
LatticeComplex coor(&Fine);
|
|
|
|
|
|
|
|
for(int d=0;d<Nd;d++){
|
|
|
|
// Integer i=10000;
|
|
|
|
Integer i=0;
|
|
|
|
LatticeCoordinate(coor,d);
|
|
|
|
lex = lex + coor*stride+i;
|
|
|
|
stride=stride*latt_size[d];
|
|
|
|
}
|
|
|
|
U=lex;
|
|
|
|
}
|
|
|
|
|
|
|
|
pickCheckerboard(Even,Ue,U);
|
|
|
|
pickCheckerboard(Odd,Uo,U);
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
// std::cout<<GridLogMessage << U<<std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Ue " <<norm2(Ue)<<std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Uo " <<norm2(Uo)<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
TComplex cm;
|
2015-12-12 07:11:46 +00:00
|
|
|
TComplex cmeo;
|
2015-05-31 15:09:02 +01:00
|
|
|
for(int dir=0;dir<Nd;dir++){
|
2015-11-04 10:02:17 +00:00
|
|
|
// if ( dir!=1 ) continue;
|
2015-05-31 15:09:02 +01:00
|
|
|
for(int shift=0;shift<latt_size[dir];shift++){
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<<"Shifting by "<<shift<<" in direction"<<dir<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<GridLogMessage<<"Even grid"<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
ShiftUe = Cshift(Ue,dir,shift); // Shift everything cb by cb
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<GridLogMessage << "\tShiftUe " <<norm2(ShiftUe)<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<GridLogMessage<<"Odd grid"<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
ShiftUo = Cshift(Uo,dir,shift);
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<GridLogMessage << "\tShiftUo " <<norm2(ShiftUo)<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<GridLogMessage<<"Recombined Even/Odd grids"<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
setCheckerboard(rbShiftU,ShiftUe);
|
|
|
|
setCheckerboard(rbShiftU,ShiftUo);
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<GridLogMessage << "\trbShiftU " <<norm2(rbShiftU)<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<GridLogMessage<<"Full grid shift"<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
ShiftU = Cshift(U,dir,shift); // Shift everything
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<GridLogMessage << "\tShiftU " <<norm2(rbShiftU)<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
|
|
|
|
std::vector<int> coor(4);
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "Checking the non-checkerboard shift"<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
|
|
|
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
|
|
|
for(coor[1]=0;coor[1]<latt_size[1];coor[1]++){
|
|
|
|
for(coor[0]=0;coor[0]<latt_size[0];coor[0]++){
|
|
|
|
|
|
|
|
peekSite(cm,ShiftU,coor);
|
|
|
|
|
|
|
|
///////// double nrm=norm2(U);
|
|
|
|
|
|
|
|
std::vector<int> scoor(coor);
|
|
|
|
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
|
|
|
|
|
|
|
Integer slex = scoor[0]
|
|
|
|
+ latt_size[0]*scoor[1]
|
|
|
|
+ latt_size[0]*latt_size[1]*scoor[2]
|
|
|
|
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
|
|
|
|
|
|
|
Complex scm(slex);
|
|
|
|
|
|
|
|
double nrm = abs(scm-cm()()());
|
|
|
|
std::vector<int> peer(4);
|
2015-06-14 00:51:37 +01:00
|
|
|
Complex ctmp = cm;
|
|
|
|
Integer index=real(ctmp);
|
2015-05-31 15:09:02 +01:00
|
|
|
Fine.CoorFromIndex(peer,index,latt_size);
|
|
|
|
|
|
|
|
if (nrm > 0){
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<"FAIL shift "<< shift<<" in dir "<< dir
|
2015-05-31 15:09:02 +01:00
|
|
|
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
|
|
|
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
index=real(scm);
|
|
|
|
Fine.CoorFromIndex(peer,index,latt_size);
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}}}}
|
|
|
|
|
2015-11-04 10:02:17 +00:00
|
|
|
int exx=0;
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "Checking the checkerboard shift"<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
|
|
|
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
|
|
|
for(coor[1]=0;coor[1]<latt_size[1];coor[1]++){
|
|
|
|
for(coor[0]=0;coor[0]<latt_size[0];coor[0]++){
|
|
|
|
|
|
|
|
peekSite(cm,rbShiftU,coor);
|
|
|
|
|
2015-12-12 07:11:46 +00:00
|
|
|
Integer checkerboard = RBFine.CheckerBoard(coor);
|
|
|
|
|
|
|
|
// std::cout << " coor "<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] \n ";
|
|
|
|
// std::cout << "shift "<< shift <<" dir "<<dir<< " checker board "<< checkerboard << " ";
|
|
|
|
// std::cout << "Uo " << ShiftUo.checkerboard << " Ue "<<ShiftUe.checkerboard<<std::endl;
|
|
|
|
if ( checkerboard == ShiftUo.checkerboard ) {
|
|
|
|
peekSite(cmeo,ShiftUo,coor);
|
|
|
|
} else {
|
|
|
|
peekSite(cmeo,ShiftUe,coor);
|
|
|
|
}
|
|
|
|
|
2015-05-31 15:09:02 +01:00
|
|
|
|
|
|
|
std::vector<int> scoor(coor);
|
|
|
|
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
|
|
|
|
|
|
|
Integer slex = scoor[0]
|
|
|
|
+ latt_size[0]*scoor[1]
|
|
|
|
+ latt_size[0]*latt_size[1]*scoor[2]
|
|
|
|
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
|
|
|
|
|
|
|
Complex scm(slex);
|
2015-12-12 07:11:46 +00:00
|
|
|
|
2015-05-31 15:09:02 +01:00
|
|
|
std::vector<int> peer(4);
|
2015-12-12 07:11:46 +00:00
|
|
|
Complex ctmp=cmeo;
|
2015-06-14 00:51:37 +01:00
|
|
|
Integer index=real(ctmp);
|
2015-05-31 15:09:02 +01:00
|
|
|
Fine.CoorFromIndex(peer,index,latt_size);
|
|
|
|
|
2015-12-12 07:11:46 +00:00
|
|
|
double nrm = abs(cmeo()()()-scm);
|
|
|
|
if (nrm != 0) {
|
|
|
|
std::cout<<"EOFAIL shift "<< shift<<" in dir "<< dir
|
|
|
|
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
|
|
|
<< cmeo()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
|
|
|
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
|
|
|
index=real(scm);
|
|
|
|
Fine.CoorFromIndex(peer,index,latt_size);
|
|
|
|
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
|
|
|
exx=1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ctmp=cm;
|
|
|
|
index=real(ctmp);
|
|
|
|
nrm = abs(scm-cm()()());
|
|
|
|
|
2015-05-31 15:09:02 +01:00
|
|
|
if (nrm > 0){
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<"FAIL shift "<< shift<<" in dir "<< dir
|
2015-05-31 15:09:02 +01:00
|
|
|
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
|
|
|
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
2015-05-31 15:09:02 +01:00
|
|
|
index=real(scm);
|
|
|
|
Fine.CoorFromIndex(peer,index,latt_size);
|
2015-11-04 10:02:17 +00:00
|
|
|
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
|
|
|
exx=1;
|
|
|
|
} else if (1) {
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<<"PASS shift "<< shift<<" in dir "<< dir
|
2015-05-31 15:09:02 +01:00
|
|
|
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
|
|
|
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
|
|
|
}
|
|
|
|
}}}}
|
2015-11-04 10:02:17 +00:00
|
|
|
if (exx) exit(-1);
|
2015-05-31 15:09:02 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Grid_finalize();
|
|
|
|
}
|