coneoproject / COFFEE

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

TypeError when using 'abs' with COFFEE optimisations enabled #20

Closed ctjacobs closed 9 years ago

ctjacobs commented 9 years ago

The swe_dam_break_2d Firedrake-Fluids test fails with COFFEE optimisations enabled. The following code reproduces the issue:

from firedrake import *

mesh = UnitSquareMesh(2, 2)
U = VectorFunctionSpace(mesh, "CG", 1)
H = FunctionSpace(mesh, "CG", 1)

u = Function(U).interpolate(Expression(("1.0", "1.0")))
magnitude = TrialFunction(H)
w = TestFunction(H)
solution = Function(H)

a = w*magnitude*dx
L = w*abs(dot(u, u))*dx
solve(a == L, solution, bcs=[])
christian@elevate /data/coffee_bugs $ python abs.py 
pyop2:INFO Solving linear variational problem...
Compiling form form

Compiler stage 1: Analyzing form(s)
-----------------------------------

  Geometric dimension:       2
  Number of cell subdomains: 0
  Rank:                      1
  Arguments:                 '(v_0)'
  Number of coefficients:    3
  Coefficients:              '[Coordinates, function_7, function_10]'
  Unique elements:           'CG1(?), Vector<2 x CG1(?)>, Vector<2 x CG1(?)>'
  Unique sub elements:       'CG1(?), Vector<2 x CG1(?)>, Vector<2 x CG1(?)>, CG1(?)
                             '

  representation:    quadrature
  quadrature_degree: auto --> 3
  quadrature_rule:   auto --> default

Compiler stage 1 finished in 0.00705218 seconds.

Compiler stage 2: Computing intermediate representation
-------------------------------------------------------
  Computing representation of integrals
  Computing quadrature representation
  Transforming cell integral
Traceback (most recent call last):
  File "abs.py", line 14, in <module>
    solve(a == L, solution, bcs=[])
  File "/data/firedrake/firedrake/solving.py", line 119, in solve
    _solve_varproblem(*args, **kwargs)
  File "/data/firedrake/firedrake/solving.py", line 143, in _solve_varproblem
    solver.solve()
  File "<string>", line 2, in solve
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/profiling.py", line 197, in wrapper
    return f(*args, **kwargs)
  File "/data/firedrake/firedrake/variational_solver.py", line 252, in solve
    self.snes.solve(None, v)
  File "PETSc/SNES.pyx", line 511, in petsc4py.PETSc.SNES.solve (src/petsc4py.PETSc.c:155735)
  File "PETSc/petscsnes.pxi", line 249, in petsc4py.PETSc.SNES_Function (src/petsc4py.PETSc.c:30548)
  File "/data/firedrake/firedrake/variational_solver.py", line 174, in form_function
    form_compiler_parameters=self._problem.form_compiler_parameters)
  File "/data/firedrake/firedrake/assemble.py", line 58, in assemble
    form_compiler_parameters=form_compiler_parameters)
  File "/data/firedrake/firedrake/assemble.py", line 79, in _assemble
    kernels = ffc_interface.compile_form(f, "form", parameters=form_compiler_parameters)
  File "/data/firedrake/firedrake/ffc_interface.py", line 261, in compile_form
    parameters).kernels)]
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/caching.py", line 202, in __new__
    obj = make_obj()
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/caching.py", line 192, in make_obj
    obj.__init__(*args, **kwargs)
  File "/data/firedrake/firedrake/ffc_interface.py", line 184, in __init__
    ffc_tree = ffc_compile_form(form, prefix=name, parameters=parameters)
  File "/usr/local/lib/python2.7/dist-packages/FFC-1.5.0_-py2.7-linux-x86_64.egg/ffc/compiler.py", line 156, in compile_form
    ir = compute_ir(analysis, object_names, parameters)
  File "/usr/local/lib/python2.7/dist-packages/FFC-1.5.0_-py2.7-linux-x86_64.egg/ffc/representation.py", line 100, in compute_ir
    for (i, fd) in enumerate(form_datas)]
  File "/usr/local/lib/python2.7/dist-packages/FFC-1.5.0_-py2.7-linux-x86_64.egg/ffc/representation.py", line 231, in _compute_integral_ir
    parameters)
  File "/usr/local/lib/python2.7/dist-packages/FFC-1.5.0_-py2.7-linux-x86_64.egg/ffc/quadrature/quadraturerepresentation.py", line 94, in compute_integral_ir
    itg_data.integral_type)
  File "/usr/local/lib/python2.7/dist-packages/FFC-1.5.0_-py2.7-linux-x86_64.egg/ffc/quadrature/quadraturerepresentation.py", line 167, in _transform_integrals_by_type
    terms = _transform_integrals(transformer, integrals_dict, integral_type)
  File "/usr/local/lib/python2.7/dist-packages/FFC-1.5.0_-py2.7-linux-x86_64.egg/ffc/quadrature/quadraturerepresentation.py", line 223, in _transform_integrals
    terms = transformer.generate_terms(integral.integrand(), integral_type)
  File "/usr/local/lib/python2.7/dist-packages/FFC-1.5.0_-py2.7-linux-x86_64.egg/ffc/quadrature/quadraturetransformerbase.py", line 773, in generate_terms
    terms = self.visit(integrand)
  File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/transformer.py", line 102, in visit
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/transformer.py", line 102, in visit
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/transformer.py", line 102, in visit
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python2.7/dist-packages/ufl/algorithms/transformer.py", line 102, in visit
    r = h(o, *[self.visit(op) for op in o.ufl_operands])
  File "/usr/local/lib/python2.7/dist-packages/FFC-1.5.0_-py2.7-linux-x86_64.egg/ffc/quadrature/optimisedquadraturetransformer.py", line 204, in abs
    var = format["absolute value"][self.parameters["format"]](str(val))
TypeError: <lambda>() takes no arguments (1 given)

Note that I'm using the fix-funcall-gen branch of FFC here.

ctjacobs commented 9 years ago

Actually, it's the swe_mms_p0p1 test, but that doesn't really matter.

ctjacobs commented 9 years ago

Sorry, never mind - a git pull on that FFC branch did the trick.