Skip to content

Commit

Permalink
use macro and move to proper place
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed May 13, 2024
1 parent f2645fc commit d51c44c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 34 deletions.
37 changes: 3 additions & 34 deletions core/config/multigrid_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,20 @@
#include <ginkgo/core/config/registry.hpp>
#include <ginkgo/core/multigrid/fixed_coarsening.hpp>
#include <ginkgo/core/multigrid/pgm.hpp>
#include <ginkgo/core/solver/multigrid.hpp>


#include "core/config/config_helper.hpp"
#include "core/config/dispatch.hpp"
#include "core/config/parse_marco.hpp"
#include "core/config/type_descriptor_helper.hpp"


namespace gko {
namespace config {


template <>
deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Pgm>(
const pnode& config, const registry& context,
const gko::config::type_descriptor& td)
{
auto updated = update_type(config, td);
return dispatch<gko::LinOpFactory, multigrid::Pgm>(
config, context, updated,
make_type_selector(updated.get_value_typestr(), value_type_list()),
make_type_selector(updated.get_index_typestr(), index_type_list()));
}

template <>
deferred_factory_parameter<gko::LinOpFactory>
parse<LinOpFactoryType::FixedCoarsening>(const pnode& config,
const registry& context,
const gko::config::type_descriptor& td)
{
auto updated = update_type(config, td);
return dispatch<gko::LinOpFactory, multigrid::FixedCoarsening>(
config, context, updated,
make_type_selector(updated.get_value_typestr(), value_type_list()),
make_type_selector(updated.get_index_typestr(), index_type_list()));
}

template <>
deferred_factory_parameter<gko::LinOpFactory>
parse<LinOpFactoryType::Multigrid>(const pnode& config, const registry& context,
const gko::config::type_descriptor& td)
{
auto updated = update_type(config, td);
return solver::Multigrid::parse(config, context, updated);
}
PARSE_VALUE_AND_INDEX_TYPE(Pgm, gko::multigrid::Pgm);
PARSE_VALUE_AND_INDEX_TYPE(FixedCoarsening, gko::multigrid::FixedCoarsening);


} // namespace config
Expand Down
11 changes: 11 additions & 0 deletions core/config/solver_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <ginkgo/core/solver/gmres.hpp>
#include <ginkgo/core/solver/idr.hpp>
#include <ginkgo/core/solver/ir.hpp>
#include <ginkgo/core/solver/multigrid.hpp>
#include <ginkgo/core/solver/triangular.hpp>


Expand Down Expand Up @@ -44,5 +45,15 @@ PARSE_VALUE_AND_INDEX_TYPE(LowerTrs, gko::solver::LowerTrs);
PARSE_VALUE_AND_INDEX_TYPE(UpperTrs, gko::solver::UpperTrs);


template <>
deferred_factory_parameter<gko::LinOpFactory>
parse<LinOpFactoryType::Multigrid>(const pnode& config, const registry& context,
const gko::config::type_descriptor& td)
{
auto updated = update_type(config, td);
return solver::Multigrid::parse(config, context, updated);
}


} // namespace config
} // namespace gko

0 comments on commit d51c44c

Please sign in to comment.