From a977d9901b1064d2fce1180375654ccbad1f0aac Mon Sep 17 00:00:00 2001 From: ferben Date: Wed, 13 Nov 2019 14:52:06 +0000 Subject: [PATCH] cleanup --- Hadrons/Modules/MDistil/DistilVectors.hpp | 62 +++++++++++++---------- Hadrons/Modules/MDistil/Perambulator.hpp | 29 ++++------- tests/hadrons/Test_distil.cc | 27 +++++----- 3 files changed, 58 insertions(+), 60 deletions(-) diff --git a/Hadrons/Modules/MDistil/DistilVectors.hpp b/Hadrons/Modules/MDistil/DistilVectors.hpp index 9af5158f..be387606 100644 --- a/Hadrons/Modules/MDistil/DistilVectors.hpp +++ b/Hadrons/Modules/MDistil/DistilVectors.hpp @@ -164,32 +164,33 @@ void TDistilVectors::execute(void) const int Ntfirst{ grid4d->LocalStarts()[3] }; const int Nt{env().getDim(Tdir)}; - const int nvec{dp.nvec}; - const int nnoise{dp.nnoise}; - const int tsrc{dp.tsrc}; - const int TI{dp.TI}; - const int LI{dp.LI}; - const int SI{dp.SI}; - const bool full_tdil{ TI == Nt }; - const int Nt_inv{ full_tdil ? 1 : TI }; + const bool full_tdil{ dp.TI == Nt }; + const int Nt_inv{ full_tdil ? 1 : dp.TI }; int vecindex; int t_inv; if (!RhoName.empty()) { auto &rho = envGet(std::vector, RhoName); - 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; + for (int inoise = 0; inoise < dp.nnoise; inoise++) + { + for (int dk = 0; dk < dp.LI; dk++) + { + for (int dt = 0; dt < Nt_inv; dt++) + { + for (int ds = 0; ds < dp.SI; ds++) + { + vecindex = inoise + dp.nnoise * dk + dp.nnoise * dp.LI * ds + dp.nnoise *dp.LI * dp.SI*dt; rho[vecindex] = 0; - source3d_nospin = 0; - 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){ + for (int it = dt; it < Nt; it += dp.TI) + { + const int t_inv{full_tdil ? dp.tsrc : it}; + if (t_inv >= Ntfirst && t_inv < Ntfirst + Ntlocal) + { + for (int ik = dk; ik < dp.nvec; ik += dp.LI) + { + for (int is = ds; is < Ns; is += dp.SI) + { ExtractSliceLocal(evec3d,epack.evec[ik],0,t_inv-Ntfirst,Tdir); source3d_nospin = evec3d * noise.tensor(inoise, t_inv, ik, is); source3d=0; @@ -206,17 +207,24 @@ void TDistilVectors::execute(void) } } } - if (!PhiName.empty()) { + if (!PhiName.empty()) + { auto &phi = envGet(std::vector, PhiName); - 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; + for (int inoise = 0; inoise < dp.nnoise; inoise++) + { + for (int dk = 0; dk < dp.LI; dk++) + { + for (int dt = 0; dt < Nt_inv; dt++) + { + for (int ds = 0; ds < dp.SI; ds++) + { + vecindex = inoise + dp.nnoise * dk + dp.nnoise * dp.LI * ds + dp.nnoise *dp.LI *dp. SI*dt; phi[vecindex] = 0; - for (int t = Ntfirst; t < Ntfirst + Ntlocal; t++) { + for (int t = Ntfirst; t < Ntfirst + Ntlocal; t++) + { sink3d=0; - for (int ivec = 0; ivec < nvec; ivec++) { + for (int ivec = 0; ivec < dp.nvec; ivec++) + { ExtractSliceLocal(evec3d,epack.evec[ivec],0,t-Ntfirst,Tdir); sink3d += evec3d * perambulator.tensor(t, ivec, dk, inoise,dt,ds); } diff --git a/Hadrons/Modules/MDistil/Perambulator.hpp b/Hadrons/Modules/MDistil/Perambulator.hpp index 40738865..2ffaf6fc 100644 --- a/Hadrons/Modules/MDistil/Perambulator.hpp +++ b/Hadrons/Modules/MDistil/Perambulator.hpp @@ -130,14 +130,8 @@ void TPerambulator::execute(void) { const DistilParameters &dp{ envGet(DistilParameters, par().DistilParams) }; const int Nt{env().getDim(Tdir)}; - const int nvec{dp.nvec}; - const int nnoise{dp.nnoise}; - const int tsrc{dp.tsrc}; - const int TI{dp.TI}; - const int LI{dp.LI}; - const int SI{dp.SI}; - const bool full_tdil{ TI == Nt }; - const int Nt_inv{ full_tdil ? 1 : TI }; + const bool full_tdil{ dp.TI == Nt }; + const int Nt_inv{ full_tdil ? 1 : dp.TI }; auto &solver=envGet(Solver, par().solver); auto &mat = solver.getFMat(); @@ -161,26 +155,25 @@ void TPerambulator::execute(void) const int Ntfirst{grid4d->LocalStarts()[3]}; const std::string UnsmearedSinkFileName{ par().UnsmearedSinkFileName }; - for (int inoise = 0; inoise < nnoise; inoise++) + for (int inoise = 0; inoise < dp.nnoise; inoise++) { - for (int dk = 0; dk < LI; dk++) + for (int dk = 0; dk < dp.LI; dk++) { for (int dt = 0; dt < Nt_inv; dt++) { - for (int ds = 0; ds < SI; ds++) + for (int ds = 0; ds < dp.SI; ds++) { LOG(Message) << "LapH source vector from noise " << inoise << " and dilution component (d_k,d_t,d_alpha) : (" << dk << ","<< dt << "," << ds << ")" << std::endl; dist_source = 0; - source3d_nospin = 0; evec3d = 0; - for (int it = dt; it < Nt; it += TI) + for (int it = dt; it < Nt; it += dp.TI) { - const int t_inv{full_tdil ? tsrc : it}; + const int t_inv{full_tdil ? dp.tsrc : it}; if( t_inv >= Ntfirst && t_inv < Ntfirst + Ntlocal ) { - for (int ik = dk; ik < nvec; ik += LI) + for (int ik = dk; ik < dp.nvec; ik += dp.LI) { - for (int is = ds; is < Ns; is += SI) + for (int is = ds; is < Ns; is += dp.SI) { ExtractSliceLocal(evec3d,epack.evec[ik],0,t_inv-Ntfirst,Tdir); source3d_nospin = evec3d * noise.tensor(inoise, t_inv, ik, is); @@ -205,14 +198,14 @@ void TPerambulator::execute(void) result4d = v4dtmp; } if (!UnsmearedSinkFileName.empty()) - unsmeared_sink[inoise+nnoise*(dk+LI*(dt+Nt_inv*ds))] = result4d; + unsmeared_sink[inoise+dp.nnoise*(dk+dp.LI*(dt+Nt_inv*ds))] = result4d; for (int is = 0; is < Ns; is++) { result4d_nospin = peekSpin(result4d,is); for (int t = Ntfirst; t < Ntfirst + Ntlocal; t++) { ExtractSliceLocal(result3d_nospin,result4d_nospin,0,t-Ntfirst,Tdir); - for (int ivec = 0; ivec < nvec; ivec++) + for (int ivec = 0; ivec < dp.nvec; ivec++) { ExtractSliceLocal(evec3d,epack.evec[ivec],0,t-Ntfirst,Tdir); pokeSpin(perambulator.tensor(t, ivec, dk, inoise,dt,ds),static_cast(innerProduct(evec3d, result3d_nospin)),is); diff --git a/tests/hadrons/Test_distil.cc b/tests/hadrons/Test_distil.cc index d137e5e7..8519fd28 100644 --- a/tests/hadrons/Test_distil.cc +++ b/tests/hadrons/Test_distil.cc @@ -142,17 +142,15 @@ std::string test_Solver(Application &application, const char * pSuffix = nullptr ///////////////////////////////////////////////////////////// std::string test_DPar(Application &application) { - // DistilVectors parameters - //MDistil::DistilParPar DistilPar; - MDistil::DistilParameters DistilPar; - DistilPar.nvec = 5; - DistilPar.nnoise = 1; - DistilPar.tsrc = 0; - DistilPar.LI = 5; - DistilPar.TI = 8; - DistilPar.SI = 4; + MDistil::DistilPar DPar; + DPar.nvec = 5; + DPar.nnoise = 1; + DPar.tsrc = 0; + DPar.LI = 5; + DPar.TI = 8; + DPar.SI = 4; std::string sDParName{"DPar_l"}; - application.createModule(sDParName,DistilPar); + application.createModule(sDParName,DPar); return sDParName; } ///////////////////////////////////////////////////////////// @@ -160,9 +158,8 @@ std::string test_DPar(Application &application) { ///////////////////////////////////////////////////////////// std::string test_Noises(Application &application, const std::string &sNoiseBaseName ) { - // DistilVectors parameters MDistil::NoisesPar NoisePar; - NoisePar.DistilPar = "DPar_l"; + NoisePar.DistilParams = "DPar_l"; NoisePar.NoiseFileName = "noise"; std::string sNoiseName{"noise"}; application.createModule(sNoiseName,NoisePar); @@ -186,7 +183,7 @@ void test_LoadPerambulators( Application &application, const char * pszSuffix = std::string sModuleName{ PerambulatorName( pszSuffix ) }; MIO::LoadPerambulator::Par PerambPar; PerambPar.PerambFileName = sModuleName; - PerambPar.DistilPar = "DPar_l"; + PerambPar.DistilParams = "DPar_l"; test_Noises(application, sModuleName); // I want these written after solver stuff application.createModule( sModuleName, PerambPar ); } @@ -199,7 +196,7 @@ void test_Perambulators( Application &application, const char * pszSuffix = null PerambPar.lapevec = "LapEvec"; PerambPar.PerambFileName = sModuleName; PerambPar.solver = test_Solver( application, pszSuffix ); - PerambPar.DistilPar = "DPar_l"; + PerambPar.DistilParams = "DPar_l"; PerambPar.noise = "noise"; test_Noises(application, sModuleName); // I want these written after solver stuff application.createModule( sModuleName, PerambPar ); @@ -223,7 +220,7 @@ void test_DistilVectors(Application &application, const char * pszSuffix = nullp DistilVecPar.phi = "phi"; DistilVecPar.perambulator = sPerambName; DistilVecPar.lapevec = "LapEvec"; - DistilVecPar.DistilPar = "DPar_l"; + DistilVecPar.DistilParams = "DPar_l"; application.createModule(sModuleName,DistilVecPar); }