mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 04:37:05 +01:00
WIP
This commit is contained in:
@ -60,13 +60,11 @@ public:
|
||||
std::string, sink,
|
||||
bool, multiFile,
|
||||
int, tsrc,
|
||||
//int, nnoise,
|
||||
int, LI,
|
||||
int, SI,
|
||||
int, TI,
|
||||
int, nvec,
|
||||
int, Ns,
|
||||
int, Nt,
|
||||
int, Nt_inv);
|
||||
};
|
||||
|
||||
@ -172,7 +170,7 @@ template <typename FImpl>
|
||||
void TDistilVectors<FImpl>::setup(void)
|
||||
{
|
||||
Cleanup();
|
||||
auto &noise = envGet(std::vector<Complex>, NoiseVectorName);
|
||||
auto &noise = envGet(NoiseTensor, NoiseVectorName);
|
||||
auto &perambulator = envGet(DistilPeramb, PerambulatorName);
|
||||
|
||||
// We expect the perambulator to have been created with these indices
|
||||
@ -180,7 +178,8 @@ void TDistilVectors<FImpl>::setup(void)
|
||||
for(int i = 0; i < DistilPeramb::NumIndices; i++ )
|
||||
assert( sIndexNames[i] == perambulator.IndexNames[i] && "Perambulator indices bad" );
|
||||
|
||||
nnoise = static_cast<int>( noise.size() );
|
||||
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;
|
||||
@ -225,7 +224,7 @@ void TDistilVectors<FImpl>::Cleanup(void)
|
||||
template <typename FImpl>
|
||||
void TDistilVectors<FImpl>::execute(void)
|
||||
{
|
||||
auto &noise = envGet(std::vector<Complex>, NoiseVectorName);
|
||||
auto &noise = envGet(NoiseTensor, NoiseVectorName);
|
||||
auto &perambulator = envGet(DistilPeramb, PerambulatorName);
|
||||
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, LapEvecName);
|
||||
|
||||
@ -244,7 +243,7 @@ void TDistilVectors<FImpl>::execute(void)
|
||||
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;
|
||||
const int Nt{grid4d->GlobalDimensions()[Tdir]};
|
||||
int TI=par().TI;
|
||||
int nvec=par().nvec;
|
||||
int SI=par().SI;
|
||||
@ -255,10 +254,10 @@ void TDistilVectors<FImpl>::execute(void)
|
||||
int t_inv;
|
||||
if( bMakeSource ) {
|
||||
auto &rho = envGet(std::vector<FermionField>, SourceName);
|
||||
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++) {
|
||||
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;
|
||||
@ -268,7 +267,8 @@ void TDistilVectors<FImpl>::execute(void)
|
||||
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_nospin = evec3d * noise[inoise + nnoise*(t_inv + Nt*(ik+nvec*is))];
|
||||
tmp3d_nospin = evec3d * noise(inoise, t_inv, ik, is);
|
||||
tmp3d=zero;
|
||||
pokeSpin(tmp3d,tmp3d_nospin,is);
|
||||
tmp2=zero;
|
||||
@ -285,10 +285,10 @@ void TDistilVectors<FImpl>::execute(void)
|
||||
}
|
||||
if( bMakeSink ) {
|
||||
auto &phi = envGet(std::vector<FermionField>, SinkName);
|
||||
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++) {
|
||||
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++) {
|
||||
@ -307,7 +307,5 @@ void TDistilVectors<FImpl>::execute(void)
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MDistil_DistilVectors_hpp_
|
||||
|
@ -106,54 +106,53 @@ std::vector<std::string> TNoises<FImpl>::getOutput(void)
|
||||
template <typename FImpl>
|
||||
void TNoises<FImpl>::setup(void)
|
||||
{
|
||||
const DistilParameters & Distil{par().Distil};
|
||||
const int nvec{par().nvec};
|
||||
|
||||
envCreate(std::vector<Complex>, getName(), 1, nvec*Distil.Ns*Distil.Nt*Distil.nnoise);
|
||||
|
||||
const int Nt{env().getGrid()->GlobalDimensions()[Tdir]};
|
||||
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);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TNoises<FImpl>::execute(void)
|
||||
{
|
||||
const std::string &UniqueIdentifier{par().UniqueIdentifier};
|
||||
auto &noise = envGet(std::vector<Complex>, getName());
|
||||
const int nvec{par().nvec};
|
||||
const DistilParameters & Distil{par().Distil};
|
||||
const int nnoise{Distil.nnoise};
|
||||
const int Nt{Distil.Nt};
|
||||
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};
|
||||
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedUniqueString(UniqueIdentifier + std::to_string(vm().getTrajectory())); //maybe add more??
|
||||
Real rn;
|
||||
|
||||
for (int inoise=0;inoise<nnoise;inoise++) {
|
||||
for (int t=0;t<Nt;t++) {
|
||||
for (int ivec=0;ivec<nvec;ivec++) {
|
||||
for (int is=0;is<Ns;is++) {
|
||||
if (exact_distillation)
|
||||
noise[inoise + nnoise*(t + Nt*(ivec+nvec*is))] = 1.;
|
||||
else{
|
||||
random(sRNG,rn);
|
||||
// We could use a greater number of complex roots of unity
|
||||
// ... but this seems to work well
|
||||
noise[inoise + nnoise*(t + Nt*(ivec+nvec*is))] = (rn > 0.5) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &UniqueIdentifier{par().UniqueIdentifier};
|
||||
auto &noise = envGet(NoiseTensor, getName());
|
||||
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};
|
||||
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedUniqueString(UniqueIdentifier + std::to_string(vm().getTrajectory())); //maybe add more??
|
||||
Real rn;
|
||||
|
||||
for( int inoise = 0; inoise < nnoise; inoise++ ) {
|
||||
for( int t = 0; t < Nt; t++ ) {
|
||||
for( int ivec = 0; ivec < nvec; ivec++ ) {
|
||||
for( int is = 0; is < Ns; is++ ) {
|
||||
if( exact_distillation )
|
||||
//noise[inoise + nnoise*(t + Nt*(ivec+nvec*is))] = 1.;
|
||||
noise(inoise, t, ivec, is) = 1.;
|
||||
else{
|
||||
random(sRNG,rn);
|
||||
// We could use a greater number of complex roots of unity
|
||||
// ... but this seems to work well
|
||||
//noise[inoise + nnoise*(t + Nt*(ivec+nvec*is))] = (rn > 0.5) ? -1 : 1;
|
||||
noise(inoise, t, ivec, is) = (rn > 0.5) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MDistil_Noises_hpp_
|
||||
|
@ -154,6 +154,7 @@ void TPerambFromSolve<FImpl>::setup(void)
|
||||
|
||||
grid4d = env().getGrid();
|
||||
grid3d = MakeLowerDimGrid(grid4d);
|
||||
const int Nt{grid4d->GlobalDimensions()[Tdir]};
|
||||
|
||||
|
||||
const int nvec_reduced{par().nvec_reduced};
|
||||
@ -161,9 +162,9 @@ void TPerambFromSolve<FImpl>::setup(void)
|
||||
//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,Distil.Nt,nvec_reduced,LI_reduced,Distil.nnoise,Distil.Nt_inv,Distil.SI);
|
||||
sIndexNames,Nt,nvec_reduced,LI_reduced,Distil.nnoise,Distil.Nt_inv,Distil.SI);
|
||||
envCreate(std::vector<Complex>, getName() + "_noise", 1,
|
||||
nvec*Distil.Ns*Distil.Nt*Distil.nnoise);
|
||||
nvec*Distil.Ns*Nt*Distil.nnoise);
|
||||
|
||||
envTmp(LatticeColourVector, "result_3d",1,LatticeColourVector(grid3d));
|
||||
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
|
||||
@ -187,34 +188,32 @@ void TPerambFromSolve<FImpl>::Cleanup(void)
|
||||
template <typename FImpl>
|
||||
void TPerambFromSolve<FImpl>::execute(void)
|
||||
{
|
||||
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{Distil.Nt};
|
||||
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 &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
|
||||
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());
|
||||
auto &solve = envGet(std::vector<FermionField>, par().solve);
|
||||
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
|
||||
|
||||
envGetTmp(LatticeColourVector, result_nospin);
|
||||
envGetTmp(LatticeColourVector, result_3d);
|
||||
envGetTmp(LatticeColourVector, evec3d);
|
||||
|
||||
GridCartesian * grid4d = env().getGrid();
|
||||
|
||||
int Ntlocal = grid4d->LocalDimensions()[3];
|
||||
int Ntfirst = grid4d->LocalStarts()[3];
|
||||
|
||||
for (int inoise = 0; inoise < nnoise; inoise++) {
|
||||
for (int dk = 0; dk < LI_reduced; dk++) {
|
||||
for (int dt = 0; dt < Nt_inv; dt++) {
|
||||
|
@ -134,38 +134,36 @@ std::vector<std::string> TPerambulator<FImpl>::getOutput(void)
|
||||
template <typename FImpl>
|
||||
void TPerambulator<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}; // 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,
|
||||
sIndexNames,Distil.Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI);
|
||||
envCreate(std::vector<FermionField>, getName() + "_unsmeared_sink", 1,
|
||||
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"};
|
||||
|
||||
envCreate(Perambulator<SpinVector COMMA 6 COMMA sizeof(Real)>, getName(), 1,
|
||||
sIndexNames,Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI);
|
||||
envCreate(std::vector<FermionField>, getName() + "_unsmeared_sink", 1,
|
||||
nnoise*LI*Ns*Nt_inv, envGetGrid(FermionField));
|
||||
|
||||
grid4d = env().getGrid();
|
||||
grid3d = MakeLowerDimGrid(grid4d);//new GridCartesian(latt_size,simd_layout_3,mpi_layout,*grid4d);
|
||||
|
||||
envTmpLat(LatticeSpinColourVector, "dist_source");
|
||||
envTmpLat(LatticeSpinColourVector, "tmp2");
|
||||
envTmpLat(LatticeSpinColourVector, "result");
|
||||
envTmpLat(LatticeColourVector, "result_nospin");
|
||||
envTmp(LatticeSpinColourVector, "tmp3d",1,LatticeSpinColourVector(grid3d));
|
||||
envTmp(LatticeColourVector, "tmp3d_nospin",1,LatticeColourVector(grid3d));
|
||||
envTmp(LatticeColourVector, "result_3d",1,LatticeColourVector(grid3d));
|
||||
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
|
||||
|
||||
Ls_ = env().getObjectLs(par().solver);
|
||||
envTmpLat(FermionField, "v4dtmp");
|
||||
envTmpLat(FermionField, "v5dtmp", Ls_);
|
||||
envTmpLat(FermionField, "v5dtmp_sol", Ls_);
|
||||
|
||||
|
||||
envTmpLat(LatticeSpinColourVector, "dist_source");
|
||||
envTmpLat(LatticeSpinColourVector, "tmp2");
|
||||
envTmpLat(LatticeSpinColourVector, "result");
|
||||
envTmpLat(LatticeColourVector, "result_nospin");
|
||||
envTmp(LatticeSpinColourVector, "tmp3d",1,LatticeSpinColourVector(grid3d));
|
||||
envTmp(LatticeColourVector, "tmp3d_nospin",1,LatticeColourVector(grid3d));
|
||||
envTmp(LatticeColourVector, "result_3d",1,LatticeColourVector(grid3d));
|
||||
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
|
||||
|
||||
Ls_ = env().getObjectLs(par().solver);
|
||||
envTmpLat(FermionField, "v4dtmp");
|
||||
envTmpLat(FermionField, "v5dtmp", Ls_);
|
||||
envTmpLat(FermionField, "v5dtmp_sol", Ls_);
|
||||
}
|
||||
|
||||
// clean up any temporaries created by setup (that aren't stored in the environment)
|
||||
@ -183,30 +181,29 @@ 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 Nt{Distil.Nt};
|
||||
const int Nt_inv{Distil.Nt_inv}; // TODO: PROBABLY BETTER: if (full_tdil) Nt_inv=1; else Nt_inv = TI;
|
||||
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 &mat = solver.getFMat();
|
||||
envGetTmp(FermionField, v4dtmp);
|
||||
envGetTmp(FermionField, v5dtmp);
|
||||
envGetTmp(FermionField, v5dtmp_sol);
|
||||
|
||||
|
||||
const bool full_tdil{TI==Nt};
|
||||
const bool exact_distillation{full_tdil && LI==nvec};
|
||||
|
||||
const std::string &UniqueIdentifier{par().UniqueIdentifier};
|
||||
|
||||
auto &noise = envGet(std::vector<Complex>, par().noise);
|
||||
//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 &unsmeared_sink = envGet(std::vector<FermionField>, getName() + "_unsmeared_sink");
|
||||
@ -245,7 +242,8 @@ void TPerambulator<FImpl>::execute(void)
|
||||
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_nospin = evec3d * noise[inoise + nnoise*(t_inv + Nt*(ik+nvec*is))];
|
||||
tmp3d_nospin = evec3d * noise(inoise, t_inv, ik, is);
|
||||
tmp3d=zero;
|
||||
pokeSpin(tmp3d,tmp3d_nospin,is);
|
||||
tmp2=zero;
|
||||
|
Reference in New Issue
Block a user