Upload
alex-moore
View
1.090
Download
0
Tags:
Embed Size (px)
DESCRIPTION
This is my 10 minute introduction to The Parallel Extensions to the .Net Framework that I presented at the Central Ohio .Net User Group lightning talk meeting. If you have any questions just DM me at twitter.
Citation preview
Shallow Dive: Parallel Fx
Alex MooreSoftware Developer, TDCI
No More Free Lunch
Processors not getting much faster
No More Free Lunch
transistors++
No More Free Lunch
transistors++ speed++
No More Free Lunch
transistors++ speed++
No More Free Lunch
transistors++ speed++
cores++
Elephant in the Room
Elephant in the Room
Parallel / Concurrent Programming is about to reach it’s boiling point
Elephant in the Room
Can’t ignore it much longer
Elephant in the Room
There will be language, library, and tool support for this soon.
There will be language, library, tool, and hardware support for this soon.Concurrency is one of the main themes for C# 4.0, the PFX will probably be part of .Net 4.0, Visual Studio 2010 will have tools to help better debug concurrent programs, and Intel’s next Core processor, the i7, will have a whole slew of improvements to help run concurrent and threaded applications better.
Parallel Extensions to the .Net Framework
PLINQ
Task Parallel Library
Scheduler
System.Threading
CDS
How to Express Parallelism
How to Express Parallelism
Threading sucks
How to Express Parallelism
Declarative data parallelism - PLINQ
How to Express Parallelism
Declarative data parallelism - PLINQ
Imperative data parallelism - Parallel.For
How to Express Parallelism
Declarative data parallelism - PLINQ
Imperative data parallelism - Parallel.For
Imperative task parallelism - Tasks, Futures
PLINQ
from x in setwhere x == somevalueselect expensiveFunction(x);
PLINQ
from x in setwhere x == somevalueselect expensiveFunction(x);
from x in set.AsParallel()where x == somevalueselect expensiveFunction(x);
Parallel.For
for( int i = 0; i < 10; i++ ){ ... }
Parallel.For
for( int i = 0; i < 10; i++ ){ ... }
Parallel.For( 0, 10, i => { ... } );
Parallel.ForEach
foreach( var x in set ) { ... }
Parallel.ForEach
foreach( var x in set ) { ... }
Parallel.ForEach( set, x => {...});
Tasks
A();B();C();
Do_Something();
Tasks
Task t1 = Task.Create( ()=> A(); );Task t2 = Task.Create( ()=> B(); );Task t3 = Task.Create( ()=> C(); );
Task.WaitAll(t1, t2, t3);
Do_Something();
Futures
var a = A();var b = B();var c = C();
Do_Something(a,b,c);
Futures
var a = Future.Create( ()=> A(); );var b = Future.Create( ()=> B(); );var c = Future.Create( ()=> C(); );
Do_Something(a,b,c);
Demos
Box of Sharp Knives
PFX is a big box of sharp knives. Yes they are shiny and you want to grab them but be careful.
Box of Sharp Knives
★Not a silver bullet for performance
This should not be your first choice for improving performance. Clean “responsible” design will go a long way when optimizing code, and will help when deciding where to apply concurrency.
Box of Sharp Knives
★Not a silver bullet for performance
✓Get the CTP
✓Read, Do, and Learn
This should not be your first choice for improving performance. Clean “responsible” design will go a long way when optimizing code, and will help when deciding where to apply concurrency.
Questions?Comments ?
Are there any questions ? Comments ?
How to find info
• MSDN Magazine - October ‘08
• Channel 9 - “Parallel Extensions”
• Blogs: Joe Duffy, Herb Sutter
• http://geekswithblogs.net/alexmoore/archive/2008/10/22/parallel-extensions-links.aspx
Thanks!
Alex Moore
Blog: geekswithblogs.net/alexmoore
Twitter: @alexmoore