<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 23, 2016 at 11:34 PM, Adam Nemet <span dir="ltr"><<a href="mailto:anemet@apple.com" target="_blank">anemet@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div><div class="h5"><blockquote type="cite"><div><br></div><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span><div><br></div></span><div>Hi Vikram,</div><div><br></div><div>Is the analysis result specific to a loop nest or to a loop nest together with a set of reference groups?</div></div></div></blockquote><div>The result is specific to each loop in the loop nest and the calculations are based on the references in the loop nest.</div></div></div></blockquote><div><br></div></div></div><div>Sorry can you please rephrase/elaborate, I don’t understand what you mean.  Analysis results are retained unless a transformation invalidates them.  My question is how the reference groups affect all this.</div></div></div></blockquote><div> </div><div>Sorry, I now understood that you meant llvm's analysis result (I thought how the analysis calculates the result). The analysis result is specific to each loop in its loop nest. Reference groups are necessary during cost computation only.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><br></div><div>You could probably describe how you envision this analysis would be used with something like Loop Fusion.</div></div></div></blockquote><div> </div><div>For Loop Interchange, the cost calculated for each loop can provide a desired ordering of the loops. Loop interchange can start interchanging the loops to match the desired order iff interchange legality check passes.<br></div><div>Eg: For matrix multiplication case,</div><div>       for (i = 0 to 5000)<br>         for (j = 0 to 5000)<br>           for (k = 0 to 5000)</div><div>             C[i,j] = C[i,j] + A[i,k]* B[k,j]</div><div>       Here, based on cache line size and the cache penalties for the references (please refer to first mail of the thread or the reference paper for different penalties), following costs result:</div><div>       Loop i cost: <span style="color:rgb(0,0,0);white-space:pre-wrap">2.501750e+11</span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">       Loop j cost: </span><span style="color:rgb(0,0,0);white-space:pre-wrap">6.256252e+10</span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">       Loop k cost: </span><span style="color:rgb(0,0,0);white-space:pre-wrap">1.563688e+11</span></div><div><font color="#000000"><span style="white-space:pre-wrap">Loop cost here is nothing but the total cache penalities due to all references, including penalties due to outer loops. So lower costing loop is a better fit for innermost loop because it has better cache locality. This would result in the desired loop order: i, k, j; and LoopInterchange can interchange 'j' and 'k' loops given the legality check passes (a nearest ordering for which legality is correct is also an optimal loop ordering).</span></font></div><div><font color="#000000"><span style="white-space:pre-wrap"><br></span></font></div><div><font color="#000000"><span style="white-space:pre-wrap">For fusion/fission, loop costs due to cache can be calculated by assigning cache penalties for references with respect to loops before and after fusion/fission. The costs will be a profitability measure for fusion/fission.</span></font></div><div><font color="#000000"><span style="white-space:pre-wrap"><br></span></font></div><div><font color="#000000"><span style="white-space:pre-wrap">I think use case description was very brief in a previous mail. So I have elaborated this time. More details can also be found in <a href="http://www.cs.utexas.edu/users/mckinley/papers/asplos-1994.pdf">http://www.cs.utexas.edu/users/mckinley/papers/asplos-1994.pdf</a>.</span></font></div><div><font color="#000000"><span style="white-space:pre-wrap"><br></span></font></div><div><font color="#000000"><span style="white-space:pre-wrap">Thanks</span></font></div></div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><br></div><div>Good time...</div><div>Vikram TV</div><div>CompilerTree Technologies</div><div>Mysore, Karnataka, INDIA</div></div></div></div></div>
</div></div>