Thread: Multithreading and game development

  1. #1
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072

    Multithreading and game development

    Do you use multi-threading in your games?

    I've never used multi-threading in any game for anything other than playing music. I don't know of any game with heavy calculations being done in multiple threads.

    But today's (and tomorrow's) processors are optimized for multiple threads. Intel has HyperThreading and AMD's new processor will have double cores. I belive Intel's upcoming processor will have four cores for execution.

    It seems that dividing the game calculations into multiple threads would have advantages.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    It's quite common to use multi threading in a game. Ideally, you would want your AI, physics, and rendering to all be on seperate threads that way they are not dependent of eachother, and each can be given a seperate time slice. That is much better than capping frame rate, which would just be the lazy way of trying to do the same.

  3. #3
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    It's more difficult to design multiple worker-threads than it appears. Most games generally only use one primary worker-thread for the hardcore engine code, and use other threads (if even) for lesser functionality.

    When you have your primary engine work being handled by multiple threads (which is really sort of pointless unless it's a true SMP environment) you have to consider synchronization, overhead, and debugging concerns.

    SMP is good for software designed specifically for SMP computing, and games are generally not designed for SMP (aside from little hacks).

    Hyper-threading and whatever AMD is working on, for desktop computing is IMHO, not an equivalent to SMP. Hyper-threading for example is good for modern desktop computers because people today run many many processes at the same time, some of which require a little CPU time now-and-then. So it seems like a good idea to have a little "runoff thread" as I like to call it, that allows secondary processes the CPU-time they need without having to interrupt the primary process.

    This technology is to me, not really a big design consideration for games (for primary work, that is).

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by BMJ
    It's more difficult to design multiple worker-threads than it appears. Most games generally only use one primary worker-thread for the hardcore engine code, and use other threads (if even) for lesser functionality.
    That's what I thought.

    But I am under the impression that HyperThreading actually will enhance performance if the work is divided into multiple threads.
    HyperThreading is only the beginning though, so this will certainly be the case in the future when the dual-core processors arrive.

    It seems that Quake 3 is optimized for multiple processors. I think this will be the case with many more games in the future.
    http://www.2cpu.com/articles/6_1.html
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    I wouldn't say, "optimized for".

    I think they just gathered up all non-low-level-engine frame code and dumped it into a new thread for "SMP" support.
    Last edited by BMJ; 08-11-2004 at 11:47 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multithreading
    By ~Kyo~ in forum Game Programming
    Replies: 5
    Last Post: 09-14-2005, 09:30 PM
  2. Multithreading
    By JaWiB in forum Game Programming
    Replies: 7
    Last Post: 08-24-2003, 09:28 PM