Reputation: 23
I'm going to be starting a project using parallel processing, and I am wondering if I will get more optimization from using Java threads or from Cuda programming? Also I'm not an expert with either scheme, which route would have the smaller learning curve?
Upvotes: 1
Views: 1018
Reputation: 533530
A GPU is useful if you have a simple task you need to perform many times (thousands or more) You can access a GPU using OpenCL. A Java wrapper for this is http://www.jocl.org/ Others are http://jogamp.org/jocl/www/ and http://code.google.com/p/nativelibs4java/wiki/OpenCL but I haven't tried them.
A CPU is much better for general purpose programming. You may be surprised how much you can get done in a single thread let alone on a Socket with many cores.
Upvotes: 0
Reputation: 803
The short answer: It depends on the problem you are trying to solve.
The long answer:
There are some very fundamental differences between parallel processing in Java and Cuda. A big difference is how the jobs are packaged up and executed. In Java, you're going to write a program that loads the data and then you'll use something like an ExecutorService to execute your tasks. In Cuda you will load the data, but then write a piece of code that actually does the execution (in Cuda, this is called a kernel). Sounds similar, right? But not really. There is additional memory overhead involved in Cuda. A GPU has limited memory so your software has to first load the data, then package it up as a part of the kernel then send it over to the GPU which then stores the data and performs the computation. Then your application has to retrieve the results. This works really well for some computational problems, but is really inefficient for other computational problems. It all depends on what you are trying to accomplish.
Upvotes: 4