<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=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@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:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        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;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.gmail-m-9120581935815487100msolistparagraph, li.gmail-m-9120581935815487100msolistparagraph, div.gmail-m-9120581935815487100msolistparagraph
        {mso-style-name:gmail-m_-9120581935815487100msolistparagraph;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:2.0cm 42.5pt 2.0cm 3.0cm;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:333462967;
        mso-list-template-ids:-1753574404;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:36.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:72.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:108.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:144.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:180.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:216.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:252.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:288.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:324.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1
        {mso-list-id:347412406;
        mso-list-type:hybrid;
        mso-list-template-ids:1671989736 -828048462 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l1:level1
        {mso-level-start-at:10;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-font-family:Calibri;}
@list l1:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l1:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l1:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l1:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l1:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l1:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l1:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l1:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l2
        {mso-list-id:635918228;
        mso-list-template-ids:827783824;}
@list l2:level1
        {mso-level-tab-stop:36.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l2:level2
        {mso-level-tab-stop:72.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l2:level3
        {mso-level-tab-stop:108.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l2:level4
        {mso-level-tab-stop:144.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l2:level5
        {mso-level-tab-stop:180.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l2:level6
        {mso-level-tab-stop:216.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l2:level7
        {mso-level-tab-stop:252.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l2:level8
        {mso-level-tab-stop:288.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l2:level9
        {mso-level-tab-stop:324.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l3
        {mso-list-id:1687899594;
        mso-list-template-ids:-486533036;}
@list l3:level1
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:36.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l3:level2
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:72.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l3:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:108.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l3:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:144.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l3:level5
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:180.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l3:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:216.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l3:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:252.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l3:level8
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:288.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l3:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:324.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></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 Enrique,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> 1) What do yourefer by OpenCL RT?<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">I mean OpenCL Runtime – some library which implements OpenCL API for you.<o:p></o:p></p>
<p class="MsoNormal"><br>
Basically, OpenCL consist of two parts: host code and device code.<o:p></o:p></p>
<p class="MsoNormal">Host code can be written at any language and actually it is a regular C/C++/Python/whatever application which uses OpenCL API.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">OpenCL API allows you to select platform, device, create context and buffers for data, create and build program for your device, create command queue and kernel, set kernel arguments and then enqueue your kernel for execution on the selected
 device.<o:p></o:p></p>
<p class="MsoNormal">You can always read the spec [1] to understand all these concepts. I would recommend section 3 “The OpenCL Architecture”: in particular, section 3.1 “Platform Model” and 3.2 “Execution Model”.<o:p></o:p></p>
<p class="MsoNormal">Also you can find some videos [2], slides [3] or articles [4] about this topic.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So, the next part is device code: it can be written on OpenCL C, C++ for OpenCL in clang, or any other language which can be represented in SPIR-V.<o:p></o:p></p>
<p class="MsoNormal">As I said in previous emails, device code can be compiled online or offline and then it will be launched on selected device using API.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I encourage you to read the spec or search for videos/slides/articles on this topic to get familiar with main OpenCL concepts/architecture/ideas.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> 2) Could you give me some examples of an open-source OpenCL implementation and update optimization pipeline?<br>
<br>
Sure, here you go (there might be more implementations, I’m just not aware of them):<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<ul style="margin-top:0cm" type="disc">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l1 level1 lfo4">POCL [5]<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l1 level1 lfo4">Intel graphics compute runtime and compiler [6] and [7]<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l1 level1 lfo4">ROCm [8]. I guess compiler sources are located in corresponding forks of llvm [9] and clang [10]<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l1 level1 lfo4">VC4CL [11]<o:p></o:p></li></ul>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Please note that each implementation targets specific device or set of devices from one or more particular vendors.<o:p></o:p></p>
<p class="MsoNormal">The most generic/portable one is POCL, I guess.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[1]: <a href="https://www.khronos.org/registry/OpenCL/specs/2.2/pdf/OpenCL_API.pdf">
https://www.khronos.org/registry/OpenCL/specs/2.2/pdf/OpenCL_API.pdf</a><o:p></o:p></p>
<p class="MsoNormal">[2]: <a href="https://www.youtube.com/watch?v=hUiX8rBcNzw">https://www.youtube.com/watch?v=hUiX8rBcNzw</a><o:p></o:p></p>
<p class="MsoNormal">[3]: <a href="https://www.fz-juelich.de/SharedDocs/Downloads/IAS/JSC/EN/slides/opencl/opencl-03-basics.pdf?__blob=publicationFile">
https://www.fz-juelich.de/SharedDocs/Downloads/IAS/JSC/EN/slides/opencl/opencl-03-basics.pdf?__blob=publicationFile</a><o:p></o:p></p>
<p class="MsoNormal">[4]: <a href="https://www.sciencedirect.com/topics/computer-science/opencl">
https://www.sciencedirect.com/topics/computer-science/opencl</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[5]: <a href="https://github.com/pocl/pocl">https://github.com/pocl/pocl</a><o:p></o:p></p>
<p class="MsoNormal">[6]: <a href="https://github.com/intel/compute-runtime">https://github.com/intel/compute-runtime</a><o:p></o:p></p>
<p class="MsoNormal">[7]: <a href="https://github.com/intel/intel-graphics-compiler">
https://github.com/intel/intel-graphics-compiler</a><o:p></o:p></p>
<p class="MsoNormal">[8]: <a href="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime">
https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime</a><o:p></o:p></p>
<p class="MsoNormal">[9]: <a href="https://github.com/RadeonOpenCompute/llvm">https://github.com/RadeonOpenCompute/llvm</a><o:p></o:p></p>
<p class="MsoNormal">[10]: <a href="https://github.com/RadeonOpenCompute/clang">https://github.com/RadeonOpenCompute/clang</a><o:p></o:p></p>
<p class="MsoNormal">[11]: <a href="https://github.com/doe300/VC4CL">https://github.com/doe300/VC4CL</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><a name="_____replyseparator"></a><b>From:</b> Enrique González <enrike.gonzalez.98@gmail.com>
<br>
<b>Sent:</b> Thursday, September 26, 2019 2:41 PM<br>
<b>To:</b> Sachkov, Alexey <alexey.sachkov@intel.com>; llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm-dev] Execute OpenCL<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hi Alexey,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Your reply has been a great help to me,your way of explain the different types of compilation is very detailed and easy to understand.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Even so, I have a couple of questions.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">1) What do yourefer by OpenCL RT?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">2) Could you give me some examples of an open-source OpenCL implementation and update optimization pipeline?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thank you in advance. Regards<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">El vie., 20 sept. 2019 a las 12:34, Sachkov, Alexey (<<a href="mailto:alexey.sachkov@intel.com">alexey.sachkov@intel.com</a>>) escribió:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi Enrique,<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">> First, I only want to compile a project and execute it to see how it works, specifically this one:
<a href="https://github.com/rsnemmen/OpenCL-examples/tree/master/add_numbers" target="_blank">
https://github.com/rsnemmen/OpenCL-examples/tree/master/add_numbers</a><br>
<br>
As I can see, it has a Makefile which you could use. Anyway, on Linux you need to do something like:<br>
<br>
<span style="font-family:Consolas">clang -std=c99 add_numbers.c -lOpenCL -I/path/to/folder/with/CL/cl.h</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Usually, libOpenCL.so and CL/cl.h are provided by OpenCL SDKs from HW/SW vendor, for example: [1], [2], [3], [4] and others [5]<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">But, you can also get them from KhronosGroup repos: OpenCL-ICD-Loader [6], OpenCL-Headers [7]<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">> I want to do that the .c file uses the .cl that i have compiled before with clang and i do not know how to do it.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">This is an interesting question. Basically, in OpenCL you can build your device program in a separate ways:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<ol start="1" type="1">
<li class="gmail-m-9120581935815487100msolistparagraph" style="mso-list:l2 level1 lfo1">
Use clCreateProgramFromSource + clBuildProgram: this is so-called “online” compilation, when your device code is written in OpenCL C and its compilation is performed in runtime (all stages like front-end, middle-end optimizations and back-end, i.e. codegen
 to native code)<o:p></o:p></li><li class="gmail-m-9120581935815487100msolistparagraph" style="mso-list:l2 level1 lfo1">
Use clCreateProgramWithBinary + clBuildProgram: this is so-called “offline” compilation, where you build your device code manually prior launching the app. Unfortunately, OpenCL spec doesn’t define binary format, i.e. it is implementation-defined. Usually each
 vendor provides so-called “offline compiler” tool which allows you to get device binary for your OpenCL code – the binary is not portable across different devices/vendors<o:p></o:p></li><li class="gmail-m-9120581935815487100msolistparagraph" style="mso-list:l2 level1 lfo1">
Use clCreateProgramWithIL + clBuildProgram: requires OpenCL 2.1 or cl_khr_il_program extension. Allows you to create program from SPIR-V. Basically, this is kind of combination of online and offline models: one the one side, you need to launch offline compiler
 to parse source code and get SPIR-V, on the other side, SPIR-V is an intermediate representation, i.e. partially-compiled program – that will save some runtime resources. Plus, SPIR-V is a standard and it is portable between devices/vendors.<o:p></o:p></li></ol>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Summarizing:<o:p></o:p></p>
<ul type="disc">
<li class="gmail-m-9120581935815487100msolistparagraph" style="mso-list:l0 level1 lfo2">
There are several OpenCL implementations (both open-source and closed-source) which are LLVM-based<o:p></o:p></li><li class="gmail-m-9120581935815487100msolistparagraph" style="mso-list:l0 level1 lfo2">
Not sure that a lot of them provide possibility to create OpenCL program from pure LLVM IR produced by clang<o:p></o:p></li></ul>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">If you want to optimize your OpenCL code by yourself you can do the following:<o:p></o:p></p>
<ul type="disc">
<li class="gmail-m-9120581935815487100msolistparagraph" style="mso-list:l3 level1 lfo3">
Try to understand binary format that is accepted by OpenCL runtime you are using: try to contact support/forums to check if you can pass already optimized LLVM BC there (BTW, not sure that this functionality is widely supported)<o:p></o:p></li><li class="gmail-m-9120581935815487100msolistparagraph" style="mso-list:l3 level1 lfo3">
Get LLVM IR from clang, then optimize it as you want, then convert it to SPIR-V and pass to OpenCL RT<o:p></o:p></li><li class="gmail-m-9120581935815487100msolistparagraph" style="mso-list:l3 level1 lfo3">
Find open-source OpenCL implementation and update optimization pipeline in there with you own modifications<o:p></o:p></li></ul>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Personally, I would go with the last option.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[1]:
<a href="https://software.intel.com/en-us/opencl-sdk" target="_blank">https://software.intel.com/en-us/opencl-sdk</a>
<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[2]:
<a href="https://developer.nvidia.com/opencl" target="_blank">https://developer.nvidia.com/opencl</a>
<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[3]:
<a href="https://github.com/GPUOpen-LibrariesAndSDKs/OCL-SDK/releases" target="_blank">
https://github.com/GPUOpen-LibrariesAndSDKs/OCL-SDK/releases</a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[4]:
<a href="https://developer.arm.com/solutions/graphics/apis/opencl" target="_blank">
https://developer.arm.com/solutions/graphics/apis/opencl</a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[5]:
<a href="https://www.iwocl.org/resources/opencl-implementations/" target="_blank">
https://www.iwocl.org/resources/opencl-implementations/</a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[6]:
<a href="https://github.com/KhronosGroup/OpenCL-ICD-Loader" target="_blank">https://github.com/KhronosGroup/OpenCL-ICD-Loader</a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">[7]:
<a href="https://github.com/KhronosGroup/OpenCL-Headers" target="_blank">https://github.com/KhronosGroup/OpenCL-Headers</a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><a name="m_-9120581935815487100______replyseparat"></a><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>>
<b>On Behalf Of </b>Enrique Gonzalez via llvm-dev<br>
<b>Sent:</b> Thursday, September 19, 2019 11:41 PM<br>
<b>To:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> [llvm-dev] Execute OpenCL<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Dear all,<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">After a huge amount of time trying to install LLVM and Clang i could finally do it, so now im trying to use this tools for generating a bytecode, then apply it modular optimizations
 and then generate an executable to test the result. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">First, I only want to compile a project and execute it to see how it works, specifically this one: <a href="https://github.com/rsnemmen/OpenCL-examples/tree/master/add_numbers" target="_blank">https://github.com/rsnemmen/OpenCL-examples/tree/master/add_numbers</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Which commands would you use?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I want to do that the .c file uses the .cl that i have compiled before with clang and i do not know how to do it.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thanks in advance.  <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>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<p class="MsoNormal">Un saludo<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">Enrique González<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>