expressing parallel patterns in modern c++
DESCRIPTION
Expressing Parallel Patterns in Modern C++. Rahul V. Patil Microsoft C++ Parallel Computing Team. Note: this is a simplified version of the deck used in the video. Agenda. Patterns (70%) Infrastructure (9%) Coordination Data Structures (1%) Tooling (20%). Data Flow. Fork-Join. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/1.jpg)
Expressing Parallel Patterns in Modern C++
Rahul V. PatilMicrosoft
C++ Parallel Computing Team
Note: this is a simplified version of the deck used in the video
![Page 2: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/2.jpg)
Agenda• Patterns (70%)• Infrastructure (9%)• Coordination Data Structures (1%)• Tooling (20%)
![Page 3: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/3.jpg)
Asynchrony
Data Flow
Fork-Join
![Page 4: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/4.jpg)
Asynchrony
Data Flow
Fork-Join
![Page 5: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/5.jpg)
![Page 6: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/6.jpg)
![Page 7: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/7.jpg)
![Page 8: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/8.jpg)
![Page 9: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/9.jpg)
![Page 10: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/10.jpg)
![Page 11: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/11.jpg)
![Page 12: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/12.jpg)
![Page 13: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/13.jpg)
![Page 14: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/14.jpg)
![Page 15: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/15.jpg)
![Page 16: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/16.jpg)
![Page 17: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/17.jpg)
Fork-Join
Data Parallel Reduction Cancelation Nested fork-join Recursive fork-join
parallel_for parallel_for_eachparallel_invokeparallel_for fixedparallel_for simpleparallel_transformparallel_reduceparallel_sortparallel_radixsortparallel_buffered_sort
task_group.run(), .wait(), .cancel(), .run_and_wait()
Constructs
Patterns
![Page 18: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/18.jpg)
Asynchrony
Data Flow
Fork-Join
![Page 19: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/19.jpg)
![Page 20: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/20.jpg)
![Page 21: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/21.jpg)
![Page 22: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/22.jpg)
![Page 23: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/23.jpg)
![Page 24: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/24.jpg)
![Page 25: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/25.jpg)
![Page 26: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/26.jpg)
![Page 27: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/27.jpg)
Asynchrony
Speculative background work If you block, you break Dynamic continuation graphs
std::future<t>std::async, std::promise<t>task<t>
.then,
.wait,
.get,
.cancelwhen_all, when_any
task_completion_event<t>.set
Constructs
Patterns
![Page 28: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/28.jpg)
Asynchrony
Data Flow
Fork-Join
![Page 29: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/29.jpg)
![Page 30: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/30.jpg)
![Page 31: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/31.jpg)
Data Flow
Producer-Consumer Pipelines
Blocks and operationscall<t>transformer<t>join, multitype_join<…>choice<…>unbounded_bufferoverwrite_buffersingle_assignmenttimer
Constructs
Patterns
![Page 32: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/32.jpg)
RecapFork-Join
• Sequential code that needs to go faster
• Well defined input, transformation and output
Data-Flow• Either transformative or
reactive • Natural to express
computation in phases• Streaming inputs• Order matters
Async • If you block you break• Speculative background
work• Reactive• Continuations
![Page 33: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/33.jpg)
Infrastructure• Composable• Scalable• Efficient
![Page 34: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/34.jpg)
Conccurrent Data Structuresconcurrent_vector<t>concurrent_queue<t>concurrent_unordered_map<key,t>concurrent_unordered_multimap<key,t>concurrent_unordered_set<key,t>concurrent_unordered_multiset<key,t>concurrent_priority_queue<t>
![Page 35: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/35.jpg)
Tooling
![Page 36: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/36.jpg)
Intel Advisor
![Page 37: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/37.jpg)
Identify hot loops
![Page 38: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/38.jpg)
![Page 39: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/39.jpg)
Intel correctness tool
Identify Write race when parallelizing inner loop
![Page 40: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/40.jpg)
Add PPL tasks code
![Page 41: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/41.jpg)
Add Synchronization
![Page 42: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/42.jpg)
Launch Concurrency Visualizer
![Page 43: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/43.jpg)
![Page 44: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/44.jpg)
![Page 45: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/45.jpg)
Add parallelism to middle loop
![Page 46: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/46.jpg)
![Page 47: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/47.jpg)
![Page 48: Expressing Parallel Patterns in Modern C++](https://reader035.vdocument.in/reader035/viewer/2022062315/56816457550346895dd6256d/html5/thumbnails/48.jpg)
Q&A
• Blog Posts: C++ PPL and AMP blog• Questions on PPL: Native parallelism forum
Email me at:[r_ a_ h_ u_ l d o t p_ a_ t_ i_ l a t m_ i_ c_ r_ o_ s_ o_ f_ t_ . c_ o_ m (delete all underscores and spaces; replace d o t with the character ".“; at with @ ).]