Can you run Java on a GPU? |
Can you run C++ on a GPU?
If you treat both questions literally, then answer is: no to both*.
But if I interpret your question as - can you write a Java program that does some computations on GPU, with a little help of additional API or DSL - then answer is: obviously yes!
See: JOCL, JavaCL, OpenCL4Java. There are probably also some CUDA bindings.
* Actually ScalaCL can run Scala on GPU in such a way, that there is no need to learn any special language nor complex API. All you use is pure Scala code. I guess you can't do it with C++ - e.g. CUDA compiler understands only C.
// Added later: oh, actually Java can be run on GPU thanks to rootbeer1 which directly compiles Java bytecode to CUDA:
https://github.com/pcpratts/rootbeer1
Obviously you wouldn't care for half a day, why do you say it's no slower then say it'd take an extra 12 hours ? 12 hours is a significant amount of time if you are waiting for it |
So you lost 12 hours for longer Java execution, but saved a week or more for coding. That's scientists use Python or MatLab even more often, although it is much slwoer than Java. What I do in Python or MatLab in a day, it would take a month in C++. Execution time is then irrelevant. In science most time goes into preparation of experiment (in CS: designing and coding the algorithms), not running the experiment itself.