<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<blockquote class="quotableTextTraining" style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(32, 31, 30); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 15px; background-color: rgb(255, 255, 255); display: inline !important">As
a first step, I would like to remove unused extensions described in the list III.</span><br>
</div>
</blockquote>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
To make progress on this RFC, the removal of unused extensions is covered by <a href="https://reviews.llvm.org/D89372" id="LPlnk542671" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">https://reviews.llvm.org/D89372</a>. Any additional
feedback is welcome.</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,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Marco</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> cfe-dev <cfe-dev-bounces@lists.llvm.org> on behalf of Anastasia Stulova via cfe-dev <cfe-dev@lists.llvm.org><br>
<b>Sent:</b> 30 September 2020 11:24<br>
<b>To:</b> clang developer list <cfe-dev@lists.llvm.org><br>
<b>Cc:</b> nd <nd@arm.com><br>
<b>Subject:</b> [cfe-dev] [OpenCL] Simplification in extensions</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">In this RFC I would like to discuss simplifications in the OpenCL extension
<div>implementation, that can affect existing code. Please, provide your feedback
</div>
<div>and concerns if any to reduce the possibility of a negative impact. </div>
<div><br>
</div>
<div>1. *Removal/prevention from adding unused extensions.* Currently, about 1/3 of
</div>
<div>extensions added to clang are unused - extensions that are added into the </div>
<div>OpenCLOptions data structure</div>
<div>(<a href="https://clang.llvm.org/doxygen/OpenCLOptions_8h_source.html" title="https://clang.llvm.org/doxygen/OpenCLOptions_8h_source.html">https://clang.llvm.org/doxygen/OpenCLOptions_8h_source.html</a>) but never</div>
<div>appear to be used in the rest of the source code except for setting them in the</div>
<div>targets. Note that some of the extensions that are added to clang don't even have
</div>
<div>corresponding kernel language changes and therefore it is very unclear why </div>
<div>they were added to clang in the first place (see cl_khr_spir, cl_khr_icd, </div>
<div>cl_khr_context_abort, etc). There are also other 1/3 that are added for the </div>
<div>sake of defining macros, however, I am wondering if more dedicated approaches</div>
<div>to defining macros could be used i.e. using clang::MacroBuilder for adding macros
</div>
<div>directly or using headers/pre-processor command-line options. </div>
<div><br>
</div>
<div>Below I provide the list summarizing the current status of the extension uses.
</div>
<div>As a first step, I would like to remove unused extensions described in the list III.</div>
<div>As a second step, I would like to find an alternative way to add extension macro
</div>
<div>for the extensions that only add functionality in the header - list II (i.e. those</div>
<div>that do not affect the parser in any way), so that they can be moved out of clang</div>
<div>and live in headers or in pre-processor command-line options i.e. -D. I, therefore,
</div>
<div>suggest that we create a mechanism for adding the macro corresponding to the
</div>
<div>extensions: either by adding a target hook for loading a vendor header that </div>
<div>could contain a definition of those macros or a hook for adding the pre-</div>
<div>processor options to define those macros. </div>
<div><br>
</div>
<div>2. *Removal/prevention from adding the redundant extension pragma.* Currently,</div>
<div>every extension registered in clang via OpenCLOptions will add an extension</div>
<div>pragma too. However, in the majority of cases, the pragma seems to be unused or</div>
<div>used without adding any value leading to the increase of the complexity in </div>
<div>applications and tools - one example is guarding the use of types or even </div>
<div>functions by the pragma (see detailed explanation in</div>
<div><a href="https: //github.com/KhronosGroup/OpenCL-Docs/pull/355#issuecomment-662679499" title="https: //github.com/KhronosGroup/OpenCL-Docs/pull/355#issuecomment-662679499">https://github.com/KhronosGroup/OpenCL-Docs/pull/355#issuecomment-662679499</a>).</div>
<div>Currently only cl_khr_fp64 seems to require pragma genuinely for switching the
</div>
<div>floating-point literal between single and double precision. I would like to </div>
<div>remove such pragmas together with unused pragmas. Note that removal of old </div>
<div>pragmas doesn't necessarily break backward compatibility as the use of unknown
</div>
<div>pragmas is ignored with a warning. And only in cases where warnings are </div>
<div>undesirable the application code is to be updated. </div>
<div><br>
</div>
<div>Both 1 and 2 have two actions: (a) refactoring of existing code and (b) </div>
<div>establishing clear guidelines for future development in particular OpenCL 3.0.
</div>
<div>So even if we won't be able to achieve all the refactoring described above, I
</div>
<div>would at least like to set the directions for the future development that will
</div>
keep our codebase cleaner and more maintainable.
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div><br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">==================================</span><br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">List of the OpenCL extensions classified by their use</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">==================================</span></div>
<div><br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">I. Used by the parser (and optionally in internal headers)
</span>
<div><br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_fp64</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_fp16</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_gl_msaa_sharing</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_3d_image_writes</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_subgroups</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_int64_base_atomics</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_int64_extended_atomics</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_mipmap_image</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_mipmap_image_writes</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_intel_subgroups</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_intel_device_side_avc_motion_estimation<br>
</span></div>
<div><br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">II. Used in internal headers</span></div>
<div><br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_depth_images</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_subgroup_extended_types</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_subgroup_non_uniform_vote</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_subgroup_ballot</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_subgroup_non_uniform_arithmetic</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_subgroup_extended_type</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_subgroup_shuffle</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_subgroup_shuffle_relative</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_subgroup_clustered_reduce</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_global_int32_base_atomics</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_global_int32_extended_atomics</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_local_int32_base_atomics</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_local_int32_extended_atomics</span></div>
<div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_amd_media_ops</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_amd_media_ops2</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_arm_integer_dot_product_int8</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_arm_integer_dot_product_accumulate_int8</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_arm_integer_dot_product_accumulate_int16</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_arm_integer_dot_product_accumulate_saturate_int8</span></div>
<br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">III. Unused (defined and optionally set by the targets, but not used in parser or header)</span><br>
</div>
<div><br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_icd</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_initialize_memory</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_d3d10_sharing</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_gl_event</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_egl_image</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_context_abort</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_d3d11_sharing</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_dx9_media_sharing</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_image2d_from_buffer</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_gl_depth_images</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_spir</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_srgb_image_writes</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_khr_terminate_context</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)"><span style="font-size:12pt; background-color:rgba(0,0,0,0)">cles_khr_int64</span><br>
</span></div>
<span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">cl_intel_subgroups_short</span><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">Looking forward to any feedback!</span><br>
</div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">Thank you,</span></div>
<div><span style="font-size:12pt; color:rgb(50,49,48); background-color:rgba(0,0,0,0)">Anastasia</span><br>
</div>
</div>
</div>
</body>
</html>