Presentation is loading. Please wait.

Presentation is loading. Please wait.

Games at Bolton Programming multiple cores Andrew Williams

Similar presentations


Presentation on theme: "Games at Bolton Programming multiple cores Andrew Williams"— Presentation transcript:

1 Games at Bolton Programming multiple cores Andrew Williams http://www.bolton.ac.uk/staff/adw1

2 Games at Bolton Introduction  Cores  Processes  Threads  Symmetric Multiprocessing (SMP)  Asymmetric Multiprocessing

3 Games at Bolton Processes versus threads  Processes –MS Word –Powerpoint –Firefox  Threads (within Firefox) –Read data from a website –Render page to screen

4 Games at Bolton Processes versus Threads  Processes usually independent of each other  Every process contains at least one thread (… of execution)  Threads tend to be doing different aspects of the same task  Processes have separate, protected address spaces and call stacks –Context switches tend to be slow

5 Games at Bolton Processes versus Threads  Processes communicate through operating system calls –Inter-process communication –Typically a socket or a pipe –My chess program communicates with its GUI like this

6 Games at Bolton Inter-process communication - Xboard  Launch command (shell command on Unix): xboard -fcp "./postmodernist xboard" -size Middling -animateMoving False -tc 1400 -inc 0 -td 0.6 -showCoords True -showThinking True $1 $2 $3 $4 $5  Checking for input from Xboard (from xbd.c ): retValue = PeekNamedPipe(stdInputHandle, NULL, 0, NULL, &dw, NULL); if(!retValue || dw == 0) return 0; else return 1;

7 Games at Bolton Multiple CPU motherboards  “Back in the day” approach  Multiple CPUs on the motherboard  Two, four, even eight CPU boards  Very popular in computer chess circles! Dual-Celeron MB from http://tinyurl.com/392zwu

8 Games at Bolton Multiple CPU motherboards  These were SMP  Problems with this approach: –Communication between CPUs Information transferred over slower, external bus –Complex, expensive motherboards –Needed to buy two (or four or eight) CPUs

9 Games at Bolton Modern approaches  On 26/9/2007, Dell’s cheapest model for home customers was the Inspiron 531 (£269 without display) –This features an AMD® Athlon™ 64 X2 Dual Core Processor 3800+  Modern consumer CPUs have multiple cores: –Intel Core 2 Duo –AMD X2

10 Games at Bolton Multiple Cores in Consoles  We are used to this  PS2 used the Emotion engine –Q: Symmetric or Asymmetric?  XBox360’s CPU is an IBM-designed triple-core product –See Ars Technica’s coverageSee Ars Technica’s coverage  PS3 uses the CELL chip –Q: Symmetric or Asymmetric?

11 Games at Bolton Xbox360’s Xenon CPU Image reproduced from Ars Technica, op cit

12 Games at Bolton Xbox360’s Xenon CPU  Questions: –Is the Xenon symmetric or asymmetric? –The marketing material for the Xenon says: “Two hardware threads per core; six hardware threads total” –How is this achieved?

13 Games at Bolton Making use of Multiple Cores –6 α=-6 β=+inf +16 α=+16 β=+inf -9 α=-9 β=-6 +12 α=+12 β=+inf +12+2 +9 α=+6 β=+12 +5+9 -16 α=-16 β=-9 +16 α=+16 β=+inf +3+16 +36 α=+36 β=+16 +36 A game-tree in a two- person, perfect information game

14 Games at Bolton Making use of Multiple Cores –6 α=-6 β=+inf +16 α=+16 β=+inf -9 α=-9 β=-6 +12 α=+12 β=+inf +12+2 +9 α=+6 β=+12 +5+9 -16 α=-16 β=-9 +16 α=+16 β=+inf +3+16 +36 α=+36 β=+16 +36 Q: How do we parallelize this process? Give me some options!

15 Games at Bolton Making use of Multiple Cores  Typical game loop (pseudocode): Initialize_game(); while(!quit) { Get_user_input(); Do_ai(); Do_physics(); Render(); } Shutdown_game();  Q: How do we parallelize that?  Give me some options!

16 Games at Bolton Task Parallelism  The question is, to what extent are (eg) physics and AI separate things?  Can we sensibly do them both at once?  What if one of them needs data produced by the other? –which is pretty likely if you think about it even for a moment  How up-to-date does this information really need to be?

17 Games at Bolton Data parallelism  Suppose you have 200 NPCs running around the screen (eg in an RTS)  Divide them up among the available cores?  So four “spare” cores do the AI and physics for 50 NPCs each? –Simultaneously? –What if two of them bump into each other? Fine if they are both “on” the same core?

18 Games at Bolton Mixed approaches  What about a mixture between task parallelism and data parallelism?  We have six cores: –Two for our NPCs, so give each core 100 –Two for rendering? –Two for game logic and user input?  Note that if you think like this, you’re committing yourself to the Xbox360 implementation –What about PS3 or PC or Wii?


Download ppt "Games at Bolton Programming multiple cores Andrew Williams"

Similar presentations


Ads by Google