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

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 

Recently uploaded (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 

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