<div dir="ltr">Hi,<br><div class="gmail_quote"><div dir="ltr"><div><br></div><div>I've been looking into making the spir target work with the latest version of clang.</div><div><br></div><div>Comparing the current version to this spir branch of clang</div><div><a href="https://github.com/KhronosGroup/SPIR" target="_blank">https://github.com/KhronosGroup/SPIR</a></div><div>I found these pieces missing that are necessary to generate confirming spir code:</div><div><br></div><div>1) the "<span style="color:rgb(0,0,0);white-space:pre-wrap">-cl-kernel-arg-info" option currently suppresses the generation of all kernel metadata when it should only omit the "</span><span style="color:rgb(0,0,0);white-space:pre-wrap">kernel_arg_name" name node</span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">2) The "</span><span style="color:rgb(0,0,0);white-space:pre-wrap">spir_kernel" calling convention needs to be set on kernel functions</span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">3) Additional spir metadata needs to be added to the generated module. Done by this code: </span><a href="https://github.com/KhronosGroup/SPIR/blob/spir_12/lib/CodeGen/CGSPIRMetadataAdder.cpp" target="_blank">https://github.com/KhronosGroup/SPIR/blob/spir_12/lib/CodeGen/CGSPIRMetadataAdder.cpp</a></div><div><br></div><div>4) An additional "<font face="Menlo"><span style="font-size:11px">cl-spir-compile-options" option is added to clang to allow options to be passed through in the SPIR metadata</span></font></div><div><font face="Menlo"><span style="font-size:11px"><br></span></font></div><div>Do anyone see any obstacles to checking in these pieces? or know why they haven't been committed already?</div><div><br></div><div>Thanks</div><div><br></div></div>
<br>----------<br><span><font color="#888">From: <b>Pekka Jääskeläinen</b> <span dir="ltr"><<a href="mailto:pekka.jaaskelainen@tut.fi" target="_blank">pekka.jaaskelainen@tut.fi</a>></span><br>Date: Tue, Nov 18, 2014 at 5:18 AM<br>To: Ribulous Barnulous <<a href="mailto:rnickb731@gmail.com" target="_blank">rnickb731@gmail.com</a>>, <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br></font><br></span><br>Hi,<span><br>
<br>
On 11/17/2014 03:48 AM, Ribulous Barnulous wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Do anyone see any obstacles to checking in these pieces? or know why they<br>
haven't been committed already?<br>
</blockquote>
<br></span>
I think the main problem is the fact that the SPIR format is fixed to<br>
the IR produced by certain LLVM versions. So, if later LLVM versions<br>
have changes in the IR output, it might not produce valid SPIR<br>
binaries anymore.<br>
<br>
SPIR 1.2 is fixed to LLVM 3.2 IR and SPIR 2.0 to LLVM 3.4.<br>
<br>
However, if there are other non-SPIR-specific features in that branch,<br>
I hope Someone breaks them up in smaller patches so they get reviewed and<br>
upstreamed.<span><font color="#888888"><br>
<br>
-- <br>
Pekka<br>
</font></span><br>----------<br><span><font color="#888">From: <b>Ribulous Barnulous</b> <span dir="ltr"><<a href="mailto:rnickb731@gmail.com" target="_blank">rnickb731@gmail.com</a>></span><br>Date: Thu, Nov 20, 2014 at 1:01 AM<br>To: Pekka Jääskeläinen <<a href="mailto:pekka.jaaskelainen@tut.fi" target="_blank">pekka.jaaskelainen@tut.fi</a>><br></font><br></span><br><div dir="ltr">Hey Pekka,<div><br></div><div>LLVM already has some of the SPIR code checked in. Running</div><div><br></div><div><span style="font-family:Menlo;font-size:11px">clang -x cl -fno-builtin -target spir -c -emit-llvm</span><span style="font-family:Menlo;font-size:11px"> <cl-file></span><br></div><div><br></div><div>comes close to generated correct SPIR code. If SPIR code's going to be included at all, shouldn't the other missing pieces be checked in?</div><div><br></div><div>Even if the official version of SPIR is pegged to a particular version of LLVM, I think adding the functionality to make the SPIR annotations and calling conventions in the IR code would still be very useful. Implementations and future versions of SPIR will track the LLVM IR versions; so if changes were introduced that made the IR incompatible with the latest version of SPIR, it's likely that many implementations would support it anyways and it would surely be adopted into the next iteration of the SPIR standard to eventually be officially supported.</div><div><br></div><div>Under this view, if you wanted to generate SPIR, you'd tell clang the SPIR and OCL version; it would add SPIR annotations and set calling conventions but wouldn't guarantee that the IR was compatible with the SPIR standard. </div><div><br></div><div>This would make a lot more sense to me than having a completely separate fork that only makes minor modifications to the IR for the SPIR target, and has to be continually synced up.</div><div><br></div><div>Thanks</div></div><div></div><br>----------<br><span><font color="#888">From: <b>Pekka Jääskeläinen</b> <span dir="ltr"><<a href="mailto:pekka.jaaskelainen@tut.fi" target="_blank">pekka.jaaskelainen@tut.fi</a>></span><br>Date: Thu, Nov 20, 2014 at 9:52 AM<br>To: Ribulous Barnulous <<a href="mailto:rnickb731@gmail.com" target="_blank">rnickb731@gmail.com</a>><br></font><br></span><br>Hi,<span><br>
<br>
On 11/20/2014 08:01 AM, Ribulous Barnulous wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This would make a lot more sense to me than having a completely separate<br>
fork that only makes minor modifications to the IR for the SPIR target,<br>
and has to be continually synced up.<br>
</blockquote>
<br></span>
Right. In case the LLVM IR of the later versions is<br>
a superset of the previous versions, one can even try and add<br>
a switch that (tries to) restrict the output to the subset so<br>
it's SPIR compatible.<br>
<br>
So, if someone breaks up the patches and upstreams them, I can<br>
try to help at least by reviewing them (with my limited Clang<br>
knowledge).<span><font color="#888888"><br>
<br>
-- <br>
--Pekka Jääskeläinen<br>
<br>
</font></span><br>----------<br><span><font color="#888">From: <b>Ribulous Barnulous</b> <span dir="ltr"><<a href="mailto:rnickb731@gmail.com" target="_blank">rnickb731@gmail.com</a>></span><br>Date: Fri, Nov 21, 2014 at 1:02 AM<br>To: Pekka Jääskeläinen <<a href="mailto:pekka.jaaskelainen@tut.fi" target="_blank">pekka.jaaskelainen@tut.fi</a>><br></font><br></span><br><div dir="ltr">Thanks Pekka.<div><br></div><div> I attached two small patches to these issue reports:<div><br></div><div><a href="http://llvm.org/bugs/show_bug.cgi?id=21554" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=21554</a> -- patch to set the SPIR calling convention</div><div><br></div><div><a href="http://llvm.org/bugs/show_bug.cgi?id=21555" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=21555</a> -- patch to fix behavior of "-cl-kernel-arg-info option" to follow current spec: <a href="https://www.khronos.org/registry/spir/specs/spir_spec-1.2.pdf" target="_blank">https://www.khronos.org/registry/spir/specs/spir_spec-1.2.pdf</a></div><div><div><br></div><div>Let me know if you'd rather receive them through a different medium or if you want me to make any changes to them. </div><div><br></div><div>And I'll work on putting together some patches for the other parts.</div><div><br></div></div></div></div><div></div><br>----------<br><span><font color="#888">From: <b>Pekka Jääskeläinen</b> <span dir="ltr"><<a href="mailto:pekka.jaaskelainen@tut.fi" target="_blank">pekka.jaaskelainen@tut.fi</a>></span><br>Date: Fri, Nov 21, 2014 at 4:34 AM<br>To: Ribulous Barnulous <<a href="mailto:rnickb731@gmail.com" target="_blank">rnickb731@gmail.com</a>><br></font><br></span><br>Thanks,<br>
<br>
Can you post these to the cfe-dev list as well?<span><br></span><br>----------<br><span><font color="#888">From: <b>Ribulous Barnulous</b> <span dir="ltr"><<a href="mailto:rnickb731@gmail.com" target="_blank">rnickb731@gmail.com</a>></span><br>Date: Fri, Nov 21, 2014 at 11:18 PM<br>To: Pekka Jääskeläinen <<a href="mailto:pekka.jaaskelainen@tut.fi" target="_blank">pekka.jaaskelainen@tut.fi</a>><br></font><br></span><br><div dir="ltr">Yep.<div><br></div><div>They're attached.</div></div><div></div><br></div><br></div>