SlideShare a Scribd company logo
1 of 65
Preparing AI for Parallelism Lessons from NASCAR The Game 2011 Neil Henning – Technology Lead Neil Henning neil@codeplay.com Paris Game AI Conference 2011
Introduction Neil Henning neil@codeplay.com Paris Game AI Conference 2011
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
Introduction  Team from Codeplay worked for 15 months on game Neil Henning neil@codeplay.com Paris Game AI Conference 2011
Introduction ,[object Object]
 43 cars on screen at the same time
 Cars race in tight packs on the circuit
 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
Agenda Neil Henning neil@codeplay.com Paris Game AI Conference 2011
Agenda  How to prepare AI for parallelism ,[object Object],Neil Henning neil@codeplay.com Paris Game AI Conference 2011
Agenda ,[object Object]
 Why prepare your AI for parallelism?
 What changes should be made?
 What common issues are there?
 How did these changes help when optimizing NASCAR?
 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
Why prepare your AI for parallelism? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
Why prepare your AI for parallelism? ,[object Object]
 Say we have four bots
 In serial – can easily fit in a frameframe length Neil Henning neil@codeplay.com Paris Game AI Conference 2011
Why prepare your AI for parallelism?  Without parallelism, tighter limits on number of bots ,[object Object]
Have to either optimize or parallelize (or both)frame length Neil Henning neil@codeplay.com Paris Game AI Conference 2011
Why prepare your AI for parallelism?  Without parallelism, tighter limits on number of bots ,[object Object]
 Only possible with parallelismframe length Neil Henning neil@codeplay.com Paris Game AI Conference 2011
Why prepare your AI for parallelism? ,[object Object]
 This generation of consoles are multicore
 Sony's new PS Vita is quad core
 Even iPad usesdual core processors now!
 Being able to split work amongst cores is key
 Might not be required yet, but could be essential laterNeil Henning neil@codeplay.com Paris Game AI Conference 2011
Why prepare your AI for parallelism? ,[object Object]
 Optimization being sought throughout engine
 Either optimize engine or cut features
 Have AI prepared to become parallel
 Optimization folks will love you!Neil Henning neil@codeplay.com Paris Game AI Conference 2011
What changes should be made? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
What changes should be made? ,[object Object]
 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
What changes should be made? ,[object Object]
 All components in a group can be run in parallelNeil Henning neil@codeplay.com Paris Game AI Conference 2011
What changes should be made? ,[object Object]
 Each car’s groups can be run in parallel too0 1 2 … … 42 Neil Henning neil@codeplay.com Paris Game AI Conference 2011
What changes should be made? ,[object Object]
 Two phases for your AI
 Read phase can read world/other car state
 Write phase can modify own car stateNeil Henning neil@codeplay.com Paris Game AI Conference 2011
What changes should be made? ,[object Object]
 In read phase, store needed reads into temporary data
 In write phase, read from the temporary data
 AI is one frame behind world events
 Effect on AI is minimalNeil Henning neil@codeplay.com Paris Game AI Conference 2011
What changes should be made? ,[object Object]
 Write phase uses data from previous frames read phaseWrite Phase Read Phase ,[object Object]
 Only components that required world/other car stateNeil Henning neil@codeplay.com Paris Game AI Conference 2011
What changes should be made? ,[object Object]
 Having two or more threads means lots of duplicate localsvoid func() { 	char localBuffer[1024]; // … do something with localBuffer } ,[object Object],Neil Henning neil@codeplay.com Paris Game AI Conference 2011
What changes should be made? ,[object Object],structFoo { Bar* bar; }; many : one?  one : one?  one : many? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
What changes should be made? ,[object Object],structFoo { Bar* bar; }; ,[object Object]
 Documenting the relationship saves time and effort laterNeil Henning neil@codeplay.com Paris Game AI Conference 2011
 What common issues are there? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
 What common issues are there? ,[object Object]
 ~500-1200 cycles on PowerPC if virtual lookup misses cache
 Can equate to a large amount of time doing no workNeil Henning neil@codeplay.com Paris Game AI Conference 2011
 What common issues are there? ,[object Object]
 Based on previous game (Supercar Challenge)

More Related Content

Similar to Paris Game/AI Conference 2011

Threading Successes 01 Intro
Threading Successes 01   IntroThreading Successes 01   Intro
Threading Successes 01 Introguest40fc7cd
 
Threading Game Engines: QUAKE 4 & Enemy Territory QUAKE Wars
Threading Game Engines: QUAKE 4 & Enemy Territory QUAKE WarsThreading Game Engines: QUAKE 4 & Enemy Territory QUAKE Wars
Threading Game Engines: QUAKE 4 & Enemy Territory QUAKE Warspsteinb
 
The fight for surviving in the IoT world
The fight for surviving in the IoT worldThe fight for surviving in the IoT world
The fight for surviving in the IoT worldRadu Vunvulea
 
The fight for surviving in the IoT world - Radu Vunvulea
The fight for surviving in the IoT world - Radu VunvuleaThe fight for surviving in the IoT world - Radu Vunvulea
The fight for surviving in the IoT world - Radu VunvuleaITCamp
 
Scalability for All: Unreal Engine* 4 with Intel
Scalability for All: Unreal Engine* 4 with Intel Scalability for All: Unreal Engine* 4 with Intel
Scalability for All: Unreal Engine* 4 with Intel Intel® Software
 
Overview Of Parallel Development - Ericnel
Overview Of Parallel Development -  EricnelOverview Of Parallel Development -  Ericnel
Overview Of Parallel Development - Ericnelukdpe
 
Unleashing Data Intelligence with Intel and Apache Spark with Michael Greene
Unleashing Data Intelligence with Intel and Apache Spark with Michael GreeneUnleashing Data Intelligence with Intel and Apache Spark with Michael Greene
Unleashing Data Intelligence with Intel and Apache Spark with Michael GreeneDatabricks
 
Overview Of Parallel Development - Ericnel
Overview Of Parallel Development -  EricnelOverview Of Parallel Development -  Ericnel
Overview Of Parallel Development - Ericnelukdpe
 
ITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream Projects
ITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream ProjectsITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream Projects
ITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream ProjectsITCamp
 
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"LogeekNightUkraine
 
Deep learning for FinTech
Deep learning for FinTechDeep learning for FinTech
Deep learning for FinTechgeetachauhan
 
Optimization Deep Dive: Unreal Engine 4 on Intel
Optimization Deep Dive: Unreal Engine 4 on IntelOptimization Deep Dive: Unreal Engine 4 on Intel
Optimization Deep Dive: Unreal Engine 4 on IntelIntel® Software
 
Forts and Fights Scaling Performance on Unreal Engine*
Forts and Fights Scaling Performance on Unreal Engine*Forts and Fights Scaling Performance on Unreal Engine*
Forts and Fights Scaling Performance on Unreal Engine*Intel® Software
 
Accelerate Machine Learning Software on Intel Architecture
Accelerate Machine Learning Software on Intel Architecture Accelerate Machine Learning Software on Intel Architecture
Accelerate Machine Learning Software on Intel Architecture Intel® Software
 
The best of Windows Server 2016 - Thomas Maurer
 The best of Windows Server 2016 - Thomas Maurer The best of Windows Server 2016 - Thomas Maurer
The best of Windows Server 2016 - Thomas MaurerITCamp
 
Accelerating AI from the Cloud to the Edge
Accelerating AI from the Cloud to the EdgeAccelerating AI from the Cloud to the Edge
Accelerating AI from the Cloud to the EdgeIntel® Software
 
Python* Scalability in Production Environments
Python* Scalability in Production EnvironmentsPython* Scalability in Production Environments
Python* Scalability in Production EnvironmentsIntel® Software
 

Similar to Paris Game/AI Conference 2011 (20)

Threading Successes 01 Intro
Threading Successes 01   IntroThreading Successes 01   Intro
Threading Successes 01 Intro
 
Threading Game Engines: QUAKE 4 & Enemy Territory QUAKE Wars
Threading Game Engines: QUAKE 4 & Enemy Territory QUAKE WarsThreading Game Engines: QUAKE 4 & Enemy Territory QUAKE Wars
Threading Game Engines: QUAKE 4 & Enemy Territory QUAKE Wars
 
The fight for surviving in the IoT world
The fight for surviving in the IoT worldThe fight for surviving in the IoT world
The fight for surviving in the IoT world
 
The fight for surviving in the IoT world - Radu Vunvulea
The fight for surviving in the IoT world - Radu VunvuleaThe fight for surviving in the IoT world - Radu Vunvulea
The fight for surviving in the IoT world - Radu Vunvulea
 
Scalability for All: Unreal Engine* 4 with Intel
Scalability for All: Unreal Engine* 4 with Intel Scalability for All: Unreal Engine* 4 with Intel
Scalability for All: Unreal Engine* 4 with Intel
 
Build 2019 Recap
Build 2019 RecapBuild 2019 Recap
Build 2019 Recap
 
Overview Of Parallel Development - Ericnel
Overview Of Parallel Development -  EricnelOverview Of Parallel Development -  Ericnel
Overview Of Parallel Development - Ericnel
 
Interview
InterviewInterview
Interview
 
Unleashing Data Intelligence with Intel and Apache Spark with Michael Greene
Unleashing Data Intelligence with Intel and Apache Spark with Michael GreeneUnleashing Data Intelligence with Intel and Apache Spark with Michael Greene
Unleashing Data Intelligence with Intel and Apache Spark with Michael Greene
 
Overview Of Parallel Development - Ericnel
Overview Of Parallel Development -  EricnelOverview Of Parallel Development -  Ericnel
Overview Of Parallel Development - Ericnel
 
ITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream Projects
ITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream ProjectsITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream Projects
ITCamp 2017 - Raffaele Rialdi - Adopting .NET Core in Mainstream Projects
 
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"
 
Deep learning for FinTech
Deep learning for FinTechDeep learning for FinTech
Deep learning for FinTech
 
Optimization Deep Dive: Unreal Engine 4 on Intel
Optimization Deep Dive: Unreal Engine 4 on IntelOptimization Deep Dive: Unreal Engine 4 on Intel
Optimization Deep Dive: Unreal Engine 4 on Intel
 
Forts and Fights Scaling Performance on Unreal Engine*
Forts and Fights Scaling Performance on Unreal Engine*Forts and Fights Scaling Performance on Unreal Engine*
Forts and Fights Scaling Performance on Unreal Engine*
 
Accelerate Machine Learning Software on Intel Architecture
Accelerate Machine Learning Software on Intel Architecture Accelerate Machine Learning Software on Intel Architecture
Accelerate Machine Learning Software on Intel Architecture
 
The best of Windows Server 2016 - Thomas Maurer
 The best of Windows Server 2016 - Thomas Maurer The best of Windows Server 2016 - Thomas Maurer
The best of Windows Server 2016 - Thomas Maurer
 
Accelerating AI from the Cloud to the Edge
Accelerating AI from the Cloud to the EdgeAccelerating AI from the Cloud to the Edge
Accelerating AI from the Cloud to the Edge
 
Python* Scalability in Production Environments
Python* Scalability in Production EnvironmentsPython* Scalability in Production Environments
Python* Scalability in Production Environments
 
Intel python 2017
Intel python 2017Intel python 2017
Intel python 2017
 

Recently uploaded

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 

Recently uploaded (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Paris Game/AI Conference 2011

  • 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
  • 2. Introduction 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
  • 5.
  • 6. 43 cars on screen at the same time
  • 7. Cars race in tight packs on the circuit
  • 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
  • 9. Agenda Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 10.
  • 11.
  • 12. Why prepare your AI for parallelism?
  • 13. What changes should be made?
  • 14. What common issues are there?
  • 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
  • 18.
  • 19. Say we have four bots
  • 20. In serial – can easily fit in a frameframe length Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 21.
  • 22. Have to either optimize or parallelize (or both)frame length Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 23.
  • 24. Only possible with parallelismframe length Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 25.
  • 26. This generation of consoles are multicore
  • 27. Sony's new PS Vita is quad core
  • 28. Even iPad usesdual core processors now!
  • 29. Being able to split work amongst cores is key
  • 30. Might not be required yet, but could be essential laterNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 31.
  • 32. Optimization being sought throughout engine
  • 33. Either optimize engine or cut features
  • 34. Have AI prepared to become parallel
  • 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
  • 43.
  • 44. Two phases for your AI
  • 45. Read phase can read world/other car state
  • 46. Write phase can modify own car stateNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 47.
  • 48. In read phase, store needed reads into temporary data
  • 49. In write phase, read from the temporary data
  • 50. AI is one frame behind world events
  • 51. Effect on AI is minimalNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 52.
  • 53.
  • 54. Only components that required world/other car stateNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 55.
  • 56.
  • 57.
  • 58.
  • 59. Documenting the relationship saves time and effort laterNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 60. What common issues are there? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 61.
  • 62. ~500-1200 cycles on PowerPC if virtual lookup misses cache
  • 63. Can equate to a large amount of time doing no workNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 64.
  • 65. Based on previous game (Supercar Challenge)
  • 66. 16 cars in previous, now 43 cars
  • 67. 5 component types in previous, now 18 component types
  • 68. Now read/write phase too
  • 69. 80 virtual calls to update became 1333 virtual calls!Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 70.
  • 71. In real terms, 3ms of virtual function lookup per frame
  • 72. First optimization was to have typed buckets of components
  • 73. 1333 virtual calls went to 31 virtual calls
  • 74. Platform agnostic (PS3, 360 and Wii all sped up)Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 75.
  • 76. Not knowing the size of data kills SPU/Compute developmentNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 77.
  • 79.
  • 80.
  • 81. AI required knowledge of obstacles
  • 82. Physics system used, raycast to find problematic obstacles
  • 83. Each call to raycast used a mutex, every thread would halt!
  • 84. Had to refactor code to remove need for lockingNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 85.
  • 86. How did these changes help when optimizing NASCAR? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 87.
  • 88. Allowed work to be split across all 6 threads
  • 89. Each thread was given 1/6th of the cars to process
  • 90. Takes 2ms of all CPU resources on 360 in a frameNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 91.
  • 92. Only 2 threads on PS3, but have 6 sub processors (the SPUs)
  • 93. Both threads on PS3 were completely full
  • 94.
  • 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
  • 98. Costly groups were made to use the SPUs
  • 99. Knowing relationship between data was key
  • 100. Well documented code made life so much easier!Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 101. How did we make use of the PS3's unique hardware? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 102.
  • 103. Very tight deadlines, 1 month to reduce time taken in AI
  • 104. No main thread time left – have to use the SPUs
  • 105. Our Offload compiler technology crucialNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 106.
  • 107. They are amazingly fast, if you code correctly for them
  • 108. Normally requires total rewrite of existing codebase
  • 109. Painful to access global variables
  • 110. Virtual functions are a complete write offNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 111.
  • 112. Common to have 4-5 SPU programmers for ~10 months
  • 113. Not feasible for late-in-cycle development
  • 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
  • 138. What performance improvement was achieved? Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 139.
  • 140. ~100 lines of source code changed
  • 141. 2½ weeks development timeNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 142.
  • 143. ~100 lines of source code changed
  • 144. 2½ weeks development timeNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 145.
  • 146. ~50 lines of source code changed
  • 147. 1 week development timeNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 148.
  • 149. ~50 lines of source code changed
  • 150. 1 week development timeNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 151.
  • 152. ~20 lines of source code changed
  • 153. 8 hours development timeNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 154.
  • 155. ~20 lines of source code changed
  • 156. 8 hours development timeNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 157.
  • 158. 50% speed improvement on PS3Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 159. Takeaway Neil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 160.
  • 161. But need code ready to be parallelised
  • 162. Small changes in coding style lead to hugely better results
  • 163. Better to plan systems from beginning with multicore in mindNeil Henning neil@codeplay.com Paris Game AI Conference 2011
  • 164. Questions? Can also catch me on twitter @sheredom Neil Henning neil@codeplay.com Paris Game AI Conference 2011