From 815a9780d19ce8b90136d46defb8321290e85b45 Mon Sep 17 00:00:00 2001 From: Pratik Nayak Date: Sat, 27 Apr 2019 20:16:02 +0200 Subject: [PATCH] Make non-scalar args const refs. Change BICGSTAB to Bicgstab. --- include/deal.II/lac/ginkgo_solver.h | 87 +++++++++++++++-------------- source/lac/ginkgo_solver.cc | 82 +++++++++++++-------------- tests/ginkgo/solver.cc | 2 +- 3 files changed, 87 insertions(+), 84 deletions(-) diff --git a/include/deal.II/lac/ginkgo_solver.h b/include/deal.II/lac/ginkgo_solver.h index 9307385b9a..9f4116d0d9 100644 --- a/include/deal.II/lac/ginkgo_solver.h +++ b/include/deal.II/lac/ginkgo_solver.h @@ -54,6 +54,9 @@ namespace GinkgoWrappers * Constructor. * * The @p exec_type defines the paradigm where the solution is computed. + * It is a string and the choices are "omp" , "reference" or "cuda". + * The respective strings create the respective executors as given below. + * * Ginkgo currently supports three different executor types: * * + OmpExecutor specifies that the data should be stored and the @@ -99,7 +102,7 @@ namespace GinkgoWrappers * The @p solver_control object is the same as for other * deal.II iterative solvers. */ - SolverBase(SolverControl &solver_control, std::string exec_type); + SolverBase(SolverControl &solver_control, const std::string &exec_type); /** * Destructor. @@ -195,11 +198,11 @@ namespace GinkgoWrappers std::shared_ptr> system_matrix; /** - * The execution paradigm to be set by the user. The choices are between - * `omp`, `cuda` and `reference` - * and more details can be found in Ginkgo's documentation. + * The execution paradigm as a string to be set by the user . The choices + * are between `omp`, `cuda` and `reference` and more details can be found + * in Ginkgo's documentation. */ - std::string exec_type; + const std::string exec_type; }; @@ -228,7 +231,7 @@ namespace GinkgoWrappers * @p exec_type The execution paradigm for the CG solver. */ SolverCG(SolverControl & solver_control, - std::string exec_type, + const std::string & exec_type, const AdditionalData &data = AdditionalData()); /** @@ -242,10 +245,10 @@ namespace GinkgoWrappers * * @p preconditioner The preconditioner for the solver. */ - SolverCG(SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data = AdditionalData()); + SolverCG(SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData & data = AdditionalData()); protected: /** @@ -256,12 +259,12 @@ namespace GinkgoWrappers /** - * An implementation of the solver interface using the Ginkgo BICGSTAB solver. + * An implementation of the solver interface using the Ginkgo Bicgstab solver. * * @ingroup GinkgoWrappers */ template - class SolverBICGSTAB : public SolverBase + class SolverBicgstab : public SolverBase { public: /** @@ -274,30 +277,30 @@ namespace GinkgoWrappers * Constructor. * * @p solver_control The solver control object is then used to set the - * parameters and setup the BICGSTAB solver from the BICGSTAB factory which + * parameters and setup the Bicgstab solver from the Bicgstab factory which * solves the linear system. * - * @p exec_type The execution paradigm for the BICGSTAB solver. + * @p exec_type The execution paradigm for the Bicgstab solver. */ - SolverBICGSTAB(SolverControl & solver_control, - std::string exec_type, + SolverBicgstab(SolverControl & solver_control, + const std::string & exec_type, const AdditionalData &data = AdditionalData()); /** * Constructor. * * @p solver_control The solver control object is then used to set the - * parameters and setup the BICGSTAB solver from the BICGSTAB factory which + * parameters and setup the Bicgstab solver from the Bicgstab factory which * solves the linear system. * - * @p exec_type The execution paradigm for the BICGSTAB solver. + * @p exec_type The execution paradigm for the Bicgstab solver. * * @p preconditioner The preconditioner for the solver. */ - SolverBICGSTAB(SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data = AdditionalData()); + SolverBicgstab(SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData &data = AdditionalData()); protected: /** @@ -331,7 +334,7 @@ namespace GinkgoWrappers * @p exec_type The execution paradigm for the CGS solver. */ SolverCGS(SolverControl & solver_control, - std::string exec_type, + const std::string & exec_type, const AdditionalData &data = AdditionalData()); /** @@ -345,10 +348,10 @@ namespace GinkgoWrappers * * @p preconditioner The preconditioner for the solver. */ - SolverCGS(SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data = AdditionalData()); + SolverCGS(SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData &data = AdditionalData()); protected: /** @@ -382,7 +385,7 @@ namespace GinkgoWrappers * @p exec_type The execution paradigm for the FCG solver. */ SolverFCG(SolverControl & solver_control, - std::string exec_type, + const std::string & exec_type, const AdditionalData &data = AdditionalData()); /** @@ -396,10 +399,10 @@ namespace GinkgoWrappers * * @p preconditioner The preconditioner for the solver. */ - SolverFCG(SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data = AdditionalData()); + SolverFCG(SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData &data = AdditionalData()); protected: /** @@ -444,7 +447,7 @@ namespace GinkgoWrappers * @p exec_type The execution paradigm for the GMRES solver. */ SolverGMRES(SolverControl & solver_control, - std::string exec_type, + const std::string & exec_type, const AdditionalData &data = AdditionalData()); /** @@ -458,10 +461,10 @@ namespace GinkgoWrappers * * @p preconditioner The preconditioner for the solver. */ - SolverGMRES(SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data = AdditionalData()); + SolverGMRES(SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData &data = AdditionalData()); protected: /** @@ -495,7 +498,7 @@ namespace GinkgoWrappers * @p exec_type The execution paradigm for the IR solver. */ SolverIR(SolverControl & solver_control, - std::string exec_type, + const std::string & exec_type, const AdditionalData &data = AdditionalData()); /** @@ -509,10 +512,10 @@ namespace GinkgoWrappers * * @p inner_solver The Inner solver for the IR solver. */ - SolverIR(SolverControl & solver_control, - std::string exec_type, - std::shared_ptr inner_solver, - const AdditionalData & data = AdditionalData()); + SolverIR(SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &inner_solver, + const AdditionalData & data = AdditionalData()); protected: /** diff --git a/source/lac/ginkgo_solver.cc b/source/lac/ginkgo_solver.cc index 1e58be0670..f79e10d29b 100644 --- a/source/lac/ginkgo_solver.cc +++ b/source/lac/ginkgo_solver.cc @@ -32,7 +32,7 @@ namespace GinkgoWrappers { template SolverBase::SolverBase(SolverControl &solver_control, - std::string exec_type) + const std::string &exec_type) : solver_control(solver_control) , exec_type(exec_type) { @@ -51,7 +51,7 @@ namespace GinkgoWrappers else { std::cerr - << "exec_type needs to be one of the three strings: reference, cuda or omp, but provided with" + << "exec_type needs to be one of the three strings: \"reference\", \"cuda\" or \"omp\", but provided with" << exec_type << std::endl; std::exit(-1); } @@ -295,7 +295,7 @@ namespace GinkgoWrappers template SolverCG::SolverCG(SolverControl & solver_control, - std::string exec_type, + const std::string & exec_type, const AdditionalData &data) : SolverBase(solver_control, exec_type) , additional_data(data) @@ -307,10 +307,10 @@ namespace GinkgoWrappers template SolverCG::SolverCG( - SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data) + SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData & data) : SolverBase(solver_control, exec_type) , additional_data(data) { @@ -322,12 +322,12 @@ namespace GinkgoWrappers } - /* ---------------------- SolverBICGSTAB ------------------------ */ + /* ---------------------- SolverBicgstab ------------------------ */ template - SolverBICGSTAB::SolverBICGSTAB( + SolverBicgstab::SolverBicgstab( SolverControl & solver_control, - std::string exec_type, + const std::string & exec_type, const AdditionalData &data) : SolverBase(solver_control, exec_type) , additional_data(data) @@ -339,11 +339,11 @@ namespace GinkgoWrappers } template - SolverBICGSTAB::SolverBICGSTAB( - SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data) + SolverBicgstab::SolverBicgstab( + SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData & data) : SolverBase(solver_control, exec_type) , additional_data(data) { @@ -357,8 +357,8 @@ namespace GinkgoWrappers /* ---------------------- SolverCGS ------------------------ */ template - SolverCGS::SolverCGS(SolverControl &solver_control, - std::string exec_type, + SolverCGS::SolverCGS(SolverControl & solver_control, + const std::string &exec_type, const AdditionalData &data) : SolverBase(solver_control, exec_type) , additional_data(data) @@ -370,10 +370,10 @@ namespace GinkgoWrappers template SolverCGS::SolverCGS( - SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data) + SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData & data) : SolverBase(solver_control, exec_type) , additional_data(data) { @@ -387,8 +387,8 @@ namespace GinkgoWrappers /* ---------------------- SolverFCG ------------------------ */ template - SolverFCG::SolverFCG(SolverControl &solver_control, - std::string exec_type, + SolverFCG::SolverFCG(SolverControl & solver_control, + const std::string &exec_type, const AdditionalData &data) : SolverBase(solver_control, exec_type) , additional_data(data) @@ -400,10 +400,10 @@ namespace GinkgoWrappers template SolverFCG::SolverFCG( - SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data) + SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData & data) : SolverBase(solver_control, exec_type) , additional_data(data) { @@ -424,7 +424,7 @@ namespace GinkgoWrappers template SolverGMRES::SolverGMRES(SolverControl &solver_control, - std::string exec_type, + const std::string &exec_type, const AdditionalData &data) : SolverBase(solver_control, exec_type) , additional_data(data) @@ -438,10 +438,10 @@ namespace GinkgoWrappers template SolverGMRES::SolverGMRES( - SolverControl & solver_control, - std::string exec_type, - std::shared_ptr preconditioner, - const AdditionalData & data) + SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &preconditioner, + const AdditionalData & data) : SolverBase(solver_control, exec_type) , additional_data(data) { @@ -457,7 +457,7 @@ namespace GinkgoWrappers template SolverIR::SolverIR(SolverControl & solver_control, - std::string exec_type, + const std::string & exec_type, const AdditionalData &data) : SolverBase(solver_control, exec_type) , additional_data(data) @@ -469,10 +469,10 @@ namespace GinkgoWrappers template SolverIR::SolverIR( - SolverControl & solver_control, - std::string exec_type, - std::shared_ptr inner_solver, - const AdditionalData & data) + SolverControl & solver_control, + const std::string & exec_type, + const std::shared_ptr &inner_solver, + const AdditionalData & data) : SolverBase(solver_control, exec_type) , additional_data(data) { @@ -500,10 +500,10 @@ namespace GinkgoWrappers DEALII_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(DECLARE_SOLVER_CG) # undef DECLARE_SOLVER_CG -# define DECLARE_SOLVER_BICGSTAB(ValueType, IndexType) \ - class SolverBICGSTAB - DEALII_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(DECLARE_SOLVER_BICGSTAB) -# undef DECLARE_SOLVER_BICGSTAB +# define DECLARE_SOLVER_Bicgstab(ValueType, IndexType) \ + class SolverBicgstab + DEALII_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(DECLARE_SOLVER_Bicgstab) +# undef DECLARE_SOLVER_Bicgstab # define DECLARE_SOLVER_CGS(ValueType, IndexType) \ class SolverCGS diff --git a/tests/ginkgo/solver.cc b/tests/ginkgo/solver.cc index 12709a4506..f24c4b669f 100644 --- a/tests/ginkgo/solver.cc +++ b/tests/ginkgo/solver.cc @@ -69,7 +69,7 @@ main(int argc, char **argv) .on(exec)) .on(exec); GinkgoWrappers::SolverCG<> cg_solver(control, executor); - GinkgoWrappers::SolverBICGSTAB<> bicgstab_solver(control, executor); + GinkgoWrappers::SolverBicgstab<> bicgstab_solver(control, executor); GinkgoWrappers::SolverCGS<> cgs_solver(control, executor); GinkgoWrappers::SolverFCG<> fcg_solver(control, executor); GinkgoWrappers::SolverGMRES<> gmres_solver(control, executor); -- 2.39.5