FeaturedIT topics

BrandPost: OpenCL Is for GPUs Too

OpenCL started as a solution for GPUs, but it has recently received a lot of attention as a solution for FPGAs. So much so, in fact, that I’ve heard people wonder if OpenCL was for GPUs still. Yes, it is. More than ever! OpenCL is an important heterogeneous language, and the support for GPUs—as well as for FPGAs—continues to grow.

Why OpenCL?

OpenCL offers a clever, portable, and effective way to see which devices are present (e.g., a GPU), and to perform certain computations with less power and possibly higher performance than a CPU. It’s incredibly easy to use, and with GPUs included on virtually all systems, it’s definitely something to experience (see the link below for a “Hello World” example as well as download links).

The OpenCL models

 OpenCL consists of two parts: an API (library calls) to find and move programs and data to/from attached devices (e.g., a GPU), and a compiler to generate code to run on the attached device. The code compiled for a device is written using a subset of C, with some recent additions to support a subset of C++. In other words, the entire program looks like C or C++ code for the host and the target device (e.g., GPU or FPGA).

A typical OpenCL program will: (1) query what devices are available, (2) ask a device to load a program, (3) load data to the device, (4) ask the device to execute the load program, and (5) retrieve output data from the device. This is all done with easy-to-understand function calls using the C-like OpenCL API.

No matter what device is targeted, if the target is not available the CPU can be used to run the code. The diagram below illustrates that with the Intel® SDK for OpenCL™ Applications for Intel® processors and graphics technology we can have a system for (1) developing code plus running on a CPU or GPU, (2) running on a CPU or GPU, or (3) running on a CPU. This is the support we expect from an OpenCL SDK. While the language for OpenCL is a common standard, support for OpenCL comes as both a compiler and drivers for particular vendors and supplied by those vendors.  In addition to Intel OpenCL for Intel GPUs, there are separate OpenCL kits available for Intel FPGAs, and more. Such widespread support helps explain the popularity of OpenCL.

Intel support for GPUs is a great place to start

Intel has steadily added support for additional operating systems and platforms, and integration into recent IDEs for flexibility. The Intel SDK allows developers to customize heterogeneous compute applications and accelerate performance by offloading compute to Intel® Graphics Technology tailored to application needs. Code can be run on an Intel CPU in place of a GPU (this can make testing easier, especially while learning OpenCL). OpenCL with an Intel GPU can be used to deliver high-performance image and video processing pipelines—and enhance power efficiency. There are also extensions available for this utility. 

The latest Intel SDK is available from the Intel® SDK for OpenCL website. Because a driver (runtime) package (for GPU/CPU or CPU-only) is required in addition to the SDK to execute applications, OpenCL users and developers should also ensure that they have the latest driver updates installed.

Useful links for more information

·         Intel® SDK for OpenCL™ Applications Homepage (with downloads)

·         A simple “Hello World” compute example in OpenCL (Apple website)

·         Intel® Parallel Studio XE 2019 Beta Signup – includes complementary tools (all free)

·         FPGAs and OpenCL: What’s Up? 

·         Intel OpenCL Forum

Related Articles

Back to top button