WORLDCOMP Conference: PDPTA-2014 Las Vegas, Nevada, USA “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” July 21-24, 2014 WORLDCOMP Conference: PDPTA-2014 Las Vegas, Nevada, USA “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Presented by: Dr. Abu Asaduzzaman Assistant Professor in Computer Architecture and Director of CAPPLab Department of Electrical Engineering and Computer Science (EECS) Wichita State University (WSU), USA July 23, 2014 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” ► Outline ■ Introduction Problem Statement and Contributions Background and Motivation ■ Important Techniques for Game Engine Data Level Parallelism Task Level Parallelism ■ Experimentations Test Game Engine: Tower Defense Game Different Implementations ■ Experimental Results ■ Discussion Dr. Zaman QUESTIONS? Any time! 3 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Authors ■ Abu Asaduzzaman, Assistant Professor EECS Department, Wichita State University (WSU), USA Director, Computer Arch & Parallel Prog Lab (CAPPLab) ■ Hin Y. Lee, MS in CS EECS Department, Wichita State University (WSU), USA Graduation: Fall 2012 ■ Deepthi Gummadi, MS/CN Student EECS Department, Wichita State University (WSU), USA Graduation: Spring 2014 Dr. Zaman 4 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Introduction ■ Xbox 360 3 cores GPU card ■ PS3 1 master core 6 worker core GPU card Dr. Zaman 5 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Introduction ■ Game Technology In addition to standalone game machines, game engines are nowadays being used for educational, engineering, and scientific applications. To fulfill the high performance requirements, game engines are adopting new hardware technologies like multicore CPUs and software technologies like parallel programming. As the number of cores in a processor increases, multithreading can be very helpful to get as much performance out of a system as possible to the advancement of video game technologies. Dr. Zaman 6 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Introduction ■ Game Engine Many Components: Physics, Graphics, etc. ■ Multithreading Concurrent and Parallel Processing Data Level Parallelism and Task Level Parallelism (Thread) Synchronization Load Balancing, etc. Dr. Zaman 7 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Introduction ■ Contributions Multi-object interactive game console in an 8-core system Single-Threaded Model (STM) Multithreaded Asynchronous Model (MAM) Multithreaded Synchronous Model (MSM) MSM with Data Parallelism (MSMDP) We investigate the challenges and benefits of thread synchronization and data level parallelism. Dr. Zaman 8 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Introduction ■ Background and Motivation The game industry has surpassed the movie and music industry in U.S. in 2005 and 2007, respectively. In 2008, the game industry surpassed the music industry in the U.K. and is expected to surpass DVD sales in the future. Multicore architecture is a recent design trend and most vendors are adopting multicore processors to their products. Multicore systems are very suitable for multithreaded processing as multiple threads can be executed on multiple cores at the same time. Dr. Zaman 9 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Introduction ■ Background and Motivation Data parallelism is where the same type of data is parallelized in multiple threads. The use of this in a game engine is when a component spawns multiple worker threads to process one type of data. Task level parallelism is a popular method for game engine multithreading, where components run asynchronously in their own loop or synchronously in a single loop with multiple forks and joins. To properly scale a multicore game engine, data parallelism and task parallelism have to be employed. Dr. Zaman 10 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” ► Outline ■ Introduction Problem Statement and Contributions Background Work and Motivation ■ Important Techniques for Game Engine Data Level Parallelism Task Level Parallelism ■ Experimentations Test Game Engine: Tower Defense Game Different Implementations ■ Experimental Results ■ Discussion Dr. Zaman 11 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Important Techniques for Game Engine ■ Data Level Parallelism Data parallelism is where the same type of data in a component is parallelized in multiple threads. Example: The animation subcomponent in the graphics component is divided into 3 batches of data for simultaneous processing. Dr. Zaman 12 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Important Techniques for Game Engine ■ Task Level Parallelism The use of task parallelism in game engine is by running each component task in its own thread. Example: In synchronized model (left) all tasks must finish in a single clock cycle. In asynchronous model (right) the tasks can run and finish at their own time. Dr. Zaman 13 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Important Techniques for Game Engine ■ Thread Pool Thread pool is a system where tasks are queued in a list and assigned to any available threads that are idle. Max. amount of threads should run at the same time. Dr. Zaman 14 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” ► Outline ■ Introduction Problem Statement and Contributions Background Work and Motivation ■ Important Techniques for Game Engine Data Level Parallelism Task Level Parallelism ■ Experimentations Test Game Engine: Tower Defense Game Different Implementations ■ Experimental Results ■ Discussion Dr. Zaman 15 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Test Game Engine ■ CAPPLab Tower Defense Game v1 Defend the Base Structure; players are to build Defensive Structures and try to survive as many waves as possible. For every enemy destroyed, the player gains credits. Maximum 20 objects in the screen at one time. The game is over if (i) Player survives 3 minutes, (ii) Base Struct. is destroyed, or (iii) Abnormal termination Dr. Zaman 16 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Test Game Engine ■ Single Threaded Model (STM) The order of operations in the single threaded implementation is: 1) Capture input 2) Update input operation (graphics) 3) Update game logic 4) Update AI 5) Update physics 6) Process navigational mesh updates 7) Simulate physics 8) Render graphics Dr. Zaman 17 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Test Game Engine ■ Multithreaded Asynchronous Model (MAM) The order of operations is: Thread 1: Thread 2: 1) Capture input 1) Update graphics 2) Update game logic 2) Render graphics 3) Update AI 4) Update physics 5) Process navigational mesh updates 6) Simulate physics Dr. Zaman 18 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Test Game Engine ■ Multithreaded Synchronous Model (MSM) The order of operations is: Serial Stage: Parallel stage: (One possible order) 1) Capture input 1) Process navigational mesh updates 2) Update logic 2) Simulate physics 3) Update AI 3) Render graphics 4) Update physics 5) Update graphics Dr. Zaman 19 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Test Game Engine ■ MSM with Data Parallelism (MSMDP) The order of operations is: Serial Stage: Parallel stage: (One possible order) 1) Capture input 1) Update navigational mesh 2) Update logic 2) Simulate physics 3) Update AI 3) Perform collision detection on object batch 1 4) Update physics 4) Perform collision detection on object batch 2 5) Update graphics 5) Render graphics Dr. Zaman 20 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” ► Outline ■ Introduction Problem Statement and Contributions Background Work and Motivation ■ Important Techniques for Game Engine Data Level Parallelism Task Level Parallelism ■ Experimentations Test Game Engine: Tower Defense Game Different Implementations ■ Experimental Results ■ Discussion Dr. Zaman 21 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Experimental Results ■ Generation and processing of Frames MSMDP generates more frames than other implementations. SMT takes more time to process a frame than multithreaded ones. Dr. Zaman 22 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Experimental Results ■ Processing Time for Components and Speedup Physics simulation takes the maximum amount of time. About 14x speedup is achieved due to MSMDP for 512 threads. Dr. Zaman 23 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” Conclusions and Future Extension ■ We explore the challenges due to thread synchronization and data parallelism by developing a multicore video game console. ■ Experimental results show that the MSMDP generates more frames and takes less amount of time to process the frames. ■ On an 8-core system, the speedup due to MSMDP is about 14 with respect to the STM implementation. ■ Higher speedup needed for future game engines can be achieved by GPU computing. Dr. Zaman 24 WORLDCOMP Conference: PDPTA; Las Vegas, USA; 2014 “Impact of Thread Synchronization and Data Parallelism on Multicore Game Programming” QUESTIONS? Contact: Abu Asaduzzaman E-mail: abuasaduzzaman@ieee.org Phone: +1-316-978-5261 CAPPLab: http://www.cs.wichita.edu/~capplab/ Thank You!