1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-20 09:15:38 +01:00

Fairly close to ready for release. Felix and I to review, then submit for release

This commit is contained in:
Michael Marshall 2019-04-30 23:53:57 +01:00
parent e56ead55ef
commit 334f29becb
14 changed files with 290 additions and 1036 deletions

View File

@ -33,16 +33,10 @@
#include <Hadrons/Global.hpp> #include <Hadrons/Global.hpp>
#include <Hadrons/Module.hpp> #include <Hadrons/Module.hpp>
#include <Hadrons/ModuleFactory.hpp> #include <Hadrons/ModuleFactory.hpp>
#include <Hadrons/Solver.hpp>
/****************************************************************************** #include <Hadrons/EigenPack.hpp>
Needed to make sure envCreate() (see Hadrons) work with specialisations #include <Hadrons/A2AVectors.hpp>
with more than one parameter, eg obj<T1 COMMA T2> #include <Hadrons/DilutedNoise.hpp>
I imagine this exists already?
******************************************************************************/
#ifndef COMMA
#define COMMA ,
#endif
/****************************************************************************** /******************************************************************************
A consistent set of cross-platform methods for big endian <-> host byte ordering A consistent set of cross-platform methods for big endian <-> host byte ordering
@ -207,24 +201,53 @@ BEGIN_HADRONS_NAMESPACE
BEGIN_MODULE_NAMESPACE(MDistil) BEGIN_MODULE_NAMESPACE(MDistil)
using DistilEP = Grid::Hadrons::EigenPack<LatticeColourVector>; using LapEvecs = Grid::Hadrons::EigenPack<LatticeColourVector>;
// Noise vector index order: nnoise, nt, nvec, ns // Noise vector index order: nnoise, nt, nvec, ns
using NoiseTensor = Eigen::Tensor<Complex, 4, Eigen::RowMajor>; using NoiseTensor = Eigen::Tensor<Complex, 4, Eigen::RowMajor>;
struct DistilParameters: Serializable { struct DistilParameters: Serializable {
GRID_SERIALIZABLE_CLASS_MEMBERS(DistilParameters, GRID_SERIALIZABLE_CLASS_MEMBERS(DistilParameters,
int, TI,
int, LI,
int, nnoise, int, nnoise,
int, tsrc, int, tsrc,
int, SI, std::string, TI,
int, Ns, std::string, LI,
int, Nt_inv) std::string, SI )
DistilParameters() = default; DistilParameters() = default;
template <class ReaderClass> DistilParameters(Reader<ReaderClass>& Reader){read(Reader,"Distil",*this);} template <class ReaderClass> DistilParameters(Reader<ReaderClass>& Reader){read(Reader,"Distil",*this);}
// Numeric parameter is allowed to be empty (in which case it = Default),
// but assert during setup() if specified but not numeric
static int ParameterDefault( const std::string & s, int Default, bool bCalledFromSetup )
{
int i = Default;
if( s.length() > 0 ) {
std::istringstream ss( s );
ss >> i;
if( bCalledFromSetup )
assert( !ss.fail() && "Parameter should either be empty or integer" );
}
return i;
}
int getTI( const Environment & env, bool bCalledFromSetup ) const {
return ParameterDefault( TI, env.getDim(Tdir), bCalledFromSetup ); }
}; };
#define DISTIL_PARAMETERS_DEFINE( inSetup ) \
const int Nt{env().getDim(Tdir)}; \
const int nvec{par().nvec}; \
const int Ns{Grid::QCD::Ns}; \
const int nnoise{par().Distil.nnoise}; \
const int tsrc{par().Distil.tsrc}; \
const int TI{par().Distil.getTI(env(), inSetup)}; \
const int LI{Hadrons::MDistil::DistilParameters::ParameterDefault(par().Distil.LI, nvec, inSetup)}; \
const int SI{Hadrons::MDistil::DistilParameters::ParameterDefault(par().Distil.SI, Ns, inSetup)}; \
const bool full_tdil{ TI == Nt }; \
const bool exact_distillation{ full_tdil && LI == nvec }; \
const int Nt_inv{ full_tdil ? 1 : TI }
class BFieldIO: Serializable{ class BFieldIO: Serializable{
public: public:
using BaryonTensorSet = Eigen::Tensor<Complex, 7>; using BaryonTensorSet = Eigen::Tensor<Complex, 7>;
@ -299,7 +322,7 @@ public:
// Construct a named tensor explicitly specifying size of each dimension // Construct a named tensor explicitly specifying size of each dimension
template<typename... IndexTypes> template<typename... IndexTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NamedTensor(std::array<std::string,NumIndices_> &IndexNames_, Eigen::Index firstDimension, IndexTypes... otherDimensions) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NamedTensor(const std::array<std::string,NumIndices_> &IndexNames_, Eigen::Index firstDimension, IndexTypes... otherDimensions)
: tensor(firstDimension, otherDimensions...), IndexNames{NumIndices} : tensor(firstDimension, otherDimensions...), IndexNames{NumIndices}
{ {
// The number of dimensions used to construct a tensor must be equal to the rank of the tensor. // The number of dimensions used to construct a tensor must be equal to the rank of the tensor.
@ -343,8 +366,9 @@ template<typename T> struct is_named_tensor<T, typename std::enable_if<std::is_b
Endian_Scalar_Size can be removed once (deprecated) NamedTensor::ReadBinary & WriteBinary methods deleted Endian_Scalar_Size can be removed once (deprecated) NamedTensor::ReadBinary & WriteBinary methods deleted
******************************************************************************/ ******************************************************************************/
template<typename Scalar_, int NumIndices_, uint16_t Endian_Scalar_Size = sizeof(Scalar_)> //template<typename Scalar_, int NumIndices_, uint16_t Endian_Scalar_Size = sizeof(Scalar_)>
using Perambulator = NamedTensor<Scalar_, NumIndices_, Endian_Scalar_Size>; using Perambulator = NamedTensor<SpinVector, 6, sizeof(Real)>;
static const std::array<std::string, 6> PerambIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
/****************************************************************************** /******************************************************************************
Save NamedTensor binary format (NB: On-disk format is Big Endian) Save NamedTensor binary format (NB: On-disk format is Big Endian)

View File

@ -39,10 +39,8 @@
#include <Hadrons/Modules/MScalar/FreeProp.hpp> #include <Hadrons/Modules/MScalar/FreeProp.hpp>
#include <Hadrons/Modules/MScalar/Scalar.hpp> #include <Hadrons/Modules/MScalar/Scalar.hpp>
#include <Hadrons/Modules/MScalar/ChargedProp.hpp> #include <Hadrons/Modules/MScalar/ChargedProp.hpp>
#include <Hadrons/Modules/MDistil/DistilSource.hpp>
#include <Hadrons/Modules/MDistil/LapEvec.hpp> #include <Hadrons/Modules/MDistil/LapEvec.hpp>
#include <Hadrons/Modules/MDistil/DistilVectors.hpp> #include <Hadrons/Modules/MDistil/DistilVectors.hpp>
#include <Hadrons/Modules/MDistil/DistilSink.hpp>
#include <Hadrons/Modules/MDistil/Noises.hpp> #include <Hadrons/Modules/MDistil/Noises.hpp>
#include <Hadrons/Modules/MDistil/BC2.hpp> #include <Hadrons/Modules/MDistil/BC2.hpp>
#include <Hadrons/Modules/MDistil/Perambulator.hpp> #include <Hadrons/Modules/MDistil/Perambulator.hpp>

View File

@ -1,36 +0,0 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: Hadrons/Modules/MDistil/DistilSink.cc
Copyright (C) 2019
Author: Felix Erben <ferben@ed.ac.uk>
Author: Michael Marshall <Michael.Marshall@ed.ac.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/
/* END LEGAL */
#include <Hadrons/Modules/MDistil/DistilSink.hpp>
using namespace Grid;
using namespace Hadrons;
using namespace MDistil;
template class Grid::Hadrons::MDistil::TDistilSink<FIMPL>;

View File

@ -1,236 +0,0 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: Hadrons/Modules/MDistil/DistilSink.hpp
Copyright (C) 2019
Author: Felix Erben <ferben@ed.ac.uk>
Author: Michael Marshall <Michael.Marshall@ed.ac.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/
/* END LEGAL */
#ifndef Hadrons_MDistil_DistilSink_hpp_
#define Hadrons_MDistil_DistilSink_hpp_
#include <Hadrons/Global.hpp>
#include <Hadrons/Module.hpp>
#include <Hadrons/ModuleFactory.hpp>
#include <Hadrons/Solver.hpp>
#include <Hadrons/EigenPack.hpp>
#include <Hadrons/A2AVectors.hpp>
#include <Hadrons/DilutedNoise.hpp>
// These are members of Distillation
#include <Hadrons/Distil.hpp>
BEGIN_HADRONS_NAMESPACE
/******************************************************************************
* DistilSink *
******************************************************************************/
BEGIN_MODULE_NAMESPACE(MDistil)
class DistilSinkPar: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(DistilSinkPar,
std::string, perambulator,
std::string, eigenPack,
bool, multiFile,
int, tsrc,
int, nnoise,
int, LI,
int, SI,
int, TI,
int, nvec,
int, Ns,
int, Nt,
int, Nt_inv);
};
template <typename FImpl>
class TDistilSink: public Module<DistilSinkPar>
{
public:
FERM_TYPE_ALIASES(FImpl,);
public:
// constructor
TDistilSink(const std::string name);
// destructor
virtual ~TDistilSink(void);
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// setup
virtual void setup(void);
// execution
virtual void execute(void);
protected:
// These variables are created in setup() and freed in Cleanup()
GridCartesian * grid3d; // Owned by me, so I must delete it
GridCartesian * grid4d; // Owned by environment (so I won't delete it)
protected:
virtual void Cleanup(void);
};
MODULE_REGISTER_TMP(DistilSink, TDistilSink<FIMPL>, MDistil);
/******************************************************************************
* TDistilSink implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
template <typename FImpl>
TDistilSink<FImpl>::TDistilSink(const std::string name)
: grid3d{nullptr}, grid4d{nullptr}, Module<DistilSinkPar>(name)
{}
// destructor
template <typename FImpl>
TDistilSink<FImpl>::~TDistilSink(void)
{
Cleanup();
};
// dependencies/products ///////////////////////////////////////////////////////
template <typename FImpl>
std::vector<std::string> TDistilSink<FImpl>::getInput(void)
{
std::vector<std::string> in;
in.push_back(par().perambulator);
in.push_back(par().eigenPack);
return in;
}
template <typename FImpl>
std::vector<std::string> TDistilSink<FImpl>::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
template <typename FImpl>
void TDistilSink<FImpl>::setup(void)
{
Cleanup();
int nnoise=par().nnoise;
int LI=par().LI;
int Ns=par().Ns;
int SI=par().SI;
int Nt_inv=par().Nt_inv;
envCreate(std::vector<FermionField>, getName(), 1,
nnoise*LI*SI*Nt_inv, envGetGrid(FermionField));
grid4d = env().getGrid();
std::vector<int> latt_size = GridDefaultLatt();
std::vector<int> simd_layout = GridDefaultSimd(Nd, vComplex::Nsimd());
std::vector<int> mpi_layout = GridDefaultMpi();
std::vector<int> simd_layout_3 = GridDefaultSimd(Nd-1, vComplex::Nsimd());
latt_size[Nd-1] = 1;
simd_layout_3.push_back( 1 );
mpi_layout[Nd-1] = 1;
grid3d = MakeLowerDimGrid(grid4d);
envTmp(LatticeSpinColourVector, "tmp2",1,LatticeSpinColourVector(grid4d));
envTmp(LatticeColourVector, "tmp_nospin",1,LatticeColourVector(grid4d));
envTmp(LatticeSpinColourVector, "tmp3d",1,LatticeSpinColourVector(grid3d));
envTmp(LatticeColourVector, "tmp3d_nospin",1,LatticeColourVector(grid3d));
envTmp(LatticeSpinColourVector, "sink_tslice",1,LatticeSpinColourVector(grid3d));
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
}
// clean up any temporaries created by setup (that aren't stored in the environment)
template <typename FImpl>
void TDistilSink<FImpl>::Cleanup(void)
{
if( grid3d != nullptr ) {
delete grid3d;
grid3d = nullptr;
}
grid4d = nullptr;
}
// execution ///////////////////////////////////////////////////////////////////
template <typename FImpl>
void TDistilSink<FImpl>::execute(void)
{
auto &perambulator = envGet(Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, par().perambulator);
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
auto &phi = envGet(std::vector<FermionField>, getName());
envGetTmp(LatticeSpinColourVector, tmp2);
envGetTmp(LatticeColourVector, tmp_nospin);
envGetTmp(LatticeSpinColourVector, tmp3d);
envGetTmp(LatticeColourVector, tmp3d_nospin);
envGetTmp(LatticeSpinColourVector, sink_tslice);
envGetTmp(LatticeColourVector, evec3d);
int Ntlocal = grid4d->LocalDimensions()[3];
int Ntfirst = grid4d->LocalStarts()[3];
int tsrc=par().tsrc;
int nnoise=par().nnoise;
int LI=par().LI;
int SI=par().SI;
int Ns=par().Ns;
int Nt_inv=par().Nt_inv; // TODO: No input, but define through Nt, TI
int Nt=par().Nt;
int TI=par().TI;
int nvec=par().nvec;
bool full_tdil=(TI==Nt);
int vecindex;
int t_inv;
for (int inoise = 0; inoise < nnoise; inoise++) {
for (int dk = 0; dk < LI; dk++) {
for (int dt = 0; dt < Nt_inv; dt++) {
for (int ds = 0; ds < SI; ds++) {
vecindex = inoise + nnoise * dk + nnoise * LI * ds + nnoise *LI * SI*dt;
phi[vecindex] = zero;
for (int t = Ntfirst; t < Ntfirst + Ntlocal; t++) {
sink_tslice=zero;
for (int ivec = 0; ivec < nvec; ivec++) {
ExtractSliceLocal(evec3d,epack.evec[ivec],0,t,3);
sink_tslice += evec3d * perambulator(t, ivec, dk, inoise,dt,ds);
}
InsertSliceLocal(sink_tslice,phi[vecindex],0,t-Ntfirst,Grid::QCD::Tdir);
}
}
}
}
}
// TEST TO SEE WHETHER THIS MIGHT BE THE MEMORY LEAK
Cleanup();
}
END_MODULE_NAMESPACE
END_HADRONS_NAMESPACE
#endif // Hadrons_MDistil_DistilSink_hpp_

View File

@ -1,36 +0,0 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: Hadrons/Modules/MDistil/DistilSource.cc
Copyright (C) 2019
Author: Felix Erben <ferben@ed.ac.uk>
Author: Michael Marshall <Michael.Marshall@ed.ac.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/
/* END LEGAL */
#include <Hadrons/Modules/MDistil/DistilSource.hpp>
using namespace Grid;
using namespace Hadrons;
using namespace MDistil;
template class Grid::Hadrons::MDistil::TDistilSource<FIMPL>;

View File

@ -1,250 +0,0 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: Hadrons/Modules/MDistil/DistilSource.hpp
Copyright (C) 2019
Author: Felix Erben <ferben@ed.ac.uk>
Author: Michael Marshall <Michael.Marshall@ed.ac.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/
/* END LEGAL */
#ifndef Hadrons_MDistil_DistilSource_hpp_
#define Hadrons_MDistil_DistilSource_hpp_
#include <Hadrons/Global.hpp>
#include <Hadrons/Module.hpp>
#include <Hadrons/ModuleFactory.hpp>
#include <Hadrons/Solver.hpp>
#include <Hadrons/EigenPack.hpp>
#include <Hadrons/A2AVectors.hpp>
#include <Hadrons/DilutedNoise.hpp>
// These are members of Distillation
#include <Hadrons/Distil.hpp>
BEGIN_HADRONS_NAMESPACE
/******************************************************************************
* DistilSource *
******************************************************************************/
BEGIN_MODULE_NAMESPACE(MDistil)
class DistilSourcePar: Serializable
{
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(DistilSourcePar,
std::string, noise,
std::string, eigenPack,
bool, multiFile,
int, tsrc,
int, nnoise,
int, LI,
int, SI,
int, TI,
int, nvec,
int, Ns,
int, Nt,
int, Nt_inv);
};
template <typename FImpl>
class TDistilSource: public Module<DistilSourcePar>
{
public:
FERM_TYPE_ALIASES(FImpl,);
public:
// constructor
TDistilSource(const std::string name);
// destructor
virtual ~TDistilSource(void);
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// setup
virtual void setup(void);
// execution
virtual void execute(void);
protected:
// These variables are created in setup() and freed in Cleanup()
GridCartesian * grid3d; // Owned by me, so I must delete it
GridCartesian * grid4d; // Owned by environment (so I won't delete it)
protected:
virtual void Cleanup(void);
};
MODULE_REGISTER_TMP(DistilSource, TDistilSource<FIMPL>, MDistil);
/******************************************************************************
* TDistilSource implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
template <typename FImpl>
TDistilSource<FImpl>::TDistilSource(const std::string name)
: grid3d{nullptr}, grid4d{nullptr}, Module<DistilSourcePar>(name)
{}
// destructor
template <typename FImpl>
TDistilSource<FImpl>::~TDistilSource(void)
{
Cleanup();
};
// dependencies/products ///////////////////////////////////////////////////////
template <typename FImpl>
std::vector<std::string> TDistilSource<FImpl>::getInput(void)
{
std::vector<std::string> in;
in.push_back(par().noise);
in.push_back(par().eigenPack);
return in;
}
template <typename FImpl>
std::vector<std::string> TDistilSource<FImpl>::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
template <typename FImpl>
void TDistilSource<FImpl>::setup(void)
{
Cleanup();
auto &noise = envGet(std::vector<Complex>, par().noise);
int nnoise=par().nnoise;
int LI=par().LI;
int Ns=par().Ns;
int SI=par().SI;
int Nt_inv=par().Nt_inv;
envCreate(std::vector<FermionField>, getName(), 1,
nnoise*LI*SI*Nt_inv, envGetGrid(FermionField));
grid4d = env().getGrid();
std::vector<int> latt_size = GridDefaultLatt();
std::vector<int> simd_layout = GridDefaultSimd(Nd, vComplex::Nsimd());
std::vector<int> mpi_layout = GridDefaultMpi();
std::vector<int> simd_layout_3 = GridDefaultSimd(Nd-1, vComplex::Nsimd());
latt_size[Nd-1] = 1;
simd_layout_3.push_back( 1 );
mpi_layout[Nd-1] = 1;
grid3d = MakeLowerDimGrid(grid4d);
envTmp(LatticeSpinColourVector, "tmp2",1,LatticeSpinColourVector(grid4d));
envTmp(LatticeColourVector, "tmp_nospin",1,LatticeColourVector(grid4d));
envTmp(LatticeSpinColourVector, "tmp3d",1,LatticeSpinColourVector(grid3d));
envTmp(LatticeColourVector, "tmp3d_nospin",1,LatticeColourVector(grid3d));
envTmp(LatticeSpinColourVector, "sink_tslice",1,LatticeSpinColourVector(grid3d));
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
}
// clean up any temporaries created by setup (that aren't stored in the environment)
template <typename FImpl>
void TDistilSource<FImpl>::Cleanup(void)
{
if( grid3d != nullptr ) {
delete grid3d;
grid3d = nullptr;
}
grid4d = nullptr;
}
// execution ///////////////////////////////////////////////////////////////////
template <typename FImpl>
void TDistilSource<FImpl>::execute(void)
{
auto &noise = envGet(std::vector<Complex>, par().noise);
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
auto &rho = envGet(std::vector<FermionField>, getName());
envGetTmp(LatticeSpinColourVector, tmp2);
envGetTmp(LatticeColourVector, tmp_nospin);
envGetTmp(LatticeSpinColourVector, tmp3d);
envGetTmp(LatticeColourVector, tmp3d_nospin);
envGetTmp(LatticeSpinColourVector, sink_tslice);
envGetTmp(LatticeColourVector, evec3d);
int Ntlocal = grid4d->LocalDimensions()[3];
int Ntfirst = grid4d->LocalStarts()[3];
int tsrc=par().tsrc;
int nnoise=par().nnoise;
int LI=par().LI;
int Ns=par().Ns;
int Nt_inv=par().Nt_inv; // TODO: No input, but define through Nt, TI
int Nt=par().Nt;
int TI=par().TI;
int nvec=par().nvec;
int SI=par().SI;
bool full_tdil=(TI==Nt);
int vecindex;
int t_inv;
for (int inoise = 0; inoise < nnoise; inoise++) {
for (int dk = 0; dk < LI; dk++) {
for (int dt = 0; dt < Nt_inv; dt++) {
for (int ds = 0; ds < SI; ds++) {
vecindex = inoise + nnoise * dk + nnoise * LI * ds + nnoise *LI * SI*dt;
rho[vecindex] = zero;
tmp3d_nospin = zero;
for (int it = dt; it < Nt; it += TI){
if (full_tdil) t_inv = tsrc; else t_inv = it;
if( t_inv >= Ntfirst && t_inv < Ntfirst + Ntlocal ) {
for (int ik = dk; ik < nvec; ik += LI){
for (int is = ds; is < Ns; is += SI){
ExtractSliceLocal(evec3d,epack.evec[ik],0,t_inv,3);
tmp3d_nospin = evec3d * noise[inoise + nnoise*(t_inv + Nt*(ik+nvec*is))];
tmp3d=zero;
pokeSpin(tmp3d,tmp3d_nospin,is);
tmp2=zero;
InsertSliceLocal(tmp3d,tmp2,0,t_inv-Ntfirst,Grid::QCD::Tdir);
rho[vecindex] += tmp2;
}
}
}
}
}
}
}
}
// TEST TO SEE WHETHER THIS MIGHT BE THE MEMORY LEAK
Cleanup();
}
END_MODULE_NAMESPACE
END_HADRONS_NAMESPACE
#endif // Hadrons_MDistil_DistilSource_hpp_

View File

@ -60,12 +60,8 @@ public:
std::string, sink, std::string, sink,
bool, multiFile, bool, multiFile,
int, tsrc, int, tsrc,
int, LI, std::string, nvec,
int, SI, std::string, TI)
int, TI,
int, nvec,
int, Ns,
int, Nt_inv);
}; };
template <typename FImpl> template <typename FImpl>
@ -73,8 +69,6 @@ class TDistilVectors: public Module<DistilVectorsPar>
{ {
public: public:
FERM_TYPE_ALIASES(FImpl,); FERM_TYPE_ALIASES(FImpl,);
// This is the type of perambulator I expect
using DistilPeramb = Perambulator<SpinVector, 6, sizeof(Real)>;
// constructor // constructor
TDistilVectors(const std::string name); TDistilVectors(const std::string name);
// destructor // destructor
@ -100,7 +94,6 @@ public:
bool bMakeSink; bool bMakeSink;
std::string SourceName; std::string SourceName;
std::string SinkName; std::string SinkName;
int nnoise;
}; };
MODULE_REGISTER_TMP(DistilVectors, TDistilVectors<FIMPL>, MDistil); MODULE_REGISTER_TMP(DistilVectors, TDistilVectors<FIMPL>, MDistil);
@ -171,19 +164,24 @@ void TDistilVectors<FImpl>::setup(void)
{ {
Cleanup(); Cleanup();
auto &noise = envGet(NoiseTensor, NoiseVectorName); auto &noise = envGet(NoiseTensor, NoiseVectorName);
auto &perambulator = envGet(DistilPeramb, PerambulatorName); auto &perambulator = envGet(Perambulator, PerambulatorName);
// We expect the perambulator to have been created with these indices // We expect the perambulator to have been created with these indices
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"}; for(int i = 0; i < Perambulator::NumIndices; i++ )
for(int i = 0; i < DistilPeramb::NumIndices; i++ ) assert( PerambIndexNames[i] == perambulator.IndexNames[i] && "Perambulator indices bad" );
assert( sIndexNames[i] == perambulator.IndexNames[i] && "Perambulator indices bad" );
nnoise = static_cast<int>( noise.dimension(0) ); const int Nt{ env().getDim(Tdir) };
LOG(Message) << "NoiseTensor has " << nnoise << " noise vectors" << std::endl; assert( Nt == static_cast<int>( perambulator.tensor.dimension(0) ) && "Perambulator time dimensionality bad" );
int LI=par().LI; const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, true) };
int Ns=par().Ns; const int LI{ static_cast<int>( perambulator.tensor.dimension(2) ) };
int SI=par().SI; const int SI{ static_cast<int>( perambulator.tensor.dimension(5) ) };
int Nt_inv=par().Nt_inv; const int Nt_inv{ static_cast<int>( perambulator.tensor.dimension(4) ) };
const int nnoise{ static_cast<int>( perambulator.tensor.dimension(3) ) };
assert( nnoise >= static_cast<int>( noise.dimension(0) ) && "Not enough noise vectors for perambulator" );
// Nvec defaults to what's in the perambulator unless overriden
const int nvec_per{ static_cast<int>( perambulator.tensor.dimension(1) ) };
const int nvec{Hadrons::MDistil::DistilParameters::ParameterDefault(par().nvec, nvec_per, true) };
assert( nvec <= nvec_per && "Not enough distillation sub-space vectors" );
if( bMakeSource ) if( bMakeSource )
envCreate(std::vector<FermionField>, SourceName, 1, nnoise*LI*SI*Nt_inv, envGetGrid(FermionField)); envCreate(std::vector<FermionField>, SourceName, 1, nnoise*LI*SI*Nt_inv, envGetGrid(FermionField));
@ -225,30 +223,29 @@ template <typename FImpl>
void TDistilVectors<FImpl>::execute(void) void TDistilVectors<FImpl>::execute(void)
{ {
auto &noise = envGet(NoiseTensor, NoiseVectorName); auto &noise = envGet(NoiseTensor, NoiseVectorName);
auto &perambulator = envGet(DistilPeramb, PerambulatorName); auto &perambulator = envGet(Perambulator, PerambulatorName);
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, LapEvecName); auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, LapEvecName);
envGetTmp(LatticeSpinColourVector, tmp2); envGetTmp(LatticeSpinColourVector, tmp2);
//envGetTmp(LatticeColourVector, tmp_nospin);
envGetTmp(LatticeSpinColourVector, tmp3d); envGetTmp(LatticeSpinColourVector, tmp3d);
envGetTmp(LatticeColourVector, tmp3d_nospin); envGetTmp(LatticeColourVector, tmp3d_nospin);
envGetTmp(LatticeSpinColourVector, sink_tslice); envGetTmp(LatticeSpinColourVector, sink_tslice);
envGetTmp(LatticeColourVector, evec3d); envGetTmp(LatticeColourVector, evec3d);
const int Ntlocal{ grid4d->LocalDimensions()[3] };
const int Ntfirst{ grid4d->LocalStarts()[3] };
int Ntlocal = grid4d->LocalDimensions()[3]; const int Ns{ Grid::QCD::Ns };
int Ntfirst = grid4d->LocalStarts()[3]; const int Nt{ env().getDim(Tdir) };
const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, false ) };
int tsrc=par().tsrc; const int LI{ static_cast<int>( perambulator.tensor.dimension(2) ) };
int LI=par().LI; const int SI{ static_cast<int>( perambulator.tensor.dimension(5) ) };
int Ns=par().Ns; const int Nt_inv{ static_cast<int>( perambulator.tensor.dimension(4) ) };
int Nt_inv=par().Nt_inv; // TODO: No input, but define through Nt, TI const int nnoise{ static_cast<int>( perambulator.tensor.dimension(3) ) };
const int Nt{grid4d->GlobalDimensions()[Tdir]}; // Nvec defaults to what's in the perambulator unless overriden
int TI=par().TI; const int nvec{Hadrons::MDistil::DistilParameters::ParameterDefault(par().nvec, static_cast<int>( perambulator.tensor.dimension(1) ), false)};
int nvec=par().nvec; const int tsrc{ par().tsrc };
int SI=par().SI; const bool full_tdil{ TI==Nt };
bool full_tdil=(TI==Nt);
int vecindex; int vecindex;
int t_inv; int t_inv;

View File

@ -51,7 +51,7 @@ BEGIN_MODULE_NAMESPACE(MDistil)
struct StoutParameters: Serializable { struct StoutParameters: Serializable {
GRID_SERIALIZABLE_CLASS_MEMBERS(StoutParameters, GRID_SERIALIZABLE_CLASS_MEMBERS(StoutParameters,
int, steps, int, steps,
double, parm) // TODO: change name of this to rho double, rho) // TODO: change name of this to rho
StoutParameters() = default; StoutParameters() = default;
template <class ReaderClass> StoutParameters(Reader<ReaderClass>& Reader){read(Reader,"StoutSmearing",*this);} template <class ReaderClass> StoutParameters(Reader<ReaderClass>& Reader){read(Reader,"StoutSmearing",*this);}
}; };
@ -67,13 +67,10 @@ struct ChebyshevParameters: Serializable {
struct LanczosParameters: Serializable { struct LanczosParameters: Serializable {
GRID_SERIALIZABLE_CLASS_MEMBERS(LanczosParameters, GRID_SERIALIZABLE_CLASS_MEMBERS(LanczosParameters,
//int, Nstart,
int, Nvec, int, Nvec,
int, Nk, int, Nk,
//int, Nm, // Not currently used
int, Np, int, Np,
int, MaxIt, int, MaxIt,
//int, MinRes,
double, resid, double, resid,
int, IRLLog) int, IRLLog)
LanczosParameters() = default; LanczosParameters() = default;
@ -82,19 +79,12 @@ struct LanczosParameters: Serializable {
// These are the actual parameters passed to the module during construction // These are the actual parameters passed to the module during construction
class LapEvecPar: Serializable struct LapEvecPar: Serializable {
{ GRID_SERIALIZABLE_CLASS_MEMBERS(LapEvecPar
public: ,std::string, gauge
GRID_SERIALIZABLE_CLASS_MEMBERS(LapEvecPar, ,StoutParameters, Stout
std::string, gauge,
// std::string, ConfigFileDir,
// std::string, ConfigFileName,
//,std::string, EigenPackName
StoutParameters, Stout
,ChebyshevParameters, Cheby ,ChebyshevParameters, Cheby
,LanczosParameters, Lanczos ,LanczosParameters, Lanczos)
//,DistilParameters, Distil
)//,SolverParameters, Solver)
}; };
/****************************************************************************** /******************************************************************************
@ -123,7 +113,7 @@ protected:
// These variables are created in setup() and freed in Cleanup() // These variables are created in setup() and freed in Cleanup()
GridCartesian * gridLD; // Owned by me, so I must delete it GridCartesian * gridLD; // Owned by me, so I must delete it
GridCartesian * gridHD; // Owned by environment (so I won't delete it) GridCartesian * gridHD; // Owned by environment (so I won't delete it)
int Nx, Ny, Nz, Nt; std::string sGaugeName;
protected: protected:
virtual void Cleanup(void); virtual void Cleanup(void);
}; };
@ -151,8 +141,12 @@ TLapEvec<GImpl>::~TLapEvec()
template <typename GImpl> template <typename GImpl>
std::vector<std::string> TLapEvec<GImpl>::getInput(void) std::vector<std::string> TLapEvec<GImpl>::getInput(void)
{ {
std::vector<std::string> in = {par().gauge}; sGaugeName = par().gauge;
return in; if( sGaugeName.size() == 0 ) {
sGaugeName = getName();
sGaugeName.append( "_gauge" );
}
return std::vector<std::string>{ sGaugeName };
} }
template <typename GImpl> template <typename GImpl>
@ -170,19 +164,16 @@ void TLapEvec<GImpl>::setup(void)
Environment & e{env()}; Environment & e{env()};
gridHD = e.getGrid(); gridHD = e.getGrid();
gridLD = MakeLowerDimGrid( gridHD ); gridLD = MakeLowerDimGrid( gridHD );
Nx = gridHD->_fdimensions[Xdir]; const int Nt{e.getDim(Tdir)};
Ny = gridHD->_fdimensions[Ydir];
Nz = gridHD->_fdimensions[Zdir];
Nt = gridHD->_fdimensions[Tdir];
// Temporaries // Temporaries
//envTmpLat(GaugeField, "Umu"); envTmpLat(GaugeField, "Umu");
envTmpLat(GaugeField, "Umu_stout"); envTmpLat(GaugeField, "Umu_stout");
envTmpLat(GaugeField, "Umu_smear"); envTmpLat(GaugeField, "Umu_smear");
envTmp(LatticeGaugeField, "UmuNoTime",1,LatticeGaugeField(gridLD)); envTmp(LatticeGaugeField, "UmuNoTime",1,LatticeGaugeField(gridLD));
envTmp(LatticeColourVector, "src",1,LatticeColourVector(gridLD)); envTmp(LatticeColourVector, "src",1,LatticeColourVector(gridLD));
envTmp(std::vector<DistilEP>, "eig",1,std::vector<DistilEP>(Nt)); envTmp(std::vector<LapEvecs>, "eig",1,std::vector<LapEvecs>(Nt));
// Output objects // Output objects
envCreate(DistilEP, getName(), 1, par().Lanczos.Nvec, gridHD ); envCreate(LapEvecs, getName(), 1, par().Lanczos.Nvec, gridHD );
} }
// clean up any temporaries created by setup (that aren't stored in the environment) // clean up any temporaries created by setup (that aren't stored in the environment)
@ -206,35 +197,21 @@ void TLapEvec<GImpl>::execute(void)
{ {
const ChebyshevParameters &ChebPar{par().Cheby}; const ChebyshevParameters &ChebPar{par().Cheby};
const LanczosParameters &LPar{par().Lanczos}; const LanczosParameters &LPar{par().Lanczos};
const int &nvec{LPar.Nvec};
//const bool exact_distillation{TI==Nt && LI==nvec};
//const bool full_tdil{TI==Nt};
//const int &Nt_inv{full_tdil ? 1 : TI};
// Assertions on the parameters we read
//assert(TI>1);
//assert(LI>1);
//if(exact_distillation)
//assert(nnoise==1);
//else
//assert(nnoise>1);
// Disable IRL logging if requested // Disable IRL logging if requested
LOG(Message) << "IRLLog=" << LPar.IRLLog << std::endl; LOG(Message) << "IRLLog=" << LPar.IRLLog << std::endl;
const int PreviousIRLLogState{GridLogIRL.isActive()}; const int PreviousIRLLogState{GridLogIRL.isActive()};
GridLogIRL.Active( LPar.IRLLog == 0 ? 0 : 1 ); GridLogIRL.Active( LPar.IRLLog == 0 ? 0 : 1 );
auto &Umu = envGet(GaugeField, par().gauge);
envGetTmp(GaugeField, Umu_smear);
// Stout smearing // Stout smearing
Umu_smear = Umu; envGetTmp(GaugeField, Umu_smear);
LOG(Message) << "Initial plaquette: " << WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu) << std::endl;
{ {
auto &Umu = envGet(GaugeField, sGaugeName);
LOG(Message) << "Initial plaquette: " << WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu) << std::endl;
Umu_smear = Umu;
const StoutParameters &Stout{par().Stout}; const StoutParameters &Stout{par().Stout};
envGetTmp(GaugeField, Umu_stout); envGetTmp(GaugeField, Umu_stout);
Smear_Stout<PeriodicGimplR> LS(Stout.parm, Tdir); // spatial smearing only Smear_Stout<PeriodicGimplR> LS(Stout.rho, Tdir); // spatial smearing only
for (int i = 0; i < Stout.steps; i++) { for (int i = 0; i < Stout.steps; i++) {
LS.smear(Umu_stout, Umu_smear); LS.smear(Umu_stout, Umu_smear);
Umu_smear = Umu_stout; Umu_smear = Umu_stout;
@ -246,8 +223,8 @@ void TLapEvec<GImpl>::execute(void)
// Invert Peardon Nabla operator separately on each time-slice // Invert Peardon Nabla operator separately on each time-slice
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
auto & eig4d = envGet(DistilEP, getName() ); auto & eig4d = envGet(LapEvecs, getName() );
envGetTmp(std::vector<DistilEP>, eig); // Eigenpack for each timeslice envGetTmp(std::vector<LapEvecs>, eig); // Eigenpack for each timeslice
envGetTmp(LatticeGaugeField, UmuNoTime); // Gauge field without time dimension envGetTmp(LatticeGaugeField, UmuNoTime); // Gauge field without time dimension
envGetTmp(LatticeColourVector, src); envGetTmp(LatticeColourVector, src);
const int Ntlocal{gridHD->LocalDimensions()[Tdir]}; const int Ntlocal{gridHD->LocalDimensions()[Tdir]};
@ -267,12 +244,6 @@ void TLapEvec<GImpl>::execute(void)
<< " with parameters (alpha,beta) = (" << ChebPar.alpha << "," << ChebPar.beta << ")" << std::endl; << " with parameters (alpha,beta) = (" << ChebPar.alpha << "," << ChebPar.beta << ")" << std::endl;
Chebyshev<LatticeColourVector> Cheb(ChebPar.alpha,ChebPar.beta,ChebPar.PolyOrder); Chebyshev<LatticeColourVector> Cheb(ChebPar.alpha,ChebPar.beta,ChebPar.PolyOrder);
//from Test_Cheby.cc
//if( Ntfirst == 0 && t==0) {
//std::ofstream of("cheby_" + std::to_string(ChebPar.alpha) + "_" + std::to_string(ChebPar.beta) + "_" + std::to_string(ChebPar.PolyOrder));
//Cheb.csv(of);
//}
// Construct source vector according to Test_dwf_compressed_lanczos.cc // Construct source vector according to Test_dwf_compressed_lanczos.cc
src = 11.0; src = 11.0;
RealD nn = norm2(src); RealD nn = norm2(src);

View File

@ -52,9 +52,11 @@ class NoisesPar: Serializable
{ {
public: public:
GRID_SERIALIZABLE_CLASS_MEMBERS(NoisesPar, GRID_SERIALIZABLE_CLASS_MEMBERS(NoisesPar,
std::string, UniqueIdentifier, int, nnoise,
int, nvec, int, nvec,
DistilParameters, Distil); std::string, UniqueIdentifier,
std::string, TI,
std::string, LI)
}; };
template <typename FImpl> template <typename FImpl>
@ -103,36 +105,41 @@ std::vector<std::string> TNoises<FImpl>::getOutput(void)
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
template <typename FImpl> template <typename FImpl>
void TNoises<FImpl>::setup(void) void TNoises<FImpl>::setup(void)
{ {
const int Nt{env().getGrid()->GlobalDimensions()[Tdir]}; const int Nt{env().getDim(Tdir)};
const int Ns{Grid::QCD::Ns};
const int nnoise{par().nnoise};
const int nvec{par().nvec}; const int nvec{par().nvec};
const DistilParameters & Distil{par().Distil}; const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, true) };
//envCreate(std::vector<Complex>, getName(), 1, nvec*Distil.Ns*Distil.Nt*Distil.nnoise); const int LI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().LI, nvec, true) };
envCreate(NoiseTensor, getName(), 1, Distil.nnoise, Nt, nvec, Distil.Ns); envCreate(NoiseTensor, getName(), 1, nnoise, Nt, nvec, Ns);
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
template <typename FImpl> template <typename FImpl>
void TNoises<FImpl>::execute(void) void TNoises<FImpl>::execute(void)
{ {
const std::string &UniqueIdentifier{par().UniqueIdentifier}; const int Nt{env().getDim(Tdir)};
auto &noise = envGet(NoiseTensor, getName()); const int Ns{Grid::QCD::Ns};
const int nnoise{par().nnoise};
const int nvec{par().nvec}; const int nvec{par().nvec};
const DistilParameters & Distil{par().Distil}; const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, false) };
const int nnoise{Distil.nnoise}; const int LI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().LI, nvec, false) };
const int Nt{env().getGrid()->GlobalDimensions()[Tdir]}; const bool full_tdil{ TI == Nt }; \
const int Ns{Distil.Ns}; const bool exact_distillation{ full_tdil && LI == nvec }; \
const int TI{Distil.TI}; std::string UniqueIdentifier{par().UniqueIdentifier};
const int LI{Distil.LI}; if( UniqueIdentifier.length() == 0 ) {
const bool full_tdil{TI==Nt}; UniqueIdentifier = getName();
const bool exact_distillation{full_tdil && LI==nvec}; }
UniqueIdentifier.append( std::to_string( vm().getTrajectory() ) ); //maybe add more??
GridSerialRNG sRNG; GridSerialRNG sRNG;
sRNG.SeedUniqueString(UniqueIdentifier + std::to_string(vm().getTrajectory())); //maybe add more?? sRNG.SeedUniqueString(UniqueIdentifier);
Real rn; Real rn;
auto &noise = envGet(NoiseTensor, getName());
for( int inoise = 0; inoise < nnoise; inoise++ ) { for( int inoise = 0; inoise < nnoise; inoise++ ) {
for( int t = 0; t < Nt; t++ ) { for( int t = 0; t < Nt; t++ ) {
for( int ivec = 0; ivec < nvec; ivec++ ) { for( int ivec = 0; ivec < nvec; ivec++ ) {

View File

@ -47,21 +47,6 @@ BEGIN_HADRONS_NAMESPACE
* PerambFromSolve * * PerambFromSolve *
******************************************************************************/ ******************************************************************************/
BEGIN_MODULE_NAMESPACE(MDistil) BEGIN_MODULE_NAMESPACE(MDistil)
/*
struct DistilParameters: Serializable {
GRID_SERIALIZABLE_CLASS_MEMBERS(DistilParameters,
int, TI,
int, LI,
int, nnoise,
int, tsrc,
int, SI,
int, Ns,
int, Nt,
int, Nt_inv)
DistilParameters() = default;
template <class ReaderClass> DistilParameters(Reader<ReaderClass>& Reader){read(Reader,"Distil",*this);}
};
*/
class PerambFromSolvePar: Serializable class PerambFromSolvePar: Serializable
{ {
@ -122,91 +107,54 @@ TPerambFromSolve<FImpl>::~TPerambFromSolve(void)
template <typename FImpl> template <typename FImpl>
std::vector<std::string> TPerambFromSolve<FImpl>::getInput(void) std::vector<std::string> TPerambFromSolve<FImpl>::getInput(void)
{ {
std::vector<std::string> in; return std::vector<std::string>{ par().solve, par().eigenPack };
in.push_back(par().solve);
in.push_back(par().eigenPack);
return in;
} }
template <typename FImpl> template <typename FImpl>
std::vector<std::string> TPerambFromSolve<FImpl>::getOutput(void) std::vector<std::string> TPerambFromSolve<FImpl>::getOutput(void)
{ {
std::vector<std::string> out = {getName()}; return std::vector<std::string>{ getName() };
return out;
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
template <typename FImpl> template <typename FImpl>
void TPerambFromSolve<FImpl>::setup(void) void TPerambFromSolve<FImpl>::setup(void)
{ {
Cleanup(); Cleanup();
DISTIL_PARAMETERS_DEFINE( true );
const int nvec{par().nvec}; grid4d = env().getGrid();
const DistilParameters & Distil{par().Distil}; grid3d = MakeLowerDimGrid(grid4d);
const int LI{Distil.LI}; const int nvec_reduced{par().nvec_reduced};
const int nnoise{Distil.nnoise}; const int LI_reduced{par().LI_reduced};
const int Nt_inv{Distil.Nt_inv}; //std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
const int Ns{Distil.Ns}; envCreate(Perambulator, getName(), 1, PerambIndexNames,Nt,nvec_reduced,LI_reduced,nnoise,Nt_inv,SI);
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"}; envCreate(NoiseTensor, getName() + "_noise", 1, nnoise, Nt, nvec, Ns );
envTmp(LatticeColourVector, "result_3d",1,LatticeColourVector(grid3d));
grid4d = env().getGrid(); envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
grid3d = MakeLowerDimGrid(grid4d); envTmpLat(LatticeColourVector, "result_nospin");
const int Nt{grid4d->GlobalDimensions()[Tdir]};
const int nvec_reduced{par().nvec_reduced};
const int LI_reduced{par().LI_reduced};
//envCreate(Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, getName(), 1,
// sIndexNames,Distil.Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI);
envCreate(Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, getName(), 1,
sIndexNames,Nt,nvec_reduced,LI_reduced,Distil.nnoise,Distil.Nt_inv,Distil.SI);
envCreate(std::vector<Complex>, getName() + "_noise", 1,
nvec*Distil.Ns*Nt*Distil.nnoise);
envTmp(LatticeColourVector, "result_3d",1,LatticeColourVector(grid3d));
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
envTmpLat(LatticeColourVector, "result_nospin");
} }
template <typename FImpl> template <typename FImpl>
void TPerambFromSolve<FImpl>::Cleanup(void) void TPerambFromSolve<FImpl>::Cleanup(void)
{ {
if( grid3d != nullptr ) { if( grid3d != nullptr ) {
delete grid3d; delete grid3d;
grid3d = nullptr; grid3d = nullptr;
} }
grid4d = nullptr; grid4d = nullptr;
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
template <typename FImpl> template <typename FImpl>
void TPerambFromSolve<FImpl>::execute(void) void TPerambFromSolve<FImpl>::execute(void)
{ {
GridCartesian * grid4d = env().getGrid(); GridCartesian * grid4d = env().getGrid();
const int Nt{grid4d->GlobalDimensions()[Tdir]};
const int Ntlocal{grid4d->LocalDimensions()[3]}; const int Ntlocal{grid4d->LocalDimensions()[3]};
const int Ntfirst{grid4d->LocalStarts()[3]}; const int Ntfirst{grid4d->LocalStarts()[3]};
const int nvec_reduced{par().nvec_reduced}; const int nvec_reduced{par().nvec_reduced};
const int LI_reduced{par().LI_reduced}; const int LI_reduced{par().LI_reduced};
const int nvec{par().nvec}; DISTIL_PARAMETERS_DEFINE( false );
const DistilParameters & Distil{par().Distil}; auto &perambulator = envGet(Perambulator, getName());
const int LI{Distil.LI};
const int TI{Distil.TI};
const int SI{Distil.SI};
const int nnoise{Distil.nnoise};
const int Nt_inv{Distil.Nt_inv};
const int tsrc{Distil.tsrc};
const int Ns{Distil.Ns};
const bool full_tdil{TI==Nt};
const bool exact_distillation{full_tdil && LI==nvec};
auto &perambulator = envGet(Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, getName());
auto &solve = envGet(std::vector<FermionField>, par().solve); auto &solve = envGet(std::vector<FermionField>, par().solve);
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack); auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);

View File

@ -30,14 +30,6 @@
#ifndef Hadrons_MDistil_Perambulator_hpp_ #ifndef Hadrons_MDistil_Perambulator_hpp_
#define Hadrons_MDistil_Perambulator_hpp_ #define Hadrons_MDistil_Perambulator_hpp_
#include <Hadrons/Global.hpp>
#include <Hadrons/Module.hpp>
#include <Hadrons/ModuleFactory.hpp>
#include <Hadrons/Solver.hpp>
#include <Hadrons/EigenPack.hpp>
#include <Hadrons/A2AVectors.hpp>
#include <Hadrons/DilutedNoise.hpp>
// These are members of Distillation // These are members of Distillation
#include <Hadrons/Distil.hpp> #include <Hadrons/Distil.hpp>
@ -53,41 +45,42 @@ class PerambulatorPar: Serializable
{ {
public: public:
GRID_SERIALIZABLE_CLASS_MEMBERS(PerambulatorPar, GRID_SERIALIZABLE_CLASS_MEMBERS(PerambulatorPar,
std::string, eigenPack, std::string, lapevec,
std::string, solver,
std::string, noise, std::string, noise,
std::string, PerambFileName, //stem!!! std::string, PerambFileName, //stem!!!
std::string, UniqueIdentifier,
bool, multiFile, bool, multiFile,
int, nvec, int, nvec,
DistilParameters, Distil, DistilParameters, Distil);
std::string, solver);
}; };
template <typename FImpl> template <typename FImpl>
class TPerambulator: public Module<PerambulatorPar> class TPerambulator: public Module<PerambulatorPar>
{ {
public: public:
FERM_TYPE_ALIASES(FImpl,); FERM_TYPE_ALIASES(FImpl,);
SOLVER_TYPE_ALIASES(FImpl,); SOLVER_TYPE_ALIASES(FImpl,);
// constructor // constructor
TPerambulator(const std::string name); TPerambulator(const std::string name);
// destructor // destructor
virtual ~TPerambulator(void); virtual ~TPerambulator(void);
// dependency relation // dependency relation
virtual std::vector<std::string> getInput(void); virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void); virtual std::vector<std::string> getOutput(void);
// setup // setup
virtual void setup(void); virtual void setup(void);
// execution // execution
virtual void execute(void); virtual void execute(void);
protected: protected:
// These variables are created in setup() and freed in Cleanup() virtual void Cleanup(void);
GridCartesian * grid3d; // Owned by me, so I must delete it
GridCartesian * grid4d; // Owned by environment (so I won't delete it)
protected: protected:
virtual void Cleanup(void); // These variables are created in setup() and freed in Cleanup()
private: GridCartesian * grid3d; // Owned by me, so I must delete it
unsigned int Ls_; GridCartesian * grid4d; // Owned by environment (so I won't delete it)
// Other members
unsigned int Ls_;
std::string sLapEvecName;
std::string sNoiseName;
}; };
// Can't name the module Perambulator, because that's what we've called the object // Can't name the module Perambulator, because that's what we've called the object
@ -113,21 +106,17 @@ TPerambulator<FImpl>::~TPerambulator(void)
template <typename FImpl> template <typename FImpl>
std::vector<std::string> TPerambulator<FImpl>::getInput(void) std::vector<std::string> TPerambulator<FImpl>::getInput(void)
{ {
std::vector<std::string> in; sLapEvecName = par().lapevec;
sNoiseName = par().noise;
in.push_back(par().eigenPack); if( sNoiseName.length() == 0 )
in.push_back(par().solver); sNoiseName = getName() + "_noise";
in.push_back(par().noise); return {sLapEvecName, par().solver, sNoiseName };
return in;
} }
template <typename FImpl> template <typename FImpl>
std::vector<std::string> TPerambulator<FImpl>::getOutput(void) std::vector<std::string> TPerambulator<FImpl>::getOutput(void)
{ {
std::vector<std::string> out = {getName(),getName() + "_unsmeared_sink"}; return {getName(), getName() + "_unsmeared_sink"};
return out;
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
@ -137,17 +126,9 @@ void TPerambulator<FImpl>::setup(void)
Cleanup(); Cleanup();
grid4d = env().getGrid(); grid4d = env().getGrid();
grid3d = MakeLowerDimGrid(grid4d); grid3d = MakeLowerDimGrid(grid4d);
const int Nt{grid4d->GlobalDimensions()[Tdir]}; DISTIL_PARAMETERS_DEFINE( true );
const int nvec{par().nvec};
const DistilParameters & Distil{par().Distil};
const int LI{Distil.LI};
const int nnoise{Distil.nnoise};
const int Nt_inv{Distil.Nt_inv}; // TODO: PROBABLY BETTER: if (full_tdil) Nt_inv=1; else Nt_inv = TI;
const int Ns{Distil.Ns};
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
envCreate(Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, getName(), 1, envCreate(Perambulator, getName(), 1, PerambIndexNames,Nt,nvec,LI,nnoise,Nt_inv,SI);
sIndexNames,Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI);
envCreate(std::vector<FermionField>, getName() + "_unsmeared_sink", 1, envCreate(std::vector<FermionField>, getName() + "_unsmeared_sink", 1,
nnoise*LI*Ns*Nt_inv, envGetGrid(FermionField)); nnoise*LI*Ns*Nt_inv, envGetGrid(FermionField));
@ -181,18 +162,7 @@ void TPerambulator<FImpl>::Cleanup(void)
template <typename FImpl> template <typename FImpl>
void TPerambulator<FImpl>::execute(void) void TPerambulator<FImpl>::execute(void)
{ {
const int Nt{grid4d->GlobalDimensions()[Tdir]}; DISTIL_PARAMETERS_DEFINE( false );
const int nvec{par().nvec};
const DistilParameters & Distil{par().Distil};
const int LI{Distil.LI};
const int SI{Distil.SI};
const int TI{Distil.TI};
const int nnoise{Distil.nnoise};
const int tsrc{Distil.tsrc};
const int Ns{Distil.Ns};
const bool full_tdil{TI==Nt};
const bool exact_distillation{full_tdil && LI==nvec};
const int Nt_inv{full_tdil ? 1 : TI}; // TODO: PROBABLY BETTER: if (full_tdil) Nt_inv=1; else Nt_inv = TI;
auto &solver=envGet(Solver, par().solver); auto &solver=envGet(Solver, par().solver);
auto &mat = solver.getFMat(); auto &mat = solver.getFMat();
@ -200,12 +170,9 @@ void TPerambulator<FImpl>::execute(void)
envGetTmp(FermionField, v5dtmp); envGetTmp(FermionField, v5dtmp);
envGetTmp(FermionField, v5dtmp_sol); envGetTmp(FermionField, v5dtmp_sol);
const std::string &UniqueIdentifier{par().UniqueIdentifier}; auto &noise = envGet(NoiseTensor, sNoiseName);
auto &perambulator = envGet(Perambulator, getName());
//auto &noise = envGet(std::vector<Complex>, par().noise); auto &epack = envGet(LapEvecs, sLapEvecName);
auto &noise = envGet(NoiseTensor, par().noise);
auto &perambulator = envGet(Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, getName());
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
auto &unsmeared_sink = envGet(std::vector<FermionField>, getName() + "_unsmeared_sink"); auto &unsmeared_sink = envGet(std::vector<FermionField>, getName() + "_unsmeared_sink");

View File

@ -101,20 +101,16 @@ std::vector<std::string> TLoadPerambulator<FImpl>::getOutput(void)
template <typename FImpl> template <typename FImpl>
void TLoadPerambulator<FImpl>::setup(void) void TLoadPerambulator<FImpl>::setup(void)
{ {
GridCartesian * grid4d = env().getGrid(); DISTIL_PARAMETERS_DEFINE( true );
const int Nt{grid4d->GlobalDimensions()[Tdir]}; //std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
const int nvec{par().nvec}; envCreate(MDistil::Perambulator, getName(), 1, MDistil::PerambIndexNames,Nt,nvec,LI,nnoise,Nt_inv,SI);
const MDistil::DistilParameters & Distil{par().Distil};
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
envCreate(MDistil::Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, getName(), 1,
sIndexNames,Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI);
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
template <typename FImpl> template <typename FImpl>
void TLoadPerambulator<FImpl>::execute(void) void TLoadPerambulator<FImpl>::execute(void)
{ {
auto &perambulator = envGet(MDistil::Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, getName()); auto &perambulator = envGet(MDistil::Perambulator, getName());
const std::string sPerambName{par().PerambFileName + "." + std::to_string(vm().getTrajectory())}; const std::string sPerambName{par().PerambFileName + "." + std::to_string(vm().getTrajectory())};
perambulator.read(sPerambName.c_str()); perambulator.read(sPerambName.c_str());
} }

View File

@ -43,9 +43,7 @@ modules_cc =\
Modules/MDistil/BC2.cc \ Modules/MDistil/BC2.cc \
Modules/MDistil/Noises.cc \ Modules/MDistil/Noises.cc \
Modules/MDistil/BContraction.cc \ Modules/MDistil/BContraction.cc \
Modules/MDistil/DistilSource.cc \
Modules/MDistil/LapEvec.cc \ Modules/MDistil/LapEvec.cc \
Modules/MDistil/DistilSink.cc \
Modules/MDistil/Baryon2pt.cc \ Modules/MDistil/Baryon2pt.cc \
Modules/MDistil/Perambulator.cc \ Modules/MDistil/Perambulator.cc \
Modules/MDistil/PerambFromSolve.cc \ Modules/MDistil/PerambFromSolve.cc \
@ -118,10 +116,8 @@ modules_hpp =\
Modules/MScalar/FreeProp.hpp \ Modules/MScalar/FreeProp.hpp \
Modules/MScalar/Scalar.hpp \ Modules/MScalar/Scalar.hpp \
Modules/MScalar/ChargedProp.hpp \ Modules/MScalar/ChargedProp.hpp \
Modules/MDistil/DistilSource.hpp \
Modules/MDistil/LapEvec.hpp \ Modules/MDistil/LapEvec.hpp \
Modules/MDistil/DistilVectors.hpp \ Modules/MDistil/DistilVectors.hpp \
Modules/MDistil/DistilSink.hpp \
Modules/MDistil/Noises.hpp \ Modules/MDistil/Noises.hpp \
Modules/MDistil/BC2.hpp \ Modules/MDistil/BC2.hpp \
Modules/MDistil/Perambulator.hpp \ Modules/MDistil/Perambulator.hpp \

View File

@ -70,7 +70,7 @@ void test_SolverS(Application &application)
{ {
std::string boundary = "1 1 1 -1"; std::string boundary = "1 1 1 -1";
MAction::DWF::Par actionPar; MAction::DWF::Par actionPar;
actionPar.gauge = "gauge"; actionPar.gauge = "LapEvec_gauge";
actionPar.Ls = 16; actionPar.Ls = 16;
actionPar.M5 = 1.8; actionPar.M5 = 1.8;
actionPar.mass = 0.005; actionPar.mass = 0.005;
@ -90,19 +90,16 @@ void test_SolverS(Application &application)
void test_LapEvec(Application &application) void test_LapEvec(Application &application)
{ {
const char szGaugeName[] = "gauge"; const char szModuleName[] = "LapEvec";
// gauge field // gauge field
application.createModule<MGauge::Random>(szGaugeName); std::string sGaugeName{szModuleName};
sGaugeName.append( "_gauge" );
application.createModule<MGauge::Random>(sGaugeName);
// Now make an instance of the LapEvec object // Now make an instance of the LapEvec object
MDistil::LapEvecPar p; MDistil::LapEvecPar p;
p.gauge = szGaugeName; //p.gauge = sGaugeName; // This is the default for LapEvec, so no need to be explicit
//p.EigenPackName = "ePack";
//p.Distil.TI = 8;
//p.Distil.LI = 3;
//p.Distil.Nnoise = 2;
//p.Distil.tSrc = 0;
p.Stout.steps = 3; p.Stout.steps = 3;
p.Stout.parm = 0.2; p.Stout.rho = 0.2;
p.Cheby.PolyOrder = 11; p.Cheby.PolyOrder = 11;
p.Cheby.alpha = 0.3; p.Cheby.alpha = 0.3;
p.Cheby.beta = 12.5; p.Cheby.beta = 12.5;
@ -112,58 +109,90 @@ void test_LapEvec(Application &application)
p.Lanczos.MaxIt = 1000; p.Lanczos.MaxIt = 1000;
p.Lanczos.resid = 1e-2; p.Lanczos.resid = 1e-2;
p.Lanczos.IRLLog = 0; p.Lanczos.IRLLog = 0;
application.createModule<MDistil::LapEvec>("LapEvec",p); application.createModule<MDistil::LapEvec>(szModuleName,p);
}
/////////////////////////////////////////////////////////////
// Noises
/////////////////////////////////////////////////////////////
std::string test_Noises(Application &application, const std::string &sNoiseBaseName ) {
// DistilVectors parameters
MDistil::NoisesPar NoisePar;
NoisePar.nnoise = 1;
NoisePar.nvec = 5;
std::string sNoiseName{sNoiseBaseName + "_noise"};
application.createModule<MDistil::Noises>(sNoiseName,NoisePar);
return sNoiseName;
} }
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// Perambulators // Perambulators
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
void test_Perambulators(Application &application) void test_Perambulators( Application &application, const char * pszSuffix = nullptr )
{ {
std::string sModuleName{ "Peramb" };
if( pszSuffix )
sModuleName.append( pszSuffix );
test_Noises(application, sModuleName);
// Perambulator parameters // Perambulator parameters
MDistil::Peramb::Par PerambPar; MDistil::Peramb::Par PerambPar;
PerambPar.eigenPack="LapEvec"; PerambPar.lapevec = "LapEvec";
PerambPar.noise="Peramb_noise"; PerambPar.PerambFileName = sModuleName + ".bin";
PerambPar.PerambFileName="peramb.bin";
PerambPar.UniqueIdentifier="full_dilution";
PerambPar.solver="CG_s"; PerambPar.solver="CG_s";
PerambPar.Distil.tsrc = 0; PerambPar.Distil.tsrc = 0;
PerambPar.Distil.nnoise = 1; PerambPar.Distil.nnoise = 1;
PerambPar.Distil.LI=5;
PerambPar.Distil.SI=4;
PerambPar.Distil.TI=8;
PerambPar.nvec=5; PerambPar.nvec=5;
PerambPar.Distil.Ns=4; application.createModule<MDistil::Peramb>( sModuleName, PerambPar );
PerambPar.Distil.Nt_inv=1;
//PerambPar.Solver.mass=0.005;
//PerambPar.Solver.M5=1.8;
//PerambPar.Ls=16;
//PerambPar.Solver.CGPrecision=1e-8;
//PerambPar.Solver.MaxIterations=10000;
application.createModule<MDistil::Peramb>("Peramb",PerambPar);
} }
/////////////////////////////////////////////////////////////
// DistilVectors
/////////////////////////////////////////////////////////////
#define TEST_DISTIL_VECTORS_COMMON \
std::string sModuleName{"DistilVecs"}; \
if( pszSuffix ) \
sModuleName.append( pszSuffix ); \
std::string sPerambName{"Peramb"}; \
if( pszSuffix ) \
sPerambName.append( pszSuffix ); \
MDistil::DistilVectors::Par DistilVecPar; \
DistilVecPar.noise = sPerambName + "_noise"; \
DistilVecPar.perambulator = sPerambName; \
DistilVecPar.lapevec = "LapEvec"; \
DistilVecPar.tsrc = 0; \
if( pszNvec ) \
DistilVecPar.nvec = pszNvec
#define TEST_DISTIL_VECTORS_COMMON_END \
application.createModule<MDistil::DistilVectors>(sModuleName,DistilVecPar)
void test_DistilVectors(Application &application, const char * pszSuffix = nullptr, const char * pszNvec = nullptr )
{
TEST_DISTIL_VECTORS_COMMON;
TEST_DISTIL_VECTORS_COMMON_END;
}
void test_DistilVectorsSS(Application &application, const char * pszSink, const char * pszSource,
const char * pszSuffix = nullptr, const char * pszNvec = nullptr )
{
TEST_DISTIL_VECTORS_COMMON;
if( pszSink )
DistilVecPar.sink = pszSink;
if( pszSource )
DistilVecPar.source = pszSource;
TEST_DISTIL_VECTORS_COMMON_END;
}
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// Multiple Perambulators // Multiple Perambulators
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
void test_MultiPerambulators(Application &application) void test_MultiPerambulators(Application &application)
{ {
// Perambulator parameters test_Perambulators( application, "5" );
MDistil::Peramb::Par PerambPar;
PerambPar.eigenPack="LapEvec";
PerambPar.UniqueIdentifier="full_dilution";
PerambPar.PerambFileName="Peramb5";
PerambPar.solver="CG_s";
PerambPar.Distil.tsrc = 0;
PerambPar.Distil.nnoise = 1;
PerambPar.Distil.LI=5;
PerambPar.Distil.SI=4;
PerambPar.Distil.TI=8;
PerambPar.nvec=5;
PerambPar.Distil.Ns=4;
PerambPar.Distil.Nt_inv=1;
application.createModule<MDistil::Peramb>("Peramb5",PerambPar);
MDistil::PerambFromSolve::Par SolvePar; MDistil::PerambFromSolve::Par SolvePar;
SolvePar.eigenPack="LapEvec"; SolvePar.eigenPack="LapEvec";
SolvePar.PerambFileName="Peramb2"; SolvePar.PerambFileName="Peramb2";
@ -175,35 +204,16 @@ void test_MultiPerambulators(Application &application)
SolvePar.nvec=5; SolvePar.nvec=5;
SolvePar.nvec_reduced=2; SolvePar.nvec_reduced=2;
SolvePar.LI_reduced=2; SolvePar.LI_reduced=2;
SolvePar.Distil.Ns=4;
SolvePar.Distil.Nt_inv=1;
application.createModule<MDistil::PerambFromSolve>("Peramb2",SolvePar); application.createModule<MDistil::PerambFromSolve>("Peramb2",SolvePar);
SolvePar.PerambFileName="Peramb3"; SolvePar.PerambFileName="Peramb3";
SolvePar.nvec_reduced=3; SolvePar.nvec_reduced=3;
SolvePar.LI_reduced=3; SolvePar.LI_reduced=3;
application.createModule<MDistil::PerambFromSolve>("Peramb3",SolvePar); application.createModule<MDistil::PerambFromSolve>("Peramb3",SolvePar);
MDistil::DistilVectors::Par DistilVecPar;
DistilVecPar.noise="Peramb5_noise"; test_DistilVectors( application, "2", "2" );
DistilVecPar.perambulator="Peramb2"; test_DistilVectors( application, "3", "3" );
DistilVecPar.lapevec ="LapEvec"; test_DistilVectors( application, "5", "5" );
DistilVecPar.tsrc = 0;
//DistilVecPar.nnoise = 1;
DistilVecPar.LI=2;
DistilVecPar.SI=4;
DistilVecPar.TI=8;
DistilVecPar.nvec=2;
DistilVecPar.Ns=4;
DistilVecPar.Nt_inv=1;
application.createModule<MDistil::DistilVectors>("DistilVecs2",DistilVecPar);
DistilVecPar.perambulator="Peramb3";
DistilVecPar.LI=3;
DistilVecPar.nvec=3;
application.createModule<MDistil::DistilVectors>("DistilVecs3",DistilVecPar);
//DistilVecPar.perambulator="Peramb5_perambulator_light";
DistilVecPar.perambulator="Peramb5";
DistilVecPar.LI=5;
DistilVecPar.nvec=5;
application.createModule<MDistil::DistilVectors>("DistilVecs5",DistilVecPar);
MContraction::A2AMesonField::Par A2AMesonFieldPar; MContraction::A2AMesonField::Par A2AMesonFieldPar;
A2AMesonFieldPar.left="DistilVecs2_rho"; A2AMesonFieldPar.left="DistilVecs2_rho";
A2AMesonFieldPar.right="DistilVecs2_rho"; A2AMesonFieldPar.right="DistilVecs2_rho";
@ -235,88 +245,6 @@ void test_MultiPerambulators(Application &application)
application.createModule<MContraction::A2AMesonField>("DistilMesonFieldPhi5",A2AMesonFieldPar); application.createModule<MContraction::A2AMesonField>("DistilMesonFieldPhi5",A2AMesonFieldPar);
} }
void test_Noises(Application &application) {
// DistilVectors parameters
MDistil::NoisesPar NoisePar;
NoisePar.UniqueIdentifier = "full_dilution";
NoisePar.nvec = 5;
NoisePar.Distil.TI = 8;
NoisePar.Distil.SI = 4;
NoisePar.Distil.LI = 5;
NoisePar.Distil.nnoise = 1;
NoisePar.Distil.Ns = 4;
NoisePar.Distil.Nt_inv = 1;
NoisePar.Distil.tsrc = 0;
application.createModule<MDistil::Noises>("Peramb_noise",NoisePar);
}
/////////////////////////////////////////////////////////////
// DistilVectors
/////////////////////////////////////////////////////////////
void test_DistilVectors(Application &application)
{
test_Noises(application);
// DistilVectors parameters
MDistil::DistilVectors::Par DistilVecPar;
DistilVecPar.noise="Peramb_noise";
//DistilVecPar.perambulator="Peramb_perambulator_light";
DistilVecPar.perambulator="Peramb";
DistilVecPar.lapevec="LapEvec";
DistilVecPar.tsrc = 0;
DistilVecPar.LI=5;
DistilVecPar.SI=4;
DistilVecPar.TI=8;
DistilVecPar.nvec=5;
DistilVecPar.Ns=4;
DistilVecPar.Nt_inv=1;
application.createModule<MDistil::DistilVectors>("DistilVecs",DistilVecPar);
}
void test_PerambulatorsS(Application &application)
{
// Perambulator parameters
MDistil::Peramb::Par PerambPar;
PerambPar.eigenPack="LapEvec";
PerambPar.PerambFileName="perambS.bin";
PerambPar.UniqueIdentifier="full_dilution";
PerambPar.solver="CG_s";
PerambPar.Distil.tsrc = 0;
PerambPar.Distil.nnoise = 1;
PerambPar.Distil.LI=5;
PerambPar.Distil.SI=4;
PerambPar.Distil.TI=8;
PerambPar.nvec=5;
PerambPar.Distil.Ns=4;
PerambPar.Distil.Nt_inv=1;
//PerambPar.Solver.mass=0.005; //strange mass???
//PerambPar.Solver.M5=1.8;
//PerambPar.Ls=16;
//PerambPar.Solver.CGPrecision=1e-8;
//PerambPar.Solver.MaxIterations=10000;
application.createModule<MDistil::Peramb>("PerambS",PerambPar);
}
/////////////////////////////////////////////////////////////
// DistilVectors
/////////////////////////////////////////////////////////////
void test_DistilVectorsS(Application &application)
{
// DistilVectors parameters
MDistil::DistilVectors::Par DistilVecPar;
DistilVecPar.noise="PerambS_noise";
//DistilVecPar.perambulator="PerambS_perambulator_light";
DistilVecPar.perambulator="PerambS";
DistilVecPar.lapevec="LapEvec";
DistilVecPar.tsrc = 0;
//DistilVecPar.nnoise = 1;
DistilVecPar.LI=5;
DistilVecPar.SI=4;
DistilVecPar.TI=32;
DistilVecPar.nvec=5;
DistilVecPar.Ns=4;
DistilVecPar.Nt_inv=1;
application.createModule<MDistil::DistilVectors>("DistilVecsS",DistilVecPar);
}
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// MesonSink // MesonSink
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
@ -516,35 +444,10 @@ void test_PerambulatorsSolve(Application &application)
PerambFromSolvePar.PerambFileName="perambAslashS.bin"; PerambFromSolvePar.PerambFileName="perambAslashS.bin";
PerambFromSolvePar.Distil.tsrc = 0; PerambFromSolvePar.Distil.tsrc = 0;
PerambFromSolvePar.Distil.nnoise = 1; PerambFromSolvePar.Distil.nnoise = 1;
PerambFromSolvePar.Distil.LI=5;
PerambFromSolvePar.Distil.SI=4;
PerambFromSolvePar.Distil.TI=8;
PerambFromSolvePar.nvec=5; PerambFromSolvePar.nvec=5;
PerambFromSolvePar.Distil.Ns=4;
PerambFromSolvePar.Distil.Nt_inv=1;
application.createModule<MDistil::PerambFromSolve>("PerambAslashS",PerambFromSolvePar); application.createModule<MDistil::PerambFromSolve>("PerambAslashS",PerambFromSolvePar);
} }
/////////////////////////////////////////////////////////////
// DistilVectors
/////////////////////////////////////////////////////////////
void test_DistilVectorsAslashSeq(Application &application)
{
// DistilVectors parameters
MDistil::DistilSink::Par DistilSinkPar;
DistilSinkPar.perambulator="PerambAslashS";
DistilSinkPar.eigenPack="LapEvec";
DistilSinkPar.tsrc = 0;
DistilSinkPar.nnoise = 1;
DistilSinkPar.LI=5;
DistilSinkPar.SI=4;
DistilSinkPar.TI=8;
DistilSinkPar.nvec=5;
DistilSinkPar.Ns=4;
DistilSinkPar.Nt=8;
DistilSinkPar.Nt_inv=1;
application.createModule<MDistil::DistilSink>("DistilVecsAslashSeq",DistilSinkPar);
}
bool bNumber( int &ri, const char * & pstr, bool bGobbleWhiteSpace = true ) bool bNumber( int &ri, const char * & pstr, bool bGobbleWhiteSpace = true )
{ {
if( bGobbleWhiteSpace ) if( bGobbleWhiteSpace )
@ -702,7 +605,7 @@ bool DebugEigenTest()
// Test initialisation of an array of strings // Test initialisation of an array of strings
for( auto a : as ) for( auto a : as )
std::cout << a << std::endl; std::cout << a << std::endl;
Grid::Hadrons::MDistil::Perambulator<Complex,3,sizeof(Real)> p{as,2,7,2}; Grid::Hadrons::MDistil::NamedTensor<Complex,3,sizeof(Real)> p{as,2,7,2};
DebugShowTensor(p, "p"); DebugShowTensor(p, "p");
std::cout << "p.IndexNames follow" << std::endl; std::cout << "p.IndexNames follow" << std::endl;
for( auto a : p.IndexNames ) for( auto a : p.IndexNames )
@ -950,7 +853,7 @@ bool DebugGridTensorTest( void )
bool ConvertPeramb(const char * pszSource, const char * pszDest) { bool ConvertPeramb(const char * pszSource, const char * pszDest) {
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"}; std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
Grid::Hadrons::MDistil::Perambulator<SpinVector, 6, sizeof(Real)> p(sIndexNames); Grid::Hadrons::MDistil::Perambulator p(sIndexNames);
p.ReadBinary( pszSource ); p.ReadBinary( pszSource );
p.write(pszDest); p.write(pszDest);
return true; return true;
@ -1016,21 +919,21 @@ int main(int argc, char *argv[])
break; break;
case 2: case 2:
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_Perambulators( application ); test_Perambulators( application );
break; break;
default: // 3 default: // 3
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_Perambulators( application ); test_Perambulators( application );
test_DistilVectors( application ); test_DistilVectors( application );
break; break;
case 4: case 4:
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_Perambulators( application ); test_Perambulators( application );
test_DistilVectors( application ); test_DistilVectors( application );
test_MesonField( application, "Phi", "_phi" ); test_MesonField( application, "Phi", "_phi" );
@ -1038,28 +941,28 @@ int main(int argc, char *argv[])
break; break;
case 5: // 3 case 5: // 3
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_Perambulators( application ); test_Perambulators( application );
test_DistilVectors( application ); test_DistilVectors( application );
test_PerambulatorsS( application ); test_Perambulators( application, "S" );
test_DistilVectorsS( application ); test_DistilVectors( application, "S" );
test_MesonField( application, "SPhi", "S_phi" ); test_MesonField( application, "SPhi", "S_phi" );
test_MesonField( application, "SRho", "S_rho" ); test_MesonField( application, "SRho", "S_rho" );
break; break;
#ifdef DISTIL_PRE_RELEASE #ifdef DISTIL_PRE_RELEASE
case 6: // 3 case 6: // 3
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_Perambulators( application ); test_Perambulators( application );
test_g5_sinks( application ); test_g5_sinks( application );
test_MesonSink( application ); test_MesonSink( application );
break; break;
case 7: // 3 case 7: // 3
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_Perambulators( application ); test_Perambulators( application );
test_DistilVectors( application ); test_DistilVectors( application );
test_BaryonFieldPhi( application ); test_BaryonFieldPhi( application );
@ -1068,8 +971,8 @@ int main(int argc, char *argv[])
#endif #endif
case 8: // 3 case 8: // 3
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_Perambulators( application ); test_Perambulators( application );
test_DistilVectors( application ); test_DistilVectors( application );
test_MesonField( application, "Phi", "_phi" ); test_MesonField( application, "Phi", "_phi" );
@ -1083,8 +986,8 @@ int main(int argc, char *argv[])
break; break;
case 10: // 3 case 10: // 3
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_Perambulators( application ); test_Perambulators( application );
test_g5_sinks( application ); test_g5_sinks( application );
test_em( application ); test_em( application );
@ -1092,8 +995,8 @@ int main(int argc, char *argv[])
break; break;
case 11: // 3 case 11: // 3
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_Perambulators( application ); test_Perambulators( application );
test_DistilVectors( application ); test_DistilVectors( application );
test_BaryonFieldPhi2( application ); test_BaryonFieldPhi2( application );
@ -1102,26 +1005,31 @@ int main(int argc, char *argv[])
#endif #endif
case 12: // 3 case 12: // 3
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_PerambulatorsS( application ); test_SolverS( application );
test_Perambulators( application, "S" );
test_em( application ); test_em( application );
test_AslashSeq( application ); test_AslashSeq( application );
test_PerambulatorsSolve( application ); test_PerambulatorsSolve( application );
test_DistilVectorsAslashSeq( application ); test_DistilVectorsSS( application, "AslashSeq", nullptr, "S" );
test_MesonField( application, "AslashSeq" ); test_MesonField( application, "AslashSeq" );
break; break;
case 13: case 13:
test_Global( application ); test_Global( application );
test_SolverS( application );
test_LapEvec( application ); test_LapEvec( application );
test_SolverS( application );
test_MultiPerambulators( application ); test_MultiPerambulators( application );
break; break;
} }
// execution // execution
application.saveParameterFile("test_distil.xml"); static const char XmlFileName[] = "test_distil.xml";
LOG(Warning) << "These parameters are designed to run on a laptop usid --grid 4.4.4.8" << std::endl; application.saveParameterFile( XmlFileName );
application.run();
const std::vector<int> &lat{GridDefaultLatt()};
if( lat.size() == 4 && lat[0] == 4 && lat[1] == 4 && lat[2] == 4 && lat[3] == 8 )
application.run();
else
LOG(Warning) << "The parameters in " << XmlFileName << " are designed to run on a laptop usid --grid 4.4.4.8" << std::endl;
// epilogue // epilogue
LOG(Message) << "Grid is finalizing now" << std::endl; LOG(Message) << "Grid is finalizing now" << std::endl;