<br><br><div class="gmail_quote">2012/8/4 Sean Kelly <span dir="ltr"><<a href="mailto:sean@invisibleduck.org" target="_blank">sean@invisibleduck.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On Aug 1, 2012, at 10:25 AM, Walter Bright <<a href="mailto:walter@digitalmars.com">walter@digitalmars.com</a>> wrote:<br>
><br>
> To reiterate, this is why I need to know what problem you are trying to address, rather than going at it from the solution point of view.<br>
<br>
</div>I think the original request was for there to be some way to prevent compiler optimization of certain plain old loads/stores:<br>
<div class="im"><br>
<br>
On Jul 23, 2012, at 2:28 PM, Alex Rønne Petersen <<a href="mailto:xtzgzorex@gmail.com">xtzgzorex@gmail.com</a>> wrote:<br>
><br>
> And further: How are people *really* supposed to prevent compiler<br>
> reordering in modern D2 programs (without using atomics; they are<br>
> expensive and wasteful for this)?<br>
<br>
</div>This can be useful for tuning concurrent algorithms to avoid unnecessary synchronized operations and also for the occasional store where the ordering isn't important so much as that it simply be issued at all.  Using DMD, my suggestion would be to use atomicStore!msync.raw, which performs a plain old store in asm and uses the fact that DMD doesn't optimize across asm blocks to make the operation behave in the desired manner.  But I believe GDC and LLDC may both optimize more aggressively with respect to asm code and so this assumption doesn't hold universally.  Personally, if I could be guaranteed that at least specific asm blocks would be treated as volatile by the compiler in that there's no code movement across them, etc, then that would probably be enough.<br>


<div class="HOEnZb"><div class="h5">_______________________________________________<br>
dmd-internals mailing list<br>
<a href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-internals" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a><br>
</div></div></blockquote></div><br>shared is supposed to garantee that. volatile is useless in regard to concurency.<br>