<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 21, 2016, at 11:14 AM, Philip Reames <<a href="mailto:listmail@philipreames.com" class="">listmail@philipreames.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class="">
<div class="moz-cite-prefix">On 08/17/2016 03:05 PM, Mehdi Amini
wrote:<br class="">
</div>
<blockquote cite="mid:F7C6C8F0-C753-4937-B9AD-297FAADB3DE4@apple.com" type="cite" class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
<br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Aug 17, 2016, at 2:08 PM, Zhuravlyov,
Konstantin <<a moz-do-not-send="true" href="mailto:Konstantin.Zhuravlyov@amd.com" class="">Konstantin.Zhuravlyov@amd.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="WordSection1" style="page: WordSection1;
font-family: Helvetica; font-size: 12px; font-style:
normal; font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; orphans: auto; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif; background-color:
white;" class=""><span style="font-family: Calibri,
sans-serif;" class="">>Why not going with a
metadata attachment directly and kill the
"singlethread" keyword? Something like:<o:p class=""></o:p></span></div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class="">>Something
like:<o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class="">>
cmpxchg i32* %addr, i32 42, i32 0 monotonic
monotonic, 3, !memory.scope{!42}<o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class="">>
cmpxchg i32* %addr, i32 42, i32 0 monotonic
monotonic, 3, !memory.scope{!43}<o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class="">>...<o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class="">>!42
= !{"singlethread"}<o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class="">>!43
= !{"L2"}<o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;
background-color: white;" class=""><span style="font-family: Calibri, sans-serif;" class="">>It
is not clear to me if there is any correctness
issues to dropping metadata?<o:p class=""></o:p></span></div>
</div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif; background-color:
white;" class=""><span style="font-family: Calibri,
sans-serif;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif; background-color:
white;" class=""><span style="font-family: Calibri,
sans-serif;" class="">Yes, we cannot use the metadata
approach since this metadata can be dropped during the
processing of one module but not dropped in the
processing of a second module, potentially resulting
in inconsistent scopes for synchronizing operations
leading to data races and subsequently leading to
correctness issues.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif; background-color:
white;" class=""><span style="font-family: Calibri,
sans-serif;" class=""><o:p class=""> </o:p></span></div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Right, I saw Sameer's explanation for that earlier, and we
shouldn’t move forward (without Philip’s opinion on the topic
as he expressed concerns).</div>
</div>
</blockquote>
Given my current time commitments, having me on the critical path
for any proposal is not a good idea. I'm willing to step aside here
as long as the proposal is well reviewed by someone who's familiar
with the memory model. Hal, Sanjoy, JF, Chandler, and Danny would
all be reasonable alternates. </div></div></blockquote><div><br class=""></div><div>OK, good to know. I put you on the path because you wrote:</div><div><br class=""></div><div>"I am opposed to extending the instructions without a strong motivating case. I don't care anywhere near as much about metadata based schemes, but extending the instruction semantics imposes a much larger burden on the rest of the community. That burden has to be well justified and supported."</div><div><br class=""></div><div>It is not clear to me right now if the "use case" makes it "well justified" or not (an alternative being using intrinsic for OpenCL as Justin Lebar mentioned). I don’t feel I can answer this, so adding CC Chandler and Sanjoy to begin with.</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div bgcolor="#FFFFFF" text="#000000" class="">Mehdi, if things get to the point
where you think they're good to go and no one else has chimed in,
ping me. I'm not going to be following until then, but I'll make
the time for a final pass through if no one else has first. <br class="">
<blockquote cite="mid:F7C6C8F0-C753-4937-B9AD-297FAADB3DE4@apple.com" type="cite" class="">
<div class="">
<div class=""><br class="">
</div>
<div class="">But you stripped out the second part of my email where I
wrote "It seems you’re going back to integer, which I don’t
really like for reasons mentioned earlier in this thread, and
that I don’t feel you addressed here”. Why can’t `synchscope`
take a string literal?</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">— </div>
<div class="">Mehdi</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<blockquote type="cite" class="">
<div class="">
<div class="WordSection1" style="page: WordSection1;
font-family: Helvetica; font-size: 12px; font-style:
normal; font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; orphans: auto; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif; background-color:
white;" class=""><span style="font-family: Calibri,
sans-serif;" class=""><o:p class=""><br class="">
</o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif; background-color:
white;" class=""><span style="font-family: Calibri,
sans-serif;" class=""><o:p class=""> </o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family: 'Times New Roman', serif;
text-align: center;" align="center">
<hr class="" align="center" size="2" width="98%"></div>
<div id="divRplyFwdMsg" class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><b class=""><span style="font-size: 11pt; font-family:
Calibri, sans-serif;" class="">From:</span></b><span style="font-size: 11pt; font-family: Calibri,
sans-serif;" class=""><span class="Apple-converted-space"> </span>Zhuravlyov,
Konstantin<br class="">
<b class="">Sent:</b><span class="Apple-converted-space"> </span>Wednesday,
August 17, 2016 4:29:30 PM<br class="">
<b class="">To:</b><span class="Apple-converted-space"> </span>Sameer
Sahasrabuddhe; Philip Reames<br class="">
<b class="">Cc:</b><span class="Apple-converted-space"> </span>Mehdi Amini;
Liu, Yaxun (Sam); Ke Bai; Mekhanoshin, Stanislav;
Sumner, Brian; <a moz-do-not-send="true" href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>;
Tye, Tony<br class="">
<b class="">Subject:</b><span class="Apple-converted-space"> </span>RE:
[llvm-dev] Memory scope proposal</span><o:p class=""></o:p></div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""> <o:p class=""></o:p></div>
</div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class="">Hi,<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class="">I
have updated the review here:<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class=""><a moz-do-not-send="true" href="https://reviews.llvm.org/D21723" style="color: purple; text-decoration: underline;" class="">https://reviews.llvm.org/D21723</a><o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class="">As
Sameer pointed out, the motivation is:<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class="">In
OpenCL 2.x, two atomic operations on the same atomic
object need to have the same scope to prevent a data
race. This derives from the definition of "inclusive
scope" in OpenCL 2.x. Encoding OpenCL 2.x scope as
metadata in LLVM IR would be a problem because there
cannot be a "safe default value" to be used when the
metadata is dropped. If the "largest" scope is used as
the default, then the optimizer must guarantee that
the metadata is dropped from every atomic operation in
the whole program, or not dropped at all.<o:p class=""></o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class="">Thanks,<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class="">Konstantin<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri,
sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><b class=""><span style="font-size: 11pt; font-family:
Calibri, sans-serif;" class="">From:</span></b><span style="font-size: 11pt; font-family: Calibri,
sans-serif;" class=""><span class="Apple-converted-space"> </span>Sameer
Sahasrabuddhe [<a moz-do-not-send="true" href="mailto:sameer@sbuddhe.net" class="">mailto:sameer@sbuddhe.net</a>]<span class="Apple-converted-space"> </span><br class="">
<b class="">Sent:</b><span class="Apple-converted-space"> </span>Sunday, July
10, 2016 4:06 AM<br class="">
<b class="">To:</b><span class="Apple-converted-space"> </span>Philip
Reames <<a moz-do-not-send="true" href="mailto:listmail@philipreames.com" class="">listmail@philipreames.com</a>><br class="">
<b class="">Cc:</b><span class="Apple-converted-space"> </span>Mehdi Amini
<<a moz-do-not-send="true" href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>>;
Liu, Yaxun (Sam) <<a moz-do-not-send="true" href="mailto:Yaxun.Liu@amd.com" class="">Yaxun.Liu@amd.com</a>>;
Ke Bai <<a moz-do-not-send="true" href="mailto:kebai613@gmail.com" class="">kebai613@gmail.com</a>>;
Mekhanoshin, Stanislav <<a moz-do-not-send="true" href="mailto:Stanislav.Mekhanoshin@amd.com" class="">Stanislav.Mekhanoshin@amd.com</a>>;
Sumner, Brian <<a moz-do-not-send="true" href="mailto:Brian.Sumner@amd.com" class="">Brian.Sumner@amd.com</a>>;
<a moz-do-not-send="true" href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>;
Zhuravlyov, Konstantin <<a moz-do-not-send="true" href="mailto:Konstantin.Zhuravlyov@amd.com" class="">Konstantin.Zhuravlyov@amd.com</a>>;
Tye, Tony <<a moz-do-not-send="true" href="mailto:Tony.Tye@amd.com" class="">Tony.Tye@amd.com</a>><br class="">
<b class="">Subject:</b><span class="Apple-converted-space"> </span>Re:
[llvm-dev] Memory scope proposal<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><o:p class=""> </o:p></div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: 'Times New Roman', serif;" class=""><o:p class=""> </o:p></div>
<div class="">
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size:
12pt; font-family: 'Times New Roman', serif;" class="">On Mon, Jul 4, 2016 at 5:09 AM, Philip
Reames via llvm-dev <<a moz-do-not-send="true" href="mailto:llvm-dev@lists.llvm.org" target="_blank" style="color: purple;
text-decoration: underline;" class="">llvm-dev@lists.llvm.org</a>>
wrote:<o:p class=""></o:p></div>
<blockquote style="border-style: none none none
solid; border-left-color: rgb(204, 204, 204);
border-left-width: 1pt; padding: 0in 0in 0in
6pt; margin: 5pt 0in 5pt 4.8pt;" class="">
<div class="">
<div class="">
<div style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family: 'Times New
Roman', serif;" class="">I will comment -
as one of the few people actually working
on llvm's atomic implementation with any
regularity - that I am opposed to
extending the instructions without a
strong motivating case. I don't care
anywhere near as much about metadata based
schemes, but extending the instruction
semantics imposes a much larger burden on
the rest of the community. That burden
has to be well justified and supported. <o:p class=""></o:p></div>
</div>
</div>
</blockquote>
<div class=""><p class="MsoNormal" style="margin: 0in 0in
12pt; font-size: 12pt; font-family: 'Times New
Roman', serif;"><br class="">
In OpenCL 2.x, two atomic operations on the
same atomic object need to have the same scope
to prevent a data race. This derives from the
definition of "inclusive scope" in OpenCL 2.x.
Encoding OpenCL 2.x scope as metadata in LLVM
IR would be a problem because there cannot be
a "safe default value" to be used when the
metadata is dropped. If the "largest" scope is
used as the default, then the optimizer must
guarantee that the metadata is dropped from
every atomic operation in the whole program,
or not dropped at all.<o:p class=""></o:p></p>
</div>
<div class=""><p class="MsoNormal" style="margin: 0in 0in
12pt; font-size: 12pt; font-family: 'Times New
Roman', serif;">Hence the original attempt to
extend LLVM atomic instructions with a broader
scope field.<o:p class=""></o:p></p>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size:
12pt; font-family: 'Times New Roman', serif;" class="">Sameer.</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</blockquote><p class=""><br class="">
</p>
</div>
</div></blockquote></div><br class=""></body></html>