Skip to content

Commit

Permalink
Only use Boost.PropertyTree if runtime interface is used (#88)
Browse files Browse the repository at this point in the history
* Only use Boost.PropertyTree if runtime interface is used

(or boost is otherwise available)
  • Loading branch information
ddemidov committed Jun 26, 2018
1 parent 946398e commit a2fab10
Show file tree
Hide file tree
Showing 45 changed files with 130 additions and 16 deletions.
2 changes: 2 additions & 0 deletions amgcl/amg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class amg {
#endif
{}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, coarsening),
AMGCL_PARAMS_IMPORT_CHILD(p, relax),
Expand Down Expand Up @@ -196,6 +197,7 @@ class amg {
AMGCL_PARAMS_EXPORT_VALUE(p, path, async_setup);
#endif
}
#endif
} prm;

/// Builds the AMG hierarchy for the system matrix.
Expand Down
3 changes: 3 additions & 0 deletions amgcl/backend/block_crs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ struct block_crs {
size_t block_size;

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

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, block_size)
{
Expand All @@ -166,6 +168,7 @@ struct block_crs {
void get(boost::property_tree::ptree &p, const std::string &path) const {
AMGCL_PARAMS_EXPORT_VALUE(p, path, block_size);
}
#endif
};

static std::string name() { return "block_crs"; }
Expand Down
2 changes: 2 additions & 0 deletions amgcl/backend/cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ struct cuda {

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

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, cusparse_handle)
{
Expand All @@ -274,6 +275,7 @@ struct cuda {
void get(boost::property_tree::ptree &p, const std::string &path) const {
AMGCL_PARAMS_EXPORT_VALUE(p, path, cusparse_handle);
}
#endif
};

static std::string name() { return "cuda"; }
Expand Down
2 changes: 2 additions & 0 deletions amgcl/coarsening/aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ struct aggregation {

params() : over_interp(1.5f) { }

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_CHILD(p, nullspace),
Expand All @@ -109,6 +110,7 @@ struct aggregation {
AMGCL_PARAMS_EXPORT_CHILD(p, path, nullspace);
AMGCL_PARAMS_EXPORT_VALUE(p, path, over_interp);
}
#endif
} prm;

aggregation(const params &prm = params()) : prm(prm) {}
Expand Down
2 changes: 2 additions & 0 deletions amgcl/coarsening/plain_aggregates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct plain_aggregates {

params() : eps_strong(0.08f) {}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, eps_strong)
{
Expand All @@ -83,6 +84,7 @@ struct plain_aggregates {
void get(boost::property_tree::ptree &p, const std::string &path) const {
AMGCL_PARAMS_EXPORT_VALUE(p, path, eps_strong);
}
#endif
};

static const ptrdiff_t undefined = -1;
Expand Down
2 changes: 2 additions & 0 deletions amgcl/coarsening/pointwise_aggregates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class pointwise_aggregates {

params() : block_size(1) {}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: plain_aggregates::params(p),
AMGCL_PARAMS_IMPORT_VALUE(p, block_size)
Expand All @@ -72,6 +73,7 @@ class pointwise_aggregates {
plain_aggregates::params::get(p, path);
AMGCL_PARAMS_EXPORT_VALUE(p, path, block_size);
}
#endif
};

static const ptrdiff_t undefined = -1;
Expand Down
2 changes: 2 additions & 0 deletions amgcl/coarsening/ruge_stuben.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct ruge_stuben {

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

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, eps_strong),
AMGCL_PARAMS_IMPORT_VALUE(p, do_trunc),
Expand All @@ -94,6 +95,7 @@ struct ruge_stuben {
AMGCL_PARAMS_EXPORT_VALUE(p, path, do_trunc);
AMGCL_PARAMS_EXPORT_VALUE(p, path, eps_trunc);
}
#endif
} prm;

ruge_stuben(const params &prm = params()) : prm(prm) {}
Expand Down
2 changes: 2 additions & 0 deletions amgcl/coarsening/smoothed_aggr_emin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct smoothed_aggr_emin {

params() {}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_CHILD(p, nullspace)
Expand All @@ -76,6 +77,7 @@ struct smoothed_aggr_emin {
AMGCL_PARAMS_EXPORT_CHILD(p, path, aggr);
AMGCL_PARAMS_EXPORT_CHILD(p, path, nullspace);
}
#endif
} prm;

smoothed_aggr_emin(const params &prm = params()) : prm(prm) {}
Expand Down
2 changes: 2 additions & 0 deletions amgcl/coarsening/smoothed_aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ struct smoothed_aggregation {

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

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_CHILD(p, nullspace),
Expand All @@ -120,6 +121,7 @@ struct smoothed_aggregation {
AMGCL_PARAMS_EXPORT_VALUE(p, path, estimate_spectral_radius);
AMGCL_PARAMS_EXPORT_VALUE(p, path, power_iters);
}
#endif
} prm;

smoothed_aggregation(const params &prm = params()) : prm(prm) {}
Expand Down
2 changes: 2 additions & 0 deletions amgcl/coarsening/tentative_prolongation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct nullspace_params {

nullspace_params() : cols(0) {}

#ifdef BOOST_VERSION
nullspace_params(const boost::property_tree::ptree &p)
: cols(p.get("cols", nullspace_params().cols))
{
Expand Down Expand Up @@ -105,6 +106,7 @@ struct nullspace_params {
}

void get(boost::property_tree::ptree&, const std::string&) const {}
#endif
};

/// Tentative prolongation operator
Expand Down
4 changes: 4 additions & 0 deletions amgcl/make_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class make_solver {

params() {}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, precond),
AMGCL_PARAMS_IMPORT_CHILD(p, solver)
Expand All @@ -83,6 +84,7 @@ class make_solver {
AMGCL_PARAMS_EXPORT_CHILD(p, path, precond);
AMGCL_PARAMS_EXPORT_CHILD(p, path, solver);
}
#endif
} prm;

/** Sets up the preconditioner and creates the iterative solver. */
Expand Down Expand Up @@ -189,10 +191,12 @@ class make_solver {
return P.system_matrix();
}

#ifdef BOOST_VERSION
/// Stores the parameters used during construction into the property tree \p p.
void get_params(boost::property_tree::ptree &p) const {
prm.get(p);
}
#endif

/// Returns the size of the system matrix.
size_t size() const {
Expand Down
2 changes: 2 additions & 0 deletions amgcl/mpi/amg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class amg {
npre(1), npost(1), ncycle(1), pre_cycles(1)
{}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, coarsening),
AMGCL_PARAMS_IMPORT_CHILD(p, relax),
Expand Down Expand Up @@ -148,6 +149,7 @@ class amg {
AMGCL_PARAMS_EXPORT_VALUE(p, path, ncycle);
AMGCL_PARAMS_EXPORT_VALUE(p, path, pre_cycles);
}
#endif
} prm;

template <class Matrix>
Expand Down
2 changes: 2 additions & 0 deletions amgcl/mpi/coarsening/aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct aggregation {

params() : over_interp(1.5f) { }

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_VALUE(p, over_interp)
Expand All @@ -84,6 +85,7 @@ struct aggregation {
AMGCL_PARAMS_EXPORT_CHILD(p, path, aggr);
AMGCL_PARAMS_EXPORT_VALUE(p, path, over_interp);
}
#endif
} prm;

aggregation(const params &prm = params()) : prm(prm) {}
Expand Down
2 changes: 2 additions & 0 deletions amgcl/mpi/coarsening/pmis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct pmis {

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

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, eps_strong),
AMGCL_PARAMS_IMPORT_VALUE(p, block_size)
Expand All @@ -74,6 +75,7 @@ struct pmis {
AMGCL_PARAMS_EXPORT_VALUE(p, path, eps_strong);
AMGCL_PARAMS_EXPORT_VALUE(p, path, block_size);
}
#endif
};

std::shared_ptr< distributed_matrix<bool_backend> > conn;
Expand Down
2 changes: 2 additions & 0 deletions amgcl/mpi/coarsening/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ THE SOFTWARE.
* \brief Runtime wrapper for distributed coarsening schemes.
*/

#include <boost/property_tree/ptree.hpp>

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

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, aggr),
AMGCL_PARAMS_IMPORT_VALUE(p, relax),
Expand All @@ -87,6 +88,7 @@ struct smoothed_aggregation {
AMGCL_PARAMS_EXPORT_VALUE(p, path, estimate_spectral_radius);
AMGCL_PARAMS_EXPORT_VALUE(p, path, power_iters);
}
#endif
} prm;

smoothed_aggregation(const params &prm = params()) : prm(prm) {}
Expand Down
2 changes: 2 additions & 0 deletions amgcl/mpi/direct_solver/pastix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class pastix : public solver_base< value_type, pastix<value_type, Distrib> > {
: max_rows_per_process(50000)
{}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, max_rows_per_process)
{
Expand All @@ -83,6 +84,7 @@ class pastix : public solver_base< value_type, pastix<value_type, Distrib> > {
void get(boost::property_tree::ptree &p, const std::string &path) const {
AMGCL_PARAMS_EXPORT_VALUE(p, path, max_rows_per_process);
}
#endif
};

/// Constructor.
Expand Down
2 changes: 2 additions & 0 deletions amgcl/mpi/direct_solver/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ THE SOFTWARE.
* \brief Runtime wrapper for distributed direct solvers.
*/

#include <boost/property_tree/ptree.hpp>

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

params() {}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, precond),
AMGCL_PARAMS_IMPORT_CHILD(p, solver)
Expand All @@ -78,6 +79,7 @@ class make_solver {
AMGCL_PARAMS_EXPORT_CHILD(p, path, precond);
AMGCL_PARAMS_EXPORT_CHILD(p, path, solver);
}
#endif
} prm;

template <class Matrix>
Expand Down Expand Up @@ -146,9 +148,11 @@ class make_solver {
return P.system_matrix();
}

#ifdef BOOST_VERSION
void get_params(boost::property_tree::ptree &p) const {
prm.get(p);
}
#endif

size_t size() const {
return n;
Expand Down
2 changes: 2 additions & 0 deletions amgcl/mpi/partition/merge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct merge {
enable(false), min_per_proc(10000), shrink_ratio(8)
{}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, enable),
AMGCL_PARAMS_IMPORT_VALUE(p, min_per_proc),
Expand All @@ -74,6 +75,7 @@ struct merge {
AMGCL_PARAMS_EXPORT_VALUE(p, path, min_per_proc);
AMGCL_PARAMS_EXPORT_VALUE(p, path, shrink_ratio);
}
#endif
} prm;

merge(const params &prm = params()) : prm(prm) {}
Expand Down
2 changes: 2 additions & 0 deletions amgcl/mpi/partition/parmetis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct parmetis {
enable(false), min_per_proc(10000), shrink_ratio(8)
{}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, enable),
AMGCL_PARAMS_IMPORT_VALUE(p, min_per_proc),
Expand All @@ -76,6 +77,7 @@ struct parmetis {
AMGCL_PARAMS_EXPORT_VALUE(p, path, min_per_proc);
AMGCL_PARAMS_EXPORT_VALUE(p, path, shrink_ratio);
}
#endif
} prm;

parmetis(const params &prm = params()) : prm(prm) {}
Expand Down
2 changes: 2 additions & 0 deletions amgcl/mpi/partition/ptscotch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct ptscotch {
enable(false), min_per_proc(10000), shrink_ratio(8)
{}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_VALUE(p, enable),
AMGCL_PARAMS_IMPORT_VALUE(p, min_per_proc),
Expand All @@ -76,6 +77,7 @@ struct ptscotch {
AMGCL_PARAMS_EXPORT_VALUE(p, path, min_per_proc);
AMGCL_PARAMS_EXPORT_VALUE(p, path, shrink_ratio);
}
#endif
} prm;

ptscotch(const params &prm = params()) : prm(prm) {}
Expand Down
1 change: 1 addition & 0 deletions amgcl/mpi/partition/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ THE SOFTWARE.
*/

#include <memory>
#include <boost/property_tree/ptree.hpp>

#include <amgcl/mpi/partition/merge.hpp>

Expand Down
3 changes: 3 additions & 0 deletions amgcl/mpi/relaxation/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ THE SOFTWARE.
*/

#include <memory>

#include <boost/property_tree/ptree.hpp>

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

params() : approx_schur(true) {}

#ifdef BOOST_VERSION
params(const boost::property_tree::ptree &p)
: AMGCL_PARAMS_IMPORT_CHILD(p, usolver),
AMGCL_PARAMS_IMPORT_CHILD(p, psolver),
Expand Down Expand Up @@ -142,6 +143,7 @@ class schur_pressure_correction {
AMGCL_PARAMS_EXPORT_CHILD(p, path, psolver);
AMGCL_PARAMS_EXPORT_VALUE(p, path, approx_schur);
}
#endif
} prm;

template <class Matrix>
Expand Down

0 comments on commit a2fab10

Please sign in to comment.