[Game Engine] Multi-Threading Programming Resources
Here is a collection of links that can be useful for multithreaded programming. Threads creation, data synchronization, synchrosnous and asynchrosnous models, deadlocks and multithreaded game engine architecture are covered by these links. I will update this article as soon as I discover new resources…
- Multithreaded Programming Guide: A complete multithreading programming guide by Sun MicroSystem. Also available in PDF format HERE.
- Coding For Multiple Cores on Xbox 360 and Microsoft Windows:
A very complete guide about how use multithreading under Windows and Xbox 360. This article shows some examples of multithreaded designs and explains how to create, synchronize and debug threads.
- Lockless Programming Considerations for Xbox 360 and Microsoft Windows
Lockless programming is a way to safely share changing data between multiple threads without the cost of acquiring and releasing locks. This sounds like a panacea, but lockless programming is complex and subtle, and sometimes doesn’t give the benefits that it promises. Lockless programming is particularly complex on Xbox 360.
- Designing the Framework of a Parallel Game Engine: this paper describes the architecture of a multi-threaded game engine that is designed to scale to as many processors as are available. Parallel execution modes such as Free Step Mode or Lock Step Mode are also explained.
- Multi-threaded Rendering and Physics Simulation: Learn how to decouple rendering and physical simulation in a multi-threaded environment with a simple physical simulation demonstration. The sample code provided with this paper can either be used as an example or adapted directly into your game engine.
- Intel Guide for Developing Multithreaded Applications – Part 1 The Intel Guide for Developing Multithreaded Applications provides a reference to design and optimization guidelines for developing efficient multithreaded applications across Intel-based symmetric multiprocessors (SMP) and/or systems with Intel Hyper-Threading Technology
- Multithreaded Game Engine Architectures: This article details parallel models used in multithreaded programming such as synchronous and asynchronous function parallel model or data parallel model.
A game loop parallelized using the synchronous function parallel model. The animation and the physics tasks can be executed in parallel.
The asynchronous function parallel model enables interdependent tasks to run in parallel. The rendering task does not wait for the physics task to finish, but uses the latest complete physics update.
- Threading 3D Game Engine Basics: The goal of this article is to present some of the pitfalls to threading games along with possible solutions. Amdahl’s Law is also detailled: Amdahl’s Law allows to compute the speedup brought by parallel programming.
- Multithreaded Game Programming and Hyper-Threading Technology: This paper aims to introduce the two domains of threading methodology as they apply to game development, and address the most common pitfalls of game programming for Hyper-Threading Technology (HT) enabled systems.
- Multi-Threaded Fluid Simulation for Games: this article explains how to multithread a fluid simulation with TBB (Intel Threading Building Blocks).
- Intel Threading Building Blocks (TBB): Intel Threading Building Blocks (TBB) offers a rich and complete approach to expressing parallelism in a C++ program. It is a library that helps you take advantage of multi-core processor performance without having to be a threading expert. Threading Building Blocks is not just a threads-replacement library. It represents a higher-level, task-based parallelism that abstracts platform details and threading mechanisms for scalability and performance.
- Real-Time Deep Ocean Simulation on Multi-Threaded Architectures: This white paper investigates a technique for real-time simulation of deep ocean waves on multi-processor machines under simulated work loads using threading.
- a href=”http://msdn.microsoft.com/en-us/library/ms810303.aspx”>Detecting Deadlocks in Multithreaded Win32 Applications: this article describes different strategies to detect deadlocks in multithreaded applications.
- Win32 Multithreading and Synchronization: This tutorial will explain how to create and manage multiple threads in Windows. This is an advanced tutorial, the reader should be familiar with Win32 programming.
- Windows Performance Analysis Tools: tools that can be useful for profiling multithreaded apps.
- Multi-Threading: Deadlock Tracer Utility: Tracing deadlocks in multi-threaded applications. Source code is available.
- Introduction to Multi-Threaded Programming: A description of POSIX thread basics for C programmers.
- Win32 Multithreaded Programming – Chapter 1: First chapter of Win32 Multithreaded Programming book.
- Multithreaded Game Scripting with Stackless Python: This seems to be a very interesting for Python programming (and maybe GeeXLab can take adavantage of it):
“Stackless Python is a modified version of the mainstream version based on the work of Christian Tismer. The main feature that makes Stackless so attractive for use as a scripting language is the support for tasklets. Tasklets make it possible to create micro-threads, allowing the programmer to switch among several execution threads that only exist in the python environment and have no dependencies on the underlying OS threads. Some would call these threads”green-threads”. These threads has very small footprint on memory and CPU. You can actually create hundreds of threads with almost no overhead. Every tasklet has only a few bytes of memory overhead. And the scheduling of threads takes O(1) time with a simple Round-Robin scheduling algorithm.”
- Lost Planet Multithreaded Rendering: some details about Capcom multithreaded rendering engine.
- Sponsored Feature: Multi-Core Simulation of Soft-Body Characters Using Cloth: In this Intel-sponsored feature, part of the Visual Computing microsite, Intel senior software engineer Brad Werth explains how multicore CPUs can be leveraged for an efficient method of representing soft-body characters by way of cloth simulation.
- Lock or Be Free:
“Lock step just means all systems update at the same rate. For each frame, all systems update and sync. If a system takes longer to run, the other systems have to wait for it to finish. This is the biggest complaint against lock step. In free step, all systems run at separate frequencies… they update and sync based on events.”
- volatile – Multithreaded Programmer’s Best Friend
“The volatile keyword was devised to prevent compiler optimizations that might render code incorrect in the presence of certain asynchronous events. For example, if you declare a primitive variable as volatile, the compiler is not permitted to cache it in a register — a common optimization that would be disastrous if that variable were shared among multiple threads. So the general rule is, if you have variables of primitive type that must be shared among multiple threads, declare those variables volatile.”
- Volatile: Almost Useless for Multi-Threaded Programming:
“There is a widespread notion that the keyword volatile is good for multi-threaded programming. I’ve seen interfaces with volatile qualifiers justified as “it might be used for multi-threaded programming”. I thought was useful until the last few weeks, when it finally dawned on me (or if you prefer, got through my thick head) that volatile is almost useless for multi-threaded programming.”
- Intel Smoke Multi-Core CPU Tech Demo 1.2
- Multithreading Tutorial: tutorial about win32 multithreading: thread creation, synchronization, etc.
- Managed Threading Best Practices
“Multithreading solves problems with throughput and responsiveness, but in doing so it introduces new problems: deadlocks and race conditions.”
- The Quest for More Processing Power, Part Two: Multi-core and multi-threaded gaming
“In Part 2, we will investigate the advantages and disadvantages of the new market trend: multi-core CPUs. Will dual core enhance your gaming experience? Tim Sweeney, the leading developer behind the Unreal 3 engine, was so kind to answer our questions about multi-threaded development with concise answers.”
- Introduction to Multithreading, Superthreading and Hyperthreading: this article details some common terms such as symmetric multiprocessing, simultaneous multithreading, preemptive multitasking, process, context, and thread, Hyper-threading.
Here is a small glossary about the world of multithreading:
- Hyper-threading: Technology created by Intel for their Pentium 4 processors in which they made the processors pretend to have more than one processor to allow simultaneous execution of threads.
- SMT: simultaneous multithreading also known as hyper-threading.
- SMP: symmetric multiprocessing
- Deadlock: A deadlock occurs when each of two threads tries to lock a resource the other has already locked. Neither thread can make any further progress. Deadlock is a permanent blocking of a set of threads that are competing for a set of resources.
- Race Condition: A race condition is a bug that occurs when the outcome of a program depends on which of two or more threads reaches a particular block of code first. Running the program many times produces different results, and the result of any given run cannot be predicted.
- Multithreading tutorial, part one: Introduction
- Threaded Game Engine @ OGRE forums
- GDC 2008: Getting More From Multicore
- Why multithreaded games are so rare?
- Swarm – the Scalable Multithreaded Game Engine
- Ice Storm Fighters Game Technology Demo