coneoproject / COFFEE

COFFEE - A COmpiler For Fast Expression Evaluation
Other
9 stars 6 forks source link

COFFEE does not sum factorise #101

Closed miklos1 closed 7 years ago

miklos1 commented 8 years ago

FInAT master, firedrakeproject/tsfc@2fac97b6bd630613dd5f3e5a91ee6b83ab1fe14a (finat-coffee-patch branch), running this snippet:

from ufl import *
from tsfc import compile_form

cell = TensorProductCell(interval, interval)
mesh = Mesh(VectorElement('Q', cell, 1))

f = Coefficient(FunctionSpace(mesh, FiniteElement('Q', cell, 7)))
v = TestFunction(FunctionSpace(mesh, FiniteElement('Q', cell, 7)))

kernel, = compile_form(f*v*dx)

from coffee import O2
from coffee.plan import ASTKernel

knl = ASTKernel(kernel.ast)
knl.plan_cpu(O2)
print knl.gencode()

Standard error:

Multiple free indices in FlexiblyIndexed: might break COFFEE.
COFFEE finished in 0.0205209 seconds (flops: 19104 -> 19104)

Standard output.

The multiple free indices complaint is for the coefficient evaluation which is prefactorised by TSFC. For the argument, I reverted the kernel interface on this branch, and fixed the attachment of linear loops pragmas. Yet COFFEE does nothing.

@FabioLuporini: can you have a look at this example, and tell whether:

  1. there is a problem with the generated AST and something needs to be generated differently; or
  2. COFFEE needs some minor fix in analysis etc. to recognise this; or
  3. Luporini et al. (2016) does not cover the sum factorisation problem?

Just in case it is unclear, here's what the sum factorised version is supposed to look like. If the answer happens to be 3, don't bother wasting too much doing sum factorisation in COFFEE, there is a fairly easy way to do it in TSFC, although that requires argument factorisation. (Fortunately, unlike UFLACS, we will be able to turn that off at least. But it would be nice to have an automatic/optimal logic that gives the best combination of sum factorisation and COFFEE.)

FabioLuporini commented 8 years ago

No, this should just work. I will take a look shortly