Linq Plinq
Linq Plinq
>
1. 2. 3.
>
1. 2. 3.
>
>
>
Data Structures
Agents Library
Data Structures
.NET Framework 4
ThreadPool
Task Scheduler Resource Manager
Visual C++ 10
Task Scheduler
Resource Manager
Concurrency Visualizer
Operating System
UMS Threads
An easy change
>
int[] output = arr .Select(x => Foo(x)) .ToArray();
>
int[] output = arr.AsParallel() .Select(x => Foo(x)) .ToArray();
coding walkthrough
int[] input = ... bool[] output = input.AsParallel() .Select(x => IsPrime(x)) .ToArray();
input: output:
1
6
F F T F T
3
8
2 7
IEnumerable<int> input = Enumerable.Range(1,100); bool[] output = input.AsParallel() .Select(x => IsPrime(x)) .ToArray();
Input Enumerator
output:
...
Poll
Input Enumerator
...
Poll
Input Enumerator
MoveNext
...
int result = input.AsParallel() .Aggregate( 0, (a, e) => a + Foo(e), (a1,a2) => a1 + a2);
res1:
Input Enumerator
res2:
result:
...
resN:
resultFound:
Input Enumerator
result:
Poll
...
Set
int[] output = input.AsParallel() .Where(x => IsPrime(x)) .GroupBy(x => x % 5) .Select(g => ProcessGroup(g)) .ToArray();
output:
Input Enumerator
...
...
>
> >
>
>
>
> > >
>
Core 1
Cache
6 7 3 2 5
Memory:
5 7 3 2 5 7 3 2
Invalidate
Cache Cache line
Core 2
Core 3
Cache
5 7 3 2
Core 4
5 7 3 2
> >
>
>
>
>
>
> >
>
> >
>
>
>
>
>
> >
>
>
>
>
>
>
channel9.msdn.com/learn
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.