diff pytools/commands.py @ 3692:4a76e44544d9

Made the safeadd and vectorlib examples runnable from the gl script: gl safeadd gl vectorlib Consolidated individual DaCapo commands into one 'dacapo' command.
author Doug Simon <doug.simon@oracle.com>
date Thu, 24 Nov 2011 13:19:40 +0100
parents b054dd61bfe1
children 60d31b1fada5
line wrap: on
line diff
--- a/pytools/commands.py	Wed Nov 23 18:11:28 2011 +0100
+++ b/pytools/commands.py	Thu Nov 24 13:19:40 2011 +0100
@@ -38,39 +38,55 @@
 def bootstrap(env, args):
     return env.run_vm(args + ['-version'])
 
-def safeadd(env, args):
-    return env.run_vm(args + ['-cp', env.mx().pdb().classpath('com.oracle.max.graal.examples.safeadd'), '-Xcomp', '-G:+PrintCompilation', '-G:+Extend', '-G:-Inline', '-XX:CompileOnly=Main', 'com.oracle.max.graal.examples.safeadd.Main'])
+def _example(env, args, project, mainClass):
+    cp = env.mx().pdb().classpath(project)
+    sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass]
     
-def avrora(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'avrora'])
+    res = []
+    print "=== Server VM ==="
+    res.append(env.run_vm(['-cp', cp,] + sharedArgs, vm="-server"))
+    print "=== Graal VM ==="
+    res.append(env.run_vm(['-cp', cp, '-G:+PrintCompilation', '-G:-Extend', '-G:-Inline'] + sharedArgs))
+    print "=== Graal VM with extensions ==="
+    res.append(env.run_vm(['-cp', cp, '-G:+PrintCompilation', '-G:+Extend', '-G:-Inline'] + sharedArgs))
+    
+    if len([x for x in res if x != 0]) != 0:
+        return 1
+    return 0
 
-def batik(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'batik'])
+def safeadd(env, args):
+    """run the SafeAdd example"""
+    return _example(env, args, 'com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main')
 
-def eclipse(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'eclipse'])
-
-def fop(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '100', 'fop'])
+def vectorlib(env, args):
+    """run the VectorLib example"""
+    return _example(env, args, 'com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main')
 
-def h2(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'h2'])
-
-def jython(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'jython'])
-
-def lusearch(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '5', 'lusearch'])
-
-def pmd(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '10', 'pmd'])
-
-def tradebeans(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'tradebeans'])
-
-def xalan(env, args):
-    return env.run_dacapo(args + ['Harness', '--preserve', '-n', '20', 'xalan'])
-
+def dacapo(env, args):
+    """run a DaCapo benchmark"""
+    
+    benchmarks = {
+        'avrora': ['--preserve', '-n', '20'],
+        'batik': ['-n', '20'],
+        'eclipse': ['-n', '20'],
+        'fop': ['-n', '100'],
+        'h2': ['-n', '10'],
+        'jython': ['-n', '10'],
+        'lusearch': ['-n', '5'],
+        'pmd': ['-n', '10'],
+        'tradebeans': ['-n', '20'],
+        'xalan': ['-n', '20'],
+    }
+    
+    if len(args) == 0:
+        env.abort('which benchmark?\nselect one of: ' + str(benchmarks.keys()))
+    bm = args[0]
+    config = benchmarks.get(bm)
+    if (config is None):
+        env.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(benchmarks.keys()))
+    args = args[1:]
+    return env.run_dacapo(args + ['Harness'] + config + [bm])
+    
 def tests(env, args):
     """run a selection of the Maxine JTT tests in Graal"""
     
@@ -168,20 +184,13 @@
 # used in the call to str.format().  
 # Extensions should update this table directly
 table = {
-    'avrora': [avrora, ''],
-    'safeadd': [safeadd, ''],
-    'batik': [batik, ''],
+    'dacapo': [dacapo, 'benchmark [VM options]'],
     'bootstrap': [bootstrap, ''],
     'clean': [clean, ''],
-    'fop': [fop, ''],
-    'h2': [h2, ''],
-    'jython': [jython, ''],
-    'lusearch': [lusearch, ''],
-    'pmd': [pmd, ''],
-    'tradebeans': [tradebeans, ''],
-    'tests': [tests, ''],
     'help': [help_, '[command]'],
     'make': [make, ''],
-    'xalan': [xalan, ''],
+    'safeadd': [safeadd, ''],
+    'tests': [tests, ''],
+    'vectorlib': [vectorlib, ''],
     'vm': [vm, ''],
 }