Power Your Apps With GPU Programming

A computer’s CPU traditionally carries the application workload, but developers can now tap a programming approach that engages the graphics processing unit (GPU) as well.

The concept, referred to as General Purpose GPU, or GPGPU, essentially makes the GPU available for computing chores other than graphics. The ability to offload tasks from overtaxed CPUs can boost application performance. In addition, writing programs to leverage more resources make for improved energy management — tasks can be targeted toward the parts of a system that consume less power.

A couple of key frameworks make GPGPU happen. OpenCL, a Khronos Group specification, provides an API set and programming language that lets coders write programs that use all of a system’s resources. On the proprietary side, NVIDIA’s CUDA, which the company describes as a parallel computing platform and programming model, also makes use of GPU power.

To date, GPGPU, or GPU programming, has made the biggest mark on desktop and notebook computers. But mobile devices — processor-constrained smartphones and tablets — also stand to benefit. However, widespread use of GPGPU in the mobile app development space may be a couple of years away.

The Benefits of GPU Programming

“The key benefit of programming GPUs is high performance of calculation operations,” says Eugene Filipkov, senior game developer at Eligraphics Studio in Minsk, Belarus. “GPUs can carry out an enormous number of simple operations in parallel to CPUs — more complex operations can be calculated by CPUs and simpler operations by GPUs.”

As a game developer, Eligraphics limits its involvement with GPU programming to the vertex and pixel shaders for games, Filipkov explains. He suggested the company’s use of GPU programming could increase in the future. If Eligraphics decides to create its own 3D engine, for example, the effort would involve parallelizing tasks and transitioning elements of computing to the GPU.

Arnon Peleg, software products marketing manager at Intel, says he takes a broader view of GPU programing. He points to OpenCL as a key enabler. “We are talking about platform programmability and not only CPU or graphics,” he says. “OpenCL is a standard programming language. What it brings to you is a way to access the computing firepower of the entire platform.”

At this point, Intel supports OpenCL on client PCs and Ultrabooks. The company has not announced support for OpenCL on smartphones and tablets. But in the case of Intel-equipped Ultrabooks, for example, OpenCL lets developers access both the CPU and Intel HD graphics in a standard manner.

“The performance on the entire platform is the key here,” says Peleg. “It is the ability to program the overall platform and utilize the power of the entire platform and get the most power efficiency.”

As for the latter point, a developer can program an application to run code on the least power-consuming system component, which is typically the graphics component. Developers who balance their code between the CPU and Intel HD graphics can, potentially, create applications that use energy more efficiently, notes Peleg.

GPGPUs: Shifting to Mobile Development

Neil Trevett, vice president of mobile content at NVIDIA and president of Khronos Group, says GPU and cross-platform programming will eventually work its way down to mobile devices.

“Silicon and IP vendors are working now to build CUDA/OpenCL-programmable GPUs into the power budget of mobile phones at a useful level of performance,” says Trevett. He calls that task a non-trivial exercise. That said, he says he believes the next two years will see multiple system-on-a-chip integrated circuits for phones and tablets emerging with that capability, making it a useful feature for developers to target.

“I think the first beachhead applications to take advantage of GPU programmability will be image and vision processing, computational photography and video editing/analysis,” says Trevett. “Also, games will use this capability to accelerate physics and simulation engines — just like desktop games today.”

YOUi Labs, based in Ottawa, adds Natural User Interfaces (NUIs) to the list of software that can benefit from GPU computing. The company, which focuses on developing NUIs for embedded platforms, reasons that NUIs require more computational power than traditional graphical user interfaces. A YOUi Labs whitepaper states that making use of available GPU cycles is important for maximizing the hardware’s capability for an NUI.

“This process of using GPUs as [GPGPUs] has been traditionally limited to desktop computing platforms, but as portable devices are becoming more powerful, encompassing multiple-core CPU and GPU elements, implementation becomes crucial for efficient use of the hardware’s capability,” the whitepaper says.

Jason Flick, chief executive officer of YOUi Labs, says GPU programming is headed for mobile devices, noting that OpenCL drivers are already showing up on pre-production hardware. He says about half of the development boards in the next six months will have OpenCL support, although at the moment only a few have that feature.

“It certainly will be moving into that space,” he says of GPGPU and mobile devices.