<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 22, 2018 at 5:45 AM Lorenz Braun via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
i just found out that i can use llc to also produce ptx assembly for <br>
GPUs. I noticed that the produced ptx assembly seems to be targeted at <br>
the gpu architecture sm_20 by default.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:verdana,sans-serif">This is currently the default CPU type for NVPTX back-end.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Is there a way to explicitly demand different or additional target <br>
architectures like sm_30 for example?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:verdana,sans-serif">It works the same way as for the other back-ends. You specify the CPU variant with -mcpu=. E.g. for sm_30 you should use <span style="font-family:Arial,Helvetica,sans-serif">-mcpu=sm_30</span></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
When i compile a cuda kernel with gpu arch. sm_30 using clang++ the <br>
.target directive in the ptx assembly will be set to sm_30. However when <br>
i save the bitcode of the same compilation and hand it to llc the <br>
.target directive is sm_20. There is an attribute in the bitcode that <br>
say "target-cpu"="sm_30". The information that sm_30 is required is <br>
still there. </blockquote><div><br></div><div><div class="gmail_default" style="font-family:verdana,sans-serif">It's a *function* attribute which, generally speaking, can't be used as the default for the whole module. It also does not do much in NVPTX back-end. Eventually it will be used to enforce that -mcpu=XXX is the same or higher than the all target-cpu attributes in a module. This is one of the areas where NVPTX can't implement what the attribute was intended to do -- target different CPU variants within the same module. It's doable on x86 where the same ISA can represent instructions for different CPU variants, but can't be done in PTX which requires everything in the module to be for the same GPU.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><span style="font-family:Arial,Helvetica,sans-serif"> </span><br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I can imagine that llc might not process this information. Could this be a bug?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:verdana,sans-serif">Not really. It's more of a feature in clang/llvm which NVPTX back-end can't implement.</div><br></div><div><div class="gmail_default" style="font-family:verdana,sans-serif">--Artem</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I am currently using llvm 7.0 and i can provide the bitcode if anyone <br>
wants to reproduce the problem.<br>
<br>
Best regards<br>
Lorenz<br>
<br>
-- <br>
Lorenz Braun<br>
Research Associate<br>
Institute of Computer Engineering (ZITI)<br>
INF 368<br>
Raum 528<br>
69120 Heidelberg<br>
<br>
Phone: +49 6221 54-16441<br>
<a href="mailto:lorenz.braun@ziti.uni-heidelberg.de" target="_blank">lorenz.braun@ziti.uni-heidelberg.de</a><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">--Artem Belevich</div></div></div></div>