Chapter 34. GPU Flow-Control Idioms

Mark HarrisNVIDIA Corporation

Ian BuckStanford University

Flow control is one of the most fundamental concepts taught to beginning programmers. Branching and looping are such basic concepts that it can be daunting to write software for a platform that supports them in a limited manner. The latest GPUs support vertex and fragment program branching in multiple forms, but their highly parallel nature requires care in how they are used. This chapter surveys some of the limitations of branching on current GPUs and describes a variety of techniques for iteration and decision making in GPGPU programs.

Flow-Control Challenges

Let’s start by discussing the most obvious form of flow control on GPUs. All current high-level ...

Get GPU Gems 2: Programming Techniques for High-Performance Graphics and General-Purpose Computation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.