Parallelism and Concurrency in C++17 and C++20. Rainer Grimm Training, Coaching and, Technology Consulting
|
|
- Kelley Floyd
- 5 years ago
- Views:
Transcription
1 Parallelism and Concurrency in C++17 and C++20 Rainer Grimm Training, Coaching and, Technology Consulting
2 Multithreading and Parallelism in C++
3 Multithreading in C++17
4 Parallel STL The execution policy of the STL algorithm can be chosen. Execution policy std::execution::seq Sequential execution on calling thread std::execution::par Parallel std::execution::par_unseq Parallel and vectorized Performed on multiple data at the same time SIMD
5 Parallel STL using namespace std; vector<int> vec ={1, 2, 3, 4, 5... } // static decision sort(vec.begin(), vec.end()); // sequential as ever sort(execution::seq, vec.begin(), vec.end()); // sequential sort(execution::par, vec.begin(), vec.end()); // parallel sort(execution::par_unseq, vec.begin(), vec.end()); // par + vec // dynamic decision size_t threshold=... execution_policy exec = execution::seq; if(vec.size() > threshold) exec = execution::par; sort(exec, vec.begin(), vec.end());
6 Parallel STL adjacent_difference, adjacent_find, all_of any_of, copy, copy_if, copy_n, count, count_if, equal, exclusive_scan, fill, fill_n, find, find_end, find_first_of, find_if, find_if_not, for_each, for_each_n, generate, generate_n, includes, inclusive_scan, inner_product, inplace_merge, is_heap, is_heap_until, is_partitioned, is_sorted, is_sorted_until, lexicographical_compare, max_element, merge, min_element, minmax_element, mismatch, move, none_of, nth_element, partial_sort, partial_sort_copy, partition, partition_copy, reduce, remove, remove_copy, remove_copy_if, remove_if, replace, replace_copy, replace_copy_if, replace_if, reverse, reverse_copy, rotate, rotate_copy, search, search_n, set_difference, set_intersection, set_symmetric_difference, set_union, sort, stable_partition, stable_sort, swap_ranges, transform, transform_exclusive_scan, transform_inclusive_scan, transform_reduce, uninitialized_copy, uninitialized_copy_n, uninitialized_fill, uninitialized_fill_n, unique, unique_copy
7 Parallel STL std::parallel::transform_reduce Haskells map function is called std::transform in C++ parallel::transform_reduce parallel::map_reduce
8 Multithreading in C++20
9 Atomic Smart Pointers C++11 has a std::shared_ptr: Shared ownership std::weak_ptr: Breaks cyclic references Issues: The control block and the deletion of the resource is thread-safe, but not the resource. C++11 has atomic operations for std::shared_ptr. New atomic data types: std::atomic_shared_ptr std::atomic_weak_ptr
10 std::future extensions std::future support no function composition. std::future Improvements Continuation then: Execute the second future, if the first one is done. future<int> f1= async([]() {return 123;}); future<string> f2 = f1.then([](future<int> f) { return f.get().to_string(); // non-blocking }); auto myresult= f2.get(); // blocking
11 std::future extensions when_all: Execute the future when all of the futures are done. future<int> futures[] = { async([]() { return intresult(125); }), async([]() { return intresult(456); })}; future<vector<future<int>>> all_f = when_all(begin(futures), end(futures)); vector<future<int>> myresult= all_f.get(); for (auto fut: myresult): fut.get(); when_any: Execute the future when any of the futures is done. future<int> futures[] = {async([]() { return intresult(125); }), async([]() { return intresult(456); })}; when_any_result<vector<future<int>>> any_f = when_any(begin(futures), end(futures)); future<int>& myresult= any_f.futures[any_f.index]; auto myresult= myresult.get();
12 Latches and Barriers C++ has no semaphores. Latches and barriers Concepts A thread waits eventually at a synchronization point until the counter is 0. latch is a single-use barrier count_down_and_wait: Decrements the counter and block until 0 count_down: Decrements the counter is_ready: Checks the counter wait: Waits until the counter is 0
13 Latches and Barriers barrier is a reusable barrier arrive_and_wait: Waits at the synchronization point. arrive_and_drop: Removes itself from the synchronization set. flex_barrier is a reusable and flexible barrier The constructor can get a callable. The callable will be executed in the completion phase. The callable must return a value which specifies the counter for the next iteration. It's the only barrier that can increase the counter.
14 Latches and Barriers void dowork(threadpool* pool) { latch completion_latch(number_tasks); for (int i = 0; i < NUMBER_TASKS; ++i) { pool->add_task([&] { // perform the work... completion_latch.count_down(); })); } // block until all tasks are done completion_latch.wait(); }
15 Coroutines Coroutines are generalized functions that can suspend and resume execution while keeping their state. Programming concept for Cooperative task Event loops Iterators Infinite lists Pipes
16 Coroutines Design Principles (James McNellis) Scalable, to billions of concurrent coroutines Efficient: Suspend/resume operations comparable in cost to function call overhead Open-Ended: Library designers can develop coroutines libraries Seamless Interaction with existing facilities with no overhead. Usable in environments where exceptions are forbidden or not available.
17 Coroutines: Generators generator<int> generatorfornumbers(int begin, int inc= 1){ for (int i= begin;; i += inc){ co_yield i; } } int main(){ auto numbers= generatorfornumbers(-10); for (int i= 1; i <= 20; ++i) std::cout << numbers << " "; for (auto n: getfornumbers(0,5)) std::cout << n << " "; }
18 Coroutines: Waiting instead of Blocking Blocking Waiting Acceptor accept{443}; Acceptor accept{443}; while (true){ Socket so= accept.accept(); // block auto req= so.read(); // block auto resp= handlerequest(req); so.write(resp); // block } while (true){ Socket soc= co_await accept.accept(); auto req= co_await so.read(); auto resp= handlerequest(req); co_await so.write(resp); }
19 Transactional Memory Transactional Memory is the transaction idea of databases applied to the software development. A transaction has the ACID property excluding Durability atomic{ statement1; statement2; statement3; } Atomicity: All or no statement will be executed. Consistency: The system is always in a consistent state. Isolation: A transaction runs in total isolation. Durability: The result of a committed transaction remains.
20 Transactional Memory Transactions Execute in a single total order Are protected (behave like a global lock) Use optimistic concurrency Locks Workflow Retry Rollback A transaction remembers its initial state. The transaction runs without synchronization. The system detects a conflict with the initial state. The transaction will be committed.
21 Transactional Memory Two forms Synchronized block: Relaxed transactions Are no transactions in the strict sense. Can call transaction-unsafe code Atomic blocks: Atomic transactions Are available in three forms. Can only call transaction-safe code
22 Transactional Memory: Synchronized blocks int i= 0; void inc() { synchronized{ cout << ++i << ","; } } vector<thread> vecsyn(10); for(auto& t: vecsyn) t= thread([]{ for(int n = 0; n < 10; ++n) inc(); });
23 Transactional Memory: Synchronized blocks void inc() { synchronized{ std::cout << ++i << ","; this_thead::sleep_for(1ns); } } vector<thread> vecsyn(10), vecunsyn(10); for(auto& t: vecsyn) t= thread[]{ for(int n = 0; n < 10; ++n) inc(); }); for(auto& t: vecunsyn) t= thread[]{ for(int n = 0; n < 10; ++n) cout << ++i << ","; });
24 Transactional Memory Atomic blocks atomic_<exception_specifier>{ // begin transaction... } // end transaction Exception occurs atomic_noexcept: std::abort is called. atomic_cancel: std::abort is called unless it was a transaction_safe exception. => Cancel the transaction, set the atomic block to is initial state and throw the exception. atomic_commit: Commit the transaction and throw the exception.
25 Transactional Memory: Atomic blocks int i= 0; void func() { atomic_noexcepts{ cout << ++i << ","; // non transaction-safe code } } The transaction can only executed transaction-safe code. Compile time error
26 Transactional memory: transaction_safe A function be be declared transaction_safe have a transaction_unsafe attribute. int transactionsafefunction() transaction_safe; [[transaction_unsafe]] int transactionunsafefunction(); transaction_safe is part of the type of the function.
27 Task Blocks Fork-join parallelism with task blocks.
28 Task Blocks template <typename Func> int traverse(node& n, Func && f){ int left = 0, right = 0; define_task_block( [&](task_block& tb){ if (n.left) tb.run([&]{ left = traverse(*n.left, f); }); if (n.right) tb.run([&]{ right = traverse(*n.right, f); }); } ); return f(n) + left + right; } define_task_block Tasks can potentially run The end of task block joins the tasks run: Runs a task
29 Task Blocks define_task_block_restore_thread... define_task_block([&](auto& tb) tb.run([&]{[] func(); }); define_task_block_restore_thread([&](auto& tb){ tb.run([&]([]{ func2(); }); define_task_block([&](auto& tb){ tb.run([&]{ func3(); } }); }); }); wait define_task_block([&](auto& tb){ tb.run([&]{ process(x1, x2) }); if (x2 == x3) tb.wait(); process(x3, x4); });
30 Multithreading and Parallelism in C++
31 Further Information Modernes C++: Training, coaching, and technology consulting by Rainer Grimm Blog to modern C++ (German) (English)
32 Rainer Grimm Training, Coaching, and Technology Consulting
Concurrency and Parallelism with C++17 and C++20. Rainer Grimm Training, Coaching and, Technology Consulting
Concurrency and Parallelism with C++17 and C++20 Rainer Grimm Training, Coaching and, Technology Consulting www.modernescpp.de Concurrency and Parallelism in C++ Concurrency and Parallelism in C++17 Parallel
More informationMajor Language Changes, pt. 1
C++0x What is C++0x? Updated version of C++ language. Addresses unresolved problems in C++03. Almost completely backwards compatible. Greatly increases expressiveness (and complexity!) of language. Greatly
More informationBoost.Compute. A C++ library for GPU computing. Kyle Lutz
Boost.Compute A C++ library for GPU computing Kyle Lutz GPUs (NVIDIA, AMD, Intel) Multi-core CPUs (Intel, AMD) STL for Parallel Devices Accelerators (Xeon Phi, Adapteva Epiphany) FPGAs (Altera, Xilinx)
More informationWorking Draft, Technical Specification for C++ Extensions for Parallelism, Revision 1
Document Number: N3960 Date: 2014-02-28 Reply to: Jared Hoberock NVIDIA Corporation jhoberock@nvidia.com Working Draft, Technical Specification for C++ Extensions for Parallelism, Revision 1 Note: this
More informationProgramming Languages Technical Specification for C++ Extensions for Parallelism
ISO 05 All rights reserved ISO/IEC JTC SC WG N4409 Date: 05-04-0 ISO/IEC DTS 9570 ISO/IEC JTC SC Secretariat: ANSI Programming Languages Technical Specification for C++ Extensions for Parallelism Warning
More informationC++ - parallelization and synchronization. Jakub Yaghob Martin Kruliš
C++ - parallelization and synchronization Jakub Yaghob Martin Kruliš The problem Race conditions Separate threads with shared state Result of computation depends on OS scheduling Race conditions simple
More informationC++ - parallelization and synchronization. David Bednárek Jakub Yaghob Filip Zavoral
C++ - parallelization and synchronization David Bednárek Jakub Yaghob Filip Zavoral The problem Race conditions Separate threads with shared state Result of computation depends on OS scheduling Race conditions
More informationParallelism in C++ J. Daniel Garcia. Universidad Carlos III de Madrid. November 23, 2018
J. Daniel Garcia Universidad Carlos III de Madrid November 23, 2018 cbea J. Daniel Garcia ARCOS@UC3M (josedaniel.garcia@uc3m.es) 1/58 Introduction to generic programming 1 Introduction to generic programming
More informationTo use various types of iterators with the STL algorithms ( ). To use Boolean functions to specify criteria for STL algorithms ( 23.8).
CHAPTER 23 STL Algorithms Objectives To use various types of iterators with the STL algorithms ( 23.1 23.20). To discover the four types of STL algorithms: nonmodifying algorithms, modifying algorithms,
More informationParallel Programming with OpenMP and Modern C++ Alternatives
Parallel Programming with OpenMP and Modern C++ Alternatives Michael F. Hava and Bernhard M. Gruber RISC Software GmbH Softwarepark 35, 4232 Hagenberg, Austria RISC Software GmbH Johannes Kepler University
More informationLecture 21 Standard Template Library. A simple, but very limited, view of STL is the generality that using template functions provides.
Lecture 21 Standard Template Library STL: At a C++ standards meeting in 1994, the committee voted to adopt a proposal by Alex Stepanov of Hewlett-Packard Laboratories to include, as part of the standard
More informationC++ Standard Template Library
C++ Standard Template Library CS 247: Software Engineering Principles Generic Algorithms A collection of useful, typesafe, generic (i.e., type-parameterized) containers that - know (almost) nothing about
More informationFunctors. Cristian Cibils
Functors Cristian Cibils (ccibils@stanford.edu) Administrivia You should have Evil Hangman feedback on paperless. If it is there, you received credit Functors Let's say that we needed to find the number
More informationScientific programming (in C++)
Scientific programming (in C++) F. Giacomini INFN-CNAF School on Open Science Cloud Perugia, June 2017 https://baltig.infn.it/giaco/201706_perugia_cpp What is C++ C++ is a programming language that is:
More informationParallelism in C++ Higher-level Parallelization in C++ for Asynchronous Task-Based Programming. Hartmut Kaiser
Parallelism in C++ Higher-level Parallelization in C++ for Asynchronous Task-Based Programming Hartmut Kaiser (hartmut.kaiser@gmail.com) State of the Art Modern architectures impose massive challenges
More informationDistributed Real-Time Control Systems. Lecture 16 C++ Libraries Templates
Distributed Real-Time Control Systems Lecture 16 C++ Libraries Templates 1 C++ Libraries One of the greatest advantages of C++ is to facilitate code reuse. If code is well organized and documented into
More informationGeneric Programming with JGL 4
Generic Programming with JGL 4 By John Lammers Recursion Software, Inc. July 2004 TABLE OF CONTENTS Abstract...1 Introduction to Generic Programming...1 How does Java support generic programming?...2 The
More informationNew Iterator Concepts
New Iterator Concepts Author: David Abrahams, Jeremy Siek, Thomas Witt Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@styleadvisor.com Organization: Boost Consulting, Indiana University Open
More informationData_Structures - Hackveda
Data_Structures - Hackveda ( Talk to Live Mentor) Become a Data Structure and Algorithm Professional - (Beginner - Advanced) Skill level: Beginner - Advanced Training fee: INR 15999 only (Topics covered:
More informationC and C++ Courses. C Language
C Language The "C" Language is currently one of the most widely used programming languages. Designed as a tool for creating operating systems (with its help the first Unix systems were constructed) it
More informationTransactional Memory in C++ Hans-J. Boehm. Google and ISO C++ Concurrency Study Group chair ISO C++ Transactional Memory Study Group participant
Transactional Memory in C++ Hans-J. Boehm Google and ISO C++ Concurrency Study Group chair ISO C++ Transactional Memory Study Group participant 1 Disclaimers I ve been writing concurrent programs for decades,
More informationASYNCHRONOUS COMPUTING IN C++
http://stellar-goup.org ASYNCHRONOUS COMPUTING IN C++ Hartmut Kaiser (Hartmut.Kaiser@gmail.com) CppCon 2014 WHAT IS ASYNCHRONOUS COMPUTING? Spawning off some work without immediately waiting for the work
More informationImprovements to std::future<t> and Related APIs
Document number: Supersedes: Date: Reply-to: N3784 N3721 2013-09-27 Niklas Gustafsson < niklas.gustafsson@microsoft.com> Artur Laksberg < arturl@microsoft.com> Herb Sutter < hsutter@microsoft.com> Sana
More informationThe C++ Memory Model. Rainer Grimm Training, Coaching and Technology Consulting
The C++ Memory Model Rainer Grimm Training, Coaching and Technology Consulting www.grimm-jaud.de Multithreading with C++ C++'s answers to the requirements of the multicore architectures. A well defined
More informationBigger Better More. The new C++ Standard Library. Thomas Witt April Copyright 2009 Thomas Witt
Bigger Better More The new C++ Standard Library Thomas Witt April 24 2009 Landscape C99 (2003) Technical Report on C++ Library Extensions (TR1) Jan 2006 Committee Draft (CD) Oct 2008 C++ 0x TR2.NET, Java,
More informationA Standardized Representation of Asynchronous Operations
Document number: N3428=12-0118. Date: 2012-09-21 Reply-to: Niklas Gustafsson < niklas.gustafsson@microsoft.com> Artur Laksberg < arturl@microsoft.com> Herb Sutter < hsutter@microsoft.com> Sana Mithani
More informationMODULE 37 --THE STL-- ALGORITHM PART V
MODULE 37 --THE STL-- ALGORITHM PART V My Training Period: hours Note: Compiled using Microsoft Visual C++.Net, win32 empty console mode application. g++ compilation example is given at the end of this
More informationContents. 2 Introduction to C++ Programming,
cppfp2_toc.fm Page vii Thursday, February 14, 2013 9:33 AM Chapter 24 and Appendices F K are PDF documents posted online at www.informit.com/title/9780133439854 Preface xix 1 Introduction 1 1.1 Introduction
More informationDeitel Series Page How To Program Series
Deitel Series Page How To Program Series Android How to Program C How to Program, 7/E C++ How to Program, 9/E C++ How to Program, Late Objects Version, 7/E Java How to Program, 9/E Java How to Program,
More informationA Parallel Algorithms Library N3724
A Parallel Algorithms Library N3724 Jared Hoberock Jaydeep Marathe Michael Garland Olivier Giroux Vinod Grover {jhoberock, jmarathe, mgarland, ogiroux, vgrover}@nvidia.com Artur Laksberg Herb Sutter {arturl,
More informationEfficient C++ Programming and Memory Management
Efficient C++ Programming and Memory Management F. Giacomini INFN-CNAF ESC 17 Bertinoro, 22-28 October 2017 https://baltig.infn.it/giaco/cpp-memory-esc17 Outline Introduction Type deduction Function, function
More informationA Standardized Representation of Asynchronous Operations
Document number: Supersedes: Date: Reply-to: N3558 N3428=12-0118 March 15 th 2013 Niklas Gustafsson < niklas.gustafsson@microsoft.com> Artur Laksberg < arturl@microsoft.com> Herb Sutter < hsutter@microsoft.com>
More informationImprovements to std::future<t> and Related APIs
Document number: Supersedes: Date: Reply-to: N3634 N3558 2013-05-02 Niklas Gustafsson < niklas.gustafsson@microsoft.com> Artur Laksberg < arturl@microsoft.com> Herb Sutter < hsutter@microsoft.com> Sana
More informationTHE STANDARD TEMPLATE LIBRARY (STL) Week 6 BITE 1513 Computer Game Programming
THE STANDARD TEMPLATE LIBRARY (STL) Week 6 BITE 1513 Computer Game Programming What the heck is STL???? Another hard to understand and lazy to implement stuff? Standard Template Library The standard template
More informationWorking Draft, Technical Specification for C++ Extensions for Parallelism
Document Number: N3850 Date: 2014-01-17 Reply to: Jared Hoberock NVIDIA Corporation jhoberock@nvidia.com Working Draft, Technical Specification for C++ Extensions for Parallelism Note: this is an early
More informationawait/yield: C++ coroutines Zbigniew Skowron 30 November 2016
await/yield: C++ coroutines Zbigniew Skowron 30 November 2016 Agenda Current status Overview and motivation Stackful vs. stackless Coroutines as generators Coroutines instead of callbacks Awaitable types
More informationFoundations of Programming, Volume I, Linear structures
Plan 1. Machine model. Objects. Values. Assignment, swap, move. 2. Introductory algorithms: advance, distance, find, copy. Iterators: operations, properties, classification. Ranges and their validity.
More informationHPX The C++ Standards Library for Concurrency and Parallelism. Hartmut Kaiser
HPX The C++ Standards Library for Concurrency and Hartmut Kaiser (hkaiser@cct.lsu.edu) HPX A General Purpose Runtime System The C++ Standards Library for Concurrency and Exposes a coherent and uniform,
More informationTemplates and Vectors
Templates and Vectors 1 Generic Programming function templates class templates 2 the STL vector class a vector of strings enumerating elements with an iterator inserting and erasing 3 Writing our own vector
More informationNational Body Comments ISO/IEC PDTS Technical Specification: C++ Extensions for Concurrency
Document No: WG21 N4551 Date: 2015-08-13 References: ISO/IEC PDTS 19571 Reply To: Barry Hedquist INCITS/PL22.16 IR National Body Comments ISO/IEC PDTS 19571 Technical Specification: C++
More informationCOPYRIGHTED MATERIAL. Index SYMBOLS. Index
Index Index SYMBOLS &= (ampersand, equal) operator, 8 & (ampersand) operator, 8 \ (backslash) escape character, 4 ^= (caret, equal) operator, 9 ^ (caret) operator, 9 \r (carriage return) escape character,
More informationLecture on pointers, references, and arrays and vectors
Lecture on pointers, references, and arrays and vectors pointers for example, check out: http://www.programiz.com/cpp-programming/pointers [the following text is an excerpt of this website] #include
More informationSynchronization SPL/2010 SPL/20 1
Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization
More informationMODULE 35 --THE STL-- ALGORITHM PART III
MODULE 35 --THE STL-- ALGORITHM PART III My Training Period: hours Note: Compiled using Microsoft Visual C++.Net, win32 empty console mode application. g++ compilation example is given at the end of this
More informationThe Cut and Thrust of CUDA
The Cut and Thrust of CUDA Luke Hodkinson Center for Astrophysics and Supercomputing Swinburne University of Technology Melbourne, Hawthorn 32000, Australia May 16, 2013 Luke Hodkinson The Cut and Thrust
More informationMore STL algorithms (revision 2)
Doc No: N2666=08-0176 Reply to: Matt Austern Date: 2008-06-11 More STL algorithms (revision 2) This paper proposes a number of nonstandard STL-style algorithms for inclusion in the
More informationC++ How To Program 10 th Edition. Table of Contents
C++ How To Program 10 th Edition Table of Contents Preface xxiii Before You Begin xxxix 1 Introduction to Computers and C++ 1 1.1 Introduction 1.2 Computers and the Internet in Industry and Research 1.3
More informationMODULE 33 --THE STL-- ALGORITHM PART I
MODULE 33 --THE STL-- ALGORITHM PART I My Training Period: hours Note: Compiled using Microsoft Visual C++.Net, win32 empty console mode application. g++ compilation examples given at the end of this Module.
More informationI/O and STL Algorithms
CS193D Handout 21 Winter 2005/2006 February 29, 2006 I/O and STL Algorithms See also: Chapter 14, Chapter 22 I/O and STL Algorithms CS193D, 2/29/06 1 Raw Input and Output ostream::put(char ch); ostream::write(const
More informationHomework 4. Any questions?
CSE333 SECTION 8 Homework 4 Any questions? STL Standard Template Library Has many pre-build container classes STL containers store by value, not by reference Should try to use this as much as possible
More informationGJL: The Generic Java Library
GJL: The Generic Java Library An STL for Java Winter 1999 Semester Project Laboratoire des Méthodes de Programmation Ecole Polytechnique Fédérale de Lausanne Corine Hari February 2000 Table of Contents
More informationusing namespace std; //Standard classes are in namspace std //Don't add "using namespace" in header files, only in source files
System headers #include //For cin & cout #include //For vector #include //For list #include //For map #include //For shared_ptr #include //For thread
More informationHPX A GENERAL PURPOSE C++ RUNTIME SYSTEM FOR PARALLEL AND DISTRIBUTED APPLICATIONS OF ANY SCALE
HPX A GENERAL PURPOSE C++ RUNTIME SYSTEM FOR PARALLEL AND DISTRIBUTED APPLICATIONS OF ANY SCALE The Venture Point TECHNOLOGY DEMANDS NEW RESPONSE 2 Technology Demands new Response 3 Technology Demands
More informationCSE 333 Lecture smart pointers
CSE 333 Lecture 14 -- smart pointers Hal Perkins Department of Computer Science & Engineering University of Washington Administrivia Midterm Friday - Review in sections this week - Closed book; topic list
More informationChapters and Appendices F J are PDF documents posted online at the book s Companion Website, which is accessible from.
Contents Chapters 23 26 and Appendices F J are PDF documents posted online at the book s Companion Website, which is accessible from http://www.pearsonhighered.com/deitel See the inside front cover for
More informationSoftware Transactional Memory Pure functional approach
Software Transactional Memory Pure functional approach Alexander Granin graninas@gmail.com C++ Russia 2018, Saint Petersburg struct Presentation Introduction1 Functional programming in C++ Introduction2
More informationParallel STL in today s SYCL Ruymán Reyes
Parallel STL in today s SYCL Ruymán Reyes ruyman@codeplay.com Codeplay Research 15 th November, 2016 Outline 1 Parallelism TS 2 The SYCL parallel STL 3 Heterogeneous Execution with Parallel STL 4 Conclusions
More informationPlain Threads are the GOTO of Today s Computing
Plain Threads are the GOTO of Today s Computing Plain Threads Considered Harmful Hartmut Kaiser (Hartmut.Kaiser@gmail.com) GOTO Considered Harmful Edsger Dijkstra (1968): 2 Plain Threads Considered Harmful
More informationCSE 333 Lecture smart pointers
CSE 333 Lecture 14 -- smart pointers Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington Administrivia New exercise out today, due Wednesday morning Exam Friday
More informationContribution:javaMultithreading Multithreading Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team
http://101companies.org/wiki/ Contribution:javaMultithreading Multithreading Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team Non-101samples available here: https://github.com/101companies/101repo/tree/master/technologies/java_platform/samples/javathreadssamples
More informationItem 3: Predicates, Part 2: Matters of State
ITEM1_11new.fm Page 1 Tuesday, November 27, 2001 12:41 PM Item 3: Predicates, Part 2: Matters of State ITEM 3: PREDICATES, PART 2: MATTERS OF STATE DIFFICULTY: 7 Following up from the introduction given
More informationExercise 6.2 A generic container class
Exercise 6.2 A generic container class The goal of this exercise is to write a class Array that mimics the behavior of a C++ array, but provides more intelligent memory management a) Start with the input
More informationSupporting async use-cases for interrupt_token
Document No. P1287R0 Date 2018-10-08 Reply To Audience Lewis Baker < lbaker@fb.com > Kirk Shoop < kirkshoop@fb.com > SG1, LEWG Supporting async use-cases for interrupt_token Abstract The jthread paper
More informationFunction Templates. Consider the following function:
Function Templates Consider the following function: void swap (int& a, int& b) { int tmp = a; a = b; b = tmp; Swapping integers. This function let's you swap the contents of two integer variables. But
More informationThreads Questions Important Questions
Threads Questions Important Questions https://dzone.com/articles/threads-top-80-interview https://www.journaldev.com/1162/java-multithreading-concurrency-interviewquestions-answers https://www.javatpoint.com/java-multithreading-interview-questions
More informationIntroduction to C++11 and its use inside Qt
Introduction to C++11 and its use inside Qt Olivier Goffart February 2013 1/43 Introduction to C++11 and its use inside Qt About Me http://woboq.com http://code.woboq.org 2/43 Introduction to C++11 and
More informationThe Standard Template Library. EECS 211 Winter 2018
The Standard Template Library EECS 211 Winter 2018 2 Problem: finding the maximum element of a vector A simple fixed-size vector struct: struct Int_vec int* data; size_t size; ; 3 Solution: max_int_vec
More informationTemplates & the STL. CS 2308 :: Fall 2015 Molly O'Neil
Templates & the STL CS 2308 :: Fall 2015 Molly O'Neil Function Templates Let's say we have a program that repeatedly needs to find the maximum value in an array In one place in our code, we need the max
More informationApply the following edits to N4741, the working draft of the Standard. The feature test macros cpp_lib_latch and cpp_lib_barrier should be created.
Doc number: P0666R2 Revises: P0666R1, P0159R0, N4392 Date: 2018-05-06 Project: Programming Language C++, Concurrency Working Group Reply-to: Olivier Giroux Revised Latches and Barriers
More informationBetter Code: Concurrency Sean Parent Principal Scientist Adobe Systems Incorporated. All Rights Reserved.
Better Code: Concurrency Sean Parent Principal Scientist 2014 Adobe Systems Incorporated All Rights Reserved Better Code! Regular Type! Goal: Implement Complete and Efficient Types! Algorithms! Goal: No
More informationasynchronous programming with allocation aware futures /Naios/continuable Denis Blank Meeting C
Continuable asynchronous programming with allocation aware futures /Naios/continuable Denis Blank Meeting C++ 2018 Introduction About me Denis Blank Master s student @Technical
More informationFelix Petriconi
Prepared for code::dive 2018 c 2018 2018-11-07 1 / 90 Started with C++ 1994 Programmer and development manager since 2003 at MeVis Medical Solutions AG, Bremen, Germany Programming activities: Blog editor
More informationCSE 333 Lecture smart pointers
CSE 333 Lecture 13 -- smart pointers Steve Gribble Department of Computer Science & Engineering University of Washington Administrivia HW2 is due on Thursday! - check out the discussion board for a few
More informationWhat is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?
What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular
More informationExpansion statements. Version history. Introduction. Basic usage
Expansion statements Version history Document: P1306R0 Revises: P0589R0 Date: 08 10 2018 Audience: EWG Authors: Andrew Sutton (asutton@uakron.edu) Sam Goodrick (sgoodrick@lock3software.com) Daveed Vandevoorde
More informationBetter Code: Concurrency Sean Parent Principal Scientist Adobe Systems Incorporated. All Rights Reserved.
Better Code: Concurrency Sean Parent Principal Scientist 2014 Adobe Systems Incorporated All Rights Reserved Better Code! Regular Type! Goal: Implement Complete and Efficient Types! Algorithms! Goal: No
More informationCSE 160 Lecture 7. C++11 threads C++11 memory model
CSE 160 Lecture 7 C++11 threads C++11 memory model Today s lecture C++ threads The C++11 Memory model 2013 Scott B. Baden / CSE 160 / Winter 2013 2 C++11 Threads Via , C++ supports a threading
More informationC++ Programming Lecture 11 Software Engineering Group
C++ Programming Lecture 11 Software Engineering Group Philipp D. Schubert Contents 1. High performance computing 2. High performance computing in C++ 1. std::thread 2. std::future 3. std::async 4. std::future
More informationCOEN244: Class & function templates
COEN244: Class & function templates Aishy Amer Electrical & Computer Engineering Templates Function Templates Class Templates Outline Templates and inheritance Introduction to C++ Standard Template Library
More informationIntroduction to GIL, Boost and Generic Programming
Introduction to GIL, Boost and Generic Programming Hailin Jin Advanced Technology Labs Adobe Systems Incorporated http://www.adobe.com/technology/people/sanjose/jin.html 1 Outline GIL Boost Generic programming
More informationNVIDIA Think about Computing as Heterogeneous One Leo Liao, 1/29/2106, NTU
NVIDIA Think about Computing as Heterogeneous One Leo Liao, 1/29/2106, NTU GPGPU opens the door for co-design HPC, moreover middleware-support embedded system designs to harness the power of GPUaccelerated
More informationHeckaton. SQL Server's Memory Optimized OLTP Engine
Heckaton SQL Server's Memory Optimized OLTP Engine Agenda Introduction to Hekaton Design Consideration High Level Architecture Storage and Indexing Query Processing Transaction Management Transaction Durability
More informationDistributed Programming
Distributed Programming Lecture 02 - Processes, Threads and Synchronization Edirlei Soares de Lima Programs and Processes What is a computer program? Is a sequence
More informationRevised Latches and Barriers for C++20
Doc number: P0666R1 Revises: P0666R1, P0159R0, N4392 Date: 2018-02-11 Project: Programming Language C++, Concurrency Working Group Reply-to: Olivier Giroux Revised Latches and Barriers
More informationMore STL algorithms. Design Decisions. Doc No: N2569= Reply to: Matt Austern Date:
Doc No: N2569=08-0079 Reply to: Matt Austern Date: 2008-02-29 More STL algorithms This paper proposes a number of nonstandard STL-style algorithms for inclusion in the standard. Nothing
More informationProgramming at Compile Time. Rainer Grimm Training, Coaching, and Technology Consulting
Programming at Compile Time Rainer Grimm Training, Coaching, and Technology Consulting www.modernescpp.de Overview Constant expressions Type-traits library Template metaprogramming Template Metaprogramming
More informationUnit 1: Preliminaries Part 4: Introduction to the Standard Template Library
Unit 1: Preliminaries Part 4: Introduction to the Standard Template Library Engineering 4892: Data Structures Faculty of Engineering & Applied Science Memorial University of Newfoundland May 6, 2010 ENGI
More informationWhat will happen if we try to compile, link and run this program? Do you have any comments to the code?
1 # include < iostream > 2 3 int main () 4 { 5 std :: cout
More informationProgramming at Compile Time. Rainer Grimm Training, Coaching, and Technology Consulting
Programming at Compile Time Rainer Grimm Training, Coaching, and Technology Consulting www.modernescpp.de Overview Constant expressions Type-traits library Template metaprogramming Template Metaprogramming
More informationCOMP3151/9151 Foundations of Concurrency Lecture 8
1 COMP3151/9151 Foundations of Concurrency Lecture 8 Transactional Memory Liam O Connor CSE, UNSW (and data61) 8 Sept 2017 2 The Problem with Locks Problem Write a procedure to transfer money from one
More informationHigh-Productivity CUDA Development with the Thrust Template Library. San Jose Convention Center September 23 rd 2010 Nathan Bell (NVIDIA Research)
High-Productivity CUDA Development with the Thrust Template Library San Jose Convention Center September 23 rd 2010 Nathan Bell (NVIDIA Research) Diving In #include #include
More informationCS4961 Parallel Programming. Lecture 12: Advanced Synchronization (Pthreads) 10/4/11. Administrative. Mary Hall October 4, 2011
CS4961 Parallel Programming Lecture 12: Advanced Synchronization (Pthreads) Mary Hall October 4, 2011 Administrative Thursday s class Meet in WEB L130 to go over programming assignment Midterm on Thursday
More informationApril 4-7, 2016 Silicon Valley. ADVANCED THRUST PROGRAMMING WITH EXECUTION POLICIES Steven Dalton, April 6th
April 4-7, 2016 Silicon Valley ADVANCED THRUST PROGRAMMING WITH EXECUTION POLICIES Steven Dalton, April 6th Execution-policies are: PITCH Extremely important and a core design feature of Thrust Not well-understood
More informationLecture 8: September 30
CMPSCI 377 Operating Systems Fall 2013 Lecture 8: September 30 Lecturer: Prashant Shenoy Scribe: Armand Halbert 8.1 Semaphores A semaphore is a more generalized form of a lock that can be used to regulate
More informationWRITING DATA PARALLEL ALGORITHMS ON GPUs
WRITING DATA PARALLEL ALGORITHMS ON GPUs WITH C++ AMP Ade Miller Technical Director, CenturyLink Cloud. ABSTRACT TODAY MOST PCS, TABLETS AND PHONES SUPPORT MULTI-CORE PROCESSORS AND MOST PROGRAMMERS HAVE
More informationCPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.
CPSC/ECE 3220 Fall 2017 Exam 1 Name: 1. Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.) Referee / Illusionist / Glue. Circle only one of R, I, or G.
More informationConcurrent & Distributed Systems Supervision Exercises
Concurrent & Distributed Systems Supervision Exercises Stephen Kell Stephen.Kell@cl.cam.ac.uk November 9, 2009 These exercises are intended to cover all the main points of understanding in the lecture
More informationMultiple Inheritance. Computer object can be viewed as
Multiple Inheritance We have seen that a class may be derived from a given parent class. It is sometimes useful to allow a class to be derived from more than one parent, inheriting members of all parents.
More informationThreads and Parallelism in Java
Threads and Parallelism in Java Java is one of the few main stream programming languages to explicitly provide for user-programmed parallelism in the form of threads. A Java programmer may organize a program
More informationUsing SYCL as an Implementation Framework for HPX.Compute
Using SYCL as an Implementation Framework for HPX.Compute Marcin Copik 1 Hartmut Kaiser 2 1 RWTH Aachen University mcopik@gmail.com 2 Louisiana State University Center for Computation and Technology The
More information