Reputation: 2459
Firstly: Is it possible to use Java and let it (partly) run on or use GPUs? And if it's possible, is it possible to use the normal Java syntax and not using special cuda or opencl syntax?
I want just take my coded java source and let it run with the smallest changes possible on GPUs.
I would greatly appreciate code samples.
Upvotes: 20
Views: 28676
Reputation: 453
TornadoVM is a plug-in to OpenJDK that allows programmers to automatically run Java programs on heterogeneous hardware. TornadoVM currently targets OpenCL-compatible devices and it runs on multi-core CPUs, GPUs (NVIDIA and AMD), Intel integrated GPUs, and Intel FPGAs. Take a look here: https://github.com/beehive-lab/TornadoVM
Upvotes: 4
Reputation: 968
Consider Aparapi http://aparapi.github.io/. It attempts to convert bytecode to OpenCL at runtime. So you can code for your GPU in pure Java.
Full disclosure, I am the Aparapi lead developer.
Upvotes: 14
Reputation: 388
The Rootbeer GPU Compiler supports running arbitrary Java code on the GPU. It is more full featured than Aparapi. Rootbeer supports arbirary object graphs of any type.
It was just released open source on my github account: https://github.com/pcpratts/rootbeer1
Upvotes: 11
Reputation: 56
Have a look on http://code.google.com/p/java-gpu/.
It compiles pure java code into kernels, with only using annotations.
Upvotes: 2
Reputation: 206816
There are several Java bindings to CUDA and OpenCL (jcuda.org, jocl.org, something else also called jocl) but these are all just ways to get CUDA or OpenCL code running on the GPU via Java and require you to write your code specifically for that. I don't think there is an easy way to run an arbitrary multi-threaded Java program on the GPU with just minor changes to the code.
What does your Java program do that you want to run on the GPU?
You have to take into account that the architecture of a GPU is quite different than that of a CPU; cores on a GPU are not general-purpose cores that can do anything and work independently, as in an Intel x86 CPU. To really take advantage of the specific SIMD architecture of a GPU, your code has to be written with that architecture in mind.
Upvotes: 8