Skip to content

Commit

Permalink
Change (again) the way to get rid of Boost.property_tree dependency
Browse files Browse the repository at this point in the history
Instead of declaring AMGCL_USE_PROPERTY_TREE to enable runtime parameters,
users now should declare AMGCL_NO_BOOST to disable the functionality.

If AMGCL_NO_BOOST is declared, and one of runtime headers is included,
compilation will fail with a meaningful error.

See KratosMultiphysics/Kratos#2570
  • Loading branch information
ddemidov committed Jul 26, 2018
1 parent 9faf485 commit f22a189
Show file tree
Hide file tree
Showing 51 changed files with 88 additions and 102 deletions.
2 changes: 1 addition & 1 deletion amgcl/amg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class amg {
#endif
{}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, coarsening),
AMGCL_PARAMS_IMPORT_CHILD(p, relax),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/backend/block_crs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct block_crs {

params(size_t block_size = 4) : block_size(block_size) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, block_size)
{
Expand Down
2 changes: 1 addition & 1 deletion amgcl/backend/cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ struct cuda {

params(cusparseHandle_t handle = 0) : cusparse_handle(handle) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, cusparse_handle)
{
Expand Down
2 changes: 1 addition & 1 deletion amgcl/backend/hpx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ struct HPX {

params() : grain_size(4096) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, grain_size)
{
Expand Down
2 changes: 1 addition & 1 deletion amgcl/backend/vexcl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct vexcl {

params() : fast_matrix_setup(true) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, fast_matrix_setup)
{
Expand Down
2 changes: 1 addition & 1 deletion amgcl/coarsening/aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct aggregation {

params() : over_interp(1.5f) { }

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_CHILD(p, nullspace),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/coarsening/plain_aggregates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct plain_aggregates {

params() : eps_strong(0.08f) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, eps_strong)
{
Expand Down
2 changes: 1 addition & 1 deletion amgcl/coarsening/pointwise_aggregates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class pointwise_aggregates {

params() : block_size(1) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: plain_aggregates::params(p),
AMGCL_PARAMS_IMPORT_VALUE(p, block_size)
Expand Down
2 changes: 1 addition & 1 deletion amgcl/coarsening/ruge_stuben.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct ruge_stuben {

params() : eps_strong(0.25f), do_trunc(true), eps_trunc(0.2f) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, eps_strong),
AMGCL_PARAMS_IMPORT_VALUE(p, do_trunc),
Expand Down
11 changes: 5 additions & 6 deletions amgcl/coarsening/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ THE SOFTWARE.
#include <stdexcept>
#include <type_traits>

#include <amgcl/util.hpp>
#ifndef AMGCL_USE_PROPERTY_TREE
# error \
Runtime interface relies on Boost.PropertyTree! \
Either define AMGCL_USE_PROPERTY_TREE, or \
include <boost/property_tree/ptree.hpp> before any of the amgcl headers.
#ifdef AMGCL_NO_BOOST
# error Runtime interface relies on Boost.PropertyTree!
#endif

#include <boost/property_tree/ptree.hpp>

#include <amgcl/util.hpp>
#include <amgcl/backend/interface.hpp>
#include <amgcl/coarsening/ruge_stuben.hpp>
#include <amgcl/coarsening/aggregation.hpp>
Expand Down
2 changes: 1 addition & 1 deletion amgcl/coarsening/smoothed_aggr_emin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct smoothed_aggr_emin {

params() {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_CHILD(p, nullspace)
Expand Down
2 changes: 1 addition & 1 deletion amgcl/coarsening/smoothed_aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct smoothed_aggregation {

params() : relax(1.0f), estimate_spectral_radius(false), power_iters(0) { }

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_CHILD(p, nullspace),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/coarsening/tentative_prolongation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct nullspace_params {

nullspace_params() : cols(0) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
nullspace_params(const boost::property_tree::ptree &p)
: cols(p.get("cols", nullspace_params().cols))
{
Expand Down
4 changes: 2 additions & 2 deletions amgcl/make_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class make_solver {

params() {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, precond),
AMGCL_PARAMS_IMPORT_CHILD(p, solver)
Expand Down Expand Up @@ -191,7 +191,7 @@ class make_solver {
return P.system_matrix();
}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
/// Stores the parameters used during construction into the property tree \p p.
void get_params(boost::property_tree::ptree &p) const {
prm.get(p);
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/amg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class amg {
npre(1), npost(1), ncycle(1), pre_cycles(1)
{}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, coarsening),
AMGCL_PARAMS_IMPORT_CHILD(p, relax),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/coarsening/aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct aggregation {

params() : over_interp(1.5f) { }

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_VALUE(p, over_interp)
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/coarsening/pmis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct pmis {

params() : eps_strong(0.08), block_size(1) { }

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, eps_strong),
AMGCL_PARAMS_IMPORT_VALUE(p, block_size)
Expand Down
11 changes: 5 additions & 6 deletions amgcl/mpi/coarsening/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ THE SOFTWARE.
* \brief Runtime wrapper for distributed coarsening schemes.
*/

#include <amgcl/util.hpp>
#ifndef AMGCL_USE_PROPERTY_TREE
# error \
Runtime interface relies on Boost.PropertyTree! \
Either define AMGCL_USE_PROPERTY_TREE, or \
include <boost/property_tree/ptree.hpp> before any of the amgcl headers.
#ifdef AMGCL_NO_BOOST
# error Runtime interface relies on Boost.PropertyTree!
#endif

#include <boost/property_tree/ptree.hpp>

#include <amgcl/util.hpp>
#include <amgcl/mpi/util.hpp>
#include <amgcl/mpi/distributed_matrix.hpp>
#include <amgcl/mpi/coarsening/aggregation.hpp>
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/coarsening/smoothed_aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct smoothed_aggregation {
: relax(1.0f), estimate_spectral_radius(false), power_iters(0)
{ }

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_VALUE(p, relax),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/direct_solver/pastix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class pastix : public solver_base< value_type, pastix<value_type, Distrib> > {
: max_rows_per_process(50000)
{}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, max_rows_per_process)
{
Expand Down
11 changes: 5 additions & 6 deletions amgcl/mpi/direct_solver/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ THE SOFTWARE.
* \brief Runtime wrapper for distributed direct solvers.
*/

#include <amgcl/util.hpp>
#ifndef AMGCL_USE_PROPERTY_TREE
# error \
Runtime interface relies on Boost.PropertyTree! \
Either define AMGCL_USE_PROPERTY_TREE, or \
include <boost/property_tree/ptree.hpp> before any of the amgcl headers.
#ifdef AMGCL_NO_BOOST
# error Runtime interface relies on Boost.PropertyTree!
#endif

#include <boost/property_tree/ptree.hpp>

#include <amgcl/util.hpp>
#include <amgcl/mpi/direct_solver/skyline_lu.hpp>
#ifdef AMGCL_HAVE_EIGEN
# include <amgcl/mpi/direct_solver/eigen_splu.hpp>
Expand Down
4 changes: 2 additions & 2 deletions amgcl/mpi/make_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class make_solver {

params() {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, precond),
AMGCL_PARAMS_IMPORT_CHILD(p, solver)
Expand Down Expand Up @@ -148,7 +148,7 @@ class make_solver {
return P.system_matrix();
}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
void get_params(boost::property_tree::ptree &p) const {
prm.get(p);
}
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/partition/merge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct merge {
enable(false), min_per_proc(10000), shrink_ratio(8)
{}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, enable),
AMGCL_PARAMS_IMPORT_VALUE(p, min_per_proc),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/partition/parmetis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct parmetis {
enable(false), min_per_proc(10000), shrink_ratio(8)
{}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, enable),
AMGCL_PARAMS_IMPORT_VALUE(p, min_per_proc),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/partition/ptscotch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct ptscotch {
enable(false), min_per_proc(10000), shrink_ratio(8)
{}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, enable),
AMGCL_PARAMS_IMPORT_VALUE(p, min_per_proc),
Expand Down
13 changes: 5 additions & 8 deletions amgcl/mpi/partition/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,17 @@ THE SOFTWARE.

#include <memory>

#include <amgcl/util.hpp>
#ifndef AMGCL_USE_PROPERTY_TREE
# error \
Runtime interface relies on Boost.PropertyTree! \
Either define AMGCL_USE_PROPERTY_TREE, or \
include <boost/property_tree/ptree.hpp> before any of the amgcl headers.
#ifdef AMGCL_NO_BOOST
# error Runtime interface relies on Boost.PropertyTree!
#endif

#include <amgcl/mpi/partition/merge.hpp>
#include <boost/property_tree/ptree.hpp>

#include <amgcl/util.hpp>
#include <amgcl/mpi/partition/merge.hpp>
#ifdef AMGCL_HAVE_SCOTCH
# include <amgcl/mpi/partition/ptscotch.hpp>
#endif

#ifdef AMGCL_HAVE_PARMETIS
# include <amgcl/mpi/partition/parmetis.hpp>
#endif
Expand Down
11 changes: 5 additions & 6 deletions amgcl/mpi/relaxation/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ THE SOFTWARE.

#include <memory>

#include <amgcl/util.hpp>
#ifndef AMGCL_USE_PROPERTY_TREE
# error \
Runtime interface relies on Boost.PropertyTree! \
Either define AMGCL_USE_PROPERTY_TREE, or \
include <boost/property_tree/ptree.hpp> before any of the amgcl headers.
#ifdef AMGCL_NO_BOOST
# error Runtime interface relies on Boost.PropertyTree!
#endif

#include <boost/property_tree/ptree.hpp>

#include <amgcl/util.hpp>
#include <amgcl/backend/interface.hpp>
#include <amgcl/value_type/interface.hpp>
#include <amgcl/relaxation/runtime.hpp>
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/schur_pressure_correction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class schur_pressure_correction {

params() : approx_schur(true) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, usolver),
AMGCL_PARAMS_IMPORT_CHILD(p, psolver),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/mpi/subdomain_deflation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class subdomain_deflation {

params() {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, local),
AMGCL_PARAMS_IMPORT_CHILD(p, isolver),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/preconditioner/cpr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class cpr {

params() : block_size(2), active_rows(0) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, pprecond),
AMGCL_PARAMS_IMPORT_CHILD(p, sprecond),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/preconditioner/cpr_drs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class cpr_drs {

params() : block_size(2), active_rows(0), eps_dd(0.2), eps_ps(0.02) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, pprecond),
AMGCL_PARAMS_IMPORT_CHILD(p, sprecond),
Expand Down
11 changes: 5 additions & 6 deletions amgcl/preconditioner/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ THE SOFTWARE.
* \brief Runtime-configurable wrappers around amgcl classes.
*/

#include <amgcl/util.hpp>
#ifndef AMGCL_USE_PROPERTY_TREE
# error \
Runtime interface relies on Boost.PropertyTree! \
Either define AMGCL_USE_PROPERTY_TREE, or \
include <boost/property_tree/ptree.hpp> before any of the amgcl headers.
#ifdef AMGCL_NO_BOOST
# error Runtime interface relies on Boost.PropertyTree!
#endif

#include <boost/property_tree/ptree.hpp>

#include <amgcl/util.hpp>
#include <amgcl/solver/runtime.hpp>
#include <amgcl/coarsening/runtime.hpp>
#include <amgcl/relaxation/runtime.hpp>
Expand Down
2 changes: 1 addition & 1 deletion amgcl/preconditioner/schur_pressure_correction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class schur_pressure_correction {

params() : approx_schur(true) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, usolver),
AMGCL_PARAMS_IMPORT_CHILD(p, psolver),
Expand Down
2 changes: 1 addition & 1 deletion amgcl/relaxation/chebyshev.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class chebyshev {

params() : degree(5), lower(1.0f / 30), power_iters(0) {}

#ifdef AMGCL_USE_PROPERTY_TREE
#ifndef AMGCL_NO_BOOST
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, degree),
AMGCL_PARAMS_IMPORT_VALUE(p, lower),
Expand Down

0 comments on commit f22a189

Please sign in to comment.