Presentation is loading. Please wait.

Presentation is loading. Please wait.

Technical Architect Ubisoft Montreal Michael LAVAIRE Technical Lead Ubisoft Montreal Remi QUENIN Squeeze the Juice out of CPUs Post Mortem of a Data-Driven.

Similar presentations


Presentation on theme: "Technical Architect Ubisoft Montreal Michael LAVAIRE Technical Lead Ubisoft Montreal Remi QUENIN Squeeze the Juice out of CPUs Post Mortem of a Data-Driven."— Presentation transcript:

1 Technical Architect Ubisoft Montreal Michael LAVAIRE Technical Lead Ubisoft Montreal Remi QUENIN Squeeze the Juice out of CPUs Post Mortem of a Data-Driven Scheduler

2 Table of Contents

3 1. COMMON ARCHITECTURAL DESIGNS Usual multithreading patterns

4 Folded loop Gameplay Engine Loop Graphic Smaller Engine Loop Thread 1 Thread 2 Background Loading Thread 3 FrameNN+1N+2

5 Sync point Sync Applying modifications Gameplay Graphic Background Loading Applying modifications

6 Tasks Scheduling Stage 1 Waiting Stage 2 Stage 3 Gate Task A Task D Task C Task B Task E Task F

7 2. « SHEARS » SOLUTION 60 FPS for everyone

8 Objectives

9 2.1 DATA DRIVEN SCHEDULING Focus on data, not on the code

10 Task A Data driven scheduling Task A Task B Task A Task C Data D1 Data D0 Data D1

11 D0D1 Data driven scheduling Task A Task B Task A Task C Data D1 Data D0

12 Data driven scheduling D0D1 Task A Task B Task C

13 Data driven scheduling D0D1 Task A Task B Task C

14 Data driven scheduling

15

16

17 2.2 WORKLOADS No locks, be scalable

18 Workload

19 Lock-free : Internal Container State Thread 2 Container::Remove() State Thread 1 Container::Add() State Test &Set SUCCESS !FAILED !SUCCESS !

20 Lock-free

21 Lock-free : Comparison Q6600

22 Lock-free : Comparison X360

23 Lock-free : Comparison PS3

24 2.3 WORKING WITH SPU Easy cross-platforming, easy debugging

25 Working with SPU Cross Platform API

26 Main Memory Impl DMA Impl Memory Access Interface Satellite Task

27 Working with SPU Easy Debugging Main Memory Impl DMA Impl Memory Access Interface Satellite Task

28 Working with SPU Easy Debugging

29 Main Memory Impl DMA Impl Memory Access Interface Satellite Task Named Pipe

30

31 3. TIPS & TRICKS Multithreading & peace of mind

32 Tip 1: Clever profiling

33 Tip 2: Watchdog

34 Tip 3: Unit Tests

35 Trick 1: Perturbation

36 Test A Test C Test B Test D Test A Test C Test B Test D Loop nLoop n+1 Thread A Thread B New thread synchronization

37 Trick 2: State validation

38 S t a t e 1 Process AProcess BProcess C Process X S t a t e 2 S t a t e 3 State X S t a t e X Assert !

39 Trick 2: State validation class StateChecker { public: enum State { State1, State2, State3 }; StateChecker() { m_state = State1; } bool SetState( State oldState, State newState ) { return Atomic::TestAndSet ( &m_state, oldState, newState ) == oldState; } private: volatile State m_state; };

40 Trick 3: Access verification

41 class AccessChecker { public: AccessChecker() { m_access = 0; } bool StartReadAccess() { return Atomic::Inc( &m_access ) > 0; } bool EndReadAccess() { return Atomic::Dec( &m_access ) >= 0; } bool StartWriteAccess() { return Atomic::Dec( &m_access ) == -1; } bool EndWriteAccess() { return Atomic::Inc( &m_access ) == 0; } private: volatile int m_access; };

42 Trick 4: Multithreaded Assert

43 extern volatile bool g_waitOnAssert = false; #define ASSERT( condition )\ while(g_waitOnAssert) {}\ if( !(condition) )\ {\ g_waitOnAssert = true;\ DoAssert();\ g_waitOnAssert = false;\ }

44 Squeeze the Juice !

45 Inspiration Game Programming Gems 6: Lock-free Algorithms by Toby Jones Design and Implementation of Multi-Threaded Games by Bruce Dawson Floodgate: Maximizing SPU parallelism without sacrificing cross platform development by David Asbell & Michael Noland SPU Shaders by Mike Acton

46 michael.lavaire@ubisoft.com remi.quenin@ubisoft.com

47 Ubisoft is recruiting! Come see us at the Ubisoft Booth in the Career Pavilion (CP 2308, South Hall) You can also check out: www.creatorsofemotions.com


Download ppt "Technical Architect Ubisoft Montreal Michael LAVAIRE Technical Lead Ubisoft Montreal Remi QUENIN Squeeze the Juice out of CPUs Post Mortem of a Data-Driven."

Similar presentations


Ads by Google