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

Merge branch 'feature/distil' of github.com:mmphys/Grid into feature/distil

Added index names to Perambulator
This commit is contained in:
Michael Marshall 2019-02-01 15:31:27 +00:00
commit 48528c5b1d
3 changed files with 59 additions and 31 deletions

View File

@ -4,4 +4,4 @@ using namespace Grid;
using namespace Hadrons; using namespace Hadrons;
using namespace MDistil; using namespace MDistil;
template class Grid::Hadrons::MDistil::TPerambLight<GIMPL>; template class Grid::Hadrons::MDistil::TPerambLight<FIMPL>;

View File

@ -56,11 +56,11 @@ public:
SolverParameters, Solver); SolverParameters, Solver);
}; };
template <typename GImpl> template <typename FImpl>
class TPerambLight: public Module<PerambLightPar> class TPerambLight: public Module<PerambLightPar>
{ {
public: public:
GAUGE_TYPE_ALIASES(GImpl,); FERM_TYPE_ALIASES(FImpl,);
// constructor // constructor
TPerambLight(const std::string name); TPerambLight(const std::string name);
// destructor // destructor
@ -81,27 +81,27 @@ protected:
virtual void Cleanup(void); virtual void Cleanup(void);
}; };
MODULE_REGISTER_TMP(PerambLight, TPerambLight<GIMPL>, MDistil); MODULE_REGISTER_TMP(PerambLight, TPerambLight<FIMPL>, MDistil);
/****************************************************************************** /******************************************************************************
* TPerambLight implementation * * TPerambLight implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
template <typename GImpl> template <typename FImpl>
TPerambLight<GImpl>::TPerambLight(const std::string name) TPerambLight<FImpl>::TPerambLight(const std::string name)
: grid3d{nullptr}, grid4d{nullptr}, Module<PerambLightPar>(name) : grid3d{nullptr}, grid4d{nullptr}, Module<PerambLightPar>(name)
{} {}
// destructor // destructor
template <typename GImpl> template <typename FImpl>
TPerambLight<GImpl>::~TPerambLight(void) TPerambLight<FImpl>::~TPerambLight(void)
{ {
Cleanup(); Cleanup();
}; };
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
template <typename GImpl> template <typename FImpl>
std::vector<std::string> TPerambLight<GImpl>::getInput(void) std::vector<std::string> TPerambLight<FImpl>::getInput(void)
{ {
std::vector<std::string> in; std::vector<std::string> in;
@ -110,27 +110,29 @@ std::vector<std::string> TPerambLight<GImpl>::getInput(void)
return in; return in;
} }
template <typename GImpl> template <typename FImpl>
std::vector<std::string> TPerambLight<GImpl>::getOutput(void) std::vector<std::string> TPerambLight<FImpl>::getOutput(void)
{ {
std::vector<std::string> out = {getName() + "_perambulator_light",getName() + "_noise"}; std::vector<std::string> out = {getName() + "_perambulator_light",getName() + "_noise",getName() + "_unsmeared_sink"};
return out; return out;
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
template <typename GImpl> template <typename FImpl>
void TPerambLight<GImpl>::setup(void) void TPerambLight<FImpl>::setup(void)
{ {
Cleanup(); Cleanup();
// auto &noise = envGet(std::vector<std::vector<std::vector<SpinVector>>>, par().noise); // auto &noise = envGet(std::vector<std::vector<std::vector<SpinVector>>>, par().noise);
const int nvec{par().nvec}; const int nvec{par().nvec};
const DistilParameters & Distil{par().Distil}; const DistilParameters & Distil{par().Distil};
//const char * IndexNames[6] = {"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"}; 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"}; std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
//std::complex<double> z{0.6,-3.1}; //std::complex<double> z{0.6,-3.1};
//envCreate(std::string, getName() + "_debug_delete_me", 1, "Bingonuts"); //envCreate(std::string, getName() + "_debug_delete_me", 1, "Bingonuts");
//envCreate(std::complex<double>, getName() + "_debug_delete_me_2", 1, 0.6); //envCreate(std::complex<double>, getName() + "_debug_delete_me_2", 1, 0.6);
//envCreate(std::complex<double>, getName() + "_debug_delete_me_3", 1, z); //envCreate(std::complex<double>, getName() + "_debug_delete_me_3", 1, z);
@ -140,6 +142,8 @@ void TPerambLight<GImpl>::setup(void)
sIndexNames,Distil.Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI); sIndexNames,Distil.Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI);
envCreate(std::vector<Complex>, getName() + "_noise", 1, envCreate(std::vector<Complex>, getName() + "_noise", 1,
nvec*Distil.Ns*Distil.Nt*Distil.nnoise); nvec*Distil.Ns*Distil.Nt*Distil.nnoise);
envCreate(std::vector<FermionField>, getName() + "_unsmeared_sink", 1,
nnoise*LI*Ns*Nt_inv, envGetGrid(FermionField));
grid4d = env().getGrid(); grid4d = env().getGrid();
grid3d = MakeLowerDimGrid(grid4d);//new GridCartesian(latt_size,simd_layout_3,mpi_layout,*grid4d); grid3d = MakeLowerDimGrid(grid4d);//new GridCartesian(latt_size,simd_layout_3,mpi_layout,*grid4d);
@ -159,8 +163,8 @@ void TPerambLight<GImpl>::setup(void)
} }
// 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)
template <typename GImpl> template <typename FImpl>
void TPerambLight<GImpl>::Cleanup(void) void TPerambLight<FImpl>::Cleanup(void)
{ {
if( grid3d != nullptr ) { if( grid3d != nullptr ) {
delete grid3d; delete grid3d;
@ -170,8 +174,8 @@ void TPerambLight<GImpl>::Cleanup(void)
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
template <typename GImpl> template <typename FImpl>
void TPerambLight<GImpl>::execute(void) void TPerambLight<FImpl>::execute(void)
{ {
const int nvec{par().nvec}; const int nvec{par().nvec};
const DistilParameters & Distil{par().Distil}; const DistilParameters & Distil{par().Distil};
@ -192,6 +196,7 @@ void TPerambLight<GImpl>::execute(void)
auto &noise = envGet(std::vector<Complex>, getName() + "_noise"); auto &noise = envGet(std::vector<Complex>, getName() + "_noise");
auto &perambulator = envGet(Perambulator<SpinVector COMMA 6>, getName() + "_perambulator_light"); auto &perambulator = envGet(Perambulator<SpinVector COMMA 6>, getName() + "_perambulator_light");
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack); auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
auto &unsmeared_sink = envGet(std::vector<FermionField>, getName() + "_unsmeared_sink");
envGetTmp(GaugeField, Umu); envGetTmp(GaugeField, Umu);
FieldMetaData header; FieldMetaData header;
@ -321,8 +326,8 @@ void TPerambLight<GImpl>::execute(void)
SchurSolver(Dop,src5,sol5); SchurSolver(Dop,src5,sol5);
Dop.ExportPhysicalFermionSolution(sol5,result); //These are the meson sinks Dop.ExportPhysicalFermionSolution(sol5,result); //These are the meson sinks
// TODO: Can we inherit something from MContraction to compute the fourier-transformed sinks??? // TODO: Can we inherit something from MContraction to compute the fourier-transformed sinks???
//if (compute_current_sink) if ((1)) // comment out if unsmeared sink is too large???
// current_sink[inoise+nnoise*(dk+LI*(dt+Nt_inv*ds))] = result; unsmeared_sink[inoise+nnoise*(dk+LI*(dt+Nt_inv*ds))] = result;
std::cout << "Contraction of perambulator from noise " << inoise << " and dilution component (d_k,d_t,d_alpha) : (" << dk << ","<< dt << "," << ds << ")" << std::endl; std::cout << "Contraction of perambulator from noise " << inoise << " and dilution component (d_k,d_t,d_alpha) : (" << dk << ","<< dt << "," << ds << ")" << std::endl;
for (int is = 0; is < Ns; is++) { for (int is = 0; is < Ns; is++) {
result_nospin = peekSpin(result,is); result_nospin = peekSpin(result,is);
@ -347,7 +352,7 @@ void TPerambLight<GImpl>::execute(void)
perambulator.SliceShare( grid3d, grid4d ); perambulator.SliceShare( grid3d, grid4d );
// THIS IS WHERE WE WANT TO SAVE THE PERAMBULATORS TO DISK // THIS IS WHERE WE WANT TO SAVE THE PERAMBULATORS TO DISK
perambulator.WriteTemporary(std::string("perambulators/file")); perambulator.WriteTemporary(std::string("perambulators/file")); // TODO: Specify the file name in the xml
} }

View File

@ -169,22 +169,21 @@ void test_DistilVectorsS(Application &application)
application.createModule<MDistil::DistilVectors>("DistilVecsS",DistilVecPar); application.createModule<MDistil::DistilVectors>("DistilVecsS",DistilVecPar);
} }
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// MesonFields // MesonSink
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
void test_MesonField(Application &application) void test_MesonSink(Application &application)
{ {
// DistilVectors parameters // DistilVectors parameters
MContraction::A2AMesonField::Par A2AMesonFieldPar; MContraction::A2AMesonField::Par A2AMesonFieldPar;
A2AMesonFieldPar.left="DistilVecs_phi"; A2AMesonFieldPar.left="Peramb_unsmeared_sink";
//A2AMesonFieldPar.right="DistilVecs_rho"; A2AMesonFieldPar.right="Peramb_unsmeared_sink";
A2AMesonFieldPar.right="DistilVecs_phi";
A2AMesonFieldPar.output="DistilFields"; A2AMesonFieldPar.output="DistilFields";
A2AMesonFieldPar.gammas="all"; A2AMesonFieldPar.gammas="all";
A2AMesonFieldPar.mom={"0 0 0"}; A2AMesonFieldPar.mom={"0 0 0"};
A2AMesonFieldPar.cacheBlock=2; A2AMesonFieldPar.cacheBlock=2;
A2AMesonFieldPar.block=4; A2AMesonFieldPar.block=4;
application.createModule<MContraction::A2AMesonField>("DistilMesonField",A2AMesonFieldPar); application.createModule<MContraction::A2AMesonField>("DistilMesonSink",A2AMesonFieldPar);
} }
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// MesonFields // MesonFields
@ -197,7 +196,25 @@ void test_MesonFieldSL(Application &application)
A2AMesonFieldPar.left="DistilVecsS_phi"; A2AMesonFieldPar.left="DistilVecsS_phi";
//A2AMesonFieldPar.right="DistilVecs_rho"; //A2AMesonFieldPar.right="DistilVecs_rho";
A2AMesonFieldPar.right="DistilVecs_phi"; A2AMesonFieldPar.right="DistilVecs_phi";
A2AMesonFieldPar.output="DistilFields"; A2AMesonFieldPar.output="DistilFieldsS";
A2AMesonFieldPar.gammas="all";
A2AMesonFieldPar.mom={"0 0 0"};
A2AMesonFieldPar.cacheBlock=2;
A2AMesonFieldPar.block=4;
application.createModule<MContraction::A2AMesonField>("DistilMesonFieldS",A2AMesonFieldPar);
}
/////////////////////////////////////////////////////////////
// MesonFields
/////////////////////////////////////////////////////////////
void test_MesonField(Application &application)
{
// DistilVectors parameters
MContraction::A2AMesonField::Par A2AMesonFieldPar;
A2AMesonFieldPar.left="DistilVecs_phi";
//A2AMesonFieldPar.right="DistilVecs_rho";
A2AMesonFieldPar.right="DistilVecs_phi";
A2AMesonFieldPar.output="MesonSinks";
A2AMesonFieldPar.gammas="all"; A2AMesonFieldPar.gammas="all";
A2AMesonFieldPar.mom={"0 0 0"}; A2AMesonFieldPar.mom={"0 0 0"};
A2AMesonFieldPar.cacheBlock=2; A2AMesonFieldPar.cacheBlock=2;
@ -374,6 +391,12 @@ int main(int argc, char *argv[])
test_DistilVectorsS( application ); test_DistilVectorsS( application );
test_MesonFieldSL( application ); test_MesonFieldSL( application );
break; break;
case 6: // 3
test_Global( application );
test_LapEvec( application );
test_Perambulators( application );
test_MesonSink( application );
break;
} }
LOG(Message) << "====== XML creation for test " << iTestNum << " complete ======" << std::endl; LOG(Message) << "====== XML creation for test " << iTestNum << " complete ======" << std::endl;