1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-09 23:45:36 +00:00

Improved stencil tests passing all on KNL multinode

This commit is contained in:
paboyle 2017-02-07 00:58:34 -05:00
parent b5e9c900a4
commit 9ff97b4711
4 changed files with 109 additions and 52 deletions

View File

@ -66,7 +66,7 @@ int main (int argc, char ** argv)
random(fRNG,Foo);
gaussian(fRNG,Bar);
/*
Integer stride =1000;
{
double nrm;
@ -79,7 +79,6 @@ int main (int argc, char ** argv)
}
Foo=lex;
}
*/
typedef CartesianStencil<vobj,vobj> Stencil;
for(int dir=0;dir<4;dir++){
@ -92,7 +91,6 @@ int main (int argc, char ** argv)
std::vector<int> displacements(npoint,disp);
Stencil myStencil(&Fine,npoint,0,directions,displacements);
std::vector<int> ocoor(4);
for(int o=0;o<Fine.oSites();o++){
Fine.oCoorFromOindex(ocoor,o);
@ -147,7 +145,7 @@ int main (int argc, char ** argv)
}}}}
if (nrm > 1.0e-4) exit(-1);
}
}
@ -182,8 +180,6 @@ int main (int argc, char ** argv)
SimpleCompressor<vobj> compress;
EStencil.HaloExchange(EFoo,compress);
OStencil.HaloExchange(OFoo,compress);
Bar = Cshift(Foo,dir,disp);
@ -196,6 +192,7 @@ int main (int argc, char ** argv)
}
// Implement a stencil code that should agree with that darn cshift!
EStencil.HaloExchange(EFoo,compress);
for(int i=0;i<OCheck._grid->oSites();i++){
int permute_type;
StencilEntry *SE;
@ -209,6 +206,7 @@ int main (int argc, char ** argv)
else
OCheck._odata[i] = EStencil.CommBuf()[SE->_offset];
}
OStencil.HaloExchange(OFoo,compress);
for(int i=0;i<ECheck._grid->oSites();i++){
int permute_type;
StencilEntry *SE;
@ -254,6 +252,7 @@ int main (int argc, char ** argv)
}}}}
if (nrm > 1.0e-4) exit(-1);
}
}

View File

@ -32,6 +32,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
using namespace Grid;
using namespace Grid::QCD;
#define POWER10
int main (int argc, char ** argv)
{
Grid_init(&argc,&argv);
@ -52,6 +54,7 @@ int main (int argc, char ** argv)
LatticeComplex U(&Fine);
LatticeComplex ShiftU(&Fine);
LatticeComplex rbShiftU(&Fine);
LatticeComplex err(&Fine);
LatticeComplex Ue(&RBFine);
LatticeComplex Uo(&RBFine);
LatticeComplex ShiftUe(&RBFine);
@ -68,7 +71,11 @@ int main (int argc, char ** argv)
Integer i=0;
LatticeCoordinate(coor,d);
lex = lex + coor*stride+i;
#ifndef POWER10
stride=stride*latt_size[d];
#else
stride=stride*10;
#endif
}
U=lex;
}
@ -87,28 +94,31 @@ int main (int argc, char ** argv)
// if ( dir!=1 ) continue;
for(int shift=0;shift<latt_size[dir];shift++){
std::cout<<GridLogMessage<<"Shifting by "<<shift<<" in direction"<<dir<<std::endl;
std::cout<<GridLogMessage<<"Shifting by "<<shift<<" in direction"<<dir<< " ";
std::cout<<GridLogMessage<<"Even grid"<<std::endl;
// std::cout<<GridLogMessage<<"Even grid"<<std::endl;
ShiftUe = Cshift(Ue,dir,shift); // Shift everything cb by cb
std::cout<<GridLogMessage << "\tShiftUe " <<norm2(ShiftUe)<<std::endl;
// std::cout<<GridLogMessage << "\tShiftUe " <<norm2(ShiftUe)<<std::endl;
std::cout<<GridLogMessage<<"Odd grid"<<std::endl;
// std::cout<<GridLogMessage<<"Odd grid"<<std::endl;
ShiftUo = Cshift(Uo,dir,shift);
std::cout<<GridLogMessage << "\tShiftUo " <<norm2(ShiftUo)<<std::endl;
// std::cout<<GridLogMessage << "\tShiftUo " <<norm2(ShiftUo)<<std::endl;
std::cout<<GridLogMessage<<"Recombined Even/Odd grids"<<std::endl;
// std::cout<<GridLogMessage<<"Recombined Even/Odd grids"<<std::endl;
setCheckerboard(rbShiftU,ShiftUe);
setCheckerboard(rbShiftU,ShiftUo);
std::cout<<GridLogMessage << "\trbShiftU " <<norm2(rbShiftU)<<std::endl;
//std::cout<<GridLogMessage << "\trbShiftU " <<norm2(rbShiftU)<<std::endl;
std::cout<<GridLogMessage<<"Full grid shift"<<std::endl;
// std::cout<<GridLogMessage<<"Full grid shift"<<std::endl;
ShiftU = Cshift(U,dir,shift); // Shift everything
std::cout<<GridLogMessage << "\tShiftU " <<norm2(rbShiftU)<<std::endl;
// std::cout<<GridLogMessage << "\tShiftU " <<norm2(rbShiftU)<<std::endl;
err = ShiftU - rbShiftU;
std::cout<< "\terror " <<norm2(err)<<std::endl;
std::vector<int> coor(4);
std::cout<<GridLogMessage << "Checking the non-checkerboard shift"<<std::endl;
std::cout<<GridLogMessage << " Checking the non-checkerboard shift "<<shift <<" dir "<<dir <<" ... ";
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]++){
@ -121,18 +131,26 @@ int main (int argc, char ** argv)
std::vector<int> scoor(coor);
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
#ifndef POWER10
std::vector<int> powers=latt_size;
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];
#else
std::vector<int> powers({1,10,100,1000});
Integer slex = scoor[0]
+ 10 *scoor[1]
+ 100 *scoor[2]
+ 1000 *scoor[3];
#endif
Complex scm(slex);
double nrm = abs(scm-cm()()());
std::vector<int> peer(4);
Complex ctmp = cm;
Integer index=real(ctmp);
Lexicographic::CoorFromIndex(peer,index,latt_size);
Lexicographic::CoorFromIndex(peer,index,powers);
if (nrm > 0){
std::cout<<"FAIL shift "<< shift<<" in dir "<< dir
@ -145,9 +163,10 @@ int main (int argc, char ** argv)
exit(-1);
}
}}}}
std::cout << " OK !"<<std::endl;
int exx=0;
std::cout<<GridLogMessage << "Checking the checkerboard shift"<<std::endl;
std::cout<<GridLogMessage << " Checking the checkerboard shift "<< shift << " dir " << dir <<" ... ";
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]++){
@ -157,39 +176,49 @@ int main (int argc, char ** argv)
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);
}
std::vector<int> scoor(coor);
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
#ifndef POWER10
std::vector<int> powers=latt_size;
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];
#else
std::vector<int> powers({1,10,100,1000});
Integer slex = scoor[0]
+ 10 *scoor[1]
+ 100 *scoor[2]
+ 1000 *scoor[3];
#endif
Complex scm(slex);
std::vector<int> peer(4);
Complex ctmp=cmeo;
Integer index=real(ctmp);
Lexicographic::CoorFromIndex(peer,index,latt_size);
Lexicographic::CoorFromIndex(peer,index,powers);
double nrm = abs(cmeo()()()-scm);
if (nrm != 0) {
std::cout << " coor "<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] \n ";
std::cout << "shift "<< shift <<" dir "<<dir<< " checker board "<< checkerboard << " ";
std::cout << "Uo cb = " << ShiftUo.checkerboard << " Ue cb= "<<ShiftUe.checkerboard<<std::endl;
std::cout<<"EOFAIL shift "<< shift<<" in dir "<< dir
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
<<" cm " << cm()()()<<" cmeo "
<< cmeo()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
index=real(scm);
Lexicographic::CoorFromIndex(peer,index,latt_size);
Lexicographic::CoorFromIndex(peer,index,powers);
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
exx=1;
@ -205,17 +234,17 @@ int main (int argc, char ** argv)
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
index=real(scm);
Lexicographic::CoorFromIndex(peer,index,latt_size);
Lexicographic::CoorFromIndex(peer,index,powers);
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
exx=1;
} else if (1) {
} else if (0) {
std::cout<<GridLogMessage<<"PASS shift "<< shift<<" in dir "<< dir
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
}
}}}}
if (exx) exit(-1);
std::cout << " OK !"<<std::endl;
}
}

View File

@ -32,6 +32,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
using namespace Grid;
using namespace Grid::QCD;
#define POWER10
int main (int argc, char ** argv)
{
Grid_init(&argc,&argv);
@ -49,6 +51,7 @@ int main (int argc, char ** argv)
GridParallelRNG FineRNG(&Fine); FineRNG.SeedRandomDevice();
LatticeComplex err(&Fine);
LatticeComplex U(&Fine);
LatticeComplex ShiftU(&Fine);
LatticeComplex rbShiftU(&Fine);
@ -66,9 +69,15 @@ int main (int argc, char ** argv)
for(int d=0;d<Nd;d++){
// Integer i=10000;
Integer i=0;
#ifdef POWER10
LatticeCoordinate(coor,Nd-d-1);
lex = lex + coor*stride+i;
stride=stride*10;
#else
LatticeCoordinate(coor,d);
lex = lex + coor*stride+i;
stride=stride*latt_size[d];
#endif
}
U=lex;
}
@ -87,28 +96,30 @@ int main (int argc, char ** argv)
// if ( dir!=1 ) continue;
for(int shift=0;shift<latt_size[dir];shift++){
std::cout<<GridLogMessage<<"Shifting by "<<shift<<" in direction"<<dir<<std::endl;
std::cout<<GridLogMessage<<"Shifting by "<<shift<<" in direction"<<dir;
std::cout<<GridLogMessage<<"Even grid"<<std::endl;
// std::cout<<GridLogMessage<<"Even grid"<<std::endl;
ShiftUe = Cshift(Ue,dir,shift); // Shift everything cb by cb
std::cout<<GridLogMessage << "\tShiftUe " <<norm2(ShiftUe)<<std::endl;
std::cout<<GridLogMessage<<"Odd grid"<<std::endl;
// std::cout<<GridLogMessage << "\tShiftUe " <<norm2(ShiftUe)<<std::endl;
// std::cout<<GridLogMessage<<"Odd grid"<<std::endl;
ShiftUo = Cshift(Uo,dir,shift);
std::cout<<GridLogMessage << "\tShiftUo " <<norm2(ShiftUo)<<std::endl;
// std::cout<<GridLogMessage << "\tShiftUo " <<norm2(ShiftUo)<<std::endl;
std::cout<<GridLogMessage<<"Recombined Even/Odd grids"<<std::endl;
// std::cout<<GridLogMessage<<"Recombined Even/Odd grids"<<std::endl;
setCheckerboard(rbShiftU,ShiftUe);
setCheckerboard(rbShiftU,ShiftUo);
std::cout<<GridLogMessage << "\trbShiftU " <<norm2(rbShiftU)<<std::endl;
// std::cout<<GridLogMessage << "\trbShiftU " <<norm2(rbShiftU)<<std::endl;
std::cout<<GridLogMessage<<"Full grid shift"<<std::endl;
// std::cout<<GridLogMessage<<"Full grid shift"<<std::endl;
ShiftU = Cshift(U,dir,shift); // Shift everything
std::cout<<GridLogMessage << "\tShiftU " <<norm2(rbShiftU)<<std::endl;
// std::cout<<GridLogMessage << "\tShiftU " <<norm2(rbShiftU)<<std::endl;
err = ShiftU - rbShiftU;
std::cout<< "\terror " <<norm2(err)<<std::endl;
std::vector<int> coor(4);
std::cout<<GridLogMessage << "Checking the non-checkerboard shift"<<std::endl;
std::cout<<GridLogMessage << " Checking the non-checkerboard shift "<< shift << " dir "<<dir <<"... ";
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]++){
@ -120,11 +131,20 @@ int main (int argc, char ** argv)
std::vector<int> scoor(coor);
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
#ifdef POWER10
std::vector<int> powers({1,10,100,1000});
Integer slex = scoor[3]
+ 10 *scoor[2]
+ 100 *scoor[1]
+ 1000 *scoor[0];
#else
std::vector<int> powers=latt_size;
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];
#endif
Complex scm(slex);
@ -132,7 +152,7 @@ int main (int argc, char ** argv)
std::vector<int> peer(4);
Complex ctmp = cm;
Integer index=real(ctmp);
Lexicographic::CoorFromIndex(peer,index,latt_size);
Lexicographic::CoorFromIndex(peer,index,powers);
if (nrm > 0){
std::cout<<"FAIL shift "<< shift<<" in dir "<< dir
@ -140,14 +160,16 @@ int main (int argc, char ** argv)
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
index=real(scm);
Lexicographic::CoorFromIndex(peer,index,latt_size);
Lexicographic::CoorFromIndex(peer,index,powers);
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
exit(-1);
}
}}}}
std::cout<< " OK! "<<std::endl ;
int exx=0;
std::cout<<GridLogMessage << "Checking the checkerboard shift"<<std::endl;
std::cout<<GridLogMessage << " Checking the checkerboard shift "<< shift << " dir " << dir <<"... ";
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]++){
@ -169,18 +191,26 @@ int main (int argc, char ** argv)
std::vector<int> scoor(coor);
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
#ifdef POWER10
std::vector<int> powers({1,10,100,1000});
Integer slex = scoor[3]
+ 10 *scoor[2]
+ 100 *scoor[1]
+ 1000 *scoor[0];
#else
std::vector<int> powers = latt_size;
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];
#endif
Complex scm(slex);
std::vector<int> peer(4);
Complex ctmp=cmeo;
Integer index=real(ctmp);
Lexicographic::CoorFromIndex(peer,index,latt_size);
Lexicographic::CoorFromIndex(peer,index,powers);
double nrm = abs(cmeo()()()-scm);
if (nrm != 0) {
@ -189,10 +219,9 @@ int main (int argc, char ** argv)
<< cmeo()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
index=real(scm);
Lexicographic::CoorFromIndex(peer,index,latt_size);
Lexicographic::CoorFromIndex(peer,index,powers);
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
exx=1;
}
ctmp=cm;
@ -205,16 +234,17 @@ int main (int argc, char ** argv)
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
index=real(scm);
Lexicographic::CoorFromIndex(peer,index,latt_size);
Lexicographic::CoorFromIndex(peer,index,powers);
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
exx=1;
} else if (1) {
} else if (0) {
std::cout<<GridLogMessage<<"PASS shift "<< shift<<" in dir "<< dir
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
}
}}}}
if (exx) exit(-1);
std::cout<< " OK! "<<std::endl ;
}
}

View File

@ -45,7 +45,6 @@ int main (int argc, char ** argv)
LatticeComplex U(&Fine);
LatticeComplex ShiftU(&Fine);
LatticeComplex lex(&Fine);
lex=zero;
Integer stride =1;