<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=WordSection1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Dan,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> I've been working on an OpenCL GPU language code generator
for the last two years, so I can answer some of your questions. <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>1) I would check out the gallium 3d project as they are doing
something very similar to this already, but are mainly targeting GLSL and not
OpenCL. Support for vectors is very good in LLVM, as long as your vectors are
power of 2 in size. Occasionally I run into a problem where vector support is
non-existent, but adding it from similar code isn't too much of an issue.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>2) LLVM is low level, you might want to look into HLVM for your
high level optimizations.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>3) I've developed on Mac, Linux and Windows and have not had
trouble with LLVM from that perspective.  So there isn't really a problem
to worry about here.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Some other things to take into account that are problematic for
LLVM that I've ran across. For example, LLVM does not produce 'good' flow
control code for vector architecture with the default passes enabled. The
passes need to be tweaked to disable many flow control optimizations. Another
issue is the fact that the GPU language I am targeting has constant resource
ID's and a non-uniform address space. So keeping track of which pointer belongs
to which resource ID is very difficult and in some cases impossible at the
machine instruction level.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>We use a separate compiler for ISA generation/scheduling/register
allocation and not LLVM, so I can't comment to deeply on how LLVM works here,
but I believe it would be difficult to fix llvm to generate ISA for our GPU
architecture as the concepts that the architecture has does not exist in llvm.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hope this helps,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Micah<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> llvmdev-bounces@cs.uiuc.edu
[mailto:llvmdev-bounces@cs.uiuc.edu] <b>On Behalf Of </b>Daan Nijs<br>
<b>Sent:</b> Friday, July 23, 2010 2:55 AM<br>
<b>To:</b> llvmdev@cs.uiuc.edu<br>
<b>Subject:</b> [LLVMdev] Questions about GPU code generation/ VS development<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>Hey everyone,<br>
<br>
I've been working for a while on a virtual machine/DSL (for lack of a more
precise term) specialised for graphics. I hope to allow domain specific
optimizations, eg folding together post-processing passes, or automatic LODing
for procedural textures. I'm planning to make the renderer itself to be defined
at runtime, to allow foward rendering, deferred rendering, raytracing, or a
combination of all 3. Of course, this is lot to chew on, so for now it's more
of a proof of concept than anything production-ready. <br>
<br>
Due to my unfamiliarity with LLVM, I do have some broad questions though. If
somebody can answer, or just point me to the relevant documentation/code, I
would be very grateful.<br>
<br>
Right now I use my own code to schedule between the GPU code (OpenCL and GLSL),
and to generate the GPU code. In fact, I only use LLVM to generate the CPU side
code. <br clear=all>
<br>
1. Which steps would it take to implement an OpenCL/GLSL backend to LLVM? What
is the level of vector integration in the core? Is there already some work done
in this direction I could look at/reuse?<br>
2. Would it make sense to use LLVM to drive the whole compilation process,
considering I will operate on high level concepts, eg convolutions, frequency
analysis, error metrics? Or should I do break down these things first and then
use LLVM for the lower level code?<br>
3. ATM I'm using VS2008 as my environment, and LLVM from head. Timewise, am I
shooting myself in the foot? I'm hesitant to switch to another platform, as I
have a lot of experience with VS, but I'm unsure how well the LLVM support
stacks up to Mac/Linux support.<br>
4. I'm using my own custom 3d engine, which should have it's routines called
dynamically. Does this mean I have to run CLang on it to make it callable from
LLVM generated code, or should I just be able to call it as as external code?<br>
<br>
I apologize in advance if some of these questions are basic or too broad, I
recently hit a bit of a brick wall designing the guts of the system, and would
love to benefit from the opinion of experienced LLVM users. Thank you for your
time.<o:p></o:p></p>

</div>

</div>

</body>

</html>