Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP by Bjoern Knafla and Claudia Leopold (now Fohry)
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP by Bjoern Knafla and Claudia Leopold (now Fohry)

on

  • 1,398 views

Slides from my presentation of a paper with the same title at ParCo 2007 - http://www.fz-juelich.de/nic-series/volume38/knafla.pdf . ...

Slides from my presentation of a paper with the same title at ParCo 2007 - http://www.fz-juelich.de/nic-series/volume38/knafla.pdf .

Future computer games need parallel programming to meet their ever growing hunger for per- formance. We report on our experiences in parallelizing the game-like C++ application Open- SteerDemo with OpenMP. To enable deterministic data-parallel processing of real-time agent steering behaviour, we had to change the high-level design, and refactor interfaces for explicit shared resource access. Our experience is summarized in a set of guidelines to help parallelizing legacy game code.

Statistics

Views

Total Views
1,398
Views on SlideShare
1,394
Embed Views
4

Actions

Likes
2
Downloads
12
Comments
0

1 Embed 4

http://www.slideshare.net 4

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP by Bjoern Knafla and Claudia Leopold (now Fohry) Presentation Transcript

  • 1. Parallelizing a Real-Time Steering Simulation for Computer Games with OpenMP Bjoern Knafla and Claudia Leopold University of Kassel (Germany) Dienstag, 11. September 2007 1
  • 2. Dienstag, 11. September 2007 2
  • 3. Steering a flock of birds Dienstag, 11. September 2007 2
  • 4. Dienstag, 11. September 2007 3
  • 5. Dienstag, 11. September 2007 3
  • 6. Dienstag, 11. September 2007 3
  • 7. Bird Dienstag, 11. September 2007 3
  • 8. Bird Boid Dienstag, 11. September 2007 3
  • 9. Bird Boid Agent Dienstag, 11. September 2007 3
  • 10. Dienstag, 11. September 2007 4
  • 11. CPU core Dienstag, 11. September 2007 4
  • 12. Dienstag, 11. September 2007 4
  • 13. CPU CPU CPU CPU core core core core CPU CPU CPU CPU core core core core CPU CPU CPU CPU core core core core CPU CPU CPU CPU core core core core Dienstag, 11. September 2007 4
  • 14. Dienstag, 11. September 2007 4
  • 15. Outline Dienstag, 11. September 2007 5
  • 16. Outline 1. Steering behaviors Dienstag, 11. September 2007 5
  • 17. Outline 1. Steering behaviors 2. OpenSteerDemo Dienstag, 11. September 2007 5
  • 18. Outline 1. Steering behaviors 2. OpenSteerDemo 3. Bad parallelization Dienstag, 11. September 2007 5
  • 19. Outline 1. Steering behaviors 2. OpenSteerDemo 3. Bad parallelization 4. Parallelization that works Dienstag, 11. September 2007 5
  • 20. Outline 1. Steering behaviors 2. OpenSteerDemo 3. Bad parallelization 4. Parallelization that works 5. Performance Dienstag, 11. September 2007 5
  • 21. Outline 1. Steering behaviors 2. OpenSteerDemo 3. Bad parallelization 4. Parallelization that works 5. Performance 6. Summary Dienstag, 11. September 2007 5
  • 22. Steering behaviors Dienstag, 11. September 2007 6
  • 23. Dienstag, 11. September 2007 7
  • 24. Dienstag, 11. September 2007 7
  • 25. Dienstag, 11. September 2007 7
  • 26. Dienstag, 11. September 2007 7
  • 27. Alignment Dienstag, 11. September 2007 8
  • 28. OpenSteerDemo Dienstag, 11. September 2007 9
  • 29. OpenSteerDemo Testbed for the open source library OpenSteer from Craig W. Reynods Dienstag, 11. September 2007 9
  • 30. OpenSteerDemo Testbed for the open source library OpenSteer from Craig W. Reynods Simulates steering behavior of agents Dienstag, 11. September 2007 9
  • 31. OpenSteerDemo Testbed for the open source library OpenSteer from Craig W. Reynods Simulates steering behavior of agents Game-like C++ real-time application Dienstag, 11. September 2007 9
  • 32. OpenSteerDemo Testbed for the open source library OpenSteer from Craig W. Reynods Simulates steering behavior of agents Game-like C++ real-time application OpenGL Dienstag, 11. September 2007 9
  • 33. OpenSteerDemo Testbed for the open source library OpenSteer from Craig W. Reynods Simulates steering behavior of agents Game-like C++ real-time application OpenGL http://opensteer.sourceforge.net Dienstag, 11. September 2007 9
  • 34. Main loop Dienstag, 11. September 2007 10
  • 35. Main loop Input Update Output Dienstag, 11. September 2007 10
  • 36. Main loop Graph- Input Update ics Dienstag, 11. September 2007 11
  • 37. Input stage Graph- Input Update ics Time step t Dienstag, 11. September 2007 12
  • 38. Update stage Graph- Input Update ics Time step t Dienstag, 11. September 2007 13
  • 39. Graphics stage Graph- Input Update ics Time step t Dienstag, 11. September 2007 14
  • 40. Next main loop cycle Graph- Input Update ics Time step t+1 Dienstag, 11. September 2007 15
  • 41. Update stage Graph- Input Update ics Dienstag, 11. September 2007 16
  • 42. Agent update Update agent read + write read + write read + write write Agent Neighbors Random. Graphics state references Dienstag, 11. September 2007 17
  • 43. Time step t In state t-1 Update Update Update Update agent agent agent ... agent 0 1 2 n Sequential agent update order Dienstag, 11. September 2007 18
  • 44. Time step t In state t-1 Update Update Update Update agent agent agent ... agent 0 1 2 n Sequential Neighbors agent update order In state t-1 Dienstag, 11. September 2007 18
  • 45. Time step t In state t-1 Update Update Update Update agent agent agent ... agent 0 1 2 n Sequential agent update order Dienstag, 11. September 2007 19
  • 46. Time step t In state t In state t-1 Update Update Update Update agent agent agent ... agent 0 1 2 n Sequential agent update order Dienstag, 11. September 2007 20
  • 47. Time step t In state t In state t-1 Update Update Update Update agent agent agent ... agent 0 1 2 n Sequential agent update order Dienstag, 11. September 2007 21
  • 48. Time step t In state t In state t-1 Update Update Update Update agent agent agent ... agent 0 1 2 n Sequential Neighbors agent update order In state ? Dienstag, 11. September 2007 21
  • 49. Bad parallelization Dienstag, 11. September 2007 22
  • 50. Dienstag, 11. September 2007 23
  • 51. Questionable reliability and correctness Dienstag, 11. September 2007 23
  • 52. No speedup Dienstag, 11. September 2007 24
  • 53. No speedup Dienstag, 11. September 2007 24
  • 54. Main parallelization problems Dienstag, 11. September 2007 25
  • 55. Dienstag, 11. September 2007 26
  • 56. Race conditions Dienstag, 11. September 2007 26
  • 57. Race conditions Global variables, deep inheritance hierarchies, strongly interdependent classes Dienstag, 11. September 2007 26
  • 58. Race conditions Global variables, deep inheritance hierarchies, strongly interdependent classes Non-determinism Dienstag, 11. September 2007 26
  • 59. Race conditions Global variables, deep inheritance hierarchies, strongly interdependent classes Non-determinism Order of agent updates and random numbers Dienstag, 11. September 2007 26
  • 60. Race conditions Global variables, deep inheritance hierarchies, strongly interdependent classes Non-determinism Order of agent updates and random numbers Non-thread-safe functions Dienstag, 11. September 2007 26
  • 61. Parallelization that works Dienstag, 11. September 2007 27
  • 62. Guiding ideas Dienstag, 11. September 2007 28
  • 63. Guiding ideas Update order independent simulation Dienstag, 11. September 2007 28
  • 64. Guiding ideas Update order independent simulation Agent modification only dependent on its steering vector Dienstag, 11. September 2007 28
  • 65. Guiding ideas Update order independent simulation Agent modification only dependent on its steering vector Minimize synchronization Dienstag, 11. September 2007 28
  • 66. Guiding ideas Update order independent simulation Agent modification only dependent on its steering vector Minimize synchronization Finish parallel processing before graphics stage Dienstag, 11. September 2007 28
  • 67. Guiding ideas Update order independent simulation Agent modification only dependent on its steering vector Minimize synchronization Finish parallel processing before graphics stage Interfaces for explicit context Dienstag, 11. September 2007 28
  • 68. Refactorization Dienstag, 11. September 2007 29
  • 69. Split agent update Agent update Sim. Modify agent agent Agent update order Dienstag, 11. September 2007 30
  • 70. Simulate agent stage read + write Sim. agent Steering Vector read read write Agent Render- Random. Neighbors state Feeder Agent Agent public state references Agent private Dienstag, 11. September 2007 31
  • 71. Simulate agent stage read + write Sim. agent Steering Vector read on st read on st write c c Agent Render- Random. Neighbors state Feeder Agent Agent public state references Agent private Dienstag, 11. September 2007 31
  • 72. Modify agent stage read Modify agent Steering Vector read + write Agent Render- Random. Neighbors state Feeder Agent Agent public state references Agent private Dienstag, 11. September 2007 32
  • 73. Modify neighbor data structure Modify neigh- bors Steering Vector read write Agent Render- Random. Neighbors state Feeder Agent Agent public state references Agent private Dienstag, 11. September 2007 33
  • 74. Refactor update stage Input Update Output Dienstag, 11. September 2007 34
  • 75. Split update stage Update stage Sim. Modify Sub-stages: simulation and modification Dienstag, 11. September 2007 35
  • 76. Old update stage Update agent Update agent Update agent Sim. Modify Sim. Modify Sim. Modify agent agent agent agent ... agent agent 0 0 1 1 n n Sequential processing order Dienstag, 11. September 2007 36
  • 77. Time step t Agents in state t-1 Sim. Modify Sim. Modify Sim. Modify agent agent agent agent ... agent agent 0 0 1 1 n n Sequential processing order Dienstag, 11. September 2007 37
  • 78. Time step t Agent in state t Agents in state t-1 Sim. Modify Sim. Modify Sim. Modify agent agent agent agent ... agent agent 0 0 1 1 n n Sequential processing order Dienstag, 11. September 2007 38
  • 79. New update stage Simulation sub-stage Modification sub-stage Sim. Sim. Sim. Modify Modify Modify agent agent ... agent agent agent ... agent 0 1 n 0 1 n Sequential processing order Dienstag, 11. September 2007 39
  • 80. Time step t Agents in public state t-1 Sim. Sim. Sim. Modify Modify Modify agent agent ... agent agent agent ... agent 0 1 n 0 1 n Sequential processing order Dienstag, 11. September 2007 40
  • 81. Time step t Agents in public state t-1 Sim. Sim. Sim. Modify Modify Modify agent agent ... agent agent agent ... agent 0 1 n 0 1 n Sequential processing order Dienstag, 11. September 2007 41
  • 82. Time step t Agents in public state t-1 Sim. Sim. Sim. Modify Modify Modify agent agent ... agent agent agent ... agent 0 1 n 0 1 n Sequential processing order Dienstag, 11. September 2007 42
  • 83. Time step t Agents in public state t-1 Sim. Sim. Sim. Modify Modify Modify agent agent ... agent agent agent ... agent 0 1 n 0 1 n Sequential Each agent is modified processing based solely on its own order state Dienstag, 11. September 2007 42
  • 84. Parallelization Dienstag, 11. September 2007 43
  • 85. Parallel update stage Simulation Modification S S M M M P P B B a S S a M M M a a r r r r Update a S S S a M M M r r neigh- l l i i bors l S S l M M M e e e e Possibly r r l S S S l M M M parallel Dienstag, 11. September 2007 44
  • 86. Parallel simulation sub-stage Simulation Modification S S P P B B a S S a a a r r r r Update a S S S a r r neigh- l l i i bors l S S l e e e e Possibly r r l S S S l parallel Dienstag, 11. September 2007 45
  • 87. Parallel modification sub-stage Simulation Modification M M M P P B B a a M M M a a r r r r Update a a M M M r r neigh- l l i i bors l l M M M e e e e Possibly r r l l M M M parallel Dienstag, 11. September 2007 46
  • 88. Parallel modification sub-stage Simulation Modification P P B B a a a a r r r r Update a a r r neigh- l l i i bors l l e e e e Possibly r r l l parallel Dienstag, 11. September 2007 47
  • 89. Performance Dienstag, 11. September 2007 48
  • 90. Test-computer Dual-processor dual- core 2 GHz AMD Opteron with 2 GB Ram 2x Nvidia 7800 GTX graphics cards in SLI mode Linux OS Dienstag, 11. September 2007 49
  • 91. Max speedups Dienstag, 11. September 2007 50
  • 92. Max speedups Comparison of OpenSteerDemo flock of birds simulation with 4 threads with OpenMP-disabled version Dienstag, 11. September 2007 50
  • 93. Max speedups Comparison of OpenSteerDemo flock of birds simulation with 4 threads with OpenMP-disabled version Whole application: ! 2.84 Dienstag, 11. September 2007 50
  • 94. Max speedups Comparison of OpenSteerDemo flock of birds simulation with 4 threads with OpenMP-disabled version Whole application: ! 2.84 Update stage: !! ! 3.54 Dienstag, 11. September 2007 50
  • 95. Summary Dienstag, 11. September 2007 51
  • 96. Dienstag, 11. September 2007 52
  • 97. Refactored first Dienstag, 11. September 2007 52
  • 98. Refactored first Simplicity! Dienstag, 11. September 2007 52
  • 99. Refactored first Simplicity! High-level design to min. synchronization Dienstag, 11. September 2007 52
  • 100. Refactored first Simplicity! High-level design to min. synchronization Explicit context Dienstag, 11. September 2007 52
  • 101. Refactored first Simplicity! High-level design to min. synchronization Explicit context Deferred computation Dienstag, 11. September 2007 52
  • 102. Refactored first Simplicity! High-level design to min. synchronization Explicit context Deferred computation Identified slices for data-parallel computation Dienstag, 11. September 2007 52
  • 103. Thank you! Dienstag, 11. September 2007 53