Project Smoke Ncore engine experiment Threading for Performance

  • Slides: 28
Download presentation
Project “Smoke” N-core engine experiment Threading for Performance AND Features

Project “Smoke” N-core engine experiment Threading for Performance AND Features

“Smoke” is threaded for performance and features – here’s how! Engine + framework with

“Smoke” is threaded for performance and features – here’s how! Engine + framework with typical game subsystems • Well partitioned, configurable • Share source, demos, samples, workloads, white papers • More info at Intel Developer Forum 2

Experiment with game tech – how does it all fit together? • Explore performance

Experiment with game tech – how does it all fit together? • Explore performance on n-cores – Framework designed to scale to n threads – Which game architecture runs well with 8 threads? More? • Try features – Procedural fire/smoke – Dynamic vegetation, etc. • Measure them separately/together (to see interplay) – – Core threading techniques Physics Dynamic vegetation Fire/smoke, etc. • Extend into the future 3

It’s working today! • Display (Ogre 3 D) • Task. Manager • Physics •

It’s working today! • Display (Ogre 3 D) • Task. Manager • Physics • Sound • Volumetric Smoke • Procedural Fire • Procedural Trees • AI • Animation • User input/control • Scripting • Instrumentation • Camera bot 4

The framework holds it together Heavy use of interfaces, easy to extend Minimizes thread

The framework holds it together Heavy use of interfaces, easy to extend Minimizes thread sync via messaging Most of the code is in the Systems Engine Framework Parser Scheduler Messaging (Change control) UScene UObject … Managers Environment Task Service Platform UObject System Interfaces Systems Definition Files 5

GDC 2007: Restructuring will take games to multiple processors! 6

GDC 2007: Restructuring will take games to multiple processors! 6

Task Manager: scalable n-core thread pool Three configurations: • Single thread – shut threading

Task Manager: scalable n-core thread pool Three configurations: • Single thread – shut threading off • Native threads • Threading Building Blocks Thread count scales to HW (4 -core here) Task Manager puts System’s update in pool Systems chunk the update for other threads Thread pool used by all systems (even external ones, like Havok) 7

Systems subscribe to change messages Graphics System Subscribe Physics System Subscribe AI System …

Systems subscribe to change messages Graphics System Subscribe Physics System Subscribe AI System … • Each system subscribes to changes it needs • Decoupled communication reduces dependencies – Observer/Mediator • Lower memory bandwidth 8

Tasks get subdivided Graphics System Render • Scheduler invokes each system per frame Physics

Tasks get subdivided Graphics System Render • Scheduler invokes each system per frame Physics System Physics AI System AI AI AI. . . • System subdivides work into sub-tasks AI • Using “natural” granularity • Good middleware makes this easy 9

Tasks get subdivided Graphics System Render Physics System Physics AI System AI AI AI.

Tasks get subdivided Graphics System Render Physics System Physics AI System AI AI AI. . . AI • All sub-tasks in single job pool Job Pool Render Physics AI AI Physics AI. . . AI 10

Tasks get subdivided Graphics System • N worker threads, 1 per processor core Render

Tasks get subdivided Graphics System • N worker threads, 1 per processor core Render Physics System Physics • Sub-tasks spread out as needed AI System AI AI AI. . . AI Worker Threads Physics Job Pool AI AI Physics AI. . . AI Render Physics AI AI AI 11

Tasks post changes Graphics System Render Messaging Physics System Physics (change control) Physics Post

Tasks post changes Graphics System Render Messaging Physics System Physics (change control) Physics Post changes AI System AI AI AI. . . AI Worker Threads Physics Job Pool AI AI Physics AI. . . AI Render Physics AI AI AI 12

Each thread has queued changes Graphics System Render C 1 C 3 C 5

Each thread has queued changes Graphics System Render C 1 C 3 C 5 Physics System Physics Messaging C 7 C 2 C 6 C 4 (change control) AI System AI AI AI. . . AI Worker Threads Physics Job Pool AI AI Physics AI. . . AI Render Physics AI AI AI 13

Changes are sent to observers Graphics System Render C 1 C 3 C 5

Changes are sent to observers Graphics System Render C 1 C 3 C 5 Physics System Physics C 7 C 2 C 6 C 4 (change control) Change Occurred AI System AI AI AI. . . Messaging AI Worker Threads Physics Job Pool AI AI Physics AI. . . AI Render Physics AI AI AI 14

Good news/bad news: systems can (must) chunk up work • Some systems are very

Good news/bad news: systems can (must) chunk up work • Some systems are very good at this (physics, fire, volumetric smoke, animation) • Harder in other cases (graphics, script) 15

Sounds great, what makes this harder? • Messaging system isn’t natural for sharing some

Sounds great, what makes this harder? • Messaging system isn’t natural for sharing some data • Service manager selectively exposes framework/system interfaces • How do collision and AI work without data from multiple systems? 16

Graphics and animation show it all • Using Ogre 3 D • Extending window

Graphics and animation show it all • Using Ogre 3 D • Extending window – Display performance stats – Debug output • Extending Ogre’s animation – Drive skeletal based data to provide realistic creature expressions and locomotion – Use skeletons and weight maps – Hierarchical skeletal animation supports animation blending Orion Granatir 17

Scene layout is configurable Fire. Ball. Object Meteor. Object + + Physics Propertie s

Scene layout is configurable Fire. Ball. Object Meteor. Object + + Physics Propertie s Falling. Meteor. On. Fire. Object 18

How do we put a scene together? Smoke. Demo. Scene <Scene> <Include CDF="House. Scene"/>

How do we put a scene together? Smoke. Demo. Scene <Scene> <Include CDF="House. Scene"/> <Include CDF="Sky. Object"/> <Include CDF="Terrain. Object"/> // Meteor 1 <Include ODF="Falling. Meteor. On. Fire. Object"/> // Meteor 2 <Include ODF="Falling. Meteor. On. Fire. Object"/>. . . // Meteor 10 <Include ODF="Falling. Meteor. On. Fire. Object"/> </Scene> 19

The fire system burns brightly! • Propagates naturally • Smart particle systems use heat

The fire system burns brightly! • Propagates naturally • Smart particle systems use heat particles from each fire to spread procedurally • Configurable density, velocity, direction, etc. 20

Procedural trees • Editable grammar and seeded parser – Easy to create an endless

Procedural trees • Editable grammar and seeded parser – Easy to create an endless variety of trees • Canopies can be added, changed, or removed for seasonal effects • Create Forests: each seed creates a different tree 21

Physics rocks (and shatters)! • Integrated physics – ODE/Newton – Havok (with Character. Proxy

Physics rocks (and shatters)! • Integrated physics – ODE/Newton – Havok (with Character. Proxy and Break. Off. Parts) – Bullet Physics Library • Porting all systems to work with different physics • Physics issues jobs that we put in thread pool as tasks

AI makes the world appear alive • Flocks of chickens, herds of horses, and

AI makes the world appear alive • Flocks of chickens, herds of horses, and swoops of swallows all interact with the scene using custom AIs • “Smart” enough to find companions, fear fire, and avoid falling objects • AI was built from the ground up to be highly threaded • AI drives velocity changes, uses Havok’s Character Proxy to interact w/environment 23

Sometimes, things go wrong Heavy contention on global sync object Per-thread sync 24

Sometimes, things go wrong Heavy contention on global sync object Per-thread sync 24

What’s next for Smoke? • Continuing development • Look for public showing later in

What’s next for Smoke? • Continuing development • Look for public showing later in 2008 • Code and white paper release to follow 25

Lessons learned (so far) Do: • Evaluate the features of your middleware for integration.

Lessons learned (so far) Do: • Evaluate the features of your middleware for integration. • Find the best “chunking” in your systems. • Measure, understand tune your performance/content. • Be the one that figures this all out! Don’t: • Ignore thread interaction between systems, especially middleware. • Panic. No one method works for everybody. • Forget to share your great success stories at GDC 2009! 26

Questions from the attendees • What do you think? • Where should we go

Questions from the attendees • What do you think? • Where should we go from here? Any favorite technologies we should integrate? • Have you tried something like this? How did it go? • Have you rejected trying something like this? Why? 27