From 3595f7d250a35487354374af7c168eb95d28011e Mon Sep 17 00:00:00 2001 From: Matteo Di Carlo Date: Mon, 22 May 2023 17:11:12 +0100 Subject: [PATCH] adding C1M and restructuring solvers --- RbcUkqcd.hpp | 262 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 244 insertions(+), 18 deletions(-) diff --git a/RbcUkqcd.hpp b/RbcUkqcd.hpp index 1ed3c50..7c74e94 100644 --- a/RbcUkqcd.hpp +++ b/RbcUkqcd.hpp @@ -39,25 +39,97 @@ struct RbcUkqcd unsigned int L, T, Ls; }; - static constexpr EnsembleParameters m0UnitaryPar{0.000678, 0.02661, 1.8, 2., 64, 128, 12}; - static constexpr EnsembleParameters m0LCDPar{0.0006203, 0.02661, 1.8, 2., 64, 128, 12}; + // M0 + inline static constexpr EnsembleParameters m0UnitaryPar{0.000678, 0.02661, 1.8, 2., 64, 128, 12}; + inline static constexpr EnsembleParameters m0LCDPar{0.0006203, 0.02661, 1.8, 2., 64, 128, 12}; + + // C1M + inline static constexpr EnsembleParameters c1mLCDPar {0.005, 0.0362, 1.8, 2., 24, 64, 24}; + inline static constexpr EnsembleParameters c1m16LCDPar{0.005, 0.0362, 1.8, 2., 16, 64, 24}; + inline static constexpr EnsembleParameters c1m20LCDPar{0.005, 0.0362, 1.8, 2., 20, 64, 24}; + inline static constexpr EnsembleParameters c1m32LCDPar{0.005, 0.0362, 1.8, 2., 32, 64, 24}; + + // Runtime deflation parameters + struct DeflationParameters + { + double alpha, beta; + unsigned int nPoly, nStop, nK, nM; + }; + + inline static constexpr DeflationParameters c1mDeflPar {5.0e-04, 5.5, 101, 100, 110, 120}; + inline static constexpr DeflationParameters c1m16DeflPar{5.0e-03, 5.5, 101, 200, 220, 230}; + inline static constexpr DeflationParameters c1m20DeflPar{3.0e-03, 5.5, 101, 200, 220, 230}; + inline static constexpr DeflationParameters c1m32DeflPar{3.0e-06, 5.5, 101, 100, 110, 120}; + + // Light solver: load deflation from disk + static inline void addLightLCDSolver(Application &app, const RbcUkqcd::EnsembleParameters &par, + const std::string solverName, const std::string gaugeName, + const std::string gaugeTransform, + const std::string eigenpackPath, const double residual); - // Solvers (LCD: Local Coherence Deflation) static inline void addM0LightLCDSolver(Application &app, const std::string solverName, const std::string gaugeName, const std::string gaugeTransform, const std::string eigenpackPath, const double residual = 1.0e-8); + // Light solver: deflation at runtime + static inline void + addLightRuntimeLCDSolver(Application &app, const RbcUkqcd::EnsembleParameters &par, + const RbcUkqcd::DeflationParameters &deflPar, + const std::string solverName, const std::string gaugeName, + const std::string gaugeTransform, const double residual); + + static inline void addC1MLightRuntimeLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, + const double residual = 1.0e-8); + static inline void addC1M16LightRuntimeLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, + const double residual = 1.0e-8); + static inline void addC1M20LightRuntimeLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, + const double residual = 1.0e-8); + static inline void addC1M32LightRuntimeLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, + const double residual = 1.0e-8); + + // Strange solver (undeflated) + static inline void addStrangeSolver(Application &app, const RbcUkqcd::EnsembleParameters &par, + const std::string solverName, const std::string gaugeName, + const std::string gaugeTransform, const double residual); + static inline void addM0StrangeSolver(Application &app, const std::string solverName, const std::string gaugeName, const std::string gaugeTransform, const double residual = 1.0e-8); + static inline void addC1MStrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, + const double residual = 1.0e-8); + static inline void addC1M16StrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, + const double residual = 1.0e-8); + static inline void addC1M20StrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, + const double residual = 1.0e-8); + static inline void addC1M32StrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, + const double residual = 1.0e-8); }; // Implementations ///////////////////////////////////////////////////////////////////////////////// -void RbcUkqcd::addM0LightLCDSolver(Application &app, const std::string solverName, - const std::string gaugeName, const std::string gaugeTransform, - const std::string eigenpackPath, const double residual) + +// Load deflation from disk +void RbcUkqcd::addLightLCDSolver(Application &app, const RbcUkqcd::EnsembleParameters &par, + const std::string solverName, const std::string gaugeName, + const std::string gaugeTransform, const std::string eigenpackPath, + const double residual) { const std::string prefix = solverName; @@ -71,10 +143,10 @@ void RbcUkqcd::addM0LightLCDSolver(Application &app, const std::string solverNam MAction::ScaledDWF::Par actionPar; actionPar.gauge = gaugeName; - actionPar.Ls = RbcUkqcd::m0LCDPar.Ls; - actionPar.M5 = RbcUkqcd::m0LCDPar.M5; - actionPar.mass = RbcUkqcd::m0LCDPar.ml; - actionPar.scale = RbcUkqcd::m0LCDPar.scale; + actionPar.Ls = par.Ls; + actionPar.M5 = par.M5; + actionPar.mass = par.ml; + actionPar.scale = par.scale; actionPar.boundary = "1 1 1 1"; actionPar.twist = "0. 0. 0. 0."; app.createModule(prefix + "_dwf", actionPar); @@ -117,9 +189,20 @@ void RbcUkqcd::addM0LightLCDSolver(Application &app, const std::string solverNam app.createModule(solverName, solverPar); } -void RbcUkqcd::addM0StrangeSolver(Application &app, const std::string solverName, - const std::string gaugeName, const std::string gaugeTransform, - const double residual) +// Light M0 +void RbcUkqcd::addM0LightLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, const std::string gaugeTransform, + const std::string eigenpackPath, const double residual) +{ + RbcUkqcd::addLightLCDSolver(app, RbcUkqcd::m0LCDPar, solverName, gaugeName, gaugeTransform, + eigenpackPath, residual); +} + +// Deflation at runtime +void RbcUkqcd::addLightRuntimeLCDSolver(Application &app, const RbcUkqcd::EnsembleParameters &par, + const RbcUkqcd::DeflationParameters &deflPar, + const std::string solverName, const std::string gaugeName, + const std::string gaugeTransform, const double residual) { const std::string prefix = solverName; @@ -133,17 +216,120 @@ void RbcUkqcd::addM0StrangeSolver(Application &app, const std::string solverName MAction::ScaledDWF::Par actionPar; actionPar.gauge = gaugeName; - actionPar.Ls = RbcUkqcd::m0LCDPar.Ls; - actionPar.M5 = RbcUkqcd::m0LCDPar.M5; - actionPar.mass = RbcUkqcd::m0LCDPar.ms; - actionPar.scale = RbcUkqcd::m0LCDPar.scale; + actionPar.Ls = par.Ls; + actionPar.M5 = par.M5; + actionPar.mass = par.ml; + actionPar.scale = par.scale; actionPar.boundary = "1 1 1 1"; actionPar.twist = "0. 0. 0. 0."; app.createModule(prefix + "_dwf", actionPar); actionPar.gauge = prefix + "_gauge_fp32"; app.createModule(prefix + "_dwf_fp32", actionPar); - // Batched mixed-precision red-black preconditionned CG + // Guesser + MFermion::Operators::Par opPar; + opPar.action = prefix + "_dwf"; + app.createModule(prefix + "_dwf_op", opPar); + + MSolver::FermionImplicitlyRestartedLanczosIo32::Par lanPar; + lanPar.op = prefix + "_dwf_op_schur"; + lanPar.multiFile = false; + lanPar.redBlack = true; + lanPar.lanczosParams.Cheby.alpha = deflPar.alpha; + lanPar.lanczosParams.Cheby.beta = deflPar.beta; + lanPar.lanczosParams.Cheby.Npoly = deflPar.nPoly; + lanPar.lanczosParams.Nstop = deflPar.nStop; + lanPar.lanczosParams.Nk = deflPar.nK; + lanPar.lanczosParams.Nm = deflPar.nM; + lanPar.lanczosParams.resid = 3e-6; + lanPar.lanczosParams.MaxIt = 10000; + lanPar.lanczosParams.betastp = 0; + lanPar.lanczosParams.MinRes = 0; + lanPar.output = ""; + app.createModule(prefix + "_epack", lanPar); + + MGuesser::ExactDeflation::Par guessPar; + guessPar.eigenPack = prefix + "_epack"; + guessPar.size = deflPar.nStop; + app.createModule(prefix + "_defl", guessPar); + + // Mixed-precision red-black preconditionned CG + MSolver::MixedPrecisionRBPrecCG::Par solverPar; + + solverPar.innerAction = prefix + "_dwf_fp32"; + solverPar.outerAction = prefix + "_dwf"; + solverPar.maxInnerIteration = 30000; + solverPar.maxOuterIteration = 100; + solverPar.residual = residual; + solverPar.innerGuesser = ""; + solverPar.outerGuesser = prefix + "_defl"; + app.createModule(solverName, solverPar); +} + +// Light C1M +void RbcUkqcd::addC1MLightRuntimeLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, const double residual) +{ + RbcUkqcd::addLightRuntimeLCDSolver(app, RbcUkqcd::c1mLCDPar, RbcUkqcd::c1mDeflPar, solverName, + gaugeName, gaugeTransform, residual); +} + +// Light C1M16 +void RbcUkqcd::addC1M16LightRuntimeLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, const double residual) +{ + RbcUkqcd::addLightRuntimeLCDSolver(app, RbcUkqcd::c1m16LCDPar, RbcUkqcd::c1m16DeflPar, solverName, + gaugeName, gaugeTransform, residual); +} + +// Light C1M20 +void RbcUkqcd::addC1M20LightRuntimeLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, const double residual) +{ + RbcUkqcd::addLightRuntimeLCDSolver(app, RbcUkqcd::c1m20LCDPar, RbcUkqcd::c1m20DeflPar, solverName, + gaugeName, gaugeTransform, residual); +} + +// Light C1M32 +void RbcUkqcd::addC1M32LightRuntimeLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string gaugeTransform, const double residual) +{ + RbcUkqcd::addLightRuntimeLCDSolver(app, RbcUkqcd::c1m32LCDPar, RbcUkqcd::c1m32DeflPar, solverName, + gaugeName, gaugeTransform, residual); +} + +// Strange +void RbcUkqcd::addStrangeSolver(Application &app, const RbcUkqcd::EnsembleParameters &par, + const std::string solverName, const std::string gaugeName, + const std::string gaugeTransform, const double residual) +{ + const std::string prefix = solverName; + + // Gauge field FP32 cast + MUtilities::GaugeSinglePrecisionCast::Par gaugeCastPar; + + gaugeCastPar.field = gaugeName; + app.createModule(prefix + "_gauge_fp32", gaugeCastPar); + + // Scaled DWF action + FP32 version + MAction::ScaledDWF::Par actionPar; + + actionPar.gauge = gaugeName; + actionPar.Ls = par.Ls; + actionPar.M5 = par.M5; + actionPar.mass = par.ms; + actionPar.scale = par.scale; + actionPar.boundary = "1 1 1 1"; + actionPar.twist = "0. 0. 0. 0."; + app.createModule(prefix + "_dwf", actionPar); + actionPar.gauge = prefix + "_gauge_fp32"; + app.createModule(prefix + "_dwf_fp32", actionPar); + + // Mixed-precision red-black preconditionned CG MSolver::MixedPrecisionRBPrecCG::Par solverPar; solverPar.innerAction = prefix + "_dwf_fp32"; @@ -156,4 +342,44 @@ void RbcUkqcd::addM0StrangeSolver(Application &app, const std::string solverName app.createModule(solverName, solverPar); } +void RbcUkqcd::addM0StrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, const std::string gaugeTransform, + const double residual) +{ + RbcUkqcd::addStrangeSolver(app, RbcUkqcd::m0LCDPar, solverName, gaugeName, gaugeTransform, + residual); +} + +void RbcUkqcd::addC1MStrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, const std::string gaugeTransform, + const double residual) +{ + RbcUkqcd::addStrangeSolver(app, RbcUkqcd::c1mLCDPar, solverName, gaugeName, gaugeTransform, + residual); +} + +void RbcUkqcd::addC1M16StrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, const std::string gaugeTransform, + const double residual) +{ + RbcUkqcd::addStrangeSolver(app, RbcUkqcd::c1m16LCDPar, solverName, gaugeName, gaugeTransform, + residual); +} + +void RbcUkqcd::addC1M20StrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, const std::string gaugeTransform, + const double residual) +{ + RbcUkqcd::addStrangeSolver(app, RbcUkqcd::c1m20LCDPar, solverName, gaugeName, gaugeTransform, + residual); +} + +void RbcUkqcd::addC1M32StrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, const std::string gaugeTransform, + const double residual) +{ + RbcUkqcd::addStrangeSolver(app, RbcUkqcd::c1m32LCDPar, solverName, gaugeName, gaugeTransform, + residual); +} + } // namespace hadpresets