-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge Add solver config except for the multigrid
This PR adds the solver file config except for the multigrid part Related PR: #1395
- Loading branch information
Showing
37 changed files
with
1,282 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#ifndef GKO_CORE_CONFIG_PARSE_MACRO_HPP_ | ||
#define GKO_CORE_CONFIG_PARSE_MACRO_HPP_ | ||
|
||
|
||
#include <ginkgo/core/config/config.hpp> | ||
#include <ginkgo/core/config/registry.hpp> | ||
#include <ginkgo/core/config/type_descriptor.hpp> | ||
|
||
|
||
#include "core/config/config_helper.hpp" | ||
#include "core/config/dispatch.hpp" | ||
#include "core/config/type_descriptor_helper.hpp" | ||
|
||
|
||
// for value_type only | ||
#define GKO_PARSE_VALUE_TYPE(_type, _configurator) \ | ||
template <> \ | ||
deferred_factory_parameter<gko::LinOpFactory> \ | ||
parse<gko::config::LinOpFactoryType::_type>( \ | ||
const gko::config::pnode& config, \ | ||
const gko::config::registry& context, \ | ||
const gko::config::type_descriptor& td) \ | ||
{ \ | ||
auto updated = gko::config::update_type(config, td); \ | ||
return gko::config::dispatch<gko::LinOpFactory, _configurator>( \ | ||
config, context, updated, \ | ||
gko::config::make_type_selector(updated.get_value_typestr(), \ | ||
gko::config::value_type_list())); \ | ||
} \ | ||
static_assert(true, \ | ||
"This assert is used to counter the false positive extra " \ | ||
"semi-colon warnings") | ||
|
||
|
||
// for value_type and index_type | ||
#define GKO_PARSE_VALUE_AND_INDEX_TYPE(_type, _configurator) \ | ||
template <> \ | ||
deferred_factory_parameter<gko::LinOpFactory> \ | ||
parse<gko::config::LinOpFactoryType::_type>( \ | ||
const gko::config::pnode& config, \ | ||
const gko::config::registry& context, \ | ||
const gko::config::type_descriptor& td) \ | ||
{ \ | ||
auto updated = gko::config::update_type(config, td); \ | ||
return gko::config::dispatch<gko::LinOpFactory, _configurator>( \ | ||
config, context, updated, \ | ||
gko::config::make_type_selector(updated.get_value_typestr(), \ | ||
gko::config::value_type_list()), \ | ||
gko::config::make_type_selector(updated.get_index_typestr(), \ | ||
gko::config::index_type_list())); \ | ||
} \ | ||
static_assert(true, \ | ||
"This assert is used to counter the false positive extra " \ | ||
"semi-colon warnings") | ||
|
||
|
||
#endif // GKO_CORE_CONFIG_PARSE_MACRO_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <ginkgo/core/base/exception_helpers.hpp> | ||
#include <ginkgo/core/config/config.hpp> | ||
#include <ginkgo/core/config/registry.hpp> | ||
#include <ginkgo/core/solver/bicg.hpp> | ||
#include <ginkgo/core/solver/bicgstab.hpp> | ||
#include <ginkgo/core/solver/cb_gmres.hpp> | ||
#include <ginkgo/core/solver/cg.hpp> | ||
#include <ginkgo/core/solver/cgs.hpp> | ||
#include <ginkgo/core/solver/direct.hpp> | ||
#include <ginkgo/core/solver/fcg.hpp> | ||
#include <ginkgo/core/solver/gcr.hpp> | ||
#include <ginkgo/core/solver/gmres.hpp> | ||
#include <ginkgo/core/solver/idr.hpp> | ||
#include <ginkgo/core/solver/ir.hpp> | ||
#include <ginkgo/core/solver/triangular.hpp> | ||
|
||
|
||
#include "core/config/config_helper.hpp" | ||
#include "core/config/dispatch.hpp" | ||
#include "core/config/parse_macro.hpp" | ||
#include "core/config/solver_config.hpp" | ||
|
||
|
||
namespace gko { | ||
namespace config { | ||
|
||
|
||
GKO_PARSE_VALUE_TYPE(Cg, gko::solver::Cg); | ||
GKO_PARSE_VALUE_TYPE(Bicg, gko::solver::Bicg); | ||
GKO_PARSE_VALUE_TYPE(Bicgstab, gko::solver::Bicgstab); | ||
GKO_PARSE_VALUE_TYPE(Cgs, gko::solver::Cgs); | ||
GKO_PARSE_VALUE_TYPE(Fcg, gko::solver::Fcg); | ||
GKO_PARSE_VALUE_TYPE(Ir, gko::solver::Ir); | ||
GKO_PARSE_VALUE_TYPE(Idr, gko::solver::Idr); | ||
GKO_PARSE_VALUE_TYPE(Gcr, gko::solver::Gcr); | ||
GKO_PARSE_VALUE_TYPE(Gmres, gko::solver::Gmres); | ||
GKO_PARSE_VALUE_TYPE(CbGmres, gko::solver::CbGmres); | ||
GKO_PARSE_VALUE_AND_INDEX_TYPE(Direct, gko::experimental::solver::Direct); | ||
GKO_PARSE_VALUE_AND_INDEX_TYPE(LowerTrs, gko::solver::LowerTrs); | ||
GKO_PARSE_VALUE_AND_INDEX_TYPE(UpperTrs, gko::solver::UpperTrs); | ||
|
||
|
||
} // namespace config | ||
} // namespace gko |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#ifndef GKO_CORE_CONFIG_SOLVER_CONFIG_HPP_ | ||
#define GKO_CORE_CONFIG_SOLVER_CONFIG_HPP_ | ||
|
||
|
||
#include <ginkgo/core/config/config.hpp> | ||
#include <ginkgo/core/config/registry.hpp> | ||
|
||
|
||
#include "core/config/config_helper.hpp" | ||
#include "core/config/dispatch.hpp" | ||
|
||
namespace gko { | ||
namespace config { | ||
|
||
|
||
template <typename SolverParam> | ||
inline void common_solver_parse(SolverParam& params, const pnode& config, | ||
const registry& context, | ||
type_descriptor td_for_child) | ||
{ | ||
if (auto& obj = config.get("generated_preconditioner")) { | ||
params.with_generated_preconditioner( | ||
gko::config::get_stored_obj<const LinOp>(obj, context)); | ||
} | ||
if (auto& obj = config.get("criteria")) { | ||
params.with_criteria( | ||
gko::config::parse_or_get_factory_vector< | ||
const stop::CriterionFactory>(obj, context, td_for_child)); | ||
} | ||
if (auto& obj = config.get("preconditioner")) { | ||
params.with_preconditioner( | ||
gko::config::parse_or_get_factory<const LinOpFactory>( | ||
obj, context, td_for_child)); | ||
} | ||
} | ||
|
||
|
||
} // namespace config | ||
} // namespace gko | ||
|
||
#endif // GKO_CORE_CONFIG_SOLVER_CONFIG_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#ifndef GKO_CORE_CONFIG_TRISOLVER_CONFIG_HPP_ | ||
#define GKO_CORE_CONFIG_TRISOLVER_CONFIG_HPP_ | ||
|
||
|
||
#include <ginkgo/core/config/config.hpp> | ||
#include <ginkgo/core/config/registry.hpp> | ||
#include <ginkgo/core/solver/triangular.hpp> | ||
|
||
|
||
#include "core/config/config_helper.hpp" | ||
#include "core/config/dispatch.hpp" | ||
|
||
namespace gko { | ||
namespace config { | ||
|
||
|
||
template <typename SolverParam> | ||
inline void common_trisolver_parse(SolverParam& params, const pnode& config, | ||
const registry& context, | ||
type_descriptor td_for_child) | ||
{ | ||
if (auto& obj = config.get("num_rhs")) { | ||
params.with_num_rhs(gko::config::get_value<size_type>(obj)); | ||
} | ||
if (auto& obj = config.get("unit_diagonal")) { | ||
params.with_unit_diagonal(gko::config::get_value<bool>(obj)); | ||
} | ||
if (auto& obj = config.get("algorithm")) { | ||
using gko::solver::trisolve_algorithm; | ||
auto str = obj.get_string(); | ||
if (str == "sparselib") { | ||
params.with_algorithm(trisolve_algorithm::sparselib); | ||
} else if (str == "syncfree") { | ||
params.with_algorithm(trisolve_algorithm::syncfree); | ||
} else { | ||
GKO_INVALID_STATE("Wrong value for algorithm"); | ||
} | ||
} | ||
} | ||
|
||
|
||
} // namespace config | ||
} // namespace gko | ||
|
||
#endif // GKO_CORE_CONFIG_TRISOLVER_CONFIG_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.