12

I've been playing with the ATI OpenCL implementation in their Stream 2.0 beta. The OpenCL in the current beta only uses the CPU for now, the next version is supposed to support GPU kernels. I downloaded Stream because I have an ATI GPU in my work machine.

I write software that would benefit hugely from gains by using the GPU. However this software runs on customer machines, I don't have the luxury (as many scientific computing environments have) to choose the exact hardware to develop for, and optimize for that. So my question is, if I distribute the ATI OpenCL implementation with my application, will that mean it will never be able to use e.g. NVidia video cards? And if I use the NVidia OpenCL SDK, that it will never run optimally on AMD chips (considering the ATI/AMD link)?

On other words, who is in the end responsible for providing the OpenCL implementation? Will users be able to e.g. install an OpenCL 'driver' for their NVidia video card, alongside a 'driver' that gives them optimal performance on their AMD CPU?

As an aside, are there any good/active support forums for OpenCL apart from the Khronos message boards, or is that the place to go? I've seen that ATI has a board, and NVidia presumably has their own, where does the OpenCL user/developer community hang out? Has it already consolidated into one place?

2 Answers 2

9

I know this is an old question with old answers above. Thought I would update it with an up to date answer.

Yes, one implementation of OpenCL kernels and code will work on a wide variety of devices today with correctly written platform and device enumeration code. It is pretty easy to write correct platform and device enumeration code, the tricky part is selecting which platform or device. You should probably present a configuration option in your app where the user can select one, or run a microbenchmark against each one and dynamically select one and cache the bench result.

People can and will have more than one platform. For example, my system has GTX 580 SLI, so it has two devices in the NVidia platform. It also has the Intel OpenCL SDK, so my CoreI7 990x Extreme CPU also comes up as a device in the Intel platform.

Yes a binary developed and built using, for example, the NVidia OpenCL SDK, will work on ATI or Intel OpenCL, and vice versa. No need to worry about that anymore.

Obviously, an end user might have no OpenCL whatsoever, so you may need to delay-load or LoadLibrary opencl.dll and dynamic link.

I stronly suggest testing your code against the Intel OpenCL SDK, on NVidia GPUs, AND on AMD GPUs. You will probably find bugs that cause problems on one platform, but works fine on others. You will also probably find that totally fine code mysteriously doesn't give correct results on one of those platforms, due to driver bugs.

1
  • Thanks for that, I was writing a new question to know if things had changed since the first answer...
    – Mikarnage
    Jan 10, 2013 at 9:05
6

Ultimately, OpenCL will work the same way as OpenGL. That is, users will install the current drivers from their hardware vendors (ATI, NVIDIA, Intel). You as the developer will simply link against an OpenCL library when building your applications. When users run your application, the application will redirect to the appropriate vendor specific libraries provided by the drivers.

This is the way it will work, but it does not yet work in this way.

Another important thing to keep in mind is that you will still probably have to provide vendor specific code paths as code running on the CPU using OpenCL will probably use different optimized kernel parameters than code running on the GPU. The same is probably true for differences between GPU vendors.

11
  • The difference with OpenGL is that for OpenGL, the GPU vendor writes the drivers - period. OpenGL only works on the video card. But for OpenCL, ideally the CPU vendor writes the driver for CPU kernels and the GPU vendor writes the drivers for GPU kernels, as OpenCL kernels can run on CPU threads or GPU threads. Is this how it is supposed to work in the future?
    – Roel
    Sep 7, 2009 at 9:42
  • OpenGL always supports a software path for when the hardware doesn't support certain operations. As such, OS vendors must supply a software OpenGL implementation (the MS Windows OpenGL is stuck at OpenGL 1.1). Something similar will probably happen with OpenCL. In any case, AMD/ATI will likely release a version of OpenCL that will support both their CPUs and their GPUs. Similarly, Intel will likely release an OpenCL that supports the regular CPUs and the Larrabee GPUs. I don't know enough about Apple's OpenCL implementation to know what it supports.
    – Eric
    Sep 7, 2009 at 10:21
  • 1
    Ok, so can I conclude from that if a customer has an ATI video card and an Intel CPU, they won't have optimal performance? That, depending on what OpenCL driver/implementation they have installed, they will either run kernels on the CPU or the GPU? I mean I know that it will probably run on the machine, that's not my concern; my concern is, will it run fast (so using all hardware on the machine, all CPU cores and all GPU 'cores').
    – Roel
    Sep 7, 2009 at 12:54
  • The short answer is it's too early to tell, especially in cross-vendor scenarios. Also, there can be orders of magnitude difference between between using all hardware and using all hardware optimally. Catering to the memory architecture and optimal work group size and on the different platforms will be of critical importance to get the maximum performance out of your application. Even if you target only AMD CPUs and GPUs, you will probably need to tune your kernel parameters for each to get the best performance.
    – Eric
    Sep 7, 2009 at 15:57
  • Also, I think you're prematurely optimizing now. OpenCL is "the way of the future" if you want cross-platform, high-performance computing. Focus on learning the details now and optimizing for your current platform. Then later, you can worry about multiple vendors/platforms.
    – Eric
    Sep 7, 2009 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.