Use ctypes to load jit compiled classes

Issue #91 resolved
Martin Sandve Alnæs created an issue

I suggest introducing this stepwise in a function next to the existing jit, allowing testing on different systems for a while until we trust it.

The dijitso project is a prototype of how to use ctypes to jit and load modules, but I suggest adding this functionality into ffc (perhaps as a submodule). There are a number of issues on the dijitso tracker, most of them small, some of them have been solved in instant, some of them may turn out to be irrelevant: https://bitbucket.org/fenics-project/dijitso/issues?status=new&status=open

One suggestion for an initial ffc.jit using ctypes is to just handle the jitting of elements, dealing with forms when elements are in place.

Comments (8)

  1. Martin Sandve Alnæs reporter

    When the issue on generating elements and forms separately is implemented, see

    https://bitbucket.org/fenics-project/ffc/issues/90/split-generation-of-elements-and-forms

    class dependencies will need to be handled compile time (include dirs) and link time (libname, rpath). Using the element classname constructed from a signature, .cpp files will #include .h files from other jit modules, and .so files must be linked to other relevant .so files (using rpath to avoid libdir issues).

  2. Martin Sandve Alnæs reporter

    When ctypes is used instead of swig, the ufc interface will not be wrapped and available in python. This is only used very few places, but some adaption of ufc interface might turn up as necessary to do. In particular, dolfin.Form uses ufc::form::enabled_coefficients() (name from memory) which returns a const std::vector<int> &. New functions int num_enabled_coefficients() and int enabled_coefficient(int i) can replace that and easily be wrapped using ctypes.

  3. Martin Sandve Alnæs reporter

    We can soon address this issue as the dependencies are in next. I suggest adding a new jit implementation next to the old one and keep the old one until the new is working and trusted. We can use an environment variable to pick the new implementation, allowing non intrusive running of all dolfin tests.

  4. Log in to comment