Download presentation
Presentation is loading. Please wait.
Published byRuth Lester Modified over 9 years ago
1
Rick Molloy Program Manager Microsoft Corporation TL25
5
Make it easier to express and manage the correctness, efficiency and maintainability of parallelism on Microsoft platforms for developers of all skill levels Enable developers to express parallelism easily and focus on the problem to be solved Improve the efficiency and scalability of parallel applications Simplify the process of designing and testing parallel applications
6
void MatrixMult( int size, double** m1, double** m2, double** result) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { result[i][j] = 0; for (int k = 0; k < size; k++) { result[i][j] += m1[i][k] * m2[k][j]; }
7
void MatrixMult( int size, double** m1, double** m2, double** result) { int N = size; int P = 2 * NUMPROCS; int Chunk = N / P; HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); long counter = P; for (int c = 0; c < P; c++) { std::thread t ([&,c] { for (int i = c * Chunk; i < (c + 1 == P ? N : (c + 1) * Chunk); i++) { for (int j = 0; j < size; j++) { result[i][j] = 0; for (int k = 0; k < size; k++) { result[i][j] += m1[i][k] * m2[k][j]; } if (InterlockedDecrement(counter) == 0) SetEvent(hEvent); }); } WaitForSingleObject(hEvent,INFINITE); CloseHandle(hEvent); } Synchronization Knowledge Error prone Heavy synchronization Static partitioning Lack of thread reuse Tricks Lots of boilerplate
9
MSFT Parallel Computing Technologies Robotics-based manufacturing assembly line Silverlight Olympics viewer Enterprise search, OLTP, collab Animation / CGI rendering Weather forecasting Seismic monitoring Oil exploration Automotive control system Internet –based photo services Ultrasound imaging equipment Media encode/decode Image processing/ enhancement Data visualization Task Concurrency Data Parallelism Distributed/ Cloud Computing Local Computing CCR Maestro TPL / PPL Cluster TPL Cluster PLINQ MPI / MPI.Net WCF Cluster SOA WF PLINQ TPL / PPL CDS OpenMP WF Compute Shader
10
AreaDescriptionsExample Scenarios Imperative Data Parallelism Apply the same operation to common collections/sets in parallel. Looping, data partitioning, divide-and-conquer, reductions, scans, etc. Medical imaging Bond pricing Task Parallelism Simultaneously perform multiple independent operations. Tasks, threads, fork/join, futures, etc. Process control automation Shared Resources Building blocks for implementing concurrent components. Scalable and thread-safe collections, locks, etc. Middle-tier configuration/ state management Declarative Data Parallelism Define what computation needs to be done, without the how. Selections, filters, joins, aggregations, groupings, etc. Statistical modeling Asynchrony Exploit latent operations by doing work while waiting for data. Asynch I/O, async interaction points, message passing, etc. Streaming audio
12
Scenario: Simple Image Processing Pipeline task transform / parallel for search for files transform load image from disk image filters transform / parallel for transform load image from disk image filters alternator load balance unbounded buffer image ready
13
Parallel Pattern Library Resource Manager Task Scheduler Task Parallel Library Task Parallel Library PLINQ Managed Library Native Library Key: Threads Operating System Concurrency Runtime Programming Models Agents Library Agents Library ThreadPool Task Scheduler Resource Manager Data Structures Tools Parallel Debugger Tool Windows Parallel Debugger Tool Windows Profiler Concurrency Analysis Profiler Concurrency Analysis
14
Parallel Pattern Library Resource Manager Task Scheduler Task Parallel Library Task Parallel Library PLINQ Managed Library Native Library Key: Threads Operating System Concurrency Runtime Programming Models Agents Library Agents Library ThreadPool Task Scheduler Resource Manager Data Structures Tools Parallel Debugger Tool Windows Parallel Debugger Tool Windows Profiler Concurrency Analysis Profiler Concurrency Analysis
16
Visual Studio 10 Concurrency Runtime Programming Model Operating System Platform Infrastructure for Concurrency Low overhead scheduling and load balancing Cooperative blocking Support for multiple scheduler instances Resource management Common resource management Dynamic load balancing between schedulers Platform extensibility and composability Enables ISVs and partners to integrate concurrent libraries with the Scheduler and Resource Manager
17
Visual Studio 10 Concurrency Runtime Programming Model Operating System Platform Infrastructure for Concurrency Low overhead scheduling and load balancing Cooperative blocking Support for multiple scheduler instances Resource management Common resource management Dynamic load balancing between schedulers Platform extensibility and composability Enables ISVs and partners to integrate concurrent libraries with the Scheduler and Resource Manager OpenMP Threading Building Blocks Intel Parallel Studio
18
Visual Studio 10 Programming Model Operating System OpenMP Threading Building Blocks Intel Parallel Studio Reduce the number of concepts to learn through interfaces and containers common to TBB and PPL Encourage broader adoption by aligning interfaces and responding to customer feedback Better application scalability and composability with platform integration Concurrency Runtime
20
Dynamic scheduling allows work to be distributed efficiently at runtime. CPU0 CPU1 CPU2 CPU3 CPU0 CPU1 CPU2 CPU3
21
Parallel Pattern Library Resource Manager Task Scheduler Task Parallel Library Task Parallel Library PLINQ Managed Library Native Library Key: Threads Operating System Concurrency Runtime Programming Models Agents Library Agents Library ThreadPool Task Scheduler Resource Manager Data Structures Tools Parallel Debugger Tool Windows Parallel Debugger Tool Windows Concurrent Profiling Concurrent Profiling
22
Visual Studio 10 Concurrency Runtime Operating System Simplify writing parallel applications by raising the level of abstraction Simplify writing parallel applications by providing alternatives to shared state Unlock Platform Performance by providing developers with concurrent algorithms and containers
24
void quicksort(int * a, int n) { if (n <= 1) return; int s = partition(a,n); quicksort(a,s); quicksort(a+s,n-s); }
25
void quicksort(int * a, int n) { if (n <= 1) return; int s = partition(a,n); task_group g; g.run([&]{quicksort(a,s);}); g.run([&]{quicksort(a+s,n-s);}); g.wait(); }
27
Parallel Pattern Library Resource Manager Task Scheduler Task Parallel Library Task Parallel Library PLINQ Managed Library Native Library Key: Threads Operating System Concurrency Runtime Programming Models Agents Library Agents Library ThreadPool Task Scheduler Resource Manager Data Structures Tools Parallel Debugger Tool Windows Parallel Debugger Tool Windows Concurrent Profiling Concurrent Profiling
32
Parallel Pattern Library Resource Manager Task Scheduler Task Parallel Library Task Parallel Library PLINQ Managed Library Native Library Key: Threads Operating System Concurrency Runtime Programming Models Agents Library Agents Library ThreadPool Task Scheduler Resource Manager Data Structures Tools Parallel Debugger Tools Windows Parallel Debugger Tools Windows Concurrent Profiling Concurrent Profiling
34
int sum = 0; for (vector ::iterator it = myVec.begin(); it != myVec.end(); ++it) { int element = *it; SomeFineGrainComputation(element); sum += element; }
35
combinable localSums; parallel_for_each(myVec.begin(), myVec.end(), [&localSums] (int element) { SomeFineGrainComputation(element); localSums.local() += element; }); int sum = localSums.combine(std::plus );
36
//a vector of imagePaths vector images; list imageList for_each(images.begin(),images.end(),[&](string path){ Cimage* image = new Cimage(); image->Load(path.c_str()); imageList.push_back(image); }
37
//a vector of imagePaths vector images; //a combinable list combinable > combinableImageList; parallel_for_each(images.begin(),images.end(),[&](string path){ Cimage* image = new Cimage(); image->Load(path.c_str()); combinableImageList.local().push_back(image); } //our result list list imageList; combinableImageList.combine_each([&](list & localList){ imageList.splice(resultImageList.begin(),localList); });
38
Express Concurrency in C++
39
Parallel Pattern Library Resource Manager Task Scheduler Task Parallel Library Task Parallel Library PLINQ Managed Library Native Library Key: Threads Operating System Concurrency Runtime Programming Models Agents Library Agents Library ThreadPool Task Scheduler Resource Manager Data Structures Tools Parallel Debugger Tool Windows Parallel Debugger Tool Windows Concurrent Profiling Concurrent Profiling
40
Visual Studio 10 Concurrency Runtime Operating System Simplify writing parallel applications by raising the level of abstraction Simplify writing parallel applications providing alternatives to shared state by providing alternatives to shared state Unlock Platform Performance by providing developers with concurrent algorithms and containers
43
HRESULT LogChunkFileParser::ParseFile() { HRESULT hr = S_OK; WCHAR wszLine[MAX_LINE] = {0}; hr = reader->OpenFile(pFileName); if (SUCCEEDED(hr)){ while(!reader->EndOfFile()){ //read the next line hr = reader->ReadLine(wszLine, MAX_LINE); if (SUCCEEDED(hr)){ //and parse it Parse(wszLine); } return S_OK; }
44
HRESULT LogChunkFileParser::ParseFile(){ unbounded_buffer * MsgBuffer= new unbounded_buffer (); ParserAgent parseAgent; parseAgent.start(); HRESULT hr = S_OK; WCHAR* wszLine; hr = reader->OpenFile(pFileName); if (SUCCEEDED(hr)){ while(!reader->EndOfFile()){ wszLine = new WCHAR[MAX_LINE]; // read the next line hr = reader->ReadLine(wszLine, MAX_LINE); if (SUCCEEDED(hr)){ //and parse it send(MsgBuffer, AgentMessage(wszLine)); } send(MsgBuffer, AgentMessage(EXIT)); parseAgent.wait(); } return hr; }; class ParserAgent : agent{ unbounded_buffer & buf_; public: … void Run(){ AgentMessage msg; while((msg = receive(buf_))->type != EXIT) { Parse(msg->pCurrentLine); delete msg->pCurrentLine; } }); class ParserAgent : agent{ unbounded_buffer & buf_; public: … void Run(){ AgentMessage msg; while((msg = receive(buf_))->type != EXIT) { Parse(msg->pCurrentLine); delete msg->pCurrentLine; } });
47
PDC Parallelism Sessions
49
And download Parallel Extensions to the.NET Framework!
51
Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com
52
© 2008 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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.