]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make non-scalar args const refs. Change BICGSTAB to Bicgstab.
authorPratik Nayak <pratik.nayak4@gmail.com>
Sat, 27 Apr 2019 18:16:02 +0000 (20:16 +0200)
committerPratik Nayak <pratik.nayak4@gmail.com>
Sat, 27 Apr 2019 18:16:02 +0000 (20:16 +0200)
include/deal.II/lac/ginkgo_solver.h
source/lac/ginkgo_solver.cc
tests/ginkgo/solver.cc

index 9307385b9a7accc0da4415ece47890a3517746b4..9f4116d0d9a3ae14b683c80fa194903e28be3396 100644 (file)
@@ -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<gko::matrix::Csr<ValueType, IndexType>> 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<gko::LinOpFactory> preconditioner,
-             const AdditionalData &             data = AdditionalData());
+    SolverCG(SolverControl &                           solver_control,
+             const std::string &                       exec_type,
+             const std::shared_ptr<gko::LinOpFactory> &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 <typename ValueType = double, typename IndexType = int32_t>
-  class SolverBICGSTAB : public SolverBase<ValueType, IndexType>
+  class SolverBicgstab : public SolverBase<ValueType, IndexType>
   {
   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<gko::LinOpFactory> preconditioner,
-                   const AdditionalData &             data = AdditionalData());
+    SolverBicgstab(SolverControl &                           solver_control,
+                   const std::string &                       exec_type,
+                   const std::shared_ptr<gko::LinOpFactory> &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<gko::LinOpFactory> preconditioner,
-              const AdditionalData &             data = AdditionalData());
+    SolverCGS(SolverControl &                           solver_control,
+              const std::string &                       exec_type,
+              const std::shared_ptr<gko::LinOpFactory> &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<gko::LinOpFactory> preconditioner,
-              const AdditionalData &             data = AdditionalData());
+    SolverFCG(SolverControl &                           solver_control,
+              const std::string &                       exec_type,
+              const std::shared_ptr<gko::LinOpFactory> &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<gko::LinOpFactory> preconditioner,
-                const AdditionalData &             data = AdditionalData());
+    SolverGMRES(SolverControl &                           solver_control,
+                const std::string &                       exec_type,
+                const std::shared_ptr<gko::LinOpFactory> &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<gko::LinOpFactory> inner_solver,
-             const AdditionalData &             data = AdditionalData());
+    SolverIR(SolverControl &                           solver_control,
+             const std::string &                       exec_type,
+             const std::shared_ptr<gko::LinOpFactory> &inner_solver,
+             const AdditionalData &                    data = AdditionalData());
 
   protected:
     /**
index 1e58be06705aeeaf82918bd080ea715f98019741..f79e10d29bd4032e87634fbcc6e4ccb07ec08424 100644 (file)
@@ -32,7 +32,7 @@ namespace GinkgoWrappers
 {
   template <typename ValueType, typename IndexType>
   SolverBase<ValueType, IndexType>::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 <typename ValueType, typename IndexType>
   SolverCG<ValueType, IndexType>::SolverCG(SolverControl &       solver_control,
-                                           std::string           exec_type,
+                                           const std::string &   exec_type,
                                            const AdditionalData &data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
@@ -307,10 +307,10 @@ namespace GinkgoWrappers
 
   template <typename ValueType, typename IndexType>
   SolverCG<ValueType, IndexType>::SolverCG(
-    SolverControl &                    solver_control,
-    std::string                        exec_type,
-    std::shared_ptr<gko::LinOpFactory> preconditioner,
-    const AdditionalData &             data)
+    SolverControl &                           solver_control,
+    const std::string &                       exec_type,
+    const std::shared_ptr<gko::LinOpFactory> &preconditioner,
+    const AdditionalData &                    data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
   {
@@ -322,12 +322,12 @@ namespace GinkgoWrappers
   }
 
 
-  /* ---------------------- SolverBICGSTAB ------------------------ */
+  /* ---------------------- SolverBicgstab ------------------------ */
 
   template <typename ValueType, typename IndexType>
-  SolverBICGSTAB<ValueType, IndexType>::SolverBICGSTAB(
+  SolverBicgstab<ValueType, IndexType>::SolverBicgstab(
     SolverControl &       solver_control,
-    std::string           exec_type,
+    const std::string &   exec_type,
     const AdditionalData &data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
@@ -339,11 +339,11 @@ namespace GinkgoWrappers
   }
 
   template <typename ValueType, typename IndexType>
-  SolverBICGSTAB<ValueType, IndexType>::SolverBICGSTAB(
-    SolverControl &                    solver_control,
-    std::string                        exec_type,
-    std::shared_ptr<gko::LinOpFactory> preconditioner,
-    const AdditionalData &             data)
+  SolverBicgstab<ValueType, IndexType>::SolverBicgstab(
+    SolverControl &                           solver_control,
+    const std::string &                       exec_type,
+    const std::shared_ptr<gko::LinOpFactory> &preconditioner,
+    const AdditionalData &                    data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
   {
@@ -357,8 +357,8 @@ namespace GinkgoWrappers
   /* ---------------------- SolverCGS ------------------------ */
 
   template <typename ValueType, typename IndexType>
-  SolverCGS<ValueType, IndexType>::SolverCGS(SolverControl &solver_control,
-                                             std::string    exec_type,
+  SolverCGS<ValueType, IndexType>::SolverCGS(SolverControl &    solver_control,
+                                             const std::string &exec_type,
                                              const AdditionalData &data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
@@ -370,10 +370,10 @@ namespace GinkgoWrappers
 
   template <typename ValueType, typename IndexType>
   SolverCGS<ValueType, IndexType>::SolverCGS(
-    SolverControl &                    solver_control,
-    std::string                        exec_type,
-    std::shared_ptr<gko::LinOpFactory> preconditioner,
-    const AdditionalData &             data)
+    SolverControl &                           solver_control,
+    const std::string &                       exec_type,
+    const std::shared_ptr<gko::LinOpFactory> &preconditioner,
+    const AdditionalData &                    data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
   {
@@ -387,8 +387,8 @@ namespace GinkgoWrappers
   /* ---------------------- SolverFCG ------------------------ */
 
   template <typename ValueType, typename IndexType>
-  SolverFCG<ValueType, IndexType>::SolverFCG(SolverControl &solver_control,
-                                             std::string    exec_type,
+  SolverFCG<ValueType, IndexType>::SolverFCG(SolverControl &    solver_control,
+                                             const std::string &exec_type,
                                              const AdditionalData &data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
@@ -400,10 +400,10 @@ namespace GinkgoWrappers
 
   template <typename ValueType, typename IndexType>
   SolverFCG<ValueType, IndexType>::SolverFCG(
-    SolverControl &                    solver_control,
-    std::string                        exec_type,
-    std::shared_ptr<gko::LinOpFactory> preconditioner,
-    const AdditionalData &             data)
+    SolverControl &                           solver_control,
+    const std::string &                       exec_type,
+    const std::shared_ptr<gko::LinOpFactory> &preconditioner,
+    const AdditionalData &                    data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
   {
@@ -424,7 +424,7 @@ namespace GinkgoWrappers
 
   template <typename ValueType, typename IndexType>
   SolverGMRES<ValueType, IndexType>::SolverGMRES(SolverControl &solver_control,
-                                                 std::string    exec_type,
+                                                 const std::string &exec_type,
                                                  const AdditionalData &data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
@@ -438,10 +438,10 @@ namespace GinkgoWrappers
 
   template <typename ValueType, typename IndexType>
   SolverGMRES<ValueType, IndexType>::SolverGMRES(
-    SolverControl &                    solver_control,
-    std::string                        exec_type,
-    std::shared_ptr<gko::LinOpFactory> preconditioner,
-    const AdditionalData &             data)
+    SolverControl &                           solver_control,
+    const std::string &                       exec_type,
+    const std::shared_ptr<gko::LinOpFactory> &preconditioner,
+    const AdditionalData &                    data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
   {
@@ -457,7 +457,7 @@ namespace GinkgoWrappers
 
   template <typename ValueType, typename IndexType>
   SolverIR<ValueType, IndexType>::SolverIR(SolverControl &       solver_control,
-                                           std::string           exec_type,
+                                           const std::string &   exec_type,
                                            const AdditionalData &data)
     : SolverBase<ValueType, IndexType>(solver_control, exec_type)
     , additional_data(data)
@@ -469,10 +469,10 @@ namespace GinkgoWrappers
 
   template <typename ValueType, typename IndexType>
   SolverIR<ValueType, IndexType>::SolverIR(
-    SolverControl &                    solver_control,
-    std::string                        exec_type,
-    std::shared_ptr<gko::LinOpFactory> inner_solver,
-    const AdditionalData &             data)
+    SolverControl &                           solver_control,
+    const std::string &                       exec_type,
+    const std::shared_ptr<gko::LinOpFactory> &inner_solver,
+    const AdditionalData &                    data)
     : SolverBase<ValueType, IndexType>(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<ValueType, IndexType>
-  DEALII_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(DECLARE_SOLVER_BICGSTAB)
-#  undef DECLARE_SOLVER_BICGSTAB
+#  define DECLARE_SOLVER_Bicgstab(ValueType, IndexType) \
+    class SolverBicgstab<ValueType, IndexType>
+  DEALII_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(DECLARE_SOLVER_Bicgstab)
+#  undef DECLARE_SOLVER_Bicgstab
 
 #  define DECLARE_SOLVER_CGS(ValueType, IndexType) \
     class SolverCGS<ValueType, IndexType>
index 12709a450669d085356e0e3041af5d84c71c253d..f24c4b669ffafb3e24ea61f6b1db38295382693c 100644 (file)
@@ -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);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.