paweł Łukasik wroc.net mail: [email protected] twitter: @pawel_lukasik

18
Aplikacje równoległe s ą dla każdego Paweł Łukasik Wroc.NET mail: [email protected] Twitter: @pawel_lukasik

Upload: leah-holland

Post on 26-Mar-2015

224 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

Aplikacje równoległe są dla każdego Paweł Łukasik

Wroc.NET

mail: [email protected]: @pawel_lukasik

Page 2: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

AGENDA

−Po co nam coś nowego?−ThreadPool w .NET 4−Data parallelism−Task parallelism−Nowe klasy

„zsynchronizowane”−Narzędzia

Page 3: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

Po co nam coś nowego?

− Abstrakcja− Spójne API− Uproszczone użycie− Dynamiczne zrównoleglenie− Anulowanie zadań− Stany wątków

A wszystko to tylko w jednym celu….

The purpose of the TPL is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications. The TPL scales the degree of concurrency dynamically to most efficiently use all the processors that are available. In addition, the TPL handles the partitioning of the work, the scheduling of threads on the ThreadPool, cancellation support, state management, and other low-level details. By using TPL, you can maximize the performance of your code while focusing on the work that your program is designed to accomplish. 

Page 4: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

ThreadPool – Co nowego?

− Zmiana wewnętrznego działania – mniej blokowania

− Wykradanie zadań (work-stealing)− Szybszy - od 2x (na Dual) do 5,6x (na

Quad)

Page 5: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

Global queue

Thread 1 Thread 2

T1 T2 T3

Page 6: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

DEMO – Data parallelism

Page 7: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

Podsumowanie

− Użycie− ParallelOptions− Anulowanie− Różne strategie wyjścia (tzw. Early

Termination)− Partitioner− Local state

Page 8: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

DEMO - Task parallelism

Page 9: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

TPL - podsumowanie

− Sposób użycia− TaskCreationOptions (PreferFairness,

AttachToParent, LongRunning)− TaskContinuationOptions (NotOn…,

OnlyOn)− Scheduler− Anulowanie

Page 10: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

DEMO - Parallel LINQ

Page 11: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

PLINQ - Podsumowanie

− .AsParallel, ParallelEnumerable− WithDegreeOfParallelism− WithExecutionMode− WithMergeOptions− WithCancellation

Page 12: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

DEMO – Concurrent classes

Page 13: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

Podsumowanie – Concurrent classes− Thread-safe− BlockingCollection− ConcurrentQueue

Page 14: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

DEMO – Debugging tools

Page 15: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

Debugging Tools - Podsumowanie

− Pozwalają w łatwiejszy sposób przyjrzeć się naszej aplikacji− Śledzenie tasków (Parallel Tasks)− Obrazowanie zależności (Parallel Stacks)− Wydajność (Performance Analysis)

Page 16: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

Pytania?

Page 18: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik

Dziękuję za uwagęPytania?