8#include <ginkgo/ginkgo.hpp>
9#include <ginkgo/extensions/kokkos.hpp>
18namespace NeoN::la::ginkgo
21gko::config::pnode parse(
const Dictionary& dict);
23class GinkgoSolver :
public SolverFactory::template
Register<GinkgoSolver>
30 GinkgoSolver(Executor exec,
const Dictionary& solverConfig)
31 : Base(exec), gkoExec_(getGkoExecutor(exec)), config_(parse(solverConfig)),
32 factory_(gko::config::parse(
33 config_, gko::config::registry(), gko::config::make_type_descriptor<
scalar>()
38 static std::string
name() {
return "Ginkgo"; }
40 static std::string doc() {
return "TBD"; }
42 static std::string schema() {
return "none"; }
44 virtual void solve(
const LinearSystem<scalar, localIdx>& sys, Vector<scalar>& x)
const final
46 auto nrows = sys.rhs().size();
48 auto gkoMtx = detail::createGkoMtx(gkoExec_, sys);
49 auto solver = factory_->generate(gkoMtx);
54 auto rhs = detail::createGkoDense(gkoExec_, sys.rhs().data(), nrows);
55 auto gkoX = detail::createGkoDense(gkoExec_, x.data(), nrows);
57 solver->apply(rhs, gkoX);
65 virtual std::unique_ptr<SolverFactory> clone() const final
73 std::shared_ptr<const gko::Executor> gkoExec_;
74 gko::config::pnode config_;
75 std::shared_ptr<const gko::LinOpFactory> factory_;
A template class for registering derived classes with a base class.
void solve(Expression< typename VectorType::ElementType > &exp, VectorType &solution, scalar t, scalar dt, const Dictionary &fvSchemes, const Dictionary &fvSolution)
const std::string & name(const NeoN::Document &doc)
Retrieves the name of a Document.