[Python-compilers] Wrapping JIT-compiled functions

Mark Dewing markdewing at gmail.com
Sun Jul 10 01:23:44 EDT 2016


Hello,
  The first bullet point for the Python Compilers Workshop talks about
passing JIT'ed code to wrapped C-functions.  Let me describe some work on a
special case, which may be useful for the discussion.
  The starting point was the scipy integration routines (quad, etc) that
accept a native function for the integrand callback.  I wrote a Sympy to
LLVM JIT that would compile expressions into callbacks for scipy quad, and
then extended that to several other libraries.

There is a longer description here:
https://markdewing.github.io/blog/posts/integration-callbacks/

The python wrappers around the Cubature and Cuba libraries required
modifications to accept native code callbacks.  It seems any wrapper around
a native code library that uses
callbacks will need code to handle a native code callback vs. a Python
callback.
 For details, see these pull requests:
     https://github.com/saullocastro/cubature/pull/16
     https://github.com/JohannesBuchner/PyMultiNest/pull/73/files


One of the issues in generalizing this is how to scale to different
libraries and callbacks without needing to program knowledge of each of
them into Sympy.
There needs to be some way to describe the parameters expected in the
callback, but it should be at a higher level than just C types - which ones
are inputs, outputs, array lengths, etc.

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-compilers/attachments/20160710/0051d611/attachment.html>


More information about the Python-compilers mailing list