ddemidov / amgcl

C++ library for solving large sparse linear systems with algebraic multigrid method
http://amgcl.readthedocs.org/
MIT License
728 stars 111 forks source link

Compile errors after changing to new version #166

Closed klausbu closed 3 years ago

klausbu commented 4 years ago

Hello Denis,

I tried to update an interface with the latest version of AMGCL to work with mixed precision etc. all MPI but I get a few compile Errors even before making changes:

This is the code section in questioon which worked:

// Use runtime interface for simplicity:
typedef amgcl::backend::builtin<double> Backend;
typedef amgcl::mpi::make_solver<
    amgcl::mpi::amg<
        Backend,
        amgcl::runtime::mpi::coarsening::wrapper<Backend>,
        amgcl::runtime::mpi::relaxation::wrapper<Backend>,
        amgcl::runtime::mpi::direct::solver<double>,
        amgcl::runtime::mpi::partition::wrapper<Backend>
        >,
    amgcl::runtime::solver::wrapper
    > Solver;

    // Solver and preconditioner parameters
    boost::property_tree::ptree prm;

if (matrix_.symmetric()) {
// solver options
    prm.put("solver.type", "cg");
    prm.put("solver.tol", tol);

    // amg preconditioner options (p, {"coarsening", "relax", "direct", "repart", "coarse_enough",  "direct_coarse", "max_levels", "npre", "npost", "ncycle", "pre_cycles"});
    prm.put("precond.coarsening.type", "aggregation"); // aggregation or smoothed_aggregation
    prm.put("precond.relax.type", "spai0"); // for MPI is only spai0 supported
    prm.put("precond.max_levels", 20);
    prm.put("precond.npre", 0);
    prm.put("precond.npost", 2);
} else {
    prm.put("solver.type", "bicgstabl");
    prm.put("solver.tol", tol);
    prm.put("solver.L", 2);
    }

    ptrdiff_t chunk(n);

    // Solver constructor:
    Solver solve(MPI_COMM_WORLD, std::tie(chunk, ptr_, col, val), prm);

    std::tie(iters, resid) = solve(rhs, solution);

These are the compile errors: Fehler means error

myNewAMGCLSOLVER.C:325:9: Fehler: Typ/Wert des Arguments 2 passt nicht in Template-Parameterliste für »template<class Precond, class IterativeSolver> class amgcl::mpi::make_solver« 325 | > Solver; | ^

This is about amgcl::runtime::solver::wrapper Solver;

"the type/value of argument 2 doesn't fit the template parameter list...

myNewAMGCLSOLVER.C:325:9: Anmerkung: einen Typ erwartet, »wrapper« erhalten

same line, "type expected, wrapper received..."

myNewAMGCLSOLVER.C:350:74: Fehler: Ausdrucksliste als zusammengesetzten Ausdruck in Initialisierung behandelt [-fpermissive] 350 | Solver solve(MPI_COMMWORLD, std::tie(chunk, ptr, col, val), prm); | ^

"expression list handled as composed expression while initializing"

myNewAMGCLSOLVER.C:350:74: Fehler: »boost::property_tree::ptree« {aka »boost::property_tree::basic_ptree<std::__cxx11::basic_string, std::__cxx11::basic_string >«} kann nicht nach »Solver« {aka »int«} in Initialisierung umgewandelt werden

"boost property tree can't be converted into Solver while initializing"

myNewAMGCLSOLVER.C:353:53: Fehler: »solve« kann nicht als Funktion verwendet werden 353 | std::tie(iters, resid) = solve(rhs, solution);

"solve can't be used as function"

Is this caused by changes in the library?

ddemidov commented 4 years ago

I think you are missing template parameter for backend in amgcl::runtime::solver::wrapper.

The following code (simplifed version of examples/mpi/mpi_amg.cpp) does compile for me: https://gist.github.com/ddemidov/0629e36b9c9f3a056c063a1d3e15dd93.

Can you please check if that works for you as well? If that it does, please post a minimal reproducible example that does not work for you. Also note that at this time the MPI interface does not support mixed precision.