<div class="gmail_quote">On Mon, Apr 2, 2012 at 7:16 AM, Yabin Hu <span dir="ltr"><<a href="mailto:yabin.hwu@gmail.com">yabin.hwu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,
<div><br></div><div>I am a phd student from Huazhong University of Sci&Tech, China. The following is my GSoC 2012 proposal.</div><div>Comments are welcome!</div><div><br></div><div><b>Title: Automatic GPGPU Code Generation for LLVM</b><br>


<br><b>Abstract</b></div><div>
<span style="font-family:'AR PL UKai CN';font-size:medium"><span><span style="vertical-align:baseline;font-variant:normal;font-style:normal;font-size:15px;white-space:pre-wrap;text-decoration:none;font-family:'Times New Roman';font-weight:normal">Very often, manually developing an GPGPU application is a time-consuming, complex, error-prone and </span><span style="vertical-align:baseline;font-variant:normal;font-size:15px;white-space:pre-wrap;text-decoration:none;font-family:'Times New Roman'">iterative</span><span style="vertical-align:baseline;font-variant:normal;font-style:normal;font-size:15px;white-space:pre-wrap;text-decoration:none;font-family:'Times New Roman';font-weight:normal"> process. </span></span></span>In this project, I propose to build an automatic GPGPU code generation framework for LLVM, based on two successful LLVM (sub-)projects - Polly and PTX backend. This can be very useful to ease the burden of the long learning curve of various GPU programming model. </div>

<div><br><b>Motivation</b><br>With the broad proliferation of GPU computing, it is very important to provide an easy and automatic tool to develop or port the applications to GPU for normal developers, especially for those domain experts who want to harness the huge computing power of GPU. Polly has implemented many transformations, such as tiling, auto-vectorization and openmp code generation. With the help of LLVM's PTX backend, I plan to extend Polly with the feature of GPGPU code generation.</div>
</blockquote><div><br></div><div>Very interesting!  I'm quite familiar with Muthu's work, and putting that into LLVM would be great.  If done right, it could apply to any heterogeneous systems, including AMD GPUs.</div>
<div><br></div><div>As the maintainer and primary developer on the PTX back-end, please feel free to contact me with any issues/suggestions you have regarding the PTX back-end!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div style="background-color:transparent"><br></div><br><b>Project Detail</b><br><span>In this project, we target various parallel loops which can be described by Polly's polyhedral model. We first translated the selected SCoPs (Static Control Parts) into 4-depth loops with Polly's schedule optimization. Then we extract the loop body (or inner non-parallel loops) into a LLVM sub-function, tagged with PTX_Kernel or PTX_Device call convention. After that, we use PTX backend to translate the subfunctions into a string of the corresponding PTX codes. Finally, we provide an runtime library to generate the executable program.</span></div>
</blockquote><div><br></div><div>I'm a bit confused by the wording here.  What do you mean by 'LLVM sub-function?'  I'm assuming you mean extracting the relevant code into a separate function, but I would just use the word 'function'.</div>
<div><br></div><div>And what do you mean by a run-time library to generate the executable program?  Are you proposing to side-step the LLVM code generator LLC?  It seems like a reasonable approach would be to write an LLVM pass (or set of passes) that takes as input a single IR file, and produces two: (1) the GPU kernel/device code, and (2) the non-translatable IR with GPU code replaced by appropriate CUDA Driver API calls.  Then, both of these can pass through the opt/llc tools with the appropriate selection for optimization passes and target back-end.</div>
<div><br></div><div>This way, you could fairly easily create a GPGPU compiler by writing a simple wrapper around Clang (or better yet, improve Clang to support multiple targets simultaneously!)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><span><br></span></div><div><span>There are three key challenges in this project here.</span></div><div>1. How to get the optimal execution configure of GPU codes.</div><div>The execution configure is essential to the performance of the GPU codes. It is limited by many factors, including hardware, source codes, register usage, local store (device) usage, original memory access patterns and so on. We must take all the staff into consideration.</div>

<div><br></div><div>2. How to automatically insert the synchronization codes.</div><div>This is very important to preserve the original semantics. We must detect where we need insert them correctly.</div><div><br></div><div>

3.      How to automatically generate the memory copy operation between host and device.</div><div>We must transport the input data to GPU and copy the results back. Fortunately, Polly has implemented a very expressive way to describe memory access.</div>

<div><b><br></b></div><div><b>Timeline</b></div><div>May 21 ~ June 3 preliminary code generation for 1-d and 2d parallel loops.</div><div>June 4 ~ June 11 code generation for parallel loops with non-parallel inner loops.</div>

<div>June 11 ~ June 24 automatic memory copy insertions.</div><div>June 25 ~ July 8 auto-tuning for GPU execution configuration.</div><div>July 9 ~ July 15 Midterm evaluation and writing documents.</div><div>July 16 ~ July 22 automatic synchronization insertion.</div>

<div>July 23 ~ August 3 test on polybench benchmarks.</div><div><span style="font-weight:normal">August 4 ~ August 12 summarize and complete the final documents.<br><font color="#222222" face="arial, helvetica, sans-serif"><span style="border-collapse:collapse;font-size:14px"><br>

</span></font></span></div><div><b><br></b></div><div><b>Project experience</b></div><div>I participated in several projects related to binary translation (optimization) and run-time system. And I implemented a frontend for numerical computing languages like octave/matlab, following the style of clang. Recently, I work very close with Polly team to contribute some patches and investigate lots of details about polyhedral transformation. </div>

<div><b><br></b></div><div><b><br></b></div><div><b>References</b></div><div><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px">1. </span><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px">Tobias Grosser, Ragesh A. </span><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px"><i>Polly - First Successful Optimizations - How to proceed?</i> </span><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px">LLVM Developer Meeting 2011.</span></div>

<div><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px">2. </span><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px">Muthu Manikandan Baskaran, J. Ramanujam and P. Sadayappan.<i> </i></span><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px"><i>Automatic C-to-CUDA Code Generation for Affine Programs</i>. </span><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px">CC 2010.</span></div>

<div><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px">3. </span><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px">Soufiane Baghdadi, Armin Größlinger, and Albert Cohen. </span><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px"><i>Putting Automatic Polyhedral Compilation for GPGPU to Work</i>. </span><span style="color:rgb(34,34,34);font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19px">In Proc. of Compilers for Parallel Computers (CPC), 2010.</span></div>

<div></div><div></div>
<br>_______________________________________________<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div><br>