[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] [llvm-dev] [RfC] A proposal of adding SPIR-V Toolchain in Clang
From:       Anastasia Stulova via cfe-dev <cfe-dev () lists ! llvm ! org>
Date:       2018-10-29 16:54:25
Message-ID: DB6PR0802MB2614DC92C421D81BBA3F8B00F0F30 () DB6PR0802MB2614 ! eurprd08 ! prod ! outlook ! com
[Download RAW message or body]

Thanks to everyone who participated in the Round Table discussion during th=
e LLVM Dev Meeting. Below is a brief summary.


First of all, a number of concerns were raised again regarding the backend =
implementation. The implementation effort of developing the backend is sign=
ificant and it's not clear to the SPIR-V developers if it results in the co=
mparable or better quality generated binaries compared to the current solut=
ion using the IR translation [1]. This has been discussed earlier on llvm-d=
ev as well [2], [3]. Another big concern was about the code duplication bet=
ween the translation from/to SPIR-V that would have to be separated out int=
o different flows.


The opinion of the developers attending the meeting was that we would prefe=
r to continue using the translation tool [1]; but we would still like to im=
prove the integration with LLVM as much as possible. There are a number of =
options that we have discussed briefly: external translator tool invocation=
 via fork of Clang, adding SPIR-V triple w/o any external tool, adding tran=
slator as an official tool to the LLVM project (suggested earlier [4]).


To address concerns and suggestions from the LLVM community on this thread =
I am planning to look at the following topics with some help from Neil Hick=
ey (in CC), before getting back with an updated proposal:


A. We will prototype a SPIR-V backend using the Global ISel in order to und=
erstand further the development effort and the quality of the code produced=
 by the backend (+ potentially compilation time) compared to the simple IR =
translation.


B. I will look at how external tools are currently used with LLVM and try t=
o suggest reasonable flow/process for the translator tool [1] that we would=
 like to integrate at least for the purpose of importing SPIR-V modules to =
LLVM [5].


Please, let me know if you would like to be involved with any of the invest=
igation activities I am planning or if you have any additional information =
that should be considered.

Cheers,
Anastasia

[1] https://github.com/KhronosGroup/SPIRV-LLVM-Translator
[2] http://lists.llvm.org/pipermail/llvm-dev/2017-May/112651.html
[3] http://lists.llvm.org/pipermail/llvm-dev/2017-May/112550.html

[4] https://lists.llvm.org/pipermail/llvm-dev/2018-February/121317.html

<https://github.com/KhronosGroup/SPIRV-LLVM-Translator>[5] <https://github.=
com/KhronosGroup/SPIRV-LLVM-Translator/wiki/SPIRV-Toolchain-for-Clang> http=
://lists.llvm.org/pipermail/cfe-dev/2018-September/059368.html


________________________________
From: llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Anastasia Stu=
lova via llvm-dev <llvm-dev@lists.llvm.org>
Sent: 17 September 2018 10:00
To: Nicholas Wilson
Cc: llvm-dev@lists.llvm.org; nd; clang developer list; Brian.Sumner@amd.com
Subject: Re: [llvm-dev] [RfC] A proposal of adding SPIR-V Toolchain in Clan=
g


Hi Nicholas,


A number of developers that are interested in the SPIR-V support will be at=
tending the conference. Sounds good to have a round table. It is important =
to involve relevant developers outside of Khronos that are affected too!


So far there are the following topics to address:

- Generation of SPIR-V binaries in LLVM.

- Importing and linking SPIR-V libraries/binaries.

- Generic target in Clang for the next OpenCL C and C++ features.

- Use of external tools.



My only concern now is about the OpenCL C++ implementation that might be st=
alled while we are waiting for the decisions. But it's probably important t=
o make sure we are going the right route to fit all requirements.


Anastasia

________________________________
From: Nicholas Wilson <iamthewilsonator@hotmail.com>
Sent: 17 September 2018 04:42:32
To: Anastasia Stulova
Cc: clang developer list; llvm-dev@lists.llvm.org; nd; Brian.Sumner@amd.com
Subject: Re: [llvm-dev] [RfC] A proposal of adding SPIR-V Toolchain in Clan=
g

Given the amount of discussion that has gone on (and in past threads) and t=
he size of the proposal, should we do a roundtable at the dev meeting in Oc=
tober to make sure everyone is on the same page going forward? I would come=
 along for that if there is sufficient participation from Khronos to make g=
ood progress.

Nic


> On 10 Sep 2018, at 11:10 pm, Anastasia Stulova via llvm-dev <llvm-dev@lis=
ts.llvm.org> wrote:
>
> Hello,
>
> Since 2015 Khronos has switched to the new portable intermediate format S=
PIR-V, which has replaced the original SPIR. The advantage is that it offer=
s higher portability across different toolchains. There was a talk about it=
 at a Dev Meeting:
> http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#17
>
> LLVM currently only supports SPIR format for OpenCL in Clang. Several Khr=
onos vendors (ARM, AMD, Intel, Xilinx, Codeplay and others) are interested =
in adding support for SPIR-V, which should gradually replace the old SPIR o=
nce products are no longer shipped with the old format. Here is the detaile=
d description:
> https://github.com/KhronosGroup/SPIRV-LLVM-Translator/wiki/SPIRV-Toolchai=
n-for-Clang
>
> To summarize, the idea is to add a SPIR-V target triple to Clang that can=
 be used to generate a SPIR-V binary for OpenCL code. There was a separate =
thread regarding generation of SPIR-V binary and the community suggested th=
at a translator from LLVM IR to SPIR-V can be used as an external tool, cal=
led llvm-spirv. This can be invoked similar to such tools as ptxas and fatb=
inary for the CUDA toolchain:
> http://lists.llvm.org/pipermail/llvm-dev/2018-February/121440.html
>
> An example of how Clang can be used to target SPIR-V:
>
> clang -c test.cl -target spirv[32|64]-unknown-unknown -o test.spv
>
> This will result in the following Clang actions:
>
> (1) clang -cc1 -triple spirv[32|64]-unknown-unknown test.cl -emit-llvm-bc=
 -o test.bc
>
> (2) llvm-spirv test.bc -o test.spv
>
> SPIR-V generation is essential for completion of OpenCL C++ support in Cl=
ang, as newer OpenCL standards require frontend invocation to be performed =
offline, producing the SPIR-V binary that can be then loaded at application=
 execution time. Besides that, it will also allow Clang to be used as a com=
plete standalone tool to generate portable binaries that can then be consum=
ed by different proprietary toolchains. In addition, this will open a path =
to the LLVM backends for various languages and frontends that already gener=
ate SPIR-V.
>
> A more detailed explanation of the complete design proposal is given in t=
his Wiki page:
> https://github.com/KhronosGroup/SPIRV-LLVM-Translator/wiki/SPIRV-Toolchai=
n-for-Clang
>
> Looking forward to any feedback about the proposal or possible collaborat=
ions,
>
> Thanks!
>
> Anastasia
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} \
--></style> </head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); \
font-family:Calibri,Helvetica,sans-serif,&quot;EmojiFont&quot;,&quot;Apple Color \
Emoji&quot;,&quot;Segoe UI Emoji&quot;,NotoColorEmoji,&quot;Segoe UI \
Symbol&quot;,&quot;Android Emoji&quot;,EmojiSymbols"> <p style="margin-top:0; \
margin-bottom:0">Thanks to everyone who participated in the Round Table discussion \
<span>during the LLVM Dev Meeting</span>. Below is a brief summary.</p> <p \
style="margin-top:0; margin-bottom:0"><br> </p>
<p style="margin-top:0; margin-bottom:0">First of all, a number of concerns were \
raised again regarding the backend implementation. The implementation effort of \
developing the backend is significant and it's not clear to the SPIR-V developers if \
it results  in the comparable or better quality generated binaries compared to the \
current solution using the IR translation [1]. This has been discussed earlier on \
llvm-dev as well [2], [3]. Another big concern was about the code duplication between \
the translation from/to  SPIR-V that would have to be separated out into different \
flows.</p> <p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">The opinion of the developers attending the \
meeting was that we would prefer to continue using the translation tool [1]; but we \
would still like to improve the integration with LLVM as much as possible. There are \
a number  of options that we have discussed briefly: external translator tool \
invocation via fork of Clang, adding SPIR-V triple w/o any external tool, adding \
translator as an official tool to the LLVM project (suggested earlier [4]).</p> <p \
style="margin-top:0; margin-bottom:0"><br> </p>
<p style="margin-top:0; margin-bottom:0">To address concerns and suggestions from the \
LLVM community on this thread I am planning to look at the following topics with some \
help from Neil Hickey (in CC), before getting back with an updated proposal:</p> <p \
style="margin-top:0; margin-bottom:0"><br> </p>
<p style="margin-top:0; margin-bottom:0">A. <span>We will prototype a SPIR-V \
backend</span> using the Global ISel in order to understand further the development \
effort and the quality of the code produced by the backend (&#43; potentially \
compilation time) compared  to the simple IR translation.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">B. I will look at how external tools are \
currently used with LLVM and try to suggest reasonable flow/process for the \
translator tool [1] that we would like to integrate at least for the purpose of \
importing SPIR-V modules  to LLVM [5]. <br>
</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Please, let me know if you would like to be \
involved with any of the investigation activities I am planning or if you have any \
additional information that should be considered.<br> </p>
<p style="margin-top:0; margin-bottom:0"></p>
<div><br>
Cheers,<br>
Anastasia<br>
<br>
<div>[1] <a href="https://github.com/KhronosGroup/SPIRV-LLVM-Translator" \
class="OWAAutoLink"> https://github.com/KhronosGroup/SPIRV-LLVM-Translator</a></div>
[2] <a href="http://lists.llvm.org/pipermail/llvm-dev/2017-May/112651.html" \
class="OWAAutoLink"> \
http://lists.llvm.org/pipermail/llvm-dev/2017-May/112651.html</a><span><br> [3] <a \
href="http://lists.llvm.org/pipermail/llvm-dev/2017-May/112550.html" \
class="OWAAutoLink"> \
http://lists.llvm.org/pipermail/llvm-dev/2017-May/112550.html</a></span><br> \
<span></span></div> <p></p>
<p style="margin-top:0; margin-bottom:0"><span>[4] <a \
href="https://lists.llvm.org/pipermail/llvm-dev/2018-February/121317.html" \
class="OWAAutoLink"> \
https://lists.llvm.org/pipermail/llvm-dev/2018-February/121317.html</a></span><br> \
</p> <p style="margin-top:0; margin-bottom:0"><a \
href="https://github.com/KhronosGroup/SPIRV-LLVM-Translator" \
class="OWAAutoLink"></a>[5]&nbsp;<a \
href="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/wiki/SPIRV-Toolchain-for-Clang" \
class="OWAAutoLink"></a><a \
href="http://lists.llvm.org/pipermail/cfe-dev/2018-September/059368.html" \
class="OWAAutoLink">http://lists.llvm.org/pipermail/cfe-dev/2018-September/059368.html</a><br>
 </p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<div style="color:rgb(0,0,0)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" \
face="Calibri, sans-serif"><b>From:</b> llvm-dev \
&lt;llvm-dev-bounces@lists.llvm.org&gt; on behalf of Anastasia Stulova via llvm-dev \
&lt;llvm-dev@lists.llvm.org&gt;<br> <b>Sent:</b> 17 September 2018 10:00<br>
<b>To:</b> Nicholas Wilson<br>
<b>Cc:</b> llvm-dev@lists.llvm.org; nd; clang developer list; \
Brian.Sumner@amd.com<br> <b>Subject:</b> Re: [llvm-dev] [RfC] A proposal of adding \
SPIR-V Toolchain in Clang</font> <div>&nbsp;</div>
</div>
<meta content="text/html; charset=iso-8859-1">
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); \
font-family:Calibri,Helvetica,sans-serif,&quot;EmojiFont&quot;,&quot;Apple Color \
Emoji&quot;,&quot;Segoe UI Emoji&quot;,NotoColorEmoji,&quot;Segoe UI \
Symbol&quot;,&quot;Android Emoji&quot;,EmojiSymbols"> <div \
id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); \
font-family:Calibri,Helvetica,sans-serif,&quot;EmojiFont&quot;,&quot;Apple Color \
Emoji&quot;,&quot;Segoe UI Emoji&quot;,NotoColorEmoji,&quot;Segoe UI \
Symbol&quot;,&quot;Android Emoji&quot;,EmojiSymbols"> <p style="margin-top:0; \
margin-bottom:0">Hi Nicholas,</p> <p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">A number of developers that are interested \
in the SPIR-V support will be attending the conference. Sounds good to have a round \
table. It is important to involve relevant developers outside of Khronos that are \
affected  too!</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">So far there are the following topics to \
address:</p> <p style="margin-top:0; margin-bottom:0">- Generation of SPIR-V binaries \
in LLVM.</p> <p style="margin-top:0; margin-bottom:0">- Importing and linking SPIR-V \
libraries/binaries.</p> <p style="margin-top:0; margin-bottom:0">- Generic target in \
Clang for the next OpenCL C and C&#43;&#43; features.</p> <p style="margin-top:0; \
margin-bottom:0">- Use of external tools.</p> <p style="margin-top:0; \
margin-bottom:0"><br> </p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">My only concern now is about the OpenCL \
C&#43;&#43; implementation that might be stalled while we are waiting for the \
decisions. But it's probably important to make sure we are going the right route to \
fit all requirements.<br> </p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Anastasia<br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" \
face="Calibri, sans-serif"><b>From:</b> Nicholas Wilson \
&lt;iamthewilsonator@hotmail.com&gt;<br> <b>Sent:</b> 17 September 2018 04:42:32<br>
<b>To:</b> Anastasia Stulova<br>
<b>Cc:</b> clang developer list; llvm-dev@lists.llvm.org; nd; \
Brian.Sumner@amd.com<br> <b>Subject:</b> Re: [llvm-dev] [RfC] A proposal of adding \
SPIR-V Toolchain in Clang</font> <div>&nbsp;</div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_PlainText">Given the amount of discussion that has gone on (and in past \
threads) and the size of the proposal, should we do a roundtable at the dev meeting \
in October to make sure everyone is on the same page going forward? I would come \
along  for that if there is sufficient participation from Khronos to make good \
progress.<br> <br>
Nic<br>
<br>
<br>
&gt; On 10 Sep 2018, at 11:10 pm, Anastasia Stulova via llvm-dev \
&lt;llvm-dev@lists.llvm.org&gt; wrote:<br> &gt; <br>
&gt; Hello,<br>
&gt; <br>
&gt; Since 2015 Khronos has switched to the new portable intermediate format SPIR-V, \
which has replaced the original SPIR. The advantage is that it offers higher \
portability across different toolchains. There was a talk about it at a Dev \
Meeting:<br> &gt; <a \
href="http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#17"> \
http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#17</a><br> &gt; \
<br> &gt; LLVM currently only supports SPIR format for OpenCL in Clang. Several \
Khronos vendors (ARM, AMD, Intel, Xilinx, Codeplay and others) are interested in \
adding support for SPIR-V, which should gradually replace the old SPIR once products \
are no longer shipped  with the old format. Here is the detailed description:<br>
&gt; <a href="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/wiki/SPIRV-Toolchain-for-Clang">
 https://github.com/KhronosGroup/SPIRV-LLVM-Translator/wiki/SPIRV-Toolchain-for-Clang</a><br>
 &gt; <br>
&gt; To summarize, the idea is to add a SPIR-V target triple to Clang that can be \
used to generate a SPIR-V binary for OpenCL code. There was a separate thread \
regarding generation of SPIR-V binary and the community suggested that a translator \
from LLVM IR to  SPIR-V can be used as an external tool, called llvm-spirv. This can \
be invoked similar to such tools as ptxas and fatbinary for the CUDA toolchain:<br> \
&gt; <a href="http://lists.llvm.org/pipermail/llvm-dev/2018-February/121440.html">http://lists.llvm.org/pipermail/llvm-dev/2018-February/121440.html</a><br>
 &gt; <br>
&gt; An example of how Clang can be used to target SPIR-V:<br>
&gt; <br>
&gt; clang -c test.cl -target spirv[32|64]-unknown-unknown -o test.spv<br>
&gt; <br>
&gt; This will result in the following Clang actions:<br>
&gt; <br>
&gt; (1) clang -cc1 -triple spirv[32|64]-unknown-unknown test.cl -emit-llvm-bc -o \
test.bc<br> &gt; <br>
&gt; (2) llvm-spirv test.bc -o test.spv<br>
&gt; <br>
&gt; SPIR-V generation is essential for completion of OpenCL C&#43;&#43; support in \
Clang, as newer OpenCL standards require frontend invocation to be performed offline, \
producing the SPIR-V binary that can be then loaded at application execution time. \
Besides that, it  will also allow Clang to be used as a complete standalone tool to \
generate portable binaries that can then be consumed by different proprietary \
toolchains. In addition, this will open a path to the LLVM backends for various \
languages and frontends that already  generate SPIR-V.<br>
&gt; <br>
&gt; A more detailed explanation of the complete design proposal is given in this \
Wiki page:<br> &gt; <a \
href="https://github.com/KhronosGroup/SPIRV-LLVM-Translator/wiki/SPIRV-Toolchain-for-Clang">
 https://github.com/KhronosGroup/SPIRV-LLVM-Translator/wiki/SPIRV-Toolchain-for-Clang</a><br>
 &gt; <br>
&gt; Looking forward to any feedback about the proposal or possible \
collaborations,<br> &gt; <br>
&gt; Thanks!<br>
&gt; <br>
&gt; Anastasia<br>
&gt; _______________________________________________<br>
&gt; LLVM Developers mailing list<br>
&gt; llvm-dev@lists.llvm.org<br>
&gt; <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
 <br>
</div>
</span></font></div>
</div>
</div>
</div>
</div>
</body>
</html>


[Attachment #4 (unknown)]

_______________________________________________
cfe-dev mailing list
cfe-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic