Title: Multicore Environment Programming
1Multicore Environment Programming
- BarCamp Blacksburg Summer 2008
2Multicore Examples
3Multicore Examples
- ...pretty much everything since 2005
- Intel Core 2 Duo, Core 2 Quad
- AMD Athlon 64 X2, Phenom
- As well as chips by Sun, IBM, and others (Cell,
Sparc, etc)
4...how many is multicore?
- Core 2 Duo 2 processors on a chipCore 2 Quad
2 sets of 2 processors on a chipOpterons are
also 2- and 4-cores per chip
5Then things get crazy...
6If you wanted to...
- You could build a 16-core computer today
- Â
- AMD Opteron 2350 Barcelona 2.0GHz x4Â
1016Tyan Tiger n4250QE 891.998 gigs eccÂ
200 - Â
- Total 2107.99 case and ps
- Â
7Sweet!!
- That'll make everything super fast
8Kinda, sorta, not really
- Hardware scales to give us cores (and other ways
of throwing more threads at the cpu)......but
software doesn't "magically" go faster on these
chips.
9But we're coders
10...it's our job to push the hardware, not the
other way around.
11How we've been trying to push it...
12How we've been trying to push it...
13How we've been trying to push it...
14How we've been trying to push it...
- Threads
- Â
- Worker pools
- Â
- Combinations of the above (task parallel library)
15Threads are easy until...
16Threads are easy until...
- you try to communicate between them
17Locking
- Where do you lock?Â
- In what order do you lock?Â
- Are all my modules locking in the same way?Â
- Do my locks compose well with 3rd party
libraries? - Â
- Â
18That's a pain
- But since we're coders, it's doable.
19Â Except that's not the problem...
- The real trick is the simple fact that our
programs now have a different kind of
bottleneck.Â
20What we'd like to see is something like this
21Thanks to academics, we have some options...
- Pi Calculus
- Join Calculus
- Kleene Algebra-based orchestration
- Streams
- Communicating Sequential Processes
- Requirements Annotations
- Functional Decomposition
- ...and countless other variations
22What they have in common
- Instead of just talking about a program as
something that starts, does things, and
finishes......let's talk about it as
independent pieces working together.
23What they have in common
- Instead of just talking about a program as
something that starts, does things, and
finishes......let's talk about it as
independent pieces working together....then we
can let the compiler and/or runtime do the rest.
24What we're talking about today
- Bringing parallelism into OOP using actors
- AKA Active objects
25What we're talking about today
- Bringing parallelism into OOP using actors
- AKA Active objects
- ...but we're going to work with them on a
massive scale.
26But what's an actor?
- An actor
- Is an object in the oop sense
- Lives on its own thread, so it acts independently
of the rest of the system - Can communicate with other actors in the system
27Example Scatter
- main
- Â Â Â start event handler
- Â Â Â Â start video
- Â Â Â start timekeeper
- Â
- event handler
- Â Â Â get mouse (x,y)
- Â Â Â if button down
- Â Â Â Â Â Â Â create new dot
- Â Â Â msg all dots (x,y)
- video
- Â Â Â render frame
- Â Â Â display next frame
- Â
- timekeeper
- Â Â Â delay x ms
- Â Â Â msg event handler
- Â
- dot
- Â Â Â get (x,y), calc new pos
- Â Â Â msg video new pos
28For this to be possible, you need...
- (Mostly) free threads
- (Mostly) free messaging
- (Mostly) no locks
- Others?
29Example Signal Proc. Optimization
30To find out more
- Erlang http//www.erlang.org
- Â
- StreamIT http//www.cag.csail.mit.edu/streamit/
- Â
- Wikipedia http//en.wikipedia.org/wiki/Actor_mode
l - Â
- My site http//www.minnow-lang.org
- Â
31Thanks
- Images
- http//www.pbase.com/bkbowden/image/69140176
- http//www.toychestpenrith.co.uk/acatalog/Wooden_T
oys.html