Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 148 additions & 4 deletions benchmark/utils/preconditioners.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

Expand All @@ -22,7 +22,11 @@ DEFINE_string(preconditioners, "none",
"A comma-separated list of preconditioners to use. "
"Supported values are: none, jacobi, paric, parict, parilu, "
"parilut, ic, ilu, paric-isai, parict-isai, parilu-isai, "
"parilut-isai, ic-isai, ilu-isai, sor, overhead");
"parilut-isai, ic-isai, ilu-isai, sor, overhead"
#ifdef GINKGO_BUILD_MPI
", schwarz-jacobi, schwarz-ilu, schwarz-ic, schwarz-lu, dist-mg"
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't mg just be its own thing? You can use it also without mpi.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it should just be schwarz and then another option to set the local preconditioner for schwarz.

);

DEFINE_uint32(parilu_iterations, 5,
"The number of iterations for ParIC(T)/ParILU(T)");
Expand Down Expand Up @@ -55,6 +59,18 @@ DEFINE_double(sor_relaxation_factor, 1.0,
DEFINE_bool(sor_symmetric, false,
"Apply the SOR preconditioner symmetrically, i.e. use SSOR");

DEFINE_bool(pgm_deterministic, false,
"Use deterministic computation of the aggregated group within PGM");

DEFINE_uint32(
mg_max_num_levels, false,
"The maximum number of levels to use for the Multigrid preconditioner");

DEFINE_double(mg_tolerance, false, "The tolerance for the coarse solver");

DEFINE_uint32(mg_max_iters, false,
"The max number of iterations for the coarse solver");

Comment on lines +65 to +72
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, this looks like we reached the limit of what we can do through the CLI. I think for now this is fine, but we should consider in the long term to also allow our json config to define these parameters.


// parses the Jacobi storage optimization command line argument
gko::precision_reduction parse_storage_optimization(const std::string& flag)
Expand Down Expand Up @@ -307,12 +323,140 @@ const std::map<std::string, std::function<std::unique_ptr<gko::LinOpFactory>(
.with_symmetric(FLAGS_sor_symmetric)
.on(exec);
}},
{"overhead", [](std::shared_ptr<const gko::Executor> exec) {
{"overhead",
[](std::shared_ptr<const gko::Executor> exec) {
return gko::Overhead<etype>::build()
.with_criteria(gko::stop::ResidualNorm<etype>::build()
.with_reduction_factor(rc_etype{}))
.on(exec);
}}};
}}
#ifdef GINKGO_BUILD_MPI
,
{"schwarz-jacobi",
[](std::shared_ptr<const gko::Executor> exec) {
return gko::experimental::distributed::preconditioner::Schwarz<
etype>::build()
.with_local_solver(
gko::preconditioner::Jacobi<etype>::build()
.with_max_block_size(FLAGS_jacobi_max_block_size)
.with_storage_optimization(
parse_storage_optimization(FLAGS_jacobi_storage))
.with_accuracy(
static_cast<rc_etype>(FLAGS_jacobi_accuracy))
.with_skip_sorting(true)
.on(exec))
.on(exec);
}},
{"schwarz-general-isai",
[](std::shared_ptr<const gko::Executor> exec) {
return gko::experimental::distributed::preconditioner::Schwarz<
etype, itype>::build()
.with_local_solver(
gko::preconditioner::GeneralIsai<etype, itype>::build()
.with_sparsity_power(FLAGS_isai_power)
.on(exec))
.on(exec);
}},
{"schwarz-spd-isai",
[](std::shared_ptr<const gko::Executor> exec) {
return gko::experimental::distributed::preconditioner::Schwarz<
etype, itype>::build()
.with_local_solver(
gko::preconditioner::SpdIsai<etype, itype>::build()
.with_sparsity_power(FLAGS_isai_power)
.on(exec))
.on(exec);
}},
{"schwarz-ilu",
[](std::shared_ptr<const gko::Executor> exec) {
auto fact =
gko::share(gko::factorization::Ilu<etype, itype>::build()
.with_skip_sorting(true)
.on(exec));
return gko::experimental::distributed::preconditioner::Schwarz<
etype, itype>::build()
.with_local_solver(gko::preconditioner::Ilu<
gko::solver::LowerTrs<etype, itype>,
gko::solver::UpperTrs<etype, itype>,
false, itype>::build()
.with_factorization(fact)
.on(exec))
.on(exec);
}},
{"schwarz-ic",
[](std::shared_ptr<const gko::Executor> exec) {
auto fact =
gko::share(gko::factorization::Ic<etype, itype>::build()
.with_skip_sorting(true)
.on(exec));
return gko::experimental::distributed::preconditioner::Schwarz<
etype, itype>::build()
.with_local_solver(
gko::preconditioner::Ic<
gko::solver::LowerTrs<etype, itype>, itype>::build()
.with_factorization(fact)
.on(exec))
.on(exec);
}},
{"schwarz-lu",
[](std::shared_ptr<const gko::Executor> exec) {
auto fact = gko::share(
gko::experimental::factorization::Lu<etype, itype>::build().on(
exec));
return gko::experimental::distributed::preconditioner::Schwarz<
etype, itype>::build()
.with_local_solver(
gko::experimental::solver::Direct<etype, itype>::build()
.with_factorization(fact)
.on(exec))
.on(exec);
}},
{"dist-mg",
[](std::shared_ptr<const gko::Executor> exec) {
using ir = gko::solver::Ir<etype>;
using schwarz =
gko::experimental::distributed::preconditioner::Schwarz<etype,
itype>;
using bj = gko::preconditioner::Jacobi<etype, itype>;
auto iter_stop = gko::share(gko::stop::Iteration::build()
.with_max_iters(FLAGS_mg_max_iters)
.on(exec));
auto tol_stop =
gko::share(gko::stop::ResidualNorm<etype>::build()
.with_baseline(gko::stop::mode::absolute)
.with_reduction_factor(FLAGS_mg_tolerance)
.on(exec));
auto coarsest_solver_gen = gko::share(
ir::build()
.with_solver(schwarz::build().with_local_solver(
bj::build().with_max_block_size(1u).with_skip_sorting(
true)))
.with_relaxation_factor(static_cast<etype>(0.9))
.with_criteria(
gko::stop::Iteration::build().with_max_iters(4u))
.on(exec));
auto pre_smoother = gko::share(
ir::build()
.with_solver(schwarz::build().with_local_solver(
bj::build().with_max_block_size(1u).with_skip_sorting(
true)))
.with_relaxation_factor(static_cast<etype>(0.9))
.with_criteria(
gko::stop::Iteration::build().with_max_iters(1u))
.on(exec));
return gko::solver::Multigrid::build()
.with_mg_level(
gko::multigrid::Pgm<etype, itype>::build()
.with_deterministic(FLAGS_pgm_deterministic))
.with_criteria(iter_stop, tol_stop)
.with_pre_smoother(pre_smoother)
.with_post_uses_pre(true)
.with_max_levels(FLAGS_mg_max_num_levels)
.with_coarsest_solver(coarsest_solver_gen)
.on(exec);
}}
#endif
};


#endif // GKO_BENCHMARK_UTILS_PRECONDITIONERS_HPP_
Loading