<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)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><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;}
/* 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:blue;
text-decoration:underline;}
p.xmsonormal, li.xmsonormal, div.xmsonormal
{mso-style-name:x_msonormal;
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
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="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi, Anastasia! Thanks for your reply.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regarding disagreements between specification and implementation: what now comes to mind is that it is worth mentioning that clang supports compilation only for FULL OpenCL profile, not EMBEDDED profile (https://github.com/KhronosGroup/OpenCL-Docs/blob/master/api/embedded_profile.asciidoc).
Though we can discuss if we plan to support compilation for EMBEDDED OpenCL profile in clang.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I also checked out the proposal about simplification in extension mechanism: there is something common with OpenCL features, especially there are features which affect only internal opencl-c.h header, such as:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">__opencl_c_atomic_scope_device<o:p></o:p></p>
<p class="MsoNormal">__opencl_c_atomic_scope_all_devices<o:p></o:p></p>
<p class="MsoNormal">__opencl_c_work_group_collective_functions.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I could do some research to find a proper way to define those macros somehow else (except '-D' flag) and this can be reused for extensions which are mentioned in II section of your letter (http://lists.llvm.org/pipermail/cfe-dev/2020-September/066911.html).
However, I don't see any strong concerns about current implementation in defining such macros since all the extensions are already defined only in OpenCLExtensions.def, so this approach is already unified for extensions of all types. Perhaps we could extend
current functionality of '-cl-ext' to allow registering new custom features/extensions which affect header only. Also, we can differentiate if extension or feature is used only in header by adding a flag into definition in OpenCLExtensions.def file.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Anton<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 <Anastasia.Stulova@arm.com> <br>
<b>Sent:</b> Wednesday, September 30, 2020 1:33 PM<br>
<b>To:</b> cfe-dev@lists.llvm.org; Zabaznov, Anton <anton.zabaznov@intel.com><br>
<b>Cc:</b> nd <nd@arm.com><br>
<b>Subject:</b> Re: [cfe-dev] [RFC] OpenCL C 3.0 support in clang<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Hi Anton,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Thank you for this exciting announcement. It is great to see clang continuing
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">to provide support for evolving OpenCL C standards. However, I would like to
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">highlight the following - considering that the specification has been released
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">without the upstream implementation, it is possible that some functionality
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">wouldn't be implemented without the need of modifying the specification or
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">deviating from the specification. As a matter of fact, this is not specific to
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">OpenCL 3.0 and there were several such issues while implementing the<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">earlier standards. I would like to be more diligent this time to document what<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">is not conformant to the spec, this page should be a good place<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><a href="https://clang.llvm.org/docs/LanguageExtensions.html" title="https://clang.llvm.org/docs/LanguageExtensions.html">https://clang.llvm.org/docs/LanguageExtensions.html</a>.
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">There is one aspect that would be good to clarify before we start implementing
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">the features - what would be the interface for the targets to set the feature
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">presence? For example for extensions, different approaches were used i.e.
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">- Adding to clang source code i.e. target setting. Those could also be amended
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">using -cl-ext flag.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">- Outside of clang the extension macros could be defined in headers or using<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">pre-processor flags -D.
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">I understand that if we follow the first approach only we will provide a more
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">unified interface but however, we end up adding something in clang that
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">won't be used in the parser itself. However, for the second approach, we end<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">up with more heterogeneity but provide higher flexibility to add any custom
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">extensions as well as simplifying the clang code base. For the features it is<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">less critical as they are all known, it is also possible that future standards will
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">define new features or remove existing ones.
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">FYI I have provided more details regarding this topic on a separate RFC:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><a href="http://lists.llvm.org/pipermail/cfe-dev/2020-September/066911.html" title="http://lists.llvm.org/pipermail/cfe-dev/2020-September/066911.html">http://lists.llvm.org/pipermail/cfe-dev/2020-September/066911.html</a><o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Kind regards,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Anastasia<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org">cfe-dev-bounces@lists.llvm.org</a>> on behalf of Zabaznov, Anton via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Sent:</b> 25 September 2020 14:36<br>
<b>To:</b> <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>Subject:</b> [cfe-dev] [RFC] OpenCL C 3.0 support in clang</span> <o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<p class="xmsonormal">Hi! I'm happy to announce OpenCL C 3.0 support in clang.<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">Language specification is available at <a href="https://github.com/KhronosGroup/OpenCL-Docs">
https://github.com/KhronosGroup/OpenCL-Docs</a>. OpenCL C 3.0 language standard is now backward compatible with 1.2 and makes 2.0 features optional. New OpenCL language specification is important because it allows platform vendors to optionally support OpenCL
C 2.0 features which are no longer required for compliance with the core specification. This allows vendors to port OpenCL implementations on high variety of devices by choosing necessary functionality to implement. Such vendors as Intel and ARM are highly
interested in OpenCL C 3.0. So I encourage everyone else who is also looking forward for OpenCL C 3.0 support in clang to take part in the following discussions and reviews.<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">In OpenCL 3.0 support of various features is indicated with a feature test macros. This is pretty much similar to C++ feature test macros but the difference is that the presence and the value of the latter directly relates to C++ language
standard. The presence of feature test macros in OpenCL C 3.0 in the contrary is target specific: macros are being optionally defined by the frontend compiler depending on whether the target architecture supports feature or not.<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">------- Implementation Details -------<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">First it is worth mentioning that there are no big conceptual changes in clang expected since OpenCL C 3.0 makes 2.0 features optional. I've been working on OpenCL C 3.0 support in Intel and full patch is already published in Intel opencl-clang
repo:<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal"><a href="https://github.com/intel/opencl-clang/tree/ocl-open-110/patches/clang">https://github.com/intel/opencl-clang/tree/ocl-open-110/patches/clang</a><o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">There already exists such concept as extensions in OpenCL C language specification which has a similar meaning with OpenCL features. The difference between two of them is that OpenCL extensions are not the part of core specification and
require special pragma directive to enable them. Despite the fact that features and extensions are different I tried to reuse the current extension mechanism in clang as much as possible to avoid code duplication. Also, I'm going to introduce new LangOpts
flags for OpenCL C specific keywords such as 'generic' and 'pipe'; and 'OPENCLBUILTIN' concept (instead of 'LANGBUILTIN') to forward OpenCL C feature name as a parameter.<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">The main idea behind proposed implementation is that feature tests macros are being defined by compiler in all OpenCL versions and can't be disabled in versions prior to 3.0. This unified approach will help to avoid additional checks when
identifying various types and built-ins support for all OpenCL versions in both: in clang and opencl-c.h header. Also, it logically expresses compiler behavior for other OpenCL versions, for example: OpenCL C 2.0 supports generic address space by default thus
'__opencl_c_generic_address_space' macro is defined when '-cl-std=CL2.0' option is used.<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">There are some cases when for OpenCL C 3.0 feature already exists equivalent OpenCL C extension ('__opencl_c_3d_image_writes' and 'cl_khr_3d_image_writes'). The strategy which I decided to follow here is to provide simultaneous test macro
presence for both: for feature and corresponding extension because they describe same functionality. Additionally, the reason for this is backward compatibility: there may be older applications where extension macro is checked instead of feature macro. With
this approach older applications will continue to compile with OpenCL C 3.0<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">Please let me know if you have any concerns about this proposal, I would be glad to discuss it.<o:p></o:p></p>
<p class="xmsonormal">--------------------------------------<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">Here is a very first step on a route to upstreaming of OpenCL C 3.0 support in clang:<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal"><a href="https://reviews.llvm.org/D88300">https://reviews.llvm.org/D88300</a><o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">This initial patch adds option and predefined macros for OpenCL C 3.0 version.<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">Thanks in advance!<o:p></o:p></p>
<p class="xmsonormal">Anton.<o:p></o:p></p>
</div>
<p><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></p>
<p>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></p>
</div>
<p><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</p><p>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.</p>
</body>
</html>