← Back to team overview

dolfin team mailing list archive

Improvements in generation of SWIG interface

 

Hello!

I have improved (hopefully!) the automatic generation of the SWIG
interface of DOLFIN by reducing the size of the generated
modulePYTHON_wrap.cxx file, with the result of using less memory during
compilation of the individual modules. It now peaks at 650 MB instead of
1.2 GB. The reduced interface is accomplished by only importing and
including the dependent dolfin types for each module. Previously we
exposed the whole dolfin library to all modules.

The reduced import is accomplished by parsing all .h files in the DOLFIN
tree, and collecting dependencies. For this I used a python module
called CppHeaderParser. It is released using BSD license and is included
in dolfin_utils. I have worked together with Jashua Cloutier the
developer of CppHeaderParser to make it parse the whole DOLFIN library.

CppHeaderParser depends on ply.lex, which is distributed in debian in
the python-ply package. So one either need to:

  sudo apt-get install python-ply

or

  pip install ply

using PyPI.

JIT compilation of dolfin modules (Expressions and SubDomains) is also
much faster now, as the JIT compiled DOLFIN code is parsed runtime and
only dependent files are included or imported when the SWIG interface is
generated. Running Expression.py unit test takes 42 s instead of 140 s.

Not everything could be automated through the parsing, as the
Hierarchical class with all its derived classes causes huge pain for
SWIG. The pain was, however, overcome by two simple hacks in
generateswigcode.py and compileextensionmodule.py.

Regards,

Johan


Follow ups