<br><br><div class="gmail_quote">On Wed, Apr 4, 2012 at 4:49 AM, Tobias Grosser <span dir="ltr"><<a href="mailto:tobias@grosser.es">tobias@grosser.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 04/03/2012 03:13 PM, Hongbin Zheng wrote:<br>
> Hi Yabin,<br>
><br>
> Instead of compile the LLVM IR to PTX asm string in a ScopPass, you<br>
> can also the improve llc/lli or create new tools to support the code<br>
> generation for Heterogeneous platforms[1], i.e. generate code for more<br>
> than one target architecture at the same time. Something like this is<br>
> not very complicated and had been implemented[2,3] by some people, but<br>
> not available in LLVM mainstream. Implement this could make your GPU<br>
> project more complete.<br>
<br>
</div>I agree with ether that we should ensure as much work as possible is<br>
done within generic, not Polly specific code.<br></blockquote><div><br></div><div>Right, this has the potential to impact more people that the users of Polly. By moving as much as possible to generic LLVM, that infrastructure can be leveraged by people doing work outside of the polyhedral model.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
In terms of heterogeneous code generation the approach Yabin proposed<br>
seems to work, but we should discuss other approaches. For the moment,<br>
I believe his proposal is very similar the model of OpenCL and CUDA. He<br>
splits the code into host and kernel code. The host code is directly<br>
compiled to machine code by the existing tools (clang/llc). The kernel<br>
code is stored as a string and only at execution time it is compiled to<br>
platform specific code.<br></blockquote><div><br></div><div>Depending on your target, that may be the only way.  If your target is OpenCL-compatible accelerators, then your only portable option is save the kernel code as OpenCL text and let the driver JIT compiler it at run-time.  Any other approach is not guaranteed to be compatible across platforms or even driver versions.</div>
<div><br></div><div>In this case, the target is the CUDA Driver API, so you're free to pass along any valid PTX assembly.  In this case, you still pass the PTX code as a string to the driver, which JIT compiles it to actual GPU device code at run-time.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Are there any other approaches that could be taken? What specific<br>
heterogeneous platform support would be needed. At the moment, it seems<br>
to me we actually do not need too much additional support.<br></blockquote><div><br></div><div>I could see this working without any additional support, if needed.  It seems like this proposal is dealing with LLVM IR -> LLVM IR code generation, so the only thing that is really needed is a way to split the IR into multiple separate IRs (one for host, and one for each accelerator target).  This does not really need any supporting infrastructure, as you could imagine an opt pass processing the input IR and transforming it to the host IR, and emitting the device IR as a separate module.</div>
<div><br></div><div>Now if you're talking about source-level support for heterogeneous platforms (e.g. C++ AMP), then you would need to adapt Clang to support emission of multiple IR modules.  Basically, the AST would need to be split into host and device portions, and codegen'd appropriately.  I feel that is far beyond the scope of this proposal, though.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers<br>
Tobi<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div><br>