Compute APIs are a new evolution in the mobile and embedded market space, and are subject to quite a range of different conceptual approaches compared to the evolution of 3D graphics API. The mobile-optimised OpenGL ES API for 3D graphics evolved from a market-tested and well-proven OpenGL API for desktop PCs; this allowed a rapid API evolution with fairly little risk. In the mobile space, two offerings are currently competing for developer attention: the Khronos developed OpenCL API (OS agnostic) and the Google Android-specific Renderscript API. While the goal of both APIs is the same in exposing parallel compute functionality, the approach and vision behind both APIs is very different, as I’ll discuss below.
Compute is far newer as an API concept, and the desktop market is still in the early days of API evolution, where a hardware-specific proprietary API called CUDA is playing a significant role. Custom APIs though are an approach long-abandoned in the 3D space. As a result, compute APIs are all still very young and are going through the usual growing pains, as the software and hardware vendors find the most optimal approaches and balanced feature sets.
OpenCL – a bottom-up development approach
OpenCL, developed by the Khronos Group, builds on the proven concepts of the other open APIs, and follows a logical hardware-driven evolutionary approach. Specifically, this means that an initial version of the API has been created with a feature set in-line with the feature set available in products. As with the Khronos 3D APIs, a desktop hardware optimised variant exists, and a mobile/embedded hardware optimised variant exists.
Unlike the Khronos 3D API, which has two different and separate API developments (OpenGL and OpenGL ES), the compute API OpenCL takes a different approach. This approach is a bit more like that of Microsoft DirectX, in that it exposes different feature levels: a desktop Full Profile and an embedded/mobile optimised variant called the Embedded Profile.
Additionally, in line with the OpenGL concept, the OpenCL API also allows for extensions. These are extra features which can be exposed optionally, and are typically used to check market feedback on new features that were just not convincing enough to make it into the core specification. Over time, these extensions can be deprecated and fall to the side, or may be adopted into the core if enough Khronos Group members decide they are useful.
The development approach of OpenCL is a bottom-up approach, in that the API starts from the feature set supported by hardware. The API does not typically expose new features until they are usable, allowing for a simple and straightforward approach where over time newer functionality is added to the API as the hardware evolves. The two profiles in OpenCL allow for the embedded market to evolve in line with its far more power-limited requirements, while the desktop profile can concentrate on high-performance compute usage cases which are not (or are far less), limited by power budgets.
The diagram below shows the bottom-up, hardware and market segment focussed approach of the OpenCL API. Over time, incremental OpenCL versions have been released in line with hardware capabilities and market requirements – with 2 specific profiles – a Full Profile (FP) focussed on the desktop High Performance Compute (HPC) market segment, and an Embedded Profile (EP) focussed on the mobile low power consumption focussed market segment.
This development approach is fairly hardware-centric, and it allows for a trivial link between hardware generations and API versions. From a software point of view, this approach is also interesting, in that any new feature exposed is also a feature which is likely to be available and run at full performance. The disadvantage is that software must be rewritten over time to take advantage of the new features added in later versions of the API.