Parallel Computing For Managed Developers
-
Upload
bala-subra -
Category
Documents
-
view
568 -
download
4
description
Transcript of Parallel Computing For Managed Developers
![Page 1: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/1.jpg)
Visual Studio 2010and
.NET Framework 4
Training Workshop
Visual Studio 2010and
.NET Framework 4
Training Workshop
![Page 2: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/2.jpg)
Parallel Computingfor
Managed Developers
Parallel Computingfor
Managed Developers
NameTitleOrganizationEmail
![Page 3: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/3.jpg)
ObjectivesObjectives
Understand the importance of the “parallel computing shift”
Understand the technologies introduced in the .NET Framework 4 that are easing this transition
![Page 4: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/4.jpg)
“I used to think that cyberspace was fifty years away. What I thought was fifty years away, was only ten years away. And what I thought was ten years away... it was already here. I just wasn't aware of it yet.”
- Bruce Sterling
![Page 5: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/5.jpg)
Baby NamesBaby Names
![Page 6: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/6.jpg)
“Moore’s Law scaling should easily let us hit the 80-core mark in mainstream processors within the next ten years and quite possibly even sooner.”
- Justin Ratner, CTO, Intel
![Page 7: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/7.jpg)
The Parallel Computing Initiative
The Parallel Computing Initiative
Letting the brightest developers solve business problems, not concurrency problems.
“Concurrency for the masses”
![Page 8: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/8.jpg)
Concurrency LandscapeConcurrency Landscape
For Visual Studio 2010 and the .NET Framework 4…
System.Threading Parallel Extensions
Unified Cancellation Model
![Page 9: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/9.jpg)
New System.Threading PrimitivesNew System.Threading Primitives
A Barrier is a synchronization primitive that enforces the stopping of execution between a number of threads or processes at a given point and prevents further execution until all threads or processors have reached the given point.
A CountdownEvent is a synchronization primitive that enables ongoing tracking of a given workload in order to determine if processing of that workload is finished or not.
YUCK!
![Page 10: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/10.jpg)
BarrierBarrier“Let’s all caravan over to Seattle! We’ll meet at
the gas station and leave from there.” - Charlie
Mac
Charlie
Dennis
Seattle
Barrier
Gas Station
![Page 11: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/11.jpg)
Unified CancellationUnified Cancellation
“Sir, we are ready to seat you…” - Hostess
CancellationTokenSource
CancellationToken
![Page 12: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/12.jpg)
System.Threading and the new Unified Cancellation
Model
System.Threading and the new Unified Cancellation
Model
![Page 13: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/13.jpg)
Parallel Extensions is a .NET Library that supports declarative and imperative data parallelism, imperative task parallelism, and a set of data structures that make coordination easier.
1. Parallel LINQ (PLINQ)
2. Task Parallel Library (TPL)
3. Coordination Data Structures (CDS)
![Page 14: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/14.jpg)
From Threads To TasksFrom Threads To Tasks
![Page 15: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/15.jpg)
“Work Stealing” in Action“Work Stealing” in Action
Worker Thread
1
Worker Thread
pProgram
ThreadTask 1
Task 2Task 3
Task 5Task 4
![Page 16: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/16.jpg)
Parallel Static ClassParallel Static Class
When program statements are independent…
…they can be parallelized
StatementA();StatementB();StatementC();
Parallel.Invoke( () => StatementA(), () => StatementB(), () => StatementC() );
![Page 17: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/17.jpg)
Parallel Static ClassParallel Static Class
![Page 18: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/18.jpg)
PLINQPLINQ
Parallel LINQ (PLINQ) enables developers to easily leverage manycore with a minimal impact to existing LINQ programming model
var q = from p in people where p.Name == queryInfo.Name && p.State == queryInfo.State && p.Year >= yearStart && p.Year <= yearEnd orderby p.Year ascending select p;
.AsParallel()
![Page 19: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/19.jpg)
PLINQPLINQ
![Page 20: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/20.jpg)
RecapRecap
For Visual Studio 2010 and the .NET Framework 4.0…
System.Threading Parallel Extensions
Unified Cancellation Model
![Page 21: Parallel Computing For Managed Developers](https://reader033.fdocuments.us/reader033/viewer/2022052621/55810a1bd8b42a05558b4a4a/html5/thumbnails/21.jpg)