Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do JavaCL and JogAmp JOCL compare?

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/

like image 696
romeroabelleira Avatar asked Jan 10 '11 18:01

romeroabelleira


2 Answers

(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.

like image 176
zOlive Avatar answered Oct 16 '22 10:10

zOlive


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.

like image 32
xranby Avatar answered Oct 16 '22 08:10

xranby