Parallel Pattern Library Resource Manager Task Scheduler Task Parallel Library Task Parallel Library Parallel LINQ Managed Native Key: Threads Operating System Concurrency Runtime Programming Models ThreadPool Task Scheduler Resource Manager Data Structures Tools Tooling Parallel Debugger Tool Windows Parallel Debugger Tool Windows Concurrency Visualizer Agents Library UMS Threads.NET Framework 4 Visual C++ 10 Visual Studio IDE Visual Studio IDE Windows Parallel LINQ
int[] output = arr.Select(x => Foo(x)).ToArray(); int[] output = arr.Select(x => Foo(x)).ToArray(); int[] output = arr.AsParallel().Select(x => Foo(x)).ToArray(); int[] output = arr.AsParallel().Select(x => Foo(x)).ToArray();
coding walkthrough
1 1 int[] input =... bool[] output = input.AsParallel().Select(x => IsPrime(x)).ToArray(); int[] input =... bool[] output = input.AsParallel().Select(x => IsPrime(x)).ToArray(); input:output: … … F F F F T T F F T T T T … …
IEnumerable input = Enumerable.Range(1,100); bool[] output = input.AsParallel().Select(x => IsPrime(x)).ToArray(); IEnumerable input = Enumerable.Range(1,100); bool[] output = input.AsParallel().Select(x => IsPrime(x)).ToArray();... Input Enumerator output:
var q = input.AsParallel().Select(x => IsPrime(x)); foreach(var x in q) {... } var q = input.AsParallel().Select(x => IsPrime(x)); foreach(var x in q) {... } Input Enumerator Output Enumerator Output Enumerator... Poll MoveNext
var q = input.AsParallel().AsOrdered().Select(x => IsPrime(x)); foreach(var x in q) {... } var q = input.AsParallel().AsOrdered().Select(x => IsPrime(x)); foreach(var x in q) {... } Input Enumerator Output Enumerator Output Enumerator... Poll MoveNext
Input Enumerator... int result = input.AsParallel().Aggregate( 0, (a, e) => a + Foo(e), (a1,a2) => a1 + a2); int result = input.AsParallel().Aggregate( 0, (a, e) => a + Foo(e), (a1,a2) => a1 + a2); res1: res2: resN: result:
Input Enumerator... int result = input.AsParallel().AsOrdered().Where(x => IsPrime(x)).First(); int result = input.AsParallel().AsOrdered().Where(x => IsPrime(x)).First(); resultFound: F F result: Poll Set
int[] output = input.AsParallel().Where(x => IsPrime(x)).GroupBy(x => x % 5).Select(g => ProcessGroup(g)).ToArray(); int[] output = input.AsParallel().Where(x => IsPrime(x)).GroupBy(x => x % 5).Select(g => ProcessGroup(g)).ToArray();... Input Enumerator output:...
Core Core 2 Core 3 Core 4 Invalidate Cache Memory: Cache line
src.Select(x => Foo(x)).TakeWhile(x => Filter(x)).AsParallel().Select(x => Bar(x)).ToArray(); src.Select(x => Foo(x)).TakeWhile(x => Filter(x)).AsParallel().Select(x => Bar(x)).ToArray();
Built by Developers for Developers….
© 2009 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.