Work-stealing multithreading
Posted: Wed Jan 05, 2011 10:53 am
I found this interesting article the other day while looking for a multithreading design for my engine without having to screw up my existing architecture
The article can be found here: http://software.intel.com/en-us/article ... cheduling/ (source code included)
I successfully got it implemented in my own rendering engine (since my game engine doesn't really have any other functionality besides rendering yet) and with some small modifications this could be applicable to irrlicht too, with a really easy mechanism for adding other libraries like physics, audio, AI, etc.
This mechanism will spawn a number of worker threads equal to the amount of hardware threads (CPU cores) your computer has, and will divide all the work, implemented as separate tasks, among these threads using a work-stealing scheduling algo.
In my engine design I let every entity that needs to be updated the next frame register itself with my scene manager, it will then gather all information needed for rendering (and for staying thread-safe) and separate tasks are created (animation/physics tasks, decision making, etc.) which are then fed to the scheduler. After all threads have completed their work the scene will be drawn and presented to the user (maybe when I start on a DX11 driver I will be able to multithread this too)
This could all be changed in the future, my engine is still an unstable WIP so architecture changes and optimizations will probably happen
This may not be the most optimal multithreading system out there, but it's definitely a great system for people being used to writing single threaded games
The article can be found here: http://software.intel.com/en-us/article ... cheduling/ (source code included)
I successfully got it implemented in my own rendering engine (since my game engine doesn't really have any other functionality besides rendering yet) and with some small modifications this could be applicable to irrlicht too, with a really easy mechanism for adding other libraries like physics, audio, AI, etc.
This mechanism will spawn a number of worker threads equal to the amount of hardware threads (CPU cores) your computer has, and will divide all the work, implemented as separate tasks, among these threads using a work-stealing scheduling algo.
In my engine design I let every entity that needs to be updated the next frame register itself with my scene manager, it will then gather all information needed for rendering (and for staying thread-safe) and separate tasks are created (animation/physics tasks, decision making, etc.) which are then fed to the scheduler. After all threads have completed their work the scene will be drawn and presented to the user (maybe when I start on a DX11 driver I will be able to multithread this too)
This could all be changed in the future, my engine is still an unstable WIP so architecture changes and optimizations will probably happen
This may not be the most optimal multithreading system out there, but it's definitely a great system for people being used to writing single threaded games