20
votes

I'm looking for comparisons between OpenCL and DirectCompute, but I haven't found anything. OpenCL's advantages of being cross-platform and having a wider range of supported GPUs don't matter to me. I'm fine with coding on Windows against DX11 GPUs only. Assuming that, what are the pros and cons of each API?

I know this question was raised before, but I'm looking for more details.

I'm not interested in CUDA, since I don't want to restrict myself to only Nvidia hardware.

5
You might want to reconsider your stance on CUDA, it's pretty kickass, as is nvidia hardware. - Benson
@Benson Assuming that all your users have Nvidia hardware seems like a pretty big failure. Best to actually stick to a standardised API such as OpenCL or DirectCompute. They both offer the same advantages of CUDA without the disadvantage of only working on Nvidia hardware. In fact nowadays one has to question the decision to use CUDA at all when there are other APIs that do exactly the same thing on any number of different hardware systems. - Cromulent
@Simon Do they really? I admit it's been a few months since I did any comparison, but last I checked CUDA was an order of magnitude more complete and feature rich. You make other assumptions when you use DirectCompute. Meanwhile, not everyone has generic "users". A great many scientific computing projects buy hardware and build the software to run on it. Since we haven't gotten any details from Bob, you can't assume one way or another. - Benson
@Benson We can assume he is not interested in CUDA, because he said he wasn't. Specifically because he didn't want to restrict himself to Nvidia hardware. As for CUDA being more feature rich you'll have to be more specific. I am unaware of any major advantage of CUDA that would persuade me that using it was preferable to a solution that worked on all GPU's (and in the case of OpenCL other hardware devices like CPUs and DSPs and any other OpenCL compatible device - does CUDA allow that?). - Cromulent
@Benson: does CUDA supports append buffer, consume buffer? - Stringer

5 Answers

14
votes

Probably the biggest difference for a coder is that DirectCompute is programmed by a language which is similar to HLSL, and OpenCL is programmed via a C-like language.

Another difference to consider is that, generally, for commodity level GPUs, the DirectX support is better (faster and less buggy) than OpenGL support on Windows. This may translate to more stable support for DirectCompute, but really, this is just speculation.

13
votes

Well the major advantage of OpenCL is that it is not just limited to graphics cards. You can make use of your multicore CPU, Graphics Card and potentially any number of other hardware acceleration devices (DSPs etc) all from the same program.

I'm not sure if DirectCompute allows that freedom.

5
votes

The OpenCL cross-platform-ness is not just a detail, as the host code (the one calling the OpenCL API and submitting kernels) can itself be cross-platform (see link text, link text...).

Write once, run on any GPGPU, anywhere.

Otherwise the OpenCL tooling is really getting better, with an ATI Stream plugin for Visual Studio, the NVidia & ATI SDKs that contains tons of samples, etc...

3
votes

Another option now is C++ AMP which gives you modern C++ syntax without a need for a seperate compiler while still preserving hardware portability. Please follow links from here for more info and feel free to post questions as you have them: http://blogs.msdn.com/b/nativeconcurrency/archive/2011/09/13/c-amp-in-a-nutshell.aspx

1
votes

I use OpenCL because i can easily port my App to Linux but with DirectCompute this is not possible. I think also that the performance of the OpenCL implementation will increase with time (that it comes at the same Level like CUDA for NVidia Cards) and also that the (driver)bugs will (hopefully ;) ) be eliminated with time.