[Bug 126] Add support for attribute to mark data as volatile.

via D.gnu d.gnu at puremagic.com
Fri May 23 07:51:49 PDT 2014


http://bugzilla.gdcproject.org/show_bug.cgi?id=126

--- Comment #4 from Johannes Pfau <johannespfau at gmail.com> ---
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.

-- 
You are receiving this mail because:
You are watching all bug changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20140523/f92db68e/attachment-0001.html>


More information about the D.gnu mailing list