<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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>
</body>
</html>