At the moment there are two ways to define an Expression in DOLFIN; the first by providing C++ code which is compiled JIT, and the second by extending the class Expression within Python. The first offers excellent performance, at the expense of readability in Python code, and the second offers ease of use and a seamless Python experience, at the expense of speed.
I think we could offer a third way which combines the advantages of both. Numba http://numba.pydata.org/ is a way of speeding up maths heavy and array-oriented code by compiling a subset of Python into native code using the LLVM backend. With Numba, you simply add the decorator @jit to your function, and let it handle the rest (it's really quite magic). I've being playing around with Numba and I've found that with very minor modifications to DOLFIN it is possible to use a JIT compiled Numba Expression from the Python interface. Unsurprisingly, performance on compute-heavy expressions (tight loops etc.) is orders of magnitude better than pure-Python and competitive with C++. An outstanding issue is that when using a Numba expression the C++ layer calls out to Python that then calls back to the compiled code. Obviously this is suboptimal, but there are blueprints within Numba to provide a C interface for compiled Numba code which could eventually remove this bottle-neck. Let me know what you think, ----- Dr. Jack S. Hale Marie Skłodowska-Curie Postdoctoral Fellow University of Luxembourg Campus Kirchberg G005 Phone +352 44 666 44 5236 jack.h...@uni.lu Latest publications and conferences: http://goo.gl/rNiISG ORCID: http://orcid.org/0000-0001-7216-861X Google Scholar: http://scholar.google.com/citations?user=Fx9lQ7MAAAAJ&hl=de
_______________________________________________ fenics mailing list fenics@fenicsproject.org http://fenicsproject.org/mailman/listinfo/fenics