how to improve the computational efficiency of FEniCS code?

Asked by Eric Li on 2012-12-13

Hi all,

I wonder if there is any way I can improve the computational efficiency of my code. I am doing parallel computation.The dof of my problem is about order of 2*10^6 (quite big system) and I use solver= LinearSolver("gmres","amg") as my solver and pre-conditioner. I have tried the following two strategies:

1). set form_compiler_parameters
2). avoiding assembling as possible as I can

However, I don't see significant improvement on the computational efficiency. Is there any other solver & pre-conditioner pair works in parallel with high efficiency? Or is there anything I can do to improve the efficiency?

Many thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

Hi,

Optimization is pretty problem-specific and so is choice of solvers/preconditioners. Use list_krylov_solver_preconditioners() and list_krylov_solver_methods() to see which are available.

Some other tricks I find useful are

sol = KrylovSolver('gmres', 'hypre_amg')
sol.parameters['preconditioner']['reuse'] = True #(needs to be False if you reassemble matrix)

A = assemble(...) # Matrix
A.compress() # Speeds up Krylov solvers if you have a lot of zeros in your columns

Block operators (see CBC.Block)

A very efficient trick is to use matrix-vector products to assemble rhs. For example if you want to compute the linear form

L1 = inner(grad(u0), grad(v))*dx

where u0 is Coefficient and v is TestFunction, then you can compute it like

b = assemble(L1)

or like

A1 = assemble(inner(grad(u), grad(v))*dx) # u = TrialFunction
b = A1 * u0.vector()

If you already have A1 assembled (it does not change in time), then this is a very efficient approach.

Best regards

Mikael

Den Dec 13, 2012 kl. 1:06 AM skrev Eric Li:

> New question #216654 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/216654
>
> Hi all,
>
> I wonder if there is any way I can improve the computational efficiency of my code. I am doing parallel computation.The dof of my problem is about order of 2*10^6 (quite big system) and I use solver= LinearSolver("gmres","amg") as my solver and pre-conditioner. I have tried the following two strategies:
>
> 1). set form_compiler_parameters
> 2). avoiding assembling as possible as I can
>
> However, I don't see significant improvement on the computational efficiency. Is there any other solver & pre-conditioner pair works in parallel with high efficiency? Or is there anything I can do to improve the efficiency?
>
> Many thanks.
>
>
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

Eric Li (li-gt17) said : #2

Thank you Mikael, I'll give it a try.

Kent-Andre Mardal (kent-and) said : #3

What kind of problem do you have?

Kent

On 13 December 2012 17:06, Eric Li <email address hidden>wrote:

> Question #216654 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/216654
>
> Eric Li posted a new comment:
> Thank you Mikael, I'll give it a try.
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>

Eric Li (li-gt17) said : #4

Hi Kent, I am solving a equation system involving poisson and convection-diffusion equations with large number of dof. The problem is that the computational efficiency is quite low and I want to speed it up.

Kent-Andre Mardal (kent-and) said : #5

ilu is often more efficient than amg for convection dominated problems,
unless your grid numbering is aligned with the flow.

use
dolfin.parameters["krylov_solver"]["monitor_convergence"] = True
to monitor the convergence

and adjust the tolerance with
dolfin.parameters["krylov_solver"]["absolute_tolerance"] or
dolfin.parameters["krylov_solver"]["relative_tolerance"]
if the criteria are to strict.

Kent

On 13 December 2012 17:31, Eric Li <email address hidden>wrote:

> Question #216654 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/216654
>
> Eric Li posted a new comment:
> Hi Kent, I am solving a equation system involving poisson and
> convection-diffusion equations with large number of dof. The problem is
> that the computational efficiency is quite low and I want to speed it
> up.
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>

Eric Li (li-gt17) said : #6

Hi Kent, Thank you very much for your suggestions, I'll try it out.

Can you help with this problem?

Provide an answer of your own, or ask Eric Li for more information if necessary.

To post a message you must log in.