For a lot of people, disruptive technology makes them uncomfortable. It changes the rules. It takes you out of your comfort zone. Not me—I love it.
Traditionally, the way we think about software development is that you have a CPU (central processing unit) and a GPU (graphics processing unit), and each is good at handling certain sets of tasks. The x86 CPU is good at executing a sequence of stored instructions, and even has the ability to handle multiple instructions simultaneously (instruction-level parallelism). The GPU is a powerful vector engine that can operate simultaneously on multiple data items (data parallelism). Developers have used the CPU for handling the majority of computational tasks, and the GPU for visualization and graphics-related functions. But it’s time to forget conventional wisdom and to rethink everything.
The GPU isn’t just for visualization anymore. The world is waking up to the fact that GPUs are high-performance, many-core processors that can be used to accelerate a wide range of applications. This knowledge is driving a shift in how applications are developed and accelerated.
This shift began with hardware optimizations in the GPU that enable software to harness its processing power for more general data structures. Microsoft’s Windows 7 and Apple’s Snow Leopard are prime examples of software designed to leverage next-generation graphics technology. And now the software development community has to figure out how to harness the GPU for computational tasks that can benefit from its very high computation and data throughput capabilities.
Let’s take a quick look at tools for programming the GPU. We have moved beyond the era where programming the GPU was a “bare metal” experience. Graphics libraries like Microsoft DirectX and OpenGL are widely used today for “traditional” GPU functions, such as creating 2D and 3D graphics and performing multimedia operations like image rendering, video transcoding, and even HD video conferencing.
DirectX is a set of low-level application programming interfaces (APIs) that includes support for high-performance 2D and 3D graphics, sound, and input. Components of DirectX include Direct2D, Direct3D and DirectCompute (more about that later). Several of these APIs use the GPU for hardware acceleration of tasks. For example, Direct2D is an immediate-mode, 2D graphics API introduced with DirectX 11 that utilizes hardware acceleration for high-performance and high-quality rendering for menus, user-interface elements, and heads-up displays. These APIs are used with Microsoft’s developer tools, mainly Visual Studio.
OpenGL is a cross-platform, low-level procedural API maintained by The Khronos Group. It is used to develop portable, interactive 2D and 3D computer graphics applications, and it offers a broad base of rendering, texture mapping, special effects and other powerful visualization functions.
OpenGL is a specification based on the C programming language, and can be accessed by other programming languages with the proper bindings (which exist for Fortran, BASIC, Visual Basic, Python, Perl, Java, Ruby and C#, to name a few). Like DirectX, OpenGL will offload computation to the GPU in certain tasks.