diff --git a/Jlqcd.hpp b/Jlqcd.hpp new file mode 100644 index 0000000..7b53c37 --- /dev/null +++ b/Jlqcd.hpp @@ -0,0 +1,435 @@ +/* + * Copyright (C) 2026 + * + * Author: Antonin Portelli + * Author: Ryan Hill + * Elements based on workflows from Teseo San Jose Perez + * + * Hadrons 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. + * + * Hadrons 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 Hadrons. If not, see . + * + * See the full license in the file "LICENSE" in the top level distribution + * directory. + */ + +#pragma once + +#include +#include + +#include +#include +#include +#include + +namespace hadpresets +{ +using namespace Grid::Hadrons; + +struct Jlqcd +{ + struct EnsembleParameters + { + double ml, ms, M5, scale; + unsigned int L, T, Ls; + }; + + inline static constexpr EnsembleParameters fUd3SaPar {0.003, 0.015, 1., 2., 64, 128, 8}; + inline static constexpr EnsembleParameters mUd3SaPar {0.0042, 0.025, 1., 2., 48, 96, 8}; + inline static constexpr EnsembleParameters mUd3SbPar {0.0042, 0.018, 1., 2., 48, 96, 8}; + inline static constexpr EnsembleParameters cUd2SaPar {0.0035, 0.040, 1., 2., 32, 64, 12}; + inline static constexpr EnsembleParameters cUd2SaLPar{0.0035, 0.040, 1., 2., 48, 96, 12}; + inline static constexpr EnsembleParameters cUd3SaPar {0.007, 0.040, 1., 2., 32, 64, 12}; + inline static constexpr EnsembleParameters cUd3SbPar {0.007, 0.030, 1., 2., 32, 64, 12}; + inline static constexpr EnsembleParameters testPar {0.010, 0.030, 1., 2., 8, 16, 8}; + + static inline const EnsembleParameters &ensemble(const std::string& name); + + static inline void addMixedPrecisionSolver(Application &app, + const EnsembleParameters &par, + const std::string &solverName, + const std::string &gaugeName, + const double mass, + const std::string &twist, + const std::string &boundary = "1 1 1 -1", + const double residual = 1.0e-8); + + static inline void addNoFailSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, + const std::string &gaugeName, const double mass, + const std::string &twist, + const std::string &boundary = "1 1 1 -1", + const double residual = 1.0e-20); + + // Light solvers (no deflation) + static inline void addLightSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary = "1 1 1 -1", + const double residual = 1.0e-8); + + static inline void addLightSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", + const double residual = 1.0e-8); + + static inline void addfUd3SaLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addmUd3SaLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addmUd3SbLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addcUd2SaLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addcUd2SaLLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addcUd3SaLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addcUd3SbLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + + // Strange solvers + static inline void addStrangeSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, + const std::string &gaugeName, const double mass, + const std::string &twist, + const std::string &boundary = "1 1 1 -1", + const double residual = 1.0e-8); + + static inline void addStrangeSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, + const std::string &gaugeName, + const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", + const double residual = 1.0e-8); + + static inline void addfUd3SaStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addmUd3SaStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addmUd3SbStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addcUd2SaStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addcUd2SaLStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addcUd3SaStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addcUd3SbStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-8); + + // Heavy solvers + static inline void addHeavySolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary = "1 1 1 -1", + const double residual = 1.0e-20); + + static inline void addfUd3SaHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-20); + static inline void addmUd3SaHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-20); + static inline void addmUd3SbHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-20); + static inline void addcUd2SaHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-20); + static inline void addcUd2SaLHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-20); + static inline void addcUd3SaHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-20); + static inline void addcUd3SbHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist = "0. 0. 0. 0.", + const std::string &boundary = "1 1 1 -1", const double residual = 1.0e-20); + +}; + +inline const Jlqcd::EnsembleParameters &Jlqcd::ensemble(const std::string& name) +{ + if (name == "fUd3Sa" ) return fUd3SaPar; + if (name == "mUd3Sa" ) return mUd3SaPar; + if (name == "mUd3Sb" ) return mUd3SbPar; + if (name == "cUd2Sa" ) return cUd2SaPar; + if (name == "cUd2SaL") return cUd2SaLPar; + if (name == "cUd3Sa" ) return cUd3SaPar; + if (name == "cUd3Sb" ) return cUd3SbPar; + if (name == "test" ) return testPar; + + throw std::invalid_argument("unknown JLQCD ensemble preset '" + std::string(name) + "'"); +} + +inline void Jlqcd::addMixedPrecisionSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + const std::string prefix = solverName; + + MUtilities::GaugeSinglePrecisionCast::Par gaugeCastPar; + gaugeCastPar.field = gaugeName; + app.createModule(prefix + "_gauge_fp32", gaugeCastPar); + + MAction::ScaledDWF::Par actionPar; + actionPar.gauge = gaugeName; + actionPar.Ls = par.Ls; + actionPar.M5 = par.M5; + actionPar.mass = mass; + actionPar.scale = par.scale; + actionPar.boundary = boundary; + actionPar.twist = twist; + app.createModule(prefix + "_dwf", actionPar); + + actionPar.gauge = prefix + "_gauge_fp32"; + app.createModule(prefix + "_dwf_fp32", actionPar); + + MSolver::MixedPrecisionRBPrecCG::Par solverPar; + solverPar.innerAction = prefix + "_dwf_fp32"; + solverPar.outerAction = prefix + "_dwf"; + solverPar.maxInnerIteration = 10000; + solverPar.maxOuterIteration = 100; + solverPar.residual = residual; + solverPar.innerGuesser = ""; + solverPar.outerGuesser = ""; + app.createModule(solverName, solverPar); +} + +inline void Jlqcd::addNoFailSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + const std::string prefix = solverName; + + MAction::ScaledDWF::Par actionPar; + actionPar.gauge = gaugeName; + actionPar.Ls = par.Ls; + actionPar.M5 = par.M5; + actionPar.mass = mass; + actionPar.scale = par.scale; + actionPar.boundary = boundary; + actionPar.twist = twist; + app.createModule(prefix + "_dwf", actionPar); + + MSolver::RBPrecCGNoFail::Par solverPar; + solverPar.action = prefix + "_dwf"; + solverPar.maxIteration = 30000; + solverPar.residual = residual; + solverPar.guesser = ""; + app.createModule(solverName, solverPar); +} + +// Light solvers (no deflation) +inline void Jlqcd::addLightSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addMixedPrecisionSolver(app, par, solverName, gaugeName, mass, twist, boundary, residual); +} + +inline void Jlqcd::addLightSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const std::string &twist, const std::string &boundary, + const double residual) +{ + addLightSolver(app, par, solverName, gaugeName, par.ml, twist, boundary, residual); +} + +inline void Jlqcd::addfUd3SaLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addLightSolver(app, fUd3SaPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addmUd3SaLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addLightSolver(app, mUd3SaPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addmUd3SbLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addLightSolver(app, mUd3SbPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addcUd2SaLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addLightSolver(app, cUd2SaPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addcUd2SaLLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addLightSolver(app, cUd2SaLPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addcUd3SaLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addLightSolver(app, cUd3SaPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addcUd3SbLightSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addLightSolver(app, cUd3SbPar, solverName, gaugeName, twist, boundary, residual); +} + +// Strange solvers +inline void Jlqcd::addStrangeSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addMixedPrecisionSolver(app, par, solverName, gaugeName, mass, twist, boundary, residual); +} + +inline void Jlqcd::addStrangeSolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const std::string &twist, const std::string &boundary, + const double residual) +{ + addStrangeSolver(app, par, solverName, gaugeName, par.ms, twist, boundary, residual); +} + +inline void Jlqcd::addfUd3SaStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addStrangeSolver(app, fUd3SaPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addmUd3SaStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addStrangeSolver(app, mUd3SaPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addmUd3SbStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addStrangeSolver(app, mUd3SbPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addcUd2SaStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addStrangeSolver(app, cUd2SaPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addcUd2SaLStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addStrangeSolver(app, cUd2SaLPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addcUd3SaStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addStrangeSolver(app, cUd3SaPar, solverName, gaugeName, twist, boundary, residual); +} + +inline void Jlqcd::addcUd3SbStrangeSolver(Application &app, const std::string &solverName, + const std::string &gaugeName, const std::string &twist, + const std::string &boundary, const double residual) +{ + addStrangeSolver(app, cUd3SbPar, solverName, gaugeName, twist, boundary, residual); +} + +// Heavy solvers +inline void Jlqcd::addHeavySolver(Application &app, const EnsembleParameters &par, + const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addNoFailSolver(app, par, solverName, gaugeName, mass, twist, boundary, residual); +} + +inline void Jlqcd::addfUd3SaHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addHeavySolver(app, fUd3SaPar, solverName, gaugeName, mass, twist, boundary, residual); +} +inline void Jlqcd::addmUd3SaHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addHeavySolver(app, mUd3SaPar, solverName, gaugeName, mass, twist, boundary, residual); +} +inline void Jlqcd::addmUd3SbHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addHeavySolver(app, mUd3SbPar, solverName, gaugeName, mass, twist, boundary, residual); +} +inline void Jlqcd::addcUd2SaHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addHeavySolver(app, cUd2SaPar, solverName, gaugeName, mass, twist, boundary, residual); +} +inline void Jlqcd::addcUd2SaLHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addHeavySolver(app, cUd2SaLPar, solverName, gaugeName, mass, twist, boundary, residual); +} +inline void Jlqcd::addcUd3SaHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addHeavySolver(app, cUd3SaPar, solverName, gaugeName, mass, twist, boundary, residual); +} +inline void Jlqcd::addcUd3SbHeavySolver(Application &app, const std::string &solverName, const std::string &gaugeName, + const double mass, const std::string &twist, + const std::string &boundary, const double residual) +{ + addHeavySolver(app, cUd3SbPar, solverName, gaugeName, mass, twist, boundary, residual); +} + +} // namespace hadpresets diff --git a/RbcUkqcd.hpp b/RbcUkqcd.hpp index 5439b7b..5b8d5e1 100644 --- a/RbcUkqcd.hpp +++ b/RbcUkqcd.hpp @@ -40,6 +40,9 @@ struct RbcUkqcd unsigned int L, T, Ls; }; + inline static constexpr hadpresets::RbcUkqcd::EnsembleParameters testPar{0.005, 0.0362, 1., 2., + 8, 8, 4}; + // C0 inline static constexpr EnsembleParameters c0UnitaryPar{0.00078, 0.0362, 1.8, 2., 48, 96, 24}; inline static constexpr unsigned int c0ZMobiusLs = 10; @@ -57,6 +60,10 @@ struct RbcUkqcd inline static constexpr EnsembleParameters c0LCDPar{0.00078, 0.0362, 1.8, NAN, 48, 96, c0ZMobiusLs}; + // C0L + inline static constexpr EnsembleParameters c0LUnitaryPar{0.00078, 0.0362, 1.8, 2., 64, 128, 24}; + inline static constexpr EnsembleParameters c0LLCDPar{0.00078, 0.0362, 1.8, 2., 64, 128, 24}; + // 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}; @@ -79,6 +86,11 @@ struct RbcUkqcd inline static constexpr DeflationParameters c1m20DeflPar{3.0e-03, 5.5, 101, 200, 220, 230}; inline static constexpr DeflationParameters c1m32DeflPar{5.0e-05, 5.5, 101, 100, 110, 120}; + // Light solvers: no deflation + static inline void addLightSolver(Application &app, const RbcUkqcd::EnsembleParameters &par, + const std::string solverName, const std::string gaugeName, + const std::string boundary, const double residual); + // Light solvers: load deflation from disk static inline void addC0LightZMobiusLCDSolver(Application &app, const std::string solverName, const std::string gaugeName, @@ -87,6 +99,17 @@ struct RbcUkqcd const std::string boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void + addC0LightMADWFLCDSolver(Grid::Hadrons::Application &app, const std::string solverName, + const std::string gaugeName, const std::string gaugeTransform, + const std::string eigenpackPath, const std::string boundary = "1 1 1 -1", + const double residual = 1.0e-8); + + static inline void + addC0LLightLCDSolver(Application &app, const std::string solverName, const std::string gaugeName, + const std::string gaugeTransform, const std::string eigenpackPath, + const std::string boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addM0LightLCDSolver(Application &app, const std::string solverName, const std::string gaugeName, const std::string gaugeTransform, const std::string eigenpackPath, @@ -125,6 +148,14 @@ struct RbcUkqcd const std::string gaugeName, const std::string boundary = "1 1 1 -1", const double residual = 1.0e-8); + static inline void addC0StrangeZMobiusSolver(Grid::Hadrons::Application &app, + const std::string solverName, + const std::string gaugeName, + const std::string boundary, const double residual); + static inline void addC0LStrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, + const std::string boundary = "1 1 1 -1", + const double residual = 1.0e-8); static inline void addM0StrangeSolver(Application &app, const std::string solverName, const std::string gaugeName, const std::string boundary = "1 1 1 1", @@ -147,10 +178,18 @@ struct RbcUkqcd const double residual = 1.0e-8); // Charm solvers, mass is a free parameter + static inline void addUnsmearedCharmSolver(Application &app, const std::string solverName, + const std::string gaugeName, const double mass, + const int Ls, const double M5, + const std::string boundary, const double residual); static inline void addC0CharmSolver(Application &app, const std::string solverName, const std::string gaugeName, const double mass, const std::string boundary = "1 1 1 -1", const double residual = 1.0e-18); + static inline void addC0LCharmSolver(Application &app, const std::string solverName, + const std::string gaugeName, const double mass, + const std::string boundary = "1 1 1 -1", + const double residual = 1.0e-18); static inline void addM0CharmSolver(Application &app, const std::string solverName, const std::string gaugeName, const double mass, const std::string boundary = "1 1 1 1", @@ -159,6 +198,46 @@ struct RbcUkqcd // Implementations ///////////////////////////////////////////////////////////////////////////////// +// Light +void RbcUkqcd::addLightSolver(Application &app, const RbcUkqcd::EnsembleParameters &par, + const std::string solverName, const std::string gaugeName, + const std::string boundary, 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.ml; + actionPar.scale = par.scale; + actionPar.boundary = boundary; + 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"; + solverPar.outerAction = prefix + "_dwf"; + solverPar.maxInnerIteration = 30000; + solverPar.maxOuterIteration = 100; + solverPar.residual = residual; + solverPar.innerGuesser = ""; + solverPar.outerGuesser = ""; + app.createModule(solverName, solverPar); +} + // Light C0 (load deflation from disk) void RbcUkqcd::addC0LightZMobiusLCDSolver(Application &app, const std::string solverName, const std::string gaugeName, @@ -236,6 +315,212 @@ void RbcUkqcd::addC0LightZMobiusLCDSolver(Application &app, const std::string so app.createModule(solverName, solverPar); } +void RbcUkqcd::addC0LightMADWFLCDSolver(Grid::Hadrons::Application &app, + const std::string solverName, const std::string gaugeName, + const std::string gaugeTransform, + const std::string eigenpackPath, const std::string boundary, + const double residual) +{ + using namespace Grid; + using namespace Hadrons; + using namespace hadpresets; + + const std::string prefix = solverName; + const bool gaugeFixed = !gaugeTransform.empty(); + + // Gauge field & transform FP32 cast + MUtilities::GaugeSinglePrecisionCast::Par gaugeCastPar; + + gaugeCastPar.field = gaugeName; + app.createModule(prefix + "_gauge_fp32", gaugeCastPar); + if (gaugeFixed) + { + MUtilities::ColourMatrixSinglePrecisionCast::Par transformCastPar; + + transformCastPar.field = gaugeTransform; + app.createModule(prefix + "_gaugeTransform_fp32", + transformCastPar); + } + + // Scaled DWF action + MAction::ScaledDWF::Par actionPar; + actionPar.gauge = gaugeName; + actionPar.Ls = RbcUkqcd::c0UnitaryPar.Ls; + actionPar.M5 = RbcUkqcd::c0UnitaryPar.M5; + actionPar.mass = RbcUkqcd::c0UnitaryPar.ml; + actionPar.scale = 2.; + actionPar.boundary = boundary; + actionPar.twist = "0. 0. 0. 0."; + app.createModule(prefix + "_dwf", actionPar); + + // Single-prec ZMobius Action + MAction::ZMobiusDWFF::Par actionFPar; + actionFPar.Ls = RbcUkqcd::c0LCDPar.Ls; + actionFPar.M5 = RbcUkqcd::c0LCDPar.M5; + actionFPar.mass = RbcUkqcd::c0LCDPar.ml; + actionFPar.b = 1.; + actionFPar.c = 0.; + actionFPar.omega = std::vector>(RbcUkqcd::c0ZMobiusOmega.begin(), + RbcUkqcd::c0ZMobiusOmega.end()); + actionFPar.boundary = boundary; + actionFPar.twist = "0. 0. 0. 0."; + actionFPar.gauge = prefix + "_gauge_fp32"; + app.createModule(prefix + "_dwf_fp32", actionFPar); + + // Compressed eigenpack + MIO::LoadCoarseFermionEigenPack250F::Par epPar; + + epPar.filestem = eigenpackPath; + epPar.multiFile = true; + epPar.redBlack = true; + epPar.sizeFine = 250; + epPar.sizeCoarse = 2000; + epPar.Ls = 10; + epPar.blockSize = "4 4 4 3 10"; + epPar.orthogonalise = gaugeFixed; + epPar.gaugeXform = gaugeFixed ? (prefix + "_gaugeTransform_fp32") : ""; + app.createModule(prefix + "_epack", epPar); + + // Inner guesser + MGuesser::CoarseDeflation250F::Par iguessPar; + + iguessPar.eigenPack = prefix + "_epack"; + iguessPar.size = 2000; + app.createModule(prefix + "_iguesser", iguessPar); + + // ZMobius-MADWF red-black preconditionned CG + MSolver::ZMADWFMixedPrecCG::Par solverPar; + solverPar.innerAction = prefix + "_dwf_fp32"; + solverPar.outerAction = prefix + "_dwf"; + solverPar.maxInnerIteration = 10000; + solverPar.maxPVIteration = 1000; + solverPar.maxOuterIteration = 100; + solverPar.innerResidual = 1e-5; + solverPar.PVResidual = 1e-5; + solverPar.outerResidual = residual; + solverPar.guesser = prefix + "_iguesser"; + app.createModule(solverName, solverPar); +} + +void RbcUkqcd::addC0StrangeZMobiusSolver(Grid::Hadrons::Application &app, + const std::string solverName, const std::string gaugeName, + const std::string boundary, const double residual) +{ + using namespace Grid; + using namespace Hadrons; + using namespace hadpresets; + + const std::string prefix = solverName; + + // Gauge field & transform FP32 cast + MUtilities::GaugeSinglePrecisionCast::Par gaugeCastPar; + + gaugeCastPar.field = gaugeName; + app.createModule(prefix + "_gauge_fp32", gaugeCastPar); + + // Scaled DWF action + FP32 version + MAction::ZMobiusDWF::Par actionPar; + + actionPar.gauge = gaugeName; + actionPar.Ls = RbcUkqcd::c0LCDPar.Ls; + actionPar.M5 = RbcUkqcd::c0LCDPar.M5; + actionPar.mass = RbcUkqcd::c0LCDPar.ms; + actionPar.b = 1.; + actionPar.c = 0.; + actionPar.omega = std::vector>(RbcUkqcd::c0ZMobiusOmega.begin(), + RbcUkqcd::c0ZMobiusOmega.end()); + actionPar.boundary = boundary; + 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 + MSolver::ZMixedPrecisionRBPrecCG::Par solverPar; + + solverPar.innerAction = prefix + "_dwf_fp32"; + solverPar.outerAction = prefix + "_dwf"; + solverPar.maxInnerIteration = 10000; + solverPar.maxOuterIteration = 100; + solverPar.residual = residual; + solverPar.innerGuesser = ""; + solverPar.outerGuesser = ""; + app.createModule(solverName, solverPar); +} + +// Light C0L (load deflation from disk) +void RbcUkqcd::addC0LLightLCDSolver(Application &app, const std::string solverName, + const std::string gaugeName, const std::string gaugeTransform, + const std::string eigenpackPath, const std::string boundary, + const double residual) +{ + const std::string prefix = solverName; + const bool gaugeFixed = !gaugeTransform.empty(); + + // Gauge field FP32 cast + MUtilities::GaugeSinglePrecisionCast::Par gaugeCastPar; + + gaugeCastPar.field = gaugeName; + app.createModule(prefix + "_gauge_fp32", gaugeCastPar); + if (gaugeFixed) + { + MUtilities::ColourMatrixSinglePrecisionCast::Par transformCastPar; + + transformCastPar.field = gaugeTransform; + app.createModule(prefix + "_gaugeTransform_fp32", + transformCastPar); + } + + // Scaled DWF action + FP32 version + MAction::ScaledDWF::Par actionPar; + + actionPar.gauge = gaugeName; + actionPar.Ls = RbcUkqcd::c0LLCDPar.Ls; + actionPar.M5 = RbcUkqcd::c0LLCDPar.M5; + actionPar.mass = RbcUkqcd::c0LLCDPar.ml; + actionPar.scale = RbcUkqcd::c0LLCDPar.scale; + actionPar.boundary = boundary; + actionPar.twist = "0. 0. 0. 0."; + app.createModule(prefix + "_dwf", actionPar); + actionPar.gauge = prefix + "_gauge_fp32"; + app.createModule(prefix + "_dwf_fp32", actionPar); + + // Compressed eigenpack + MIO::LoadCoarseFermionEigenPack200F::Par epPar; + + epPar.filestem = eigenpackPath; + epPar.multiFile = true; + epPar.redBlack = true; + epPar.sizeFine = 200; + epPar.sizeCoarse = 4500; + epPar.Ls = 24; + epPar.blockSize = "4 4 4 4 24"; + epPar.orthogonalise = false; + epPar.gaugeXform = gaugeFixed ? (prefix + "_gaugeTransform_fp32") : ""; + app.createModule(prefix + "_epack", epPar); + + // Inner guesser + MGuesser::CoarseDeflation200F::Par iguessPar; + + iguessPar.eigenPack = prefix + "_epack"; + iguessPar.size = 4500; + app.createModule(prefix + "_iguesser", iguessPar); + + // Batched mixed-precision red-black preconditionned CG + MSolver::MixedPrecisionRBPrecCGBatched::Par solverPar; + + solverPar.innerAction = prefix + "_dwf_fp32"; + solverPar.outerAction = prefix + "_dwf"; + solverPar.maxInnerIteration = 250; + solverPar.maxOuterIteration = 100; + solverPar.maxPatchupIteration = 10000; + solverPar.residual = residual; + solverPar.updateResidual = true; + solverPar.innerGuesser = prefix + "_iguesser"; + solverPar.outerGuesser = ""; + app.createModule(solverName, solverPar); +} + // Light M0 (load deflation from disk) void RbcUkqcd::addM0LightLCDSolver(Application &app, const std::string solverName, const std::string gaugeName, const std::string gaugeTransform, @@ -461,6 +746,14 @@ void RbcUkqcd::addC0StrangeSolver(Application &app, const std::string solverName residual); } +void RbcUkqcd::addC0LStrangeSolver(Application &app, const std::string solverName, + const std::string gaugeName, const std::string boundary, + const double residual) +{ + RbcUkqcd::addStrangeSolver(app, RbcUkqcd::c0LUnitaryPar, solverName, gaugeName, boundary, + residual); +} + void RbcUkqcd::addM0StrangeSolver(Application &app, const std::string solverName, const std::string gaugeName, const std::string boundary, const double residual) @@ -497,6 +790,51 @@ void RbcUkqcd::addC1M32StrangeSolver(Application &app, const std::string solverN RbcUkqcd::addStrangeSolver(app, RbcUkqcd::c1m32IRLPar, solverName, gaugeName, boundary, residual); } +// Charm +void RbcUkqcd::addUnsmearedCharmSolver(Grid::Hadrons::Application &app, + const std::string solverName, const std::string gaugeName, + const double mass, const int Ls, const double M5, + const std::string boundary, const double residual) +{ + using namespace Grid; + using namespace Hadrons; + + const std::string prefix = solverName; + + // Gauge field & transform 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 = Ls; + actionPar.M5 = M5; + actionPar.mass = mass; + actionPar.scale = 2.; + + actionPar.boundary = boundary; + 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 + MSolver::MixedPrecisionRBPrecCG::Par solverPar; + + solverPar.innerAction = prefix + "_dwf_fp32"; + solverPar.outerAction = prefix + "_dwf"; + solverPar.maxInnerIteration = 10000; + solverPar.maxOuterIteration = 100; + solverPar.residual = residual; + solverPar.innerGuesser = ""; + solverPar.outerGuesser = ""; + app.createModule(solverName, solverPar); +} + // Charm C0 void RbcUkqcd::addC0CharmSolver(Application &app, const std::string solverName, const std::string gaugeName, const double mass, @@ -535,6 +873,44 @@ void RbcUkqcd::addC0CharmSolver(Application &app, const std::string solverName, app.createModule(solverName, solverPar); } +// Charm C0L +void RbcUkqcd::addC0LCharmSolver(Application &app, const std::string solverName, + const std::string gaugeName, const double mass, + const std::string boundary, const double residual) +{ + const std::string prefix = solverName; + + // stout smearing + MGauge::StoutSmearing::Par smearPar; + + smearPar.gauge = gaugeName; + smearPar.steps = 3; + smearPar.rho = 0.1; + smearPar.orthogDim = ""; + app.createModule(prefix + "_gauge_3stout", smearPar); + + // Scaled DWF action + FP32 version + MAction::ScaledDWF::Par actionPar; + + actionPar.gauge = prefix + "_gauge_3stout"; + actionPar.Ls = 12; + actionPar.M5 = 1.; + actionPar.mass = mass; + actionPar.scale = 2.; + actionPar.boundary = boundary; + actionPar.twist = "0. 0. 0. 0."; + app.createModule(prefix + "_dwf", actionPar); + + // Red-black preconditionned CG + MSolver::RBPrecCG::Par solverPar; + + solverPar.action = prefix + "_dwf"; + solverPar.maxIteration = 30000; + solverPar.residual = residual; + solverPar.guesser = ""; + app.createModule(solverName, solverPar); +} + // Charm M0 void RbcUkqcd::addM0CharmSolver(Application &app, const std::string solverName, const std::string gaugeName, const double mass,