Download presentation
Presentation is loading. Please wait.
Published byἸωσῆς Γεωργιάδης Modified over 6 years ago
1
C++ Forever: Interactive Applications in the Age of Manycore
11/15/2018 2:29 AM SVR19 C++ Forever: Interactive Applications in the Age of Manycore Rick Molloy Program Manager Microsoft Corporation © 2007 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.
2
Demo…
3
Agenda & Takeaways Expressing Concurrency is easier:
Tasks, Parallel Loops and Pipelines Your own parallel patterns A Composable and Scalable Concurrency Runtime Focus on correctness, not scalability Managing Shared State locks and concurrent containers Alternatives with the Agents Library Parallel Development Tools for Productivity
4
Parallel Computing and PDC09
Tools Managed Languages Visual F# Axum Visual Studio 2010 Parallel Debugger Windows Managed Libraries Native Libraries DryadLINQ Parallel Pattern Library Async Agents Library Profiler Concurrency Analysis Parallel LINQ Rx Task Parallel Library Microsoft Research Data Structures Data Structures Native Concurrency Runtime Race Detection Task Scheduler SVR10 Managed Concurrency Runtime Fuzzing ThreadPool Resource Manager Operating System SVR01 HPC Server Threads SVR18 UMS Threads Operating System Key: Research / Incubation Visual Studio 2010 / .NET 4 Windows 7 / Server 2008 R2
5
Parallel Pattern Library Concepts
Task: a computation that may be run asynchronously Task group: a collection of tasks that form a logical computation Parallel Loops: STL style algorithms with support for cancellation and composition
6
How to express tasks Parallel Tasks Window Parallel Stacks Windows
Expressing Tasks demo: tasks How to express tasks Parallel Tasks Window Parallel Stacks Windows
7
Extensibility: Building a parallel loop
template< class InIt,class Pr> inline bool parallel_all_of(InIt first, InIt last, Pr pred) { typedef iterator_traits<InIt>::value_type Item_type; //create a structured task group structured_task_group tasks; auto for_each_predicate = [&pred,&tasks](const Item_type& cur){ if (!pred(cur)) tasks.cancel(); }; auto task = make_task([&](){ parallel_for_each(first, last, for_each_predicate); }); return tasks.run_and_wait(task) != canceled; } template< class InIt,class Pr> inline bool parallel_all_of(InIt first, InIt last, Pr pred) { typedef iterator_traits<InIt>::value_type Item_type; //create a structured task group structured_task_group tasks; auto for_each_predicate = [&pred,&tasks](const Item_type& cur){ if (!pred(cur)) tasks.cancel(); }; auto task = make_task([&](){ parallel_for_each(first, last, for_each_predicate); }); } template< class InIt,class Pr> inline bool parallel_all_of(InIt first, InIt last, Pr pred) { typedef iterator_traits<InIt>::value_type Item_type; //create a structured task group structured_task_group tasks; } template< class InIt,class Pr> inline bool parallel_all_of(InIt first, InIt last, Pr pred) { } template< class InIt,class Pr> inline bool parallel_all_of(InIt first, InIt last, Pr pred) { typedef iterator_traits<InIt>::value_type Item_type; //create a structured task group structured_task_group tasks; auto for_each_predicate = [&pred,&tasks](const Item_type& cur){ if (!pred(cur)) tasks.cancel(); }; }
8
Cancellation, Composability and Navigating a Sea of Tasks
demo: parallel loops Composing Parallelism Parallel Stacks Window Method View Parallel Profiler
9
Parallel Pattern Library
Task Parallelism task_handle task_group structured_task_group Parallel Algorithms parallel_for parallel_for_each parallel_invoke Synchronization Primitives reader_writer critical_section event Concurrent Containers concurrent_queue concurrent_vector combinable <T> more at
10
Asynchronous Agents Concepts
Agent: A coarse-grained application component Sources and Targets (Message Blocks): Participants in message-passing which transport from source to target Co-operative Send and Receive: Utility functions for message passing
11
Pipelining in Parallel
Demo: message blocks Using Message Blocks Parallel Tasks window Locals Window 11/15/2018
12
Build an Agent What the agent provides
A model for state and lifetime management A migration path for threads and thread local state Build an Agent 1. Derive your class from agent 2. Expose only sources and targets publicly 3. Connect your targets in the start routine
13
Agents are actors class Actor: public agent {
overwrite_buffer<int> out; transformer<int,int> trans; public: ISource<int>* output_buf; ITarget<int>* input_buf; … void run(){ //initialize source and target trans.link_target(&out); … } }
14
Visualize a race condition Avoid it with message passing
Demo: shared state Visualize a race condition Avoid it with message passing
15
Visualize a race condition Serial Code
class Widget{ size_t m_width; size_t m_height; public: Widget(size_t w, size_t h):m_width(w),m_height(h){}; size_t GetWidth(){ return m_width; } size_t GetHeight(){ return m_height; void SetWidth(size_t width){ m_width = width; void SetHeight(size_t height){ m_height = height; };
16
Visualizing a race condition
17
Visualizing a race condition
18
Visualize a race condition locked
class LockedWidget{ … reader_writer_lock lock; public: size_t GetWidth(){ auto lockGuard = reader_writer::scoped_lock_read(lock); return m_width; } void SetWidth(size_t width){ auto lockGuard = reader_writer::scoped_lock(lock); m_width = width; void SetHeight(size_t height){ auto lockGuard = reader_writer::scoped_lock(lock) m_height = height;
19
Recognize an unsafe interface
We have APIs that need to be coordinated SetWidth and SetHeight We can always fix this by: Introducing more locks Adding acquire release semantics Or… we can coordinate this with message blocks
20
Coordination message blocks
class AgentsWidget{ overwrite_buffer<WidgetDimensions> m_dimensionBuf; public: AgentsWidget(size_t w, size_t h){ send(&m_dimensionBuf,WidgetDimensions(w,h)); }; WidgetDimensions GetDimensions(){ return receive(&m_dimensionBuf); } void UpdateDimensions(size_t width, size_t height){
21
Interacting with the GUI thread
The Basics: Get the work and I/O off of the UI thread Use PostMessage and message blocks to get the work back The Sample Pack provides: ui_task_group a ui message block more at
22
Asynchronous Agents Library
Message Blocks for Storing Data unbounded_buffer<T> overwrite_buffer<T> single_assignment<T> Message Blocks for pipelining tasks transformer<T,U> call<T> Message Blocks for joining data choice join Send and receive co-operatively send & receive messages more at
23
Parallel Computing and PDC09
Tools Managed Languages Overviews: FT07 & WKSP08 Visual F# FT20 VTL02 Axum FT03 FT19 Visual Studio 2010 Parallel Debugger Windows Managed Libraries Native Libraries DryadLINQ SVR17 FT19 Parallel Pattern Library Async Agents Library Profiler Concurrency Analysis FT21 Parallel LINQ VTL04 Rx Task Parallel Library FT03 VTL32 Microsoft Research Data Structures Data Structures Native Concurrency Runtime Race Detection SVR10 Task Scheduler Managed Concurrency Runtime Fuzzing ThreadPool Resource Manager Operating System SVR01 HPC Server Threads SVR18 UMS Threads Operating System Key: Research / Incubation Visual Studio 2010 / .NET 4 Windows 7 / Server 2008 R2
24
Parallel Computing and PDC09
Overview FT07: The State of Parallel Programming WKSP08: Patterns of Parallel Programming Managed code in Visual Studio 2010 FT03: Manycore and .NET 4: A Match Made in Visual Studio 2010 FT21: PLINQ: LINQ, but Faster! FT20: F# for Parallel and Asynchronous Programming Native code in Visual Studio 2010 SVR18: Developing Applications for Scale-Up Servers Running Windows Server 2008 R2 SVR10: Lighting up Windows Server 2008 R2 Using the ConcRT on UMS FT19: C++ Forever: Interactive Applications in the Age of Manycore HPC Server SVR01: Accelerating Applications Using Windows HPC Server 2008 Research and Incubation VTL02: Axum: A .NET Language for Safe and Scalable Concurrency VTL32: Concurrency Fuzzing & Data Races SVR17: Data-Intensive Computing on Windows HPC Server with DryadLINQ VTL04: Rx: Reactive Extensions for .NET FT36: Future of Garbage Collection
25
YOUR FEEDBACK IS IMPORTANT TO US!
Please fill out session evaluation forms online at MicrosoftPDC.com
26
channel9.msdn.com/learn
11/15/2018 2:29 AM Learn More On Channel 9 Expand your PDC experience through Channel 9 Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses channel9.msdn.com/learn Built by Developers for Developers…. © 2007 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.
27
11/15/2018 2:29 AM © 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.
28
11/15/2018 2:29 AM © 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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.