<div dir="ltr"><div>Whoops I answer 2 times.<br><br></div>Would the comment bellow be appropriate?<br><div><br><span class="gmail-">This limit is chosen fairly arbitrarily.<br>
</span>GLSL IR max iteration is 32 instructions. (Multiply counting nodes and magic number 5).<br>
But there is no 1:1 mapping between GLSL IR and NIR so 25 was picked because<br>
<span class="gmail-">it seemed to give about the same results. Around 5 instructions per node.<br>
</span>But some loops that would unroll with GLSL IR fail to unroll if we set<br>
<span class="gmail-im gmail-HOEnZb">this to 25 so we set it to 26.<br><br></span><div>Elie<br></div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On 13 February 2017 at 01:00, tournier.elie <span dir="ltr"><<a target="_blank" href="mailto:tournier.elie@gmail.com">tournier.elie@gmail.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 class="gmail-h5"><br>
On 9 February 2017 at 02:48, Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>> wrote:<br>
<br>
> 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>
> Max iteration is 32 this is number of instructions, in GLSL IR it was<br>
> 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>
><br>
><br>
</div></div>So to resume. Is this comment correct for you?<br>
<span class="gmail-"><br>
This limit is chosen fairly arbitrarily.<br>
</span>GLSL IR max iteration is 32 instructions. (Counting nodes by magic number 5).<br>
But there is no 1:1 mapping between GLSL IR and NIR so 25 was picked because<br>
<span class="gmail-">it seemed to give about the same results. Around 5 instructions per node.<br>
</span>But some loops that would unroll with GLSL IR fail to unroll if we set<br>
<span class="gmail-im gmail-HOEnZb">this to 25 so we set it to 26.<br>
<br>
><br>
> ><br>
</span><div class="gmail-HOEnZb"><div class="gmail-h5">> > > + */<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>
><br>
</div></div><br><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 class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_6762188919637569504gmail-HOEnZb"><div>On Wed, 8 Feb 2017 15:54:46 -0800<br>
Jason Ekstrand <<a target="_blank" 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 target="_blank" href="mailto:tournier.elie@gmail.com">tournier.elie@gmail.com</a>> wrote:<br>
><br>
> > Signed-off-by: Elie Tournier <<a target="_blank" 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_loo<wbr>p_unroll.c<br>
> > b/src/compiler/nir/nir_opt_loo<wbr>p_unroll.c<br>
> > index 37cbced43d..035a030239 100644<br>
> > --- a/src/compiler/nir/nir_opt_loo<wbr>p_unroll.c<br>
> > +++ b/src/compiler/nir/nir_opt_loo<wbr>p_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 class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_6762188919637569504gmail-HOEnZb"><div class="gmail-m_6762188919637569504gmail-h5">
</div></div><span class="gmail-m_6762188919637569504gmail-">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-m_6762188919637569504gmail-HOEnZb"><div class="gmail-m_6762188919637569504gmail-h5"><br></div></div></blockquote><div><br>So to resume. Is this comment correct for you?<br><br><span class="gmail-m_6762188919637569504gmail-">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 class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_6762188919637569504gmail-HOEnZb"><div class="gmail-m_6762188919637569504gmail-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_unroll<wbr>(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>
<br></blockquote></div><br></div></div></div></div>