diff --git a/plugins/ginkgo/include/alien/ginkgo/backend.h b/plugins/ginkgo/include/alien/ginkgo/backend.h index 8eb398b42..75d255186 100644 --- a/plugins/ginkgo/include/alien/ginkgo/backend.h +++ b/plugins/ginkgo/include/alien/ginkgo/backend.h @@ -31,11 +31,11 @@ class Vector; class Options; -extern IInternalLinearSolver* InternalLinearSolverFactory(const Options& options); +extern std::unique_ptr> InternalLinearSolverFactory(const Options& options); -extern IInternalLinearSolver* InternalLinearSolverFactory(); +extern std::unique_ptr> InternalLinearSolverFactory(); -extern IInternalLinearAlgebra* InternalLinearAlgebraFactory(); +extern std::unique_ptr> InternalLinearAlgebraFactory(); } // namespace Alien::Ginkgo namespace Alien::BackEnd::tag @@ -58,19 +58,19 @@ struct AlgebraTraits using solver_type = IInternalLinearSolver; // factory to build algebra - static auto algebra_factory() + static std::unique_ptr algebra_factory() { return Ginkgo::InternalLinearAlgebraFactory(); } // factories to build solver - static auto solver_factory(const options_type& options) + static std::unique_ptr solver_factory(const options_type& options) { return Ginkgo::InternalLinearSolverFactory(options); } // factories to build default solver - static auto solver_factory() { return Ginkgo::InternalLinearSolverFactory(); } + static std::unique_ptr solver_factory() { return Ginkgo::InternalLinearSolverFactory(); } static BackEndId name() { return "ginkgo"; } }; diff --git a/plugins/ginkgo/src/ginkgo_linear_algebra.cpp b/plugins/ginkgo/src/ginkgo_linear_algebra.cpp index 2713fd23c..87f156b61 100644 --- a/plugins/ginkgo/src/ginkgo_linear_algebra.cpp +++ b/plugins/ginkgo/src/ginkgo_linear_algebra.cpp @@ -155,9 +155,9 @@ void InternalLinearAlgebra::scal(Arccore::Real alpha, Vector& x) const } ALIEN_GINKGO_EXPORT -IInternalLinearAlgebra* +std::unique_ptr> InternalLinearAlgebraFactory() { - return new Ginkgo::InternalLinearAlgebra(); + return std::make_unique(); } } // namespace Alien::Ginkgo diff --git a/plugins/ginkgo/src/ginkgo_linear_solver.cpp b/plugins/ginkgo/src/ginkgo_linear_solver.cpp index 98b46a8da..ca54964f7 100644 --- a/plugins/ginkgo/src/ginkgo_linear_solver.cpp +++ b/plugins/ginkgo/src/ginkgo_linear_solver.cpp @@ -239,16 +239,16 @@ InternalLinearSolver::algebra() const } ALIEN_GINKGO_EXPORT -IInternalLinearSolver* +std::unique_ptr> InternalLinearSolverFactory(const Options& options) { - return new InternalLinearSolver(options); + return std::make_unique(options); } ALIEN_GINKGO_EXPORT -IInternalLinearSolver* +std::unique_ptr> InternalLinearSolverFactory() { - return new InternalLinearSolver(); + return std::make_unique(); } } // namespace Alien::Ginkgo diff --git a/plugins/hypre/include/alien/hypre/backend.h b/plugins/hypre/include/alien/hypre/backend.h index 1dffd41dd..56260fbb4 100644 --- a/plugins/hypre/include/alien/hypre/backend.h +++ b/plugins/hypre/include/alien/hypre/backend.h @@ -30,11 +30,11 @@ class Vector; class Options; -extern IInternalLinearSolver* InternalLinearSolverFactory(const Options& options); +extern std::unique_ptr> InternalLinearSolverFactory(const Options& options); -extern IInternalLinearSolver* InternalLinearSolverFactory(); +extern std::unique_ptr> InternalLinearSolverFactory(); -extern IInternalLinearAlgebra* InternalLinearAlgebraFactory(); +extern std::unique_ptr> InternalLinearAlgebraFactory(); } // namespace Alien::Hypre namespace Alien @@ -60,19 +60,19 @@ struct AlgebraTraits using solver_type = IInternalLinearSolver; // factory to build algebra - static auto* algebra_factory() + static std::unique_ptr algebra_factory() { return Hypre::InternalLinearAlgebraFactory(); } // factories to build solver - static auto* solver_factory(const options_type& options) + static std::unique_ptr solver_factory(const options_type& options) { return Hypre::InternalLinearSolverFactory(options); } // factories to build default solver - static auto* solver_factory() + static std::unique_ptr solver_factory() { return Hypre::InternalLinearSolverFactory(); } diff --git a/plugins/hypre/src/hypre_linear_algebra.cpp b/plugins/hypre/src/hypre_linear_algebra.cpp index 1f2a69e7d..b61078eed 100644 --- a/plugins/hypre/src/hypre_linear_algebra.cpp +++ b/plugins/hypre/src/hypre_linear_algebra.cpp @@ -164,9 +164,9 @@ void InternalLinearAlgebra::scal(Arccore::Real alpha, Vector& x) const } ALIEN_HYPRE_EXPORT -IInternalLinearAlgebra* +std::unique_ptr> InternalLinearAlgebraFactory() { - return new Hypre::InternalLinearAlgebra(); + return std::make_unique(); } } // namespace Alien::Hypre diff --git a/plugins/hypre/src/hypre_linear_solver.cpp b/plugins/hypre/src/hypre_linear_solver.cpp index 9839176b3..fce7311ba 100644 --- a/plugins/hypre/src/hypre_linear_solver.cpp +++ b/plugins/hypre/src/hypre_linear_solver.cpp @@ -331,16 +331,16 @@ InternalLinearSolver::algebra() const } ALIEN_HYPRE_EXPORT -IInternalLinearSolver* +std::unique_ptr> InternalLinearSolverFactory(const Options& options) { - return new InternalLinearSolver(options); + return std::make_unique(options); } ALIEN_HYPRE_EXPORT -IInternalLinearSolver* +std::unique_ptr> InternalLinearSolverFactory() { - return new InternalLinearSolver(); + return std::make_unique(); } } // namespace Alien::Hypre diff --git a/plugins/petsc/include/alien/petsc/backend.h b/plugins/petsc/include/alien/petsc/backend.h index 4cb4c6c11..0fd46edf1 100644 --- a/plugins/petsc/include/alien/petsc/backend.h +++ b/plugins/petsc/include/alien/petsc/backend.h @@ -31,12 +31,12 @@ class Vector; class Options; -extern IInternalLinearSolver* +extern std::unique_ptr> InternalLinearSolverFactory(const Options& options); -extern IInternalLinearSolver* InternalLinearSolverFactory(); +extern std::unique_ptr> InternalLinearSolverFactory(); -extern IInternalLinearAlgebra* InternalLinearAlgebraFactory(); +extern std::unique_ptr> InternalLinearAlgebraFactory(); } // namespace Alien::PETSc namespace Alien::BackEnd::tag @@ -59,19 +59,19 @@ struct AlgebraTraits using solver_type = IInternalLinearSolver; // factory to build algebra - static auto algebra_factory() + static std::unique_ptr algebra_factory() { return PETSc::InternalLinearAlgebraFactory(); } // factories to build solver - static auto solver_factory(const options_type& options) + static std::unique_ptr solver_factory(const options_type& options) { return PETSc::InternalLinearSolverFactory(options); } // factories to build default solver - static auto solver_factory() { return PETSc::InternalLinearSolverFactory(); } + static std::unique_ptr solver_factory() { return PETSc::InternalLinearSolverFactory(); } static BackEndId name() { return "petsc"; } }; diff --git a/plugins/petsc/src/petsc_linear_algebra.cpp b/plugins/petsc/src/petsc_linear_algebra.cpp index 3490b95bc..b79d20184 100644 --- a/plugins/petsc/src/petsc_linear_algebra.cpp +++ b/plugins/petsc/src/petsc_linear_algebra.cpp @@ -152,9 +152,9 @@ void InternalLinearAlgebra::scal(Arccore::Real alpha, Vector& x) const } ALIEN_PETSC_EXPORT -IInternalLinearAlgebra* +std::unique_ptr> InternalLinearAlgebraFactory() { - return new PETSc::InternalLinearAlgebra(); + return std::make_unique(); } } // namespace Alien::PETSc diff --git a/plugins/petsc/src/petsc_linear_solver.cpp b/plugins/petsc/src/petsc_linear_solver.cpp index 073f6312f..bc29e763b 100644 --- a/plugins/petsc/src/petsc_linear_solver.cpp +++ b/plugins/petsc/src/petsc_linear_solver.cpp @@ -217,16 +217,16 @@ InternalLinearSolver::algebra() const } ALIEN_PETSC_EXPORT -IInternalLinearSolver* +std::unique_ptr> InternalLinearSolverFactory(const Options& options) { - return new InternalLinearSolver(options); + return std::make_unique(options); } ALIEN_PETSC_EXPORT -IInternalLinearSolver* +std::unique_ptr> InternalLinearSolverFactory() { - return new InternalLinearSolver(); + return std::make_unique(); } } // namespace Alien::PETSc diff --git a/plugins/trilinos/include/alien/trilinos/backend.h b/plugins/trilinos/include/alien/trilinos/backend.h index 65626a00b..ec03f3846 100644 --- a/plugins/trilinos/include/alien/trilinos/backend.h +++ b/plugins/trilinos/include/alien/trilinos/backend.h @@ -30,11 +30,11 @@ class Vector; class Options; -extern IInternalLinearSolver* InternalLinearSolverFactory(const Options& options); +extern std::unique_ptr> InternalLinearSolverFactory(const Options& options); -extern IInternalLinearSolver* InternalLinearSolverFactory(); +extern std::unique_ptr> InternalLinearSolverFactory(); -extern IInternalLinearAlgebra* InternalLinearAlgebraFactory(); +extern std::unique_ptr> InternalLinearAlgebraFactory(); } // namespace Alien::Trilinos namespace Alien @@ -60,19 +60,19 @@ struct AlgebraTraits using solver_type = IInternalLinearSolver; // factory to build algebra - static auto* algebra_factory() + static std::unique_ptr algebra_factory() { return Trilinos::InternalLinearAlgebraFactory(); } // factories to build solver - static auto* solver_factory(const options_type& options) + static std::unique_ptr solver_factory(const options_type& options) { return Trilinos::InternalLinearSolverFactory(options); } // factories to build default solver - static auto* solver_factory() + static std::unique_ptr solver_factory() { return Trilinos::InternalLinearSolverFactory(); } diff --git a/plugins/trilinos/src/trilinos_linear_algebra.cpp b/plugins/trilinos/src/trilinos_linear_algebra.cpp index 90735a63a..b15bfbee0 100644 --- a/plugins/trilinos/src/trilinos_linear_algebra.cpp +++ b/plugins/trilinos/src/trilinos_linear_algebra.cpp @@ -145,9 +145,9 @@ void InternalLinearAlgebra::scal(Arccore::Real alpha, Vector& x) const } ALIEN_TRILINOS_EXPORT -IInternalLinearAlgebra* +std::unique_ptr> InternalLinearAlgebraFactory() { - return new Trilinos::InternalLinearAlgebra(); + return std::make_unique(); } } // namespace Alien::Trilinos diff --git a/plugins/trilinos/src/trilinos_linear_solver.cpp b/plugins/trilinos/src/trilinos_linear_solver.cpp index 825ca8f51..d2df3aa03 100644 --- a/plugins/trilinos/src/trilinos_linear_solver.cpp +++ b/plugins/trilinos/src/trilinos_linear_solver.cpp @@ -157,16 +157,16 @@ InternalLinearSolver::algebra() const } ALIEN_TRILINOS_EXPORT -IInternalLinearSolver* +std::unique_ptr> InternalLinearSolverFactory(const Options& options) { - return new InternalLinearSolver(options); + return std::make_unique(options); } ALIEN_TRILINOS_EXPORT -IInternalLinearSolver* +std::unique_ptr> InternalLinearSolverFactory() { - return new InternalLinearSolver(); + return std::make_unique(); } } // namespace Alien::Trilinos diff --git a/src/core/alien/kernels/dok/DoKBackEnd.h b/src/core/alien/kernels/dok/DoKBackEnd.h index dae8413cc..6a9619186 100644 --- a/src/core/alien/kernels/dok/DoKBackEnd.h +++ b/src/core/alien/kernels/dok/DoKBackEnd.h @@ -31,15 +31,6 @@ class DoKLinearSolver; class DoKMatrix; class DoKVector; class Space; -template -class IInternalLinearAlgebra; -template -class IInternalLinearSolver; - -extern IInternalLinearAlgebra* DoKLinearAlgebraFactory(); - -extern IInternalLinearSolver* DoKLinearSolverFactory( -IMessagePassingMng* p_mng); /*---------------------------------------------------------------------------*/ @@ -52,15 +43,8 @@ namespace BackEnd::tag template <> struct AlgebraTraits { - typedef DoKMatrix matrix_type; - typedef DoKVector vector_type; - typedef IInternalLinearAlgebra algebra_type; - typedef IInternalLinearSolver solver_type; - static algebra_type* algebra_factory() { return DoKLinearAlgebraFactory(); } - static solver_type* solver_factory(IMessagePassingMng* p_mng) - { - return DoKLinearSolverFactory(p_mng); - } + using matrix_type = DoKMatrix; + using vector_type = DoKVector; static BackEndId name() { return "DoK"; } }; diff --git a/src/core/alien/kernels/redistributor/RedistributorBackEnd.h b/src/core/alien/kernels/redistributor/RedistributorBackEnd.h index 6f3836ba6..6b1267b54 100644 --- a/src/core/alien/kernels/redistributor/RedistributorBackEnd.h +++ b/src/core/alien/kernels/redistributor/RedistributorBackEnd.h @@ -41,12 +41,6 @@ class IInternalLinearAlgebra; template class IInternalLinearSolver; -extern IInternalLinearAlgebra* -redistributorLinearAlgebraFactory(); - -extern IInternalLinearSolver* -redistributorLinearSolverFactory(IMessagePassingMng* p_mng); - /*---------------------------------------------------------------------------*/ namespace BackEnd @@ -61,15 +55,9 @@ namespace BackEnd template <> struct AlgebraTraits { - typedef RedistributorMatrix matrix_type; - typedef RedistributorVector vector_type; - typedef IInternalLinearAlgebra algebra_type; - typedef IInternalLinearSolver solver_type; - static algebra_type* algebra_factory() { return redistributorLinearAlgebraFactory(); } - static solver_type* solver_factory(IMessagePassingMng* p_mng) - { - return redistributorLinearSolverFactory(p_mng); - } + using matrix_type = RedistributorMatrix; + using vector_type = RedistributorVector; + static BackEndId name() { return "redistributor"; } }; diff --git a/src/core/alien/kernels/simple_csr/SimpleCSRBackEnd.h b/src/core/alien/kernels/simple_csr/SimpleCSRBackEnd.h index 67881b90b..979b42fdc 100644 --- a/src/core/alien/kernels/simple_csr/SimpleCSRBackEnd.h +++ b/src/core/alien/kernels/simple_csr/SimpleCSRBackEnd.h @@ -47,14 +47,14 @@ class SimpleCSRVector; template struct SimpleCSRTraits { - typedef SimpleCSRMatrix MatrixType; - typedef SimpleCSRVector VectorType; - typedef IInternalLinearAlgebra AlgebraType; - typedef IInternalLinearAlgebraExpr AlgebraExprType; + using MatrixType = SimpleCSRMatrix; + using VectorType = SimpleCSRVector; + using AlgebraType = IInternalLinearAlgebra; + using AlgebraExprType = IInternalLinearAlgebraExpr; }; -extern SimpleCSRTraits::AlgebraType* SimpleCSRInternalLinearAlgebraFactory(); -extern SimpleCSRTraits::AlgebraExprType* +extern std::unique_ptr::AlgebraType> SimpleCSRInternalLinearAlgebraFactory(); +extern std::unique_ptr::AlgebraExprType> SimpleCSRInternalLinearAlgebraExprFactory(); /*---------------------------------------------------------------------------*/ @@ -72,19 +72,19 @@ template <> struct AlgebraTraits { // clang-format off - typedef Real value_type; - typedef SimpleCSRTraits::MatrixType matrix_type; - typedef SimpleCSRTraits::VectorType vector_type; - typedef SimpleCSRTraits::AlgebraType algebra_type; - typedef SimpleCSRTraits::AlgebraExprType algebra_expr_type; + using value_type = Real; + using matrix_type = SimpleCSRTraits::MatrixType; + using vector_type = SimpleCSRTraits::VectorType; + using algebra_type = SimpleCSRTraits::AlgebraType; + using algebra_expr_type = SimpleCSRTraits::AlgebraExprType; // clang-format off - static algebra_type* algebra_factory( + static std::unique_ptr algebra_factory( IMessagePassingMng* p_mng ALIEN_UNUSED_PARAM = nullptr) { return SimpleCSRInternalLinearAlgebraFactory(); } - static algebra_expr_type* algebra_expr_factory( + static std::unique_ptr algebra_expr_factory( IMessagePassingMng* p_mng ALIEN_UNUSED_PARAM = nullptr) { return SimpleCSRInternalLinearAlgebraExprFactory(); diff --git a/src/core/alien/kernels/simple_csr/algebra/SimpleCSRInternalLinearAlgebra.cc b/src/core/alien/kernels/simple_csr/algebra/SimpleCSRInternalLinearAlgebra.cc index 1bddca1c2..dc0eb8da3 100644 --- a/src/core/alien/kernels/simple_csr/algebra/SimpleCSRInternalLinearAlgebra.cc +++ b/src/core/alien/kernels/simple_csr/algebra/SimpleCSRInternalLinearAlgebra.cc @@ -38,16 +38,16 @@ using namespace Arccore; template class ALIEN_EXPORT LinearAlgebra; template class ALIEN_EXPORT LinearAlgebraExpr; -ALIEN_EXPORT IInternalLinearAlgebra, SimpleCSRVector>* +ALIEN_EXPORT std::unique_ptr, SimpleCSRVector>> SimpleCSRInternalLinearAlgebraFactory() { - return new SimpleCSRInternalLinearAlgebra(); + return std::make_unique(); } -ALIEN_EXPORT IInternalLinearAlgebraExpr, SimpleCSRVector>* +ALIEN_EXPORT std::unique_ptr, SimpleCSRVector>> SimpleCSRInternalLinearAlgebraExprFactory() { - return new SimpleCSRInternalLinearAlgebraExpr(); + return std::make_unique(); } /*---------------------------------------------------------------------------*/ @@ -262,7 +262,7 @@ SimpleCSRInternalLinearAlgebraExpr::SimpleCSRInternalLinearAlgebraExpr() /*---------------------------------------------------------------------------*/ -SimpleCSRInternalLinearAlgebraExpr::~SimpleCSRInternalLinearAlgebraExpr() {} +SimpleCSRInternalLinearAlgebraExpr::~SimpleCSRInternalLinearAlgebraExpr() = default; /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ diff --git a/src/core/alien/kernels/sycl/SYCLBackEnd.h b/src/core/alien/kernels/sycl/SYCLBackEnd.h index 765e1656e..791d10334 100644 --- a/src/core/alien/kernels/sycl/SYCLBackEnd.h +++ b/src/core/alien/kernels/sycl/SYCLBackEnd.h @@ -57,8 +57,8 @@ struct SYCLBEllPackTraits // clang-format on }; -extern SYCLBEllPackTraits::AlgebraType* SYCLInternalLinearAlgebraFactory(); -extern SYCLBEllPackTraits::AlgebraExprType* +extern std::unique_ptr::AlgebraType> SYCLInternalLinearAlgebraFactory(); +extern std::unique_ptr::AlgebraExprType> SYCLInternalLinearAlgebraExprFactory(); /*---------------------------------------------------------------------------*/ @@ -82,12 +82,12 @@ struct AlgebraTraits typedef SYCLBEllPackTraits::AlgebraExprType algebra_expr_type; // clang-format on - static algebra_type* algebra_factory( + static std::unique_ptr algebra_factory( IMessagePassingMng* p_mng ALIEN_UNUSED_PARAM = nullptr) { return SYCLInternalLinearAlgebraFactory(); } - static algebra_expr_type* algebra_expr_factory( + static std::unique_ptr algebra_expr_factory( IMessagePassingMng* p_mng ALIEN_UNUSED_PARAM = nullptr) { return SYCLInternalLinearAlgebraExprFactory(); diff --git a/src/core/alien/kernels/sycl/algebra/SYCLInternalLinearAlgebra.cc b/src/core/alien/kernels/sycl/algebra/SYCLInternalLinearAlgebra.cc index a208ed3d3..5688ab111 100644 --- a/src/core/alien/kernels/sycl/algebra/SYCLInternalLinearAlgebra.cc +++ b/src/core/alien/kernels/sycl/algebra/SYCLInternalLinearAlgebra.cc @@ -57,16 +57,16 @@ using namespace Arccore; template class ALIEN_EXPORT LinearAlgebra; template class ALIEN_EXPORT LinearAlgebraExpr; -ALIEN_EXPORT IInternalLinearAlgebra, SYCLVector>* +ALIEN_EXPORT std::unique_ptr, SYCLVector>> SYCLInternalLinearAlgebraFactory() { - return new SYCLInternalLinearAlgebra(); + return std::make_unique(); } -ALIEN_EXPORT IInternalLinearAlgebraExpr, SYCLVector>* +ALIEN_EXPORT std::unique_ptr, SYCLVector>> SYCLInternalLinearAlgebraExprFactory() { - return new SYCLInternalLinearAlgebraExpr(); + return std::make_unique(); } /*---------------------------------------------------------------------------*/ diff --git a/src/core/alien/kernels/sycl/algebra/SYCLInternalLinearAlgebra.h b/src/core/alien/kernels/sycl/algebra/SYCLInternalLinearAlgebra.h index 7bf02be92..ab512d4bc 100644 --- a/src/core/alien/kernels/sycl/algebra/SYCLInternalLinearAlgebra.h +++ b/src/core/alien/kernels/sycl/algebra/SYCLInternalLinearAlgebra.h @@ -149,28 +149,28 @@ class SYCLInternalLinearAlgebraExpr public: // IInternalLinearAlgebra interface. - Real norm0(const Vector& x) const; - Real norm1(const Vector& x) const; - Real norm2(const Vector& x) const; - void mult(const Matrix& a, const Vector& x, Vector& r) const; - void axpy(Real alpha, const Vector& x, Vector& r) const; - void aypx(Real alpha, Vector& y, const Vector& x) const; - void copy(const Vector& x, Vector& r) const; - Real dot(const Vector& x, const Vector& y) const; - void scal(Real alpha, Vector& x) const; - void diagonal(const Matrix& a, Vector& x) const; - void reciprocal(Vector& x) const; - void pointwiseMult(const Vector& x, const Vector& y, Vector& w) const; + Real norm0(const Vector& x) const override; + Real norm1(const Vector& x) const override; + Real norm2(const Vector& x) const override; + void mult(const Matrix& a, const Vector& x, Vector& r) const override; + void axpy(Real alpha, const Vector& x, Vector& r) const override; + void aypx(Real alpha, Vector& y, const Vector& x) const override; + void copy(const Vector& x, Vector& r) const override; + Real dot(const Vector& x, const Vector& y) const override; + void scal(Real alpha, Vector& x) const override; + void diagonal(const Matrix& a, Vector& x) const override; + void reciprocal(Vector& x) const override; + void pointwiseMult(const Vector& x, const Vector& y, Vector& w) const override; // IInternalLinearAlgebra interface. - void mult(const Matrix& a, const UniqueArray& x, UniqueArray& r) const; - void axpy(Real alpha, UniqueArray const& x, UniqueArray& r) const; - void aypx(Real alpha, UniqueArray& y, UniqueArray const& x) const; - void copy(const UniqueArray& x, UniqueArray& r) const; - Real dot(Integer local_size, const UniqueArray& x, const UniqueArray& y) const; + void mult(const Matrix& a, const UniqueArray& x, UniqueArray& r) const override; + void axpy(Real alpha, UniqueArray const& x, UniqueArray& r) const override; + void aypx(Real alpha, UniqueArray& y, UniqueArray const& x) const override; + void copy(const UniqueArray& x, UniqueArray& r) const override; + Real dot(Integer local_size, const UniqueArray& x, const UniqueArray& y) const override; - void scal(Real alpha, UniqueArray& x) const; + void scal(Real alpha, UniqueArray& x) const override; private: std::unique_ptr m_internal;