News for hackers. Stuff that matters.
Re:No sane compiler would optimize atomics (2015) by Retric on Sunday July 11, 2021 @08:59PM (#27805838)
Consider the reverse. What if the interleaving was undesirable, would you like some way to be informed that it’s impossible so you don’t have to reason about it?

When trying to reason about code, finding somethings that looks like a bug but isn’t can result in a lot of wasted effort.

Re:No sane compiler would optimize atomics (2015) by chrisseaton on Sunday July 11, 2021 @09:04PM (#27805865)
> What if the interleaving was undesirable, would you like some way to be informed that it’s impossible

That's like synchronised in Java or any other kind of atomic block or serialising block - that's already a thing.

Re:No sane compiler would optimize atomics (2015) by Retric on Sunday July 11, 2021 @10:21PM (#27806262)
That information is moving in the wrong direction. I don’t want the programmer to be telling a compiler what to do, I want the compiler to inform the programmer what it did.
Re:No sane compiler would optimize atomics (2015) by chrisseaton on Sunday July 11, 2021 @10:26PM (#27806293)
> That information is moving in the wrong direction.

You set the direction not me! You asked me 'would you like some way to be informed that [the interleaving is] impossible'. Yes... and the user gives me that information through a synchronised block. If they don't tell me they want an interleaving to be impossible then why should I not make it possible? There are countless other interleavings I make impossible or possible when I do any trivial compiler task such as scheduling. Should I consult the user on all of them? I don't think you'd like all the questions you'd get!

Re:No sane compiler would optimize atomics (2015) by Retric on Monday July 12, 2021 @08:37AM (#27809607)
Informing the user isn’t about what you did, it’s about the user having some way of knowing what you did. At least compilers give you assembly code to look at, CPU’s are little better than black magic from a programmers perspective.
Re:No sane compiler would optimize atomics (2015) by chrisseaton on Monday July 12, 2021 @08:48AM (#27809674)
The user can dump the compiler output and intermediate structures if they want.

Or they could program against the spec and not worry.

Re:No sane compiler would optimize atomics (2015) by kaba0 on Sunday July 11, 2021 @11:19PM (#27806595)
Check the generated machine/byte code?