Open miklos1 opened 8 years ago
I guess the refcounting of temporaries doesn't take care of this?
I have introduced code generation of ComponentTensors by translating them into loopy in the branch translation-of-comptensors. Currently I am not doing any optimisations on the expressions which are translated from Slate to gem. I am unsure if I will still need ComponentTensor code generation after including the optimisations.
ComponentTensor does now have code generation via firedrakeproject/tsfc#203. However the optimisation that needs to be applied in the original description is not yet applied.
I may write up the optimisations mentioned in the description as two separate issues, and then this issue could be closed.
They are all removed before code generation through renaming indices. Unfortunately this may cause some duplication in the generated code. One known case is the Jacobian inverse, but there may be others.
The UFL snippet for matrix inversion is to assemble the adjugate (
ListTensor
), and then element-wise divide it by the determinant (ComponentTensor
). If the Jacobian inverse is applied several times, then the division step will happen several times due to the "inlining" ofComponentTensor
s. While this particular problem can be "fixed" by changing the UFL snippet, the same problem might arise in other cases as well.