diff --git a/benchmark/solver/solver_common.hpp b/benchmark/solver/solver_common.hpp index ae9ae6dc1fb..89d040ae946 100644 --- a/benchmark/solver/solver_common.hpp +++ b/benchmark/solver/solver_common.hpp @@ -259,21 +259,18 @@ std::unique_ptr generate_solver( return gko::experimental::solver::Direct::build() .with_factorization( gko::experimental::factorization::Cholesky::build() - .on(exec)) + itype>::build()) .on(exec); } else if (description == "symm_direct") { return gko::experimental::solver::Direct::build() .with_factorization( gko::experimental::factorization::Lu::build() - .with_symmetric_sparsity(true) - .on(exec)) + .with_symmetric_sparsity(true)) .on(exec); } else if (description == "direct") { return gko::experimental::solver::Direct::build() .with_factorization( - gko::experimental::factorization::Lu::build().on( - exec)) + gko::experimental::factorization::Lu::build()) .on(exec); } else if (description == "overhead") { return add_criteria_precond_finalize>( diff --git a/benchmark/utils/overhead_linop.hpp b/benchmark/utils/overhead_linop.hpp index 168e650234d..d947b8de38e 100644 --- a/benchmark/utils/overhead_linop.hpp +++ b/benchmark/utils/overhead_linop.hpp @@ -104,27 +104,12 @@ class Overhead : public EnableLinOp>, friend class EnablePolymorphicObject; public: - GKO_CREATE_FACTORY_PARAMETERS(parameters, Factory) - { - /** - * Criterion factories. - */ - std::vector> - GKO_FACTORY_PARAMETER_VECTOR(criteria, nullptr); - - /** - * Preconditioner factory. - */ - std::shared_ptr GKO_FACTORY_PARAMETER_SCALAR( - preconditioner, nullptr); - - /** - * Already generated preconditioner. If one is provided, the factory - * `preconditioner` will be ignored. - */ - std::shared_ptr GKO_FACTORY_PARAMETER_SCALAR( - generated_preconditioner, nullptr); - }; + class Factory; + + struct parameters_type + : public gko::solver:: + enable_preconditioned_iterative_solver_factory_parameters< + parameters_type, Factory> {}; GKO_ENABLE_LIN_OP_FACTORY(Overhead, parameters, Factory); GKO_ENABLE_BUILD_METHOD(Factory); diff --git a/benchmark/utils/preconditioners.hpp b/benchmark/utils/preconditioners.hpp index 466d5f2d3f9..3450eb71b44 100644 --- a/benchmark/utils/preconditioners.hpp +++ b/benchmark/utils/preconditioners.hpp @@ -122,7 +122,7 @@ const std::map( .on(exec)); return gko::preconditioner::Ic, itype>::build() - .with_factorization_factory(fact) + .with_factorization(fact) .on(exec); }}, {"parict", @@ -137,7 +137,7 @@ const std::map( return gko::preconditioner:: Ilu, gko::solver::UpperTrs, false, itype>::build() - .with_factorization_factory(fact) + .with_factorization(fact) .on(exec); }}, {"parilu", @@ -150,7 +150,7 @@ const std::map( return gko::preconditioner:: Ilu, gko::solver::UpperTrs, false, itype>::build() - .with_factorization_factory(fact) + .with_factorization(fact) .on(exec); }}, {"parilut", @@ -165,7 +165,7 @@ const std::map( return gko::preconditioner:: Ilu, gko::solver::UpperTrs, false, itype>::build() - .with_factorization_factory(fact) + .with_factorization(fact) .on(exec); }}, {"ic", @@ -174,7 +174,7 @@ const std::map( gko::factorization::Ic::build().on(exec)); return gko::preconditioner::Ic, itype>::build() - .with_factorization_factory(fact) + .with_factorization(fact) .on(exec); }}, {"ilu", @@ -184,7 +184,7 @@ const std::map( return gko::preconditioner:: Ilu, gko::solver::UpperTrs, false, itype>::build() - .with_factorization_factory(fact) + .with_factorization(fact) .on(exec); }}, {"paric-isai", @@ -201,8 +201,8 @@ const std::map( return gko::preconditioner::Ic< gko::preconditioner::LowerIsai, itype>::build() - .with_factorization_factory(fact) - .with_l_solver_factory(lisai) + .with_factorization(fact) + .with_l_solver(lisai) .on(exec); }}, {"parict-isai", @@ -221,8 +221,8 @@ const std::map( return gko::preconditioner::Ic< gko::preconditioner::LowerIsai, itype>::build() - .with_factorization_factory(fact) - .with_l_solver_factory(lisai) + .with_factorization(fact) + .with_l_solver(lisai) .on(exec); }}, {"parilu-isai", @@ -244,9 +244,9 @@ const std::map( gko::preconditioner::LowerIsai, gko::preconditioner::UpperIsai, false, itype>::build() - .with_factorization_factory(fact) - .with_l_solver_factory(lisai) - .with_u_solver_factory(uisai) + .with_factorization(fact) + .with_l_solver(lisai) + .with_u_solver(uisai) .on(exec); }}, {"parilut-isai", @@ -270,9 +270,9 @@ const std::map( gko::preconditioner::LowerIsai, gko::preconditioner::UpperIsai, false, itype>::build() - .with_factorization_factory(fact) - .with_l_solver_factory(lisai) - .with_u_solver_factory(uisai) + .with_factorization(fact) + .with_l_solver(lisai) + .with_u_solver(uisai) .on(exec); }}, {"ic-isai", @@ -286,8 +286,8 @@ const std::map( return gko::preconditioner::Ic< gko::preconditioner::LowerIsai, itype>::build() - .with_factorization_factory(fact) - .with_l_solver_factory(lisai) + .with_factorization(fact) + .with_l_solver(lisai) .on(exec); }}, {"ilu-isai", @@ -306,9 +306,9 @@ const std::map( gko::preconditioner::LowerIsai, gko::preconditioner::UpperIsai, false, itype>::build() - .with_factorization_factory(fact) - .with_l_solver_factory(lisai) - .with_u_solver_factory(uisai) + .with_factorization(fact) + .with_l_solver(lisai) + .with_u_solver(uisai) .on(exec); }}, {"general-isai", @@ -326,8 +326,7 @@ const std::map( {"overhead", [](std::shared_ptr exec) { return gko::Overhead::build() .with_criteria(gko::stop::ResidualNorm::build() - .with_reduction_factor(rc_etype{}) - .on(exec)) + .with_reduction_factor(rc_etype{})) .on(exec); }}}; diff --git a/core/distributed/preconditioner/schwarz.cpp b/core/distributed/preconditioner/schwarz.cpp index 31c57947704..0d1267bc0b4 100644 --- a/core/distributed/preconditioner/schwarz.cpp +++ b/core/distributed/preconditioner/schwarz.cpp @@ -102,8 +102,8 @@ template void Schwarz::generate( std::shared_ptr system_matrix) { - if (parameters_.local_solver_factory) { - this->local_solver_ = parameters_.local_solver_factory->generate( + if (parameters_.local_solver) { + this->local_solver_ = parameters_.local_solver->generate( as>( system_matrix) diff --git a/core/preconditioner/isai.cpp b/core/preconditioner/isai.cpp index 52fa9140853..4e0e2ea95d8 100644 --- a/core/preconditioner/isai.cpp +++ b/core/preconditioner/isai.cpp @@ -230,17 +230,15 @@ void Isai::generate_inverse( excess_solver_factory = Gmres::build() .with_preconditioner( - Bj::build().with_max_block_size(32u).on(exec)) + Bj::build().with_max_block_size(32u)) .with_criteria( - gko::stop::Iteration::build() - .with_max_iters(excess_dim) - .on(exec), + gko::stop::Iteration::build().with_max_iters( + excess_dim), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::rhs_norm) .with_reduction_factor( remove_complex{ - excess_solver_reduction}) - .on(exec)) + excess_solver_reduction})) .on(exec); excess_solution->copy_from(excess_rhs); } else if (is_lower) { diff --git a/core/solver/multigrid.cpp b/core/solver/multigrid.cpp index 7a521f5f53e..8f4dd878a5d 100644 --- a/core/solver/multigrid.cpp +++ b/core/solver/multigrid.cpp @@ -569,21 +569,18 @@ void Multigrid::generate() using absolute_value_type = remove_complex; return solver::Gmres::build() .with_criteria( - stop::Iteration::build() - .with_max_iters(matrix->get_size()[0]) - .on(exec), + stop::Iteration::build().with_max_iters( + matrix->get_size()[0]), stop::ResidualNorm::build() .with_reduction_factor( std::numeric_limits< absolute_value_type>::epsilon() * - absolute_value_type{10}) - .on(exec)) + absolute_value_type{10})) .with_krylov_dim( std::min(size_type(100), matrix->get_size()[0])) .with_preconditioner( preconditioner::Jacobi::build() - .with_max_block_size(1u) - .on(exec)) + .with_max_block_size(1u)) .on(exec) ->generate(matrix); } else { @@ -591,8 +588,7 @@ void Multigrid::generate() int32>::build() .with_factorization( experimental::factorization::Lu::build() - .on(exec)) + int32>::build()) .on(exec) ->generate(matrix); } diff --git a/core/test/log/convergence.cpp b/core/test/log/convergence.cpp index f6294d08cd4..746e8603865 100644 --- a/core/test/log/convergence.cpp +++ b/core/test/log/convergence.cpp @@ -68,8 +68,7 @@ class Convergence : public ::testing::Test { gko::initialize({6}, exec); std::unique_ptr system = gko::solver::Ir::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec) ->generate(gko::initialize(I>{{1, 2}, {0, 3}}, exec)); std::unique_ptr rhs = gko::initialize({15, 25}, exec); diff --git a/core/test/log/profiler_hook.cpp b/core/test/log/profiler_hook.cpp index 281eed2d70b..cd6e1b0a3ce 100644 --- a/core/test/log/profiler_hook.cpp +++ b/core/test/log/profiler_hook.cpp @@ -202,8 +202,7 @@ TEST(ProfilerHook, LogsIteration) auto alpha = gko::share(gko::initialize({1.0}, exec)); auto solver = gko::solver::Ir<>::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec) ->generate(mtx); logger->set_object_name(solver, "solver"); diff --git a/core/test/log/record.cpp b/core/test/log/record.cpp index 0aeca2b3df7..098f93ad523 100644 --- a/core/test/log/record.cpp +++ b/core/test/log/record.cpp @@ -440,8 +440,7 @@ TEST(Record, CatchesLinopFactoryGenerateStarted) gko::log::Logger::linop_factory_generate_started_mask); auto factory = gko::solver::Bicgstab<>::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(3u)) .on(exec); auto input = factory->generate(gko::matrix::Dense<>::create(exec)); @@ -462,8 +461,7 @@ TEST(Record, CatchesLinopFactoryGenerateCompleted) gko::log::Logger::linop_factory_generate_completed_mask); auto factory = gko::solver::Bicgstab<>::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(3u)) .on(exec); auto input = factory->generate(gko::matrix::Dense<>::create(exec)); auto output = factory->generate(gko::matrix::Dense<>::create(exec)); @@ -569,8 +567,7 @@ TEST(Record, CatchesIterations) gko::log::Record::create(gko::log::Logger::iteration_complete_mask); auto factory = gko::solver::Bicgstab<>::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(3u)) .on(exec); auto solver = factory->generate(gko::initialize({1.1}, exec)); auto right_hand_side = gko::initialize({-5.5}, exec); diff --git a/core/test/log/stream.cpp b/core/test/log/stream.cpp index 3558a7d5564..721273ca468 100644 --- a/core/test/log/stream.cpp +++ b/core/test/log/stream.cpp @@ -606,8 +606,7 @@ TYPED_TEST(Stream, CatchesLinopFactoryGenerateStarted) gko::log::Logger::linop_factory_generate_started_mask, out); auto factory = gko::solver::Bicgstab::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(3u)) .on(exec); auto input = factory->generate(gko::matrix::Dense::create(exec)); std::stringstream ptrstream_factory; @@ -633,8 +632,7 @@ TYPED_TEST(Stream, CatchesLinopFactoryGenerateCompleted) gko::log::Logger::linop_factory_generate_completed_mask, out); auto factory = gko::solver::Bicgstab::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(3u)) .on(exec); auto input = factory->generate(gko::matrix::Dense::create(exec)); auto output = @@ -815,8 +813,7 @@ TYPED_TEST(Stream, CatchesIterationsWithVerbose) auto factory = gko::solver::Bicgstab::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(3u)) .on(exec); auto solver = factory->generate(gko::initialize({1.1}, exec)); auto right_hand_side = gko::initialize({-5.5}, exec); diff --git a/core/test/mpi/distributed/preconditioner/schwarz.cpp b/core/test/mpi/distributed/preconditioner/schwarz.cpp index ff1cd0d45e5..e0b5749e987 100644 --- a/core/test/mpi/distributed/preconditioner/schwarz.cpp +++ b/core/test/mpi/distributed/preconditioner/schwarz.cpp @@ -67,7 +67,7 @@ class SchwarzFactory : public ::testing::Test { mtx(Mtx::create(exec, MPI_COMM_WORLD)) { schwarz = Schwarz::build() - .with_local_solver_factory(jacobi_factory) + .with_local_solver(jacobi_factory) .on(exec) ->generate(mtx); } @@ -83,8 +83,8 @@ class SchwarzFactory : public ::testing::Test { gko::ptr_param b) { ASSERT_EQ(a->get_size(), b->get_size()); - ASSERT_EQ(a->get_parameters().local_solver_factory, - b->get_parameters().local_solver_factory); + ASSERT_EQ(a->get_parameters().local_solver, + b->get_parameters().local_solver); } std::shared_ptr exec; @@ -105,7 +105,7 @@ TYPED_TEST(SchwarzFactory, KnowsItsExecutor) TYPED_TEST(SchwarzFactory, CanSetLocalFactory) { - ASSERT_EQ(this->schwarz->get_parameters().local_solver_factory, + ASSERT_EQ(this->schwarz->get_parameters().local_solver, this->jacobi_factory); } @@ -125,7 +125,7 @@ TYPED_TEST(SchwarzFactory, CanBeCopied) using Mtx = typename TestFixture::Mtx; auto bj = gko::share(Jacobi::build().on(this->exec)); auto copy = Schwarz::build() - .with_local_solver_factory(bj) + .with_local_solver(bj) .on(this->exec) ->generate(Mtx::create(this->exec, MPI_COMM_WORLD)); @@ -143,7 +143,7 @@ TYPED_TEST(SchwarzFactory, CanBeMoved) auto tmp = clone(this->schwarz); auto bj = gko::share(Jacobi::build().on(this->exec)); auto copy = Schwarz::build() - .with_local_solver_factory(bj) + .with_local_solver(bj) .on(this->exec) ->generate(Mtx::create(this->exec, MPI_COMM_WORLD)); @@ -158,7 +158,7 @@ TYPED_TEST(SchwarzFactory, CanBeCleared) this->schwarz->clear(); ASSERT_EQ(this->schwarz->get_size(), gko::dim<2>(0, 0)); - ASSERT_EQ(this->schwarz->get_parameters().local_solver_factory, nullptr); + ASSERT_EQ(this->schwarz->get_parameters().local_solver, nullptr); } diff --git a/core/test/preconditioner/ic.cpp b/core/test/preconditioner/ic.cpp index efd54ee9ebc..9e1e3f3e3c4 100644 --- a/core/test/preconditioner/ic.cpp +++ b/core/test/preconditioner/ic.cpp @@ -77,9 +77,8 @@ TEST_F(IcFactory, KnowsItsExecutor) TEST_F(IcFactory, CanSetLSolverFactory) { - auto ic_factory = ic_prec_type::build() - .with_l_solver_factory(this->l_factory) - .on(this->exec); + auto ic_factory = + ic_prec_type::build().with_l_solver(this->l_factory).on(this->exec); ASSERT_EQ(ic_factory->get_parameters().l_solver_factory, this->l_factory); } @@ -88,7 +87,7 @@ TEST_F(IcFactory, CanSetLSolverFactory) TEST_F(IcFactory, CanSetFactorizationFactory) { auto ic_factory = ic_prec_type::build() - .with_factorization_factory(this->fact_factory) + .with_factorization(this->fact_factory) .on(this->exec); ASSERT_EQ(ic_factory->get_parameters().factorization_factory, diff --git a/core/test/preconditioner/ilu.cpp b/core/test/preconditioner/ilu.cpp index c7b72e09b09..f25a20b47e3 100644 --- a/core/test/preconditioner/ilu.cpp +++ b/core/test/preconditioner/ilu.cpp @@ -81,9 +81,8 @@ TEST_F(IluFactory, KnowsItsExecutor) TEST_F(IluFactory, CanSetLSolverFactory) { - auto ilu_factory = ilu_prec_type::build() - .with_l_solver_factory(this->l_factory) - .on(this->exec); + auto ilu_factory = + ilu_prec_type::build().with_l_solver(this->l_factory).on(this->exec); ASSERT_EQ(ilu_factory->get_parameters().l_solver_factory, this->l_factory); } @@ -91,9 +90,8 @@ TEST_F(IluFactory, CanSetLSolverFactory) TEST_F(IluFactory, CanSetUSolverFactory) { - auto ilu_factory = ilu_prec_type::build() - .with_u_solver_factory(this->u_factory) - .on(this->exec); + auto ilu_factory = + ilu_prec_type::build().with_u_solver(this->u_factory).on(this->exec); ASSERT_EQ(ilu_factory->get_parameters().u_solver_factory, this->u_factory); } @@ -102,7 +100,7 @@ TEST_F(IluFactory, CanSetUSolverFactory) TEST_F(IluFactory, CanSetFactorizationFactory) { auto ilu_factory = ilu_prec_type::build() - .with_factorization_factory(this->fact_factory) + .with_factorization(this->fact_factory) .on(this->exec); ASSERT_EQ(ilu_factory->get_parameters().factorization_factory, diff --git a/core/test/solver/bicg.cpp b/core/test/solver/bicg.cpp index 4c7421f63e1..37ed110bdf4 100644 --- a/core/test/solver/bicg.cpp +++ b/core/test/solver/bicg.cpp @@ -66,10 +66,9 @@ class Bicg : public ::testing::Test { bicg_factory( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), + gko::stop::Iteration::build().with_max_iters(3u), gko::stop::ResidualNorm::build() - .with_reduction_factor(gko::remove_complex{1e-6}) - .on(exec)) + .with_reduction_factor(gko::remove_complex{1e-6})) .on(exec)), solver(bicg_factory->generate(mtx)) {} diff --git a/core/test/solver/bicgstab.cpp b/core/test/solver/bicgstab.cpp index c42cd7db2af..937064da7c4 100644 --- a/core/test/solver/bicgstab.cpp +++ b/core/test/solver/bicgstab.cpp @@ -64,10 +64,9 @@ class Bicgstab : public ::testing::Test { bicgstab_factory( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), + gko::stop::Iteration::build().with_max_iters(3u), gko::stop::ResidualNorm::build() - .with_reduction_factor(gko::remove_complex{1e-6}) - .on(exec)) + .with_reduction_factor(gko::remove_complex{1e-6})) .on(exec)), solver(bicgstab_factory->generate(mtx)) {} diff --git a/core/test/solver/cb_gmres.cpp b/core/test/solver/cb_gmres.cpp index b81d84f8b1e..17dcf0c385f 100644 --- a/core/test/solver/cb_gmres.cpp +++ b/core/test/solver/cb_gmres.cpp @@ -72,23 +72,20 @@ class CbGmres : public ::testing::Test { Solver::build() .with_storage_precision(storage_precision) .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), + gko::stop::Iteration::build().with_max_iters(3u), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::initial_resnorm) - .with_reduction_factor(nc_value_type{1e-6}) - .on(exec)) + .with_reduction_factor(nc_value_type{1e-6})) .on(exec)), solver(cb_gmres_factory->generate(mtx)), cb_gmres_big_factory( Solver::build() .with_storage_precision(storage_precision) .with_criteria( - gko::stop::Iteration::build().with_max_iters(128u).on( - exec), + gko::stop::Iteration::build().with_max_iters(128u), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::initial_resnorm) - .with_reduction_factor(nc_value_type{1e-6}) - .on(exec)) + .with_reduction_factor(nc_value_type{1e-6})) .on(exec)), big_solver(cb_gmres_big_factory->generate(mtx)) {} diff --git a/core/test/solver/cg.cpp b/core/test/solver/cg.cpp index 5daf43bc160..d0381a6e5ab 100644 --- a/core/test/solver/cg.cpp +++ b/core/test/solver/cg.cpp @@ -66,10 +66,9 @@ class Cg : public ::testing::Test { cg_factory( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), + gko::stop::Iteration::build().with_max_iters(3u), gko::stop::ResidualNorm::build() - .with_reduction_factor(gko::remove_complex{1e-6}) - .on(exec)) + .with_reduction_factor(gko::remove_complex{1e-6})) .on(exec)), solver(cg_factory->generate(mtx)) {} diff --git a/core/test/solver/cgs.cpp b/core/test/solver/cgs.cpp index c23dc7b2e3b..7509c22d76e 100644 --- a/core/test/solver/cgs.cpp +++ b/core/test/solver/cgs.cpp @@ -66,10 +66,9 @@ class Cgs : public ::testing::Test { cgs_factory( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), + gko::stop::Iteration::build().with_max_iters(3u), gko::stop::ResidualNorm::build() - .with_reduction_factor(gko::remove_complex{1e-6}) - .on(exec)) + .with_reduction_factor(gko::remove_complex{1e-6})) .on(exec)), solver(cgs_factory->generate(mtx)) {} diff --git a/core/test/solver/fcg.cpp b/core/test/solver/fcg.cpp index 59bb5e0cdee..21cc686bd01 100644 --- a/core/test/solver/fcg.cpp +++ b/core/test/solver/fcg.cpp @@ -63,10 +63,9 @@ class Fcg : public ::testing::Test { fcg_factory( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), + gko::stop::Iteration::build().with_max_iters(3u), gko::stop::ResidualNorm::build() - .with_reduction_factor(gko::remove_complex{1e-6}) - .on(exec)) + .with_reduction_factor(gko::remove_complex{1e-6})) .on(exec)), solver(fcg_factory->generate(mtx)) {} diff --git a/core/test/solver/gcr.cpp b/core/test/solver/gcr.cpp index f7ba80ebba1..fec313582ed 100644 --- a/core/test/solver/gcr.cpp +++ b/core/test/solver/gcr.cpp @@ -67,23 +67,19 @@ class Gcr : public ::testing::Test { : exec(gko::ReferenceExecutor::create()), mtx(gko::initialize( {{1.0, 2.0, 3.0}, {3.0, 2.0, -1.0}, {0.0, -1.0, 2}}, exec)), - gcr_factory( - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) - .on(exec)), + gcr_factory(Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(3u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(reduction_factor)) + .on(exec)), solver(gcr_factory->generate(mtx)), gcr_big_factory( Big_solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(128u).on( - exec), + gko::stop::Iteration::build().with_max_iters(128u), gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_reduction_factor(reduction_factor)) .on(exec)), big_solver(gcr_big_factory->generate(mtx)) {} diff --git a/core/test/solver/gmres.cpp b/core/test/solver/gmres.cpp index 11cafe2c86f..8ce8135f8b2 100644 --- a/core/test/solver/gmres.cpp +++ b/core/test/solver/gmres.cpp @@ -70,20 +70,17 @@ class Gmres : public ::testing::Test { gmres_factory( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), + gko::stop::Iteration::build().with_max_iters(3u), gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_reduction_factor(reduction_factor)) .on(exec)), solver(gmres_factory->generate(mtx)), gmres_big_factory( Big_solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(128u).on( - exec), + gko::stop::Iteration::build().with_max_iters(128u), gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_reduction_factor(reduction_factor)) .on(exec)), big_solver(gmres_big_factory->generate(mtx)) {} diff --git a/core/test/solver/idr.cpp b/core/test/solver/idr.cpp index f9109acb69e..3c569e733c2 100644 --- a/core/test/solver/idr.cpp +++ b/core/test/solver/idr.cpp @@ -64,10 +64,9 @@ class Idr : public ::testing::Test { idr_factory( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), + gko::stop::Iteration::build().with_max_iters(3u), gko::stop::ResidualNorm::build() - .with_reduction_factor(gko::remove_complex{1e-6}) - .on(exec)) + .with_reduction_factor(gko::remove_complex{1e-6})) .on(exec)), solver(idr_factory->generate(mtx)) {} diff --git a/core/test/solver/ir.cpp b/core/test/solver/ir.cpp index 5fdcd55af14..7419f99bfd0 100644 --- a/core/test/solver/ir.cpp +++ b/core/test/solver/ir.cpp @@ -64,14 +64,12 @@ class Ir : public ::testing::Test { : exec(gko::ReferenceExecutor::create()), mtx(gko::initialize( {{2, -1.0, 0.0}, {-1.0, 2, -1.0}, {0.0, -1.0, 2}}, exec)), - ir_factory( - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .on(exec)), + ir_factory(Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(3u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .on(exec)), solver(ir_factory->generate(mtx)) {} diff --git a/core/test/solver/multigrid.cpp b/core/test/solver/multigrid.cpp index 856f9651ebe..8fea85a40bb 100644 --- a/core/test/solver/multigrid.cpp +++ b/core/test/solver/multigrid.cpp @@ -153,11 +153,10 @@ class Multigrid : public ::testing::Test { multigrid_factory = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(3u).on(exec), + gko::stop::Iteration::build().with_max_iters(3u), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::initial_resnorm) - .with_reduction_factor(gko::remove_complex{1e-6}) - .on(exec)) + .with_reduction_factor(gko::remove_complex{1e-6})) .with_max_levels(2u) .with_coarsest_solver(lo_factory) .with_pre_smoother(lo_factory) @@ -427,28 +426,25 @@ TYPED_TEST(Multigrid, ThrowWhenNullMgLevel) TYPED_TEST(Multigrid, ThrowWhenMgLevelContainsNullptr) { using Solver = typename TestFixture::Solver; - auto factory = Solver::build() - .with_max_levels(1u) - .with_min_coarse_rows(2u) - .with_criteria(this->criterion) - .with_mg_level(this->rp_factory, nullptr) - .on(this->exec); + auto factory_parameters = Solver::build() + .with_max_levels(1u) + .with_min_coarse_rows(2u) + .with_criteria(this->criterion) + .with_mg_level(this->rp_factory, nullptr); - ASSERT_THROW(factory->generate(this->mtx), gko::NotSupported); + ASSERT_THROW(factory_parameters.on(this->exec), gko::NotSupported); } TYPED_TEST(Multigrid, ThrowWhenEmptyMgLevelList) { using Solver = typename TestFixture::Solver; - auto factory = - Solver::build() - .with_max_levels(1u) - .with_min_coarse_rows(2u) - .with_mg_level( - std::vector>{}) - .with_criteria(this->criterion) - .on(this->exec); + auto factory = Solver::build() + .with_max_levels(1u) + .with_min_coarse_rows(2u) + .with_mg_level() + .with_criteria(this->criterion) + .on(this->exec); ASSERT_THROW(factory->generate(this->mtx), gko::NotSupported); } diff --git a/examples/adaptiveprecision-blockjacobi/adaptiveprecision-blockjacobi.cpp b/examples/adaptiveprecision-blockjacobi/adaptiveprecision-blockjacobi.cpp index b300292e9a3..c20503be941 100644 --- a/examples/adaptiveprecision-blockjacobi/adaptiveprecision-blockjacobi.cpp +++ b/examples/adaptiveprecision-blockjacobi/adaptiveprecision-blockjacobi.cpp @@ -111,18 +111,14 @@ int main(int argc, char* argv[]) const RealValueType reduction_factor = 1e-7; auto solver_gen = cg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(10000u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(10000u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(reduction_factor)) // Add preconditioner, these 2 lines are the only // difference from the simple solver example - .with_preconditioner(bj::build() - .with_max_block_size(16u) - .with_storage_optimization( - gko::precision_reduction::autodetect()) - .on(exec)) + .with_preconditioner( + bj::build().with_max_block_size(16u).with_storage_optimization( + gko::precision_reduction::autodetect())) .on(exec); // Create solver std::shared_ptr> logger = diff --git a/examples/cb-gmres/cb-gmres.cpp b/examples/cb-gmres/cb-gmres.cpp index c0235f75e55..fc8cdf50196 100644 --- a/examples/cb-gmres/cb-gmres.cpp +++ b/examples/cb-gmres/cb-gmres.cpp @@ -155,12 +155,10 @@ int main(int argc, char* argv[]) // storage type auto solver_gen_keep = cb_gmres::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1000u).on(exec), - gko::stop::ResidualNorm::build() - .with_baseline(gko::stop::mode::rhs_norm) - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1000u), + gko::stop::ResidualNorm::build() + .with_baseline(gko::stop::mode::rhs_norm) + .with_reduction_factor(reduction_factor)) .with_krylov_dim(100u) .with_storage_precision( gko::solver::cb_gmres::storage_precision::keep) @@ -168,12 +166,10 @@ int main(int argc, char* argv[]) auto solver_gen_reduce = cb_gmres::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1000u).on(exec), - gko::stop::ResidualNorm::build() - .with_baseline(gko::stop::mode::rhs_norm) - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1000u), + gko::stop::ResidualNorm::build() + .with_baseline(gko::stop::mode::rhs_norm) + .with_reduction_factor(reduction_factor)) .with_krylov_dim(100u) .with_storage_precision( gko::solver::cb_gmres::storage_precision::reduce1) diff --git a/examples/custom-logger/custom-logger.cpp b/examples/custom-logger/custom-logger.cpp index c2270cadb0d..fcfcdc52dc2 100644 --- a/examples/custom-logger/custom-logger.cpp +++ b/examples/custom-logger/custom-logger.cpp @@ -291,11 +291,9 @@ int main(int argc, char* argv[]) // object needs to be built on. auto solver_gen = cg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(20u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(20u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(reduction_factor)) .on(exec); // Instantiate a ResidualLogger logger. diff --git a/examples/custom-matrix-format/custom-matrix-format.cpp b/examples/custom-matrix-format/custom-matrix-format.cpp index af08dbdf226..b04248b3d05 100644 --- a/examples/custom-matrix-format/custom-matrix-format.cpp +++ b/examples/custom-matrix-format/custom-matrix-format.cpp @@ -292,12 +292,10 @@ int main(int argc, char* argv[]) const RealValueType reduction_factor{1e-7}; // Generate solver and solve the system cg::build() - .with_criteria(gko::stop::Iteration::build() - .with_max_iters(discretization_points) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_criteria( + gko::stop::Iteration::build().with_max_iters(discretization_points), + gko::stop::ResidualNorm::build().with_reduction_factor( + reduction_factor)) .on(exec) // notice how our custom StencilMatrix can be used in the same way as // any built-in type diff --git a/examples/custom-stopping-criterion/custom-stopping-criterion.cpp b/examples/custom-stopping-criterion/custom-stopping-criterion.cpp index 9389f86cc45..e5aa0a62381 100644 --- a/examples/custom-stopping-criterion/custom-stopping-criterion.cpp +++ b/examples/custom-stopping-criterion/custom-stopping-criterion.cpp @@ -109,13 +109,12 @@ void run_solver(volatile bool* stop_iteration_process, auto x = gko::read(std::ifstream("data/x0.mtx"), exec); // Create solver factory and solve system - auto solver = bicg::build() - .with_criteria(ByInteraction::build() - .with_stop_iteration_process( - stop_iteration_process) - .on(exec)) - .on(exec) - ->generate(A); + auto solver = + bicg::build() + .with_criteria(ByInteraction::build().with_stop_iteration_process( + stop_iteration_process)) + .on(exec) + ->generate(A); solver->add_logger(gko::log::Stream::create( gko::log::Logger::iteration_complete_mask, std::cout, true)); solver->apply(b, x); diff --git a/examples/distributed-solver/distributed-solver.cpp b/examples/distributed-solver/distributed-solver.cpp index 865a44b0643..dfc4b2eb2cd 100644 --- a/examples/distributed-solver/distributed-solver.cpp +++ b/examples/distributed-solver/distributed-solver.cpp @@ -222,19 +222,15 @@ int main(int argc, char* argv[]) const gko::remove_complex reduction_factor{1e-8}; std::shared_ptr> logger = gko::log::Convergence::create(); - auto Ainv = - solver::build() - .with_preconditioner(schwarz::build() - .with_local_solver_factory(local_solver) - .on(exec)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(num_iters).on( - exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) - .on(exec) - ->generate(A); + auto Ainv = solver::build() + .with_preconditioner( + schwarz::build().with_local_solver(local_solver)) + .with_criteria( + gko::stop::Iteration::build().with_max_iters(num_iters), + gko::stop::ResidualNorm::build() + .with_reduction_factor(reduction_factor)) + .on(exec) + ->generate(A); // Add logger to the generated solver to log the iteration count and // residual norm Ainv->add_logger(logger); diff --git a/examples/external-lib-interfacing/external-lib-interfacing.cpp b/examples/external-lib-interfacing/external-lib-interfacing.cpp index 08b35923b30..2862991dd4e 100644 --- a/examples/external-lib-interfacing/external-lib-interfacing.cpp +++ b/examples/external-lib-interfacing/external-lib-interfacing.cpp @@ -880,11 +880,9 @@ void AdvectionProblem::solve() auto solver_gen = bicgstab::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(1000).on(exec), - gko::stop::ResidualNorm<>::build() - .with_reduction_factor(1e-12) - .on(exec)) - .with_preconditioner(bj::build().on(exec)) + gko::stop::Iteration::build().with_max_iters(1000), + gko::stop::ResidualNorm<>::build().with_reduction_factor(1e-12)) + .with_preconditioner(bj::build()) .on(exec); auto solver = solver_gen->generate(gko::give(A)); diff --git a/examples/ginkgo-overhead/ginkgo-overhead.cpp b/examples/ginkgo-overhead/ginkgo-overhead.cpp index 5bd90ba0bad..f3f308c495f 100644 --- a/examples/ginkgo-overhead/ginkgo-overhead.cpp +++ b/examples/ginkgo-overhead/ginkgo-overhead.cpp @@ -72,8 +72,7 @@ int main(int argc, char* argv[]) auto cg_factory = cg::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(num_iters).on( - exec)) + gko::stop::Iteration::build().with_max_iters(num_iters)) .on(exec); auto A = gko::initialize({1.0}, exec); auto b = gko::initialize({std::nan("")}, exec); diff --git a/examples/heat-equation/heat-equation.cpp b/examples/heat-equation/heat-equation.cpp index eae87f7e64f..8e69931b250 100644 --- a/examples/heat-equation/heat-equation.cpp +++ b/examples/heat-equation/heat-equation.cpp @@ -192,11 +192,10 @@ int main(int argc, char* argv[]) // stopping at 1e-10 relative accuracy auto solver = gko::solver::Cg<>::build() - .with_preconditioner(gko::preconditioner::Ic<>::build().on(exec)) + .with_preconditioner(gko::preconditioner::Ic<>::build()) .with_criteria(gko::stop::ResidualNorm<>::build() .with_baseline(gko::stop::mode::rhs_norm) - .with_reduction_factor(1e-10) - .on(exec)) + .with_reduction_factor(1e-10)) .on(exec) ->generate(stencil_matrix); // time stamp of the last output frame (initialized to a sentinel value) diff --git a/examples/ilu-preconditioned-solver/ilu-preconditioned-solver.cpp b/examples/ilu-preconditioned-solver/ilu-preconditioned-solver.cpp index aa32e0e879a..4ce8717e316 100644 --- a/examples/ilu-preconditioned-solver/ilu-preconditioned-solver.cpp +++ b/examples/ilu-preconditioned-solver/ilu-preconditioned-solver.cpp @@ -115,11 +115,9 @@ int main(int argc, char* argv[]) const RealValueType reduction_factor{1e-7}; auto ilu_gmres_factory = gmres::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1000u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1000u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(reduction_factor)) .with_generated_preconditioner(ilu_preconditioner) .on(exec); diff --git a/examples/inverse-iteration/inverse-iteration.cpp b/examples/inverse-iteration/inverse-iteration.cpp index 5d8270f1ca1..0bd7eb1a178 100644 --- a/examples/inverse-iteration/inverse-iteration.cpp +++ b/examples/inverse-iteration/inverse-iteration.cpp @@ -119,12 +119,10 @@ int main(int argc, char* argv[]) // Generate solver operator (A - zI)^-1 auto solver = solver_type::build() - .with_criteria(gko::stop::Iteration::build() - .with_max_iters(system_max_iterations) - .on(exec), + .with_criteria(gko::stop::Iteration::build().with_max_iters( + system_max_iterations), gko::stop::ResidualNorm::build() - .with_reduction_factor(system_residual_goal) - .on(exec)) + .with_reduction_factor(system_residual_goal)) .on(exec) ->generate(system_matrix); diff --git a/examples/ir-ilu-preconditioned-solver/ir-ilu-preconditioned-solver.cpp b/examples/ir-ilu-preconditioned-solver/ir-ilu-preconditioned-solver.cpp index e676e15cc6d..7f0df25d38d 100644 --- a/examples/ir-ilu-preconditioned-solver/ir-ilu-preconditioned-solver.cpp +++ b/examples/ir-ilu-preconditioned-solver/ir-ilu-preconditioned-solver.cpp @@ -120,18 +120,16 @@ int main(int argc, char* argv[]) auto trisolve_factory = ir::build() .with_solver(bj_factory) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(sweeps).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(sweeps)) .on(exec); // Generate an ILU preconditioner factory by setting lower and upper // triangular solver - in this case the previously defined iterative // refinement method. - auto ilu_pre_factory = - gko::preconditioner::Ilu::build() - .with_l_solver_factory(gko::clone(trisolve_factory)) - .with_u_solver_factory(gko::clone(trisolve_factory)) - .on(exec); + auto ilu_pre_factory = gko::preconditioner::Ilu::build() + .with_l_solver(gko::clone(trisolve_factory)) + .with_u_solver(gko::clone(trisolve_factory)) + .on(exec); // Use incomplete factors to generate ILU preconditioner auto ilu_preconditioner = gko::share(ilu_pre_factory->generate(par_ilu)); diff --git a/examples/iterative-refinement/iterative-refinement.cpp b/examples/iterative-refinement/iterative-refinement.cpp index cbd2156be60..0460e6c045d 100644 --- a/examples/iterative-refinement/iterative-refinement.cpp +++ b/examples/iterative-refinement/iterative-refinement.cpp @@ -114,19 +114,13 @@ int main(int argc, char* argv[]) RealValueType inner_reduction_factor{1e-2}; auto solver_gen = ir::build() - .with_solver( - cg::build() - .with_criteria( - gko::stop::ResidualNorm::build() - .with_reduction_factor(inner_reduction_factor) - .on(exec)) - .on(exec)) + .with_solver(cg::build().with_criteria( + gko::stop::ResidualNorm::build() + .with_reduction_factor(inner_reduction_factor))) .with_criteria( - gko::stop::Iteration::build().with_max_iters(max_iters).on( - exec), + gko::stop::Iteration::build().with_max_iters(max_iters), gko::stop::ResidualNorm::build() - .with_reduction_factor(outer_reduction_factor) - .on(exec)) + .with_reduction_factor(outer_reduction_factor)) .on(exec); // Create solver auto solver = solver_gen->generate(A); diff --git a/examples/kokkos_assembly/kokkos_assembly.cpp b/examples/kokkos_assembly/kokkos_assembly.cpp index ba579199ee3..88ff261b759 100644 --- a/examples/kokkos_assembly/kokkos_assembly.cpp +++ b/examples/kokkos_assembly/kokkos_assembly.cpp @@ -208,13 +208,11 @@ int main(int argc, char* argv[]) const RealValueType reduction_factor{1e-7}; // Generate solver and solve the system cg::build() - .with_criteria(gko::stop::Iteration::build() - .with_max_iters(discretization_points) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) - .with_preconditioner(bj::build().on(exec)) + .with_criteria( + gko::stop::Iteration::build().with_max_iters(discretization_points), + gko::stop::ResidualNorm::build().with_reduction_factor( + reduction_factor)) + .with_preconditioner(bj::build()) .on(exec) ->generate(A) ->apply(rhs, u); diff --git a/examples/minimal-cuda-solver/minimal-cuda-solver.cpp b/examples/minimal-cuda-solver/minimal-cuda-solver.cpp index 7182bc9ad8c..53a1e1f44d3 100644 --- a/examples/minimal-cuda-solver/minimal-cuda-solver.cpp +++ b/examples/minimal-cuda-solver/minimal-cuda-solver.cpp @@ -44,12 +44,10 @@ int main() // Create the solver auto solver = gko::solver::Cg<>::build() - .with_preconditioner(gko::preconditioner::Jacobi<>::build().on(gpu)) + .with_preconditioner(gko::preconditioner::Jacobi<>::build()) .with_criteria( - gko::stop::Iteration::build().with_max_iters(20u).on(gpu), - gko::stop::ResidualNorm<>::build() - .with_reduction_factor(1e-15) - .on(gpu)) + gko::stop::Iteration::build().with_max_iters(20u), + gko::stop::ResidualNorm<>::build().with_reduction_factor(1e-15)) .on(gpu); // Solve system solver->generate(give(A))->apply(b, x); diff --git a/examples/mixed-multigrid-preconditioned-solver/mixed-multigrid-preconditioned-solver.cpp b/examples/mixed-multigrid-preconditioned-solver/mixed-multigrid-preconditioned-solver.cpp index 6f1600d2805..16fe58b6a9b 100644 --- a/examples/mixed-multigrid-preconditioned-solver/mixed-multigrid-preconditioned-solver.cpp +++ b/examples/mixed-multigrid-preconditioned-solver/mixed-multigrid-preconditioned-solver.cpp @@ -140,15 +140,13 @@ int main(int argc, char* argv[]) ir::build() .with_solver(inner_solver_gen) .with_relaxation_factor(static_cast(0.9)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec)); auto smoother_gen_f = gko::share( ir_f::build() .with_solver(inner_solver_gen_f) .with_relaxation_factor(static_cast(0.9)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec)); // Create MultigridLevel factory auto mg_level_gen = @@ -160,15 +158,13 @@ int main(int argc, char* argv[]) ir::build() .with_solver(inner_solver_gen) .with_relaxation_factor(static_cast(0.9)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(4u)) .on(exec)); auto coarsest_gen_f = gko::share( ir_f::build() .with_solver(inner_solver_gen_f) .with_relaxation_factor(static_cast(0.9)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(4u)) .on(exec)); // Create multigrid factory std::shared_ptr multigrid_gen; @@ -193,8 +189,7 @@ int main(int argc, char* argv[]) .with_coarsest_solver(coarsest_gen_f) .with_default_initial_guess( gko::solver::initial_guess_mode::zero) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec); } else { multigrid_gen = @@ -207,8 +202,7 @@ int main(int argc, char* argv[]) .with_coarsest_solver(coarsest_gen) .with_default_initial_guess( gko::solver::initial_guess_mode::zero) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec); } // Create solver factory diff --git a/examples/mixed-multigrid-solver/mixed-multigrid-solver.cpp b/examples/mixed-multigrid-solver/mixed-multigrid-solver.cpp index d3f45cda916..e9a16c4ee18 100644 --- a/examples/mixed-multigrid-solver/mixed-multigrid-solver.cpp +++ b/examples/mixed-multigrid-solver/mixed-multigrid-solver.cpp @@ -126,17 +126,15 @@ int main(int argc, char* argv[]) // Create smoother factory (ir with bj) auto smoother_gen = gko::share( ir::build() - .with_solver(bj::build().with_max_block_size(1u).on(exec)) + .with_solver(bj::build().with_max_block_size(1u)) .with_relaxation_factor(static_cast(0.9)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec)); auto smoother_gen2 = gko::share( ir2::build() - .with_solver(bj2::build().with_max_block_size(1u).on(exec)) + .with_solver(bj2::build().with_max_block_size(1u)) .with_relaxation_factor(static_cast(0.9)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec)); // Create RestrictProlong factory auto mg_level_gen = @@ -146,17 +144,15 @@ int main(int argc, char* argv[]) // Create CoarsesSolver factory auto coarsest_solver_gen = gko::share( ir::build() - .with_solver(bj::build().with_max_block_size(1u).on(exec)) + .with_solver(bj::build().with_max_block_size(1u)) .with_relaxation_factor(static_cast(0.9)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(4u)) .on(exec)); auto coarsest_solver_gen2 = gko::share( ir2::build() - .with_solver(bj2::build().with_max_block_size(1u).on(exec)) + .with_solver(bj2::build().with_max_block_size(1u)) .with_relaxation_factor(static_cast(0.9)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(4u)) .on(exec)); // Create multigrid factory std::shared_ptr multigrid_gen; diff --git a/examples/mixed-precision-ir/mixed-precision-ir.cpp b/examples/mixed-precision-ir/mixed-precision-ir.cpp index 3510a2163e1..e8122ee98f0 100644 --- a/examples/mixed-precision-ir/mixed-precision-ir.cpp +++ b/examples/mixed-precision-ir/mixed-precision-ir.cpp @@ -125,12 +125,10 @@ int main(int argc, char* argv[]) // Create inner solver auto inner_solver = cg::build() - .with_criteria(gko::stop::ResidualNorm::build() - .with_reduction_factor(inner_reduction_factor) - .on(exec), - gko::stop::Iteration::build() - .with_max_iters(max_inner_iters) - .on(exec)) + .with_criteria( + gko::stop::ResidualNorm::build() + .with_reduction_factor(inner_reduction_factor), + gko::stop::Iteration::build().with_max_iters(max_inner_iters)) .on(exec) ->generate(give(solver_A)); diff --git a/examples/multigrid-preconditioned-solver-customized/multigrid-preconditioned-solver-customized.cpp b/examples/multigrid-preconditioned-solver-customized/multigrid-preconditioned-solver-customized.cpp index 6f75ca29630..4bc56f0fa73 100644 --- a/examples/multigrid-preconditioned-solver-customized/multigrid-preconditioned-solver-customized.cpp +++ b/examples/multigrid-preconditioned-solver-customized/multigrid-preconditioned-solver-customized.cpp @@ -131,8 +131,7 @@ int main(int argc, char* argv[]) // iterative refinement with two iterations and an Ic solver. auto ic_gen = gko::share( ic::build() - .with_factorization_factory( - gko::factorization::Ic::build().on(exec)) + .with_factorization(gko::factorization::Ic::build()) .on(exec)); auto smoother_gen = gko::share( gko::solver::build_smoother(ic_gen, 2u, static_cast(0.9))); @@ -160,8 +159,7 @@ int main(int argc, char* argv[]) .with_mg_level(mg_level_gen) .with_coarsest_solver(coarsest_gen) .with_default_initial_guess(gko::solver::initial_guess_mode::zero) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec); // Create solver factory auto solver_gen = cg::build() diff --git a/examples/multigrid-preconditioned-solver/multigrid-preconditioned-solver.cpp b/examples/multigrid-preconditioned-solver/multigrid-preconditioned-solver.cpp index 7f47d039072..184863fe3c2 100644 --- a/examples/multigrid-preconditioned-solver/multigrid-preconditioned-solver.cpp +++ b/examples/multigrid-preconditioned-solver/multigrid-preconditioned-solver.cpp @@ -109,19 +109,16 @@ int main(int argc, char* argv[]) std::shared_ptr multigrid_gen; multigrid_gen = mg::build() - .with_mg_level(pgm::build().with_deterministic(true).on(exec)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_mg_level(pgm::build().with_deterministic(true)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec); const gko::remove_complex tolerance = 1e-8; auto solver_gen = cg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on(exec), - gko::stop::ResidualNorm::build() - .with_baseline(gko::stop::mode::absolute) - .with_reduction_factor(tolerance) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(100u), + gko::stop::ResidualNorm::build() + .with_baseline(gko::stop::mode::absolute) + .with_reduction_factor(tolerance)) .with_preconditioner(multigrid_gen) .on(exec); // Create solver diff --git a/examples/nine-pt-stencil-solver/nine-pt-stencil-solver.cpp b/examples/nine-pt-stencil-solver/nine-pt-stencil-solver.cpp index 51fdf97d4a4..e60d20f0a09 100644 --- a/examples/nine-pt-stencil-solver/nine-pt-stencil-solver.cpp +++ b/examples/nine-pt-stencil-solver/nine-pt-stencil-solver.cpp @@ -283,12 +283,10 @@ void solve_system(const std::string& executor_string, // Generate solver auto solver_gen = cg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(dp_2).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) - .with_preconditioner(bj::build().on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(dp_2), + gko::stop::ResidualNorm::build() + .with_reduction_factor(reduction_factor)) + .with_preconditioner(bj::build()) .on(exec); auto solver = solver_gen->generate(gko::give(matrix)); diff --git a/examples/papi-logging/papi-logging.cpp b/examples/papi-logging/papi-logging.cpp index 0d81ef65909..9152eaab7fe 100644 --- a/examples/papi-logging/papi-logging.cpp +++ b/examples/papi-logging/papi-logging.cpp @@ -178,11 +178,9 @@ int main(int argc, char* argv[]) const RealValueType reduction_factor{1e-7}; auto solver_gen = cg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(20u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(20u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(reduction_factor)) .on(exec); auto solver = solver_gen->generate(A); diff --git a/examples/performance-debugging/performance-debugging.cpp b/examples/performance-debugging/performance-debugging.cpp index f357a8d4619..146a5393f8e 100644 --- a/examples/performance-debugging/performance-debugging.cpp +++ b/examples/performance-debugging/performance-debugging.cpp @@ -417,8 +417,7 @@ int main(int argc, char* argv[]) solver::build() .with_criteria( gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec), + .with_reduction_factor(reduction_factor), gko::stop::Iteration::build().with_max_iters(max_iters).on( exec)) .with_preconditioner(preconditioner::create(exec)) diff --git a/examples/poisson-solver/poisson-solver.cpp b/examples/poisson-solver/poisson-solver.cpp index 7602600a514..12ded429cba 100644 --- a/examples/poisson-solver/poisson-solver.cpp +++ b/examples/poisson-solver/poisson-solver.cpp @@ -185,13 +185,11 @@ int main(int argc, char* argv[]) const gko::remove_complex reduction_factor = 1e-7; // Generate solver and solve the system cg::build() - .with_criteria(gko::stop::Iteration::build() - .with_max_iters(discretization_points) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) - .with_preconditioner(bj::build().on(exec)) + .with_criteria( + gko::stop::Iteration::build().with_max_iters(discretization_points), + gko::stop::ResidualNorm::build().with_reduction_factor( + reduction_factor)) + .with_preconditioner(bj::build()) .on(exec) ->generate(clone(exec, matrix)) // copy the matrix to the executor ->apply(rhs, u); diff --git a/examples/preconditioned-solver/preconditioned-solver.cpp b/examples/preconditioned-solver/preconditioned-solver.cpp index 37963f205cc..9211e42b16f 100644 --- a/examples/preconditioned-solver/preconditioned-solver.cpp +++ b/examples/preconditioned-solver/preconditioned-solver.cpp @@ -96,14 +96,12 @@ int main(int argc, char* argv[]) // Create solver factory auto solver_gen = cg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(20u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(20u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(reduction_factor)) // Add preconditioner, these 2 lines are the only // difference from the simple solver example - .with_preconditioner(bj::build().with_max_block_size(8u).on(exec)) + .with_preconditioner(bj::build().with_max_block_size(8u)) .on(exec); // Create solver auto solver = solver_gen->generate(A); diff --git a/examples/preconditioner-export/preconditioner-export.cpp b/examples/preconditioner-export/preconditioner-export.cpp index 81aeece1cb1..16baffc6472 100644 --- a/examples/preconditioner-export/preconditioner-export.cpp +++ b/examples/preconditioner-export/preconditioner-export.cpp @@ -193,13 +193,11 @@ int main(int argc, char* argv[]) auto factory = gko::preconditioner::Ilu, gko::preconditioner::UpperIsai<>>::build() - .with_factorization_factory(fact_factory) - .with_l_solver_factory(gko::preconditioner::LowerIsai<>::build() - .with_sparsity_power(sparsity_power) - .on(exec)) - .with_u_solver_factory(gko::preconditioner::UpperIsai<>::build() - .with_sparsity_power(sparsity_power) - .on(exec)) + .with_factorization(fact_factory) + .with_l_solver(gko::preconditioner::LowerIsai<>::build() + .with_sparsity_power(sparsity_power)) + .with_u_solver(gko::preconditioner::UpperIsai<>::build() + .with_sparsity_power(sparsity_power)) .on(exec); auto ilu_isai = try_generate([&] { return factory->generate(mtx); }); output(ilu_isai->get_l_solver()->get_approximate_inverse(), @@ -220,13 +218,11 @@ int main(int argc, char* argv[]) auto factory = gko::preconditioner::Ilu, gko::preconditioner::UpperIsai<>>::build() - .with_factorization_factory(fact_factory) - .with_l_solver_factory(gko::preconditioner::LowerIsai<>::build() - .with_sparsity_power(sparsity_power) - .on(exec)) - .with_u_solver_factory(gko::preconditioner::UpperIsai<>::build() - .with_sparsity_power(sparsity_power) - .on(exec)) + .with_factorization(fact_factory) + .with_l_solver(gko::preconditioner::LowerIsai<>::build() + .with_sparsity_power(sparsity_power)) + .with_u_solver(gko::preconditioner::UpperIsai<>::build() + .with_sparsity_power(sparsity_power)) .on(exec); auto ilu_isai = try_generate([&] { return factory->generate(mtx); }); output(ilu_isai->get_l_solver()->get_approximate_inverse(), @@ -250,13 +246,11 @@ int main(int argc, char* argv[]) auto factory = gko::preconditioner::Ilu, gko::preconditioner::UpperIsai<>>::build() - .with_factorization_factory(fact_factory) - .with_l_solver_factory(gko::preconditioner::LowerIsai<>::build() - .with_sparsity_power(sparsity_power) - .on(exec)) - .with_u_solver_factory(gko::preconditioner::UpperIsai<>::build() - .with_sparsity_power(sparsity_power) - .on(exec)) + .with_factorization(fact_factory) + .with_l_solver(gko::preconditioner::LowerIsai<>::build() + .with_sparsity_power(sparsity_power)) + .with_u_solver(gko::preconditioner::UpperIsai<>::build() + .with_sparsity_power(sparsity_power)) .on(exec); auto ilu_isai = try_generate([&] { return factory->generate(mtx); }); output(ilu_isai->get_l_solver()->get_approximate_inverse(), diff --git a/examples/simple-solver-logging/simple-solver-logging.cpp b/examples/simple-solver-logging/simple-solver-logging.cpp index 6aa85462605..d7519f46ea3 100644 --- a/examples/simple-solver-logging/simple-solver-logging.cpp +++ b/examples/simple-solver-logging/simple-solver-logging.cpp @@ -137,9 +137,8 @@ int main(int argc, char* argv[]) // Generate solver auto solver_gen = cg::build() - .with_criteria( - residual_criterion, - gko::stop::Iteration::build().with_max_iters(20u).on(exec)) + .with_criteria(residual_criterion, + gko::stop::Iteration::build().with_max_iters(20u)) .on(exec); auto solver = solver_gen->generate(A); diff --git a/examples/simple-solver/simple-solver.cpp b/examples/simple-solver/simple-solver.cpp index 8f665f98496..1ec3c536c58 100644 --- a/examples/simple-solver/simple-solver.cpp +++ b/examples/simple-solver/simple-solver.cpp @@ -131,11 +131,9 @@ int main(int argc, char* argv[]) const RealValueType reduction_factor{1e-7}; auto solver_gen = cg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(20u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(20u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(reduction_factor)) .on(exec); // Generate the solver from the matrix. The solver factory built in the // previous step takes a "matrix"(a gko::LinOp to be more general) as an diff --git a/examples/three-pt-stencil-solver/three-pt-stencil-solver.cpp b/examples/three-pt-stencil-solver/three-pt-stencil-solver.cpp index 6bf3cc21a8a..3dca9c7b70a 100644 --- a/examples/three-pt-stencil-solver/three-pt-stencil-solver.cpp +++ b/examples/three-pt-stencil-solver/three-pt-stencil-solver.cpp @@ -217,13 +217,11 @@ void solve_system(const std::string& executor_string, // Generate solver auto solver_gen = cg::build() - .with_criteria(gko::stop::Iteration::build() - .with_max_iters(gko::size_type(dp)) - .on(exec), + .with_criteria(gko::stop::Iteration::build().with_max_iters( + gko::size_type(dp)), gko::stop::ResidualNorm::build() - .with_reduction_factor(reduction_factor) - .on(exec)) - .with_preconditioner(bj::build().on(exec)) + .with_reduction_factor(reduction_factor)) + .with_preconditioner(bj::build()) .on(exec); auto solver = solver_gen->generate(gko::give(matrix)); diff --git a/include/ginkgo/core/distributed/preconditioner/schwarz.hpp b/include/ginkgo/core/distributed/preconditioner/schwarz.hpp index 9016442df67..ca0f4d9fac9 100644 --- a/include/ginkgo/core/distributed/preconditioner/schwarz.hpp +++ b/include/ginkgo/core/distributed/preconditioner/schwarz.hpp @@ -40,6 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if GINKGO_BUILD_MPI +#include #include #include #include @@ -93,8 +94,25 @@ class Schwarz /** * Local solver factory. */ - std::shared_ptr GKO_FACTORY_PARAMETER_SCALAR( - local_solver_factory, nullptr); + std::shared_ptr local_solver{}; + + parameters_type& with_local_solver( + deferred_factory_parameter solver) + { + this->local_solver_generator = std::move(solver); + return *this; + } + + std::unique_ptr on(std::shared_ptr exec) const + { + auto copy = *this; + copy.local_solver = local_solver_generator.on(exec); + return copy.enable_parameters_type::on( + exec); + } + + private: + deferred_factory_parameter local_solver_generator; }; GKO_ENABLE_LIN_OP_FACTORY(Schwarz, parameters, Factory); GKO_ENABLE_BUILD_METHOD(Factory); diff --git a/reference/test/preconditioner/ilu.cpp b/reference/test/preconditioner/ilu.cpp index 3511de4f011..4066b53b240 100644 --- a/reference/test/preconditioner/ilu.cpp +++ b/reference/test/preconditioner/ilu.cpp @@ -80,37 +80,29 @@ class Ilu : public ::testing::Test { u_factor(gko::initialize( {{2., 1., 1.}, {0., 4., 1.}, {0., 0., 3.}}, exec)), l_u_composition(Composition::create(l_factor, u_factor)), - l_factory( - l_solver_type::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(10u).on( - exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .on(exec)), - u_factory( - u_solver_type::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(10u).on( - exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .on(exec)), + l_factory(l_solver_type::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(10u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .on(exec)), + u_factory(u_solver_type::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(10u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .on(exec)), ilu_pre_factory(ilu_prec_type::build() - .with_l_solver_factory(l_factory) - .with_u_solver_factory(u_factory) + .with_l_solver(l_factory) + .with_u_solver(u_factory) .on(exec)), ilu_rev_pre_factory(ilu_rev_prec_type::build() - .with_l_solver_factory(l_factory) - .with_u_solver_factory(u_factory) + .with_l_solver(l_factory) + .with_u_solver(u_factory) .on(exec)) {} diff --git a/reference/test/preconditioner/isai_kernels.cpp b/reference/test/preconditioner/isai_kernels.cpp index eea171d60fe..86d0f40142a 100644 --- a/reference/test/preconditioner/isai_kernels.cpp +++ b/reference/test/preconditioner/isai_kernels.cpp @@ -82,16 +82,13 @@ class Isai : public ::testing::Test { : exec{gko::ReferenceExecutor::create()}, excess_solver_factory( excess_solver_type::build() - .with_preconditioner( - bj::build().with_max_block_size(16u).on(exec)) + .with_preconditioner(bj::build().with_max_block_size(16u)) .with_criteria( - gko::stop::Iteration::build().with_max_iters(1000u).on( - exec), + gko::stop::Iteration::build().with_max_iters(1000u), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::rhs_norm) .with_reduction_factor( - gko::remove_complex{1e-6}) - .on(exec)) + gko::remove_complex{1e-6})) .on(exec)), a_dense{gko::initialize({{2, 1, 2}, {1, -2, 3}, {-1, 1, 1}}, exec)}, diff --git a/reference/test/reorder/scaled_reordered.cpp b/reference/test/reorder/scaled_reordered.cpp index 8789ded37ca..edadc245b33 100644 --- a/reference/test/reorder/scaled_reordered.cpp +++ b/reference/test/reorder/scaled_reordered.cpp @@ -110,11 +110,9 @@ class ScaledReordered : public ::testing::Test { solver_factory( Bicgstab::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), tol{r::value} { diff --git a/reference/test/solver/bicg_kernels.cpp b/reference/test/solver/bicg_kernels.cpp index e317677b2de..aa27eb4afa3 100644 --- a/reference/test/solver/bicg_kernels.cpp +++ b/reference/test/solver/bicg_kernels.cpp @@ -64,17 +64,14 @@ class Bicg : public ::testing::Test { {{2, -1.0, 0.0}, {-1.0, 2, -1.0}, {0.0, -1.0, 2}}, exec)), stopped{}, non_stopped{}, - bicg_factory( - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .on(exec)), + bicg_factory(Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(4u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .on(exec)), mtx_big(gko::initialize( {{8828.0, 2673.0, 4150.0, -3139.5, 3829.5, 5856.0}, {2673.0, 10765.5, 1805.0, 73.0, 1966.0, 3919.5}, @@ -86,20 +83,16 @@ class Bicg : public ::testing::Test { bicg_factory_big( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), bicg_factory_big2( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ImplicitResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), mtx_non_symmetric(gko::initialize( {{1.0, 2.0, 3.0}, {3.0, 2.0, -1.0}, {0.0, -1.0, 2}}, exec)) diff --git a/reference/test/solver/bicgstab_kernels.cpp b/reference/test/solver/bicgstab_kernels.cpp index ec44b6b6f17..70302e95796 100644 --- a/reference/test/solver/bicgstab_kernels.cpp +++ b/reference/test/solver/bicgstab_kernels.cpp @@ -69,36 +69,29 @@ class Bicgstab : public ::testing::Test { bicgstab_factory( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(8u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), + gko::stop::Iteration::build().with_max_iters(8u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), bicgstab_factory2( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(8u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), + gko::stop::Iteration::build().with_max_iters(8u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), gko::stop::ImplicitResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), bicgstab_factory_precision( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on( - exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), + gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)) { auto small_size = gko::dim<2>{2, 2}; diff --git a/reference/test/solver/cb_gmres_kernels.cpp b/reference/test/solver/cb_gmres_kernels.cpp index 1127d7caff7..e5b933ad82c 100644 --- a/reference/test/solver/cb_gmres_kernels.cpp +++ b/reference/test/solver/cb_gmres_kernels.cpp @@ -77,15 +77,12 @@ class CbGmres : public ::testing::Test { gmres_type::build() .with_storage_precision(storage_prec) .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), + gko::stop::Iteration::build().with_max_iters(100u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::initial_resnorm) - .with_reduction_factor(this->reduction_factor()) - .on(exec)) + .with_reduction_factor(this->reduction_factor())) .on(exec)), mtx_big(gko::initialize( {{2295.7, -764.8, 1166.5, 428.9, 291.7, -774.5}, @@ -99,12 +96,10 @@ class CbGmres : public ::testing::Test { gmres_type::build() .with_storage_precision(storage_prec) .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::initial_resnorm) - .with_reduction_factor(this->reduction_factor()) - .on(exec)) + .with_reduction_factor(this->reduction_factor())) .on(exec)), mtx_medium( gko::initialize({{-86.40, 153.30, -108.90, 8.60, -61.60}, diff --git a/reference/test/solver/cg_kernels.cpp b/reference/test/solver/cg_kernels.cpp index 76b8cf55946..c089442488f 100644 --- a/reference/test/solver/cg_kernels.cpp +++ b/reference/test/solver/cg_kernels.cpp @@ -64,18 +64,14 @@ class Cg : public ::testing::Test { {{2, -1.0, 0.0}, {-1.0, 2, -1.0}, {0.0, -1.0, 2}}, exec)), stopped{}, non_stopped{}, - cg_factory( - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(400u).on( - exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .on(exec)), + cg_factory(Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(400u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .on(exec)), mtx_big(gko::initialize( {{8828.0, 2673.0, 4150.0, -3139.5, 3829.5, 5856.0}, {2673.0, 10765.5, 1805.0, 73.0, 1966.0, 3919.5}, @@ -87,20 +83,16 @@ class Cg : public ::testing::Test { cg_factory_big( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), cg_factory_big2( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ImplicitResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)) { auto small_size = gko::dim<2>{2, 2}; diff --git a/reference/test/solver/cgs_kernels.cpp b/reference/test/solver/cgs_kernels.cpp index 9c3ce2071a7..91c7c1e821b 100644 --- a/reference/test/solver/cgs_kernels.cpp +++ b/reference/test/solver/cgs_kernels.cpp @@ -65,15 +65,12 @@ class Cgs : public ::testing::Test { {{1.0, -3.0, 0.0}, {-4.0, 1.0, -3.0}, {2.0, -1.0, 2.0}}, exec)), stopped{}, non_stopped{}, - cgs_factory( - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(40u).on( - exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .on(exec)), + cgs_factory(Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(40u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .on(exec)), mtx_big( gko::initialize({{-99.0, 87.0, -67.0, -62.0, -68.0, -19.0}, {-30.0, -17.0, -1.0, 9.0, 23.0, 77.0}, @@ -85,20 +82,16 @@ class Cgs : public ::testing::Test { cgs_factory_big( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), cgs_factory_big2( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ImplicitResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)) { auto small_size = gko::dim<2>{2, 2}; diff --git a/reference/test/solver/direct.cpp b/reference/test/solver/direct.cpp index 617015bac1f..f69846b548d 100644 --- a/reference/test/solver/direct.cpp +++ b/reference/test/solver/direct.cpp @@ -77,8 +77,7 @@ class Direct : public ::testing::Test { .with_factorization( gko::experimental::factorization::Lu::build() - .with_symmetric_sparsity(true) - .on(exec)) + .with_symmetric_sparsity(true)) .on(exec); solver = factory->generate(mtx); std::normal_distribution> dist(0, 1); diff --git a/reference/test/solver/fcg_kernels.cpp b/reference/test/solver/fcg_kernels.cpp index e8163752689..3dd4149405e 100644 --- a/reference/test/solver/fcg_kernels.cpp +++ b/reference/test/solver/fcg_kernels.cpp @@ -65,17 +65,14 @@ class Fcg : public ::testing::Test { {{2, -1.0, 0.0}, {-1.0, 2, -1.0}, {0.0, -1.0, 2}}, exec)), stopped{}, non_stopped{}, - fcg_factory( - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .on(exec)), + fcg_factory(Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(4u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .on(exec)), mtx_big(gko::initialize( {{8828.0, 2673.0, 4150.0, -3139.5, 3829.5, 5856.0}, {2673.0, 10765.5, 1805.0, 73.0, 1966.0, 3919.5}, @@ -87,20 +84,16 @@ class Fcg : public ::testing::Test { fcg_factory_big( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), fcg_factory_big2( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ImplicitResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)) { auto small_size = gko::dim<2>{2, 2}; diff --git a/reference/test/solver/gcr_kernels.cpp b/reference/test/solver/gcr_kernels.cpp index 888cbc3b4fe..adf5c35fd1d 100644 --- a/reference/test/solver/gcr_kernels.cpp +++ b/reference/test/solver/gcr_kernels.cpp @@ -72,18 +72,15 @@ class Gcr : public ::testing::Test { non_stopped{}, mtx(gko::initialize( {{1.0, 2.0, 3.0}, {3.0, 2.0, -1.0}, {0.0, -1.0, 2}}, exec)), - gcr_factory( - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .with_krylov_dim(3u) - .on(exec)), + gcr_factory(Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(4u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .with_krylov_dim(3u) + .on(exec)), mtx_big(gko::initialize( {{2295.7, -764.8, 1166.5, 428.9, 291.7, -774.5}, {2752.6, -1127.7, 1212.8, -299.1, 987.7, 786.8}, @@ -95,20 +92,16 @@ class Gcr : public ::testing::Test { gcr_factory_big( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), gcr_factory_big2( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ImplicitResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), mtx_medium( gko::initialize({{-86.40, 153.30, -108.90, 8.60, -61.60}, diff --git a/reference/test/solver/gmres_kernels.cpp b/reference/test/solver/gmres_kernels.cpp index 585fec833bc..a99400e412b 100644 --- a/reference/test/solver/gmres_kernels.cpp +++ b/reference/test/solver/gmres_kernels.cpp @@ -76,13 +76,11 @@ class Gmres : public ::testing::Test { gmres_factory( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), + gko::stop::Iteration::build().with_max_iters(4u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .with_krylov_dim(3u) .on(exec)), mtx_big(gko::initialize( @@ -96,20 +94,16 @@ class Gmres : public ::testing::Test { gmres_factory_big( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), gmres_factory_big2( Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(100u).on( - exec), + gko::stop::Iteration::build().with_max_iters(100u), gko::stop::ImplicitResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), mtx_medium( gko::initialize({{-86.40, 153.30, -108.90, 8.60, -61.60}, diff --git a/reference/test/solver/idr_kernels.cpp b/reference/test/solver/idr_kernels.cpp index 3e74e0c319b..da1b73a035c 100644 --- a/reference/test/solver/idr_kernels.cpp +++ b/reference/test/solver/idr_kernels.cpp @@ -62,30 +62,24 @@ class Idr : public ::testing::Test { : exec(gko::ReferenceExecutor::create()), mtx(gko::initialize( {{1.0, -3.0, 0.0}, {-4.0, 1.0, -3.0}, {2.0, -1.0, 2.0}}, exec)), - idr_factory( - Solver::build() - .with_deterministic(true) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(8u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .on(exec)), + idr_factory(Solver::build() + .with_deterministic(true) + .with_criteria( + gko::stop::Iteration::build().with_max_iters(8u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .on(exec)), idr_factory_precision( Solver::build() .with_deterministic(true) .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on( - exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), + gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)) {} diff --git a/reference/test/solver/ir_kernels.cpp b/reference/test/solver/ir_kernels.cpp index 8b4255b72ef..fc0c130aa83 100644 --- a/reference/test/solver/ir_kernels.cpp +++ b/reference/test/solver/ir_kernels.cpp @@ -65,15 +65,12 @@ class Ir : public ::testing::Test { // Eigenvalues of mtx are 0.9, 1.0 and 1.1 // Richardson iteration, converges since // | relaxation_factor * lambda - 1 | < 1 - ir_factory( - Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(30u).on( - exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec)) - .on(exec)) + ir_factory(Solver::build() + .with_criteria( + gko::stop::Iteration::build().with_max_iters(30u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(r::value)) + .on(exec)) {} std::shared_ptr exec; diff --git a/reference/test/solver/multigrid_kernels.cpp b/reference/test/solver/multigrid_kernels.cpp index 3efb9d41c5e..23307d20b33 100644 --- a/reference/test/solver/multigrid_kernels.cpp +++ b/reference/test/solver/multigrid_kernels.cpp @@ -289,30 +289,26 @@ class Multigrid : public ::testing::Test { .on(exec)), smoother_factory(gko::give( Smoother::build() - .with_solver( - InnerSolver::build().with_max_block_size(1u).on(exec)) + .with_solver(InnerSolver::build().with_max_block_size(1u)) .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + gko::stop::Iteration::build().with_max_iters(1u)) .on(exec))), coarsest_factory( CoarsestSolver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), + gko::stop::Iteration::build().with_max_iters(4u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::initial_resnorm) - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .on(exec)), coarsestnext_factory( CoarsestNextSolver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec)) + gko::stop::Iteration::build().with_max_iters(4u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6))) .on(exec)), rp_factory(DummyRPFactory::build().on(exec)), lo_factory(DummyFactory::build().on(exec)), @@ -357,14 +353,12 @@ class Multigrid : public ::testing::Test { .with_mid_case(gko::solver::multigrid::mid_smooth_type::both) .with_mg_level(coarse_factory) .with_criteria( - gko::stop::Iteration::build().with_max_iters(4u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(6)) - .on(exec), + gko::stop::Iteration::build().with_max_iters(4u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(6)), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::initial_resnorm) - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .with_cycle(cycle) .with_min_coarse_rows(1u) .on(exec)); @@ -382,14 +376,12 @@ class Multigrid : public ::testing::Test { .with_mid_case(gko::solver::multigrid::mid_smooth_type::both) .with_mg_level(coarse_factory, coarsenext_factory) .with_criteria( - gko::stop::Iteration::build().with_max_iters(200u).on(exec), - gko::stop::Time::build() - .with_time_limit(std::chrono::seconds(100)) - .on(exec), + gko::stop::Iteration::build().with_max_iters(200u), + gko::stop::Time::build().with_time_limit( + std::chrono::seconds(100)), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::initial_resnorm) - .with_reduction_factor(r::value) - .on(exec)) + .with_reduction_factor(r::value)) .with_cycle(cycle) .with_min_coarse_rows(1u) .on(exec)); diff --git a/test/mpi/preconditioner/schwarz.cpp b/test/mpi/preconditioner/schwarz.cpp index 8586711a114..44a558f9b94 100644 --- a/test/mpi/preconditioner/schwarz.cpp +++ b/test/mpi/preconditioner/schwarz.cpp @@ -197,7 +197,7 @@ TYPED_TEST(SchwarzPreconditioner, CanApplyPreconditionedSolver) cg::build() .with_preconditioner( prec::build() - .with_local_solver_factory(this->local_solver_factory) + .with_local_solver(this->local_solver_factory) .on(this->exec)) .with_criteria(iter_stop, tol_stop) .on(this->exec); @@ -225,10 +225,9 @@ TYPED_TEST(SchwarzPreconditioner, CanApplyPreconditioner) using cg = typename TestFixture::solver_type; using prec = typename TestFixture::dist_prec_type; - auto precond_factory = - prec::build() - .with_local_solver_factory(this->local_solver_factory) - .on(this->exec); + auto precond_factory = prec::build() + .with_local_solver(this->local_solver_factory) + .on(this->exec); auto local_precond = this->local_solver_factory->generate(this->non_dist_mat); auto precond = precond_factory->generate(this->dist_mat); @@ -249,10 +248,9 @@ TYPED_TEST(SchwarzPreconditioner, CanAdvancedApplyPreconditioner) using cg = typename TestFixture::solver_type; using prec = typename TestFixture::dist_prec_type; - auto precond_factory = - prec::build() - .with_local_solver_factory(this->local_solver_factory) - .on(this->exec); + auto precond_factory = prec::build() + .with_local_solver(this->local_solver_factory) + .on(this->exec); auto local_precond = this->local_solver_factory->generate(this->non_dist_mat); auto precond = precond_factory->generate(this->dist_mat); diff --git a/test/mpi/solver/solver.cpp b/test/mpi/solver/solver.cpp index 59462a9be59..f53b2784124 100644 --- a/test/mpi/solver/solver.cpp +++ b/test/mpi/solver/solver.cpp @@ -107,9 +107,7 @@ struct SimpleSolverTest { std::shared_ptr exec) { return solver_type::build().with_criteria( - gko::stop::Iteration::build() - .with_max_iters(iteration_count()) - .on(exec), + gko::stop::Iteration::build().with_max_iters(iteration_count()), gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::absolute) .with_reduction_factor(reduction_factor()) @@ -164,17 +162,11 @@ struct Ir : SimpleSolverTest> { std::shared_ptr exec) { return SimpleSolverTest>::build(exec) - .with_solver( - gko::solver::Cg::build() - .with_criteria( - gko::stop::Iteration::build() - .with_max_iters(iteration_count()) - .on(exec), - gko::stop::ResidualNorm::build() - .with_baseline(gko::stop::mode::absolute) - .with_reduction_factor(2 * reduction_factor()) - .on(exec)) - .on(exec)) + .with_solver(gko::solver::Cg::build().with_criteria( + gko::stop::Iteration::build().with_max_iters(iteration_count()), + gko::stop::ResidualNorm::build() + .with_baseline(gko::stop::mode::absolute) + .with_reduction_factor(2 * reduction_factor()))) .with_relaxation_factor(0.9); } }; diff --git a/test/solver/bicg_kernels.cpp b/test/solver/bicg_kernels.cpp index a62ab3f6d72..d35e6de227d 100644 --- a/test/solver/bicg_kernels.cpp +++ b/test/solver/bicg_kernels.cpp @@ -239,19 +239,15 @@ TEST_F(Bicg, ApplyWithSpdMatrixIsEquivalentToRef) auto d_b = gko::clone(exec, b); auto bicg_factory = gko::solver::Bicg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on(ref), - gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(::r::value)) .on(ref); auto d_bicg_factory = gko::solver::Bicg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(::r::value)) .on(exec); auto solver = bicg_factory->generate(std::move(mtx)); auto d_solver = d_bicg_factory->generate(std::move(d_mtx)); @@ -271,19 +267,15 @@ TEST_F(Bicg, ApplyWithSuiteSparseMatrixIsEquivalentToRef) auto d_b = gko::clone(exec, b); auto bicg_factory = gko::solver::Bicg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on(ref), - gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(::r::value)) .on(ref); auto d_bicg_factory = gko::solver::Bicg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(::r::value)) .on(exec); auto solver = bicg_factory->generate(std::move(mtx_ani)); auto d_solver = d_bicg_factory->generate(std::move(d_mtx_ani)); diff --git a/test/solver/bicgstab_kernels.cpp b/test/solver/bicgstab_kernels.cpp index 15eda2a74cb..422d51c86ad 100644 --- a/test/solver/bicgstab_kernels.cpp +++ b/test/solver/bicgstab_kernels.cpp @@ -71,19 +71,17 @@ class Bicgstab : public CommonTestFixture { exec_bicgstab_factory = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(246u).on(exec), + gko::stop::Iteration::build().with_max_iters(246u), gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(exec)) + .with_reduction_factor(::r::value)) .on(exec); ref_bicgstab_factory = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(246u).on(ref), + gko::stop::Iteration::build().with_max_iters(246u), gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(ref)) + .with_reduction_factor(::r::value)) .on(ref); } diff --git a/test/solver/cg_kernels.cpp b/test/solver/cg_kernels.cpp index a51ac48c59b..dcb4b0147f6 100644 --- a/test/solver/cg_kernels.cpp +++ b/test/solver/cg_kernels.cpp @@ -203,19 +203,15 @@ TEST_F(Cg, ApplyIsEquivalentToRef) auto d_b = gko::clone(exec, b); auto cg_factory = gko::solver::Cg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on(ref), - gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(::r::value)) .on(ref); auto d_cg_factory = gko::solver::Cg::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(::r::value)) .on(exec); auto solver = cg_factory->generate(std::move(mtx)); auto d_solver = d_cg_factory->generate(std::move(d_mtx)); diff --git a/test/solver/cgs_kernels.cpp b/test/solver/cgs_kernels.cpp index b1b124ed420..35914d4afa6 100644 --- a/test/solver/cgs_kernels.cpp +++ b/test/solver/cgs_kernels.cpp @@ -70,18 +70,16 @@ class Cgs : public CommonTestFixture { exec_cgs_factory = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(246u).on(exec), + gko::stop::Iteration::build().with_max_iters(246u), gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(exec)) + .with_reduction_factor(::r::value)) .on(exec); ref_cgs_factory = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(246u).on(ref), + gko::stop::Iteration::build().with_max_iters(246u), gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(ref)) + .with_reduction_factor(::r::value)) .on(ref); } diff --git a/test/solver/direct.cpp b/test/solver/direct.cpp index 0a30f7ba67f..31b7bd976ce 100644 --- a/test/solver/direct.cpp +++ b/test/solver/direct.cpp @@ -93,22 +93,22 @@ class Direct : public CommonTestFixture { mtx = gko::read(s_mtx, ref); dmtx = gko::clone(exec, mtx); const auto num_rows = mtx->get_size()[0]; - factory = solver_type::build() - .with_factorization(factorization_type::build() - .with_symmetric_sparsity(true) - .on(ref)) - .with_num_rhs(static_cast(nrhs)) - .on(ref); + factory = + solver_type::build() + .with_factorization( + factorization_type::build().with_symmetric_sparsity(true)) + .with_num_rhs(static_cast(nrhs)) + .on(ref); alpha = gen_mtx(1, 1); beta = gen_mtx(1, 1); input = gen_mtx(num_rows, nrhs); output = gen_mtx(num_rows, nrhs); - dfactory = solver_type::build() - .with_factorization(factorization_type::build() - .with_symmetric_sparsity(true) - .on(exec)) - .with_num_rhs(static_cast(nrhs)) - .on(exec); + dfactory = + solver_type::build() + .with_factorization( + factorization_type::build().with_symmetric_sparsity(true)) + .with_num_rhs(static_cast(nrhs)) + .on(exec); dalpha = gko::clone(exec, alpha); dbeta = gko::clone(exec, beta); dinput = gko::clone(exec, input); diff --git a/test/solver/fcg_kernels.cpp b/test/solver/fcg_kernels.cpp index 0d1ced86f85..d8a3a1ef9b2 100644 --- a/test/solver/fcg_kernels.cpp +++ b/test/solver/fcg_kernels.cpp @@ -212,19 +212,15 @@ TEST_F(Fcg, ApplyIsEquivalentToRef) auto d_b = gko::clone(exec, b); auto fcg_factory = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on(ref), - gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(::r::value)) .on(ref); auto d_fcg_factory = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(50u).on(exec), - gko::stop::ResidualNorm::build() - .with_reduction_factor(::r::value) - .on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(50u), + gko::stop::ResidualNorm::build() + .with_reduction_factor(::r::value)) .on(exec); auto solver = fcg_factory->generate(std::move(mtx)); auto d_solver = d_fcg_factory->generate(std::move(d_mtx)); diff --git a/test/solver/gcr_kernels.cpp b/test/solver/gcr_kernels.cpp index 8f02c431f98..8db5570a6f0 100644 --- a/test/solver/gcr_kernels.cpp +++ b/test/solver/gcr_kernels.cpp @@ -74,19 +74,17 @@ class Gcr : public CommonTestFixture { exec_gcr_factory = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(246u).on(exec), + gko::stop::Iteration::build().with_max_iters(246u), gko::stop::ResidualNorm::build() - .with_reduction_factor(value_type{1e-15}) - .on(exec)) + .with_reduction_factor(value_type{1e-15})) .on(exec); ref_gcr_factory = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(246u).on(ref), + gko::stop::Iteration::build().with_max_iters(246u), gko::stop::ResidualNorm::build() - .with_reduction_factor(value_type{1e-15}) - .on(ref)) + .with_reduction_factor(value_type{1e-15})) .on(ref); } diff --git a/test/solver/gmres_kernels.cpp b/test/solver/gmres_kernels.cpp index 5c2541da1a7..7752ff4dda6 100644 --- a/test/solver/gmres_kernels.cpp +++ b/test/solver/gmres_kernels.cpp @@ -70,19 +70,17 @@ class Gmres : public CommonTestFixture { exec_gmres_factory = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(246u).on(exec), + gko::stop::Iteration::build().with_max_iters(246u), gko::stop::ResidualNorm::build() - .with_reduction_factor(value_type{1e-15}) - .on(exec)) + .with_reduction_factor(value_type{1e-15})) .on(exec); ref_gmres_factory = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(246u).on(ref), + gko::stop::Iteration::build().with_max_iters(246u), gko::stop::ResidualNorm::build() - .with_reduction_factor(value_type{1e-15}) - .on(ref)) + .with_reduction_factor(value_type{1e-15})) .on(ref); } diff --git a/test/solver/idr_kernels.cpp b/test/solver/idr_kernels.cpp index 959c857cb71..0019c05b9d4 100644 --- a/test/solver/idr_kernels.cpp +++ b/test/solver/idr_kernels.cpp @@ -76,15 +76,13 @@ class Idr : public CommonTestFixture { exec_idr_factory = Solver::build() .with_deterministic(true) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec); ref_idr_factory = Solver::build() .with_deterministic(true) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(ref); } @@ -295,15 +293,13 @@ TEST_F(Idr, IdrIterationWithComplexSubspaceOneRHSIsEquivalentToRef) Solver::build() .with_deterministic(true) .with_complex_subspace(true) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec); ref_idr_factory = Solver::build() .with_deterministic(true) .with_complex_subspace(true) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(ref); auto ref_solver = ref_idr_factory->generate(mtx); auto exec_solver = exec_idr_factory->generate(d_mtx); @@ -337,15 +333,13 @@ TEST_F(Idr, IdrIterationWithComplexSubspaceMultipleRHSIsEquivalentToRef) Solver::build() .with_deterministic(true) .with_complex_subspace(true) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec); ref_idr_factory = Solver::build() .with_deterministic(true) .with_complex_subspace(true) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(ref); auto exec_solver = exec_idr_factory->generate(d_mtx); auto ref_solver = ref_idr_factory->generate(mtx); diff --git a/test/solver/ir_kernels.cpp b/test/solver/ir_kernels.cpp index c21f6da3f66..81464036c69 100644 --- a/test/solver/ir_kernels.cpp +++ b/test/solver/ir_kernels.cpp @@ -105,13 +105,11 @@ TEST_F(Ir, ApplyIsEquivalentToRef) // both executors auto ir_factory = gko::solver::Ir::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .on(ref); auto d_ir_factory = gko::solver::Ir::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .on(exec); auto solver = ir_factory->generate(std::move(mtx)); auto d_solver = d_ir_factory->generate(std::move(d_mtx)); @@ -134,25 +132,15 @@ TEST_F(Ir, ApplyWithIterativeInnerSolverIsEquivalentToRef) auto ir_factory = gko::solver::Ir::build() - .with_solver( - gko::solver::Gmres::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - ref)) - .on(ref)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(ref)) + .with_solver(gko::solver::Gmres::build().with_criteria( + gko::stop::Iteration::build().with_max_iters(1u).on(ref))) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .on(ref); auto d_ir_factory = gko::solver::Ir::build() - .with_solver( - gko::solver::Gmres::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - exec)) - .on(exec)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(exec)) + .with_solver(gko::solver::Gmres::build().with_criteria( + gko::stop::Iteration::build().with_max_iters(1u).on(exec))) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .on(exec); auto solver = ir_factory->generate(std::move(mtx)); auto d_solver = d_ir_factory->generate(std::move(d_mtx)); @@ -180,14 +168,12 @@ TEST_F(Ir, RichardsonApplyIsEquivalentToRef) // both executors auto ir_factory = gko::solver::Ir::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .with_relaxation_factor(value_type{0.9}) .on(ref); auto d_ir_factory = gko::solver::Ir::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .with_relaxation_factor(value_type{0.9}) .on(exec); auto solver = ir_factory->generate(std::move(mtx)); @@ -210,26 +196,16 @@ TEST_F(Ir, RichardsonApplyWithIterativeInnerSolverIsEquivalentToRef) auto d_b = clone(exec, b); auto ir_factory = gko::solver::Ir::build() - .with_solver( - gko::solver::Gmres::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - ref)) - .on(ref)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(ref)) + .with_solver(gko::solver::Gmres::build().with_criteria( + gko::stop::Iteration::build().with_max_iters(1u).on(ref))) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .with_relaxation_factor(value_type{0.9}) .on(ref); auto d_ir_factory = gko::solver::Ir::build() - .with_solver( - gko::solver::Gmres::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on( - exec)) - .on(exec)) - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(exec)) + .with_solver(gko::solver::Gmres::build().with_criteria( + gko::stop::Iteration::build().with_max_iters(1u).on(exec))) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .with_relaxation_factor(value_type{0.9}) .on(exec); auto solver = ir_factory->generate(std::move(mtx)); @@ -258,14 +234,12 @@ TEST_F(Ir, ApplyWithGivenInitialGuessModeIsEquivalentToRef) auto d_x = clone(exec, x); auto ir_factory = gko::solver::Ir::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(ref)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .with_default_initial_guess(guess) .on(ref); auto d_ir_factory = gko::solver::Ir::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(2u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(2u)) .with_default_initial_guess(guess) .on(exec); auto solver = ir_factory->generate(mtx); diff --git a/test/solver/solver.cpp b/test/solver/solver.cpp index b6f228c13f5..6bb59507f17 100644 --- a/test/solver/solver.cpp +++ b/test/solver/solver.cpp @@ -101,9 +101,7 @@ struct SimpleSolverTest { gko::size_type iteration_count, bool check_residual = true) { return solver_type::build().with_criteria( - gko::stop::Iteration::build() - .with_max_iters(iteration_count) - .on(exec), + gko::stop::Iteration::build().with_max_iters(iteration_count), check_residual ? gko::stop::ResidualNorm::build() .with_baseline(gko::stop::mode::absolute) .with_reduction_factor(1e-30) @@ -116,8 +114,7 @@ struct SimpleSolverTest { gko::size_type iteration_count, bool check_residual = true) { return build(exec, iteration_count, check_residual) - .with_preconditioner( - precond_type::build().with_max_block_size(1u).on(exec)); + .with_preconditioner(precond_type::build().with_max_block_size(1u)); } static const gko::LinOp* get_preconditioner( @@ -185,8 +182,7 @@ struct Idr : SimpleSolverTest> { gko::size_type iteration_count, bool check_residual = true) { return build(exec, iteration_count, check_residual) - .with_preconditioner( - precond_type::build().with_max_block_size(1u).on(exec)); + .with_preconditioner(precond_type::build().with_max_block_size(1u)); } }; @@ -200,8 +196,7 @@ struct Ir : SimpleSolverTest> { { return SimpleSolverTest>::build( exec, iteration_count, check_residual) - .with_solver( - precond_type::build().with_max_block_size(1u).on(exec)); + .with_solver(precond_type::build().with_max_block_size(1u)); } static const gko::LinOp* get_preconditioner( @@ -232,8 +227,7 @@ struct CbGmres : SimpleSolverTest> { gko::size_type iteration_count, bool check_residual = true) { return build(exec, iteration_count, check_residual) - .with_preconditioner( - precond_type::build().with_max_block_size(1u).on(exec)); + .with_preconditioner(precond_type::build().with_max_block_size(1u)); } }; @@ -254,8 +248,7 @@ struct Gmres : SimpleSolverTest> { gko::size_type iteration_count, bool check_residual = true) { return build(exec, iteration_count, check_residual) - .with_preconditioner( - precond_type::build().with_max_block_size(1u).on(exec)); + .with_preconditioner(precond_type::build().with_max_block_size(1u)); } }; @@ -277,8 +270,7 @@ struct FGmres : SimpleSolverTest> { gko::size_type iteration_count, bool check_residual = true) { return build(exec, iteration_count, check_residual) - .with_preconditioner( - precond_type::build().with_max_block_size(1u).on(exec)) + .with_preconditioner(precond_type::build().with_max_block_size(1u)) .with_flexible(true); } }; @@ -300,8 +292,7 @@ struct Gcr : SimpleSolverTest> { gko::size_type iteration_count, bool check_residual = true) { return build(exec, iteration_count, check_residual) - .with_preconditioner( - precond_type::build().with_max_block_size(1u).on(exec)); + .with_preconditioner(precond_type::build().with_max_block_size(1u)); } }; diff --git a/test/test_install/test_install.cpp b/test/test_install/test_install.cpp index 2016f00dade..90791659cea 100644 --- a/test/test_install/test_install.cpp +++ b/test/test_install/test_install.cpp @@ -104,11 +104,9 @@ void check_solver(std::shared_ptr exec, auto solver_gen = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(num_iters).on( - exec), - gko::stop::ResidualNorm<>::build() - .with_reduction_factor(reduction_factor) - .on(exec)) + gko::stop::Iteration::build().with_max_iters(num_iters), + gko::stop::ResidualNorm<>::build().with_reduction_factor( + reduction_factor)) .on(exec); #if HAS_REFERENCE A->read(A_raw); @@ -126,11 +124,9 @@ void check_solver(std::shared_ptr exec, auto solver_gen_ref = Solver::build() .with_criteria( - gko::stop::Iteration::build().with_max_iters(num_iters).on( - exec_ref), - gko::stop::ResidualNorm<>::build() - .with_reduction_factor(reduction_factor) - .on(exec_ref)) + gko::stop::Iteration::build().with_max_iters(num_iters), + gko::stop::ResidualNorm<>::build().with_reduction_factor( + reduction_factor)) .on(exec_ref); auto x_ref = gko::clone(exec_ref, x); solver_gen->generate(A_ref)->apply(b, x_ref); @@ -480,8 +476,7 @@ int main() using Solver = gko::solver::Ir<>; auto test = Solver::build() - .with_criteria( - gko::stop::Iteration::build().with_max_iters(1u).on(exec)) + .with_criteria(gko::stop::Iteration::build().with_max_iters(1u)) .on(exec); }