MFEM  v4.1.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Attributes | List of all members
mfem::GinkgoWrappers::GinkgoIterativeSolverBase Class Reference

#include <ginkgo.hpp>

Inheritance diagram for mfem::GinkgoWrappers::GinkgoIterativeSolverBase:
[legend]

Public Member Functions

 GinkgoIterativeSolverBase (const std::string &exec_type, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
 
virtual ~GinkgoIterativeSolverBase ()=default
 
void initialize (const SparseMatrix *matrix)
 
void apply (Vector &solution, const Vector &rhs)
 
void solve (const SparseMatrix *matrix, Vector &solution, const Vector &rhs)
 

Protected Attributes

int print_lvl
 
int max_iter
 
double rel_tol
 
double abs_tol
 
double final_norm
 
int final_iter
 
int converged
 
std::shared_ptr
< gko::LinOpFactory > 
solver_gen
 
std::shared_ptr
< gko::stop::ResidualNormReduction
<>::Factory > 
residual_criterion
 
std::shared_ptr
< gko::log::Convergence<> > 
convergence_logger
 
std::shared_ptr< ResidualLogger<> > residual_logger
 
std::shared_ptr
< gko::stop::Combined::Factory > 
combined_factory
 
std::shared_ptr< gko::Executor > executor
 

Detailed Description

This class forms the base class for all of Ginkgo's iterative solvers. The various derived classes only take the additional data that is specific to them and solve the given linear system. The entire collection of solvers that Ginkgo implements is available at the Ginkgo documentation and manual pages, https://ginkgo-project.github.io/ginkgo/doc/develop.

Definition at line 192 of file ginkgo.hpp.

Constructor & Destructor Documentation

mfem::GinkgoWrappers::GinkgoIterativeSolverBase::GinkgoIterativeSolverBase ( const std::string &  exec_type,
int  print_iter,
int  max_num_iter,
double  RTOLERANCE,
double  ATOLERANCE 
)

Constructor.

The 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 associated operations executed on an OpenMP-supporting device (e.g. host CPU); ``` auto omp = gko::create<gko::OmpExecutor>(); ```
  • CudaExecutor specifies that the data should be stored and the operations executed on the NVIDIA GPU accelerator; ``` if(gko::CudaExecutor::get_num_devices() > 0 ) { auto cuda = gko::create<gko::CudaExecutor>(); } ```
  • ReferenceExecutor executes a non-optimized reference implementation, which can be used to debug the library. ``` auto ref = gko::create<gko::ReferenceExecutor>(); ```

The following code snippet demonstrates the using of the OpenMP executor to create a solver which would use the OpenMP paradigm to the solve the system on the CPU.

``` auto omp = gko::create<gko::OmpExecutor>(); using cg = gko::solver::Cg<>; auto solver_gen = cg::build() .with_criteria( gko::stop::Iteration::build().with_max_iters(20u).on(omp), gko::stop::ResidualNormReduction<>::build() .with_reduction_factor(1e-6) .on(omp)) .on(omp); auto solver = solver_gen->generate(system_matrix);

solver->apply(lend(rhs), lend(solution)); ```

Definition at line 31 of file ginkgo.cpp.

virtual mfem::GinkgoWrappers::GinkgoIterativeSolverBase::~GinkgoIterativeSolverBase ( )
virtualdefault

Destructor.

Member Function Documentation

void mfem::GinkgoWrappers::GinkgoIterativeSolverBase::apply ( Vector solution,
const Vector rhs 
)

Solve the linear system Ax=b. Dependent on the information provided by derived classes one of Ginkgo's linear solvers is chosen.

Definition at line 85 of file ginkgo.cpp.

void mfem::GinkgoWrappers::GinkgoIterativeSolverBase::initialize ( const SparseMatrix matrix)

Initialize the matrix and copy over its data to Ginkgo's data structures.

Definition at line 225 of file ginkgo.cpp.

void mfem::GinkgoWrappers::GinkgoIterativeSolverBase::solve ( const SparseMatrix matrix,
Vector solution,
const Vector rhs 
)

Solve the linear system Ax=b. Dependent on the information provided by derived classes one of Ginkgo's linear solvers is chosen.

Definition at line 258 of file ginkgo.cpp.

Member Data Documentation

double mfem::GinkgoWrappers::GinkgoIterativeSolverBase::abs_tol
protected

Definition at line 278 of file ginkgo.hpp.

std::shared_ptr<gko::stop::Combined::Factory> mfem::GinkgoWrappers::GinkgoIterativeSolverBase::combined_factory
protected

The Ginkgo combined factory object is used to create a combined stopping criterion to be passed to the solver.

Definition at line 311 of file ginkgo.hpp.

int mfem::GinkgoWrappers::GinkgoIterativeSolverBase::converged
mutableprotected

Definition at line 281 of file ginkgo.hpp.

std::shared_ptr<gko::log::Convergence<> > mfem::GinkgoWrappers::GinkgoIterativeSolverBase::convergence_logger
protected

The Ginkgo convergence logger used to check for convergence and other solver data if needed.

Definition at line 299 of file ginkgo.hpp.

std::shared_ptr<gko::Executor> mfem::GinkgoWrappers::GinkgoIterativeSolverBase::executor
protected

The execution paradigm in Ginkgo. The choices are between gko::OmpExecutor, gko::CudaExecutor and gko::ReferenceExecutor and more details can be found in Ginkgo's documentation.

Definition at line 318 of file ginkgo.hpp.

int mfem::GinkgoWrappers::GinkgoIterativeSolverBase::final_iter
mutableprotected

Definition at line 280 of file ginkgo.hpp.

double mfem::GinkgoWrappers::GinkgoIterativeSolverBase::final_norm
mutableprotected

Definition at line 279 of file ginkgo.hpp.

int mfem::GinkgoWrappers::GinkgoIterativeSolverBase::max_iter
protected

Definition at line 276 of file ginkgo.hpp.

int mfem::GinkgoWrappers::GinkgoIterativeSolverBase::print_lvl
protected

Definition at line 275 of file ginkgo.hpp.

double mfem::GinkgoWrappers::GinkgoIterativeSolverBase::rel_tol
protected

Definition at line 277 of file ginkgo.hpp.

std::shared_ptr<gko::stop::ResidualNormReduction<>::Factory> mfem::GinkgoWrappers::GinkgoIterativeSolverBase::residual_criterion
protected

The residual criterion object that controls the reduction of the residual based on the tolerance set in the solver_control member.

Definition at line 293 of file ginkgo.hpp.

std::shared_ptr<ResidualLogger<> > mfem::GinkgoWrappers::GinkgoIterativeSolverBase::residual_logger
protected

The residual logger object used to check for convergence and other solver data if needed.

Definition at line 305 of file ginkgo.hpp.

std::shared_ptr<gko::LinOpFactory> mfem::GinkgoWrappers::GinkgoIterativeSolverBase::solver_gen
protected

The Ginkgo generated solver factory object.

Definition at line 286 of file ginkgo.hpp.


The documentation for this class was generated from the following files: