From 74c38822ed563ac6e0c1e42757570b8860595b20 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 5 Feb 2019 21:56:51 +0000 Subject: [PATCH] Hadrons: 32 bit I/O directly in Lanczos module --- Hadrons/EigenPack.hpp | 4 ++- Hadrons/Module.hpp | 9 ++++++ Hadrons/Modules/MIO/LoadCoarseEigenPack.cc | 4 ++- Hadrons/Modules/MIO/LoadCoarseEigenPack.hpp | 32 +++++++++++++++---- .../Modules/MSolver/LocalCoherenceLanczos.hpp | 21 +++++++++--- 5 files changed, 57 insertions(+), 13 deletions(-) diff --git a/Hadrons/EigenPack.hpp b/Hadrons/EigenPack.hpp index a0f8b2c1..1c7497f2 100644 --- a/Hadrons/EigenPack.hpp +++ b/Hadrons/EigenPack.hpp @@ -308,7 +308,9 @@ template { public: - typedef CoarseF CoarseField; + typedef CoarseF CoarseField; + typedef CoarseFIo CoarseFieldIo; +public: std::vector evecCoarse; std::vector evalCoarse; public: diff --git a/Hadrons/Module.hpp b/Hadrons/Module.hpp index 6f923867..95db9511 100644 --- a/Hadrons/Module.hpp +++ b/Hadrons/Module.hpp @@ -77,6 +77,15 @@ env().template getGrid(Ls) #define envGetGrid(...)\ HADRONS_MACRO_REDIRECT_12(__VA_ARGS__, envGetGrid5, envGetGrid4)(__VA_ARGS__) +#define envGetCoarseGrid4(latticeType, blockSize)\ +env().template getCoarseGrid(blockSize) + +#define envGetCoarseGrid5(latticeType, blockSize, Ls)\ +env().template getCoarseGrid(blockSize, Ls) + +#define envGetCoarseGrid(...)\ +HADRONS_MACRO_REDIRECT_23(__VA_ARGS__, envGetCoarseGrid5, envGetCoarseGrid4)(__VA_ARGS__) + #define envGetRbGrid4(latticeType)\ env().template getRbGrid() diff --git a/Hadrons/Modules/MIO/LoadCoarseEigenPack.cc b/Hadrons/Modules/MIO/LoadCoarseEigenPack.cc index 22c00843..22bc55a6 100644 --- a/Hadrons/Modules/MIO/LoadCoarseEigenPack.cc +++ b/Hadrons/Modules/MIO/LoadCoarseEigenPack.cc @@ -32,4 +32,6 @@ using namespace Hadrons; using namespace MIO; template class Grid::Hadrons::MIO::TLoadCoarseEigenPack>; - +#ifdef GRID_DEFAULT_PRECISION_DOUBLE +template class Grid::Hadrons::MIO::TLoadCoarseEigenPack>; +#endif diff --git a/Hadrons/Modules/MIO/LoadCoarseEigenPack.hpp b/Hadrons/Modules/MIO/LoadCoarseEigenPack.hpp index 2e17356e..521b4814 100644 --- a/Hadrons/Modules/MIO/LoadCoarseEigenPack.hpp +++ b/Hadrons/Modules/MIO/LoadCoarseEigenPack.hpp @@ -56,7 +56,11 @@ template class TLoadCoarseEigenPack: public Module { public: - typedef CoarseEigenPack BasePack; + typedef typename Pack::Field Field; + typedef typename Pack::FieldIo FieldIo; + typedef typename Pack::CoarseField CoarseField; + typedef typename Pack::CoarseFieldIo CoarseFieldIo; + typedef CoarseEigenPack BasePack; template using iImplScalar = iScalar>>; typedef iImplScalar SiteComplex; @@ -74,7 +78,12 @@ public: virtual void execute(void); }; -MODULE_REGISTER_TMP(LoadCoarseFermionEigenPack, ARG(TLoadCoarseEigenPack>), MIO); +MODULE_REGISTER_TMP(LoadCoarseFermionEigenPack, + ARG(TLoadCoarseEigenPack>), MIO); +#ifdef GRID_DEFAULT_PRECISION_DOUBLE +MODULE_REGISTER_TMP(LoadCoarseFermionEigenPackIo32, + ARG(TLoadCoarseEigenPack>), MIO); +#endif /****************************************************************************** * TLoadCoarseEigenPack implementation * @@ -106,18 +115,27 @@ std::vector TLoadCoarseEigenPack::getOutput(void) template void TLoadCoarseEigenPack::setup(void) { - env().createGrid(par().Ls); - env().createCoarseGrid(par().blockSize, par().Ls); + GridBase *gridIo = nullptr, *gridCoarseIo = nullptr; + + if (typeHash() != typeHash()) + { + gridIo = envGetRbGrid(FieldIo, par().Ls); + } + if (typeHash() != typeHash()) + { + gridCoarseIo = envGetCoarseGrid(CoarseFieldIo, par().blockSize, par().Ls); + } envCreateDerived(BasePack, Pack, getName(), par().Ls, par().sizeFine, - par().sizeCoarse, env().getRbGrid(par().Ls), - env().getCoarseGrid(par().blockSize, par().Ls)); + par().sizeCoarse, envGetRbGrid(Field, par().Ls), + envGetCoarseGrid(CoarseField, par().blockSize, par().Ls), + gridIo, gridCoarseIo); } // execution /////////////////////////////////////////////////////////////////// template void TLoadCoarseEigenPack::execute(void) { - auto cg = env().getCoarseGrid(par().blockSize, par().Ls); + auto cg = envGetCoarseGrid(CoarseField, par().blockSize, par().Ls); auto &epack = envGetDerived(BasePack, Pack, getName()); Lattice dummy(cg); diff --git a/Hadrons/Modules/MSolver/LocalCoherenceLanczos.hpp b/Hadrons/Modules/MSolver/LocalCoherenceLanczos.hpp index bde6d065..72045313 100644 --- a/Hadrons/Modules/MSolver/LocalCoherenceLanczos.hpp +++ b/Hadrons/Modules/MSolver/LocalCoherenceLanczos.hpp @@ -65,6 +65,10 @@ public: nBasis> LCL; typedef BaseFermionEigenPack BasePack; typedef CoarseFermionEigenPack CoarsePack; + typedef typename CoarsePack::Field Field; + typedef typename CoarsePack::FieldIo FieldIo; + typedef typename CoarsePack::CoarseField CoarseField; + typedef typename CoarsePack::CoarseFieldIo CoarseFieldIo; typedef HADRONS_DEFAULT_SCHUR_OP SchurFMat; public: // constructor @@ -123,21 +127,30 @@ void TLocalCoherenceLanczos::setup(void) unsigned int Ls = env().getObjectLs(par().action); auto blockSize = strToVec(par().blockSize); + GridBase *gridIo = nullptr, *gridCoarseIo = nullptr; - env().createCoarseGrid(blockSize, Ls); + if (typeHash() != typeHash()) + { + gridIo = envGetRbGrid(FieldIo, Ls); + } + if (typeHash() != typeHash()) + { + gridCoarseIo = envGetCoarseGrid(CoarseFieldIo, blockSize, Ls); + } - auto cg = env().getCoarseGrid(blockSize, Ls); + auto cg = envGetCoarseGrid(CoarseField, blockSize, Ls); int cNm = (par().doCoarse) ? par().coarseParams.Nm : 0; LOG(Message) << "Coarse grid: " << cg->GlobalDimensions() << std::endl; envCreateDerived(BasePack, CoarsePack, getName(), Ls, - par().fineParams.Nm, cNm, env().getRbGrid(Ls), cg); + par().fineParams.Nm, cNm, envGetRbGrid(Field, Ls), cg, + gridIo, gridCoarseIo); auto &epack = envGetDerived(BasePack, CoarsePack, getName()); envTmp(SchurFMat, "mat", Ls, envGet(FMat, par().action)); envGetTmp(SchurFMat, mat); - envTmp(LCL, "solver", Ls, env().getRbGrid(Ls), cg, mat, + envTmp(LCL, "solver", Ls, envGetRbGrid(Field, Ls), cg, mat, Odd, epack.evec, epack.evecCoarse, epack.eval, epack.evalCoarse); }