Skip to content

Commit

Permalink
set limit on inner solver iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed May 4, 2020
1 parent f6866e4 commit 81693d0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/multiprecision-ir/multiprecision-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ int main(int argc, char *argv[])
using solver_mtx = gko::matrix::Csr<SolverType, IndexType>;
using cg = gko::solver::Cg<SolverType>;

gko::size_type max_iters = 10000u;
gko::size_type max_outer_iters = 100u;
gko::size_type max_inner_iters = 100u;
gko::remove_complex<ValueType> outer_reduction_factor = 1e-12;
gko::remove_complex<SolverType> inner_reduction_factor = 1e-2;

Expand Down Expand Up @@ -112,6 +113,9 @@ int main(int argc, char *argv[])
cg::build()
.with_criteria(gko::stop::ResidualNormReduction<SolverType>::build()
.with_reduction_factor(inner_reduction_factor)
.on(exec),
gko::stop::Iteration::build()
.with_max_iters(max_inner_iters)
.on(exec))
.on(exec)
->generate(give(solver_A));
Expand All @@ -134,7 +138,7 @@ int main(int argc, char *argv[])
auto res = exec->copy_val_to_host(res_vec->get_const_values());

// break if we exceed the number of iterations or have converged
if (iter > max_iters || res / initres < outer_reduction_factor) {
if (iter > max_outer_iters || res / initres < outer_reduction_factor) {
break;
}

Expand Down

0 comments on commit 81693d0

Please sign in to comment.