Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multiprocessing & The.Net Parallel Extensions Guy Ben Haim Senior Application Engineer Intel Asaf Shelly.

Similar presentations

Presentation on theme: "Multiprocessing & The.Net Parallel Extensions Guy Ben Haim Senior Application Engineer Intel Asaf Shelly."— Presentation transcript:


2 Multiprocessing & The.Net Parallel Extensions Guy Ben Haim Senior Application Engineer Intel Asaf Shelly Senior Consultant Pacific Software

3 Session Objectives and Agenda Multicore Parallel Software.Net Parallel Extensions Q&A Summary

4 What is Multicore Pentium Pentium Processor Dual Core Quad Core

5 Moore’s Law – GHz to Multicore Performance 2006 Intel MC Assistance Threading Multi-tasking Training Tools Performance Through Multi-Core frequency -+

6 Intel Processor Advancement Multiple execution cores ramping across Intel platforms

7 Why Multi Core? Power Performance 2 GHz 100%

8 CPU that is 20% Faster Power Performance 2.4 GHz2 GHz 174% 100% 113% 100%

9 CPU that is 20% Slower Power Performance 1.6 GHz 100% 2 GHz 50% 87% 2.4 GHz 174% 100% 113%

10 Multi Core: Energy Efficient Performance Power Performance 1.6 GHz 100% 2 GHz 100% 174% 2.4 GHz 174% 100% 113% 174%

11 What does it mean Multi Cores? Performance

12 Start Thinking Parallel Software Today Instructions – Assembly – Making it workInstructions – Assembly – Making it work Thinking like a CPUThinking like a CPU Functions – C, Pascal, Basic – Faster CodeFunctions – C, Pascal, Basic – Faster Code Procedural ThinkingProcedural Thinking Objects – C++, Java, C#, Delphi, VB – Manage CodeObjects – C++, Java, C#, Delphi, VB – Manage Code OOD, OOP – Thinking in objectsOOD, OOP – Thinking in objects Tasks - ? – Optimize RuntimeTasks - ? – Optimize Runtime Thinking Parallel

13 Situation Today Experts, Freelance Specialists, Skilled Groups API is not intuitive Hard to understand execution flow Problematic Design Patterns Little awareness of tools Hidden Problems Hard to test and debug

14 Understanding Parallel Computing Resources Ownership Global data / Shared data Collisions and Race Conditions Task Design Conjunction Points

15 Task Oriented Design Modify Write Open Modify Scan

16 Simple For for ( int y = 0; y < bmp.Height; y++ ) { for ( int x = 0; x < bmp.Width; x++ ) { Pixels[ x, y ] = bmp.GetPixel( x, y ); }

17 Parallel For Parallel.For( 0, bmp.Height, y => { for ( int x = 0; x < bmp.Width; x++ ) { Pixels[ x, y ] = bmp.GetPixel( x, y ); } });

18 .Net Parallel Extensions - Performance

19 Parallel Class Parallel.For Parallel.Do Parallel.ForEach Inplace code / Function Object Type

20 Parallel Do Parallel Quick Sort: void QuicksortParallel(,, ) { int pivot = Partition(arr, left, right); Parallel.Do( () => QuicksortParallel(arr, left, pivot - 1), () => QuicksortParallel(arr, pivot + 1, right)); }


22 .Net Parallel Extensions – PLINQ

23 Task Parallel Library Parallel For, Do, ForEach PLINQ Tasks over Threads Tasks over Cores TaskManager Conjunction Points

24 .Net Parallel Extensions – Tasks Parallel Library

25 .Net Parallel Extensions – RayTracer

26 Tips Shared are Globals Parallel Loops are not loops Define data as Loop internal Race Conditions are still here Don’t use Locks!! Don’t use MUTEXs

27 Threading Tools  Intel® Thread Checker Used to create correct multi- threaded code  Intel® Thread Profiler Used to analyze performance Intel Software Solutions Group:

28 Data Race example Serial program What is value of A_SUM: A_Sum = 4 R S1: x = 1.0; y = 2.0 ; A1 = 0; S2: A1 = x * y; S3: A_SUM = 2 * A1; x y A1

29 Data Race example (Cont.) Initiate x = 1.0; y = 2.0 ; A1 = 0; Thread1 A1 = x * y Thread2 A_SUM = 2 * A1 What is value of x if: Thread1 runs before Thread2? Thread2 runs before Thread1? Execution order is not guaranteed x y A_Sum = 4 A_Sum = 0 A1

30 Intel® Thread Checker Diagnostics

31 Source Code Viewer

32 Performance Profile Threads Speedup Possible causes for this scalability profile: 1.Insufficient parallel work 2.Load imbalance 3.Synchronization overhead 4.Memory bandwidth limitations

33 Finding Serial and Parallel Time

34 Load Imbalance Multi Threading should be managed Multi Threading should be managed  Programming should consider load imbalance

35 Load Imbalance Unequal work loads lead to idle threads and wasted time Busy Idle Time Thread 0 Thread 1 Thread 2 Thread 3 Start threads Join threads

36 Synchronization  Programming should consider Synchronizations issues

37 Synchronization By definition, synchronization serializes execution Lock contention means more idle time for threads Busy Idle In Critical Thread 0 Thread 1 Thread 2 Thread 3 Time

38 Real example : Before fix Serial Parallel Switching Overhead

39 Real example: After fix Serial Parallel 2 X Speed Up

40 Summary Parallelize or Perish !

41 Do we really want Parallel Code? Do users even care? 2005 2007 2008 2010

42 Change In Mindset Everything is stopped. Waiting for the photographer Everyone is working independently

43 Developers are writing functions Developers are managing tasks

44 Doing things the way we always have Things are going to be different

45 Keep yourself in the loop Public event by Pacific Software Register to the User Group Asynchronous Operations Web Site has all the online resources that you need... and more Register to my five day course titled Multiprocessing Traps and Pitfalls Use our poster to let people know that you know


47 Resources Download the Microsoft.Net Parallel Extensions 4941-8705-024bc7f180ba&displaylang=en 4941-8705-024bc7f180ba&displaylang=en Asynchronous Operations Web Site Intel’s Multicore Pacificsoft Training and Consulting Microsoft Forum for Parallel Computing

48 Make a difference Let us know what you think Feedback for the.Net Parallel Extensions Dev team Video blog about parallel computing Fill the feedback form …

49 כדאי למלא משוב ! איך ממלאים? בעקבות מייל שישלח בסיום כל יום, ב-Business Center במתחם HP, בעמדות האינטרנט במלונות הילטון ודן מילאת משוב - מגיעה לך חולצת Live It! מילאת משוב בשלושת ימי הכנס? יש לך הזדמנות לזכות בכרטיס טיסה לתאילנד מתנת סוכנות BTC, מכשיר בלאק ג'ק מתנת סמסונג, מכשיר HTC מתנת ניופאן, מדיה סנטר מתנת DataSafe ועוד...


51 © 2007 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.

Download ppt "Multiprocessing & The.Net Parallel Extensions Guy Ben Haim Senior Application Engineer Intel Asaf Shelly."

Similar presentations

Ads by Google