I want to do some GPU programming. What's the way to go here? I want to learn something that is "open" , cross platform and a "higher" language. I don't want to be lock into just GPU vendor nor OS, platform, etc.
What are my choices here? Cuda, OpenCL, OpenMP, other? What's the pros/cons for them?
What about G/HLSL and PhysX?
I'm looking at doing "general purpose" programming, some math, number crunching, simulations, etc. Maybe spit out some pretty graphics, but not specifically graphics programming.
-
I spent about a year doing OpenCL. Forgot how to program in C++ because of it. It turns out most of the claims about GPU performance are way off. For double floating point you might as well forget about it. For single floating point there is an advantage over the CPU by a factor up maybe 5. That's still significant but it requires a lot of investment. I don't know about integers. AMD GPUs are popular in bitcoining for a reason. I now mostly do OpenMP and SIMD on the CPU. AVX-512 will be out in a few years and I think Intel will close the gap on single float and dominate on double.Z boson– Z boson2014年04月15日 10:41:45 +00:00Commented Apr 15, 2014 at 10:41
6 Answers 6
The answer marked correct is now outdated and incorrect. In particular OpenMP 4.0 supports GPU acceleration.
Comments
OpenMP is cpu only, but easy to implement, CUDA is basically GPU only. Ati Stream supports both, but only on Ati/AMD gpu's. OpenCL is your only "open" option that supports both.
3 Comments
Nowadays - 2013/2014 - there is C++ Accelerated Massive Parallelism (AMP) of Microsoft. This is a high level language that compiles to High Level Shader Language (HLSL) so you do not have to write kernel code etc.
A simple and easy to read comparison between OpenCL and C++ AMP is done by the AMD folks and is found here (click!).
Comments
The GPU support for openMP will be available in near future:
Comments
If you want to get involve with GPU and at higher level than OpenCL you might have a look to Matlab. There is a chance to program GPUs via Matlab and you do not need to learn lower models such as OpenCL and CUDA. CUDA it will be more efficient as you probably are going to program a NVIDIA card. However, openCL is the standard for GPGPUs and the way to code is pretty similar. Although you might find not very difficult to use CUDA or openCL, you will really find much harder to optimize them.
I hope it helps.
Comments
Open CL is open but I've heard that a downside to this is the lack of documentation. ATI might be a better between NVIDIA and ATI since it was reportedly faster in 2009 but I'm not sure if those stats are still correct.