[Mesa-dev] [PATCH 03/10] i965/nir: Report NIR instruction counts (in SSA form) via KHR_debug.

Jason Ekstrand jason at jlekstrand.net
Fri Jan 23 13:55:11 PST 2015


On Thu, Jan 22, 2015 at 7:39 AM, Jason Ekstrand <jason at jlekstrand.net>
wrote:

>
> On Jan 22, 2015 3:41 AM, "Kenneth Graunke" <kenneth at whitecape.org> wrote:
> >
> > This allows us to count NIR instructions via shader-db.
> >
> > Use "run" as normal.  The results file will contain both NIR and
> > assembly.
> >
> > Then, to generate a NIR report:
> > ./report.py <(grep    NIR results/foo) <(grep    NIR results/bar)
> >
> > Or, to generate an i965 report:
> > ./report.py <(grep -v NIR results/foo) <(grep -v NIR results/bar)
> >
> > Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> > ---
> >  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 32
> ++++++++++++++++++++++++++++++++
> >  1 file changed, 32 insertions(+)
> >
> > I'm guessing the counting should really go in nir proper.
> > This is what I used to generate the statistics, in case people were
> > wondering.
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> > index 2d30321..0eb137f 100644
> > --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> > +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> > @@ -49,6 +49,28 @@ nir_optimize(nir_shader *nir)
> >     } while (progress);
> >  }
> >
> > +static bool
> > +count_nir_instrs_in_block(nir_block *block, void *state)
> > +{
> > +   int *count = (int *) state;
> > +   nir_foreach_instr(block, instr) {
> > +      *count = *count + 1;
>
> *count++?  Also, we could get rid of the braces on this if.  Otherwise, I
> like this.
>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>


> > +   }
> > +   return true;
> > +}
> > +
> > +static int
> > +count_nir_instrs(nir_shader *nir)
> > +{
> > +   int count = 0;
> > +   nir_foreach_overload(nir, overload) {
> > +      if (!overload->impl)
> > +         continue;
> > +      nir_foreach_block(overload->impl, count_nir_instrs_in_block,
> &count);
> > +   }
> > +   return count;
> > +}
> > +
> >  void
> >  fs_visitor::emit_nir_code()
> >  {
> > @@ -99,6 +121,16 @@ fs_visitor::emit_nir_code()
> >        nir_print_shader(nir, stderr);
> >     }
> >
> > +   if (dispatch_width == 8) {
> > +      static GLuint msg_id = 0;
> > +      _mesa_gl_debug(&brw->ctx, &msg_id,
> > +                     MESA_DEBUG_SOURCE_SHADER_COMPILER,
> > +                     MESA_DEBUG_TYPE_OTHER,
> > +                     MESA_DEBUG_SEVERITY_NOTIFICATION,
> > +                     "FS NIR shader: %d inst\n",
> > +                     count_nir_instrs(nir));
> > +   }
> > +
> >     nir_convert_from_ssa(nir);
> >     nir_validate_shader(nir);
> >     nir_lower_vec_to_movs(nir);
> > --
> > 2.2.2
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150123/3af80a86/attachment-0001.html>


More information about the mesa-dev mailing list