mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-15 10:15:36 +00:00
job parameters can be provided by cmdarg.
This commit is contained in:
parent
4c0ae75ac5
commit
bfc0306a43
@ -157,6 +157,14 @@ void GridCmdOptionInt(std::string &str,int & val)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ypj [add]
|
||||||
|
void GridCmdOptionFloat(std::string &str,double & val)
|
||||||
|
{
|
||||||
|
std::stringstream ss(str);
|
||||||
|
ss>>val;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GridParseLayout(char **argv,int argc,
|
void GridParseLayout(char **argv,int argc,
|
||||||
std::vector<int> &latt,
|
std::vector<int> &latt,
|
||||||
|
@ -54,6 +54,9 @@ namespace Grid {
|
|||||||
std::string GridCmdVectorIntToString(const std::vector<int> & vec);
|
std::string GridCmdVectorIntToString(const std::vector<int> & vec);
|
||||||
void GridCmdOptionCSL(std::string str,std::vector<std::string> & vec);
|
void GridCmdOptionCSL(std::string str,std::vector<std::string> & vec);
|
||||||
void GridCmdOptionIntVector(std::string &str,std::vector<int> & vec);
|
void GridCmdOptionIntVector(std::string &str,std::vector<int> & vec);
|
||||||
|
// ypj [add]
|
||||||
|
void GridCmdOptionInt(std::string &str,int & val);
|
||||||
|
void GridCmdOptionFloat(std::string &str,double & val);
|
||||||
|
|
||||||
|
|
||||||
void GridParseLayout(char **argv,int argc,
|
void GridParseLayout(char **argv,int argc,
|
||||||
|
@ -35,17 +35,125 @@ typedef typename GparityDomainWallFermionR::FermionField FermionField;
|
|||||||
|
|
||||||
RealD AllZero(RealD x){ return 0.;}
|
RealD AllZero(RealD x){ return 0.;}
|
||||||
|
|
||||||
|
class CmdJobParams
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string gaugefile;
|
||||||
|
|
||||||
|
int Ls;
|
||||||
|
double mass;
|
||||||
|
double M5;
|
||||||
|
double mob_b;
|
||||||
|
|
||||||
|
int Nu;
|
||||||
|
int Nk;
|
||||||
|
int Np;
|
||||||
|
int Nstop;
|
||||||
|
int MaxIter;
|
||||||
|
double resid;
|
||||||
|
|
||||||
|
double low;
|
||||||
|
double high;
|
||||||
|
int order;
|
||||||
|
|
||||||
|
CmdJobParams()
|
||||||
|
: gaugefile("Hot"),
|
||||||
|
Ls(8), mass(0.01), M5(1.8), mob_b(1.5),
|
||||||
|
Nu(4), Nk(200), Np(200), Nstop(100), MaxIter(10), resid(1.0e-8),
|
||||||
|
low(0.2), high(5.5), order(11)
|
||||||
|
{};
|
||||||
|
|
||||||
|
void Parse(char **argv, int argc);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void CmdJobParams::Parse(char **argv,int argc)
|
||||||
|
{
|
||||||
|
std::string arg;
|
||||||
|
std::vector<int> vi;
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--gconf") ){
|
||||||
|
gaugefile = GridCmdOptionPayload(argv,argv+argc,"--gconf");
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--Ls") ){
|
||||||
|
arg = GridCmdOptionPayload(argv,argv+argc,"--Ls");
|
||||||
|
GridCmdOptionInt(arg,Ls);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--mass") ){
|
||||||
|
arg = GridCmdOptionPayload(argv,argv+argc,"--mass");
|
||||||
|
GridCmdOptionFloat(arg,mass);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--M5") ){
|
||||||
|
arg = GridCmdOptionPayload(argv,argv+argc,"--M5");
|
||||||
|
GridCmdOptionFloat(arg,M5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--mob_b") ){
|
||||||
|
arg = GridCmdOptionPayload(argv,argv+argc,"--mob_b");
|
||||||
|
GridCmdOptionFloat(arg,mob_b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--irbl") ){
|
||||||
|
arg = GridCmdOptionPayload(argv,argv+argc,"--irbl");
|
||||||
|
GridCmdOptionIntVector(arg,vi);
|
||||||
|
Nu = vi[0];
|
||||||
|
Nk = vi[1];
|
||||||
|
Np = vi[2];
|
||||||
|
Nstop = vi[3];
|
||||||
|
MaxIter = vi[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--resid") ){
|
||||||
|
arg = GridCmdOptionPayload(argv,argv+argc,"--resid");
|
||||||
|
GridCmdOptionFloat(arg,resid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--cheby_l") ){
|
||||||
|
arg = GridCmdOptionPayload(argv,argv+argc,"--cheby_l");
|
||||||
|
GridCmdOptionFloat(arg,low);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--cheby_u") ){
|
||||||
|
arg = GridCmdOptionPayload(argv,argv+argc,"--cheby_u");
|
||||||
|
GridCmdOptionFloat(arg,high);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( GridCmdOptionExists(argv,argv+argc,"--cheby_n") ){
|
||||||
|
arg = GridCmdOptionPayload(argv,argv+argc,"--cheby_n");
|
||||||
|
GridCmdOptionInt(arg,order);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( CartesianCommunicator::RankWorld() == 0 ) {
|
||||||
|
clog <<" Gauge Configuration "<< gaugefile << '\n';
|
||||||
|
clog <<" Ls "<< Ls << '\n';
|
||||||
|
clog <<" mass "<< mass << '\n';
|
||||||
|
clog <<" M5 "<< M5 << '\n';
|
||||||
|
clog <<" mob_b "<< mob_b << '\n';
|
||||||
|
clog <<" Nu "<< Nu << '\n';
|
||||||
|
clog <<" Nk "<< Nk << '\n';
|
||||||
|
clog <<" Np "<< Np << '\n';
|
||||||
|
clog <<" Nstop "<< Nstop << '\n';
|
||||||
|
clog <<" MaxIter "<< MaxIter << '\n';
|
||||||
|
clog <<" resid "<< resid << '\n';
|
||||||
|
clog <<" Cheby Poly "<< low << "," << high << "," << order << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char ** argv)
|
int main (int argc, char ** argv)
|
||||||
{
|
{
|
||||||
Grid_init(&argc,&argv);
|
Grid_init(&argc,&argv);
|
||||||
|
|
||||||
const int Ls=8;
|
CmdJobParams JP;
|
||||||
//const int Ls=16;
|
JP.Parse(argv,argc);
|
||||||
|
|
||||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(JP.Ls,UGrid);
|
||||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(JP.Ls,UGrid);
|
||||||
printf("UGrid=%p UrbGrid=%p FGrid=%p FrbGrid=%p\n",UGrid,UrbGrid,FGrid,FrbGrid);
|
printf("UGrid=%p UrbGrid=%p FGrid=%p FrbGrid=%p\n",UGrid,UrbGrid,FGrid,FrbGrid);
|
||||||
|
|
||||||
std::vector<int> seeds4({1,2,3,4});
|
std::vector<int> seeds4({1,2,3,4});
|
||||||
@ -56,31 +164,23 @@ int main (int argc, char ** argv)
|
|||||||
// ypj [note] why seed RNG5 again? bug? In this case, run with a default seed().
|
// ypj [note] why seed RNG5 again? bug? In this case, run with a default seed().
|
||||||
//GridParallelRNG RNG5rb(FrbGrid); //RNG5rb.SeedFixedIntegers(seeds5);
|
//GridParallelRNG RNG5rb(FrbGrid); //RNG5rb.SeedFixedIntegers(seeds5);
|
||||||
|
|
||||||
#if 0 // ypj [note] generate a random configuration
|
|
||||||
LatticeGaugeField Umu(UGrid);
|
LatticeGaugeField Umu(UGrid);
|
||||||
SU3::HotConfiguration(RNG4, Umu);
|
|
||||||
|
|
||||||
std::vector<LatticeColourMatrix> U(4,UGrid);
|
std::vector<LatticeColourMatrix> U(4,UGrid);
|
||||||
for(int mu=0;mu<Nd;mu++){
|
|
||||||
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
|
if ( JP.gaugefile.compare("Hot") == 0 ) {
|
||||||
|
SU3::HotConfiguration(RNG4, Umu);
|
||||||
|
} else {
|
||||||
|
FieldMetaData header;
|
||||||
|
NerscIO::readConfiguration(Umu,header,JP.gaugefile);
|
||||||
}
|
}
|
||||||
#else // read configuration from a file
|
|
||||||
LatticeGaugeField Umu(UGrid);
|
|
||||||
std::vector<LatticeColourMatrix> U(4,UGrid);
|
|
||||||
|
|
||||||
FieldMetaData header;
|
|
||||||
std::string file("./ckpoint_lat");
|
|
||||||
NerscIO::readConfiguration(Umu,header,file);
|
|
||||||
|
|
||||||
for(int mu=0;mu<Nd;mu++){
|
for(int mu=0;mu<Nd;mu++){
|
||||||
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
|
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
//RealD mass=0.01;
|
RealD mass = JP.mass;
|
||||||
RealD mass=0.00107;
|
RealD M5 = JP.M5;
|
||||||
RealD M5=1.8;
|
RealD mob_b = JP.mob_b;
|
||||||
RealD mob_b=1.5;
|
|
||||||
// DomainWallFermionR Ddwf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
|
// DomainWallFermionR Ddwf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
|
||||||
GparityMobiusFermionD ::ImplParams params;
|
GparityMobiusFermionD ::ImplParams params;
|
||||||
std::vector<int> twists({1,1,1,0});
|
std::vector<int> twists({1,1,1,0});
|
||||||
@ -92,27 +192,25 @@ int main (int argc, char ** argv)
|
|||||||
SchurDiagTwoOperator<GparityMobiusFermionR,FermionField> HermOp(Ddwf);
|
SchurDiagTwoOperator<GparityMobiusFermionR,FermionField> HermOp(Ddwf);
|
||||||
// SchurDiagMooeeOperator<DomainWallFermionR,LatticeFermion> HermOp(Ddwf);
|
// SchurDiagMooeeOperator<DomainWallFermionR,LatticeFermion> HermOp(Ddwf);
|
||||||
|
|
||||||
const int Nstop = 100;
|
int Nu = JP.Nu;
|
||||||
const int Nu = 10;
|
int Nk = JP.Nk;
|
||||||
const int Nk = 200;
|
int Nm = Nk+JP.Np;
|
||||||
const int Np = 200;
|
|
||||||
const int Nm = Nk+Np;
|
|
||||||
const int MaxIt= 10;
|
|
||||||
RealD resid = 1.0e-8;
|
|
||||||
|
|
||||||
//std::vector<double> Coeffs { 0.,-1.};
|
//std::vector<double> Coeffs { 0.,-1.};
|
||||||
// ypj [note] this may not be supported by some compilers
|
// ypj [note] this may not be supported by some compilers
|
||||||
std::vector<double> Coeffs({ 0.,-1.});
|
std::vector<double> Coeffs({ 0.,-1.});
|
||||||
Polynomial<FermionField> PolyX(Coeffs);
|
Polynomial<FermionField> PolyX(Coeffs);
|
||||||
//Chebyshev<FermionField> Cheb(0.2,5.5,11);
|
//Chebyshev<FermionField> Cheb(0.2,5.5,11);
|
||||||
Chebyshev<FermionField> Cheb(0.03,5.5,21);
|
Chebyshev<FermionField> Cheb(JP.low,JP.high,JP.order);
|
||||||
// ChebyshevLanczos<LatticeFermion> Cheb(9.,1.,0.,20);
|
|
||||||
// Cheb.csv(std::cout);
|
// Cheb.csv(std::cout);
|
||||||
// exit(-24);
|
ImplicitlyRestartedBlockLanczos<FermionField> IRBL(HermOp,
|
||||||
ImplicitlyRestartedBlockLanczos<FermionField> IRBL(HermOp,Cheb,Nstop,Nu,Nk,Nm,resid,MaxIt);
|
Cheb,
|
||||||
|
JP.Nstop,
|
||||||
|
Nu,Nk,Nm,
|
||||||
|
JP.resid,
|
||||||
|
JP.MaxIter);
|
||||||
|
|
||||||
|
std::vector<RealD> eval(Nm);
|
||||||
std::vector<RealD> eval(Nm);
|
|
||||||
|
|
||||||
std::vector<FermionField> src(Nu,FrbGrid);
|
std::vector<FermionField> src(Nu,FrbGrid);
|
||||||
for ( int i=0; i<Nu; ++i ) gaussian(RNG5rb,src[i]);
|
for ( int i=0; i<Nu; ++i ) gaussian(RNG5rb,src[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user