<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b>From:</b> Anastasia Stulova [mailto:Anastasia.Stulova@arm.com]
<br>
<b>Sent:</b> Tuesday, January 17, 2017 1:55 PM<br>
<b>To:</b> Liu, Yaxun (Sam) <Yaxun.Liu@amd.com>; cfe-dev (cfe-dev@lists.llvm.org) <cfe-dev@lists.llvm.org><br>
<b>Cc:</b> Sumner, Brian <Brian.Sumner@amd.com>; Tye, Tony <Tony.Tye@amd.com>; Zhuravlyov, Konstantin <Konstantin.Zhuravlyov@amd.com>; Bader, Alexey (alexey.bader@intel.com) <alexey.bader@intel.com>; nd <nd@arm.com><br>
<b>Subject:</b> RE: [RFC] Support synchronisation scope in Clang atomic builtin functions<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB" style="color:#1F497D">FYI, reference to the relevant part of the OpenCL spec:
<a href="https://www.khronos.org/registry/OpenCL/specs/opencl-2.0-openclc.pdf#105">
https://www.khronos.org/registry/OpenCL/specs/opencl-2.0-openclc.pdf#105</a><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB" style="color:#1F497D">From the OpenCL side this proposal seems to make sense generally. I am not quite clear though what would happen with the scopes other than synch_scope_single_thread.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB" style="color:#1F497D">Do you need to extend the IR language to accommodate that too in addition to ‘singlethread’ flag you already use?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">We have the review/RFC for this posted here:
<a href="https://reviews.llvm.org/D21723">https://reviews.llvm.org/D21723</a>. But did not get a chance to follow up yet.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Konstatnin<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB" style="color:#1F497D">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB" style="color:#1F497D">Anastasia<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:"Tahoma",sans-serif">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma",sans-serif"> Liu, Yaxun (Sam) [<a href="mailto:Yaxun.Liu@amd.com">mailto:Yaxun.Liu@amd.com</a>]
<br>
<b>Sent:</b> 17 January 2017 17:16<br>
<b>To:</b> cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>)<br>
<b>Cc:</b> Sumner, Brian; Tye, Tony; Zhuravlyov, Konstantin; Anastasia Stulova; Bader, Alexey (<a href="mailto:alexey.bader@intel.com">alexey.bader@intel.com</a>)<br>
<b>Subject:</b> [RFC] Support synchronisation scope in Clang atomic builtin functions<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"><span lang="EN-GB"><o:p> </o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:9.0pt;margin-left:.5in;background:white">
<span style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:black">OpenCL 2.0 atomic builtin functions have a scope argument which is ideally represented as synchronization scope argument in LLVM atomic instructions.<o:p></o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:9.0pt;margin-left:.5in;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;widows: 2;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:black">Clang supports translating Clang atomic builtin functions to LLVM atomic instructions. However it currently does not support synchronization scope of LLVM atomic instructions. Without
 this, users have to use LLVM assembly code to implement OpenCL atomic builtin functions.<o:p></o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:9.0pt;margin-left:.5in;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;widows: 2;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:black">I have a patch (<a href="https://reviews.llvm.org/D28691">https://reviews.llvm.org/D28691</a> ) which allows Clang atomic builtin functions to accept an optional synchronization scope
 argument, so that they can be used to implement OpenCL atomic builtin functions.<o:p></o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:9.0pt;margin-left:.5in;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;widows: 2;-webkit-text-stroke-width: 0px;word-spacing:0px">
<span style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:black">This patch will not just benefits OpenCL. It will benefit any languages which need to generate atomic instructions with synchronization scopes. For languages not using synchronization
 scopes there is no functional change, since the synchronization scope argument is optional, and its default value generates the same LLVM instruction as before.<o:p></o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:9.0pt;margin-left:.5in;background:white">
<span style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:black">Your comments are welcome.<span style="background:white"><o:p></o:p></span></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:9.0pt;margin-left:.5in;background:white">
<span style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:black;background:white">Thanks.<o:p></o:p></span></p>
<p style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:9.0pt;margin-left:.5in;background:white">
<span style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:black;background:white">Sam</span><span style="font-size:10.0pt;font-family:"Segoe UI",sans-serif;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
</body>
</html>