Clarification of lettersoup: JNI = java native interface, the C/C++ interface to java. JNA = java native access, an API that aims to simplify java/C interop.
clj-native is built upon JNA and is at present a rather thin wrapper so it's good to learn a bit about JNA to get the most out of clj- native. I have been careful to make clj-native as performant as possible, but I haven't actually tested it much so I can't promise anything. clj-native uses the "direct mapping" feature of JNA which is more performant with regards to the function calls themselves than the more dynamic JNA alternatives. This can make calls into native code quite fast but calls from native code into Clojure via callbacks are slower because JNI has to use a kind of reflection API to call methods :( With regards to copying of data, clj-native expects nio buffers to be used as input where a native function requires a typed pointer. These buffers can be allocated outside of the JVM heap specifically to avoid copying. For example (ByteBuffer/allocateDirect 1000) will allocate 1000 bytes outside of the JVM heap, which means it does not have to be copied during native interop because the GC will never move it. JNA also has facilities to create ByteBuffers from pointers which means you can gain access to large blobs of memory that reside in native code. On 24 mar, 08:56, Konrad Hinsen <konrad.hin...@fastmail.net> wrote: > On 24 Mar 2010, at 07:40, mac wrote: > > > If you just want to use LLVM from Clojure however, you can use my C > > FFI clj-native with the C interface for LLVM. I actually made it > > because I wanted to play around with LLVM but I never got around to > > actually doing that again once I had a working version of clj-native. > > It would be very interesting to see if clj-native is suitable for the > > task. > > Just wondering: what are the performance implications of interfacing > to C via clj-native? Are all data items necessarily copied when > crossing the interface? I think that's what happens with JNI though I > am not sure. For big data items, that would be a disaster. > > Konrad. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.