DOLFIN_benchmark allows to automatically benchmark various solver/preconditioner options in the Python interface to FEniCS/DOLFIN.
It works by overwritting the dolfin.solver and solving the same problem with various different solvers/preconditioners. The resulting timings are then sorted and the result is reported. A typical benchmark report looks like this:
*********************************************** ********** Solver benchmark results: ********** *********************************************** cg, amg: 0.98 s cg, hypre_amg: 0.98 s gmres, amg: 0.99 s tfqmr, amg: 1.00 s . . . gmres, icc: 13.23 s gmres, sor: 14.21 s gmres, hypre_parasails: 16.72 s gmres, jacobi: 37.94 s richardson, sor: 42.80 s richardson, default: diverged richardson, hypre_parasails: diverged minres, hypre_parasails: diverged tfqmr, icc: diverged
Copy the file "solver_benchmark.py" in your project directory and import the module in your solver file with:
from solver_benchmark import *
To run benchmark one of your "solve" calls, simply change
solve(...)
to
solve(..., benchmark = True)
The result of the benchmark will be written to STDOUT.
Sometimes you will see error messages like:
PETSC ERROR: Unable to find requested PC type ml!
In that case, it is best to exclude this solver/preconditioner manually, see the section.
Solvers can be excluded from the benchmark with the optional solver_exclude and preconditioner arguments, e.g.
solve(..., benchmark = True, solver_exclude = ['lu', 'cg'], preconditioner_exclude = ['ilu'])
Run demo_poisson.py or demo_navier-stokes.py to see an example.
Adaptive solves, i.e solve calls that use the 'tol' argument, are currently not supported. But there is no reason why not, see the "How to contribute section.
Fork the project, make your changes and request a merge. Simple.