Working with Asynchrony Generically: A Tour of C++ Executors (part 1/2) - Eric Niebler - CppCon 21

Sdílet
Vložit
  • čas přidán 15. 11. 2021
  • cppcon.org/
    github.com/CppCon/CppCon2020
    ---
    Asynchrony is increasingly important across the software industry, yet C++ lacks a standard async programming model or a comprehensive set of asynchronous algorithms. In this talk, Eric will describe the approach to asynchrony taken by standard Executors, currently targeting C++23. This talk with focus on how to use the new facilities, with glimpses under the covers to see how things work.
    "Asynchrony" means many things. It means concurrency (e.g., thread pools) and parallelism (e.g., GPUs). It means parameterizing a computation on where it should execute. It means the ability to chain work, propagating values and errors to user-specified continuations. It means forking and joining async control flow without blocking. It requires guarantees that async work can make forward progress. It means a standard way to request that a computation stop early, and a way to propagate the "I have now stopped" notification back to the caller. And -- since this is C++ -- it means doing all that with bare-metal performance and seamless integration with C++20 coroutines.
    The async programming model espoused by the recent standard Executors papers satisfies these constraints while also enabling a full suite of Generic asynchronous algorithms. C++23 will likely come with algorithms such as `then` for chaining work, `timeout` and `stop_when` for cancelling work after certain criteria are met, `when_all` for launching concurrent work and joining (without blocking), and `sync_wait` for blocking until work has finished.
    The core abstraction of the Executors design, known as "Sender/Receiver", is to asynchronous algorithms what the STL's "Iterator" abstraction is to sequence algorithms: an enabling abstraction that makes reusable algorithms possible. With the containers and algorithms of the STL, the C++ Standard Library took a giant step forward in power and reusability. With C++23 Executors, the Standard Library takes the next step.
    ---
    Eric Niebler
    Eric is a long-time member of the ISO C++ Standardization Committee, and is probably best known for his work bringing ranges support to the C++20 Standard Library. He specializes in modern C++ library design, authoring several Boost libraries and the popular range-v3 library for computing with ranges and range pipelines. He currently works at NVIDIA where he is trying to build abstractions for asynchrony that are fit for standardization.
    ---
    Videos Recorded & Edited by Digital Medium: online.digital-medium.co.uk
    Register Now For CppCon 2022: cppcon.org/registration/
  • Věda a technologie

Komentáře • 44

  • @YourCRTube
    @YourCRTube Před 2 lety +22

    I am tracking this for the past few years and I like it quite a lot, mainly because its heavy abstraction. That said, I am afraid the API, much like coroutines ones, is not clear as it should be.
    Calling something `set_done` does not imply cancelation. Canceled work is never done, by definition.

    • @technik27
      @technik27 Před 2 lety +10

      I think that´s a sublety of the English language. I see it as when someone says ¨I am done eating burgers¨, not because they ate all the burgers, but because they´re not going to continue doing it. And I completely agree the syntax´s legibility should not be leaning on things like that. ¨done¨ should be reserved for things that are actually executed.

    • @EricNiebler
      @EricNiebler Před 2 lety +8

      In the last draft of the proposal, set_done has been renamed to set_stopped.

    • @think2086
      @think2086 Před rokem

      @@EricNiebler I don’t get why it’s set_ anything. Nothing is being set. Should be ‘cancel,’ or something. The other two are about setting something but this one is not. So having consistent naming seems anti-expressive: it’s a different kind of thing.

    • @theintjengineer
      @theintjengineer Před rokem +1

      @@think2086, if you think of it in the context it belongs, it actually makes sense; it's setting something, namely the state; setting it to cancelled/stopped, or however you may think of it as. Of course they could have defined it as something like `set_state(notification_type)` and have the operation state defines its status and pass it to `set_state()`. But I'd say their implementation is simpler, if you think of it in the corresponding context.
      In C++ we often have to rely on the context to understand the naming ahah. Remember RAII? Another one that isn't thaaaat expressive if you don't dive deep into the context.

    • @EricNiebler
      @EricNiebler Před rokem +3

      @@theintjengineer Exactly. A receiver is not dissimilar to a std::promise, which also receives the results of an asynchronous operation. It's members are called set_value and set_exception. We're hewing to existing practice.

  • @TheOnlyAndreySotnikov
    @TheOnlyAndreySotnikov Před 2 lety +24

    At last, NVIDIA will have a C++ professional. When I was there, the word "template" invoked primordial fear, I got berated for using a bad library "boost", and senior engineers were convincing me that C++ programs must be simple C-like procedural style, otherwise there could be a person who may not understand it.

    • @technik27
      @technik27 Před 2 lety +1

      I been in a lot of places like that, even with people that were brilliant otherwise. I feel you man.

    • @llothar68
      @llothar68 Před 2 lety +7

      And i think they are very right about this. The last thing you want to have in a company are this übersmart people who write code that even they don't get anymore after a while.
      C++ must be simple. Normal developer, aka all your business code writers, shouldn't require to write templates. Thats library only. And with GPU barebone especially.

    • @embeddor2230
      @embeddor2230 Před 2 lety +1

      I've the same problem in my embedded systems company. The word "C++" is always met with blind refusal.

    • @pesto801
      @pesto801 Před 2 lety +2

      NVidia has both Eric and Bryce who are very heavily involved in standardization. Bryce's mentor is a praiser of Generic Programming therefore I am pretty sure they took a turn on that.

    • @skaniskin
      @skaniskin Před 2 lety +1

      Isn't it a general situation? Google seems to have a similar style guide

  • @isitanos
    @isitanos Před rokem +2

    Good speaker, good presentation. The onion part was a bit abstract and could've done with better labeling.

  • @ruslangabitov5202
    @ruslangabitov5202 Před 2 lety

    Great idea and it's presentation.

  • @Versachiful
    @Versachiful Před 2 lety

    When will the other lectures be uploaded?

    • @CppCon
      @CppCon  Před 2 lety +1

      Lectures are currently available here: pages.jetbrains.com/cppcon2021
      Videos will be publicly available on this channel from the 15th. Dec.. They will be released incrementally.

  • @Quazgaa
    @Quazgaa Před 2 lety +2

    member when cppcon used to post videos to the internet? that was pretty dope

    • @CppCon
      @CppCon  Před 2 lety +2

      Lectures are currently available here: pages.jetbrains.com/cppcon2021
      Videos will gradually become publicly available on this channel from the 15th. Dec. 2021

    • @encapsulatio
      @encapsulatio Před 2 lety +1

      @@CppCon What about part 2 of this talk?

  • @shahzodadavlatova7203

    what do you mean by 0 allocations? 9:20
    a thread pool was created.

    • @EricNiebler
      @EricNiebler Před rokem +1

      I mean dynamic memory allocations, like calls to `new` and `malloc`. You're right, it's creating threads.

  • @puyadaravi3109
    @puyadaravi3109 Před 2 lety +1

    One of the recent CPPCast episodes with Bryce goes over the history. I guess Bryce convinced Eric to join NVIDIA :)

  • @4otko999
    @4otko999 Před 2 lety

    void set_done() && noexcept
    What && means here?

    • @quanzhou4608
      @quanzhou4608 Před 2 lety

      rvalue version when you call this function, I think

    • @mm1979dk
      @mm1979dk Před 2 lety

      it means that this method overload is applicable when the object is an r-value (reference).

    • @ayrendraganas8686
      @ayrendraganas8686 Před 2 lety

      its a ref qualifier. its for member functiond. In this case it specifies that the function can only be invoked on an rvalue
      the same thing exists for lvalues; the corresponding function signature (building on your example) would be
      void set_done() & noexcept

  • @rinket7779
    @rinket7779 Před 2 lety +1

    is this in c++23?

  • @yotty97
    @yotty97 Před 2 lety +1

    Is this going into c++23 ?

  • @zakeria
    @zakeria Před 2 lety +1

    Generic programming >>>

  • @mm1979dk
    @mm1979dk Před 2 lety +9

    18:03 "and this is the control flow" -- no it's not, it's actually a horrible drawing.
    Why can't we use something that at least resembles control flow chart? or message sequence chart?

  • @ZarviroffSerge
    @ZarviroffSerge Před 2 lety +22

    Why do all these speakers use trash (probably built-in) mikes? Is the salary at nvidia (ms, amd, facebook, etc.) that bad that its employee can't afford a decent one? I don't want to offend anyone (or rather trigger, because people will get defensive over this comment), but all these post-covid talks are at best tolerable. You'd only sit through one if you really, really need too. Not the first post-covid online conference too.

    • @technik27
      @technik27 Před 2 lety +1

      It´s usually just because giving public presentations from is not a common thing for most people. You´re not going to go into the trouble of researching what a good mike is, and spending money on it, for a one off thing.

    • @EricNiebler
      @EricNiebler Před 2 lety +12

      Sorry for the trash mic! I actually have a very good mic, but I couldn't get Windows to recognize it. By the time I figured out my good mic wasn't going to work, it was too late to come up with another plan.

    • @mikehebert5489
      @mikehebert5489 Před 2 lety +1

      I’ve seen some talks where a nice mic is clearly visible but the audio is still muddy. I think most of the issue is the network, and these videos are basically just screen caps of what you would’ve seen live rather than getting the raw recorded audio from the presenters.

    • @ayrendraganas8686
      @ayrendraganas8686 Před 2 lety +3

      maybe they should use rtx voice :^)

  •  Před 2 lety

    For "algorithm" you mean function.

    • @ayrendraganas8686
      @ayrendraganas8686 Před 2 lety

      its a whole construct consiting of multiple functions and possibly data types

  • @ABaumstumpf
    @ABaumstumpf Před 2 lety +2

    It really seems like the people proposing to C++ are intentionally choosing bad names and counter-intuitive concepts. The code-examples for this proposal are not much better to read then a program written in assembly.