1. Preparing AI for Parallelism Lessons from NASCAR The Game 2011 Neil Henning – Technology Lead Neil Henning neil@codeplay.com Paris Game AI Conference 2011
3. Introduction I am sure some of you are wondering... Why a guy from is doing a talk about which was developed by Neil Henning neil@codeplay.com Paris Game AI Conference 2011
4. Introduction Team from Codeplay worked for 15 months on game Neil Henning neil@codeplay.com Paris Game AI Conference 2011
8. Overtaking is all about navigating through these packs Cannot simply make the AI use LODs, nearly always in view Neil Henning neil@codeplay.com Paris Game AI Conference 2011
15. How did these changes help when optimizing NASCAR?
16. How did we make use of the PS3's unique hardware? What performance improvement was achieved? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
17. Why prepare your AI for parallelism? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
35. Optimization folks will love you!Neil Henning neil@codeplay.com Paris Game AI Conference 2011
36. What changes should be made? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
37.
38. In NASCAR, had 18 components for each carDriving Controllers Stay Behind Obstacle Detection Stay Beside Neil Henning neil@codeplay.com Paris Game AI Conference 2011
39.
40. All components in a group can be run in parallelNeil Henning neil@codeplay.com Paris Game AI Conference 2011
41.
42. Each car’s groups can be run in parallel too0 1 2 … … 42 Neil Henning neil@codeplay.com Paris Game AI Conference 2011
95. How did these changes help when optimizing NASCAR? On PS3 most costly components were targeted Neil Henning neil@codeplay.com Paris Game AI Conference 2011
96.
97. And all components in a group being able to be run in parallel
114. Offload aims to mitigate the issues with getting code onto SPU
115. Can offload code to SPU much quicker (typically a few man days)
116. Much easier to move existing code bases to SPUNeil Henning neil@codeplay.com Paris Game AI Conference 2011
117.
118. Any work within an offload block is performed on the SPU
119. All PPU code is duplicated for the SPUNeil Henning neil@codeplay.com Paris Game AI Conference 2011
120.
121. Just use them as normal!Neil Henning neil@codeplay.com Paris Game AI Conference 2011
122.
123. Just have to specify which virtual functions may be calledNeil Henning neil@codeplay.com Paris Game AI Conference 2011
124.
125. Four components taking most of the frame timeNeil Henning neil@codeplay.com Paris Game AI Conference 2011
126.
127.
128. How did we make use of the PS3's unique hardware? Stay Behind Other Car Stay Beside Other Car Looked at Stay Behind/Beside Other Car together In the same group, can be run in parallel Neil Henning neil@codeplay.com Paris Game AI Conference 2011
129. How did we make use of the PS3's unique hardware? Stay Behind Other Car Stay Beside Other Car Moved Stay Behind component to SPU Stay Beside component would continue to be run on PPU Neil Henning neil@codeplay.com Paris Game AI Conference 2011
130. How did we make use of the PS3's unique hardware? Stay Behind Other Car Stay Beside Other Car As long as SPU work was less time than the PPU work, no cost! Effectively ‘hid’ the cost of calculating Stay Behind component Neil Henning neil@codeplay.com Paris Game AI Conference 2011
131.
132.
133. Changes were purely optimizationAIObstacle** obstacles; unsigned intnumObstacles; offloadThread_thandle = __offload(obstacles, numObstacles) { for(unsigned int i = 0; i < numObstacles; i++) { AIObstacle* obstacle = obstacles[i]; // use obstacle for calculations } }; Neil Henning neil@codeplay.com Paris Game AI Conference 2011
134.
135. Changes were purely optimization// array of AIObstacle* ’s on main memory AIObstacle** obstacles; unsigned intnumObstacles; offloadThread_thandle = __offload(obstacles, numObstacles) { for(unsigned int i = 0; i < numObstacles; i++) { // AIObstacle* points to main memory AIObstacle* obstacle = obstacles[i]; // use obstacle for calculations } }; Neil Henning neil@codeplay.com Paris Game AI Conference 2011
136.
137. Changes were purely optimization// array of AIObstacle* ’s on main memory AIObstacle** obstacles; unsigned intnumObstacles; offloadThread_thandle = __offload(obstacles, numObstacles) { CachedPointer<AIObstacle*> innerObstacles(obstacles, numObstacles); for(unsigned int i = 0; i < numObstacles; i++) { // AIObstacle* points to main memory CachedPointer<AIObstacle> obstacle(innerObstacles[i]); // use obstacle for calculations } }; Neil Henning neil@codeplay.com Paris Game AI Conference 2011