Parallel Extentions to the .NET Framework

3,160 views

Published on

MikeTaulty_PFX_SlideShare

Published in: Technology
1 Comment
1 Like
Statistics
Notes
  • Hii there were few demos in the ppt. Where can i get them
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
3,160
On SlideShare
0
From Embeds
0
Number of Embeds
38
Actions
Shares
0
Downloads
92
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide
  • 06/07/09 12:26 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • Parallel Extentions to the .NET Framework

    1. 1. Parallel Extensions to the .NET Framework Mike Taulty Developer & Platform Group Microsoft Ltd [email_address] http://www.mtaulty.com
    2. 2. Buying a new Processor £100 - £300 2-3GHz 2 cores or 4 64-bit Core Core
    3. 3. Buying a new Processor Core Core Core Core £200 - £500 2-3GHz 4 cores with HT 64-bit QuickPath Interconnect Memory Controller
    4. 4. Where will it all end? Unisys ES7000 (7600R) used with kind permission of Mr Henk var der Valk, Unisys, NL
    5. 5. “ I’ll have a big one, please”
    6. 6. Was it a wise purchase? Windows OS App 1 App 2 ... App 1 .NET CLR .NET Framework My Code
    7. 7. Was it a wise purchase? <ul><li>Some environments scale to take advantage of additional CPU cores (mostly server-side) </li></ul><ul><li>A lot of code does not (mostly client-side) </li></ul><ul><li>This code will see little benefit from future hardware advances  </li></ul><ul><li>We want code to exhibit latent concurrency </li></ul>ASP.NET Web Forms/Services WCF Services WF Engine ... .NET ThreadPool or Custom Threading Strategy
    8. 8. “ The Answer” – System.Threading <ul><li>System.Threading is one answer </li></ul><ul><li>Writing correct, multi-threaded code is hard </li></ul><ul><ul><li>Co-ordinating work and sharing data across threads </li></ul></ul><ul><ul><li>Prone to races, deadlocks, livelocks, etc. </li></ul></ul><ul><li>Minimal set of co-ordination data structures in System.Threading </li></ul><ul><li>Explicitly managing threads is for “heroes” </li></ul><ul><li>Implicitly managing threads == ThreadPool </li></ul>
    9. 9. Parallel sums on ThreadPool
    10. 10. “ The Answer” – System.Threading <ul><li>ThreadPool is a good start but; </li></ul><ul><ul><li>Programming model is awkward </li></ul></ul><ul><ul><li>More than one ThreadPool? </li></ul></ul><ul><ul><li>Cancelling work? </li></ul></ul><ul><ul><li>Dependencies between work? etc. </li></ul></ul><ul><li>Generally, in System.Threading </li></ul><ul><ul><li>Focus is on the thread and not the task </li></ul></ul><ul><li>Makes it hard for the system to understand the intent and help with the implementation </li></ul>
    11. 11. Parallel Computing Initiative <ul><li>Goal is to simplify parallel programming </li></ul><ul><ul><li>Local and distributed computing </li></ul></ul><ul><ul><li>Different kinds of parallelism </li></ul></ul><ul><li>Including work on </li></ul><ul><ul><li>Operating System, runtimes, frameworks, tools </li></ul></ul><ul><li>First deliverables in VS 2010 ( .NET Fx V4.0 ) </li></ul><ul><ul><li>Managed : Parallel Extensions to .NET </li></ul></ul><ul><ul><li>Native: Parallel Pattern Library & Concurrency Runtime </li></ul></ul><ul><ul><li>Both: Parallel debugging and profiling tools </li></ul></ul>
    12. 12. Parallel Sums Revisited
    13. 13. Parallel Extensions to .NET System.Threading System.Collections.Concurrent System.dll System.Linq System.Linq.Parallel System.Core.dll System.Threading.Tasks System.Threading System.Collections.Concurrent System.Threading.Internal mscorlib.dll
    14. 14. Task Parallel Library ( TPL ) Task TaskFactory TaskScheduler Key Classes
    15. 15. Starting with Task
    16. 16. Starting with Task
    17. 17. Exploring Task
    18. 18. Exploring Task
    19. 19. Scheduling Tasks TaskScheduler Task ThreadPoolTaskScheduler SynchronizationContext TaskScheduler Custom QueueTask(Task t)
    20. 20. Picking/Building a Scheduler
    21. 21. Default Scheduling .NET ThreadPool ( with V4.0 modifications ) … Thread Thread Thread Work Item Work Item Work Item Work Item Thread’s Work Queue Thread’s Work Queue Thread’s Work Queue Work Item Work Item Work Item Global Work Queue
    22. 22. Task Exotica ( knobs )
    23. 23. Task exotica
    24. 24. Higher Level Constructs <ul><li>Even with Task there are common patterns that build into higher level abstractions </li></ul><ul><li>The Parallel class </li></ul><ul><ul><li>Invoke, For, For<T>, Foreach </li></ul></ul><ul><li>Care needs to be taken with state, ordering </li></ul><ul><ul><li>“ This is not your Father’s for loop” </li></ul></ul>
    25. 25. Parallel.Invoke, ForEach, For
    26. 26. Parallel LINQ ( PLINQ ) Select() Where() Etc. Extension method in System.LINQ Extends IEnumerable<T> LINQ to Objects LINQ to XML not LINQ to SQL,EF Results in a ParallelQuery<T> “ Usually” would be Enumerable
    27. 27. Parallel LINQ ( PLINQ ) IEnumerable<T> Could be IList<T> or Array Range Chunk Striped? Hash “ Where” “ Where” “ Where” “ OrderBy” “ OrderBy” “ OrderBy” “ Sum” “ Sum” “ Sum” Consumer( foreach … ) Merge Re-partition Task Task Task Query Query Query Partition
    28. 28. Parallel LINQ ( PLINQ ) <ul><li>Just like Parallel.For and friends, this sits on top of the Task Parallel Library </li></ul><ul><li>Care still needs to be taken </li></ul><ul><ul><li>Around shared state </li></ul></ul><ul><ul><li>Around ordering </li></ul></ul><ul><ul><li>Around the mix between computation and I/O – not necessarily a performance win from parallelising a LINQ query </li></ul></ul><ul><li>Remember </li></ul><ul><ul><li>PLINQ is nothing to do with databases </li></ul></ul>
    29. 29. PLINQ
    30. 30. Co-ordination Data Structures
    31. 31. Co-ordination Data Structures
    32. 32. What Next? <ul><li>Download VS 2010 CTP </li></ul><ul><ul><li>Remember to set the clock back </li></ul></ul><ul><li>Experiment with runtime and API </li></ul><ul><ul><li>Team is working on Visual Studio 2010 beta </li></ul></ul><ul><ul><li>Very open to feedback </li></ul></ul><ul><ul><li>Join in the discussion forums </li></ul></ul><ul><li>Keep up with other concurrency topics at; </li></ul><ul><ul><li>http://msdn.microsoft.com/concurrency </li></ul></ul>
    33. 33. © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

    ×