Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multithreading potential

Started by Telgin Feb 26, 2009 at 7:13 PM 1 replies 650+ views
Original Post
Telgin
Telgin
So I'm going through the prelimenary process of laying out the design for my next game project, and one of the major design goals I had was for this to be multithreaded in some capacity. Mostly because that's an area of programming I don't have much experience in yet (and want to have) and partly because it seems to be the wave of the future. Anyway, the real question here is what parts of a typical computer game (well, 3D in this case if it matters) are suitable to being multithreaded? I'm sure there are tons of possibilities, but I'm not coming up with much by myself. I can see a lot of merit in using extra threads to keep up with things like networking and file loading, but that's not the sort of thing I'm looking to multithread here. For one, this game won't have networking at all, and file loading is a sort of static thing in this game (i.e. happens all at start up, no dynamic loading of the world or anything). Other than that, what potential is there for multithreading? The only big thing I can think up that really seems appropriate would be updating the scene. You could traverse the scene graph and hand out objects that you come across to the CPUs in some sort of scheduling manner so that the work load is divided up. I've read that this is really a bad idea though since there are so many interdependencies between objects that memory locking causes you to pretty much loose any benefit and causes the code to be much harder to make. I think that can be circumvented though through a few different methods. Maybe compute what the next frame should be, store that data separately, then after all updating is done go back through and copy that data to the new 'current' frame. Something like that maybe... that way you don't have to fight to access otherwise volatile memory and with enough cores it should have some improvement over just doing it serially. My guess is that if it were that easy though, modern games would do it, and so I ask what sort of other things in a modern game can be divided up? I can also see a lot of point in doing things like physics asynchronously from the real frame rate and using extra CPUs, or doing animation (but isn't that usually off loaded to the GPU now anyway?). Any other ideas? I've got an 8 core computer here (not that that's why I built it mind you) and I'd like to put some of that to use.
Success requires no explanation. Failure allows none.
Palidine
Palidine
http://www.gamedev.net/community/forums/topic.asp?topic_id=505772
http://www.gamedev.net/community/forums/topic.asp?topic_id=525951
http://www.gamedev.net/community/forums/topic.asp?topic_id=479190

Anyway, discussed a crapton on this site already. Search for: "multithread engine" in the lil search box up above

The short is that there is tons of potential but it can frequently require completely re-thinking your object & data models from a standard single-threaded game: moving to event driven, or data only shared on blackboards, branching parallel for short periods with barriers before the next sequential task, etc. Not trivial stuff at all.

A few 3rd party physics systems are already very parallel: PhysX, Havok. Using that can help

-me
Telgin
Telgin
Quote:
Original post by Palidine
http://www.gamedev.net/community/forums/topic.asp?topic_id=505772
http://www.gamedev.net/community/forums/topic.asp?topic_id=525951
http://www.gamedev.net/community/forums/topic.asp?topic_id=479190

Anyway, discussed a crapton on this site already. Search for: "multithread engine" in the lil search box up above

The short is that there is tons of potential but it can frequently require completely re-thinking your object & data models from a standard single-threaded game: moving to event driven, or data only shared on blackboards, branching parallel for short periods with barriers before the next sequential task, etc. Not trivial stuff at all.

A few 3rd party physics systems are already very parallel: PhysX, Havok. Using that can help

-me


D'oh, thanks for reminding me about the search. I'm so used to spending time on forums where there's no point in searching...

I'll look through the links you gave and give the search a go.
Success requires no explanation. Failure allows none.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.