mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-17 23:37:06 +01:00
Fairly close to ready for release. Felix and I to review, then submit for release
This commit is contained in:
@ -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>;
|
@ -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_
|
@ -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>;
|
@ -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_
|
@ -60,12 +60,8 @@ public:
|
||||
std::string, sink,
|
||||
bool, multiFile,
|
||||
int, tsrc,
|
||||
int, LI,
|
||||
int, SI,
|
||||
int, TI,
|
||||
int, nvec,
|
||||
int, Ns,
|
||||
int, Nt_inv);
|
||||
std::string, nvec,
|
||||
std::string, TI)
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
@ -73,8 +69,6 @@ class TDistilVectors: public Module<DistilVectorsPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
// This is the type of perambulator I expect
|
||||
using DistilPeramb = Perambulator<SpinVector, 6, sizeof(Real)>;
|
||||
// constructor
|
||||
TDistilVectors(const std::string name);
|
||||
// destructor
|
||||
@ -100,7 +94,6 @@ public:
|
||||
bool bMakeSink;
|
||||
std::string SourceName;
|
||||
std::string SinkName;
|
||||
int nnoise;
|
||||
};
|
||||
|
||||
MODULE_REGISTER_TMP(DistilVectors, TDistilVectors<FIMPL>, MDistil);
|
||||
@ -171,19 +164,24 @@ void TDistilVectors<FImpl>::setup(void)
|
||||
{
|
||||
Cleanup();
|
||||
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
|
||||
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
||||
for(int i = 0; i < DistilPeramb::NumIndices; i++ )
|
||||
assert( sIndexNames[i] == perambulator.IndexNames[i] && "Perambulator indices bad" );
|
||||
for(int i = 0; i < Perambulator::NumIndices; i++ )
|
||||
assert( PerambIndexNames[i] == perambulator.IndexNames[i] && "Perambulator indices bad" );
|
||||
|
||||
nnoise = static_cast<int>( noise.dimension(0) );
|
||||
LOG(Message) << "NoiseTensor has " << nnoise << " noise vectors" << std::endl;
|
||||
int LI=par().LI;
|
||||
int Ns=par().Ns;
|
||||
int SI=par().SI;
|
||||
int Nt_inv=par().Nt_inv;
|
||||
const int Nt{ env().getDim(Tdir) };
|
||||
assert( Nt == static_cast<int>( perambulator.tensor.dimension(0) ) && "Perambulator 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) ) };
|
||||
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 )
|
||||
envCreate(std::vector<FermionField>, SourceName, 1, nnoise*LI*SI*Nt_inv, envGetGrid(FermionField));
|
||||
@ -225,31 +223,30 @@ template <typename FImpl>
|
||||
void TDistilVectors<FImpl>::execute(void)
|
||||
{
|
||||
auto &noise = envGet(NoiseTensor, NoiseVectorName);
|
||||
auto &perambulator = envGet(DistilPeramb, PerambulatorName);
|
||||
auto &perambulator = envGet(Perambulator, PerambulatorName);
|
||||
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, LapEvecName);
|
||||
|
||||
envGetTmp(LatticeSpinColourVector, tmp2);
|
||||
//envGetTmp(LatticeColourVector, tmp_nospin);
|
||||
envGetTmp(LatticeSpinColourVector, tmp3d);
|
||||
envGetTmp(LatticeColourVector, tmp3d_nospin);
|
||||
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 LI=par().LI;
|
||||
int Ns=par().Ns;
|
||||
int Nt_inv=par().Nt_inv; // TODO: No input, but define through Nt, TI
|
||||
const int Nt{grid4d->GlobalDimensions()[Tdir]};
|
||||
int TI=par().TI;
|
||||
int nvec=par().nvec;
|
||||
int SI=par().SI;
|
||||
|
||||
bool full_tdil=(TI==Nt);
|
||||
|
||||
envGetTmp(LatticeColourVector, evec3d);
|
||||
|
||||
const int Ntlocal{ grid4d->LocalDimensions()[3] };
|
||||
const int Ntfirst{ grid4d->LocalStarts()[3] };
|
||||
|
||||
const int Ns{ Grid::QCD::Ns };
|
||||
const int Nt{ env().getDim(Tdir) };
|
||||
const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, false ) };
|
||||
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) ) };
|
||||
const int nnoise{ static_cast<int>( perambulator.tensor.dimension(3) ) };
|
||||
// Nvec defaults to what's in the perambulator unless overriden
|
||||
const int nvec{Hadrons::MDistil::DistilParameters::ParameterDefault(par().nvec, static_cast<int>( perambulator.tensor.dimension(1) ), false)};
|
||||
const int tsrc{ par().tsrc };
|
||||
const bool full_tdil{ TI==Nt };
|
||||
|
||||
int vecindex;
|
||||
int t_inv;
|
||||
if( bMakeSource ) {
|
||||
|
@ -51,7 +51,7 @@ BEGIN_MODULE_NAMESPACE(MDistil)
|
||||
struct StoutParameters: Serializable {
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(StoutParameters,
|
||||
int, steps,
|
||||
double, parm) // TODO: change name of this to rho
|
||||
double, rho) // TODO: change name of this to rho
|
||||
StoutParameters() = default;
|
||||
template <class ReaderClass> StoutParameters(Reader<ReaderClass>& Reader){read(Reader,"StoutSmearing",*this);}
|
||||
};
|
||||
@ -67,13 +67,10 @@ struct ChebyshevParameters: Serializable {
|
||||
|
||||
struct LanczosParameters: Serializable {
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(LanczosParameters,
|
||||
//int, Nstart,
|
||||
int, Nvec,
|
||||
int, Nk,
|
||||
//int, Nm, // Not currently used
|
||||
int, Np,
|
||||
int, MaxIt,
|
||||
//int, MinRes,
|
||||
double, resid,
|
||||
int, IRLLog)
|
||||
LanczosParameters() = default;
|
||||
@ -82,19 +79,12 @@ struct LanczosParameters: Serializable {
|
||||
|
||||
// These are the actual parameters passed to the module during construction
|
||||
|
||||
class LapEvecPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(LapEvecPar,
|
||||
std::string, gauge,
|
||||
// std::string, ConfigFileDir,
|
||||
// std::string, ConfigFileName,
|
||||
//,std::string, EigenPackName
|
||||
StoutParameters, Stout
|
||||
struct LapEvecPar: Serializable {
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(LapEvecPar
|
||||
,std::string, gauge
|
||||
,StoutParameters, Stout
|
||||
,ChebyshevParameters, Cheby
|
||||
,LanczosParameters, Lanczos
|
||||
//,DistilParameters, Distil
|
||||
)//,SolverParameters, Solver)
|
||||
,LanczosParameters, Lanczos)
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
@ -123,7 +113,7 @@ protected:
|
||||
// These variables are created in setup() and freed in Cleanup()
|
||||
GridCartesian * gridLD; // Owned by me, so I must delete it
|
||||
GridCartesian * gridHD; // Owned by environment (so I won't delete it)
|
||||
int Nx, Ny, Nz, Nt;
|
||||
std::string sGaugeName;
|
||||
protected:
|
||||
virtual void Cleanup(void);
|
||||
};
|
||||
@ -151,8 +141,12 @@ TLapEvec<GImpl>::~TLapEvec()
|
||||
template <typename GImpl>
|
||||
std::vector<std::string> TLapEvec<GImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().gauge};
|
||||
return in;
|
||||
sGaugeName = par().gauge;
|
||||
if( sGaugeName.size() == 0 ) {
|
||||
sGaugeName = getName();
|
||||
sGaugeName.append( "_gauge" );
|
||||
}
|
||||
return std::vector<std::string>{ sGaugeName };
|
||||
}
|
||||
|
||||
template <typename GImpl>
|
||||
@ -170,19 +164,16 @@ void TLapEvec<GImpl>::setup(void)
|
||||
Environment & e{env()};
|
||||
gridHD = e.getGrid();
|
||||
gridLD = MakeLowerDimGrid( gridHD );
|
||||
Nx = gridHD->_fdimensions[Xdir];
|
||||
Ny = gridHD->_fdimensions[Ydir];
|
||||
Nz = gridHD->_fdimensions[Zdir];
|
||||
Nt = gridHD->_fdimensions[Tdir];
|
||||
const int Nt{e.getDim(Tdir)};
|
||||
// Temporaries
|
||||
//envTmpLat(GaugeField, "Umu");
|
||||
envTmpLat(GaugeField, "Umu");
|
||||
envTmpLat(GaugeField, "Umu_stout");
|
||||
envTmpLat(GaugeField, "Umu_smear");
|
||||
envTmp(LatticeGaugeField, "UmuNoTime",1,LatticeGaugeField(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
|
||||
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)
|
||||
@ -206,35 +197,21 @@ void TLapEvec<GImpl>::execute(void)
|
||||
{
|
||||
const ChebyshevParameters &ChebPar{par().Cheby};
|
||||
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
|
||||
LOG(Message) << "IRLLog=" << LPar.IRLLog << std::endl;
|
||||
const int PreviousIRLLogState{GridLogIRL.isActive()};
|
||||
GridLogIRL.Active( LPar.IRLLog == 0 ? 0 : 1 );
|
||||
|
||||
auto &Umu = envGet(GaugeField, par().gauge);
|
||||
envGetTmp(GaugeField, Umu_smear);
|
||||
|
||||
// Stout smearing
|
||||
Umu_smear = Umu;
|
||||
LOG(Message) << "Initial plaquette: " << WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu) << std::endl;
|
||||
envGetTmp(GaugeField, Umu_smear);
|
||||
{
|
||||
auto &Umu = envGet(GaugeField, sGaugeName);
|
||||
LOG(Message) << "Initial plaquette: " << WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu) << std::endl;
|
||||
Umu_smear = Umu;
|
||||
const StoutParameters &Stout{par().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++) {
|
||||
LS.smear(Umu_stout, Umu_smear);
|
||||
Umu_smear = Umu_stout;
|
||||
@ -246,8 +223,8 @@ void TLapEvec<GImpl>::execute(void)
|
||||
// Invert Peardon Nabla operator separately on each time-slice
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
auto & eig4d = envGet(DistilEP, getName() );
|
||||
envGetTmp(std::vector<DistilEP>, eig); // Eigenpack for each timeslice
|
||||
auto & eig4d = envGet(LapEvecs, getName() );
|
||||
envGetTmp(std::vector<LapEvecs>, eig); // Eigenpack for each timeslice
|
||||
envGetTmp(LatticeGaugeField, UmuNoTime); // Gauge field without time dimension
|
||||
envGetTmp(LatticeColourVector, src);
|
||||
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;
|
||||
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
|
||||
src = 11.0;
|
||||
RealD nn = norm2(src);
|
||||
|
@ -52,9 +52,11 @@ class NoisesPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(NoisesPar,
|
||||
std::string, UniqueIdentifier,
|
||||
int, nnoise,
|
||||
int, nvec,
|
||||
DistilParameters, Distil);
|
||||
std::string, UniqueIdentifier,
|
||||
std::string, TI,
|
||||
std::string, LI)
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
@ -103,36 +105,41 @@ std::vector<std::string> TNoises<FImpl>::getOutput(void)
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename FImpl>
|
||||
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 DistilParameters & Distil{par().Distil};
|
||||
//envCreate(std::vector<Complex>, getName(), 1, nvec*Distil.Ns*Distil.Nt*Distil.nnoise);
|
||||
envCreate(NoiseTensor, getName(), 1, Distil.nnoise, Nt, nvec, Distil.Ns);
|
||||
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);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TNoises<FImpl>::execute(void)
|
||||
{
|
||||
const std::string &UniqueIdentifier{par().UniqueIdentifier};
|
||||
auto &noise = envGet(NoiseTensor, getName());
|
||||
const int Nt{env().getDim(Tdir)};
|
||||
const int Ns{Grid::QCD::Ns};
|
||||
const int nnoise{par().nnoise};
|
||||
const int nvec{par().nvec};
|
||||
const DistilParameters & Distil{par().Distil};
|
||||
const int nnoise{Distil.nnoise};
|
||||
const int Nt{env().getGrid()->GlobalDimensions()[Tdir]};
|
||||
const int Ns{Distil.Ns};
|
||||
const int TI{Distil.TI};
|
||||
const int LI{Distil.LI};
|
||||
const bool full_tdil{TI==Nt};
|
||||
const bool exact_distillation{full_tdil && LI==nvec};
|
||||
const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, false) };
|
||||
const int LI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().LI, nvec, false) };
|
||||
const bool full_tdil{ TI == Nt }; \
|
||||
const bool exact_distillation{ full_tdil && LI == nvec }; \
|
||||
std::string UniqueIdentifier{par().UniqueIdentifier};
|
||||
if( UniqueIdentifier.length() == 0 ) {
|
||||
UniqueIdentifier = getName();
|
||||
}
|
||||
UniqueIdentifier.append( std::to_string( vm().getTrajectory() ) ); //maybe add more??
|
||||
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedUniqueString(UniqueIdentifier + std::to_string(vm().getTrajectory())); //maybe add more??
|
||||
sRNG.SeedUniqueString(UniqueIdentifier);
|
||||
Real rn;
|
||||
|
||||
auto &noise = envGet(NoiseTensor, getName());
|
||||
for( int inoise = 0; inoise < nnoise; inoise++ ) {
|
||||
for( int t = 0; t < Nt; t++ ) {
|
||||
for( int ivec = 0; ivec < nvec; ivec++ ) {
|
||||
|
@ -47,21 +47,6 @@ BEGIN_HADRONS_NAMESPACE
|
||||
* PerambFromSolve *
|
||||
******************************************************************************/
|
||||
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
|
||||
{
|
||||
@ -122,91 +107,54 @@ TPerambFromSolve<FImpl>::~TPerambFromSolve(void)
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TPerambFromSolve<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in;
|
||||
|
||||
in.push_back(par().solve);
|
||||
in.push_back(par().eigenPack);
|
||||
|
||||
return in;
|
||||
return std::vector<std::string>{ par().solve, par().eigenPack };
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TPerambFromSolve<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
return std::vector<std::string>{ getName() };
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TPerambFromSolve<FImpl>::setup(void)
|
||||
{
|
||||
Cleanup();
|
||||
|
||||
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};
|
||||
const int Ns{Distil.Ns};
|
||||
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
||||
|
||||
grid4d = env().getGrid();
|
||||
grid3d = MakeLowerDimGrid(grid4d);
|
||||
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");
|
||||
|
||||
|
||||
Cleanup();
|
||||
DISTIL_PARAMETERS_DEFINE( true );
|
||||
grid4d = env().getGrid();
|
||||
grid3d = MakeLowerDimGrid(grid4d);
|
||||
const int nvec_reduced{par().nvec_reduced};
|
||||
const int LI_reduced{par().LI_reduced};
|
||||
//std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
||||
envCreate(Perambulator, getName(), 1, PerambIndexNames,Nt,nvec_reduced,LI_reduced,nnoise,Nt_inv,SI);
|
||||
envCreate(NoiseTensor, getName() + "_noise", 1, nnoise, Nt, nvec, Ns );
|
||||
envTmp(LatticeColourVector, "result_3d",1,LatticeColourVector(grid3d));
|
||||
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
|
||||
envTmpLat(LatticeColourVector, "result_nospin");
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
void TPerambFromSolve<FImpl>::Cleanup(void)
|
||||
{
|
||||
if( grid3d != nullptr ) {
|
||||
delete grid3d;
|
||||
grid3d = nullptr;
|
||||
}
|
||||
grid4d = nullptr;
|
||||
if( grid3d != nullptr ) {
|
||||
delete grid3d;
|
||||
grid3d = nullptr;
|
||||
}
|
||||
grid4d = nullptr;
|
||||
}
|
||||
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TPerambFromSolve<FImpl>::execute(void)
|
||||
{
|
||||
GridCartesian * grid4d = env().getGrid();
|
||||
const int Nt{grid4d->GlobalDimensions()[Tdir]};
|
||||
const int Ntlocal{grid4d->LocalDimensions()[3]};
|
||||
const int Ntfirst{grid4d->LocalStarts()[3]};
|
||||
|
||||
const int nvec_reduced{par().nvec_reduced};
|
||||
const int LI_reduced{par().LI_reduced};
|
||||
const int nvec{par().nvec};
|
||||
const DistilParameters & Distil{par().Distil};
|
||||
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());
|
||||
DISTIL_PARAMETERS_DEFINE( false );
|
||||
auto &perambulator = envGet(Perambulator, getName());
|
||||
auto &solve = envGet(std::vector<FermionField>, par().solve);
|
||||
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
|
||||
|
||||
|
@ -30,14 +30,6 @@
|
||||
#ifndef 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
|
||||
#include <Hadrons/Distil.hpp>
|
||||
|
||||
@ -53,41 +45,42 @@ class PerambulatorPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(PerambulatorPar,
|
||||
std::string, eigenPack,
|
||||
std::string, lapevec,
|
||||
std::string, solver,
|
||||
std::string, noise,
|
||||
std::string, PerambFileName, //stem!!!
|
||||
std::string, UniqueIdentifier,
|
||||
bool, multiFile,
|
||||
int, nvec,
|
||||
DistilParameters, Distil,
|
||||
std::string, solver);
|
||||
DistilParameters, Distil);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
class TPerambulator: public Module<PerambulatorPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
SOLVER_TYPE_ALIASES(FImpl,);
|
||||
// constructor
|
||||
TPerambulator(const std::string name);
|
||||
// destructor
|
||||
virtual ~TPerambulator(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);
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
SOLVER_TYPE_ALIASES(FImpl,);
|
||||
// constructor
|
||||
TPerambulator(const std::string name);
|
||||
// destructor
|
||||
virtual ~TPerambulator(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)
|
||||
virtual void Cleanup(void);
|
||||
protected:
|
||||
virtual void Cleanup(void);
|
||||
private:
|
||||
unsigned int Ls_;
|
||||
// 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)
|
||||
// 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
|
||||
@ -113,21 +106,17 @@ TPerambulator<FImpl>::~TPerambulator(void)
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TPerambulator<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in;
|
||||
|
||||
in.push_back(par().eigenPack);
|
||||
in.push_back(par().solver);
|
||||
in.push_back(par().noise);
|
||||
|
||||
return in;
|
||||
sLapEvecName = par().lapevec;
|
||||
sNoiseName = par().noise;
|
||||
if( sNoiseName.length() == 0 )
|
||||
sNoiseName = getName() + "_noise";
|
||||
return {sLapEvecName, par().solver, sNoiseName };
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TPerambulator<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName(),getName() + "_unsmeared_sink"};
|
||||
|
||||
return out;
|
||||
return {getName(), getName() + "_unsmeared_sink"};
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
@ -137,17 +126,9 @@ void TPerambulator<FImpl>::setup(void)
|
||||
Cleanup();
|
||||
grid4d = env().getGrid();
|
||||
grid3d = MakeLowerDimGrid(grid4d);
|
||||
const int Nt{grid4d->GlobalDimensions()[Tdir]};
|
||||
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"};
|
||||
DISTIL_PARAMETERS_DEFINE( true );
|
||||
|
||||
envCreate(Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, getName(), 1,
|
||||
sIndexNames,Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI);
|
||||
envCreate(Perambulator, getName(), 1, PerambIndexNames,Nt,nvec,LI,nnoise,Nt_inv,SI);
|
||||
envCreate(std::vector<FermionField>, getName() + "_unsmeared_sink", 1,
|
||||
nnoise*LI*Ns*Nt_inv, envGetGrid(FermionField));
|
||||
|
||||
@ -181,18 +162,7 @@ void TPerambulator<FImpl>::Cleanup(void)
|
||||
template <typename FImpl>
|
||||
void TPerambulator<FImpl>::execute(void)
|
||||
{
|
||||
const int Nt{grid4d->GlobalDimensions()[Tdir]};
|
||||
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;
|
||||
DISTIL_PARAMETERS_DEFINE( false );
|
||||
|
||||
auto &solver=envGet(Solver, par().solver);
|
||||
auto &mat = solver.getFMat();
|
||||
@ -200,12 +170,9 @@ void TPerambulator<FImpl>::execute(void)
|
||||
envGetTmp(FermionField, v5dtmp);
|
||||
envGetTmp(FermionField, v5dtmp_sol);
|
||||
|
||||
const std::string &UniqueIdentifier{par().UniqueIdentifier};
|
||||
|
||||
//auto &noise = envGet(std::vector<Complex>, par().noise);
|
||||
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 &noise = envGet(NoiseTensor, sNoiseName);
|
||||
auto &perambulator = envGet(Perambulator, getName());
|
||||
auto &epack = envGet(LapEvecs, sLapEvecName);
|
||||
auto &unsmeared_sink = envGet(std::vector<FermionField>, getName() + "_unsmeared_sink");
|
||||
|
||||
|
||||
|
@ -101,20 +101,16 @@ std::vector<std::string> TLoadPerambulator<FImpl>::getOutput(void)
|
||||
template <typename FImpl>
|
||||
void TLoadPerambulator<FImpl>::setup(void)
|
||||
{
|
||||
GridCartesian * grid4d = env().getGrid();
|
||||
const int Nt{grid4d->GlobalDimensions()[Tdir]};
|
||||
const int nvec{par().nvec};
|
||||
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);
|
||||
DISTIL_PARAMETERS_DEFINE( true );
|
||||
//std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
||||
envCreate(MDistil::Perambulator, getName(), 1, MDistil::PerambIndexNames,Nt,nvec,LI,nnoise,Nt_inv,SI);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
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())};
|
||||
perambulator.read(sPerambName.c_str());
|
||||
}
|
||||
|
Reference in New Issue
Block a user