17

JavaCL uses JNA, JOCL uses JNI instead, so I expect JavaCL to show better cross-platform compatibility, while JOCL should generally turn out to have better performance. JOCL gets tested alongside JOGL2, which should make it easy to use GL objects in CL and vice versa. JavaCL is able to generate its context from the current GL context. JavaCL is protected by the GPL, JOCL is distributed under the BSD license.

What else can be said about these two approaches? Are there any good comparisons out there?

JavaCL: http://code.google.com/p/javacl/

JOCL: http://jogamp.org/jocl/www/

romeroabelleira
  • 468
  • 7
  • 20

3 Answers3

9

Raquel Medina Dominguez have written a paper for his "Ingeniería en Informática" degree titled "Evaluating different Java bindings for OpenCL". This paper compares JogAmp JOCL, JOCL and JavaCL. It scores the tree projects on performance, easy to use and memory consumption. The paper include set-up instructions that will help you getting started using any of the three Java OpenCL binding implementations.

http://e-archivo.uc3m.es/handle/10016/17183?locale=en - Evaluating different Java bindings for OpenCL PDF: http://e-archivo.uc3m.es/bitstream/10016/17183/5/finalversionPFC_Raquel_Medina.pdf Conclusions on page 40.

xranby
  • 596
  • 4
  • 7
9

(Disclaimer: I'm the author of JavaCL and BridJ)

In addition to its JNA-based version, JavaCL has a fully-functional BridJ port that's entirely licensed under BSD (as BridJ is itself BSD-licensed).

FYI BridJ offers significantly lower per-call overhead than JNA, nearing JNI performance while still being very portable (it's currently released with 32 and 64 bits binaries for Windows, Linux and MacOS X, but other platforms are planned).

The performance of low-level bindings is not the only thing to consider, though. While the object-oriented APIs of JavaCL and JOCL look similar, you have to look after the extra goodies. I don't know about JOCL, but JavaCL ships with :

  • transparent #include of files from the Java classpath or from any URL
  • automatic and transparent caching of program binaries
  • reduction utilities
  • linear algebra utils
  • a random number generator (a library, not a demo !)
  • a nice GUI to experiment with image transform kernels within seconds
  • a maven plugin that parses the OpenCL kernels (found in src/main/opencl) and generates typed program classes with one typed Java method per kernel (enforcing correctness of the arguments list at compile-time)

JavaCL is also used by ScalaCL (general-purpose OpenCL-backed collections + Scala compiler plugin to optimize code), which is a nice way of avoiding to write any kernel at all (albeit still in heavy development as of this writing).

Another thing to consider is the easy availability of binaries for standard platforms (Windows, Linux and MacOS X at least) and integration to build systems such as Maven. JavaCL used to be the best IMHO, but things might have changed (and for sure will change).

Finally, Marco Hutter's JOCL is another OpenCL binding, but with no high-level API. It might prove to be faster than OpenCL4Java (JavaCL) or JOCL for low-level calls, though.

EDIT: JavaCL is now covered by a chapter in Matthew Scarpino's OpenCL in Action book.

zOlive
  • 1,768
  • 13
  • 11
  • 2
    For the little story, the first version of JavaCL was available *before any OpenCL implementation* shipped publicly. I just did it for the fun of it as a mean to test JNAerator (http://code.google.com/p/jnaerator/), then realized it could actually be useful (and fast enough to be in the game :-)) – zOlive Jan 10 '11 at 19:40
  • 1
    Also, JavaCL lets you write #include statements in your OpenCL kernels that refer to files in the Java classpath (even inside a JAR !), which I believe is so far an exclusive feature. – zOlive Jan 11 '11 at 01:09
  • 6
    I've found JavaCL the easiest to get up and running and the most full-featured so far. – Chinasaur Jul 18 '11 at 05:28
  • 1
    Does JavaCL support OpenCL 1.0 drivers? – JohnIdol Jan 11 '12 at 17:22
  • 2
    @JohnIdol JavaCL is developed and tested primarily with OpenCL 1.0 drivers :-) – zOlive Jan 11 '12 at 23:33
  • Thank you for being fair with your answer(s), @zOlive. :) – Qix - MONICA WAS MISTREATED Apr 27 '13 at 06:01
6

JOCL is in its design very similar to JOGL or JOAL and is (like all http://jogamp.org projects) directly generated from the OpenCL specification header files at build time. This is why we expose the API in two levels: the 1:1 spec conform low level binding and a hand written much less verbose high level binding. The JNI based binding is static and is optimised for minimal runtime overhead. We provide (tested) builds for all common os-arch combinations and soon also for a few mobile devices.

Marco Hutter's JOCL.org is also JNI based but entirely hand written and fairly low level (as already mentioned before).

best regards,

-michael (JOCL lead, JOGL maintainer)

mbien
  • 396
  • 1
  • 7
  • But isn't the OP asking about JavaCL not JOCL.org? – Chinasaur Jul 16 '11 at 04:25
  • yep. thats why i mentioned jocl.org only briefly in one sentence since i didn't wanted to leave it out. – mbien Jul 17 '11 at 14:43
  • 2
    But you didn't address JavaCL; confusing. But good info, thanks. – Chinasaur Jul 18 '11 at 05:24
  • 1
    P.S., since I have your ear, the JOGAMP/JOCL documentation page I found pointed me to an old Git server I was unable to connect to. Eventually I found a reference to things moving to GitHub, but perhaps the documentation needs to be updated? – Chinasaur Jul 18 '11 at 05:26
  • 1
    http://github.com/mbien/jocl is the main repo but there are multiple mirrors, so you might have hit a mirror which was temporary offline. – mbien Jul 18 '11 at 19:26