Ubuntu – OpenCL programming on CPU and GPU with Nvidia cards

10.10intelnvidiaopenclprogramming

I have a bi Xeon machine with Ubuntu 10.10 and a Nvidia GTX 480 graphic card on it and I'd like to use OpenCL on the CPU and the GPU.

I installed the latest Nvidia driver (nvidia-current) with apt-get and I downloaded and installed the latest CUDA Toolkit (3.2) from the Nvidia page.

BUT this allows me only to run OpenCL code on the Nvidia GPU and NOT on the CPU.

I then read some articles on the internet saying that the ATI SDK is able to run OpenCL code on the CPU.

I installed the latest version of ATI drivers then tried to compile the SDK.

I was then able to run code on the CPU but not on the GPU anymore.

Is there any way to run OpenCL code both on the Nvidia GPU and the Xeon CPU ?

Best Answer

Both Nvidia CUDA and ATI Stream OpenCL implementation support the Khronos ICD extension, so when you call clGetPlatformIDs you'll get two different platforms, and therefore you can query for CPU/GPU devices on these platforms and of course the ATI platform will return the CPU device and Nvidia platform will return the GPU device.

Then you can create CommandQueues on these devices and start your kernel. Of course this means that it's not trivial to share the task between GPU and CPU, but at least having a button in your app that switches from CPU to GPU would be quite easy to do.

Related Question