Comment # 4
on bug 126
from Johannes Pfau
Yes, I was eagerly waiting for that talk. Unfortunately the most interesting
talks are the last ones on each day and I couldn't watch these live because of
timezone stuff. I'll watch these as soon as recordings are available though,
especially your debugging talk.
Unfortunately I won't have the DIP finished during dconf, some difficult cases
are not discussed yet and the rationale is missing completely and the DIP is
not very useful without a rationale. But if you read this during dconf there's
one thing you could ask Andrei (or everybody):
Quoting Bartosz Milewski from http://stackoverflow.com/a/8833218/471401
> I's still struggling with the use of volatile with atomics: "volatile is
> completely unnecessary when used with std::atomic". What about the loop
> optimization of while(x.load(memory_order_relaxed)) ; => bool tmp =
> x.load(memory_order_relaxed); while(tmp) ; The standard is wishy washy about
> this and Hans turns into a diplomat when asked this question directly ;-)
So translating this to D:
------------
import core.atomic;
shared bool x;
void main()
{
while(atomicLoad(x))
{
}
}
void main_optimized()
{
bool tmp = atomicLoad(x);
while(tmp)
{
}
}
------------
http://dpaste.dzfl.pl/b7ecc943ccab
Is optimizing main into main_optimized legal or not? The background of this
question is that merging reads is usually legal for atomic loads from
non-volatile memory (as-if rule). But in this case with a loop this is not
useful behavior. The question then is where to draw the line.