Reputation: 145
What API should I use for OpenCL support in Java.
I want to know that is best for performance
Is JavaCL required to convert Java byte code into OpenCL or just Aparapi (API provided by AMD) can do it.
Upvotes: 3
Views: 1382
Reputation: 968
As far as I understand Aparapi is the only framework offering automatic conversion of OpenCL from bytecode. RootBeer offers a similar option for CUDA.
WRT performance you may find JavaCL or JOCL offer more performance opportunities if you are prepared to hand tune your OpenCL and/or know how to take advantage of some more advanced features of OpenCL (local memory, vector instructions, overlapping transfer/dispatch).
Specifically if you have multiple OpenCL kernels you wish to apply (say in a pipeline) you can more readily minimize buffer transfers between host and GPU with JOCL/JavaCL. Aparapi lacks some flexibility here.
However, I would expect (and have observed) that performance for most 'simple' algorithms to be very similar between these three frameworks.
My suggestion (full disclosure I am the Aparapi inventor/initial contributor) would be to try Aparapi, if you find yourself wanting to 'tweak' the generated OpenCL (Aparapi will allow you to list it's generated code), or find you want to experiment with overlapping buffer/transfer or multi kernel dispatches, you can always switch to JOCL/JavaCL when you gain more experience.
Upvotes: 6