<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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@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">Hi! I'm happy to announce OpenCL C 3.0 support in clang.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">------- Implementation Details -------<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">https://github.com/intel/opencl-clang/tree/ocl-open-110/patches/clang<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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="MsoNormal">--------------------------------------<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">https://reviews.llvm.org/D88300<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This initial patch adds option and predefined macros for OpenCL C 3.0 version.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks in advance!<o:p></o:p></p>
<p class="MsoNormal">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</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>