120 likes | 305 Views
Parallel Fx Library for .NET 3.5 & Multi-Core Programming. Victor Stachura. The Man, The Myth, The Legend. Who is this guy?. Warning !. A New Programming Model is Needed. Multi-Core. Moore’s Law. Single Core. Performance. Time. Inside a Multi-Core Processor. One Processor.
E N D
Parallel Fx Library for .NET 3.5 & Multi-Core Programming Victor Stachura
The Man, The Myth, The Legend Who is this guy? Warning!
A New Programming Model is Needed Multi-Core Moore’s Law Single Core Performance Time
Inside a Multi-Core Processor One Processor With multiple execution Cores
Parallel Programming Makes a Difference Task 3 Core #1 Task 4 Core #1 Parallel programming with 2 cores Task 1 Task 5 Core #2 Task 2 Core #2 Degree of Parallel Programming Sequential app with threads Task 2 Task 4 Task 1 Task 3 Sequential app Task 1 Task 2 Task 3 Task 4 Execution Time
16 1 101 PA Parallel Programming How is Microsoft Addressing this Problem? Parallel Computing Initiative The Manycore Shift Whitepaper
16 1 101 PA Parallel Programming The Elements of Parallel Programming Software you need: Parallel Fx Library (Dec 07 CTP) Parallel Fx Concepts: Declarative Data Parallelism Imperative Data Parallelism* Imperative Task Parallelism Namespaces: System.Linq System.Linq.Parallel System.Threading System.Threading.Tasks .NET Framework 3.5 VS 2008 General Concepts: Problem Identification** Threads Thread Safety Locking Synchronization Race Conditions Deadlock
16 1 101 PA Parallel Programming Project Sybil So, does all this stuff work?
16 1 101 PA Parallel Programming Code Sample: Parallel.For() for (int i = 0; i < 10000000; i++) DataArray[i] = Rand.Next(); stopWatch.Start(); for (int i = 0; i < 10000000; i++) { DataArray[i] = DataArray[i] / 3; DataArray[i] = DataArray[i] * 6; DataArray[i] = DataArray[i] / 3; DataArray[i] = DataArray[i] * 5; DataArray[i] = DataArray[i] / 3; DataArray[i] *= DataArray[i]; DataArray[i] = DataArray[i] / 3; DataArray[i] = DataArray[i] * 6; DataArray[i] = DataArray[i] / 3; DataArray[i] = DataArray[i] * 5; DataArray[i] = DataArray[i] / 3; DataArray[i] *= DataArray[i]; } stopWatch.Stop(); for (int i = 0; i < 10000000; i++) DataArray[i] = Rand.Next(); stopWatch.Start(); Parallel.For(0, 10000000, delegate(int i) { DataArray[i] = DataArray[i] / 3; DataArray[i] = DataArray[i] * 6; DataArray[i] = DataArray[i] / 3; DataArray[i] = DataArray[i] * 5; DataArray[i] = DataArray[i] / 3; DataArray[i] *= DataArray[i]; DataArray[i] = DataArray[i] / 3; DataArray[i] = DataArray[i] * 6; DataArray[i] = DataArray[i] / 3; DataArray[i] = DataArray[i] * 5; DataArray[i] = DataArray[i] / 3; DataArray[i] *= DataArray[i]; }); stopWatch.Stop();
16 1 101 PA Parallel Programming Shift Happens Most applications running slow Hardware unused Applications must change You must learn You are responsible
16 1 101 PA Parallel Programming Resources MS Parallel Development Center Manycore Whitepaper Book: "Multi-core programming - Increasing Performance Through Software Multithreading" Intel ‘Go Videos’ MSDN Article: Optimized managed code for multicore machines