C++ and Beyond 2012: Herb Sutter - atomic Weapons 1 of 2

Поділитися
Вставка
  • Опубліковано 26 гру 2024

КОМЕНТАРІ •

  • @AAA-tc1uh
    @AAA-tc1uh Рік тому +7

    What an excellent talk... by now I've seen quite a few on the subject, and read many articles but this is crystal clear, from the ground up. Watch this before anything else.

  • @brewtaldeafmedal1262
    @brewtaldeafmedal1262 10 місяців тому +5

    This talk cured my cancer

  • @abhi4unme2002
    @abhi4unme2002 6 років тому +18

    This explains it clearly . Glad you uploaded this video.

  • @flyingsquirrel3271
    @flyingsquirrel3271 4 роки тому +6

    Phenomenal talk!

  • @rsjsdqps7363
    @rsjsdqps7363 Рік тому

    absolutely fantastic

  • @saultube44
    @saultube44 4 роки тому +2

    Herb thank you so much for the slides

  • @flocela
    @flocela Рік тому

    "okay, let's not get pathological, which is I know what we like to do" - LOL

  • @robrick9361
    @robrick9361 7 років тому +1

    Super helpful thanks for posting.

  • @hanyanglee9018
    @hanyanglee9018 2 роки тому

    25:20 Yeah, this reminds me of the course of CMU 15-213. I really recommend it.

  • @prankurhauhan
    @prankurhauhan 23 дні тому

    Hi Mr. Sutter,
    On the last slide with fences.
    You mentioned g=1 and x=g , cannot be moved across fence.
    But the same is true for e.g if you use a mutex to lock global=temp.
    I don't see much difference there in terms of your argument about pessimization.
    Even though I admit in case of mutex the g=1 and x=g can be moved inside critical section and then x=1 can be done. Will this really be done by the compiler ?
    Regards

  • @AdityaKumar-h8b4o
    @AdityaKumar-h8b4o 2 місяці тому

    at 1:18:10 if 'y' is a local variable it can be optimized for sure.

  • @seditt5146
    @seditt5146 5 років тому +8

    It is crazy as hell this only has 6151k views, Chernos videos get many many many times this and yet are not nearly as valuable. Not saying they are bad videos it is just that Thread programming is becoming a necessary Evil that not many are good at and if those people want to do graphics programming with good performance they should really learn what in this video. Thanks for the Upload I love this and have seen in many times.

    • @movax20h
      @movax20h 4 роки тому +1

      You don't need atomics all to write multi threading code.

    • @seditt5146
      @seditt5146 4 роки тому

      @@movax20h Who told you such nonsense? Sure you don't need them, you are perfectly allowed to make shitty buggy code.

    • @movax20h
      @movax20h 4 роки тому +3

      @@seditt5146 I think you have no idea what you are talking about. I am writing high performance multithreaded codes (mostly servers and databases), for 18 years, and I never used an atomic in them. (I had some prototypes that did use atomics in some parts, but after testing, I always removed them, because they were not needed, and they were too easy to break and make incorrect). Never use atomics in your code manually, it is just a sign of poor design, and asking for trouble and subtle bugs. Use a good implementation of the mutex (like the one in abseil library), and that is all you need to write correct multithreaded code. The only use of atomics for a normal person is 1) low over head multi-thread counters, 2) library implementer that tries to implement mutexes, spinlocks or RCU, or some other very low level primitives (like lockless queue). Even then, it is extremely tricky to get right (and trust me, I implemented all of these too as a library).

    • @superscatboy
      @superscatboy 3 роки тому

      @@movax20h For real. I'm no expert in concurrency or graphics programming, but I've been working on a fractal renderer recently and have *massively* increased performance by making it multithreaded - using literally nothing beyond std::future. There are doubtlessly ways to make it even faster using more finely tuned threading techniques (without even considering shifting the workload to the GPU), but the idea that atomics are *absolutely necessary* for this kind of work is clearly absurd.
      The rendering I'm doing only requires read-only access to shared data (a handful of render settings - and that data is so small I just give a copy to each thread for convenience anyway), and single-writer access to the output buffers (no two threads ever need to render the same pixel after all). I can't see any situation where atomics would help without introducing unnecessary complexity (and most likely potential bugs).

    • @movax20h
      @movax20h 3 роки тому

      @@superscatboy Please read my messages again. Let me quote myself: " You don't need atomics all to write multi threading code. ", "Never use atomics in your code manually, it is just a sign of poor design". I don't know where did you get idea that I claimed that "that atomics are absolutely necessary".

  • @SrivatsanVijayaraghavan-q1d
    @SrivatsanVijayaraghavan-q1d 9 місяців тому

    Brilliant.

  • @CharIie83
    @CharIie83 6 років тому

    Nice to have some ideas on the matter

  • @sirnawaz
    @sirnawaz Рік тому

    41:44, "it has to assume that any opaque function call is a full barrier". I didn't exactly understand that. Does that mean, any opaque function call (even if it does not use lock anything internally) can be used as atomic with released/sc semantic?

    • @ArmLiberty
      @ArmLiberty Рік тому +2

      He refers to “software fences”, i.e. situations that prevent compiler reordering around opaque functions, where the function might access the variable location in question (addressed-exposed variable). It is not related to hardware-related dynamic reorderings.

    • @sirnawaz
      @sirnawaz Рік тому

      @@ArmLiberty Yes. Still not clear. You merely seemed to rephrase my doubt.

    • @jiaweihe1244
      @jiaweihe1244 Рік тому +2

      @@sirnawaz I think he was saying "you cannot use opaque function call be used as atomic", because "compiler (only) has to assume that the opaque function is a full barrier", compiler is only the software part, and the underlying hardware part (processor and cache) will not assume it is a full barrier.

    • @sirnawaz
      @sirnawaz Рік тому

      @@jiaweihe1244 I tried using opaque function call and the generated code does not have any full-barrier instruction. So I'm unable to understand this part.

    • @jiaweihe1244
      @jiaweihe1244 Рік тому

      @@sirnawaz I think maybe modern compiler is able to prove whether a function call contains fence. Herb said in this talk that "compiler assume an opaque function call is a full barrier" if "it cannot prove/deduce that it uses a fence inside".

  • @Peregringlk
    @Peregringlk 3 роки тому

    Herb Sutter mentioned at 1:19:50 that "i'm assuming that [...] int, in your particular hardware, platform and compiler is a properly aligned indivisibly readable and writteable variable", and then they mention x86 as if that assertion were true there. Is that actually true that some "types" are usually "pseudo-atomics" (let's call it that way)? Has this property or situation has any formal name so can google for it?

    • @rohitahuja2782
      @rohitahuja2782 Рік тому +1

      I think, for operations to be Atomic we need to use special instruction which operates on certain data type say 4 bytes long int or a byte long char
      now suppose you have a struct whose last member variable is of type int and it is misaligned or isn't properly padded
      even though we use the atomic instruction on that int it may operate in non-atomic manner due to alignment or padding
      I am not entirely sure about it and i have noticed you have asked it two years ago I hope you have found the answer, if you do please share it with us

    • @Peregringlk
      @Peregringlk Рік тому

      @@rohitahuja2782 It turns out that in x86 and x86_64, if a read or a write of word size or less is properly aligned, then the read/write is guaranteed to be atomic (without using special instructions), in the sense that no thread will see half writes or reads (e.g., a thread reads something while it's being written by another thread), but there's no guarantees of "when" the write will happen. For example, a write can be made but the written value could live in cache without being commited to memory for a while; but in either case no half writes will ever be observed.

  • @badasahog
    @badasahog 2 роки тому

    Rip channel9

  • @vertigo6982
    @vertigo6982 6 років тому

    25:25 what did he say? slash O D? /Od ?

    • @nitinjain7543
      @nitinjain7543 5 років тому +2

      Yes.
      /Od disable optimizations (default)

  • @zyxyuv1650
    @zyxyuv1650 6 років тому +1

    Never again? Quantum computing promises the return of the Neumann machine

    • @AnthonyDentinger
      @AnthonyDentinger 2 роки тому +2

      As far as I know (not a big expert), even if quantum computing one day becomes available for the general public, it would merely be a complement to our regular transistor-based classical computing; basically a classical CPU that also happens to have a quantum chip for some applications. Not all algorithms can be run faster on quantum chips; in fact, almost everything a consumer PC or phone does is _significantly_ easier with classical computing.
      In fact, I think quantum chips require a normal CPU to control them.

  • @eyyo3571
    @eyyo3571 2 роки тому +2

    Should be a crime to not upload these talks in HD. A damn iPhone wouldve been better than the rotten potato used to film this. Hard to imagine this talk is for computer scientists and engineers.

    • @nintendoeats
      @nintendoeats 11 місяців тому

      Because of its age, I suspect this has been re-encoded N times. So while I agree it's not the nicest footage, it's probably much worse now than it was originally.

  • @zachansen8293
    @zachansen8293 7 місяців тому

    herb gives great talks except they don't lead to anything. it's the boy who cried "awesome" except no awesome ever came. now I'm sick of his talks because they just get me excited and then I'm disappointed.n. he should stop giving these talks until there's something concrete behind them.