[pypy-svn] r27046 - pypy/dist/pypy/translator/goal
ericvrp at codespeak.net
ericvrp at codespeak.net
Wed May 10 13:18:44 CEST 2006
Author: ericvrp
Date: Wed May 10 13:18:43 2006
New Revision: 27046
Modified:
pypy/dist/pypy/translator/goal/bench-cronjob.py
pypy/dist/pypy/translator/goal/bench-unix.py
Log:
Benchmarking some (llvm) llc options
Modified: pypy/dist/pypy/translator/goal/bench-cronjob.py
==============================================================================
--- pypy/dist/pypy/translator/goal/bench-cronjob.py (original)
+++ pypy/dist/pypy/translator/goal/bench-cronjob.py Wed May 10 13:18:43 2006
@@ -3,8 +3,10 @@
import autopath
import py
import time, os, sys, stat
+from pypy.translator.llvm.buildllvm import optimizations
homedir = os.getenv('HOME')
+tmpdir = py.std.tempfile.gettempdir() + '/usession-' + os.environ['USER'] + '/'
def update_pypy():
os.chdir(homedir + '/projects/pypy-dist')
@@ -13,39 +15,43 @@
def update_llvm():
os.chdir(homedir + '/projects/llvm')
os.system('cvs -q up 2>&1')
- #os.system('make clean 2>&1')
- os.system('make -j3 tools-only 2>&1')
+ os.system('make -k -j3 tools-only 2>&1')
def compile_llvm_variants(revision):
- tmpdir = py.std.tempfile.gettempdir() + '/usession-' + os.environ['USER'] + '/'
+ ll2bc(revision)
+ bc2x86_exe(revision, 'x86A', '-enable-x86-fastcc -relocation-model=static -join-liveintervals')
+ bc2x86_exe(revision, 'x86B', '-relocation-model=static')
+ bc2x86_exe(revision, 'x86C', '')
+ bc2c_exe(revision)
- cmd = 'cp %sentry_point.ll pypy/translator/goal/entry_point-%s.ll' % (tmpdir, revision)
+
+def ll2bc(revision):
+ cmd = 'cp %spypy.ll pypy/translator/goal/archive/pypy-%s.ll' % (tmpdir, revision)
print cmd
os.system(cmd)
- cmd = "rm pypy/translator/goal/pypy-llvm-" + revision
+ opts = optimizations(simple=False, use_gcc=False)
+ cmd = '~/bin/llvm-as < %spypy.ll | ~/bin/opt %s -f -o %spypy.bc' % (
+ tmpdir, opts, tmpdir)
print cmd
os.system(cmd)
- ll2bc(tmpdir)
- bc2c_exe(tmpdir, revision)
- bc2x86_exe(tmpdir, revision, 'x86' , '')
- #bc2x86_exe(tmpdir, revision, 'x86dag', '-enable-x86-dag-isel')
+ cmd = 'cp %spypy.bc pypy/translator/goal/archive/pypy-%s.bc' % (tmpdir, revision)
+ print cmd
+ os.system(cmd)
-def ll2bc(tmpdir):
- cmd = '~/bin/llvm-as < %sentry_point.ll | ~/bin/opt -verify -lowersetjmp -funcresolve -raiseallocs -simplifycfg -mem2reg -globalopt -globaldce -ipconstprop -deadargelim -instcombine -simplifycfg -basiccg -prune-eh -inline -simplify-libcalls -basiccg -argpromotion -raise -tailduplicate -simplifycfg -scalarrepl -instcombine -break-crit-edges -condprop -tailcallelim -simplifycfg -reassociate -loopsimplify -licm -instcombine -indvars -loop-unroll -instcombine -load-vn -gcse -sccp -instcombine -break-crit-edges -condprop -dse -mergereturn -adce -simplifycfg -deadtypeelim -constmerge -verify -globalopt -constmerge -ipsccp -deadargelim -inline -instcombine -scalarrepl -globalsmodref-aa -licm -load-vn -gcse -instcombine -simplifycfg -globaldce -f -o %sentry_point_llvm1_7.bc' % (tmpdir, tmpdir)
+def bc2c_exe(revision):
+ b = "%spypy-llvm-%s-c" % (tmpdir, revision)
+ cmd = "~/bin/llc %spypy.bc -march=c -f -o %s.c" % (tmpdir, b)
print cmd
os.system(cmd)
-
-def bc2c_exe(tmpdir, revision):
- b = "%spypy-llvm-%s-llvm1_7_c" % (tmpdir, revision)
- cmd = "~/bin/llc %sentry_point_llvm1_7.bc -march=c -f -o %s.c" % (tmpdir, b)
+ cmd = "gcc %s.c -S -O3 -fomit-frame-pointer -o %s.s" % (b, b)
print cmd
os.system(cmd)
- cmd = "gcc %s.c -O2 -fomit-frame-pointer -static -lgc -lm -lpthread -pipe -o %s" % (b, b)
+ cmd = "gcc %s.s -static -lgc -lm -lpthread -pipe -o %s" % (b, b)
print cmd
os.system(cmd)
@@ -54,17 +60,21 @@
os.system(cmd)
-def bc2x86_exe(tmpdir, revision, name_extra, llc_extra_options):
- b = "%spypy-llvm-%s-llvm1_7_%s" % (tmpdir, revision, name_extra)
- cmd = "~/bin/llc %sentry_point_llvm1_7.bc %s -f -o %s.s" % (tmpdir, llc_extra_options, b)
+def bc2x86_exe(revision, name_extra, llc_extra_options):
+ b = "%spypy-llvm-%s-%s" % (tmpdir, revision, name_extra)
+ cmd = "~/bin/llc %spypy.bc %s -f -o %s.s" % (tmpdir, llc_extra_options, b)
print cmd
os.system(cmd)
- cmd = "as %s.s -o %s.o" % (b, b)
+ cmd = 'cp %s.s pypy/translator/goal/archive' % b
print cmd
os.system(cmd)
- cmd = "gcc %s.o -static -lgc -lm -lpthread -pipe -o %s" % (b, b)
+ #cmd = "as %s.s -o %s.o" % (b, b)
+ #print cmd
+ #os.system(cmd)
+
+ cmd = "gcc %s.s -static -lgc -lm -lpthread -pipe -o %s" % (b, b)
print cmd
os.system(cmd)
@@ -76,13 +86,22 @@
def compile(backend):
try:
backend, features = backend.split('--', 1)
- featureoptions = ''.join([" --" + f for f in features.split('--')])
+ featureoptions = ''.join([" --" + f for f in features.split('--') if f[0] != '_'])
+ targetoptions = ''.join([" --" + f[1:] for f in features.split('--') if f[0] == '_'])
except:
features = ''
featureoptions = ''
+ targetoptions = ''
+
+ if backend == 'llvm':
+ translateoptions = ' --source'
+ else:
+ translateoptions = ''
os.chdir(homedir + '/projects/pypy-dist/pypy/translator/goal')
- os.system('/usr/local/bin/python translate.py --backend=%(backend)s%(featureoptions)s --text --batch targetpypystandalone.py 2>&1' % locals())
+ #os.system('cp ~/x/entry_point.ll %s/entry_point.ll' % tmpdir) #XXX
+ os.system('/usr/local/bin/python translate.py --backend=%(backend)s%(featureoptions)s%(translateoptions)s --text --batch targetpypystandalone.py %(targetoptions)s 2>&1' % locals())
+ os.system('mv %s/entry_point.ll %s/pypy.ll' % (tmpdir, tmpdir))
os.chdir(homedir + '/projects/pypy-dist')
try:
@@ -94,18 +113,18 @@
if features:
realname += "-" + features
- pypy = open(basename, 'rb').read()
- if len(pypy) > 0:
- open(realname, 'wb').write(pypy)
- os.chmod(realname, stat.S_IRWXU)
- os.unlink(basename)
-
- if backend == 'llvm':
+ if backend == 'llvm': #create llvm exectutable from the current source
compile_llvm_variants(revision)
+ else: #copy executable
+ pypy = open(basename, 'rb').read()
+ if len(pypy) > 0:
+ open(realname, 'wb').write(pypy)
+ os.chmod(realname, stat.S_IRWXU)
+ os.unlink(basename)
def benchmark():
- os.system('cat /proc/cpuinfo')
- os.system('free')
+ #os.system('cat /proc/cpuinfo')
+ #os.system('free')
os.chdir(homedir + '/projects/pypy-dist/pypy/translator/goal')
os.system('/usr/local/bin/python bench-unix.py 2>&1 | tee benchmark.txt' % locals())
os.system('echo "<html><body><pre>" > benchmark.html')
@@ -114,8 +133,10 @@
os.system('scp benchmark.html ericvrp at codespeak.net:public_html/benchmark/index.html')
def main(backends=[]):
- if backends == []:
- backends = 'llvm c c--stackless'.split()
+ if backends == []: #_ prefix means target specific option
+ backends = 'llvm c c--gc=framework c--stackless c--_thread c--stackless--_thread'.split()
+ #backends = 'llvm c c--stackless c--_thread c--stackless--_thread'.split()
+ #backends = 'llvm c c--stackless c--gc=ref c--gc=ref--stackless c--_thread c--gc=ref--_thread'.split()
print time.ctime()
if 'llvm' in backends:
update_llvm()
@@ -124,6 +145,7 @@
try:
compile(backend)
except:
+ raise
pass
benchmark()
print time.ctime()
Modified: pypy/dist/pypy/translator/goal/bench-unix.py
==============================================================================
--- pypy/dist/pypy/translator/goal/bench-unix.py (original)
+++ pypy/dist/pypy/translator/goal/bench-unix.py Wed May 10 13:18:43 2006
@@ -71,7 +71,7 @@
txt = run_cmd('%s -c "%s"' % (executable, argstr))
return get_result(txt, PYSTONE_PATTERN)
-def run_richards(executable='/usr/local/bin/python', n=10):
+def run_richards(executable='/usr/local/bin/python', n=5):
argstr = RICHARDS_CMD % n
txt = run_cmd('%s -c "%s"' % (executable, argstr))
return get_result(txt, RICHARDS_PATTERN)
@@ -80,7 +80,7 @@
exes = []
for exe in [os.path.join('.', name) for name in os.listdir('.') if name.startswith('pypy-')]:
try:
- exes.append( (exe.split('-',2)[2], exe) )
+ exes.append( (exe.split('-')[2], exe) )
except:
pass #skip filenames without version number
exes.sort()
More information about the Pypy-commit
mailing list