OpenCL (Open Computing Language) Overview and SDKs
OpenCL (Open Computing Language) is a multi-vendor open standard for general-purpose parallel programming of heterogeneous systems that include CPUs, GPUs and other processors. OpenCL provides a uniform programming environment for software developers to write efficient, portable code for highperformance compute servers, desktop computer systems and handheld devices. OpenCL standard is managed and defined by the Khronos Group.
The latest version (OpenCL 1.1) was ratified by the Khronos Group on the 14th of June 2010 and adds significant functionality for enhanced parallel programming flexibility, functionality and performance including:
- Host-thread safety, enabling OpenCL commands to be enqueued from multiple host threads.
- Sub-buffer objects to distribute regions of a buffer across multiple OpenCL devices.
- User events to enable enqueued OpenCL commands to wait on external events.
- Event callbacks that can be used to enqueue new OpenCL commands based on event state changes in a non-blocking manner.
- 3-component vector data types.
- Global work-offset which enable kernels to operate on different portions of the NDRange.
- Memory object destructor callback.
- Read, write and copy a 1D, 2D or 3D rectangular region of a buffer object.
- Mirrored repeat addressing mode and additional image formats.
- New OpenCL C built-in functions such as integer clamp, shuffle and asynchronous strided copies.
- Improved OpenGL interoperability through efficient sharing of images and buffers by linking OpenCL event objects to OpenGL fence sync objects.
- Optional features in OpenCL 1.0 have been bought into core OpenCL 1.1 including: writes to a pointer of bytes or shorts from a kernel, and conversion of atomics to 32-bit integers in local or global memory.
You can download OpenCL 1.1 Specification free of charge. The specifications are 385 pages long, if you just want to have a look at OpenCL API, please have a look at the 6 pages OpenCL 1.1 API Quick Reference card.
Online documentation is also available for OpenCL 1.1.
The OpenCL programming language used to write computation kernels is based on C99 (So it looks very much like C programming) with some limitations and additions. It omits the use of function pointers, recursion, bit fields, variable-length arrays, and standard C99 header files.The language is extended to easily use parallelism with vector types and operations, synchronization, functions to work with work-items/groups. It has memory region qualifiers: __global, __local, __constant, and __private. A lot of built-in functions are also added. The file extension for OpenCL files is usually “.cl”.
There are several companies providing OpenCL development kits:
- AMD APP SDK: The AMD APP SDK (Latest v2.5) has OpenCL 1.1 support for AMD CPU and APU. The SDK is available in 32-bit and 64-bit versions for Linux (openSUSE 11.x, Ubuntu 10.0x, Red Hat Enterprise Linux 6.x) ,Windows Vista and Windows 7.
- Intel® OpenCL SDK 1.1: Intel OpenCL SDK 1.1 is Intel’s implementation of the OpenCL standard optimized for Intel processors, running on Microsoft Windows and Linux operating systems. This SDK implementation is fully conformant with the OpenCL 1.1 specification for the CPU and with Microsoft Windows 7. The SDK is targeted to applications optimized for Intel Core and Intel Xeon processors.
- IBM OpenCL Development Kit: OpenCL Common Runtime (OCR) for Linux on x86 Architecture and OpenCL Development Kit for Linux on Power. You’ll need to register to access the SDKs.
- Nvidia OpenCL v1.1 drivers and SDK code: The Nvidia drivers have OpenCL support. You can refer to Nvidia OpenCL Programming Guide to program with the CUDA architecture, access OpenCL Code samples, use Visual Profiler to optimize OpenCL applications or browse/ask questions OpenCL Forum.
- Ziilabs OpenCL SDK: OpenCL 1.1 implementation for ZMS-xx processors. You’ll need to register and provide your project details in order to receive the SDK.
Linaro (Non-profit organization working on Linux for ARM) also considers developing an OpenCL toolchain based on GCC or LLVM.