intel: use a flag instead of setting PYTHONPATH

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.

v2: - put rules back in top scope (Ken)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
This commit is contained in:
Dylan Baker
2017-09-19 11:46:16 -07:00
parent a65db0ad1c
commit 848da66222
2 changed files with 26 additions and 9 deletions

View File

@@ -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

View File

@@ -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,30 @@ 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
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()
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 # pylint: disable=import-error
print '#include "brw_nir.h"'
print nir_algebraic.AlgebraicPass("brw_nir_apply_trig_workarounds",
TRIG_WORKAROUNDS).render()
if __name__ == '__main__':
main()