
OpenCL components
Before delving into the programming aspects in OpenCL, we will take a look at the different components in an OpenCL framework. The first thing is the OpenCL specification. The OpenCL specification describes the OpenCL programming architecture details, and a set of APIs to perform specific tasks, which are all required by an application developer. This specification is provided by the Khronos OpenCL consortium. Besides this, Khronos also provides OpenCL header files. They are cl.h
, cl_gl.h
, cl_platform.h
, and so on.
An application programmer uses these header files to develop his application and the host compiler links with the OpenCL.lib
library on Windows. This library contains the entry points for the runtime DLL OpenCL.dll
. On Linux the application program is linked dynamically with the libOpenCL.so
shared library. The source code for the OpenCL.lib
file is also provided by Khronos. The different OpenCL vendors shall redistribute this OpenCL.lib
file and package it along with their OpenCL development SDK. Now the application is ready to be deployed on different platforms.
The different components in OpenCL are shown in the following figure:

Different components in OpenCL
On Windows, at runtime the application first loads the OpenCL.dll
dynamic link library which in turn, based on the platform selected, loads the appropriate OpenCL runtime driver by reading the Windows registry entry for the selected platform (either of amdocl.dll
or any other vendor OpenCL runtimes). On Linux, at runtime the application loads the libOpenCL.so
shared library, which in turn reads the file /etc/OpenCL/vendors/*.icd
and loads the library for the selected platform. There may be multiple runtime drivers installed, but it is the responsibility of the application developers to choose one of them, or if there are multiple devices in the platforms, he may want to choose all the available platforms. During runtime calls to OpenCL, functions queue parallel tasks on OpenCL capable devices. We will discuss more on OpenCL Runtimes in Chapter 5, OpenCL Program and Kernel Objects.