Unnecessary recompilation?

Bug #1177383 reported by Martin Sandve Alnæs
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dolfin-adjoint
New
Undecided
Unassigned

Bug Description

This may not be a bug per se, but something that can hopefully be improved.

I notice that when running dolfin-adjoint e.g. with only a different number of timesteps, there is quite a bit of jit compilation going on. I suspect there are places in dolfin-adjoint that could avoid this. Things to keep in mind:

- Don't use computed literals in forms, wrap them in a Constant(value) to avoid recompilation

- Preserve ordering of functions if possible when doing things like replacing.

Revision history for this message
Patrick Farrell (pefarrell) wrote :

a) We don't ever add literal constants into forms, as far as I know.

b) When you say preserve ordering of functions -- what do you mean? At the moment we just use dolfin.replace and build a dictionary of what's to be replaced, which has no sense of ordering. Can you give a small example?

Revision history for this message
Martin Sandve Alnæs (martinal) wrote :

The background is that coefficients of a form must have a deterministic ordering in the ufc interface.

When ufl Coefficients are created, they get assigned a running counter, which is used to determine their ordering in generated code.

Consider some coefficients constructed in this ordering:

    f = Coefficient(V)
    g = Coefficient(V)
    h = Coefficient(V)

And the following forms:

    a = f * g**2 * dx
    b = f * h**2 * dx
    c = g * f**2 * dx
    d = h * f**2 * dx

Here the forms a and b should have the same signature and produce the same ufc code because they are the product of the first coefficient in the form and the square of the second coefficient in the form.

Similarly the forms c and d should have the same signature and produce the same ufc code because they are the product of the second coefficient in the form and the square of the first coefficient in the form.

At best, dolfin-adjoint might reduce the impact of this at the cost of some complexity, but I don't think you can get around this issue completely. If we had a more sophisticated algorithm for ordering of coefficients in ufl, all four forms above could be mapped to the same ufc code.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.