<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 Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</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=Section1>

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

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> Depends on your reading of the spec. It states that if a
work-item goes down a conditional path then all work-items in a work-group must
also go down the conditional path. So in my interpretation, the call to
user_func() in the true branch produces a different barrier during execution than
the call to user_func() in the false branch, even though they both exist on the
same line of source.<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'><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>Vinod Grover<br>
<b>Sent:</b> Thursday, October 08, 2009 11:18 PM<br>
<b>To:</b> Eli Friedman<br>
<b>Cc:</b> Reid Kleckner; LLVM Developers Mailing List<br>
<b>Subject:</b> Re: [LLVMdev] Instructions that cannot be duplicated<o:p></o:p></span></p>

</div>

</div>

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

<p class=MsoNormal>Is inlining (which duplicates code) of functions containing
OpenCL style barriers legal?<o:p></o:p></p>

<div>

<p class=MsoNormal>or e.g. <o:p></o:p></p>

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>if you had some changed phase ordering where you had<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>if (cond) {<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>call user_func() // user_func has a barrier buried inside
it.<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>you do tail splitting<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>if (cond) {<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>   call user_func()<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>} else {<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>   call user_func();<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>now you inline -- oops now you might have a problem<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>so do you want IPA to propagate the barrier bit to the call
sites?<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>you could do inlining before tail splitting<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

<p class=MsoNormal>sounds messy...<o:p></o:p></p>

</div>

<div>

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

</div>

<div>

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

</div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p>

<div>

<p class=MsoNormal>On Thu, Oct 8, 2009 at 8:38 PM, Eli Friedman <<a
href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>> wrote:<o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'>On Thu, Oct 8, 2009 at 2:11 PM,
Reid Kleckner <<a href="mailto:rnk@mit.edu">rnk@mit.edu</a>> wrote:<br>
> IMO Jeff's solution is the cleanest, simplest way to get code that<br>
> works.  Just generate a separate function for every barrier in the<br>
> program, and mark it noinline.  This way the instruction pointers
will<br>
> be unique to the barrier.<o:p></o:p></p>

</div>

<p class=MsoNormal>No, this gets rather nasty: to support an instruction like
this, it<br>
isn't legal to duplicate calls to functions containing a barrier<br>
instruction.<br>
<br>
Another proposal: add an executebarrier function attribute for<br>
functions which directly or indirectly contain an execution barrier,<br>
and adjust all the relevant transformation passes, like jump threading<br>
and loop unswitching, to avoid duplicating calls to such functions.<br>
This puts a slight burden on the frontend to mark functions<br>
appropriately, but I don't see any other solution which doesn't affect<br>
code which doesn't use execute barriers.<br>
<span style='color:#888888'><br>
-Eli</span><o:p></o:p></p>

<div>

<div>

<p class=MsoNormal><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><o:p></o:p></p>

</div>

</div>

</div>

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

</div>

</div>

</div>

</body>

</html>