OpenCL ICD

The OpenCL function clGetPlatformIDs is used to determine the different OpenCL implementations available in the platform. There can be multiple OpenCL implementations installed in the system. Let's define an OpenCL platform.

An OpenCL platform is a host computing machine and a collection of heterogeneous devices managed by OpenCL implementations, which allow an application to share hardware resources and execute kernels on different devices in the platform. Devices from different vendors will have their own OpenCL runtimes in the platform. Let's consider a system with an AMD graphics card and an NVIDIA graphics card. Now an AMD OpenCL implementation is not going to work on NVIDIA OpenCL devices. Remember only the code is portable not the underlying OpenCL runtime. So how does an application solve this problem of using the multiple OpenCL runtimes or use multiple platforms. The answer is OpenCL ICD.

What is an OpenCL ICD?

The OpenCL Installable Client Driver (ICD) is a means of allowing multiple OpenCL implementations to co-exist and applications to select between them at runtime. With this it is now the applications responsibility for querying which OpenCL platform is present in the system and which one the application should use, instead of just requesting the default like we did in our first few example wherein we chose the first available platform as default.

What is an OpenCL ICD?

OpenCL ICD and different vendors

In the preceding diagram, an OpenCL application is linked with the OpenCL ICD library. At runtime this ICD shared library (OpenCL.dll in windows and libOpencl.so in Linux) will query the registry and load the appropriate shared library as selected by the application. An application may want to use both the platforms available. The application developer can create a context for each device in the platform, and appropriately execute his algorithm on the device. It is not possible to pass device buffers between two different OpenCL contexts. It is the host applications responsibility to share, transfer, and synchronize data consumption between two contexts.