O'Reilly logo

Intel Threading Building Blocks by James Reinders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Game Threading Example

This example clearly illustrates how rethinking parallelism can result in a decomposition that is better suited to scaling. This example also emphasizes building your own structures with Threading Building Blocks tailored to your particular specialty. You’ll find more information and downloads on the Web for the particular gaming framework used here. For the purposes of this book, we’ll focus on the key design decisions and show the code that uses the task scheduler directly.

Games, like many programs, have been threaded for the sake of convenience rather than performance. Specifically, games have often been threaded along function lines and nothing more. In order to fully utilize many cores, this example shows how to thread a game using a functional pipeline with domain decomposition. This example demonstrates several ways to reach the next level of scalability in game architecture. Most threading of games has traditionally focused on functional parallelism and data parallelism. The former is pretty straightforward: one thread for rendering, one thread for physics, and so forth. Data parallelism generally comes in waves with serial interludes, as shown in Figure 11-24.

Data parallelism with serial section between

Figure 11-24. Data parallelism with serial section between

In this example, we concern ourselves with rendering stars after determining positions based on physics. We go beyond data parallelism ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required