mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-09 23:45:36 +00:00
Coordinate handling GPU friendly. Avoid std::vector
This commit is contained in:
parent
bb7d87d0a0
commit
285deab432
@ -41,12 +41,12 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
std::cout <<GridLogMessage<< " main "<<std::endl;
|
std::cout <<GridLogMessage<< " main "<<std::endl;
|
||||||
|
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
auto simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
auto mpi_layout = GridDefaultMpi();
|
||||||
//std::vector<int> latt_size ({48,48,48,96});
|
//std::vector<int> latt_size ({48,48,48,96});
|
||||||
//std::vector<int> latt_size ({32,32,32,32});
|
//std::vector<int> latt_size ({32,32,32,32});
|
||||||
std::vector<int> latt_size ({16,16,16,32});
|
Coordinate latt_size ({16,16,16,32});
|
||||||
std::vector<int> clatt_size ({4,4,4,8});
|
Coordinate clatt_size ({4,4,4,8});
|
||||||
int orthodir=3;
|
int orthodir=3;
|
||||||
int orthosz =latt_size[orthodir];
|
int orthosz =latt_size[orthodir];
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ int main (int argc, char ** argv)
|
|||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
int orthodir=3;
|
int orthodir=3;
|
||||||
int orthosz =latt_size[orthodir];
|
int orthosz =latt_size[orthodir];
|
||||||
|
|
||||||
|
@ -40,19 +40,18 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
std::cout <<GridLogMessage<< " main "<<std::endl;
|
std::cout <<GridLogMessage<< " main "<<std::endl;
|
||||||
|
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
//std::vector<int> latt_size ({48,48,48,96});
|
//std::vector<int> latt_size ({48,48,48,96});
|
||||||
//std::vector<int> latt_size ({32,32,32,32});
|
//std::vector<int> latt_size ({32,32,32,32});
|
||||||
std::vector<int> latt_size ({16,16,16,32});
|
Coordinate latt_size ({16,16,16,32});
|
||||||
std::vector<int> clatt_size ({4,4,4,8});
|
Coordinate clatt_size ({4,4,4,8});
|
||||||
int orthodir=3;
|
int orthodir=3;
|
||||||
int orthosz =latt_size[orthodir];
|
int orthosz =latt_size[orthodir];
|
||||||
|
|
||||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||||
GridCartesian Coarse(clatt_size,simd_layout,mpi_layout);
|
GridCartesian Coarse(clatt_size,simd_layout,mpi_layout);
|
||||||
|
|
||||||
|
|
||||||
GridParallelRNG pRNGa(&Fine);
|
GridParallelRNG pRNGa(&Fine);
|
||||||
GridParallelRNG pRNGb(&Fine);
|
GridParallelRNG pRNGb(&Fine);
|
||||||
GridSerialRNG sRNGa;
|
GridSerialRNG sRNGa;
|
||||||
|
@ -31,17 +31,14 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char ** argv)
|
int main (int argc, char ** argv)
|
||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
|
Coordinate simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
|
||||||
int orthodir=3;
|
int orthodir=3;
|
||||||
int orthosz =latt_size[orthodir];
|
int orthosz =latt_size[orthodir];
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
const int Ls=16;
|
const int Ls=16;
|
||||||
|
|
||||||
std::vector<int> latt4 =GridDefaultLatt();
|
auto latt4 =GridDefaultLatt();
|
||||||
|
|
||||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(latt4, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(latt4, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||||
|
@ -35,9 +35,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
auto latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
auto simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
auto mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
ShiftU = Cshift(U,dir,shift); // Shift everything
|
ShiftU = Cshift(U,dir,shift); // Shift everything
|
||||||
|
|
||||||
std::vector<int> coor(4);
|
Coordinate coor(4);
|
||||||
|
|
||||||
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
||||||
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
||||||
@ -89,7 +89,7 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
double nrm=norm2(U);
|
double nrm=norm2(U);
|
||||||
|
|
||||||
std::vector<int> scoor(coor);
|
Coordinate scoor(coor);
|
||||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||||
|
|
||||||
Integer slex = scoor[0]
|
Integer slex = scoor[0]
|
||||||
@ -100,7 +100,7 @@ int main (int argc, char ** argv)
|
|||||||
Complex scm(slex);
|
Complex scm(slex);
|
||||||
|
|
||||||
nrm = abs(scm-cm()()());
|
nrm = abs(scm-cm()()());
|
||||||
std::vector<int> peer(4);
|
Coordinate peer(4);
|
||||||
Complex tmp =cm;
|
Complex tmp =cm;
|
||||||
Integer index=real(tmp);
|
Integer index=real(tmp);
|
||||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||||
|
@ -127,10 +127,10 @@ void Tester(const functor &func)
|
|||||||
|
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
std::vector<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
std::vector<scal> input2(Nsimd);
|
ExtractBuffer<scal> input2(Nsimd);
|
||||||
std::vector<scal> result(Nsimd);
|
ExtractBuffer<scal> result(Nsimd);
|
||||||
std::vector<scal> reference(Nsimd);
|
ExtractBuffer<scal> reference(Nsimd);
|
||||||
|
|
||||||
std::vector<vec,alignedAllocator<vec> > buf(3);
|
std::vector<vec,alignedAllocator<vec> > buf(3);
|
||||||
vec & v_input1 = buf[0];
|
vec & v_input1 = buf[0];
|
||||||
@ -184,10 +184,10 @@ void IntTester(const functor &func)
|
|||||||
|
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
std::vector<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
std::vector<scal> input2(Nsimd);
|
ExtractBuffer<scal> input2(Nsimd);
|
||||||
std::vector<scal> result(Nsimd);
|
ExtractBuffer<scal> result(Nsimd);
|
||||||
std::vector<scal> reference(Nsimd);
|
ExtractBuffer<scal> reference(Nsimd);
|
||||||
|
|
||||||
std::vector<vec,alignedAllocator<vec> > buf(3);
|
std::vector<vec,alignedAllocator<vec> > buf(3);
|
||||||
vec & v_input1 = buf[0];
|
vec & v_input1 = buf[0];
|
||||||
@ -242,8 +242,8 @@ void ReductionTester(const functor &func)
|
|||||||
|
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
std::vector<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
std::vector<scal> input2(Nsimd);
|
ExtractBuffer<scal> input2(Nsimd);
|
||||||
reduced result(0);
|
reduced result(0);
|
||||||
reduced reference(0);
|
reduced reference(0);
|
||||||
reduced tmp;
|
reduced tmp;
|
||||||
@ -288,8 +288,8 @@ void IntReductionTester(const functor &func)
|
|||||||
{
|
{
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
std::vector<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
std::vector<scal> input2(Nsimd);
|
ExtractBuffer<scal> input2(Nsimd);
|
||||||
reduced result(0);
|
reduced result(0);
|
||||||
reduced reference(0);
|
reduced reference(0);
|
||||||
reduced tmp;
|
reduced tmp;
|
||||||
@ -333,7 +333,7 @@ public:
|
|||||||
int n;
|
int n;
|
||||||
funcPermute(int _n) { n=_n;};
|
funcPermute(int _n) { n=_n;};
|
||||||
template<class vec> void operator()(vec &rr,vec &i1,vec &i2) const { permute(rr,i1,n);}
|
template<class vec> void operator()(vec &rr,vec &i1,vec &i2) const { permute(rr,i1,n);}
|
||||||
template<class scal> void apply(std::vector<scal> &rr,std::vector<scal> &in) const {
|
template<class scal> void apply(ExtractBuffer<scal> &rr,ExtractBuffer<scal> &in) const {
|
||||||
int sz=in.size();
|
int sz=in.size();
|
||||||
int msk = sz>>(n+1);
|
int msk = sz>>(n+1);
|
||||||
for(int i=0;i<sz;i++){
|
for(int i=0;i<sz;i++){
|
||||||
@ -348,10 +348,10 @@ public:
|
|||||||
int n;
|
int n;
|
||||||
funcExchange(int _n) { n=_n;};
|
funcExchange(int _n) { n=_n;};
|
||||||
template<class vec> void operator()(vec &r1,vec &r2,vec &i1,vec &i2) const { exchange(r1,r2,i1,i2,n);}
|
template<class vec> void operator()(vec &r1,vec &r2,vec &i1,vec &i2) const { exchange(r1,r2,i1,i2,n);}
|
||||||
template<class scal> void apply(std::vector<scal> &r1,
|
template<class scal> void apply(ExtractBuffer<scal> &r1,
|
||||||
std::vector<scal> &r2,
|
ExtractBuffer<scal> &r2,
|
||||||
std::vector<scal> &in1,
|
ExtractBuffer<scal> &in1,
|
||||||
std::vector<scal> &in2) const
|
ExtractBuffer<scal> &in2) const
|
||||||
{
|
{
|
||||||
int sz=in1.size();
|
int sz=in1.size();
|
||||||
int msk = sz>>(n+1);
|
int msk = sz>>(n+1);
|
||||||
@ -374,7 +374,7 @@ public:
|
|||||||
int n;
|
int n;
|
||||||
funcRotate(int _n) { n=_n;};
|
funcRotate(int _n) { n=_n;};
|
||||||
template<class vec> void operator()(vec &rr,vec &i1,vec &i2) const { rr=rotate(i1,n);}
|
template<class vec> void operator()(vec &rr,vec &i1,vec &i2) const { rr=rotate(i1,n);}
|
||||||
template<class scal> void apply(std::vector<scal> &rr,std::vector<scal> &in) const {
|
template<class scal> void apply(ExtractBuffer<scal> &rr,ExtractBuffer<scal> &in) const {
|
||||||
int sz = in.size();
|
int sz = in.size();
|
||||||
for(int i=0;i<sz;i++){
|
for(int i=0;i<sz;i++){
|
||||||
rr[i] = in[(i+n)%sz];
|
rr[i] = in[(i+n)%sz];
|
||||||
@ -392,10 +392,10 @@ void PermTester(const functor &func)
|
|||||||
|
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
std::vector<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
std::vector<scal> input2(Nsimd);
|
ExtractBuffer<scal> input2(Nsimd);
|
||||||
std::vector<scal> result(Nsimd);
|
ExtractBuffer<scal> result(Nsimd);
|
||||||
std::vector<scal> reference(Nsimd);
|
ExtractBuffer<scal> reference(Nsimd);
|
||||||
|
|
||||||
std::vector<vec,alignedAllocator<vec> > buf(3);
|
std::vector<vec,alignedAllocator<vec> > buf(3);
|
||||||
vec & v_input1 = buf[0];
|
vec & v_input1 = buf[0];
|
||||||
@ -458,14 +458,14 @@ void ExchangeTester(const functor &func)
|
|||||||
|
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
std::vector<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
std::vector<scal> input2(Nsimd);
|
ExtractBuffer<scal> input2(Nsimd);
|
||||||
std::vector<scal> result1(Nsimd);
|
ExtractBuffer<scal> result1(Nsimd);
|
||||||
std::vector<scal> result2(Nsimd);
|
ExtractBuffer<scal> result2(Nsimd);
|
||||||
std::vector<scal> reference1(Nsimd);
|
ExtractBuffer<scal> reference1(Nsimd);
|
||||||
std::vector<scal> reference2(Nsimd);
|
ExtractBuffer<scal> reference2(Nsimd);
|
||||||
std::vector<scal> test1(Nsimd);
|
ExtractBuffer<scal> test1(Nsimd);
|
||||||
std::vector<scal> test2(Nsimd);
|
ExtractBuffer<scal> test2(Nsimd);
|
||||||
|
|
||||||
std::vector<vec,alignedAllocator<vec> > buf(6);
|
std::vector<vec,alignedAllocator<vec> > buf(6);
|
||||||
vec & v_input1 = buf[0];
|
vec & v_input1 = buf[0];
|
||||||
@ -547,9 +547,25 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
auto latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
auto simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
auto mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
|
{
|
||||||
|
std::cout << " Constructing Test({1,2,3,4,5,6}) " << std::endl;
|
||||||
|
Coordinate Test({1,2,3,4,5,6});
|
||||||
|
std::cout << " Test({1,2,3,4,5,6}) = " << Test <<std::endl;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
Coordinate Test = {1,2,3,4} ;
|
||||||
|
std::cout << " Test = {1,2,3,4} " << Test <<std::endl;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Coordinate Test {1,2,3,4};
|
||||||
|
std::cout << " Test {1,2,3,4} " << Test <<std::endl;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
std::vector<int> seeds({1,2,3,4});
|
std::vector<int> seeds({1,2,3,4});
|
||||||
|
@ -41,9 +41,9 @@ int main(int argc, char ** argv) {
|
|||||||
typedef typename Field::vector_object vobj;
|
typedef typename Field::vector_object vobj;
|
||||||
typedef typename vobj::scalar_object sobj;
|
typedef typename vobj::scalar_object sobj;
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
auto latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
auto simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
auto mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
double volume = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3];
|
double volume = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3];
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ int main(int argc, char ** argv) {
|
|||||||
std::vector<int> displacements(npoint,disp);
|
std::vector<int> displacements(npoint,disp);
|
||||||
|
|
||||||
Stencil myStencil(&Fine,npoint,0,directions,displacements);
|
Stencil myStencil(&Fine,npoint,0,directions,displacements);
|
||||||
std::vector<int> ocoor(4);
|
Coordinate ocoor(4);
|
||||||
for(int o=0;o<Fine.oSites();o++){
|
for(int o=0;o<Fine.oSites();o++){
|
||||||
Fine.oCoorFromOindex(ocoor,o);
|
Fine.oCoorFromOindex(ocoor,o);
|
||||||
ocoor[dir]=(ocoor[dir]+disp)%Fine._rdimensions[dir];
|
ocoor[dir]=(ocoor[dir]+disp)%Fine._rdimensions[dir];
|
||||||
@ -126,7 +126,7 @@ int main(int argc, char ** argv) {
|
|||||||
Real nrm = norm2(Diff);
|
Real nrm = norm2(Diff);
|
||||||
std::cout<<GridLogMessage<<"N2diff ="<<nrm<<" "<<nrmC<<" " <<nrmB<<std::endl;
|
std::cout<<GridLogMessage<<"N2diff ="<<nrm<<" "<<nrmC<<" " <<nrmB<<std::endl;
|
||||||
|
|
||||||
std::vector<int> coor(4);
|
Coordinate coor(4);
|
||||||
for(coor[3]=0;coor[3]<latt_size[3]/mpi_layout[3];coor[3]++){
|
for(coor[3]=0;coor[3]<latt_size[3]/mpi_layout[3];coor[3]++){
|
||||||
for(coor[2]=0;coor[2]<latt_size[2]/mpi_layout[2];coor[2]++){
|
for(coor[2]=0;coor[2]<latt_size[2]/mpi_layout[2];coor[2]++){
|
||||||
for(coor[1]=0;coor[1]<latt_size[1]/mpi_layout[1];coor[1]++){
|
for(coor[1]=0;coor[1]<latt_size[1]/mpi_layout[1];coor[1]++){
|
||||||
@ -180,7 +180,7 @@ int main(int argc, char ** argv) {
|
|||||||
Stencil EStencil(&rbFine,npoint,Even,directions,displacements);
|
Stencil EStencil(&rbFine,npoint,Even,directions,displacements);
|
||||||
Stencil OStencil(&rbFine,npoint,Odd,directions,displacements);
|
Stencil OStencil(&rbFine,npoint,Odd,directions,displacements);
|
||||||
|
|
||||||
std::vector<int> ocoor(4);
|
Coordinate ocoor(4);
|
||||||
for(int o=0;o<Fine.oSites();o++){
|
for(int o=0;o<Fine.oSites();o++){
|
||||||
Fine.oCoorFromOindex(ocoor,o);
|
Fine.oCoorFromOindex(ocoor,o);
|
||||||
ocoor[dir]=(ocoor[dir]+disp)%Fine._rdimensions[dir];
|
ocoor[dir]=(ocoor[dir]+disp)%Fine._rdimensions[dir];
|
||||||
@ -237,7 +237,7 @@ int main(int argc, char ** argv) {
|
|||||||
Real nrm = norm2(Diff);
|
Real nrm = norm2(Diff);
|
||||||
std::cout<<GridLogMessage<<"RB N2diff ="<<nrm<<" "<<nrmC<<" " <<nrmB<<std::endl;
|
std::cout<<GridLogMessage<<"RB N2diff ="<<nrm<<" "<<nrmC<<" " <<nrmB<<std::endl;
|
||||||
|
|
||||||
std::vector<int> coor(4);
|
Coordinate coor(4);
|
||||||
for(coor[3]=0;coor[3]<latt_size[3]/mpi_layout[3];coor[3]++){
|
for(coor[3]=0;coor[3]<latt_size[3]/mpi_layout[3];coor[3]++){
|
||||||
for(coor[2]=0;coor[2]<latt_size[2]/mpi_layout[2];coor[2]++){
|
for(coor[2]=0;coor[2]<latt_size[2]/mpi_layout[2];coor[2]++){
|
||||||
for(coor[1]=0;coor[1]<latt_size[1]/mpi_layout[1];coor[1]++){
|
for(coor[1]=0;coor[1]<latt_size[1]/mpi_layout[1];coor[1]++){
|
||||||
|
@ -59,10 +59,10 @@ int main (int argc, char ** argv)
|
|||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
std::vector<int> latt_size ({16,16,16,32});
|
Coordinate latt_size ({16,16,16,32});
|
||||||
std::vector<int> clatt_size ({4,4,4,8});
|
Coordinate clatt_size ({4,4,4,8});
|
||||||
int orthodir=3;
|
int orthodir=3;
|
||||||
int orthosz =latt_size[orthodir];
|
int orthosz =latt_size[orthodir];
|
||||||
|
|
||||||
|
@ -76,10 +76,10 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
std::vector<int> latt_size ({16,16,16,32});
|
Coordinate latt_size ({16,16,16,32});
|
||||||
std::vector<int> clatt_size ({4,4,4,8});
|
Coordinate clatt_size ({4,4,4,8});
|
||||||
int orthodir=3;
|
int orthodir=3;
|
||||||
int orthosz =latt_size[orthodir];
|
int orthosz =latt_size[orthodir];
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
assert(argc >= 5);
|
assert(argc >= 5);
|
||||||
|
|
||||||
std::vector<int> latt(4,0);
|
Coordinate latt(4,0);
|
||||||
latt[0] = toint(argv[1]);
|
latt[0] = toint(argv[1]);
|
||||||
latt[1] = toint(argv[2]);
|
latt[1] = toint(argv[2]);
|
||||||
latt[2] = toint(argv[3]);
|
latt[2] = toint(argv[3]);
|
||||||
@ -65,7 +65,7 @@ int main (int argc, char ** argv)
|
|||||||
const int Ls= toint(argv[5]);
|
const int Ls= toint(argv[5]);
|
||||||
|
|
||||||
std::cout << "Lattice size (" << latt[0] << "," << latt[1] << "," << latt[2] << "," << latt[3] << ") Ls=" << Ls << std::endl;
|
std::cout << "Lattice size (" << latt[0] << "," << latt[1] << "," << latt[2] << "," << latt[3] << ") Ls=" << Ls << std::endl;
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplexD::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplexD::Nsimd());
|
||||||
std::cout << "SIMD layout (" << simd_layout[0] << "," << simd_layout[1] << "," << simd_layout[2] << "," << simd_layout[3] << ")" << std::endl;
|
std::cout << "SIMD layout (" << simd_layout[0] << "," << simd_layout[1] << "," << simd_layout[2] << "," << simd_layout[3] << ")" << std::endl;
|
||||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(latt, simd_layout,GridDefaultMpi());
|
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(latt, simd_layout,GridDefaultMpi());
|
||||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||||
@ -85,8 +85,8 @@ int main (int argc, char ** argv)
|
|||||||
LatticeType src_o(FrbGrid);
|
LatticeType src_o(FrbGrid);
|
||||||
pickCheckerboard(Odd,src_o,src);
|
pickCheckerboard(Odd,src_o,src);
|
||||||
|
|
||||||
std::vector<int> site(5);
|
Coordinate site(5);
|
||||||
std::vector<int> cbsite(5);
|
Coordinate cbsite(5);
|
||||||
typedef typename GridTypeMapper<LatticeType::vector_object>::scalar_object sobj;
|
typedef typename GridTypeMapper<LatticeType::vector_object>::scalar_object sobj;
|
||||||
|
|
||||||
// std::cout << "sizeof(vobj) " << sizeof(LatticeType::vector_object) << std::endl;
|
// std::cout << "sizeof(vobj) " << sizeof(LatticeType::vector_object) << std::endl;
|
||||||
|
@ -29,7 +29,6 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
;
|
|
||||||
|
|
||||||
template<class d>
|
template<class d>
|
||||||
struct scal {
|
struct scal {
|
||||||
|
@ -38,12 +38,12 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
int Nd = latt_size.size();
|
int Nd = latt_size.size();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
std::vector<int> mask(Nd,1);
|
Coordinate mask(Nd,1);
|
||||||
mask[0]=0;
|
mask[0]=0;
|
||||||
|
|
||||||
GridCartesian Fine (latt_size,simd_layout,mpi_layout);
|
GridCartesian Fine (latt_size,simd_layout,mpi_layout);
|
||||||
@ -116,7 +116,7 @@ int main (int argc, char ** argv)
|
|||||||
err = ShiftU - rbShiftU;
|
err = ShiftU - rbShiftU;
|
||||||
std::cout<< "\terror " <<norm2(err)<<std::endl;
|
std::cout<< "\terror " <<norm2(err)<<std::endl;
|
||||||
|
|
||||||
std::vector<int> coor(4);
|
Coordinate coor(4);
|
||||||
|
|
||||||
std::cout<<GridLogMessage << " Checking the non-checkerboard shift "<<shift <<" dir "<<dir <<" ... ";
|
std::cout<<GridLogMessage << " Checking the non-checkerboard shift "<<shift <<" dir "<<dir <<" ... ";
|
||||||
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
||||||
@ -128,17 +128,17 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
///////// double nrm=norm2(U);
|
///////// double nrm=norm2(U);
|
||||||
|
|
||||||
std::vector<int> scoor(coor);
|
Coordinate scoor(coor);
|
||||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||||
|
|
||||||
#ifndef POWER10
|
#ifndef POWER10
|
||||||
std::vector<int> powers=latt_size;
|
Coordinate powers=latt_size;
|
||||||
Integer slex = scoor[0]
|
Integer slex = scoor[0]
|
||||||
+ latt_size[0]*scoor[1]
|
+ latt_size[0]*scoor[1]
|
||||||
+ latt_size[0]*latt_size[1]*scoor[2]
|
+ latt_size[0]*latt_size[1]*scoor[2]
|
||||||
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
||||||
#else
|
#else
|
||||||
std::vector<int> powers({1,10,100,1000});
|
Coordinate powers({1,10,100,1000});
|
||||||
Integer slex = scoor[0]
|
Integer slex = scoor[0]
|
||||||
+ 10 *scoor[1]
|
+ 10 *scoor[1]
|
||||||
+ 100 *scoor[2]
|
+ 100 *scoor[2]
|
||||||
@ -147,7 +147,7 @@ int main (int argc, char ** argv)
|
|||||||
Complex scm(slex);
|
Complex scm(slex);
|
||||||
|
|
||||||
double nrm = abs(scm-cm()()());
|
double nrm = abs(scm-cm()()());
|
||||||
std::vector<int> peer(4);
|
Coordinate peer(4);
|
||||||
Complex ctmp = cm;
|
Complex ctmp = cm;
|
||||||
Integer index=real(ctmp);
|
Integer index=real(ctmp);
|
||||||
Lexicographic::CoorFromIndex(peer,index,powers);
|
Lexicographic::CoorFromIndex(peer,index,powers);
|
||||||
@ -182,17 +182,17 @@ int main (int argc, char ** argv)
|
|||||||
peekSite(cmeo,ShiftUe,coor);
|
peekSite(cmeo,ShiftUe,coor);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> scoor(coor);
|
Coordinate scoor(coor);
|
||||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||||
|
|
||||||
#ifndef POWER10
|
#ifndef POWER10
|
||||||
std::vector<int> powers=latt_size;
|
Coordinate powers=latt_size;
|
||||||
Integer slex = scoor[0]
|
Integer slex = scoor[0]
|
||||||
+ latt_size[0]*scoor[1]
|
+ latt_size[0]*scoor[1]
|
||||||
+ latt_size[0]*latt_size[1]*scoor[2]
|
+ latt_size[0]*latt_size[1]*scoor[2]
|
||||||
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
||||||
#else
|
#else
|
||||||
std::vector<int> powers({1,10,100,1000});
|
Coordinate powers({1,10,100,1000});
|
||||||
Integer slex = scoor[0]
|
Integer slex = scoor[0]
|
||||||
+ 10 *scoor[1]
|
+ 10 *scoor[1]
|
||||||
+ 100 *scoor[2]
|
+ 100 *scoor[2]
|
||||||
@ -200,7 +200,7 @@ int main (int argc, char ** argv)
|
|||||||
#endif
|
#endif
|
||||||
Complex scm(slex);
|
Complex scm(slex);
|
||||||
|
|
||||||
std::vector<int> peer(4);
|
Coordinate peer(4);
|
||||||
Complex ctmp=cmeo;
|
Complex ctmp=cmeo;
|
||||||
Integer index=real(ctmp);
|
Integer index=real(ctmp);
|
||||||
Lexicographic::CoorFromIndex(peer,index,powers);
|
Lexicographic::CoorFromIndex(peer,index,powers);
|
||||||
|
@ -38,12 +38,12 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
int Nd = latt_size.size();
|
int Nd = latt_size.size();
|
||||||
std::vector<int> simd_layout( { vComplex::Nsimd(),1,1,1});
|
Coordinate simd_layout( { vComplex::Nsimd(),1,1,1});
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
std::vector<int> mask(Nd,1);
|
Coordinate mask(Nd,1);
|
||||||
mask[0]=0;
|
mask[0]=0;
|
||||||
|
|
||||||
GridCartesian Fine (latt_size,simd_layout,mpi_layout);
|
GridCartesian Fine (latt_size,simd_layout,mpi_layout);
|
||||||
@ -117,7 +117,7 @@ int main (int argc, char ** argv)
|
|||||||
err = ShiftU - rbShiftU;
|
err = ShiftU - rbShiftU;
|
||||||
std::cout<< "\terror " <<norm2(err)<<std::endl;
|
std::cout<< "\terror " <<norm2(err)<<std::endl;
|
||||||
|
|
||||||
std::vector<int> coor(4);
|
Coordinate coor(4);
|
||||||
|
|
||||||
std::cout<<GridLogMessage << " Checking the non-checkerboard shift "<< shift << " dir "<<dir <<"... ";
|
std::cout<<GridLogMessage << " Checking the non-checkerboard shift "<< shift << " dir "<<dir <<"... ";
|
||||||
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
||||||
@ -129,17 +129,17 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
///////// double nrm=norm2(U);
|
///////// double nrm=norm2(U);
|
||||||
|
|
||||||
std::vector<int> scoor(coor);
|
Coordinate scoor(coor);
|
||||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||||
|
|
||||||
#ifdef POWER10
|
#ifdef POWER10
|
||||||
std::vector<int> powers({1,10,100,1000});
|
Coordinate powers({1,10,100,1000});
|
||||||
Integer slex = scoor[3]
|
Integer slex = scoor[3]
|
||||||
+ 10 *scoor[2]
|
+ 10 *scoor[2]
|
||||||
+ 100 *scoor[1]
|
+ 100 *scoor[1]
|
||||||
+ 1000 *scoor[0];
|
+ 1000 *scoor[0];
|
||||||
#else
|
#else
|
||||||
std::vector<int> powers=latt_size;
|
Coordinate powers=latt_size;
|
||||||
Integer slex = scoor[0]
|
Integer slex = scoor[0]
|
||||||
+ latt_size[0]*scoor[1]
|
+ latt_size[0]*scoor[1]
|
||||||
+ latt_size[0]*latt_size[1]*scoor[2]
|
+ latt_size[0]*latt_size[1]*scoor[2]
|
||||||
@ -149,7 +149,7 @@ int main (int argc, char ** argv)
|
|||||||
Complex scm(slex);
|
Complex scm(slex);
|
||||||
|
|
||||||
double nrm = abs(scm-cm()()());
|
double nrm = abs(scm-cm()()());
|
||||||
std::vector<int> peer(4);
|
Coordinate peer(4);
|
||||||
Complex ctmp = cm;
|
Complex ctmp = cm;
|
||||||
Integer index=real(ctmp);
|
Integer index=real(ctmp);
|
||||||
Lexicographic::CoorFromIndex(peer,index,powers);
|
Lexicographic::CoorFromIndex(peer,index,powers);
|
||||||
@ -189,17 +189,17 @@ int main (int argc, char ** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> scoor(coor);
|
Coordinate scoor(coor);
|
||||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||||
|
|
||||||
#ifdef POWER10
|
#ifdef POWER10
|
||||||
std::vector<int> powers({1,10,100,1000});
|
Coordinate powers({1,10,100,1000});
|
||||||
Integer slex = scoor[3]
|
Integer slex = scoor[3]
|
||||||
+ 10 *scoor[2]
|
+ 10 *scoor[2]
|
||||||
+ 100 *scoor[1]
|
+ 100 *scoor[1]
|
||||||
+ 1000 *scoor[0];
|
+ 1000 *scoor[0];
|
||||||
#else
|
#else
|
||||||
std::vector<int> powers = latt_size;
|
Coordinate powers = latt_size;
|
||||||
Integer slex = scoor[0]
|
Integer slex = scoor[0]
|
||||||
+ latt_size[0]*scoor[1]
|
+ latt_size[0]*scoor[1]
|
||||||
+ latt_size[0]*latt_size[1]*scoor[2]
|
+ latt_size[0]*latt_size[1]*scoor[2]
|
||||||
@ -207,7 +207,7 @@ int main (int argc, char ** argv)
|
|||||||
#endif
|
#endif
|
||||||
Complex scm(slex);
|
Complex scm(slex);
|
||||||
|
|
||||||
std::vector<int> peer(4);
|
Coordinate peer(4);
|
||||||
Complex ctmp=cmeo;
|
Complex ctmp=cmeo;
|
||||||
Integer index=real(ctmp);
|
Integer index=real(ctmp);
|
||||||
Lexicographic::CoorFromIndex(peer,index,powers);
|
Lexicographic::CoorFromIndex(peer,index,powers);
|
||||||
|
@ -35,9 +35,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout( { vComplex::Nsimd(),1,1,1});
|
Coordinate simd_layout( { vComplex::Nsimd(),1,1,1});
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ int main (int argc, char ** argv)
|
|||||||
std::cout << "ShiftU[0]" << ShiftU[0]<<std::endl;
|
std::cout << "ShiftU[0]" << ShiftU[0]<<std::endl;
|
||||||
std::cout << "ShiftU[1]" << ShiftU[1]<<std::endl;
|
std::cout << "ShiftU[1]" << ShiftU[1]<<std::endl;
|
||||||
*/
|
*/
|
||||||
std::vector<int> coor(4);
|
Coordinate coor(4);
|
||||||
|
|
||||||
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
||||||
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
||||||
@ -87,7 +87,7 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
double nrm=norm2(U);
|
double nrm=norm2(U);
|
||||||
|
|
||||||
std::vector<int> scoor(coor);
|
Coordinate scoor(coor);
|
||||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||||
|
|
||||||
Integer slex = scoor[0]
|
Integer slex = scoor[0]
|
||||||
@ -98,7 +98,7 @@ int main (int argc, char ** argv)
|
|||||||
Complex scm(slex);
|
Complex scm(slex);
|
||||||
|
|
||||||
nrm = abs(scm-cm()()());
|
nrm = abs(scm-cm()()());
|
||||||
std::vector<int> peer(4);
|
Coordinate peer(4);
|
||||||
Complex tmp =cm;
|
Complex tmp =cm;
|
||||||
Integer index=real(tmp);
|
Integer index=real(tmp);
|
||||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||||
|
@ -113,7 +113,7 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
|
|
||||||
for(int lidx=0;lidx<FGrid->lSites();lidx++){
|
for(int lidx=0;lidx<FGrid->lSites();lidx++){
|
||||||
std::vector<int> lcoor;
|
Coordinate lcoor;
|
||||||
FGrid->LocalIndexToLocalCoor(lidx,lcoor);
|
FGrid->LocalIndexToLocalCoor(lidx,lcoor);
|
||||||
|
|
||||||
SpinColourVector siteSrc;
|
SpinColourVector siteSrc;
|
||||||
|
@ -38,9 +38,9 @@ int main (int argc, char ** argv)
|
|||||||
int threads = GridThread::GetThreads();
|
int threads = GridThread::GetThreads();
|
||||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout( { vComplexD::Nsimd(),1,1,1});
|
Coordinate simd_layout( { vComplexD::Nsimd(),1,1,1});
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
int vol = 1;
|
int vol = 1;
|
||||||
for(int d=0;d<latt_size.size();d++){
|
for(int d=0;d<latt_size.size();d++){
|
||||||
@ -60,7 +60,7 @@ int main (int argc, char ** argv)
|
|||||||
LatticeSpinMatrixD S(&GRID);
|
LatticeSpinMatrixD S(&GRID);
|
||||||
LatticeSpinMatrixD Stilde(&GRID);
|
LatticeSpinMatrixD Stilde(&GRID);
|
||||||
|
|
||||||
std::vector<int> p({1,3,2,3});
|
Coordinate p({1,3,2,3});
|
||||||
|
|
||||||
one = ComplexD(1.0,0.0);
|
one = ComplexD(1.0,0.0);
|
||||||
zz = ComplexD(0.0,0.0);
|
zz = ComplexD(0.0,0.0);
|
||||||
@ -294,7 +294,7 @@ int main (int argc, char ** argv)
|
|||||||
LatticeFermionD ref(&GRID);
|
LatticeFermionD ref(&GRID);
|
||||||
LatticeFermionD diff(&GRID);
|
LatticeFermionD diff(&GRID);
|
||||||
|
|
||||||
std::vector<int> point(4,0);
|
Coordinate point(4,0);
|
||||||
src=Zero();
|
src=Zero();
|
||||||
SpinColourVectorD ferm; gaussian(sRNG,ferm);
|
SpinColourVectorD ferm; gaussian(sRNG,ferm);
|
||||||
pokeSite(ferm,src,point);
|
pokeSite(ferm,src,point);
|
||||||
@ -373,7 +373,7 @@ int main (int argc, char ** argv)
|
|||||||
LatticeFermionD ref(&GRID);
|
LatticeFermionD ref(&GRID);
|
||||||
LatticeFermionD diff(&GRID);
|
LatticeFermionD diff(&GRID);
|
||||||
|
|
||||||
std::vector<int> point(4,0);
|
Coordinate point(4,0);
|
||||||
src=Zero();
|
src=Zero();
|
||||||
SpinColourVectorD ferm; gaussian(sRNG,ferm);
|
SpinColourVectorD ferm; gaussian(sRNG,ferm);
|
||||||
pokeSite(ferm,src,point);
|
pokeSite(ferm,src,point);
|
||||||
|
@ -39,9 +39,9 @@ int main (int argc, char ** argv)
|
|||||||
|
|
||||||
int threads = GridThread::GetThreads();
|
int threads = GridThread::GetThreads();
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout( { vComplex::Nsimd(),1,1,1});
|
Coordinate simd_layout( { vComplex::Nsimd(),1,1,1});
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
int vol = 1;
|
int vol = 1;
|
||||||
for(int d=0;d<latt_size.size();d++){
|
for(int d=0;d<latt_size.size();d++){
|
||||||
|
@ -38,9 +38,9 @@ int main (int argc, char ** argv)
|
|||||||
int threads = GridThread::GetThreads();
|
int threads = GridThread::GetThreads();
|
||||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout( { vComplexF::Nsimd(),1,1,1});
|
Coordinate simd_layout( { vComplexF::Nsimd(),1,1,1});
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
int vol = 1;
|
int vol = 1;
|
||||||
for(int d=0;d<latt_size.size();d++){
|
for(int d=0;d<latt_size.size();d++){
|
||||||
@ -57,7 +57,7 @@ int main (int argc, char ** argv)
|
|||||||
LatticeSpinMatrixF S(&Fine);
|
LatticeSpinMatrixF S(&Fine);
|
||||||
LatticeSpinMatrixF Stilde(&Fine);
|
LatticeSpinMatrixF Stilde(&Fine);
|
||||||
|
|
||||||
std::vector<int> p({1,2,3,2});
|
Coordinate p({1,2,3,2});
|
||||||
|
|
||||||
one = ComplexF(1.0,0.0);
|
one = ComplexF(1.0,0.0);
|
||||||
zz = ComplexF(0.0,0.0);
|
zz = ComplexF(0.0,0.0);
|
||||||
|
@ -236,9 +236,9 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
GridSerialRNG sRNG;
|
GridSerialRNG sRNG;
|
||||||
|
@ -84,18 +84,18 @@ int main (int argc, char ** argv)
|
|||||||
//const int L =4;
|
//const int L =4;
|
||||||
//std::vector<int> latt_2f(Nd,L);
|
//std::vector<int> latt_2f(Nd,L);
|
||||||
|
|
||||||
std::vector<int> latt_2f = GridDefaultLatt();
|
Coordinate latt_2f = GridDefaultLatt();
|
||||||
std::vector<int> latt_1f(latt_2f); latt_1f[nu] = 2*latt_2f[nu];
|
Coordinate latt_1f(latt_2f); latt_1f[nu] = 2*latt_2f[nu];
|
||||||
int L = latt_2f[nu];
|
int L = latt_2f[nu];
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplexType::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplexType::Nsimd());
|
||||||
|
|
||||||
std::cout << GridLogMessage << "SIMD layout: ";
|
std::cout << GridLogMessage << "SIMD layout: ";
|
||||||
for(int i=0;i<simd_layout.size();i++) std::cout << simd_layout[i] << " ";
|
for(int i=0;i<simd_layout.size();i++) std::cout << simd_layout[i] << " ";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi(); //node layout
|
Coordinate mpi_layout = GridDefaultMpi(); //node layout
|
||||||
|
|
||||||
GridCartesian * UGrid_1f = SpaceTimeGrid::makeFourDimGrid(latt_1f, simd_layout, mpi_layout);
|
GridCartesian * UGrid_1f = SpaceTimeGrid::makeFourDimGrid(latt_1f, simd_layout, mpi_layout);
|
||||||
GridRedBlackCartesian * UrbGrid_1f = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid_1f);
|
GridRedBlackCartesian * UrbGrid_1f = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid_1f);
|
||||||
|
@ -36,9 +36,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
GridRedBlackCartesian RBGrid(&Grid);
|
GridRedBlackCartesian RBGrid(&Grid);
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Grid_main.cc(232): error: no suitable user-defined conversion from
|
Grid_main.cc(232): error: no suitable user-defined conversion from
|
||||||
@ -58,9 +57,9 @@ auto peekDumKopf(const vobj &rhs, int i) -> decltype(peekIndex<3>(rhs, 0)) {
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
Grid_init(&argc, &argv);
|
Grid_init(&argc, &argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4, vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(4, vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
latt_size.resize(4);
|
latt_size.resize(4);
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
GridRedBlackCartesian RBGrid(&Grid);
|
GridRedBlackCartesian RBGrid(&Grid);
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
std::cout << GridLogMessage << "Making s innermost grids"<<std::endl;
|
std::cout << GridLogMessage << "Making s innermost grids"<<std::endl;
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls=16;
|
const int Ls=16;
|
||||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||||
@ -70,7 +70,7 @@ int main (int argc, char ** argv)
|
|||||||
FermionField src (FGrid);
|
FermionField src (FGrid);
|
||||||
random(pRNG5,src);
|
random(pRNG5,src);
|
||||||
/*
|
/*
|
||||||
std::vector<int> site({0,1,2,0,0});
|
Coordinate site({0,1,2,0,0});
|
||||||
ColourVector cv = Zero();
|
ColourVector cv = Zero();
|
||||||
cv()()(0)=1.0;
|
cv()()(0)=1.0;
|
||||||
src = Zero();
|
src = Zero();
|
||||||
|
@ -29,7 +29,6 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
;
|
|
||||||
|
|
||||||
template<class d>
|
template<class d>
|
||||||
struct scal {
|
struct scal {
|
||||||
@ -47,9 +46,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
GridRedBlackCartesian RBGrid(&Grid);
|
GridRedBlackCartesian RBGrid(&Grid);
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
GridRedBlackCartesian RBGrid(&Grid);
|
GridRedBlackCartesian RBGrid(&Grid);
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
;
|
|
||||||
|
|
||||||
template<class d>
|
template<class d>
|
||||||
struct scal {
|
struct scal {
|
||||||
@ -52,7 +51,6 @@ int main (int argc, char ** argv)
|
|||||||
int threads = GridThread::GetThreads();
|
int threads = GridThread::GetThreads();
|
||||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||||
|
|
||||||
|
|
||||||
const int Ls=10;
|
const int Ls=10;
|
||||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||||
|
@ -58,7 +58,7 @@ int main (int argc, char ** argv)
|
|||||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||||
|
|
||||||
// Construct a coarsened grid
|
// Construct a coarsened grid
|
||||||
std::vector<int> clatt = GridDefaultLatt();
|
Coordinate clatt = GridDefaultLatt();
|
||||||
for(int d=0;d<clatt.size();d++){
|
for(int d=0;d<clatt.size();d++){
|
||||||
clatt[d] = clatt[d]/2;
|
clatt[d] = clatt[d]/2;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ int main (int argc, char ** argv)
|
|||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
// Construct a coarsened grid; utility for this?
|
// Construct a coarsened grid; utility for this?
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
std::vector<int> clatt = GridDefaultLatt();
|
Coordinate clatt = GridDefaultLatt();
|
||||||
for(int d=0;d<clatt.size();d++){
|
for(int d=0;d<clatt.size();d++){
|
||||||
clatt[d] = clatt[d]/2;
|
clatt[d] = clatt[d]/2;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ int main(int argc,char **argv)
|
|||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> latt4 = GridDefaultLatt();
|
auto latt4 = GridDefaultLatt();
|
||||||
const int Ls=16;
|
const int Ls=16;
|
||||||
|
|
||||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(latt4, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(latt4, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||||
@ -63,8 +63,8 @@ int main(int argc,char **argv)
|
|||||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||||
|
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
auto simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
auto mpi_layout = GridDefaultMpi();
|
||||||
int threads = GridThread::GetThreads();
|
int threads = GridThread::GetThreads();
|
||||||
|
|
||||||
std::vector<int> seeds4({1,2,3,4});
|
std::vector<int> seeds4({1,2,3,4});
|
||||||
|
@ -29,15 +29,14 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
;
|
|
||||||
|
|
||||||
int main (int argc, char ** argv)
|
int main (int argc, char ** argv)
|
||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls=9;
|
const int Ls=9;
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls=8;
|
const int Ls=8;
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ int main (int argc, char** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc, &argv);
|
Grid_init(&argc, &argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls = 8;
|
const int Ls = 8;
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls=8;
|
const int Ls=8;
|
||||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||||
|
@ -41,9 +41,9 @@ int main (int argc, char** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc, &argv);
|
Grid_init(&argc, &argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls = 8;
|
const int Ls = 8;
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
GridRedBlackCartesian RBGrid(&Grid);
|
GridRedBlackCartesian RBGrid(&Grid);
|
||||||
|
@ -37,9 +37,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls=8;
|
const int Ls=8;
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls=8;
|
const int Ls=8;
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
GridRedBlackCartesian RBGrid(&Grid);
|
GridRedBlackCartesian RBGrid(&Grid);
|
||||||
|
@ -35,9 +35,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls=8;
|
const int Ls=8;
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ int main (int argc, char** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc, &argv);
|
Grid_init(&argc, &argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls = 8;
|
const int Ls = 8;
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ int main (int argc, char** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc, &argv);
|
Grid_init(&argc, &argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls = 8;
|
const int Ls = 8;
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls=9;
|
const int Ls=9;
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
GridRedBlackCartesian RBGrid(&Grid);
|
GridRedBlackCartesian RBGrid(&Grid);
|
||||||
|
@ -37,9 +37,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
GridRedBlackCartesian RBGrid(&Grid);
|
GridRedBlackCartesian RBGrid(&Grid);
|
||||||
|
@ -35,9 +35,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
Coordinate latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
Coordinate mpi_layout = GridDefaultMpi();
|
||||||
|
|
||||||
const int Ls=8;
|
const int Ls=8;
|
||||||
|
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
namespace Grid {
|
|
||||||
|
|
||||||
/*
|
|
||||||
BlockProjector
|
|
||||||
|
|
||||||
If _HP_BLOCK_PROJECTORS_ is defined, we assume that _evec is a basis that is not
|
|
||||||
fully orthonormalized (to the precision of the coarse field) and we allow for higher-precision
|
|
||||||
coarse field than basis field.
|
|
||||||
|
|
||||||
*/
|
|
||||||
//#define _HP_BLOCK_PROJECTORS_
|
|
||||||
|
|
||||||
template<typename Field>
|
|
||||||
class BlockProjector {
|
|
||||||
public:
|
|
||||||
|
|
||||||
BasisFieldVector<Field>& _evec;
|
|
||||||
BlockedGrid<Field>& _bgrid;
|
|
||||||
|
|
||||||
BlockProjector(BasisFieldVector<Field>& evec, BlockedGrid<Field>& bgrid) : _evec(evec), _bgrid(bgrid) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void createOrthonormalBasis(RealD thres = 0.0) {
|
|
||||||
|
|
||||||
GridStopWatch sw;
|
|
||||||
sw.Start();
|
|
||||||
|
|
||||||
int cnt = 0;
|
|
||||||
|
|
||||||
#pragma omp parallel shared(cnt)
|
|
||||||
{
|
|
||||||
int lcnt = 0;
|
|
||||||
|
|
||||||
#pragma omp for
|
|
||||||
for (int b=0;b<_bgrid._o_blocks;b++) {
|
|
||||||
|
|
||||||
for (int i=0;i<_evec._Nm;i++) {
|
|
||||||
|
|
||||||
auto nrm0 = _bgrid.block_sp(b,_evec._v[i],_evec._v[i]);
|
|
||||||
|
|
||||||
// |i> -= <j|i> |j>
|
|
||||||
for (int j=0;j<i;j++) {
|
|
||||||
_bgrid.block_caxpy(b,_evec._v[i],-_bgrid.block_sp(b,_evec._v[j],_evec._v[i]),_evec._v[j],_evec._v[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto nrm = _bgrid.block_sp(b,_evec._v[i],_evec._v[i]);
|
|
||||||
|
|
||||||
auto eps = nrm/nrm0;
|
|
||||||
if (Reduce(eps).real() < thres) {
|
|
||||||
lcnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: if norm is too small, remove this eigenvector/mark as not needed; in practice: set it to zero norm here and return a mask
|
|
||||||
// that is then used later to decide not to write certain eigenvectors to disk (add a norm calculation before subtraction step and look at nrm/nrm0 < eps to decide)
|
|
||||||
_bgrid.block_cscale(b,1.0 / sqrt(nrm),_evec._v[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma omp critical
|
|
||||||
{
|
|
||||||
cnt += lcnt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sw.Stop();
|
|
||||||
std::cout << GridLogMessage << "Gram-Schmidt to create blocked basis took " << sw.Elapsed() << " (" << ((RealD)cnt / (RealD)_bgrid._o_blocks / (RealD)_evec._Nm)
|
|
||||||
<< " below threshold)" << std::endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename CoarseField>
|
|
||||||
void coarseToFine(const CoarseField& in, Field& out) {
|
|
||||||
|
|
||||||
out = Zero();
|
|
||||||
out.Checkerboard() = _evec._v[0].Checkerboard();
|
|
||||||
|
|
||||||
int Nbasis = sizeof(in[0]._internal._internal) / sizeof(in[0]._internal._internal[0]);
|
|
||||||
assert(Nbasis == _evec._Nm);
|
|
||||||
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (int b=0;b<_bgrid._o_blocks;b++) {
|
|
||||||
for (int j=0;j<_evec._Nm;j++) {
|
|
||||||
_bgrid.block_caxpy(b,out,in[b]._internal._internal[j],_evec._v[j],out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename CoarseField>
|
|
||||||
void fineToCoarse(const Field& in, CoarseField& out) {
|
|
||||||
|
|
||||||
out = Zero();
|
|
||||||
|
|
||||||
int Nbasis = sizeof(out[0]._internal._internal) / sizeof(out[0]._internal._internal[0]);
|
|
||||||
assert(Nbasis == _evec._Nm);
|
|
||||||
|
|
||||||
|
|
||||||
Field tmp(_bgrid.Grid());
|
|
||||||
tmp = in;
|
|
||||||
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (int b=0;b<_bgrid._o_blocks;b++) {
|
|
||||||
for (int j=0;j<_evec._Nm;j++) {
|
|
||||||
// |rhs> -= <j|rhs> |j>
|
|
||||||
auto c = _bgrid.block_sp(b,_evec._v[j],tmp);
|
|
||||||
_bgrid.block_caxpy(b,tmp,-c,_evec._v[j],tmp); // may make this more numerically stable
|
|
||||||
out[b]._internal._internal[j] = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename CoarseField>
|
|
||||||
void deflateFine(BasisFieldVector<CoarseField>& _coef,const std::vector<RealD>& eval,int N,const Field& src_orig,Field& result) {
|
|
||||||
result = Zero();
|
|
||||||
for (int i=0;i<N;i++) {
|
|
||||||
Field tmp(result.Grid());
|
|
||||||
coarseToFine(_coef._v[i],tmp);
|
|
||||||
axpy(result,TensorRemove(innerProduct(tmp,src_orig)) / eval[i],tmp,result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename CoarseField>
|
|
||||||
void deflateCoarse(BasisFieldVector<CoarseField>& _coef,const std::vector<RealD>& eval,int N,const Field& src_orig,Field& result) {
|
|
||||||
CoarseField src_coarse(_coef._v[0].Grid());
|
|
||||||
CoarseField result_coarse = src_coarse;
|
|
||||||
result_coarse = Zero();
|
|
||||||
fineToCoarse(src_orig,src_coarse);
|
|
||||||
for (int i=0;i<N;i++) {
|
|
||||||
axpy(result_coarse,TensorRemove(innerProduct(_coef._v[i],src_coarse)) / eval[i],_coef._v[i],result_coarse);
|
|
||||||
}
|
|
||||||
coarseToFine(result_coarse,result);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename CoarseField>
|
|
||||||
void deflate(BasisFieldVector<CoarseField>& _coef,const std::vector<RealD>& eval,int N,const Field& src_orig,Field& result) {
|
|
||||||
// Deflation on coarse Grid is much faster, so use it by default. Deflation on fine Grid is kept for legacy reasons for now.
|
|
||||||
deflateCoarse(_coef,eval,N,src_orig,result);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,402 +0,0 @@
|
|||||||
namespace Grid {
|
|
||||||
|
|
||||||
template<typename Field>
|
|
||||||
class BlockedGrid {
|
|
||||||
public:
|
|
||||||
GridBase* _grid;
|
|
||||||
GridBase* Grid(void) { return _grid; };
|
|
||||||
typedef typename Field::scalar_type Coeff_t;
|
|
||||||
typedef typename Field::vector_type vCoeff_t;
|
|
||||||
|
|
||||||
std::vector<int> _bs; // block size
|
|
||||||
std::vector<int> _nb; // number of blocks
|
|
||||||
std::vector<int> _l; // local dimensions irrespective of cb
|
|
||||||
std::vector<int> _l_cb; // local dimensions of checkerboarded vector
|
|
||||||
std::vector<int> _l_cb_o; // local dimensions of inner checkerboarded vector
|
|
||||||
std::vector<int> _bs_cb; // block size in checkerboarded vector
|
|
||||||
std::vector<int> _nb_o; // number of blocks of simd o-sites
|
|
||||||
|
|
||||||
int _nd, _blocks, _cf_size, _cf_block_size, _cf_o_block_size, _o_blocks, _block_sites;
|
|
||||||
|
|
||||||
BlockedGrid(GridBase* grid, const std::vector<int>& block_size) :
|
|
||||||
_grid(grid), _bs(block_size), _nd((int)_bs.size()),
|
|
||||||
_nb(block_size), _l(block_size), _l_cb(block_size), _nb_o(block_size),
|
|
||||||
_l_cb_o(block_size), _bs_cb(block_size) {
|
|
||||||
|
|
||||||
_blocks = 1;
|
|
||||||
_o_blocks = 1;
|
|
||||||
_l = grid->FullDimensions();
|
|
||||||
_l_cb = grid->LocalDimensions();
|
|
||||||
_l_cb_o = grid->_rdimensions;
|
|
||||||
|
|
||||||
_cf_size = 1;
|
|
||||||
_block_sites = 1;
|
|
||||||
for (int i=0;i<_nd;i++) {
|
|
||||||
_l[i] /= grid->_processors[i];
|
|
||||||
|
|
||||||
assert(!(_l[i] % _bs[i])); // lattice must accommodate choice of blocksize
|
|
||||||
|
|
||||||
int r = _l[i] / _l_cb[i];
|
|
||||||
assert(!(_bs[i] % r)); // checkerboarding must accommodate choice of blocksize
|
|
||||||
_bs_cb[i] = _bs[i] / r;
|
|
||||||
_block_sites *= _bs_cb[i];
|
|
||||||
_nb[i] = _l[i] / _bs[i];
|
|
||||||
_nb_o[i] = _nb[i] / _grid->_simd_layout[i];
|
|
||||||
if (_nb[i] % _grid->_simd_layout[i]) { // simd must accommodate choice of blocksize
|
|
||||||
std::cout << GridLogMessage << "Problem: _nb[" << i << "] = " << _nb[i] << " _grid->_simd_layout[" << i << "] = " << _grid->_simd_layout[i] << std::endl;
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
_blocks *= _nb[i];
|
|
||||||
_o_blocks *= _nb_o[i];
|
|
||||||
_cf_size *= _l[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
_cf_size *= 12 / 2;
|
|
||||||
_cf_block_size = _cf_size / _blocks;
|
|
||||||
_cf_o_block_size = _cf_size / _o_blocks;
|
|
||||||
|
|
||||||
std::cout << GridLogMessage << "BlockedGrid:" << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _l = " << _l << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _l_cb = " << _l_cb << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _l_cb_o = " << _l_cb_o << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _bs = " << _bs << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _bs_cb = " << _bs_cb << std::endl;
|
|
||||||
|
|
||||||
std::cout << GridLogMessage << " _nb = " << _nb << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _nb_o = " << _nb_o << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _blocks = " << _blocks << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _o_blocks = " << _o_blocks << std::endl;
|
|
||||||
std::cout << GridLogMessage << " sizeof(vCoeff_t) = " << sizeof(vCoeff_t) << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _cf_size = " << _cf_size << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _cf_block_size = " << _cf_block_size << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _block_sites = " << _block_sites << std::endl;
|
|
||||||
std::cout << GridLogMessage << " _grid->oSites() = " << _grid->oSites() << std::endl;
|
|
||||||
|
|
||||||
// _grid->Barrier();
|
|
||||||
//abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
void block_to_coor(int b, std::vector<int>& x0) {
|
|
||||||
|
|
||||||
std::vector<int> bcoor;
|
|
||||||
bcoor.resize(_nd);
|
|
||||||
x0.resize(_nd);
|
|
||||||
assert(b < _o_blocks);
|
|
||||||
Lexicographic::CoorFromIndex(bcoor,b,_nb_o);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0;i<_nd;i++) {
|
|
||||||
x0[i] = bcoor[i]*_bs_cb[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
//std::cout << GridLogMessage << "Map block b -> " << x0 << std::endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void block_site_to_o_coor(const std::vector<int>& x0, std::vector<int>& coor, int i) {
|
|
||||||
Lexicographic::CoorFromIndex(coor,i,_bs_cb);
|
|
||||||
for (int j=0;j<_nd;j++)
|
|
||||||
coor[j] += x0[j];
|
|
||||||
}
|
|
||||||
|
|
||||||
int block_site_to_o_site(const std::vector<int>& x0, int i) {
|
|
||||||
std::vector<int> coor; coor.resize(_nd);
|
|
||||||
block_site_to_o_coor(x0,coor,i);
|
|
||||||
Lexicographic::IndexFromCoor(coor,i,_l_cb_o);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
vCoeff_t block_sp(int b, const Field& x, const Field& y) {
|
|
||||||
|
|
||||||
std::vector<int> x0;
|
|
||||||
block_to_coor(b,x0);
|
|
||||||
|
|
||||||
vCoeff_t ret = 0.0;
|
|
||||||
for (int i=0;i<_block_sites;i++) { // only odd sites
|
|
||||||
int ss = block_site_to_o_site(x0,i);
|
|
||||||
ret += TensorRemove(innerProduct(x[ss],y[ss]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
vCoeff_t block_sp(int b, const Field& x, const std::vector< ComplexD >& y) {
|
|
||||||
|
|
||||||
std::vector<int> x0;
|
|
||||||
block_to_coor(b,x0);
|
|
||||||
|
|
||||||
constexpr int nsimd = sizeof(vCoeff_t) / sizeof(Coeff_t);
|
|
||||||
int lsize = _cf_o_block_size / _block_sites;
|
|
||||||
|
|
||||||
std::vector< ComplexD > ret(nsimd);
|
|
||||||
for (int i=0;i<nsimd;i++)
|
|
||||||
ret[i] = 0.0;
|
|
||||||
|
|
||||||
for (int i=0;i<_block_sites;i++) { // only odd sites
|
|
||||||
int ss = block_site_to_o_site(x0,i);
|
|
||||||
|
|
||||||
int n = lsize / nsimd;
|
|
||||||
for (int l=0;l<n;l++) {
|
|
||||||
for (int j=0;j<nsimd;j++) {
|
|
||||||
int t = lsize * i + l*nsimd + j;
|
|
||||||
|
|
||||||
ret[j] += conjugate(((Coeff_t*)&x[ss]._internal)[l*nsimd + j]) * y[t];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vCoeff_t vret;
|
|
||||||
for (int i=0;i<nsimd;i++)
|
|
||||||
((Coeff_t*)&vret)[i] = (Coeff_t)ret[i];
|
|
||||||
|
|
||||||
return vret;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void vcaxpy(iScalar<T>& r,const vCoeff_t& a,const iScalar<T>& x,const iScalar<T>& y) {
|
|
||||||
vcaxpy(r._internal,a,x._internal,y._internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T,int N>
|
|
||||||
void vcaxpy(iVector<T,N>& r,const vCoeff_t& a,const iVector<T,N>& x,const iVector<T,N>& y) {
|
|
||||||
for (int i=0;i<N;i++)
|
|
||||||
vcaxpy(r._internal[i],a,x._internal[i],y._internal[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vcaxpy(vCoeff_t& r,const vCoeff_t& a,const vCoeff_t& x,const vCoeff_t& y) {
|
|
||||||
r = a*x + y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void block_caxpy(int b, Field& ret, const vCoeff_t& a, const Field& x, const Field& y) {
|
|
||||||
|
|
||||||
std::vector<int> x0;
|
|
||||||
block_to_coor(b,x0);
|
|
||||||
|
|
||||||
for (int i=0;i<_block_sites;i++) { // only odd sites
|
|
||||||
int ss = block_site_to_o_site(x0,i);
|
|
||||||
vcaxpy(ret[ss],a,x[ss],y[ss]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void block_caxpy(int b, std::vector< ComplexD >& ret, const vCoeff_t& a, const Field& x, const std::vector< ComplexD >& y) {
|
|
||||||
std::vector<int> x0;
|
|
||||||
block_to_coor(b,x0);
|
|
||||||
|
|
||||||
constexpr int nsimd = sizeof(vCoeff_t) / sizeof(Coeff_t);
|
|
||||||
int lsize = _cf_o_block_size / _block_sites;
|
|
||||||
|
|
||||||
for (int i=0;i<_block_sites;i++) { // only odd sites
|
|
||||||
int ss = block_site_to_o_site(x0,i);
|
|
||||||
|
|
||||||
int n = lsize / nsimd;
|
|
||||||
for (int l=0;l<n;l++) {
|
|
||||||
vCoeff_t r = a* ((vCoeff_t*)&x[ss]._internal)[l];
|
|
||||||
|
|
||||||
for (int j=0;j<nsimd;j++) {
|
|
||||||
int t = lsize * i + l*nsimd + j;
|
|
||||||
ret[t] = y[t] + ((Coeff_t*)&r)[j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void block_set(int b, Field& ret, const std::vector< ComplexD >& x) {
|
|
||||||
std::vector<int> x0;
|
|
||||||
block_to_coor(b,x0);
|
|
||||||
|
|
||||||
int lsize = _cf_o_block_size / _block_sites;
|
|
||||||
|
|
||||||
for (int i=0;i<_block_sites;i++) { // only odd sites
|
|
||||||
int ss = block_site_to_o_site(x0,i);
|
|
||||||
|
|
||||||
for (int l=0;l<lsize;l++)
|
|
||||||
((Coeff_t*)&ret[ss]._internal)[l] = (Coeff_t)x[lsize * i + l]; // convert precision
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void block_get(int b, const Field& ret, std::vector< ComplexD >& x) {
|
|
||||||
std::vector<int> x0;
|
|
||||||
block_to_coor(b,x0);
|
|
||||||
|
|
||||||
int lsize = _cf_o_block_size / _block_sites;
|
|
||||||
|
|
||||||
for (int i=0;i<_block_sites;i++) { // only odd sites
|
|
||||||
int ss = block_site_to_o_site(x0,i);
|
|
||||||
|
|
||||||
for (int l=0;l<lsize;l++)
|
|
||||||
x[lsize * i + l] = (ComplexD)((Coeff_t*)&ret[ss]._internal)[l];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void vcscale(iScalar<T>& r,const vCoeff_t& a,const iScalar<T>& x) {
|
|
||||||
vcscale(r._internal,a,x._internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T,int N>
|
|
||||||
void vcscale(iVector<T,N>& r,const vCoeff_t& a,const iVector<T,N>& x) {
|
|
||||||
for (int i=0;i<N;i++)
|
|
||||||
vcscale(r._internal[i],a,x._internal[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vcscale(vCoeff_t& r,const vCoeff_t& a,const vCoeff_t& x) {
|
|
||||||
r = a*x;
|
|
||||||
}
|
|
||||||
|
|
||||||
void block_cscale(int b, const vCoeff_t& a, Field& ret) {
|
|
||||||
|
|
||||||
std::vector<int> x0;
|
|
||||||
block_to_coor(b,x0);
|
|
||||||
|
|
||||||
for (int i=0;i<_block_sites;i++) { // only odd sites
|
|
||||||
int ss = block_site_to_o_site(x0,i);
|
|
||||||
vcscale(ret[ss],a,ret[ss]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void getCanonicalBlockOffset(int cb, std::vector<int>& x0) {
|
|
||||||
const int ndim = 5;
|
|
||||||
assert(_nb.size() == ndim);
|
|
||||||
std::vector<int> _nbc = { _nb[1], _nb[2], _nb[3], _nb[4], _nb[0] };
|
|
||||||
std::vector<int> _bsc = { _bs[1], _bs[2], _bs[3], _bs[4], _bs[0] };
|
|
||||||
x0.resize(ndim);
|
|
||||||
|
|
||||||
assert(cb >= 0);
|
|
||||||
assert(cb < _nbc[0]*_nbc[1]*_nbc[2]*_nbc[3]*_nbc[4]);
|
|
||||||
|
|
||||||
Lexicographic::CoorFromIndex(x0,cb,_nbc);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0;i<ndim;i++) {
|
|
||||||
x0[i] *= _bsc[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (cb < 2)
|
|
||||||
// std::cout << GridLogMessage << "Map: " << cb << " To: " << x0 << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pokeBlockOfVectorCanonical(int cb,Field& v,const std::vector<float>& buf) {
|
|
||||||
std::vector<int> _bsc = { _bs[1], _bs[2], _bs[3], _bs[4], _bs[0] };
|
|
||||||
std::vector<int> ldim = v.Grid()->LocalDimensions();
|
|
||||||
std::vector<int> cldim = { ldim[1], ldim[2], ldim[3], ldim[4], ldim[0] };
|
|
||||||
const int _nbsc = _bs_cb[0]*_bs_cb[1]*_bs_cb[2]*_bs_cb[3]*_bs_cb[4];
|
|
||||||
// take canonical block cb of v and put it in canonical ordering in buf
|
|
||||||
std::vector<int> cx0;
|
|
||||||
getCanonicalBlockOffset(cb,cx0);
|
|
||||||
|
|
||||||
#pragma omp parallel
|
|
||||||
{
|
|
||||||
std::vector<int> co0,cl0;
|
|
||||||
co0=cx0; cl0=cx0;
|
|
||||||
|
|
||||||
#pragma omp for
|
|
||||||
for (int i=0;i<_nbsc;i++) {
|
|
||||||
Lexicographic::CoorFromIndex(co0,2*i,_bsc); // 2* for eo
|
|
||||||
for (int j=0;j<(int)_bsc.size();j++)
|
|
||||||
cl0[j] = cx0[j] + co0[j];
|
|
||||||
|
|
||||||
std::vector<int> l0 = { cl0[4], cl0[0], cl0[1], cl0[2], cl0[3] };
|
|
||||||
int oi = v.Grid()->oIndex(l0);
|
|
||||||
int ii = v.Grid()->iIndex(l0);
|
|
||||||
int lti = i;
|
|
||||||
|
|
||||||
//if (cb < 2 && i<2)
|
|
||||||
// std::cout << GridLogMessage << "Map: " << cb << ", " << i << " To: " << cl0 << ", " << cx0 << ", " << oi << ", " << ii << std::endl;
|
|
||||||
|
|
||||||
for (int s=0;s<4;s++)
|
|
||||||
for (int c=0;c<3;c++) {
|
|
||||||
Coeff_t& ld = ((Coeff_t*)&v[oi]._internal._internal[s]._internal[c])[ii];
|
|
||||||
int ti = 12*lti + 3*s + c;
|
|
||||||
ld = Coeff_t(buf[2*ti+0], buf[2*ti+1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void peekBlockOfVectorCanonical(int cb,const Field& v,std::vector<float>& buf) {
|
|
||||||
std::vector<int> _bsc = { _bs[1], _bs[2], _bs[3], _bs[4], _bs[0] };
|
|
||||||
std::vector<int> ldim = v.Grid()->LocalDimensions();
|
|
||||||
std::vector<int> cldim = { ldim[1], ldim[2], ldim[3], ldim[4], ldim[0] };
|
|
||||||
const int _nbsc = _bs_cb[0]*_bs_cb[1]*_bs_cb[2]*_bs_cb[3]*_bs_cb[4];
|
|
||||||
// take canonical block cb of v and put it in canonical ordering in buf
|
|
||||||
std::vector<int> cx0;
|
|
||||||
getCanonicalBlockOffset(cb,cx0);
|
|
||||||
|
|
||||||
buf.resize(_cf_block_size * 2);
|
|
||||||
|
|
||||||
#pragma omp parallel
|
|
||||||
{
|
|
||||||
std::vector<int> co0,cl0;
|
|
||||||
co0=cx0; cl0=cx0;
|
|
||||||
|
|
||||||
#pragma omp for
|
|
||||||
for (int i=0;i<_nbsc;i++) {
|
|
||||||
Lexicographic::CoorFromIndex(co0,2*i,_bsc); // 2* for eo
|
|
||||||
for (int j=0;j<(int)_bsc.size();j++)
|
|
||||||
cl0[j] = cx0[j] + co0[j];
|
|
||||||
|
|
||||||
std::vector<int> l0 = { cl0[4], cl0[0], cl0[1], cl0[2], cl0[3] };
|
|
||||||
int oi = v.Grid()->oIndex(l0);
|
|
||||||
int ii = v.Grid()->iIndex(l0);
|
|
||||||
int lti = i;
|
|
||||||
|
|
||||||
//if (cb < 2 && i<2)
|
|
||||||
// std::cout << GridLogMessage << "Map: " << cb << ", " << i << " To: " << cl0 << ", " << cx0 << ", " << oi << ", " << ii << std::endl;
|
|
||||||
|
|
||||||
for (int s=0;s<4;s++)
|
|
||||||
for (int c=0;c<3;c++) {
|
|
||||||
Coeff_t& ld = ((Coeff_t*)&v[oi]._internal._internal[s]._internal[c])[ii];
|
|
||||||
int ti = 12*lti + 3*s + c;
|
|
||||||
buf[2*ti+0] = ld.real();
|
|
||||||
buf[2*ti+1] = ld.imag();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int globalToLocalCanonicalBlock(int slot,const std::vector<int>& src_nodes,int nb) {
|
|
||||||
// processor coordinate
|
|
||||||
int _nd = (int)src_nodes.size();
|
|
||||||
std::vector<int> _src_nodes = src_nodes;
|
|
||||||
std::vector<int> pco(_nd);
|
|
||||||
Lexicographic::CoorFromIndex(pco,slot,_src_nodes);
|
|
||||||
std::vector<int> cpco = { pco[1], pco[2], pco[3], pco[4], pco[0] };
|
|
||||||
|
|
||||||
// get local block
|
|
||||||
std::vector<int> _nbc = { _nb[1], _nb[2], _nb[3], _nb[4], _nb[0] };
|
|
||||||
assert(_nd == 5);
|
|
||||||
std::vector<int> c_src_local_blocks(_nd);
|
|
||||||
for (int i=0;i<_nd;i++) {
|
|
||||||
assert(_grid->_fdimensions[i] % (src_nodes[i] * _bs[i]) == 0);
|
|
||||||
c_src_local_blocks[(i+4) % 5] = _grid->_fdimensions[i] / src_nodes[i] / _bs[i];
|
|
||||||
}
|
|
||||||
std::vector<int> cbcoor(_nd); // coordinate of block in slot in canonical form
|
|
||||||
Lexicographic::CoorFromIndex(cbcoor,nb,c_src_local_blocks);
|
|
||||||
|
|
||||||
// cpco, cbcoor
|
|
||||||
std::vector<int> clbcoor(_nd);
|
|
||||||
for (int i=0;i<_nd;i++) {
|
|
||||||
int cgcoor = cpco[i] * c_src_local_blocks[i] + cbcoor[i]; // global block coordinate
|
|
||||||
int pcoor = cgcoor / _nbc[i]; // processor coordinate in my Grid
|
|
||||||
int tpcoor = _grid->_processor_coor[(i+1)%5];
|
|
||||||
if (pcoor != tpcoor)
|
|
||||||
return -1;
|
|
||||||
clbcoor[i] = cgcoor - tpcoor * _nbc[i]; // canonical local block coordinate for canonical dimension i
|
|
||||||
}
|
|
||||||
|
|
||||||
int lnb;
|
|
||||||
Lexicographic::IndexFromCoor(clbcoor,lnb,_nbc);
|
|
||||||
//std::cout << "Mapped slot = " << slot << " nb = " << nb << " to " << lnb << std::endl;
|
|
||||||
return lnb;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
namespace Grid {
|
|
||||||
|
|
||||||
template<class Field>
|
|
||||||
class BasisFieldVector {
|
|
||||||
public:
|
|
||||||
int _Nm;
|
|
||||||
|
|
||||||
typedef typename Field::scalar_type Coeff_t;
|
|
||||||
typedef typename Field::vector_type vCoeff_t;
|
|
||||||
typedef typename Field::vector_object vobj;
|
|
||||||
typedef typename vobj::scalar_object sobj;
|
|
||||||
|
|
||||||
std::vector<Field> _v; // _Nfull vectors
|
|
||||||
|
|
||||||
void report(int n,GridBase* value) {
|
|
||||||
|
|
||||||
std::cout << GridLogMessage << "BasisFieldVector allocated:\n";
|
|
||||||
std::cout << GridLogMessage << " Delta N = " << n << "\n";
|
|
||||||
std::cout << GridLogMessage << " Size of full vectors (size) = " <<
|
|
||||||
((double)n*sizeof(vobj)*value->oSites() / 1024./1024./1024.) << " GB\n";
|
|
||||||
std::cout << GridLogMessage << " Size = " << _v.size() << " Capacity = " << _v.capacity() << std::endl;
|
|
||||||
|
|
||||||
value->Barrier();
|
|
||||||
|
|
||||||
#ifdef __linux
|
|
||||||
if (value->IsBoss()) {
|
|
||||||
system("cat /proc/meminfo");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
value->Barrier();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
BasisFieldVector(int Nm,GridBase* value) : _Nm(Nm), _v(Nm,value) {
|
|
||||||
report(Nm,value);
|
|
||||||
}
|
|
||||||
|
|
||||||
~BasisFieldVector() {
|
|
||||||
}
|
|
||||||
|
|
||||||
Field& operator[](int i) {
|
|
||||||
return _v[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
void orthogonalize(Field& w, int k) {
|
|
||||||
basisOrthogonalize(_v,w,k);
|
|
||||||
}
|
|
||||||
|
|
||||||
void rotate(Eigen::MatrixXd& Qt,int j0, int j1, int k0,int k1,int Nm) {
|
|
||||||
basisRotate(_v,Qt,j0,j1,k0,k1,Nm);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size() const {
|
|
||||||
return _Nm;
|
|
||||||
}
|
|
||||||
|
|
||||||
void resize(int n) {
|
|
||||||
if (n > _Nm)
|
|
||||||
_v.reserve(n);
|
|
||||||
|
|
||||||
_v.resize(n,_v[0].Grid());
|
|
||||||
|
|
||||||
if (n < _Nm)
|
|
||||||
_v.shrink_to_fit();
|
|
||||||
|
|
||||||
report(n - _Nm,_v[0].Grid());
|
|
||||||
|
|
||||||
_Nm = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
void sortInPlace(std::vector<RealD>& sort_vals, bool reverse) {
|
|
||||||
basisSortInPlace(_v,sort_vals,reverse);
|
|
||||||
}
|
|
||||||
|
|
||||||
void deflate(const std::vector<RealD>& eval,const Field& src_orig,Field& result) {
|
|
||||||
basisDeflate(_v,eval,src_orig,result);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,136 +0,0 @@
|
|||||||
/*
|
|
||||||
Params IO
|
|
||||||
|
|
||||||
Author: Christoph Lehner
|
|
||||||
Date: 2017
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define PADD(p,X) p.get(#X,X);
|
|
||||||
|
|
||||||
class Params {
|
|
||||||
protected:
|
|
||||||
|
|
||||||
std::string trim(const std::string& sc) {
|
|
||||||
std::string s = sc;
|
|
||||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
|
|
||||||
std::not1(std::ptr_fun<int, int>(std::isspace))));
|
|
||||||
s.erase(std::find_if(s.rbegin(), s.rend(),
|
|
||||||
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
std::map< std::string, std::string > lines;
|
|
||||||
std::string _fn;
|
|
||||||
|
|
||||||
Params(const char* fn) : _fn(fn) {
|
|
||||||
FILE* f = fopen(fn,"rt");
|
|
||||||
assert(f);
|
|
||||||
while (!feof(f)) {
|
|
||||||
char buf[4096];
|
|
||||||
if (fgets(buf,sizeof(buf),f)) {
|
|
||||||
if (buf[0] != '#' && buf[0] != '\r' && buf[0] != '\n') {
|
|
||||||
char* sep = strchr(buf,'=');
|
|
||||||
assert(sep);
|
|
||||||
*sep = '\0';
|
|
||||||
lines[trim(buf)] = trim(sep+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Params() {
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string loghead() {
|
|
||||||
return _fn + ": ";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool has(const char* name) {
|
|
||||||
auto f = lines.find(name);
|
|
||||||
return (f != lines.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& get(const char* name) {
|
|
||||||
auto f = lines.find(name);
|
|
||||||
if (f == lines.end()) {
|
|
||||||
std::cout << Grid::GridLogMessage << loghead() << "Could not find value for " << name << std::endl;
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
return f->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse(std::string& s, const std::string& cval) {
|
|
||||||
std::stringstream trimmer;
|
|
||||||
trimmer << cval;
|
|
||||||
s.clear();
|
|
||||||
trimmer >> s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse(int& i, const std::string& cval) {
|
|
||||||
assert(sscanf(cval.c_str(),"%d",&i)==1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse(long long& i, const std::string& cval) {
|
|
||||||
assert(sscanf(cval.c_str(),"%lld",&i)==1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse(double& f, const std::string& cval) {
|
|
||||||
assert(sscanf(cval.c_str(),"%lf",&f)==1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse(float& f, const std::string& cval) {
|
|
||||||
assert(sscanf(cval.c_str(),"%f",&f)==1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse(bool& b, const std::string& cval) {
|
|
||||||
std::string lcval = cval;
|
|
||||||
std::transform(lcval.begin(), lcval.end(), lcval.begin(), ::tolower);
|
|
||||||
if (lcval == "true" || lcval == "yes") {
|
|
||||||
b = true;
|
|
||||||
} else if (lcval == "false" || lcval == "no") {
|
|
||||||
b = false;
|
|
||||||
} else {
|
|
||||||
std::cout << "Invalid value for boolean: " << b << std::endl;
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse(std::complex<double>& f, const std::string& cval) {
|
|
||||||
double r,i;
|
|
||||||
assert(sscanf(cval.c_str(),"%lf %lf",&r,&i)==2);
|
|
||||||
f = std::complex<double>(r,i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse(std::complex<float>& f, const std::string& cval) {
|
|
||||||
float r,i;
|
|
||||||
assert(sscanf(cval.c_str(),"%f %f",&r,&i)==2);
|
|
||||||
f = std::complex<float>(r,i);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void get(const char* name, std::vector<T>& v) {
|
|
||||||
int i = 0;
|
|
||||||
v.resize(0);
|
|
||||||
while (true) {
|
|
||||||
char buf[4096];
|
|
||||||
sprintf(buf,"%s[%d]",name,i++);
|
|
||||||
if (!has(buf))
|
|
||||||
break;
|
|
||||||
T val;
|
|
||||||
parse(val,get(buf));
|
|
||||||
std::cout << Grid::GridLogMessage << loghead() << "Set " << buf << " to " << val << std::endl;
|
|
||||||
v.push_back(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void get(const char* name, T& f) {
|
|
||||||
parse(f,get(name));
|
|
||||||
std::cout << Grid::GridLogMessage << loghead() << "Set " << name << " to " << f << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
@ -1,712 +0,0 @@
|
|||||||
/*
|
|
||||||
Authors: Christoph Lehner
|
|
||||||
Date: 2017
|
|
||||||
|
|
||||||
Multigrid Lanczos
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TODO:
|
|
||||||
|
|
||||||
High priority:
|
|
||||||
- Explore filtering of starting vector again, should really work: If cheby has 4 for low mode region and 1 for high mode, applying 15 iterations has 1e9 suppression
|
|
||||||
of high modes, which should create the desired invariant subspace already? Missing something here??? Maybe dynamic range dangerous, i.e., could also kill interesting
|
|
||||||
eigenrange if not careful.
|
|
||||||
|
|
||||||
Better: Use all Cheby up to order N in order to approximate a step function; try this! Problem: width of step function. Can kill eigenspace > 1e-3 and have < 1e-5 equal
|
|
||||||
to 1
|
|
||||||
|
|
||||||
Low priority:
|
|
||||||
- Given that I seem to need many restarts and high degree poly to create the base and this takes about 1 day, seriously consider a simple method to create a basis
|
|
||||||
(ortho krylov low poly); and then fix up lowest say 200 eigenvalues by 1 run with high-degree poly (600 could be enough)
|
|
||||||
*/
|
|
||||||
#include <Grid/Grid.h>
|
|
||||||
#include <Grid/algorithms/iterative/ImplicitlyRestartedLanczos.h>
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// The following are now decoupled from the Lanczos and deal with grids.
|
|
||||||
// Safe to replace functionality
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
#include "BlockedGrid.h"
|
|
||||||
#include "FieldBasisVector.h"
|
|
||||||
#include "BlockProjector.h"
|
|
||||||
#include "FieldVectorIO.h"
|
|
||||||
#include "Params.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace Grid;
|
|
||||||
;
|
|
||||||
|
|
||||||
bool read_evals(GridBase* _grid, char* fn, std::vector<RealD>& evals) {
|
|
||||||
|
|
||||||
FILE* f = 0;
|
|
||||||
uint32_t status = 0;
|
|
||||||
if (_grid->IsBoss()) {
|
|
||||||
f = fopen(fn,"rt");
|
|
||||||
status = f ? 1 : 0;
|
|
||||||
}
|
|
||||||
_grid->GlobalSum(status);
|
|
||||||
|
|
||||||
if (!status)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32_t N;
|
|
||||||
if (f)
|
|
||||||
assert(fscanf(f,"%d\n",&N)==1);
|
|
||||||
else
|
|
||||||
N = 0;
|
|
||||||
_grid->GlobalSum(N);
|
|
||||||
|
|
||||||
std::cout << "Reading " << N << " eigenvalues" << std::endl;
|
|
||||||
|
|
||||||
evals.resize(N);
|
|
||||||
|
|
||||||
for (int i=0;i<N;i++) {
|
|
||||||
if (f)
|
|
||||||
assert(fscanf(f,"%lf",&evals[i])==1);
|
|
||||||
else
|
|
||||||
evals[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_grid->GlobalSumVector(&evals[0],evals.size());
|
|
||||||
|
|
||||||
if (f)
|
|
||||||
fclose(f);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_evals(char* fn, std::vector<RealD>& evals) {
|
|
||||||
FILE* f = fopen(fn,"wt");
|
|
||||||
assert(f);
|
|
||||||
|
|
||||||
int N = (int)evals.size();
|
|
||||||
fprintf(f,"%d\n",N);
|
|
||||||
|
|
||||||
for (int i=0;i<N;i++) {
|
|
||||||
fprintf(f,"%.15E\n",evals[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_history(char* fn, std::vector<RealD>& hist) {
|
|
||||||
FILE* f = fopen(fn,"wt");
|
|
||||||
assert(f);
|
|
||||||
|
|
||||||
int N = (int)hist.size();
|
|
||||||
for (int i=0;i<N;i++) {
|
|
||||||
fprintf(f,"%d %.15E\n",i,hist[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename Field>
|
|
||||||
class CheckpointedLinearFunction : public LinearFunction<Field> {
|
|
||||||
public:
|
|
||||||
LinearFunction<Field>& _op;
|
|
||||||
std::string _dir;
|
|
||||||
int _max_apply;
|
|
||||||
int _apply, _apply_actual;
|
|
||||||
GridBase* _grid;
|
|
||||||
FILE* _f;
|
|
||||||
|
|
||||||
CheckpointedLinearFunction(GridBase* grid, LinearFunction<Field>& op, const char* dir,int max_apply) : _op(op), _dir(dir), _grid(grid), _f(0),
|
|
||||||
_max_apply(max_apply), _apply(0), _apply_actual(0) {
|
|
||||||
|
|
||||||
FieldVectorIO::conditionalMkDir(dir);
|
|
||||||
|
|
||||||
char fn[4096];
|
|
||||||
sprintf(fn,"%s/ckpt_op.%4.4d",_dir.c_str(),_grid->ThisRank());
|
|
||||||
printf("CheckpointLinearFunction:: file %s\n",fn);
|
|
||||||
_f = fopen(fn,"r+b");
|
|
||||||
if (!_f)
|
|
||||||
_f = fopen(fn,"w+b");
|
|
||||||
assert(_f);
|
|
||||||
fseek(_f,0,SEEK_CUR);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
~CheckpointedLinearFunction() {
|
|
||||||
if (_f) {
|
|
||||||
fclose(_f);
|
|
||||||
_f = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool load_ckpt(const Field& in, Field& out) {
|
|
||||||
|
|
||||||
off_t cur = ftello(_f);
|
|
||||||
fseeko(_f,0,SEEK_END);
|
|
||||||
if (cur == ftello(_f))
|
|
||||||
return false;
|
|
||||||
fseeko(_f,cur,SEEK_SET);
|
|
||||||
|
|
||||||
size_t sz = sizeof(out[0]) * out.size();
|
|
||||||
|
|
||||||
GridStopWatch gsw;
|
|
||||||
gsw.Start();
|
|
||||||
uint32_t crc_exp;
|
|
||||||
assert(fread(&crc_exp,4,1,_f)==1);
|
|
||||||
assert(fread(&out[0],sz,1,_f)==1);
|
|
||||||
assert(FieldVectorIO::crc32_threaded((unsigned char*)&out[0],sz,0x0)==crc_exp);
|
|
||||||
gsw.Stop();
|
|
||||||
|
|
||||||
printf("CheckpointLinearFunction:: reading %lld\n",(long long)sz);
|
|
||||||
std::cout << GridLogMessage << "Loading " << ((RealD)sz/1024./1024./1024.) << " GB in " << gsw.Elapsed() << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void save_ckpt(const Field& in, Field& out) {
|
|
||||||
|
|
||||||
fseek(_f,0,SEEK_CUR); // switch to write
|
|
||||||
|
|
||||||
size_t sz = sizeof(out[0]) * out.size();
|
|
||||||
|
|
||||||
GridStopWatch gsw;
|
|
||||||
gsw.Start();
|
|
||||||
uint32_t crc = FieldVectorIO::crc32_threaded((unsigned char*)&out[0],sz,0x0);
|
|
||||||
assert(fwrite(&crc,4,1,_f)==1);
|
|
||||||
assert(fwrite(&out[0],sz,1,_f)==1);
|
|
||||||
fflush(_f); // try this on the GPFS to suppress OPA usage for disk during dslash; this is not needed at Lustre/JLAB
|
|
||||||
gsw.Stop();
|
|
||||||
|
|
||||||
printf("CheckpointLinearFunction:: writing %lld\n",(long long)sz);
|
|
||||||
std::cout << GridLogMessage << "Saving " << ((RealD)sz/1024./1024./1024.) << " GB in " << gsw.Elapsed() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(const Field& in, Field& out) {
|
|
||||||
|
|
||||||
_apply++;
|
|
||||||
|
|
||||||
if (load_ckpt(in,out))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_op(in,out);
|
|
||||||
|
|
||||||
save_ckpt(in,out);
|
|
||||||
|
|
||||||
if (_apply_actual++ >= _max_apply) {
|
|
||||||
std::cout << GridLogMessage << "Maximum application of operator reached, checkpoint and finish in future job" << std::endl;
|
|
||||||
if (_f) { fclose(_f); _f=0; }
|
|
||||||
in.Grid()->Barrier();
|
|
||||||
Grid_finalize();
|
|
||||||
exit(3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename CoarseField,typename Field>
|
|
||||||
class ProjectedFunctionHermOp : public LinearFunction<CoarseField> {
|
|
||||||
public:
|
|
||||||
OperatorFunction<Field> & _poly;
|
|
||||||
LinearOperatorBase<Field> &_Linop;
|
|
||||||
BlockProjector<Field>& _pr;
|
|
||||||
|
|
||||||
ProjectedFunctionHermOp(BlockProjector<Field>& pr,OperatorFunction<Field> & poly,LinearOperatorBase<Field>& linop) : _poly(poly), _Linop(linop), _pr(pr) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(const CoarseField& in, CoarseField& out) {
|
|
||||||
assert(_pr._bgrid._o_blocks == in.Grid()->oSites());
|
|
||||||
|
|
||||||
Field fin(_pr._bgrid.Grid());
|
|
||||||
Field fout(_pr._bgrid.Grid());
|
|
||||||
|
|
||||||
GridStopWatch gsw1,gsw2,gsw3;
|
|
||||||
// fill fin
|
|
||||||
gsw1.Start();
|
|
||||||
_pr.coarseToFine(in,fin);
|
|
||||||
gsw1.Stop();
|
|
||||||
|
|
||||||
// apply poly
|
|
||||||
gsw2.Start();
|
|
||||||
_poly(_Linop,fin,fout);
|
|
||||||
gsw2.Stop();
|
|
||||||
|
|
||||||
// fill out
|
|
||||||
gsw3.Start();
|
|
||||||
_pr.fineToCoarse(fout,out);
|
|
||||||
gsw3.Stop();
|
|
||||||
|
|
||||||
auto eps = innerProduct(in,out);
|
|
||||||
std::cout << GridLogMessage << "Operator timing details: c2f = " << gsw1.Elapsed() << " poly = " << gsw2.Elapsed() << " f2c = " << gsw3.Elapsed() <<
|
|
||||||
" Complimentary Hermiticity check: " << eps.imag() / std::abs(eps) << std::endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename CoarseField,typename Field>
|
|
||||||
class ProjectedHermOp : public LinearFunction<CoarseField> {
|
|
||||||
public:
|
|
||||||
LinearOperatorBase<Field> &_Linop;
|
|
||||||
BlockProjector<Field>& _pr;
|
|
||||||
|
|
||||||
ProjectedHermOp(BlockProjector<Field>& pr,LinearOperatorBase<Field>& linop) : _Linop(linop), _pr(pr) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()(const CoarseField& in, CoarseField& out) {
|
|
||||||
assert(_pr._bgrid._o_blocks == in.Grid()->oSites());
|
|
||||||
Field fin(_pr._bgrid.Grid());
|
|
||||||
Field fout(_pr._bgrid.Grid());
|
|
||||||
_pr.coarseToFine(in,fin);
|
|
||||||
_Linop.HermOp(fin,fout);
|
|
||||||
_pr.fineToCoarse(fout,out);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename vtype, int N > using CoarseSiteFieldGeneral = iScalar< iVector<vtype, N> >;
|
|
||||||
template<int N> using CoarseSiteFieldD = CoarseSiteFieldGeneral< vComplexD, N >;
|
|
||||||
template<int N> using CoarseSiteFieldF = CoarseSiteFieldGeneral< vComplexF, N >;
|
|
||||||
template<int N> using CoarseSiteField = CoarseSiteFieldGeneral< vComplex, N >;
|
|
||||||
template<int N> using CoarseLatticeFermion = Lattice< CoarseSiteField<N> >;
|
|
||||||
template<int N> using CoarseLatticeFermionD = Lattice< CoarseSiteFieldD<N> >;
|
|
||||||
|
|
||||||
template<typename Field,int Nstop1>
|
|
||||||
void CoarseGridLanczos(BlockProjector<Field>& pr,RealD alpha2,RealD beta,int Npoly2,
|
|
||||||
int Nstop2,int Nk2,int Nm2,RealD resid2,RealD betastp2,int MaxIt,int MinRes2,
|
|
||||||
LinearOperatorBase<Field>& HermOp, std::vector<RealD>& eval1, bool cg_test_enabled,
|
|
||||||
int cg_test_maxiter,int nsingle,int SkipTest2, int MaxApply2,bool smoothed_eval_enabled,
|
|
||||||
int smoothed_eval_inner,int smoothed_eval_outer,int smoothed_eval_begin,
|
|
||||||
int smoothed_eval_end,RealD smoothed_eval_inner_resid) {
|
|
||||||
|
|
||||||
BlockedGrid<Field>& bgrid = pr._bgrid;
|
|
||||||
BasisFieldVector<Field>& basis = pr._evec;
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> coarseFourDimLatt;
|
|
||||||
for (int i=0;i<4;i++)
|
|
||||||
coarseFourDimLatt.push_back(bgrid._nb[1+i] * bgrid.Grid()->_processors[1+i]);
|
|
||||||
assert(bgrid.Grid()->_processors[0] == 1);
|
|
||||||
|
|
||||||
std::cout << GridLogMessage << "CoarseGrid = " << coarseFourDimLatt << " with basis = " << Nstop1 << std::endl;
|
|
||||||
GridCartesian * UCoarseGrid = SpaceTimeGrid::makeFourDimGrid(coarseFourDimLatt, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
|
||||||
GridCartesian * FCoarseGrid = SpaceTimeGrid::makeFiveDimGrid(bgrid._nb[0],UCoarseGrid);
|
|
||||||
|
|
||||||
Chebyshev<Field> Cheb2(alpha2,beta,Npoly2);
|
|
||||||
CoarseLatticeFermion<Nstop1> src_coarse(FCoarseGrid);
|
|
||||||
|
|
||||||
// Second round of Lanczos in blocked space
|
|
||||||
std::vector<RealD> eval2(Nm2);
|
|
||||||
std::vector<RealD> eval3(Nm2);
|
|
||||||
BasisFieldVector<CoarseLatticeFermion<Nstop1> > coef(Nm2,FCoarseGrid);
|
|
||||||
|
|
||||||
ProjectedFunctionHermOp<CoarseLatticeFermion<Nstop1>,LatticeFermion> Op2plain(pr,Cheb2,HermOp);
|
|
||||||
CheckpointedLinearFunction<CoarseLatticeFermion<Nstop1> > Op2ckpt(src_coarse.Grid(),Op2plain,"checkpoint",MaxApply2);
|
|
||||||
LinearFunction< CoarseLatticeFermion<Nstop1> >* Op2;
|
|
||||||
if (MaxApply2) {
|
|
||||||
Op2 = &Op2ckpt;
|
|
||||||
} else {
|
|
||||||
Op2 = &Op2plain;
|
|
||||||
}
|
|
||||||
ProjectedHermOp<CoarseLatticeFermion<Nstop1>,LatticeFermion> Op2nopoly(pr,HermOp);
|
|
||||||
ImplicitlyRestartedLanczos<CoarseLatticeFermion<Nstop1> > IRL2(*Op2,*Op2,Nstop2,Nk2,Nm2,resid2,MaxIt,betastp2,MinRes2);
|
|
||||||
|
|
||||||
|
|
||||||
src_coarse = 1.0;
|
|
||||||
|
|
||||||
// Precision test
|
|
||||||
{
|
|
||||||
Field tmp(bgrid.Grid());
|
|
||||||
CoarseLatticeFermion<Nstop1> tmp2(FCoarseGrid);
|
|
||||||
CoarseLatticeFermion<Nstop1> tmp3(FCoarseGrid);
|
|
||||||
tmp2 = 1.0;
|
|
||||||
tmp3 = 1.0;
|
|
||||||
|
|
||||||
pr.coarseToFine(tmp2,tmp);
|
|
||||||
pr.fineToCoarse(tmp,tmp2);
|
|
||||||
|
|
||||||
tmp2 -= tmp3;
|
|
||||||
std::cout << GridLogMessage << "Precision Test c->f->c: " << norm2(tmp2) / norm2(tmp3) << std::endl;
|
|
||||||
|
|
||||||
//bgrid.Grid()->Barrier();
|
|
||||||
//return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Nconv;
|
|
||||||
if (!FieldVectorIO::read_compressed_vectors("lanczos.output",pr,coef) ||
|
|
||||||
!read_evals(UCoarseGrid,(char *)"lanczos.output/eigen-values.txt",eval3) ||
|
|
||||||
!read_evals(UCoarseGrid,(char *)"lanczos.output/eigen-values.txt.linear",eval1) ||
|
|
||||||
!read_evals(UCoarseGrid,(char *)"lanczos.output/eigen-values.txt.poly",eval2)
|
|
||||||
) {
|
|
||||||
|
|
||||||
|
|
||||||
IRL2.calc(eval2,coef._v,src_coarse,Nconv,true);
|
|
||||||
|
|
||||||
coef.resize(Nstop2);
|
|
||||||
eval2.resize(Nstop2);
|
|
||||||
eval3.resize(Nstop2);
|
|
||||||
|
|
||||||
std::vector<Field> step3_cache;
|
|
||||||
|
|
||||||
// reconstruct eigenvalues of original operator
|
|
||||||
for (int i=0;i<Nstop2;i++){
|
|
||||||
RealD eval2_linear;
|
|
||||||
|
|
||||||
if (i<Nstop1) {
|
|
||||||
eval2_linear = eval1[i];
|
|
||||||
} else {
|
|
||||||
eval2_linear = eval2[i-1];
|
|
||||||
}
|
|
||||||
|
|
||||||
RealD eval2_poly = eval2[i];
|
|
||||||
RealD eval_reconstruct = Cheb2.approxInv(eval2_poly,eval2_linear,100,1e-10);
|
|
||||||
std::cout << i << " Reconstructed eval = " << eval_reconstruct << " from quess " << eval2_linear << std::endl;
|
|
||||||
eval2[i] = eval_reconstruct;
|
|
||||||
}
|
|
||||||
|
|
||||||
// as demonstrated in CG test below, best result from mixed determination
|
|
||||||
for (int i=0;i<Nstop2;i++)
|
|
||||||
eval3[i] = (i < Nstop1) ? eval1[i] : eval2[i];
|
|
||||||
|
|
||||||
for(int i=0;i<Nstop2;i++){
|
|
||||||
std::cout << i<<" / "<< Nstop2<< " eigenvalue "<< eval3[i] <<std::endl;
|
|
||||||
};
|
|
||||||
|
|
||||||
// write
|
|
||||||
mkdir("lanczos.output",ACCESSPERMS);
|
|
||||||
FieldVectorIO::write_compressed_vectors("lanczos.output",pr,coef,nsingle);
|
|
||||||
if (bgrid.Grid()->IsBoss()) {
|
|
||||||
write_evals((char *)"lanczos.output/eigen-values.txt",eval3);
|
|
||||||
write_evals((char *)"lanczos.output/eigen-values.txt.linear",eval1);
|
|
||||||
write_evals((char *)"lanczos.output/eigen-values.txt.poly",eval2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// fix up eigenvalues
|
|
||||||
if (!read_evals(UCoarseGrid,(char *)"lanczos.output/eigen-values.txt.smoothed",eval3) && smoothed_eval_enabled) {
|
|
||||||
|
|
||||||
ConjugateGradient<LatticeFermion> CG(smoothed_eval_inner_resid, smoothed_eval_inner, false);
|
|
||||||
|
|
||||||
LatticeFermion v_i(basis[0].Grid());
|
|
||||||
auto tmp = v_i;
|
|
||||||
auto tmp2 = v_i;
|
|
||||||
|
|
||||||
for (int i=smoothed_eval_begin;i<smoothed_eval_end;i++) {
|
|
||||||
|
|
||||||
GridStopWatch gsw;
|
|
||||||
|
|
||||||
gsw.Start();
|
|
||||||
|
|
||||||
pr.coarseToFine(coef[i],v_i);
|
|
||||||
v_i.Checkerboard() = Odd;
|
|
||||||
|
|
||||||
for (int j=0;j<smoothed_eval_outer;j++) {
|
|
||||||
tmp=Zero();
|
|
||||||
//pr.deflate(coef,eval3,Nstop2,v_i,tmp);
|
|
||||||
CG(HermOp, v_i, tmp);
|
|
||||||
|
|
||||||
v_i = 1.0 / ::sqrt( norm2(tmp) ) * tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = v_i;
|
|
||||||
|
|
||||||
HermOp.HermOp(tmp,tmp2);
|
|
||||||
|
|
||||||
RealD ev = innerProduct(tmp,tmp2).real();
|
|
||||||
|
|
||||||
gsw.Stop();
|
|
||||||
|
|
||||||
std::cout << GridLogMessage << "Smoothed eigenvalue " << i << " from " << eval3[i] << " to " << ev << " in " << gsw.Elapsed() << std::endl;
|
|
||||||
// " with effective smoother precision " << (CG.ResHistory.back() / CG.ResHistory.front() ) << std::endl;
|
|
||||||
// CG.ResHistory.clear();
|
|
||||||
|
|
||||||
eval3[i] = ev;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bgrid.Grid()->IsBoss()) {
|
|
||||||
write_evals((char *)"lanczos.output/eigen-values.txt.smoothed",eval3);
|
|
||||||
write_evals((char *)"lanczos.output/eigen-values.txt",eval3); // also reset this to the best ones we have available
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// do CG test with and without deflation
|
|
||||||
if (cg_test_enabled) {
|
|
||||||
ConjugateGradient<LatticeFermion> CG(1.0e-8, cg_test_maxiter, false);
|
|
||||||
LatticeFermion src_orig(bgrid.Grid());
|
|
||||||
src_orig.Checkerboard() = Odd;
|
|
||||||
src_orig = 1.0;
|
|
||||||
src_orig = src_orig * (1.0 / ::sqrt(norm2(src_orig)) );
|
|
||||||
auto result = src_orig;
|
|
||||||
|
|
||||||
// undeflated solve
|
|
||||||
std::cout << GridLogMessage << " Undeflated solve "<<std::endl;
|
|
||||||
result = Zero();
|
|
||||||
CG(HermOp, src_orig, result);
|
|
||||||
// if (UCoarseGrid->IsBoss())
|
|
||||||
// write_history("cg_test.undefl",CG.ResHistory);
|
|
||||||
// CG.ResHistory.clear();
|
|
||||||
|
|
||||||
// deflated solve with all eigenvectors
|
|
||||||
std::cout << GridLogMessage << " Deflated solve with all evectors"<<std::endl;
|
|
||||||
result = Zero();
|
|
||||||
pr.deflate(coef,eval2,Nstop2,src_orig,result);
|
|
||||||
CG(HermOp, src_orig, result);
|
|
||||||
// if (UCoarseGrid->IsBoss())
|
|
||||||
// write_history("cg_test.defl_all",CG.ResHistory);
|
|
||||||
// CG.ResHistory.clear();
|
|
||||||
|
|
||||||
// deflated solve with non-blocked eigenvectors
|
|
||||||
std::cout << GridLogMessage << " Deflated solve with non-blocked evectors"<<std::endl;
|
|
||||||
result = Zero();
|
|
||||||
pr.deflate(coef,eval1,Nstop1,src_orig,result);
|
|
||||||
CG(HermOp, src_orig, result);
|
|
||||||
// if (UCoarseGrid->IsBoss())
|
|
||||||
// write_history("cg_test.defl_full",CG.ResHistory);
|
|
||||||
// CG.ResHistory.clear();
|
|
||||||
|
|
||||||
// deflated solve with all eigenvectors and original eigenvalues from proj
|
|
||||||
std::cout << GridLogMessage << " Deflated solve with all eigenvectors and original eigenvalues from proj"<<std::endl;
|
|
||||||
result = Zero();
|
|
||||||
pr.deflate(coef,eval3,Nstop2,src_orig,result);
|
|
||||||
CG(HermOp, src_orig, result);
|
|
||||||
// if (UCoarseGrid->IsBoss())
|
|
||||||
// write_history("cg_test.defl_all_ev3",CG.ResHistory);
|
|
||||||
// CG.ResHistory.clear();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename Field>
|
|
||||||
void quick_krylov_basis(BasisFieldVector<Field>& evec,Field& src,LinearFunction<Field>& Op,int Nstop) {
|
|
||||||
Field tmp = src;
|
|
||||||
Field tmp2 = tmp;
|
|
||||||
|
|
||||||
for (int i=0;i<Nstop;i++) {
|
|
||||||
GridStopWatch gsw;
|
|
||||||
gsw.Start();
|
|
||||||
Op(tmp,tmp2);
|
|
||||||
gsw.Stop();
|
|
||||||
evec.orthogonalize(tmp2,i);
|
|
||||||
|
|
||||||
RealD nn = norm2(tmp2);
|
|
||||||
nn = Grid::sqrt(nn);
|
|
||||||
tmp2 = tmp2 * (1.0/nn);
|
|
||||||
|
|
||||||
evec[i] = tmp2;
|
|
||||||
tmp = tmp2;
|
|
||||||
std::cout << GridLogMessage << "Quick_krylov_basis: " << i << "/" << Nstop << " timing of operator=" << gsw.Elapsed() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char ** argv) {
|
|
||||||
|
|
||||||
Grid_init(&argc,&argv);
|
|
||||||
|
|
||||||
const int MaxIt = 10000;
|
|
||||||
|
|
||||||
int Ls;
|
|
||||||
RealD mass;
|
|
||||||
RealD M5;
|
|
||||||
std::vector < std::complex<double> > omega;
|
|
||||||
|
|
||||||
RealD alpha1, alpha2, beta;
|
|
||||||
int Npoly1, Npoly2;
|
|
||||||
int Nstop1, Nstop2;
|
|
||||||
int Nk1, Nk2;
|
|
||||||
int Np1, Np2;
|
|
||||||
int MinRes1, MinRes2;
|
|
||||||
int SkipTest2, MaxApply2;
|
|
||||||
bool checkpoint_basis;
|
|
||||||
bool cg_test_enabled;
|
|
||||||
bool exit_after_basis_calculation;
|
|
||||||
bool simple_krylov_basis;
|
|
||||||
int cg_test_maxiter;
|
|
||||||
int nsingle; // store in single precision, the rest in FP16
|
|
||||||
int max_cheb_time_ms;
|
|
||||||
bool smoothed_eval_enabled;
|
|
||||||
int smoothed_eval_inner;
|
|
||||||
int smoothed_eval_outer;
|
|
||||||
int smoothed_eval_begin;
|
|
||||||
int smoothed_eval_end;
|
|
||||||
RealD smoothed_eval_inner_resid;
|
|
||||||
|
|
||||||
// vector representation
|
|
||||||
std::vector<int> block_size; // 5d block size
|
|
||||||
|
|
||||||
RealD resid1, resid2, betastp1, betastp2, basis_norm_threshold;
|
|
||||||
|
|
||||||
std::string config;
|
|
||||||
|
|
||||||
Params jp("params.txt");
|
|
||||||
PADD(jp,Npoly1); PADD(jp,Npoly2);
|
|
||||||
PADD(jp,max_cheb_time_ms);
|
|
||||||
PADD(jp,Nstop1); PADD(jp,Nstop2); PADD(jp,MaxApply2);
|
|
||||||
PADD(jp,Nk1); PADD(jp,Nk2); PADD(jp,betastp1); PADD(jp,betastp2);
|
|
||||||
PADD(jp,Np1); PADD(jp,Np2); basis_norm_threshold = 1e-5; //PADD(jp,basis_norm_threshold);
|
|
||||||
PADD(jp,block_size); PADD(jp,smoothed_eval_enabled); PADD(jp,smoothed_eval_inner);
|
|
||||||
PADD(jp,resid1); PADD(jp,resid2); PADD(jp,smoothed_eval_outer);
|
|
||||||
PADD(jp,alpha1); PADD(jp,alpha2); PADD(jp,smoothed_eval_begin);
|
|
||||||
PADD(jp,MinRes1); PADD(jp,MinRes2); PADD(jp,smoothed_eval_end);
|
|
||||||
PADD(jp,beta); PADD(jp,mass); PADD(jp,smoothed_eval_inner_resid);
|
|
||||||
PADD(jp,omega); PADD(jp,config);
|
|
||||||
PADD(jp,M5); PADD(jp,cg_test_enabled);
|
|
||||||
PADD(jp,cg_test_maxiter); PADD(jp,checkpoint_basis);
|
|
||||||
PADD(jp,nsingle); PADD(jp,exit_after_basis_calculation);
|
|
||||||
PADD(jp,simple_krylov_basis); PADD(jp,SkipTest2);
|
|
||||||
|
|
||||||
Ls = (int)omega.size();
|
|
||||||
|
|
||||||
// Grids
|
|
||||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
|
||||||
GridCartesian * UGridHP = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplexD::Nsimd()),GridDefaultMpi());
|
|
||||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
|
||||||
GridRedBlackCartesian * UrbGridHP = SpaceTimeGrid::makeFourDimRedBlackGrid(UGridHP);
|
|
||||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
|
||||||
GridCartesian * FGridHP = SpaceTimeGrid::makeFiveDimGrid(Ls,UGridHP);
|
|
||||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
|
||||||
GridRedBlackCartesian * FrbGridHP = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGridHP);
|
|
||||||
|
|
||||||
// Gauge field
|
|
||||||
LatticeGaugeField Umu(UGrid);
|
|
||||||
FieldMetaData header;
|
|
||||||
NerscIO::readConfiguration(Umu,header,config);
|
|
||||||
std::cout << GridLogMessage << "Lattice dimensions: " << GridDefaultLatt()
|
|
||||||
<< " Ls: " << Ls << std::endl;
|
|
||||||
|
|
||||||
// ZMobius EO Operator
|
|
||||||
ZMobiusFermionR Ddwf(Umu, *FGrid, *FrbGrid, *UGrid, *UrbGrid, mass, M5, omega,1.,0.);
|
|
||||||
SchurDiagTwoOperator<ZMobiusFermionR,LatticeFermion> HermOp(Ddwf);
|
|
||||||
|
|
||||||
// Eigenvector storage
|
|
||||||
const int Nm1 = Np1 + Nk1;
|
|
||||||
const int Nm2 = Np2 + Nk2; // maximum number of vectors we need to keep
|
|
||||||
std::cout << GridLogMessage << "Keep " << Nm1 << " full vectors" << std::endl;
|
|
||||||
std::cout << GridLogMessage << "Keep " << Nm2 << " total vectors" << std::endl;
|
|
||||||
assert(Nm2 >= Nm1);
|
|
||||||
BasisFieldVector<LatticeFermion> evec(Nm1,FrbGrid); // start off with keeping full vectors
|
|
||||||
|
|
||||||
// First and second cheby
|
|
||||||
Chebyshev<LatticeFermion> Cheb1(alpha1,beta,Npoly1);
|
|
||||||
FunctionHermOp<LatticeFermion> Op1(Cheb1,HermOp);
|
|
||||||
PlainHermOp<LatticeFermion> Op1test(HermOp);
|
|
||||||
|
|
||||||
// Eigenvalue storage
|
|
||||||
std::vector<RealD> eval1(evec.size());
|
|
||||||
|
|
||||||
// Construct source vector
|
|
||||||
LatticeFermion src(FrbGrid);
|
|
||||||
{
|
|
||||||
src=1.0;
|
|
||||||
src.Checkerboard() = Odd;
|
|
||||||
|
|
||||||
// normalize
|
|
||||||
RealD nn = norm2(src);
|
|
||||||
nn = Grid::sqrt(nn);
|
|
||||||
src = src * (1.0/nn);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do a benchmark and a quick exit if performance is too little (ugly but needed due to performance fluctuations)
|
|
||||||
if (max_cheb_time_ms) {
|
|
||||||
// one round of warmup
|
|
||||||
auto tmp = src;
|
|
||||||
GridStopWatch gsw1,gsw2;
|
|
||||||
gsw1.Start();
|
|
||||||
Cheb1(HermOp,src,tmp);
|
|
||||||
gsw1.Stop();
|
|
||||||
Ddwf.ZeroCounters();
|
|
||||||
gsw2.Start();
|
|
||||||
Cheb1(HermOp,src,tmp);
|
|
||||||
gsw2.Stop();
|
|
||||||
Ddwf.Report();
|
|
||||||
std::cout << GridLogMessage << "Performance check; warmup = " << gsw1.Elapsed() << " test = " << gsw2.Elapsed() << std::endl;
|
|
||||||
int ms = (int)(gsw2.useconds()/1e3);
|
|
||||||
if (ms > max_cheb_time_ms) {
|
|
||||||
std::cout << GridLogMessage << "Performance too poor: " << ms << " ms, cutoff = " << max_cheb_time_ms << " ms" << std::endl;
|
|
||||||
Grid_finalize();
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// First round of Lanczos to get low mode basis
|
|
||||||
ImplicitlyRestartedLanczos<LatticeFermion> IRL1(Op1,Op1test,Nstop1,Nk1,Nm1,resid1,MaxIt,betastp1,MinRes1);
|
|
||||||
int Nconv;
|
|
||||||
|
|
||||||
char tag[1024];
|
|
||||||
if (!FieldVectorIO::read_argonne(evec,(char *)"checkpoint") || !read_evals(UGrid,(char *)"checkpoint/eigen-values.txt",eval1)) {
|
|
||||||
|
|
||||||
if (simple_krylov_basis) {
|
|
||||||
quick_krylov_basis(evec,src,Op1,Nstop1);
|
|
||||||
} else {
|
|
||||||
IRL1.calc(eval1,evec._v,src,Nconv,false);
|
|
||||||
}
|
|
||||||
evec.resize(Nstop1); // and throw away superfluous
|
|
||||||
eval1.resize(Nstop1);
|
|
||||||
if (checkpoint_basis)
|
|
||||||
FieldVectorIO::write_argonne(evec,(char *)"checkpoint");
|
|
||||||
if (UGrid->IsBoss() && checkpoint_basis)
|
|
||||||
write_evals((char *)"checkpoint/eigen-values.txt",eval1);
|
|
||||||
|
|
||||||
Ddwf.Report();
|
|
||||||
|
|
||||||
if (exit_after_basis_calculation) {
|
|
||||||
Grid_finalize();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// now test eigenvectors
|
|
||||||
if (!simple_krylov_basis) {
|
|
||||||
for (int i=0;i<Nstop1;i++){
|
|
||||||
auto B = evec[i];
|
|
||||||
auto tmp = B;
|
|
||||||
auto v = B;
|
|
||||||
|
|
||||||
{
|
|
||||||
HermOp.HermOp(B,v);
|
|
||||||
|
|
||||||
RealD vnum = real(innerProduct(B,v)); // HermOp.
|
|
||||||
RealD vden = norm2(B);
|
|
||||||
RealD vv0 = norm2(v);
|
|
||||||
RealD eval2 = vnum/vden;
|
|
||||||
v -= eval2*B;
|
|
||||||
RealD vv = norm2(v);
|
|
||||||
|
|
||||||
std::cout << i << " OP eval = " << eval2 << " (" << eval1[i] << ") "
|
|
||||||
<< "res2 = " << vv << " norm2 = " << norm2(B) << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// do second step only if needed
|
|
||||||
if (Nstop1 <= Nstop2) {
|
|
||||||
|
|
||||||
// Now setup blocking
|
|
||||||
assert(evec.size() == Nstop1);
|
|
||||||
BlockedGrid<LatticeFermion> bgrid(FrbGrid, block_size);
|
|
||||||
BlockProjector<LatticeFermion> pr(evec,bgrid);
|
|
||||||
pr.createOrthonormalBasis(basis_norm_threshold);
|
|
||||||
pr.createOrthonormalBasis(basis_norm_threshold); // another round due to precision issues created by local coherence
|
|
||||||
|
|
||||||
constexpr int common_basis_sizes[] = { 60, 250, 400 };
|
|
||||||
constexpr int n_common_basis_sizes = sizeof(common_basis_sizes) / sizeof(common_basis_sizes[0]);
|
|
||||||
switch (Nstop1) {
|
|
||||||
#define BASIS(n) case common_basis_sizes[n]:\
|
|
||||||
CoarseGridLanczos<LatticeFermion,common_basis_sizes[n]>\
|
|
||||||
(pr,alpha2,beta,Npoly2,Nstop2,Nk2,Nm2,resid2,betastp2,MaxIt,MinRes2,HermOp,eval1, \
|
|
||||||
cg_test_enabled,cg_test_maxiter,nsingle,SkipTest2, \
|
|
||||||
MaxApply2,smoothed_eval_enabled,smoothed_eval_inner,smoothed_eval_outer, \
|
|
||||||
smoothed_eval_begin,smoothed_eval_end,smoothed_eval_inner_resid); break;
|
|
||||||
BASIS(0);
|
|
||||||
BASIS(1);
|
|
||||||
BASIS(2);
|
|
||||||
default:
|
|
||||||
std::cout << GridLogMessage << "Basis size " << Nstop1 << " must be added at compile-time" << std::endl;
|
|
||||||
std::cout << GridLogMessage << "Currently available sizes: " << std::endl;
|
|
||||||
for (int i=0;i<n_common_basis_sizes;i++) {
|
|
||||||
std::cout << GridLogMessage << " " << common_basis_sizes[i] << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Grid_finalize();
|
|
||||||
}
|
|
||||||
|
|
@ -160,11 +160,11 @@ int main (int argc, char ** argv) {
|
|||||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||||
|
|
||||||
std::vector<int> fineLatt = GridDefaultLatt();
|
Coordinate fineLatt = GridDefaultLatt();
|
||||||
int dims=fineLatt.size();
|
int dims=fineLatt.size();
|
||||||
assert(blockSize.size()==dims+1);
|
assert(blockSize.size()==dims+1);
|
||||||
std::vector<int> coarseLatt(dims);
|
Coordinate coarseLatt(dims);
|
||||||
std::vector<int> coarseLatt5d ;
|
Coordinate coarseLatt5d ;
|
||||||
|
|
||||||
for (int d=0;d<coarseLatt.size();d++){
|
for (int d=0;d<coarseLatt.size();d++){
|
||||||
coarseLatt[d] = fineLatt[d]/blockSize[d]; assert(coarseLatt[d]*blockSize[d]==fineLatt[d]);
|
coarseLatt[d] = fineLatt[d]/blockSize[d]; assert(coarseLatt[d]*blockSize[d]==fineLatt[d]);
|
||||||
|
@ -264,11 +264,11 @@ int main (int argc, char ** argv) {
|
|||||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||||
|
|
||||||
std::vector<int> fineLatt = GridDefaultLatt();
|
Coordinate fineLatt = GridDefaultLatt();
|
||||||
int dims=fineLatt.size();
|
int dims=fineLatt.size();
|
||||||
assert(blockSize.size()==dims+1);
|
assert(blockSize.size()==dims+1);
|
||||||
std::vector<int> coarseLatt(dims);
|
Coordinate coarseLatt(dims);
|
||||||
std::vector<int> coarseLatt5d ;
|
Coordinate coarseLatt5d ;
|
||||||
|
|
||||||
for (int d=0;d<coarseLatt.size();d++){
|
for (int d=0;d<coarseLatt.size();d++){
|
||||||
coarseLatt[d] = fineLatt[d]/blockSize[d]; assert(coarseLatt[d]*blockSize[d]==fineLatt[d]);
|
coarseLatt[d] = fineLatt[d]/blockSize[d]; assert(coarseLatt[d]*blockSize[d]==fineLatt[d]);
|
||||||
|
@ -67,9 +67,9 @@ int main(int argc, char **argv) {
|
|||||||
Grid_init(&argc, &argv);
|
Grid_init(&argc, &argv);
|
||||||
GridLogLayout();
|
GridLogLayout();
|
||||||
|
|
||||||
std::vector<int> latt_size = GridDefaultLatt();
|
auto latt_size = GridDefaultLatt();
|
||||||
std::vector<int> simd_layout = GridDefaultSimd(Nd, vComplex::Nsimd());
|
auto simd_layout = GridDefaultSimd(Nd, vComplex::Nsimd());
|
||||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
auto mpi_layout = GridDefaultMpi();
|
||||||
GridCartesian Grid(latt_size, simd_layout, mpi_layout);
|
GridCartesian Grid(latt_size, simd_layout, mpi_layout);
|
||||||
GridRedBlackCartesian RBGrid(&Grid);
|
GridRedBlackCartesian RBGrid(&Grid);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user