Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support compiled functions as arguments in nopython mode #821

Closed
seibert opened this issue Oct 15, 2014 · 5 comments
Closed

Support compiled functions as arguments in nopython mode #821

seibert opened this issue Oct 15, 2014 · 5 comments

Comments

@seibert
Copy link
Contributor

seibert commented Oct 15, 2014

We would like to be able to support Numba-compiled implementations of algorithms (like solvers) that can call user-supplied JIT functions (or ctypes/cffi wrappped functions) without any Python overhead.

The primary use case is for automatic jitting, although we will need a syntax to specify an argument function type explicitly in type signature.

@pitrou
Copy link
Contributor

pitrou commented Oct 15, 2014

So it would call the function, not inline it? Otherwise I can't see a way of precompiling the outer function.

@seibert
Copy link
Contributor Author

seibert commented Oct 15, 2014

The initial implementation would just call the function by pointer, as you would in C. This is good enough for most cases, as it still eliminates the overhead of boxing and unboxing Python arguments.

A followup to this feature would be updating the autojit to recompile the outer function with the user function inlined. This would require some heuristic or flag in the API to enable. I think automatic inlining of user functions will be a powerful use of the JIT, but we can worry about it later.

@seibert
Copy link
Contributor Author

seibert commented Oct 15, 2014

Additionally, call by pointer would be the only option for ctypes and cffi functions, of course. With Numba functions, we have the option of eventually supporting inlining of the LLVM IR as well.

pitrou added a commit to pitrou/numba that referenced this issue Feb 25, 2015
seibert added a commit that referenced this issue Mar 4, 2015
Issue #821: allow ctypes and cffi functions as arguments in nopython mode
@stuartarchibald
Copy link
Contributor

@seibert is this sufficiently covered by @cfunc, ctypes/cffi support and now passing compiled functions as args/in containers to close this? Or do you want to keep it open for the notion of automatic-inlining/recompilation?

@stuartarchibald
Copy link
Contributor

Closing as numerous variants of the above are implemented, including passing jitted functions, first class function types, @cfunc and ctypes/cffi support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants