mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-10 14:10:46 +01:00
Beautification
This commit is contained in:
parent
4bcdb4ff95
commit
fcd90705bc
@ -41,7 +41,7 @@ BEGIN_HADRONS_NAMESPACE
|
||||
BEGIN_MODULE_NAMESPACE(MDistil)
|
||||
|
||||
/******************************************************************************
|
||||
Common elements for distillation
|
||||
Distillation code that is common across modules
|
||||
******************************************************************************/
|
||||
|
||||
struct DistilParameters: Serializable {
|
||||
@ -102,6 +102,7 @@ inline GridCartesian * MakeLowerDimGrid( GridCartesian * gridHD )
|
||||
/*************************************************************************************
|
||||
Rotate eigenvectors into our phase convention
|
||||
First component of first eigenvector is real and positive
|
||||
TODO: Should this be in Distil.hpp?
|
||||
*************************************************************************************/
|
||||
|
||||
inline void RotateEigen(std::vector<LatticeColourVector> & evec)
|
||||
|
@ -108,17 +108,20 @@ template <typename FImpl>
|
||||
std::vector<std::string> TDistilVectors<FImpl>::getInput(void)
|
||||
{
|
||||
PerambulatorName = par().perambulator;
|
||||
if( PerambulatorName.size() == 0 ) {
|
||||
if (PerambulatorName.empty())
|
||||
{
|
||||
PerambulatorName = getName();
|
||||
PerambulatorName.append("_peramb");
|
||||
}
|
||||
NoiseVectorName = par().noise;
|
||||
if( NoiseVectorName.size() == 0 ) {
|
||||
if (NoiseVectorName.empty())
|
||||
{
|
||||
NoiseVectorName = PerambulatorName;
|
||||
NoiseVectorName.append("_noise");
|
||||
}
|
||||
LapEvecName = par().lapevec;
|
||||
if( LapEvecName.size() == 0 ) {
|
||||
if (LapEvecName.empty())
|
||||
{
|
||||
LapEvecName = PerambulatorName;
|
||||
LapEvecName.append("_lapevec");
|
||||
}
|
||||
@ -132,7 +135,8 @@ std::vector<std::string> TDistilVectors<FImpl>::getOutput(void)
|
||||
SinkName = par().sink;
|
||||
bMakeSource = ( SourceName.size() > 0 );
|
||||
bMakeSink = ( SinkName.size() > 0 );
|
||||
if( !bMakeSource && !bMakeSink ) {
|
||||
if (!bMakeSource && !bMakeSink)
|
||||
{
|
||||
SourceName = getName();
|
||||
SinkName = SourceName;
|
||||
SourceName.append("_rho");
|
||||
@ -161,7 +165,6 @@ void TDistilVectors<FImpl>::setup(void)
|
||||
|
||||
const int Nt{ env().getDim(Tdir) };
|
||||
assert( Nt == static_cast<int>( perambulator.tensor.dimension(0) ) && "PerambTensor time dimensionality bad" );
|
||||
const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, true) };
|
||||
const int LI{ static_cast<int>( perambulator.tensor.dimension(2) ) };
|
||||
const int SI{ static_cast<int>( perambulator.tensor.dimension(5) ) };
|
||||
const int Nt_inv{ static_cast<int>( perambulator.tensor.dimension(4) ) };
|
||||
@ -179,7 +182,6 @@ void TDistilVectors<FImpl>::setup(void)
|
||||
|
||||
grid4d = env().getGrid();
|
||||
Coordinate latt_size = GridDefaultLatt();
|
||||
Coordinate simd_layout = GridDefaultSimd(Nd, vComplex::Nsimd());
|
||||
Coordinate mpi_layout = GridDefaultMpi();
|
||||
Coordinate simd_layout_3 = GridDefaultSimd(Nd-1, vComplex::Nsimd());
|
||||
latt_size[Nd-1] = 1;
|
||||
@ -187,7 +189,6 @@ void TDistilVectors<FImpl>::setup(void)
|
||||
mpi_layout[Nd-1] = 1;
|
||||
grid3d = MakeLowerDimGrid(grid4d);
|
||||
|
||||
|
||||
envTmp(LatticeSpinColourVector, "tmp2",1,LatticeSpinColourVector(grid4d));
|
||||
envTmp(LatticeSpinColourVector, "tmp3d",1,LatticeSpinColourVector(grid3d));
|
||||
envTmp(LatticeColourVector, "tmp3d_nospin",1,LatticeColourVector(grid3d));
|
||||
@ -199,7 +200,8 @@ void TDistilVectors<FImpl>::setup(void)
|
||||
template <typename FImpl>
|
||||
void TDistilVectors<FImpl>::Cleanup(void)
|
||||
{
|
||||
if( grid3d != nullptr ) {
|
||||
if ( grid3d != nullptr)
|
||||
{
|
||||
delete grid3d;
|
||||
grid3d = nullptr;
|
||||
}
|
||||
@ -236,7 +238,8 @@ void TDistilVectors<FImpl>::execute(void)
|
||||
|
||||
int vecindex;
|
||||
int t_inv;
|
||||
if( bMakeSource ) {
|
||||
if (bMakeSource)
|
||||
{
|
||||
auto &rho = envGet(std::vector<FermionField>, SourceName);
|
||||
for (int inoise = 0; inoise < nnoise; inoise++) {
|
||||
for (int dk = 0; dk < LI; dk++) {
|
||||
|
@ -135,7 +135,8 @@ template <typename GImpl>
|
||||
std::vector<std::string> TLapEvec<GImpl>::getInput(void)
|
||||
{
|
||||
sGaugeName = par().gauge;
|
||||
if( sGaugeName.size() == 0 ) {
|
||||
if (sGaugeName.empty())
|
||||
{
|
||||
sGaugeName = getName();
|
||||
sGaugeName.append( "_gauge" );
|
||||
}
|
||||
@ -172,7 +173,8 @@ void TLapEvec<GImpl>::setup(void)
|
||||
template <typename GImpl>
|
||||
void TLapEvec<GImpl>::Cleanup(void)
|
||||
{
|
||||
if( gridLD != nullptr ) {
|
||||
if (gridLD != nullptr)
|
||||
{
|
||||
delete gridLD;
|
||||
gridLD = nullptr;
|
||||
}
|
||||
@ -190,13 +192,12 @@ void TLapEvec<GImpl>::Cleanup(void)
|
||||
template<typename Field, typename GaugeField=LatticeGaugeField>
|
||||
class Laplacian3D : public LinearOperatorBase<Field>, public LinearFunction<Field> {
|
||||
typedef typename GaugeField::vector_type vCoeff_t;
|
||||
protected: // I don't really mind if _gf is messed with ... so make this public?
|
||||
//GaugeField & _gf;
|
||||
public:
|
||||
int nd; // number of spatial dimensions
|
||||
std::vector<Lattice<iColourMatrix<vCoeff_t> > > U;
|
||||
public:
|
||||
// Construct this operator given a gauge field and the number of dimensions it should act on
|
||||
Laplacian3D( GaugeField& gf, int dimSpatial = Tdir ) : /*_gf(gf),*/ nd{dimSpatial} {
|
||||
Laplacian3D( GaugeField& gf, int dimSpatial = Tdir ) : nd{dimSpatial}
|
||||
{
|
||||
assert(dimSpatial>=1);
|
||||
for (int mu = 0 ; mu < nd ; mu++)
|
||||
U.push_back(PeekIndex<LorentzIndex>(gf,mu));
|
||||
@ -209,9 +210,8 @@ public:
|
||||
out = ( ( Real ) ( 2 * nd ) ) * in;
|
||||
Field _tmp(in.Grid());
|
||||
typedef typename GaugeField::vector_type vCoeff_t;
|
||||
//Lattice<iColourMatrix<vCoeff_t> > U(in.Grid());
|
||||
for( int mu = 0 ; mu < nd ; mu++ ) {
|
||||
//U = PeekIndex<LorentzIndex>(_gf,mu);
|
||||
for (int mu = 0 ; mu < nd ; mu++)
|
||||
{
|
||||
out -= U[mu] * Cshift( in, mu, 1);
|
||||
_tmp = adj( U[mu] ) * in;
|
||||
out -= Cshift(_tmp,mu,-1);
|
||||
@ -231,11 +231,10 @@ class Laplacian3DHerm : public LinearFunction<Field> {
|
||||
public:
|
||||
OperatorFunction<Field> & _poly;
|
||||
LinearOperatorBase<Field> &_Linop;
|
||||
|
||||
Laplacian3DHerm(OperatorFunction<Field> & poly,LinearOperatorBase<Field>& linop)
|
||||
: _poly{poly}, _Linop{linop} {}
|
||||
|
||||
void operator()(const Field& in, Field& out) {
|
||||
void operator()(const Field& in, Field& out)
|
||||
{
|
||||
_poly(_Linop,in,out);
|
||||
}
|
||||
};
|
||||
@ -283,7 +282,8 @@ void TLapEvec<GImpl>::execute(void)
|
||||
const int Ntlocal{gridHD->LocalDimensions()[Tdir]};
|
||||
const int Ntfirst{gridHD->LocalStarts()[Tdir]};
|
||||
uint32_t ConvergenceErrors{0};
|
||||
for(int t = 0; t < Ntlocal; t++ ) {
|
||||
for (int t = 0; t < Ntlocal; t++ )
|
||||
{
|
||||
LOG(Message) << "------------------------------------------------------------" << std::endl;
|
||||
LOG(Message) << " Compute eigenpack, local timeslice = " << t << " / " << Ntlocal << std::endl;
|
||||
LOG(Message) << "------------------------------------------------------------" << std::endl;
|
||||
@ -292,12 +292,12 @@ void TLapEvec<GImpl>::execute(void)
|
||||
// Construct smearing operator
|
||||
ExtractSliceLocal(UmuNoTime,Umu_smear,0,t,Tdir); // switch to 3d/4d objects
|
||||
Laplacian3D<LatticeColourVector> Nabla(UmuNoTime);
|
||||
LOG(Debug) << "Chebyshev preconditioning to order " << ChebPar.PolyOrder
|
||||
LOG(Message) << "Chebyshev preconditioning to order " << ChebPar.PolyOrder
|
||||
<< " with parameters (alpha,beta) = (" << ChebPar.alpha << "," << ChebPar.beta << ")" << std::endl;
|
||||
Chebyshev<LatticeColourVector> Cheb(ChebPar.alpha,ChebPar.beta,ChebPar.PolyOrder);
|
||||
|
||||
// Construct source vector according to Test_dwf_compressed_lanczos.cc
|
||||
src = 11.0; //TODO: Why hard-coded 11?
|
||||
src = 11.0; // NB: This is a dummy parameter and just needs to be non-zero
|
||||
RealD nn = norm2(src);
|
||||
nn = Grid::sqrt(nn);
|
||||
src = src * (1.0/nn);
|
||||
@ -307,7 +307,8 @@ void TLapEvec<GImpl>::execute(void)
|
||||
IRL(NablaCheby,Nabla,LPar.Nvec,LPar.Nk,LPar.Nk+LPar.Np,LPar.resid,LPar.MaxIt);
|
||||
int Nconv = 0;
|
||||
IRL.calc(eig[t].eval,eig[t].evec,src,Nconv);
|
||||
if( Nconv < LPar.Nvec ) {
|
||||
if (Nconv < LPar.Nvec)
|
||||
{
|
||||
// NB: Can't assert here since we are processing local slices - i.e. not all nodes would assert
|
||||
ConvergenceErrors = 1;
|
||||
LOG(Error) << "MDistil::LapEvec : Not enough eigenvectors converged. If this occurs in practice, we should modify the eigensolver to iterate once more to ensure the second convergence test does not take us below the requested number of eigenvectors" << std::endl;
|
||||
|
@ -82,17 +82,13 @@ TNoises<FImpl>::TNoises(const std::string name)
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TNoises<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in;
|
||||
|
||||
return in;
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TNoises<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
return {getName()};
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
@ -103,8 +99,6 @@ void TNoises<FImpl>::setup(void)
|
||||
const int Nt{env().getDim(Tdir)};
|
||||
const int nnoise{par().nnoise};
|
||||
const int nvec{par().nvec};
|
||||
const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, true) };
|
||||
const int LI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().LI, nvec, true) };
|
||||
envCreate(NoiseTensor, getName(), 1, nnoise, Nt, nvec, Ns);
|
||||
}
|
||||
|
||||
@ -120,9 +114,8 @@ void TNoises<FImpl>::execute(void)
|
||||
const bool full_tdil{ TI == Nt }; \
|
||||
const bool exact_distillation{ full_tdil && LI == nvec }; \
|
||||
std::string UniqueIdentifier{par().UniqueIdentifier};
|
||||
if( UniqueIdentifier.length() == 0 ) {
|
||||
if (UniqueIdentifier.empty())
|
||||
UniqueIdentifier = getName();
|
||||
}
|
||||
UniqueIdentifier.append( std::to_string( vm().getTrajectory() ) );
|
||||
|
||||
// We use our own seeds so we can specify different noises per quark
|
||||
|
@ -93,7 +93,6 @@ TPerambFromSolve<FImpl>::~TPerambFromSolve(void)
|
||||
Cleanup();
|
||||
};
|
||||
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TPerambFromSolve<FImpl>::getInput(void)
|
||||
@ -127,7 +126,8 @@ void TPerambFromSolve<FImpl>::setup(void)
|
||||
template <typename FImpl>
|
||||
void TPerambFromSolve<FImpl>::Cleanup(void)
|
||||
{
|
||||
if( grid3d != nullptr ) {
|
||||
if (grid3d != nullptr)
|
||||
{
|
||||
delete grid3d;
|
||||
grid3d = nullptr;
|
||||
}
|
||||
@ -171,10 +171,10 @@ void TPerambFromSolve<FImpl>::execute(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(grid4d->IsBoss()) {
|
||||
if(grid4d->IsBoss())
|
||||
{
|
||||
std::string sPerambName{par().PerambFileName};
|
||||
if( sPerambName.length() == 0 )
|
||||
if (sPerambName.empty())
|
||||
sPerambName = getName();
|
||||
sPerambName.append( "." );
|
||||
sPerambName.append( std::to_string(vm().getTrajectory()));
|
||||
@ -183,7 +183,5 @@ void TPerambFromSolve<FImpl>::execute(void)
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MDistil_PerambFromSolve_hpp_
|
||||
|
@ -186,8 +186,6 @@ void TPerambulator<FImpl>::execute(void)
|
||||
const int Ntfirst{grid4d->LocalStarts()[3]};
|
||||
const std::string UnsmearedSinkFileName{ par().UnsmearedSinkFileName };
|
||||
|
||||
{
|
||||
int t_inv;
|
||||
for (int inoise = 0; inoise < nnoise; inoise++)
|
||||
{
|
||||
for (int dk = 0; dk < LI; dk++)
|
||||
@ -202,7 +200,7 @@ void TPerambulator<FImpl>::execute(void)
|
||||
evec3d = 0;
|
||||
for (int it = dt; it < Nt; it += TI)
|
||||
{
|
||||
if (full_tdil) t_inv = tsrc; else t_inv = it;
|
||||
const int t_inv{full_tdil ? tsrc : it};
|
||||
if( t_inv >= Ntfirst && t_inv < Ntfirst + Ntlocal )
|
||||
{
|
||||
for (int ik = dk; ik < nvec; ik += LI)
|
||||
@ -223,9 +221,7 @@ void TPerambulator<FImpl>::execute(void)
|
||||
result=0;
|
||||
v4dtmp = dist_source;
|
||||
if (Ls_ == 1)
|
||||
{
|
||||
solver(result, v4dtmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.ImportPhysicalFermionSource(v4dtmp, v5dtmp);
|
||||
@ -252,7 +248,6 @@ void TPerambulator<FImpl>::execute(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Now share my timeslice data with other members of the grid
|
||||
const int NumSlices{grid4d->_processors[Tdir] / grid3d->_processors[Tdir]};
|
||||
if (NumSlices > 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user