<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi Anton,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Thank you for this exciting announcement. It is great to see clang continuing
<div>to provide support for evolving OpenCL C standards. However, I would like to
</div>
<div>highlight the following - considering that the specification has been released
</div>
<div>without the upstream implementation, it is possible that some functionality </div>
<div>wouldn't be implemented without the need of modifying the specification or </div>
<div>deviating from the specification. As a matter of fact, this is not specific to
</div>
<div>OpenCL 3.0 and there were several such issues while implementing the</div>
<div>earlier standards. I would like to be more diligent this time to document what</div>
<div>is not conformant to the spec, this page should be a good place</div>
<div><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>.
</div>
<div><br>
</div>
<div>There is one aspect that would be good to clarify before we start implementing
</div>
<div>the features - what would be the interface for the targets to set the feature
</div>
<div>presence?  For example for extensions, different approaches were used i.e. </div>
<div><br>
</div>
<div>- Adding to clang source code i.e. target setting. Those could also be amended
</div>
<div>using -cl-ext flag.</div>
<div>- Outside of clang the extension macros could be defined in headers or using</div>
<div>pre-processor flags -D. </div>
<div><br>
</div>
<div>I understand that if we follow the first approach only we will provide a more
</div>
<div>unified interface but however, we end up adding something in clang that </div>
<div>won't be used in the parser itself. However, for the second approach, we end</div>
<div>up with more heterogeneity but provide higher flexibility to add any custom </div>
<div>extensions as well as simplifying the clang code base. For the features it is</div>
<div>less critical as they are all known, it is also possible that future standards will
</div>
<div>define new features or remove existing ones. </div>
<div><br>
</div>
<div>FYI I have provided more details regarding this topic on a separate RFC:</div>
<div><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><br>
</div>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Kind regards,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Anastasia<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div id="appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> cfe-dev <cfe-dev-bounces@lists.llvm.org> on behalf of Zabaznov, Anton via cfe-dev <cfe-dev@lists.llvm.org><br>
<b>Sent:</b> 25 September 2020 14:36<br>
<b>To:</b> cfe-dev@lists.llvm.org <cfe-dev@lists.llvm.org><br>
<b>Subject:</b> [cfe-dev] [RFC] OpenCL C 3.0 support in clang</font>
<div> </div>
</div>
<div lang="EN-US">
<div class="x_WordSection1">
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
Hi! I'm happy to announce OpenCL C 3.0 support in clang.</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
Language specification is available at https://github.com/KhronosGroup/OpenCL-Docs. 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.</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
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.</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
------- Implementation Details -------</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
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:</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
https://github.com/intel/opencl-clang/tree/ocl-open-110/patches/clang</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
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.</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
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.</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
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</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
Please let me know if you have any concerns about this proposal, I would be glad to discuss it.</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
--------------------------------------</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
Here is a very first step on a route to upstreaming of OpenCL C 3.0 support in clang:</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
https://reviews.llvm.org/D88300</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
This initial patch adds option and predefined macros for OpenCL C 3.0 version.</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
 </p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
Thanks in advance!</p>
<p class="x_MsoNormal" style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin:0in 0in 0.0001pt; font-size:11pt; font-family:"Calibri",sans-serif">
Anton.</p>
</div>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px">
<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 style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px; margin-top:0px; margin-bottom:0px">
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>
</div>
</body>
</html>