<div dir="ltr"><br><div><div class="gmail_extra"><div class="gmail_quote">On 9 February 2017 at 02:48, Timothy Arceri <span dir="ltr"><<a target="_blank" href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div class="gmail-HOEnZb"><div>On Wed, 8 Feb 2017 15:54:46 -0800<br>
Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
<br>
> On Wed, Feb 8, 2017 at 2:20 PM, Elie Tournier<br>
> <<a href="mailto:tournier.elie@gmail.com">tournier.elie@gmail.com</a>> wrote:<br>
><br>
> > Signed-off-by: Elie Tournier <<a href="mailto:tournier.elie@gmail.com">tournier.elie@gmail.com</a>><br>
> > ---<br>
> >  src/compiler/nir/nir_opt_loop_<wbr>unroll.c | 10 +++++++++-<br>
> >  1 file changed, 9 insertions(+), 1 deletion(-)<br>
> ><br>
> > diff --git a/src/compiler/nir/nir_opt_<wbr>loop_unroll.c<br>
> > b/src/compiler/nir/nir_opt_<wbr>loop_unroll.c<br>
> > index 37cbced43d..035a030239 100644<br>
> > --- a/src/compiler/nir/nir_opt_<wbr>loop_unroll.c<br>
> > +++ b/src/compiler/nir/nir_opt_<wbr>loop_unroll.c<br>
> > @@ -26,6 +26,14 @@<br>
> >  #include "nir_control_flow.h"<br>
> >  #include "nir_loop_analyze.h"<br>
> ><br>
> > +<br>
> > +/* This limit is chosen fairly arbitrarily.  The GLSL IR limit is<br>
> > 25.<br>
> > + * However, due to slight differences in the way the two IRs count<br>
> > + * instructions, some loops that would unroll with GLSL IR fail to<br>
> > unroll<br>
> > + * if we set this to 25 so we set it to 26.<br>
> ><br>
><br>
> Ok, I lied in my comment.  It's not 25, it's 32.  Tim, can you<br>
> explain the discrepancy?<br>
> --Jason<br> <br></div></div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div class="gmail-HOEnZb"><div class="gmail-h5">
</div></div><span class="gmail-">Max iteration is 32 this is number of instructions, in GLSL IR it was<br>
</span>counting nodes and the magic number was 5. There is no 1:1 mapping 25<br>
was picked because it seemed to give about the same results. Around 5<br>
instructions per node. <br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br></div></div></blockquote><div><br>So to resume. Is this comment correct for you?<br><br><span class="gmail-">Max iteration is 32 this is number of instructions, in GLSL IR it was<br>
</span>counting nodes and the magic number was 5. There is no 1:1 mapping 25<br>
was picked because it seemed to give about the same results. Around 5<br>
instructions per node. But some loops that would unroll with GLSL IR fail<br>to unroll if we set this to 25 so we set it to 26.<br><br> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div class="gmail-HOEnZb"><div class="gmail-h5">
><br>
><br>
> > + */<br>
> > +#define LOOP_UNROLL_LIMIT 26<br>
> > +<br>
> >  /* Prepare this loop for unrolling by first converting to lcssa<br>
> > and then<br>
> >   * converting the phis from the loops first block and the block<br>
> > that follows<br>
> >   * the loop into regs.  Partially converting out of SSA allows us<br>
> > to unroll<br>
> > @@ -460,7 +468,7 @@ is_loop_small_enough_to_<wbr>unroll(nir_shader<br>
> > *shader, nir_loop_info *li)<br>
> >        return true;<br>
> ><br>
> >     bool loop_not_too_large =<br>
> > -      li->num_instructions * li->trip_count <= max_iter * 26;<br>
> > +      li->num_instructions * li->trip_count <= max_iter *<br>
> > LOOP_UNROLL_LIMIT;<br>
> ><br>
> >     return loop_not_too_large;<br>
> >  }<br>
> > --<br>
> > 2.11.0<br>
> ><br>
> ><br>
<br>
</div></div></blockquote></div><br></div></div></div>