[pypy-commit] pypy PyPy_profopt_enabled: Profopt option now can come paired with --profoptpath to specify the training workload
Dodan
pypy.commits at gmail.com
Wed May 24 12:07:28 EDT 2017
Author: Dodan Mihai <mihai.dodan at gmail.com>
Branch: PyPy_profopt_enabled
Changeset: r91401:b5c11d10c249
Date: 2017-05-15 15:24 +0300
http://bitbucket.org/pypy/pypy/changeset/b5c11d10c249/
Log: Profopt option now can come paired with --profoptpath to specify the
training workload
diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -264,6 +264,14 @@
raise Exception("Cannot use the --output option with PyPy "
"when --shared is on (it is by default). "
"See issue #1971.")
+
+ # if both profopt and profoptpath are specified then we keep them as they are with no other changes
+ if config.translation.profopt:
+ if config.translation.profoptpath is None:
+ config.translation.profoptpath = "$(RPYDIR)/../lib-python/2.7/test/regrtest.py"
+ elif config.translation.profoptpath is not None:
+ raise Exception("Cannot use --profoptpath without specifying --profopt as well")
+
if sys.platform == 'win32':
libdir = thisdir.join('..', '..', 'libs')
libdir.ensure(dir=1)
diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -144,6 +144,7 @@
StrOption("cc", "Specify compiler to use for compiling generated C", cmdline="--cc"),
BoolOption("profopt", "Specify profile based optimization script",
cmdline="--profopt"),
+ StrOption("profoptpath", "Absolute path to the profile guided optimization training script", cmdline="--profoptpath"),
BoolOption("instrument", "internal: turn instrumentation on",
default=False, cmdline=None),
BoolOption("countmallocs", "Count mallocs and frees", default=False,
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -390,7 +390,7 @@
'cp -f libpypy-c.so $(RPYDIR)/../pypy/goal/ || true',
'rm -f $(RPYDIR)/../pypy/goal/pypy-c',
'cp -f pypy-c $(RPYDIR)/../pypy/goal/ || true',
- '$(RPYDIR)/../pypy/goal/pypy-c $(RPYDIR)/../pypy/goal/regrtest/regrtest.py --pgo -x test_asyncore test_gdb test_multiprocessing test_subprocess || true',
+ '$(RPYDIR)/../pypy/goal/pypy-c %s --pgo -x test_asyncore test_gdb test_multiprocessing test_subprocess || true' % self.config.translation.profoptpath,
'$(MAKE) clean_noprof',
'$(MAKE) CFLAGS="-fprofile-use -fprofile-correction -fPIC $(CFLAGS) -fno-lto" LDFLAGS="-fprofile-use $(LDFLAGS) -fno-lto" $(PROFOPT_TARGET)',
'rm -f $(RPYDIR)/../pypy/goal/libpypy-c.so || true',
diff --git a/rpython/translator/c/test/test_standalone.py b/rpython/translator/c/test/test_standalone.py
--- a/rpython/translator/c/test/test_standalone.py
+++ b/rpython/translator/c/test/test_standalone.py
@@ -227,7 +227,7 @@
data = cbuilder.cmdexec('hi there')
assert map(float, data.split()) == [0.0, 0.0]
- def test_profopt1(self):
+ def test_profopt(self):
if sys.platform == 'win32':
py.test.skip("no profopt on win32")
def add(a,b):
@@ -247,6 +247,29 @@
t.backendopt()
exe = t.compile()
assert (os.path.isfile("%s/pypy-c" % os.path.dirname(str(exe))))
+ # test --profoptpath
+ profoptpth = open('dummypythontraining.py', 'w+')
+ profoptpth.close()
+ abspath = os.path.abspath('dummypythontraining.py')
+ t = Translation(entry_point, backend='c', profopt=True, profoptpath=abspath, shared=True)
+ # no counters
+ t.backendopt()
+ exe = t.compile()
+ assert (os.path.isfile("%s/pypy-c" % os.path.dirname(str(exe))))
+
+ os.remove(abspath)
+
+ profoptpth = open('dummypythontraining.py', 'w+')
+ profoptpth.close()
+ abspath = os.path.abspath('dummypythontraining.py')
+ t = Translation(entry_point, backend='c', profopt=True, profoptpath=abspath, shared=False)
+ # no counters
+ t.backendopt()
+ exe = t.compile()
+ assert (os.path.isfile("%s" % exe))
+
+ os.remove(abspath)
+
# out = py.process.cmdexec("%s 500" % exe)
# assert int(out) == 500*501/2
t = Translation(entry_point, backend='c', profopt=True, shared=False)
More information about the pypy-commit
mailing list