<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;}
/* 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.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma",sans-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.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma",sans-serif;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle23
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle24
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle25
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle26
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle27
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle28
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle29
{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">Clang does not allow casting OpenCL opaque types to any other types. For example,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">$ cat test3.cl<o:p></o:p></p>
<p class="MsoNormal">void f(sampler_t s) {<o:p></o:p></p>
<p class="MsoNormal"> void *q = (void*) s;<o:p></o:p></p>
<p class="MsoNormal"> char *p = (char*) s;<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">$ bin/clang -cc1 test3.cl<o:p></o:p></p>
<p class="MsoNormal">test3.cl:2:21: error: operand of type 'sampler_t' where arithmetic or pointer type is required<o:p></o:p></p>
<p class="MsoNormal"> void *q = (void*) s;<o:p></o:p></p>
<p class="MsoNormal"> ^<o:p></o:p></p>
<p class="MsoNormal">test3.cl:3:21: error: operand of type 'sampler_t' where arithmetic or pointer type is required<o:p></o:p></p>
<p class="MsoNormal"> char *p = (char*) s;<o:p></o:p></p>
<p class="MsoNormal"> ^<o:p></o:p></p>
<p class="MsoNormal">2 errors generated.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">That makes sense since allowing OpenCL opaque types to be casted to other types potentially can cause lots of issues and needs more checks.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Then I don’t know how representing OpenCL opaque type as a non-struct type would work.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">On the other hand, any type can be easily packaged in a struct type. What we need is a struct name that can be used by a common OpenCL source code.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sam<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"><b>From:</b> Anastasia Stulova [mailto:Anastasia.Stulova@arm.com]
<br>
<b>Sent:</b> Wednesday, July 27, 2016 2:39 PM<br>
<b>To:</b> Liu, Yaxun (Sam) <Yaxun.Liu@amd.com>; Bader, Alexey <alexey.bader@intel.com>; cfe-dev (cfe-dev@lists.llvm.org) <cfe-dev@lists.llvm.org><br>
<b>Cc:</b> Sumner, Brian <Brian.Sumner@amd.com>; Pan, Xiuli <xiuli.pan@intel.com>; nd <nd@arm.com><br>
<b>Subject:</b> RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">Right, what I mean is that OpenCL types are now generated by Clang as unknown opaque types identified by their name in LLVM. Unfortunately LLVM is missing proper type support for OpenCL, therefore
we have this issue. But adding “struct.” prefix might imply that this has to be a struct. Clang uses “struct.” prefix as a naming convention for generated C struct types in LLVM.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">Implementation should however have freedom to use OpenCL opaque types differently to struct (we don’t force it to be anything). I don’t think adding a struct prefix to the OpenCL opaque type names
in LLVM is a good idea as it adds some confusion about their representation.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">Anastasia<o:p></o:p></span></p>
<p class="MsoNormal"><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"><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> 27 July 2016 18:58<br>
<b>To:</b> Anastasia Stulova; Bader, Alexey; cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>)<br>
<b>Cc:</b> Sumner, Brian; Pan, Xiuli; nd<br>
<b>Subject:</b> RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal">In LLVM, the OpenCL opaque types are already represented as an opaque struct type since only struct types can have name. This proposal does not change that, it only changes the name of the struct type to be accessible in the OpenCL source
code.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Besides, Clang does not allow OpenCL opaque types such as sampler and image types to be explicitly casted to other types.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sam<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"><b>From:</b> Anastasia Stulova [<a href="mailto:Anastasia.Stulova@arm.com">mailto:Anastasia.Stulova@arm.com</a>]
<br>
<b>Sent:</b> Wednesday, July 27, 2016 1:08 PM<br>
<b>To:</b> Liu, Yaxun (Sam) <<a href="mailto:Yaxun.Liu@amd.com">Yaxun.Liu@amd.com</a>>; Bader, Alexey <<a href="mailto:alexey.bader@intel.com">alexey.bader@intel.com</a>>; cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>) <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Cc:</b> Sumner, Brian <<a href="mailto:Brian.Sumner@amd.com">Brian.Sumner@amd.com</a>>; Pan, Xiuli <<a href="mailto:xiuli.pan@intel.com">xiuli.pan@intel.com</a>>; nd <<a href="mailto:nd@arm.com">nd@arm.com</a>><br>
<b>Subject:</b> RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">In this case I am not sure it’s generic enough to assume that those types are always mapped to some struct.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">Perhaps, we should stay with the conversion?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">Anastasia<o:p></o:p></span></p>
<p class="MsoNormal"><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"><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> 27 July 2016 16:29<br>
<b>To:</b> Bader, Alexey; Anastasia Stulova; cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>)<br>
<b>Cc:</b> Sumner, Brian; Pan, Xiuli; nd<br>
<b>Subject:</b> RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal">You are right. It should be struct.__opencl_ prefix.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sam<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"><b>From:</b> Bader, Alexey [<a href="mailto:alexey.bader@intel.com">mailto:alexey.bader@intel.com</a>]
<br>
<b>Sent:</b> Wednesday, July 27, 2016 10:56 AM<br>
<b>To:</b> Anastasia Stulova <<a href="mailto:Anastasia.Stulova@arm.com">Anastasia.Stulova@arm.com</a>>; Liu, Yaxun (Sam) <<a href="mailto:Yaxun.Liu@amd.com">Yaxun.Liu@amd.com</a>>; cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>)
<<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Cc:</b> Sumner, Brian <<a href="mailto:Brian.Sumner@amd.com">Brian.Sumner@amd.com</a>>; Pan, Xiuli <<a href="mailto:xiuli.pan@intel.com">xiuli.pan@intel.com</a>>; nd <<a href="mailto:nd@arm.com">nd@arm.com</a>><br>
<b>Subject:</b> RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="color:#1F497D">Hi Sam,</span></a><span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I want to clarify the use case.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">The intension is to allow library developer redefining OpenCL images types in a library written in OpenCL C and prefix starting with double underscore is supposed to protect the library image types definitions
from redefinition by user. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">The change you are proposing is to rename image opaque types in LLVM IR, without making them concrete.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Am I getting it right?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Wouldn’t types defined by library developer prefixed with ‘struct.’? Shouldn’t clang create opaque types with ‘struct.__opencl_’ prefix instead to match the type names defined by library developer?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Alexey<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="RU"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><a name="_____replyseparator"></a><b>From:</b> Anastasia Stulova [<a href="mailto:Anastasia.Stulova@arm.com">mailto:Anastasia.Stulova@arm.com</a>]
<br>
<b>Sent:</b> Monday, July 25, 2016 6:41 PM<br>
<b>To:</b> Liu, Yaxun (Sam) <<a href="mailto:Yaxun.Liu@amd.com">Yaxun.Liu@amd.com</a>>; cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>) <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Cc:</b> Sumner, Brian <<a href="mailto:Brian.Sumner@amd.com">Brian.Sumner@amd.com</a>>; Bader, Alexey <<a href="mailto:alexey.bader@intel.com">alexey.bader@intel.com</a>>; Pan, Xiuli <<a href="mailto:xiuli.pan@intel.com">xiuli.pan@intel.com</a>>; nd <<a href="mailto:nd@arm.com">nd@arm.com</a>><br>
<b>Subject:</b> RE: [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><span lang="RU"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">Sounds good to me!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="color:#1F497D">Anastasia<o:p></o:p></span></p>
<p class="MsoNormal"><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"><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> 20 July 2016 18:49<br>
<b>To:</b> cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>)<br>
<b>Cc:</b> Anastasia Stulova; Sumner, Brian; Bader, Alexey (<a href="mailto:alexey.bader@intel.com">alexey.bader@intel.com</a>); Pan, Xiuli<br>
<b>Subject:</b> [RFC][OpenCL] Rename OpenCL opaque types in LLVM IR from opencl.* to __opencl_*<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal">Currently OpenCL opaque types have name opencl.* in LLVM IR, which causes difficulty for library developers who need to implement the concrete types corresponding to the opaque types.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">For example, read_only image2d_t type is translated to opencl.image2d_ro_t addrspace(1)* in LLVM IR. Ideally, a library developer would implement a concreate struct type with name opencl.image2d_ro_t and access its members. However, due
to the ‘.’, ‘opencl.image2d_ro_t’ is not a valid identifier in OpenCL C language, library developers cannot use it as the name of the concrete struct type for image2d_t. Bitcasts have to be introduced, which causes extra efforts in backends.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Due to this reason, we would like to propose renaming OpenCL opaque types in LLVM IR from opencl.* to __opencl_*.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This change will make the IR deviate from SPIR spec. However, considering there is simple rule to map this new name to SPIR defined name, and LLVM IR currently generated by Clang has already been deviated from SPIR spec, a SPIR consumer
should be able to accommodate this change if it is able to accommodate existing deviations.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Your feedbacks are welcome. Thanks.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sam<o:p></o:p></p>
<p><span lang="RU"><br>
--------------------------------------------------------------------<br>
Joint Stock Company Intel A/O<br>
Registered legal address: Krylatsky Hills Business Park, <br>
17 Krylatskaya Str., Bldg 4, Moscow 121614, <br>
Russian Federation<o:p></o:p></span></p>
<p><span lang="RU">This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.<o:p></o:p></span></p>
</div>
</body>
</html>