OpenCL vs. DirectCompute?
Asked Answered
K

5

20

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.

Kenyakenyatta answered 3/7, 2010 at 17:16 Comment(7)
You might want to reconsider your stance on CUDA, it's pretty kickass, as is nvidia hardware.Noh
@Noh 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.Pyrrolidine
@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.Noh
@Noh 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?).Pyrrolidine
@Benson: does CUDA supports append buffer, consume buffer?Brushwood
@Simon When I last compared them, CUDA provided a higher level programming model that OpenCL. It gave you an API to push and pull from the device, and then a high level C-based model for writing GPU code (called "kernels"). It spawns threads automatically for each cell in your matrix to run your code. My understanding of OpenCL is that it's closer to the metal, and therefore more time consuming to use and maintain. @Stringer: I'm not sure what you mean; it does have support for comuting results while transferring data.Noh
@Benson: it's some kind of buffers that let you stream data into it (like with geometry shaders) or consume it. So what you get is a two-pass Producer/Consumer model. OpenCL will have it too for version 1.1. khronos.org/message_boards/viewtopic.php?f=41&t=2160Brushwood
L
16

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.

Longbow answered 4/7, 2010 at 2:46 Comment(2)
What does OpenGL support on windows have to do with OpenCL...? The important thing is the difference in support between the vendors; AMD supports OpenCL very well and has support for newer versions, NVIDIA (which has the competing CUDA product) only supports CL 1.1 (with image extensions etc.) Also, OpenCL guarantees certain things DirectCompute (and Compute Shaders from OpenGL) do not, like IEEE floating point compliance.Promising
When I wrote this, and I think it is still the case, the low level video card drivers are the same for each technology. Please read carefully what I say: "This may translate to more stable support..." This is speculation, but not baseless, since the protocol to move memory and functions to and from the video card is the same for either stack, and for DirectCompute shares the same amount of testing and robustness that the better supported DirectX enjoyed. Again, at the time I wrote this.Longbow
P
14

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.

Pyrrolidine answered 4/7, 2010 at 2:32 Comment(1)
DirectCompute does not run on CPU resources, however the Accelerator v2 from MSR does run on the CPU, and rather abstracts the usage of computational resources. research.microsoft.com/en-us/projects/acceleratorLongbow
O
5

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...

Orelee answered 22/7, 2010 at 8:57 Comment(0)
A
3

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

Axletree answered 16/3, 2012 at 22:32 Comment(1)
I was under the impression that only Visual Studio 2012 can compile C++ AMP code - does that not count as "a need for a separate compiler"?Hepatica
A
1

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.

Aigneis answered 10/7, 2010 at 22:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.