Presentation is loading. Please wait.

Presentation is loading. Please wait.

Parallel Extensions A glimpse into the parallel universe Eric De Carufel

Similar presentations


Presentation on theme: "Parallel Extensions A glimpse into the parallel universe Eric De Carufel"— Presentation transcript:

1 Parallel Extensions A glimpse into the parallel universe Eric De Carufel eric.decarufel@orckestra.com eric@decarufel.net http://blog.decarufel.net

2 Core Expertise Online retail and distribution –Overture Solutions Enterprise Portals and ECM –Content Management, Collaboration, (Intranet) –Office Business Solutions –Partners Service Portals (Extranet) –Customer Service Portals (Internet) Business Process Automation –EAI, SOA, ESB Search –Fast ESP (A Microsoft Subsidiary) –SharePoint Server 2007 Search –Endeca IAP (Information Access Platform) Dynamics CRM 4.0 –Sales Force Automation –xRM applications Search platforms E-Commerce platform Enterprise platform Integration platform Business platforms

3 Partners Strategic Partners Technology Partners Consulting Partners

4 Clients

5 Who am’I? Eric De Carufel is solution architect at Orckestra Over 15 years experience in software development –Bell Canada, Centre de Recherceh d’emploi St-Denis, Fédération Québécoise de Karaté, AXA Canada Tech, Provigo (5 projects), Metro-Richelieu (2 projects), Imagina, be@com, Unipage, APLC, Viasystems, Montreal Jewish Hospital, AGTI, CCQ, Ogilvy Renault, Ivanhoé Cambridge, Microcell (Fido), Cirque du Soleil, TELUS, PSP Investment, CGI, Deutsche Bank, Orckestra, Sobeys, Jean-Coutu, Xtranormal Started with an ADAM computer by Coleco Working with.NET since version 1.0

6 Agenda Introduction Overview Library Core TPL (Task Parallel Library) Parallel Linq (PLINQ) Parallel Data Structures Questions

7 Introduction Why do we have to bother? –Moore’s law is over, no more free lunch The Power Wall The Complexity Wall (Instruction-Level Parallelism) The Memory Wall The Reliability Wall –Multi cores systems will be more and more available

8 Introduction Type of Parallelism –Asynchronous operation (better user experience) –Data parallelism –Task parallelism Options –Manual treading Thread, ThreadPool, BackgroundWorkerThread –Asynchronous calls –Event driven Problems –Resource sharing –Locking –Non-deterministic sequence of execution –Hard to debug

9 Overview

10 Task Parallel Library (TPL) Lightweight task framework (Task) –Create(Action ) factory method –Wait, WaitAll, WaitAny to catch exception –ContinueWith to chain Tasks together Lazy function call –Future Task scheduler and manager –TaskManager

11 DEMO Task Parallel Library (Task, Future, TaskManager)

12 Parallel API Parallel Loops –Parallel.For –Parallel.ForEach Lazy Initialisation –LazyInit Locking –SpinWait –SpinLock CountdownEvent

13 Parallel API Standard for loop – for (int i = 0; i < N; i++) { a[i] = Compute(i); } Parallel for loop – Parallel.For(0, N, i => { a[i] = Compute(i); });

14 DEMO Parallel API (Parallel.For, Parallel.ForEach)

15 Parallel Linq (PLINQ) Parallel Query –AsParallel() Return to sequential execution –AsSequential() Preserve order –AsOrdered() Order doesn’t matter –AsUnordered()

16 Parallel Linq (PLINQ) var query = from c in Customers where c.Name = “Smith” select c; var query = from c in Customers.AsParallel() where c.Name = “Smith” select c;

17 DEMO Parallel Linq (PLINQ)

18 Parallel Data Structures IConcurrent Collection –Add(T item) –Remove(out T item) ConcurrentStack –Push(T item) –TryPop(out T item) ConcurrentQueue –Enqueue(T item) –TryDequeue(out T item) BlockingCollection –Add(T item), –Remove(out T item) –TryAdd(T item), –TryRemove(out T item)

19 DEMO Parallel Structure (IConcurrentCllection, BlockingCollection, …)

20 CLR Thread Pool: Work-Stealing Worker Thread 1 Worker Thread p Program Thread User Mode Scheduler For Tasks Global Queue Global Queue Local Queue Local Queue Local Queue Local Queue Task 1 Task 2 Task 3 Task 5 Task 4 Task 6

21 MORE DEMO ContinueWith, Lambda, LazyInit

22 What’s next Visual Studio 2010.NET Framework 4.0 New multi cores computer (4, 16, 32, 64, …) Think parallel! –Thread safety will save your life

23 Call to action Parallel FX Team blog –http://blogs.msdn.com/pfxteam/http://blogs.msdn.com/pfxteam/ Visual Studio 2010 –Look for the next release Eric De Carufel –http://web.decarufel.net/contacthttp://web.decarufel.net/contact

24 Ideas Task stealing Integration into language maybe for later Potentially in parallel Exception Handling Garbage collection Shift from threads to tasks (more than needed) Divide and conquer leads to more parallelism opportunities Use of CPU, GPU or Scale out To get another 100x performance –The Power Wall –The Complexity Wall –The Memory Wall


Download ppt "Parallel Extensions A glimpse into the parallel universe Eric De Carufel"

Similar presentations


Ads by Google