Skip to content

Commit

Permalink
rename type list
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Dec 3, 2024
1 parent e2782d1 commit f048ddb
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 35 deletions.
6 changes: 3 additions & 3 deletions core/config/dispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ deferred_factory_parameter<ReturnType> dispatch(
}
}

using value_type_list =
using value_type_list_base =
syn::type_list<double, float, std::complex<double>, std::complex<float>>;

#if GINKGO_ENABLE_HALF
using value_type_list_with_half =
using value_type_list =
syn::type_list<double, float, half, std::complex<double>,
std::complex<float>, std::complex<half>>;
#else
using value_type_list_with_half = value_type_list;
using value_type_list = value_type_list_base;
#endif // GINKGO_ENABLE_HALF

using index_type_list = syn::type_list<int32, int64>;
Expand Down
21 changes: 11 additions & 10 deletions core/config/parse_macro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@


// for value_type only
#define GKO_PARSE_VALUE_TYPE_BASE_(_type, _configurator, _value_type_list) \
#define GKO_PARSE_VALUE_TYPE_BASE_(_type, _configurator, \
_value_type_list_base) \
template <> \
deferred_factory_parameter<gko::LinOpFactory> \
parse<gko::config::LinOpFactoryType::_type>( \
Expand All @@ -28,22 +29,22 @@
return gko::config::dispatch<gko::LinOpFactory, _configurator>( \
config, context, updated, \
gko::config::make_type_selector(updated.get_value_typestr(), \
_value_type_list)); \
_value_type_list_base)); \
} \
static_assert(true, \
"This assert is used to counter the false positive extra " \
"semi-colon warnings")
#define GKO_PARSE_VALUE_TYPE_BASE(_type, _configurator) \
GKO_PARSE_VALUE_TYPE_BASE_(_type, _configurator, \
gko::config::value_type_list())
gko::config::value_type_list_base())

#define GKO_PARSE_VALUE_TYPE(_type, _configurator) \
GKO_PARSE_VALUE_TYPE_BASE_(_type, _configurator, \
gko::config::value_type_list_with_half())
gko::config::value_type_list())

// for value_type and index_type
#define GKO_PARSE_VALUE_AND_INDEX_TYPE_BASE_(_type, _configurator, \
_value_type_list) \
_value_type_list_base) \
template <> \
deferred_factory_parameter<gko::LinOpFactory> \
parse<gko::config::LinOpFactoryType::_type>( \
Expand All @@ -55,7 +56,7 @@
return gko::config::dispatch<gko::LinOpFactory, _configurator>( \
config, context, updated, \
gko::config::make_type_selector(updated.get_value_typestr(), \
_value_type_list), \
_value_type_list_base), \
gko::config::make_type_selector(updated.get_index_typestr(), \
gko::config::index_type_list())); \
} \
Expand All @@ -65,11 +66,11 @@

#define GKO_PARSE_VALUE_AND_INDEX_TYPE_BASE(_type, _configurator) \
GKO_PARSE_VALUE_AND_INDEX_TYPE_BASE_(_type, _configurator, \
gko::config::value_type_list())
gko::config::value_type_list_base())

#define GKO_PARSE_VALUE_AND_INDEX_TYPE(_type, _configurator) \
GKO_PARSE_VALUE_AND_INDEX_TYPE_BASE_( \
_type, _configurator, gko::config::value_type_list_with_half())
#define GKO_PARSE_VALUE_AND_INDEX_TYPE(_type, _configurator) \
GKO_PARSE_VALUE_AND_INDEX_TYPE_BASE_(_type, _configurator, \
gko::config::value_type_list())


#endif // GKO_CORE_CONFIG_PARSE_MACRO_HPP_
12 changes: 4 additions & 8 deletions core/config/preconditioner_ic_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,24 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Ic>(
return dispatch<gko::LinOpFactory,
IcHelper2<solver::LowerTrs>::Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
make_type_selector(updated.get_value_typestr(), value_type_list()),
make_type_selector(updated.get_index_typestr(), index_type_list()));
} else if (str == "solver::Ir") {
return dispatch<gko::LinOpFactory, IcHelper1<solver::Ir>::Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
make_type_selector(updated.get_value_typestr(), value_type_list()),
make_type_selector(updated.get_index_typestr(), index_type_list()));
} else if (str == "preconditioner::LowerIsai") {
return dispatch<gko::LinOpFactory,
IcHelper2<preconditioner::LowerIsai>::Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
make_type_selector(updated.get_value_typestr(), value_type_list()),
make_type_selector(updated.get_index_typestr(), index_type_list()));
} else if (str == "solver::Gmres") {
return dispatch<gko::LinOpFactory,
IcHelper1<solver::Gmres>::Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
make_type_selector(updated.get_value_typestr(), value_type_list()),
make_type_selector(updated.get_index_typestr(), index_type_list()));
} else {
GKO_INVALID_CONFIG_VALUE("l_solver_type", str);
Expand Down
8 changes: 4 additions & 4 deletions core/config/preconditioner_ilu_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Ilu>(
ReverseApply::value>::template Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
value_type_list()),
make_type_selector(updated.get_index_typestr(),
index_type_list()));
} else if (str == "solver::Ir") {
Expand All @@ -104,7 +104,7 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Ilu>(
ReverseApply::value>::template Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
value_type_list()),
make_type_selector(updated.get_index_typestr(),
index_type_list()));
} else if (str == "preconditioner::LowerIsai") {
Expand All @@ -114,7 +114,7 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Ilu>(
ReverseApply::value>::template Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
value_type_list()),
make_type_selector(updated.get_index_typestr(),
index_type_list()));
} else if (str == "solver::Gmres") {
Expand All @@ -124,7 +124,7 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Ilu>(
ReverseApply::value>::template Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
value_type_list()),
make_type_selector(updated.get_index_typestr(),
index_type_list()));
} else {
Expand Down
8 changes: 4 additions & 4 deletions core/config/preconditioner_isai_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Isai>(
IsaiHelper<preconditioner::isai_type::lower>::Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
value_type_list()),
make_type_selector(updated.get_index_typestr(),
index_type_list()));
} else if (str == "upper") {
Expand All @@ -57,7 +57,7 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Isai>(
IsaiHelper<preconditioner::isai_type::upper>::Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
value_type_list()),
make_type_selector(updated.get_index_typestr(),
index_type_list()));
} else if (str == "general") {
Expand All @@ -66,7 +66,7 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Isai>(
IsaiHelper<preconditioner::isai_type::general>::Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
value_type_list()),
make_type_selector(updated.get_index_typestr(),
index_type_list()));
} else if (str == "spd") {
Expand All @@ -75,7 +75,7 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Isai>(
IsaiHelper<preconditioner::isai_type::spd>::Configurator>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()),
value_type_list()),
make_type_selector(updated.get_index_typestr(),
index_type_list()));
} else {
Expand Down
6 changes: 4 additions & 2 deletions core/config/schwarz_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Schwarz>(
gko::LinOpFactory,
gko::experimental::distributed::preconditioner::Schwarz>(
config, context, updated,
make_type_selector(updated.get_value_typestr(), value_type_list()),
make_type_selector(updated.get_value_typestr(),
value_type_list_base()),
make_type_selector(updated.get_index_typestr(),
syn::type_list<int32>()),
make_type_selector(updated.get_global_index_typestr(),
Expand All @@ -39,7 +40,8 @@ deferred_factory_parameter<gko::LinOpFactory> parse<LinOpFactoryType::Schwarz>(
gko::LinOpFactory,
gko::experimental::distributed::preconditioner::Schwarz>(
config, context, updated,
make_type_selector(updated.get_value_typestr(), value_type_list()),
make_type_selector(updated.get_value_typestr(),
value_type_list_base()),
make_type_selector(updated.get_index_typestr(),
syn::type_list<int64>()),
make_type_selector(updated.get_global_index_typestr(),
Expand Down
6 changes: 2 additions & 4 deletions core/config/stop_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ deferred_factory_parameter<stop::CriterionFactory> configure_residual(
auto updated = update_type(config, td);
return dispatch<stop::CriterionFactory, ResidualNormConfigurer>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()));
make_type_selector(updated.get_value_typestr(), value_type_list()));
}


Expand Down Expand Up @@ -120,8 +119,7 @@ deferred_factory_parameter<stop::CriterionFactory> configure_implicit_residual(
auto updated = update_type(config, td);
return dispatch<stop::CriterionFactory, ImplicitResidualNormConfigurer>(
config, context, updated,
make_type_selector(updated.get_value_typestr(),
value_type_list_with_half()));
make_type_selector(updated.get_value_typestr(), value_type_list()));
}


Expand Down

0 comments on commit f048ddb

Please sign in to comment.