Investigate runtime savings of simplifying the code we swig when jitting ufc forms

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

If we can get away with generating a factory function for a ufc::form and just swigging a header with the signature, and hiding all the generated code in a .cpp file, we might be able to reduce the overhead of the jit compilation significantly. This should of course be investigated before doing surgery on ffc.

I.e. we can generate

// form_<hashvalue>.h
#include <ufc.h>
ufc::form * create_form_<hashvalue>();

// form_<hashvalue>.cpp
#include "form_<hashvalue>.h"

... regular generated ufc code
class form_<hashvalue>: public ufc::form
{ ... };

ufc::form * create_form_<hashvalue>()
{
    return new form_<hashvalue>();
}

Comments (8)

  1. Martin Sandve Alnæs reporter

    We could possibly even avoid swig altogether for this simplified generated code by returning a void* and using ctypes.

    // form_<hashvalue>.h
    void * create_form_<hashvalue>();
    
    // form_<hashvalue>.cpp
    #include <ufc.h>
    #include "form_<hashvalue>.h"
    
    ... regular generated ufc code
    class form_<hashvalue>: public ufc::form
    { ... };
    
    void * create_form_<hashvalue>()
    {
        return new form_<hashvalue>();
    }
    
  2. Martin Sandve Alnæs reporter

    I implemented a ctypes based instant replacement a week ago. It's in a private sandbox repo, I'll clean it up and publish it soon. It also has some mpi awareness with mpi4py.

  3. Martin Sandve Alnæs reporter

    Investigation is done. This is definitely valuable, and other issues for doing the work has been created.

  4. Log in to comment