Shallow Dive:
 Parallel Fx
      Alex Moore
Software 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 th...
Parallel Extensions to
the .Net Framework
                  PLINQ
     C
     D      Task Parallel Library
     S
        ...
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
Imperat...
PLINQ

from x in set
where x == somevalue
select expensiveFunction(x);
PLINQ

from x in set
where x == somevalue
select expensiveFunction(x);


from x in set.AsParallel()
where x == somevalue
s...
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.W...
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...
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...
Box of Sharp Knives

          ★ Not a silver bullet for performance

          ✓ Get the CTP
          ✓ Read, Do, and Le...
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:/...
Thanks!

Alex Moore
Blog:   geekswithblogs.net/alexmoore
Twitter: @alexmoore
Upcoming SlideShare
Loading in …5
×

Shallow Dive PFX

1,139
-1

Published on

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.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,139
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Shallow Dive PFX

  1. 1. Shallow Dive: Parallel Fx Alex Moore Software Developer, TDCI
  2. 2. No More Free Lunch Processors not getting much faster
  3. 3. No More Free Lunch transistors++
  4. 4. No More Free Lunch transistors++ speed++
  5. 5. No More Free Lunch transistors++ speed++
  6. 6. No More Free Lunch transistors++ speed++ cores++
  7. 7. Elephant in the Room
  8. 8. Elephant in the Room Parallel / Concurrent Programming is about to reach it’s boiling point
  9. 9. Elephant in the Room Can’t ignore it much longer
  10. 10. 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.
  11. 11. Parallel Extensions to the .Net Framework PLINQ C D Task Parallel Library S Scheduler System.Threading
  12. 12. How to Express Parallelism
  13. 13. How to Express Parallelism Threading sucks
  14. 14. How to Express Parallelism Declarative data parallelism - PLINQ
  15. 15. How to Express Parallelism Declarative data parallelism - PLINQ Imperative data parallelism - Parallel.For
  16. 16. How to Express Parallelism Declarative data parallelism - PLINQ Imperative data parallelism - Parallel.For Imperative task parallelism - Tasks, Futures
  17. 17. PLINQ from x in set where x == somevalue select expensiveFunction(x);
  18. 18. PLINQ from x in set where x == somevalue select expensiveFunction(x); from x in set.AsParallel() where x == somevalue select expensiveFunction(x);
  19. 19. Parallel.For for( int i = 0; i < 10; i++ ) { ... }
  20. 20. Parallel.For for( int i = 0; i < 10; i++ ) { ... } Parallel.For( 0, 10, i => { ... } );
  21. 21. Parallel.ForEach foreach( var x in set ) { ... }
  22. 22. Parallel.ForEach foreach( var x in set ) { ... } Parallel.ForEach( set, x => {...});
  23. 23. Tasks A(); B(); C(); Do_Something();
  24. 24. Tasks Task t1 = Task.Create( ()=> A(); ); Task t2 = Task.Create( ()=> B(); ); Task t3 = Task.Create( ()=> C(); ); Task.WaitAll(t1, t2, t3); Do_Something();
  25. 25. Futures var a = A(); var b = B(); var c = C(); Do_Something(a,b,c);
  26. 26. Futures var a = Future.Create( ()=> A(); ); var b = Future.Create( ()=> B(); ); var c = Future.Create( ()=> C(); ); Do_Something(a,b,c);
  27. 27. Demos
  28. 28. 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.
  29. 29. 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.
  30. 30. 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.
  31. 31. Questions? Comments ? Are there any questions ? Comments ?
  32. 32. 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
  33. 33. Thanks! Alex Moore Blog: geekswithblogs.net/alexmoore Twitter: @alexmoore
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×