FUTURE OF.NET PARALLEL PROGRAMMING Joseph Albahari SESSION CODE: DEV308 (c) 2011 Microsoft. All rights reserved.

Slides:



Advertisements
Similar presentations
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Preface Demo A Quick Thank You How Did We Do It?
Windows 8 (1) (2) (3) Windows 8 (1) (2) (3)
Feature: Identity Management - Login © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Parallel Performance Tools in Visual Studio 2010.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Windows 7 Training. Windows ® 7 Compatibility Session 0 Isolation Isolation of Windows 7 Services.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
MVC - LESSONS LEARNT FROM BEING BURNT Malcolm Sheridan - Quantitative Project Leader ANZ SESSION CODE: #WEB306.
Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Adding Value to Software Projects with VSTO Jake Ginnivan B: jake.ginnivan.net SESSION CODE: DEV304 (c) 2011 Microsoft. All rights reserved.
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
demo Default WANGPSLookup Default WANGPS.
Co- location Mass Market Managed Hosting ISV Hosting.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Multitenant Model Request/Response General Model.
demo.
Feature: Purchase Order Prepayments II © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Announcing Demo Announcing.
Feature: OLE Notes Migration Utility
NEW WINDOWS PHONE “MANGO” APPLICATION PLATFORM SERVICES Chris blog.walshie.me SESSION CODE: WPH304 (c) 2011 Microsoft. All rights.
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Rico Mariani Architect Microsoft Corporation.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Connect with life Connect with life
Windows Azure Connect Name Title Microsoft Corporation.
NEXT: Overview – Sharing skills & code.
demo Receive Inventory Export Parse and Normalize.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Suggested Item Enhancements – Sales Script and Additional Information © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Please visit m.ausalgo.com on your device and sign inm.ausalgo.com.
demo Instance AInstance B Read “7” Write “8”

customer.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
Feature: Suggested Item Enhancements – Analysis and Assignment © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and.
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
The CLR CoreCLRCoreCLR © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
UNLOCK THE POWER OF USER DEVICE AFFINITY IN SCCM 2012 James SESSION CODE: #SEC309.
MULTI-TASKING AND APPLICATION SERVICES IN WINDOWS PHONE 7.5 Chris blog.walshie.me SESSION CODE: WPH305 (c) 2011 Microsoft. All rights.

IoCompleteRequest (Irp);... p = NULL; …f(p);
OFFICE DEPLOYMENT FOR THE ELITE Yoni Kirsh Managing Director Fastrack Technology SESSION CODE: OFS308 (c) 2011 Microsoft. All rights reserved.
THE FUTURE OF C#: GOOD THINGS COME TO THOSE WHO ‘AWAIT’ Joseph Albahari SESSION CODE: DEV411 (c) 2011 Microsoft. All rights reserved.
Возможности Excel 2010, о которых следует знать
Domain Driven Design, Domain Events and Unit Testing
Title of Presentation 12/2/2018 3:48 PM
MAP & ACT Pre deployment planning for Windows 7 or Server 2008 R2
(c) 2011 Microsoft. All rights reserved.
The Essential Windows Azure Developers Toolkit
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Hyper-V server deployment - Using the right tools
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
(c) 2011 Microsoft. All rights reserved.
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
Presentation transcript:

FUTURE OF.NET PARALLEL PROGRAMMING Joseph Albahari SESSION CODE: DEV308 (c) 2011 Microsoft. All rights reserved.

JOE ALBAHARI (c) 2011 Microsoft. All rights reserved.

Agenda ► Parallel Programming in Framework 4.0 recap ► TPL Dataflow in vNext (c) 2011 Microsoft. All rights reserved.

CPU Clock Speeds over Past 25 Years (c) 2011 Microsoft. All rights reserved. (logarithmic)

(c) 2011 Microsoft. All rights reserved. Intel’s 80-core prototype

Parallel APIs in Framework 4.0 (c) 2011 Microsoft. All rights reserved. Tasks Parallel Loops PLINQ Concurrent Collections CLR Thread Pool

Fork/Join (c) 2011 Microsoft. All rights reserved. Fork Join

Parallel Programming APIs APIForkJoin PLINQ Parallel Loops Task Parallelism (c) 2011 Microsoft. All rights reserved. Functional Imperative Task Parallel Library (TPL)

Task vs. Data Parallelism (c) 2011 Microsoft. All rights reserved. Tasks Data T1T2T3T4 T1T2T3T4 Parallel Loops PLINQ

► Highest-level parallel API ► Data parallelism ► Declarative ► Transparently parallelizes LINQ queries (c) 2011 Microsoft. All rights reserved.

string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" }; var query = from n in names where n.Contains ("a") orderby n.Length select n.ToUpper(); string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" }; var query = names.Where (n => n.Contains ("a")).OrderBy (n => n.Length).Select (n => n.ToUpper());

PLINQ – gotchas ► Query needs ‘meat’ ► Original ordering lost (by default) ► Functional impurity can break queries ► No work-stealing with range partitioning (c) 2011 Microsoft. All rights reserved.

Math.Sqrt (numbers.Average (n => n * n)) Root-mean-square double mean = numbers.Average(); double sdev = Math.Sqrt (numbers.Average (n => { double dif = n - mean; return dif * dif; })); Standard deviation var numbers = new[] { 2, 3, 4, 5, 6 }.AsParallel(); var numbers = new[] { 2, 3, 4, 5, 6 }.AsParallel();

PLINQ – Tricks & Tips ► Can do I/O bound queries – but there are better ways ►.ForAll() defeats data collation ► Aggregations are parallelizable albahari.com/threading (c) 2011 Microsoft. All rights reserved.

Parallel Loops (c) 2011 Microsoft. All rights reserved. Tasks Parallel Loops PLINQ Concurrent Collections CLR Thread Pool

Parallel Loops Parallel.For Parallel.ForEach (c) 2011 Microsoft. All rights reserved.

Parallel.For (1, 1000, i => Foo (i) ); Parallel.For (1, 1000, i => Foo (i) ); for (int i = 1; i < 1000; i++) Foo (i); for (int i = 1; i < 1000; i++) Foo (i); Sequential Parallel

var toTest = new TypeToTest(); var methodsToTest = from m in toTest.GetType().GetMethods() where m.GetCustomAttributes (false).OfType ().Any() select m; Parallel.ForEach (methodsToTest, m => { try { m.Invoke (instanceToTest, null)); } catch (Exception ex) {... } } Parallel Unit Testing (c) 2011 Microsoft. All rights reserved.

Tricks & Tips ► Best with moderately sized work items – 1µs to 100ms ► Avoid for I/O bound work ► Parallel.For = range partitioning + work stealing (c) 2011 Microsoft. All rights reserved.

Task Parallelism (c) 2011 Microsoft. All rights reserved. Tasks Parallel Loops PLINQ Concurrent Collections CLR Thread Pool

Task Parallelism ►Parallel.Invoke(Action[] actions) ► Task / Task (c) 2011 Microsoft. All rights reserved.

Task and Task A task represents a concurrent operation (c) 2011 Microsoft. All rights reserved.

Tasks have two purposes 1.For multithreading – Including Parallel programming – Gets you into the thread pool 2.A value-added signaling construct – I/O bound – Asynchronous Pattern (c) 2011 Microsoft. All rights reserved. Task TaskScheduler TaskCompletionSource Task.Factory.StartNew() new TaskCompletionSource<>()

Tasks: Tricks and Tips ► Be careful with continuations – Consider async CTP if you need them – Conditional continuations are particularly nasty ► Exception-handle ‘set-and-forget’ tasks (c) 2011 Microsoft. All rights reserved.

MANDELBROT DEMO (c) 2011 Microsoft. All rights reserved.

TPL Dataflow CTP (c) 2011 Microsoft. All rights reserved. Tasks Parallel Loops PLINQ Concurrent Collections CLR Thread Pool Dataflow

TPL Dataflow ► High throughput, low-latency scenarios ► Typical applications: – Manufacturing – Imaging – Biology – Oil & Gas – Finance – Robotics (c) 2011 Microsoft. All rights reserved.

TPL Dataflow AAL (C++) CCR (MS Robotics) Axum

Dataflow Blocks BufferingExecutionJoining BufferBlock BroadcastBlock WriteOnceBlock ActionBlock TransformBlock TransformManyBlock BatchBlock JoinBlock BatchedJoinBlock (c) 2011 Microsoft. All rights reserved.

ActionBlock (c) 2011 Microsoft. All rights reserved. Action delegate

ActionBlock (c) 2011 Microsoft. All rights reserved.

Multiple Blocks (c) 2011 Microsoft. All rights reserved. Action

MaxDegreeOfParallelism (c) 2011 Microsoft. All rights reserved. MaxDegreeOfParallelism = 2

TransformBlock (c) 2011 Microsoft. All rights reserved. Func

TransformManyBlock (c) 2011 Microsoft. All rights reserved. Func

TransformBlock + ActionBlock (c) 2011 Microsoft. All rights reserved. Func Action<>

Mandelbrot Pipeline (c) 2011 Microsoft. All rights reserved. Func Action Render Encode Save

Dataflow Blocks BufferingExecutionJoining BufferBlock BroadcastBlock WriteOnceBlock ActionBlock TransformBlock TransformManyBlock BatchBlock JoinBlock BatchedJoinBlock (c) 2011 Microsoft. All rights reserved.

BatchBlock<> (c) 2011 Microsoft. All rights reserved.

JoinBlock<> (c) 2011 Microsoft. All rights reserved.

Joining Blocks: Greedy by default (c) 2011 Microsoft. All rights reserved.

Non-greedy (c) 2011 Microsoft. All rights reserved.

DataFlow Blocks BufferingExecutionJoining BufferBlock BroadcastBlock WriteOnceBlock ActionBlock TransformBlock TransformManyBlock BatchBlock JoinBlock BatchedJoinBlock (c) 2011 Microsoft. All rights reserved.

BufferBlock<> (c) 2011 Microsoft. All rights reserved.

BroadcastBlock<> (c) 2011 Microsoft. All rights reserved. “overwrite buffer”

WriteOnceBlock<> (c) 2011 Microsoft. All rights reserved.

Dataflow Blocks BufferingExecutionJoining BufferBlock BroadcastBlock WriteOnceBlock ActionBlock TransformBlock TransformManyBlock BatchBlock JoinBlock BatchedJoinBlock (c) 2011 Microsoft. All rights reserved.

Extensibility & Interoperability ► Custom data blocks ► Rx: – AsObservable() – AsObserver() (c) 2011 Microsoft. All rights reserved.

Enrol in Microsoft Virtual Academy Today Why Enroll, other than it being free? The MVA helps improve your IT skill set and advance your career with a free, easy to access training portal that allows you to learn at your own pace, focusing on Microsoft technologies. What Do I get for enrolment? ► Free training to make you become the Cloud-Hero in my Organization ► Help mastering your Training Path and get the recognition ► Connect with other IT Pros and discuss The Cloud Where do I Enrol? Then tell us what you think.

© 2010 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. (c) 2011 Microsoft. All rights reserved.