This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How do I get FEniCS to assemble from scratch every time?

0 votes

I am trying to compute the overall cost of a preconditioner constructed using FEniCS. I would like to time both the assembly of a system of equations and it's subsequent solution. I notice that the first time I run my code it takes a while to assemble the equations, but after it avoids this part and runs much faster. I am referring to whatever takes place while FEniCS outputs:

Calling FFC just-in-time (JIT) compiler, this may take some time.

Process 0: Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
--- Instant: compiling ---

How can I set FEniCS to always assemble from scratch?

Thanks,
Ben

asked Feb 1, 2017 by brk888 FEniCS Novice (990 points)
edited Feb 1, 2017 by brk888

2 Answers

+1 vote

The easiest option is simply to clean your Instant cache using 'instant-clean' (note that all ffc forms are lost if you do this!)
For more instant-options, see the FEniCS book Chapter 14.

answered Feb 1, 2017 by jmmal FEniCS User (5,890 points)

Thank you, this was helpful!

+1 vote

FEniCS always assembles from scratch!

The JIT compilation is only a preprocessor step which takes the weak form of the equations you have provided and autogenerates C-code for the matrix/vector assembly that is then compiled to machine code for better performance.

The actual matrix/vector is only assembled after this step. Hence, when you want to compare the speed of the matrix/vector assembly you should only measure the JIT-compiled version and not the other way around!

answered Feb 1, 2017 by cevito FEniCS User (5,550 points)

Sure, but let's say I hand over the code to someone who will only run it once for her particular set of parameters. In that case the true cost of the code includes the compiling stage. If I'm going to make a claim about the cost of the code, I need to include this!

If you have to recompile for changes in parameters, you should design your ufl formulation more carefully. Include Constants and Expressions and assign values to them accordingly.

Exactly as nate said: There is no recompilation necessary when you change the parameters or the mesh, only when you change the equations. This only works if your parameters appear as "Constant(value)" in the equations.

If you measure the time for the JIT compilation you are mostly measuring the speed of the gcc/clang compiler, not of the matrix assembly.

...