Parallel Extentions to the .NET Framework
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Parallel Extentions to the .NET Framework

on

  • 6,178 views

MikeTaulty_PFX_SlideShare

MikeTaulty_PFX_SlideShare

Statistics

Views

Total Views
6,178
Views on SlideShare
6,144
Embed Views
34

Actions

Likes
1
Downloads
84
Comments
1

3 Embeds 34

http://www.slideshare.net 32
http://www.marcmywords.org 1
http://www.brijj.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Hii there were few demos in the ppt. Where can i get them
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 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 Presentation Transcript

  • 1. Parallel Extensions to the .NET Framework Mike Taulty Developer & Platform Group Microsoft Ltd [email_address] http://www.mtaulty.com
  • 2. Buying a new Processor £100 - £300 2-3GHz 2 cores or 4 64-bit Core Core
  • 3. Buying a new Processor Core Core Core Core £200 - £500 2-3GHz 4 cores with HT 64-bit QuickPath Interconnect Memory Controller
  • 4. Where will it all end? Unisys ES7000 (7600R) used with kind permission of Mr Henk var der Valk, Unisys, NL
  • 5. “ I’ll have a big one, please”
  • 6. Was it a wise purchase? Windows OS App 1 App 2 ... App 1 .NET CLR .NET Framework My Code
  • 7. Was it a wise purchase?
    • Some environments scale to take advantage of additional CPU cores (mostly server-side)
    • A lot of code does not (mostly client-side)
    • This code will see little benefit from future hardware advances 
    • We want code to exhibit latent concurrency
    ASP.NET Web Forms/Services WCF Services WF Engine ... .NET ThreadPool or Custom Threading Strategy
  • 8. “ The Answer” – System.Threading
    • System.Threading is one answer
    • Writing correct, multi-threaded code is hard
      • Co-ordinating work and sharing data across threads
      • Prone to races, deadlocks, livelocks, etc.
    • Minimal set of co-ordination data structures in System.Threading
    • Explicitly managing threads is for “heroes”
    • Implicitly managing threads == ThreadPool
  • 9. Parallel sums on ThreadPool
  • 10. “ The Answer” – System.Threading
    • ThreadPool is a good start but;
      • Programming model is awkward
      • More than one ThreadPool?
      • Cancelling work?
      • Dependencies between work? etc.
    • Generally, in System.Threading
      • Focus is on the thread and not the task
    • Makes it hard for the system to understand the intent and help with the implementation
  • 11. Parallel Computing Initiative
    • Goal is to simplify parallel programming
      • Local and distributed computing
      • Different kinds of parallelism
    • Including work on
      • Operating System, runtimes, frameworks, tools
    • First deliverables in VS 2010 ( .NET Fx V4.0 )
      • Managed : Parallel Extensions to .NET
      • Native: Parallel Pattern Library & Concurrency Runtime
      • Both: Parallel debugging and profiling tools
  • 12. Parallel Sums Revisited
  • 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. Task Parallel Library ( TPL ) Task TaskFactory TaskScheduler Key Classes
  • 15. Starting with Task
  • 16. Starting with Task
  • 17. Exploring Task
  • 18. Exploring Task
  • 19. Scheduling Tasks TaskScheduler Task ThreadPoolTaskScheduler SynchronizationContext TaskScheduler Custom QueueTask(Task t)
  • 20. Picking/Building a Scheduler
  • 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. Task Exotica ( knobs )
  • 23. Task exotica
  • 24. Higher Level Constructs
    • Even with Task there are common patterns that build into higher level abstractions
    • The Parallel class
      • Invoke, For, For<T>, Foreach
    • Care needs to be taken with state, ordering
      • “ This is not your Father’s for loop”
  • 25. Parallel.Invoke, ForEach, For
  • 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. 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. Parallel LINQ ( PLINQ )
    • Just like Parallel.For and friends, this sits on top of the Task Parallel Library
    • Care still needs to be taken
      • Around shared state
      • Around ordering
      • Around the mix between computation and I/O – not necessarily a performance win from parallelising a LINQ query
    • Remember
      • PLINQ is nothing to do with databases
  • 29. PLINQ
  • 30. Co-ordination Data Structures
  • 31. Co-ordination Data Structures
  • 32. What Next?
    • Download VS 2010 CTP
      • Remember to set the clock back
    • Experiment with runtime and API
      • Team is working on Visual Studio 2010 beta
      • Very open to feedback
      • Join in the discussion forums
    • Keep up with other concurrency topics at;
      • http://msdn.microsoft.com/concurrency
  • 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.