Contents
Sponsored Feature: Optimizing Game Architectures with Intel Threading Building Blocks
 
 
Printer-Friendly VersionPrinter-Friendly Version
 


Part of:



[More information...]
 

Latest News
spacer View All spacer
 
November 22, 2009
 
Video Game Watchdog National Institute On Media And The Family Shutting Down [11]
 
Modern Warfare 2 Infinity Ward's 'Most Successful PC Version' Yet [14]
 
New Tech, Design Details Of Project Natal To Emerge At Gamefest In February
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
November 22, 2009
 
Trion Redwood City
Sr. Environment Artist
 
Trion Redwood City
Sr. Evnironment Modeler
 
Sucker Punch Productions
Network Programmer
 
Sucker Punch Productions
Texture Artist
 
Sucker Punch Productions
Character Artist
 
Sucker Punch Productions
3D Environment Artist
 
Crystal Dynamics
Sr. Level Designer
 
Sony Online Entertainment
Brand Manager
spacer
Latest Features
spacer View All spacer
 
November 22, 2009
 
arrow Upping The Craft: Susan O'Connor On Games Writing [6]
 
arrow Small Developers: Minimizing Risks in Large Productions - Part II [7]
 
arrow iPhone Piracy: The Inside Story [50]
 
arrow And Yet It Grows: Analyzing the Size and Growth of the European Game Market [5]
 
arrow NPD: Behind the Numbers, October 2009 [13]
 
arrow Reflecting On Uncharted 2: How They Did It [5]
 
arrow Sponsored Feature: Rasterization on Larrabee -- Adaptive Rasterization Helps Boost Efficiency
 
arrow Postmortem: Wadjet Eye's The Blackwell Convergence [2]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
November 22, 2009
 
Managing Creativity
 
Time Fcuk - A Postmortem [3]
 
Accepting the Inherent Value of Games
spacer
About
spacer News Director:
Leigh Alexander
Features Director:
Christian Nutt
Editor At Large:
Chris Remo
Advertising:
John 'Malik' Watson
Recruitment/Education:
Gina Gross
 
Features
  Sponsored Feature: Optimizing Game Architectures with Intel Threading Building Blocks
by Brad Werth
0 comments
Share RSS
 
 
March 30, 2009 Article Start Previous Page 5 of 5
 

Long, low-priority operation

Games occasionally rely upon computation that needs to run continuously but not at the expense of other more immediate work. Level loading, asset decompression, and AI pathfinding are common examples. These tasks can be set up to run on dedicated threads, but this exposes the problem of the continuous operation fighting for hardware resources with more immediate work. Priority APIs can help defend against this, but usually cannot guarantee that no conflict will happen. Intel TBB can implement this technique without introducing additional threads and therefore without introducing the possibility of conflict.


Figure E: Time slice a low-priority operation into the work tree.

Figure E shows parts of two work trees. On the left is some middle section of a large work tree. On the right is a root that is hosting some low-priority tasks. The Parent on the left, before spawning its own children, tests a flag for the need to initiate a low-priority task. If so, it clears the flag and adds a low-priority task to the root.

The low-priority task is added to a root with a very small task depth. If the thread that executes the Parent completes all of its other work, it will run the low-priority task. As other Intel TBB threads exhaust their own supplies of tasks to run, they will engage in stealing work from each other. If one of these other threads steals from the original thread, the low-priority task will be the one stolen due to its minimal depth value. This ensures that low-priority tasks are run periodically but infrequently even when the work tree continues to grow.

Sample 7: Adding low-priority tasks to a work tree

tbb::task *execute()
{
...
if(s_tLowPriorityTaskFlag.compare_and_swap(false, true) == true)
{
// allocation with "placement new" syntax, see TBB reference documents
tbb::task *pLowPriorityTask = new(
this->allocate_additional_child_of(*s_pLowPriorityRoot)
) LowPriorityTask();

spawn(*pLowPriorityTask);
}

// add some children
...
}

 

Sample 7 shows the test for low-priority operations as part of a base class's implementation of tbb::task::execute. This hypothetical base class would be used for all normal-priority tasks in the work tree. An atomic flag is used to test if a low-priority task should be created. This flag is set to true again when the low-priority task completes.

Game architectures will continue to use long, low-priority operations for certain types of tasks. Using this modified time-slicing scheme, a game architecture based on Intel TBB can accommodate this need without introducing extra threads and associated competition for hardware resources.

Other Features of Intel TBB Relevant to Game Architectures

Throughout the samples in this article, some core features of Intel TBB have been used without due explanation. These low-level objects provide a cross-platform encapsulation of basic synchronization and timing APIs, which are commonly used in game architectures. The APIs for all of these objects are described in detail in the Intel TBB reference documentation.

Atomics

As shown in Samples 6(a) and 6(b), Intel TBB's atomics provide a simple syntax for atomic compare-and-swap operations.

Mutexes

Intel TBB provides mutual exclusion objects with a variety of contention policies. Spinning, blocking, read-write, and recursive mutexes are available.

Time intervals

Intel TBB encapsulates each host platform's high-frequency timer into a simple API.

The Future of Intel TBB

Intel TBB has a bright future ahead in game architectures. With the variety of multi-core topologies in the major gaming platforms, developers are faced with the challenge of designing an architecture that is high performing without requiring extensive per-platform tuning. Because Intel TBB is an open-source library, it has great flexibility for the gaming platforms of the future. Wherever Intel TBB is implemented, it will continue to provide game architectures with high-performance threading through its flexible API.

Intel TBB is available at no cost from opentbb.org for Microsoft Windows, Mac OS X, Linux, Solaris, and Microsoft Xbox 360. It ships with Intel compilers. You can learn more about Intel TBB at opentbb.org and in the O'Reilly nutshell book Intel Threading Building Blocks by James Reinders.

 
Article Start Previous Page 5 of 5
 
Comments

none
 
Comment:
 


Submit Comment