<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hi Alastair,</p>
<p><br>
</p>
<p>I thought that might be the case (after reading around a bit), but was unsure due to the documentation and wanted to be certain.</p>
<p><br>
</p>
<p>Thank you very much for the quick and useful reply, looks like I'll be using the <span style="color: rgb(33, 33, 33); font-size: 16px;">Khronos SPIR compiler for all my SPIR needs then. </span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 16px;"><br>
</span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 16px;">Best Regards,</span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 16px;">Andrew Gozillon</span></p>
</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> Alastair Murray <alastair.murray@codeplay.com><br>
<b>Sent:</b> 08 March 2017 17:51:34<br>
<b>To:</b> Andrew Gozillon<br>
<b>Cc:</b> cfe-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [cfe-dev] Question on Clang OpenCL to SPIR Compilation</font>
<div> </div>
</div>
<div>
<p>Hi Andrew,<br>
</p>
<br>
<div class="moz-cite-prefix">On 08/03/17 17:07, Andrew Gozillon via cfe-dev wrote:<br>
</div>
<blockquote cite="mid:DB3PR01MB0748F5196EE91DEA2154D077A82E0@DB3PR01MB0748.eurprd01.prod.exchangelabs.com" type="cite">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hi guys,</p>
<p><br>
</p>
<p>I've been trying to get Clang 5.0 to compile a very simple OpenCL kernel example to SPIR (1.2) so that I can run it through another program that basically loads the SPIR binary and executes it. </p>
<p><br>
</p>
<p>However I've been having some issues in that the program loads up the binary fine and executes it getting the wrong result. Now I don't believe this is an issue with the program that loads the binary or the OpenCL kernel itself for a couple of reasons 1)
 Is that I can compile the OpenCL kernel to SPIR using the Intel Offline Compiler and the Khronos SPIR compiler (based off of Clang/LLVM 3.3) and the returned SPIR binary will run through the program and output as expected and 2) I can just run the OpenCL code
 through it and output the compiled binary and then run that binary back through and get the correct results.  </p>
<p><span style="font-size: 12pt;">  </span></p>
<p>So at the moment I'm unsure if this is to do with the compile command I'm giving to Clang is slightly off or if the output llvm from Clang 5.0 no longer supports SPIR 1.0/1.2 (although the Clang 5 documentation leads me to believe it does still support it)?</p>
</div>
</blockquote>
The bitcode emitted by a modern Clang is not strictly SPIR, even when setting the
<span style="font-size: 12pt;">spir64-unknown-unknown triple.  It is not intended to be SPIR either, i.e. this is not a bug.  LLVM IR has changed since the SPIR specification was written.  If you want to produce valid SPIR that an OpenCL driver will consume
 you should use something like the Khronos SPIR generator that you already mentioned.<br>
<br>
However, some drivers will actually consume bitcode like you are producing as if it were SPIR, but only up to the version of Clang/LLVM that there are built using (if they are built using Clang/LLVM).  So it is unlikely to work when producing bitcode from a
 tip Clang/LLVM, but may still work for something newer than 3.2.  This is because newer versions of LLVM can consume older bitcode files (SPIR), but cannot produce them.<br>
<br>
Regards,<br>
Alastair Murray.<br>
<br>
</span>
<blockquote cite="mid:DB3PR01MB0748F5196EE91DEA2154D077A82E0@DB3PR01MB0748.eurprd01.prod.exchangelabs.com" type="cite">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p><br>
</p>
<p>The compiler command I'm feeding to Clang at the moment is: </p>
<div>clang -cc1 -isystem $LIBCLC/generic/include -include clc/clc.h -Dcl_clang_storage_class_specifiers -<span style="font-size: 12pt;">triple spir64-unknown-unknown -x cl -cl-std=CL1.2 -emit-llvm -o $NAME.ll $NAME.cl</span></div>
<div><span style="font-size: 12pt;"><br>
</span></div>
<div><span style="font-size: 12pt;">Although I've tried a number of variations from the documentation with no luck.</span></div>
<p><br>
</p>
<p>Thank you very much for your time, and help with this matter.</p>
<p><br>
</p>
<p>Best Regards,</p>
<p>Andrew Gozillon</p>
</div>
<br>
<br>
Please consider the environment and think before you print. <br>
<br>
The University of the West of Scotland is a registered Scottish charity. Charity number SC002520.
<br>
<br>
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other
 party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.
<br>
<br>
Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the University of the West of Scotland.
<br>
<br>
As a public body, the University of the West of Scotland may be required to make available emails as well as other written forms of information as a result of a request made under the Freedom of Information (Scotland) Act 2002.
<br>
<fieldset class="mimeAttachmentHeader"></fieldset> <br>
<pre wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">-- 
Alastair Murray
Senior Software Engineer, Compilers
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St., Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a class="moz-txt-link-freetext" href="http://www.codeplay.com">http://www.codeplay.com</a>
Twitter: <a class="moz-txt-link-freetext" href="https://twitter.com/codeplaysoft">https://twitter.com/codeplaysoft</a></pre>
</div>
<br>
<br>
Please consider the environment and think before you print. <br>
<br>
The University of the West of Scotland is a registered Scottish charity. Charity number SC002520.
<br>
<br>
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other
 party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.
<br>
<br>
Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the University of the West of Scotland.
<br>
<br>
As a public body, the University of the West of Scotland may be required to make available emails as well as other written forms of information as a result of a request made under the Freedom of Information (Scotland) Act 2002.
</body>
</html>