There's an effort to bring a more modern FFI to Java that works similar to the one described in the article, called project Panama. It has tools to convert C header files into the equivalent annotated Java definitions and is intended to help improve performance as well. You can follow along here: http://mail.openjdk.java.net/pipermail/panama-dev/ The same project is also adding support for writing vector code in Java…
I don't know, it looks as if you have to hardcode pointer sizes in the source code. https://twitter.com/sundararajan_a/status/101507363642677248...
Interfacing with native methods on Graal VM
11–14 of 14 posts
Re: Interfacing with native methods on Graal VM
#12There's an effort to bring a more modern FFI to Java that works similar to the one described in the article, called project Panama. It has tools to convert C header files into the equivalent annotated Java definitions and is intended to help improve performance as well. You can follow along here: http://mail.openjdk.java.net/pipermail/panama-dev/ The same project is also adding support for writing vector code in Java…
Disclaimer: I'm affiliated with a semi competing project to panama called javacpp: https://github.com/bytedeco/javacpp I can say for a fact that panama is not seriously targeting this space. We implement a ton of that native code today that works with c++ and actual android today . We also handle gpus. Project panama is only targeting c, and even then will only do it a cross platform non committal fashion. They aren'…
John Rose of Oracle:
Panama is not just about C headers. It is about building a framework in which any data+function schema of APIs can be efficiently plugged into the JVM. So it's not just C or C++ but protocol specs and persistent memory structures and on-disk formats and stuff not invented yet. We've been relentless about designing the framework down to essential functionality (memory access and procedure calls), not just our (second-)favorite language or compiler.
The important deliverable of Panama is therefore not Posix bindings, but rather a language-neutral memory layout-and-access mechanism, plus a language-neutral (initially ABI-compliant) subroutine invocation mechanism. The jextract tool grovels over ANSI C (soon C++) schemas and translates to the layouts and function calls, bound helpfully to Java APIs with unsurprising names. But the jextract tool is just the first plugin of many.
We do look forward to building more plugins for more metadata formats outside the Java ecosystem, such as what you are building.
In fact, I expect that, in the long run, we will not build all of the plugins, but that people who invent new data schemas (or even data+function schemas or languages) will consider using our tools (layouts, binder, metadata annotations) to integrate with Java, instead of the standard technique, which is to write a set of Java native functions from scratch, or (if you are very clever) with tooling. The binder pattern, in particular, seems to be a great way to spin repetitive code for accessing data structures of all sorts, not just C or Java. I hope it will be used, eventually, in preference to static protocol compilers. The JVM is very good at on-line optimization, even of freshly spun code, so it is a natural framework for building a binder.
>They aren't doing it the way they should be in order to properly target native vectorized code.
Which is interesting since Intel is the one contributing the majority of the vector code changes.
Re: Interfacing with native methods on Graal VM
#13Earlier quoted context omitted.
I don't know, it looks as if you have to hardcode pointer sizes in the source code. https://twitter.com/sundararajan_a/status/101507363642677248...
Where are you seeing that? The pointer in that example doesn't have a hardcoded size.
Check out this document http://cr.openjdk.java.net/~mcimadamore/panama/panama-binder... for the syntax.
Re: Interfacing with native methods on Graal VM
#14Earlier quoted context omitted.
Disclaimer: I'm affiliated with a semi competing project to panama called javacpp: https://github.com/bytedeco/javacpp I can say for a fact that panama is not seriously targeting this space. We implement a ton of that native code today that works with c++ and actual android today . We also handle gpus. Project panama is only targeting c, and even then will only do it a cross platform non committal fashion. They aren'…
>Project panama is only targeting c, and even then will only do it a cross platform non committal fashion John Rose of Oracle: Panama is not just about C headers. It is about building a framework in which any data+function schema of APIs can be efficiently plugged into the JVM. So it's not just C or C++ but protocol specs and persistent memory structures and on-disk formats and stuff not invented yet. We've been rele…
That codegen isn't going to match what you need to do for real speed on cpus or gpus when writing vectorized math code.
Re: his last point. That's exactly what we talked to that team about. We don't feel those tools are going to work for real world use cases. We already do the codegen and auto bindings/mapping ourselves in addition to the memory management ourselves.