[Mesa-dev] [RFC 1/4] intel: use a flag instead of setting PYTHONPATH

Dylan Baker dylan at pnwbakers.com
Wed Sep 20 20:47:38 UTC 2017


Quoting Kenneth Graunke (2017-09-20 13:44:58)
> On Wednesday, September 20, 2017 1:27:38 PM PDT Dylan Baker wrote:
> > Meson doesn't allow setting environment variables for custom targets, so
> > we either need to not pass this as an environment variable or use a
> > shell script to wrap the invocation. The chosen solution has the
> > advantage of working for both autotools and meson.
> > 
> > Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> > ---
> >  src/intel/Makefile.compiler.am                 |  2 +-
> >  src/intel/compiler/brw_nir_trig_workarounds.py | 34 +++++++++++++++++++-------
> >  2 files changed, 26 insertions(+), 10 deletions(-)
> > 
> > diff --git a/src/intel/Makefile.compiler.am b/src/intel/Makefile.compiler.am
> > index 3ab550c96b1..45e7a6ccce8 100644
> > --- a/src/intel/Makefile.compiler.am
> > +++ b/src/intel/Makefile.compiler.am
> > @@ -35,7 +35,7 @@ BUILT_SOURCES += $(COMPILER_GENERATED_FILES)
> >  compiler/brw_nir_trig_workarounds.c: compiler/brw_nir_trig_workarounds.py \
> >                                       $(top_srcdir)/src/compiler/nir/nir_algebraic.py
> >       $(MKDIR_GEN)
> > -     $(AM_V_GEN) PYTHONPATH=$(top_srcdir)/src/compiler/nir $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/compiler/brw_nir_trig_workarounds.py > $@ || ($(RM) $@; false)
> > +     $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/compiler/brw_nir_trig_workarounds.py -p $(top_srcdir)/src/compiler/nir > $@ || ($(RM) $@; false)
> >  
> >  EXTRA_DIST += \
> >       compiler/brw_nir_trig_workarounds.py
> > diff --git a/src/intel/compiler/brw_nir_trig_workarounds.py b/src/intel/compiler/brw_nir_trig_workarounds.py
> > index 6a77d64dbd4..a752f5461f1 100644
> > --- a/src/intel/compiler/brw_nir_trig_workarounds.py
> > +++ b/src/intel/compiler/brw_nir_trig_workarounds.py
> > @@ -20,8 +20,6 @@
> >  # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> >  # IN THE SOFTWARE.
> >  
> > -import nir_algebraic
> > -
> >  # Prior to Kaby Lake, The SIN and COS instructions on Intel hardware can
> >  # produce values slightly outside of the [-1.0, 1.0] range for a small set of
> >  # values.  Obviously, this can break everyone's expectations about trig
> > @@ -33,11 +31,29 @@ import nir_algebraic
> >  # amplitude slightly.  Apparently this also minimizes the error function,
> >  # reducing the maximum error from 0.00006 to about 0.00003.
> >  
> > -trig_workarounds = [
> > -   (('fsin', 'x'), ('fmul', ('fsin', 'x'), 0.99997)),
> > -   (('fcos', 'x'), ('fmul', ('fcos', 'x'), 0.99997)),
> > -]
> > +import argparse
> > +import sys
> > +
> > +
> > +def main():
> > +    parser = argparse.ArgumentParser()
> > +    parser.add_argument('-p', '--import-path', required=True)
> > +    args = parser.parse_args()
> > +    sys.path.insert(0, args.import_path)
> > +    run()
> > +
> > +
> > +def run():
> > +    import nir_algebraic
> > +    trig_workarounds = [
> > +       (('fsin', 'x'), ('fmul', ('fsin', 'x'), 0.99997)),
> > +       (('fcos', 'x'), ('fmul', ('fcos', 'x'), 0.99997)),
> > +    ]
> > +
> > +    print '#include "brw_nir.h"'
> > +    print nir_algebraic.AlgebraicPass("brw_nir_apply_trig_workarounds",
> > +                                      trig_workarounds).render()
> > +
> >  
> > -print '#include "brw_nir.h"'
> > -print nir_algebraic.AlgebraicPass("brw_nir_apply_trig_workarounds",
> > -                                  trig_workarounds).render()
> > +if __name__ == '__main__':
> > +    main()
> > 
> 
> IMHO it would be nice to leave trig_workarounds at the top level, like
> it was.  That way, you can find the rules easily without having to dig
> through the plumbing necessary to set them up.  Either way,
> 
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

Sure, I can move them back. I'll add that to v2.

Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170920/21e57e1e/attachment-0001.sig>


More information about the mesa-dev mailing list