Multi Threading - How to split the tasks

Posted by Motig on Game Development See other posts from Game Development or by Motig
Published on 2013-10-27T23:15:28Z Indexed on 2013/10/28 4:05 UTC
Read the original article Hit count: 200

Filed under:

if I have a game engine with the basic 'game engine' components, what is the best way to 'split' the tasks with a multi-threaded approach?

Assuming I have the standard components of:

  • Rendering
  • Physics
  • Scripts
  • Networking

And a quad-core, I see two ways of multi-threading:


Option A ('Vertical'):

Using this approach I can allow one core for each component of the engine; e.g. one core for the Rendering task, one for the Physics, etc.

Advantages:

  1. I do not need to worry about thread-safety within each component
  2. I can take advantage of special optimizations provided for single-threaded access (e.g. DirectX offers a flag that can be set to tell it that you will only use single-threading)

Option B ('Horizontal'):

Using this approach, each task may be split up into 1 <= n <= numCores threads, and executed simultaneously, one after the other.

Advantages:

  1. Allows for work-sharing, i.e. each thread can take over work still remaining as the others are still processing
  2. I can take advantage of libraries that are designed for multi-threading (i.e. ... DirectX)

I think, in retrospect, I would pick Option B, but I wanted to hear you guys' thoughts on the matter.

© Game Development or respective owner

Related posts about multithreading