MTaulty_DevWeek_Parallel
Upcoming SlideShare
Loading in...5
×
 

MTaulty_DevWeek_Parallel

on

  • 1,565 views

MTaulty_DevWeek_Parallel

MTaulty_DevWeek_Parallel

Statistics

Views

Total Views
1,565
Views on SlideShare
1,565
Embed Views
0

Actions

Likes
0
Downloads
19
Comments
0

0 Embeds 0

No embeds

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…
Post Comment
Edit your comment
  • 06/08/09 15:54 © 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.

MTaulty_DevWeek_Parallel MTaulty_DevWeek_Parallel Presentation Transcript

  • Parallel Extensions to the .NET Framework Mike Taulty Developer & Platform Group Microsoft Ltd [email_address] http://www.mtaulty.com (/DevWeek.zip)
  • “ You are here” Visual Studio 2010 ... ... ... ... Parallel Pattern Library & Concurrency Runtime Debugging Enhancements .NET Framework V4.0 ... ... ... Parallel Extensions to .NET Parallel Computing Initiative ( First Deliverables )
  • Today’s Processors £100 - £300 2-3GHz 2 cores or 4 64-bit Core Core
  • Tomorrow’s Processors Core Core Core Core £200 - £500 2-3GHz 4 cores with HT 64-bit QuickPath Interconnect Memory Controller
  • Where we are heading... Unisys ES7000 (7600R) used with kind permission of Mr Henk var der Valk, Unisys, NL
  • Are we equipped to get there? Windows OS App 1 App 2 ... App 1 .NET CLR .NET Framework My Code
    • What we have;
    • Explicit Multi-threading
    • Small set of sync primitives
      • Monitors, Events, etc.
      • ReaderWriterLock, etc.
    • ThreadPool
    • Focus is on the thread
    • What we need;
    • Better data structures
    • Higher level constructs
    • As with everything .NET
      • Raise the abstraction
      • Declare intent
      • Let the system help
  • A Pretend Scenario
  • 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
  • Parallel Extensions to .NET .NET ThreadPool V4.0 Coordination Data Structures Task Parallel Library Parallel LINQ ( PLINQ )
  • Parallel Extensions to .NET .NET ThreadPool V4.0 Task Parallel Library Parallel LINQ ( PLINQ ) Coordination Data Structures
  • Co-ordination Data Structures SpinLock ManualResetEventSlim SemaphoreSlim CountdownEvent LazyInit <T> SpinWait BlockingCollection<T> Barrier ConcurrentBag<T> ConcurrentLinkedList<T> ConcurrentDictionary<K,V> ConcurrentQueue<T> ConcurrentStack<T> LazyInitField<T>
  • Co-ordination Data Structures SpinLock ManualResetEventSlim SemaphoreSlim CountdownEvent LazyInit <T> SpinWait BlockingCollection<T> Barrier ConcurrentBag<T> ConcurrentLinkedList<T> ConcurrentDictionary<K,V> ConcurrentQueue<T> ConcurrentStack<T> LazyInitField<T> * Some more detail on hidden slides in slide-deck
  • Co-ordination Data Structures SpinLock SpinWait
    • Pros/Cons of spinning rather than blocking?
    • Use with extreme caution
      • needs a lot of knowledge of the scenario
      • is a struct – has value-type semantics
  • Co-ordination Data Structures BlockingCollection<T> ConcurrentBag<T> ConcurrentLinkedList<T> ConcurrentDictionary<K,V> ConcurrentQueue<T> ConcurrentStack<T>
    • Scalable
    • Concurrent
    • Collections
    • Easy to use
    • Takes any of the collections
      • Adds bounding
      • Adds blocking
    • Very smart & useful 
  • Co-ordination Data Structures ManualResetEventSlim SemaphoreSlim
    • Slim in what way?
    • Use just like their existing .NET counterparts
      • Semaphore
      • ManualResetEvent
  • Co-ordination Data Structures LazyInit <T> LazyInitField<T>
    • LazyInitField<T> is a lighter weight version of LazyInit<T>
      • A struct rather than a class
      • Slightly less capable
  • Co-ordination Data Structures SpinLock ManualResetEventSlim SemaphoreSlim CountdownEvent LazyInit <T> SpinWait BlockingCollection<T> Barrier ConcurrentBag<T> ConcurrentLinkedList<T> ConcurrentDictionary<K,V> ConcurrentQueue<T> ConcurrentStack<T> LazyInitField<T>
  • Co-ordination Data Structures
  • Parallel Extensions to .NET Coordination Data Structures .NET ThreadPool V4.0 Parallel LINQ ( PLINQ ) Task Parallel Library
  • Task Parallel Library ( TPL ) Key Classes
  • Task Topics
  • Task
  • Scheduling Tasks TaskScheduler Task ThreadPoolTaskScheduler SynchronizationContext TaskScheduler Custom QueueTask(Task t)
  • 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
  • Task Exotica ( knobs to tweak )
  • Side-Bar: the Self-Replicating Task .NET ThreadPool ( with V4.0 modifications ) … ThreadPool Heuristics: Inject another thread? Thread Task Thread’s Work Queue Thread Thread’s Work Queue Thread Thread’s Work Queue Global Work Queue Copy 1 Copy 2
  • Higher Level Constructs in TPL
    • Even with Task there are common patterns that build into higher level abstractions
    • The Parallel class
      • Invoke, For, For<T>, Foreach
    • Makes use of the self-replicating task
    • Care needs to be taken with state, ordering
  • Parallel.Invoke, ForEach, For
  • Parallel Extensions to .NET Coordination Data Structures .NET ThreadPool V4.0 Task Parallel Library Parallel LINQ ( PLINQ )
  • 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
  • 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
  • PLINQ
  • 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
  • © 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.