FFC

Comment 5 for bug 1153508

Revision history for this message
Johan Hake (johan-hake) wrote : Re: [Bug 1153508] [NEW] Strange results in JIT compilation

On 03/11/2013 04:31 PM, Marie Rognes wrote:
> On 03/11/2013 04:07 PM, Johan Hake wrote:
>> Are you sure this is a bug?
>
> Pretty sure, yes.
>
>> In the first example the Expression is generated without setting the
>> degree. If this is auto chosen to 2 it should make perfectly sense they
>> give the same results.
>
> Yes. But the problem is that the Expression with degree=2 gives
> different results depending on what has been compiled before it.
>
>> Change degree to something else and you will have
>> a different results.
>
> Did you read the problem carefully? Look at (*) and (**). Both of these
> correspond to setting degree=2 explicitly. The numbers should therefore
> be the same. They are not, which is highly disturbing. (*) is produced
> after doing instant-clean, running with auto degree, and running with
> degree = 2 (which seems to reuse the auto degree code); while (**) is
> produced after doing instant-clean and directly running with degree=2.

Ok, I see it now. Pretty disturbing yes.

How can we find out what degree is chosen for the expression when it is
autogenerated? Is it during preprocess? Is it still so that it is the
repr of the preprocessed form that determines if a form will get recompiled?

from dolfin import *

mesh = UnitSquareMesh(16,16)
V = FunctionSpace(mesh, 'CG', 2)
w = TestFunction(V)
f = Expression("x[0]*x[0] + 2*x[1]*x[1]")
L = inner(w, f)*dx
b = assemble(L)

print "Preprocessed:", repr(L.form_data().preprocessed_form)
print "Not preprocessed:", repr(L)

Prints:
Preprocessed: Form([Integral(Product(Argument(FiniteElement('Lagrange',
Domain(Cell('triangle', 2), 'triangle_multiverse', 2, 2), 2, None), -2),
Coefficient(FiniteElement('Lagrange', None, None, None), 0)), 'cell',
'otherwise', None, None)])
Not preprocessed:
Form([Integral(Product(Argument(FiniteElement('Lagrange',
Domain(Cell('triangle', 2), 'triangle_multiverse', 2, 2), 2, None), -2),
Coefficient(FiniteElement('Lagrange', None, None, None), 0)), 'cell',
'everywhere', None, None)])

Where it is clear that the Coefficient of the first form has not got any
degree. Shouldn't it have got one?

Johan

> --
> Marie
>
>
>> Johan
>>
>> On 03/11/2013 10:06 AM, Marie Rognes wrote:
>>> Public bug reported:
>>>
>>> There seems to be something seriously wrong with either DOLFIN-FFC jit
>>> compilation or caching or instant.
>>>
>>> To reproduce, for instance consider the following code snippet and do
>>> the following
>>>
>>> (1): Run instant-clean
>>>
>>> (2): Run script unmodified.
>>>
>>> Output is:
>>>
>>> Calling FFC just-in-time (JIT) compiler, this may take some time.
>>> Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
>>> Calling FFC just-in-time (JIT) compiler, this may take some time.
>>> Calling FFC just-in-time (JIT) compiler, this may take some time.
>>> Solving linear system of size 1089 x 1089 (PETSc Krylov solver).
>>> 40.4757877531
>>>
>>> (3) Uncomment commented lines and run.
>>>
>>> Output is:
>>>
>>> Solving linear system of size 1089 x 1089 (PETSc Krylov solver).
>>> 40.4757877531
>>> Solving linear system of size 1089 x 1089 (PETSc Krylov solver).
>>> 40.4757877531 (*)
>>>
>>> (4) Run instant-clean, comment out lines defining f, g, and 1st print.
>>> Run.
>>>
>>> Output is
>>> Calling FFC just-in-time (JIT) compiler, this may take some time.
>>> Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
>>> Calling FFC just-in-time (JIT) compiler, this may take some time.
>>> Calling FFC just-in-time (JIT) compiler, this may take some time.
>>> Solving linear system of size 1089 x 1089 (PETSc Krylov solver).
>>> 40.490263582 (**)
>>>
>>> Problem: The last two floats, tagged by (*) and (**), should be the
>>> same: they are not.
>>>
>>> Code snippet:
>>>
>>> --
>>>
>>>
>>> from dolfin import *
>>> mesh = UnitSquareMesh(16,16)
>>> V = FunctionSpace(mesh, 'CG', 2)
>>>
>>> f = Expression("x[0]*x[0] + 2*x[1]*x[1]")
>>> g = project(f, V)
>>> print g.vector().norm("l2")
>>>
>>> #f2 = Expression("x[0]*x[0] + 2*x[1]*x[1]", degree=2)
>>> #g2 = project(f2, V)
>>> #print g2.vector().norm("l2")
>>>
>>>
>>> --
>>>
>>> ** Affects: dolfin
>>> Importance: Undecided
>>> Status: New
>>>
>