diff --git a/llvm/test/VISC/parboil/driver/__init__.py b/llvm/test/VISC/parboil/driver/__init__.py index 2b007fea91dd2f1f0db4ac76d5ff7cf6f25c20a0..66d6a993588902fed2184d96979bd6d72f25c2e3 100644 --- a/llvm/test/VISC/parboil/driver/__init__.py +++ b/llvm/test/VISC/parboil/driver/__init__.py @@ -15,7 +15,7 @@ def run(): # Print a banner message print "Parboil parallel benchmark suite, version 0.2" print - + # Global variable setup if not globals.root: globals.root = os.getcwd() diff --git a/llvm/test/VISC/parboil/driver/actions.py b/llvm/test/VISC/parboil/driver/actions.py index 27890d8db6024b2ec3f24ced093b1e76b6f4771f..21621a909af914c0504370eeb83c5af791906c7c 100644 --- a/llvm/test/VISC/parboil/driver/actions.py +++ b/llvm/test/VISC/parboil/driver/actions.py @@ -87,19 +87,19 @@ def run_benchmark(bmk, version_name, input_name, check=True, extra_opts=[], plat """Run the benchmark 'bmk'.""" try: impl = bmk.impls[version_name] except KeyError: - print "Cannot find benchmark version" + print "(FAIL) Cannot find benchmark version" return ErrorType.CannotFindVersion try: data = bmk.datas[input_name] except KeyError: - print "Cannot find data set" + print "(FAIL) Cannot find data set" return ErrorType.CannotFindDataSet # Run the benchmark ret = impl.run(bmk, data, check, extra_opts=extra_opts, platform=platform) if ret is not ErrorType.Success: - print "Run failed!" + print "(FAIL) Run failed!" return ret # Verify the output @@ -107,10 +107,10 @@ def run_benchmark(bmk, version_name, input_name, check=True, extra_opts=[], plat success = impl.check(bmk, data) if not success: - print "Output checking tool detected a mismatch" + print "(FAIL) Output checking tool detected a mismatch" return ErrorType.OutputMismatch else: - print "Output was not checked for correctness" + print "(WARNING) Output was not checked for correctness" return ErrorType.Success diff --git a/llvm/test/VISC/parboil/driver/globals.py b/llvm/test/VISC/parboil/driver/globals.py index 7afa9134715250d16ff8db410ec43a0e86dfb4bb..1f94599fe1e3343529a9b210077ede69706badea 100644 --- a/llvm/test/VISC/parboil/driver/globals.py +++ b/llvm/test/VISC/parboil/driver/globals.py @@ -21,3 +21,9 @@ program_env = None # option parsing. verbose = False +log = False + +outlog = None + +errlog = None + diff --git a/llvm/test/VISC/parboil/driver/options.py b/llvm/test/VISC/parboil/driver/options.py index c6af52ba53152e1889ebc6c6df56fceb3c56196c..d2160b719014ebcafc7dd6c218738a40c3a2a84a 100644 --- a/llvm/test/VISC/parboil/driver/options.py +++ b/llvm/test/VISC/parboil/driver/options.py @@ -1,4 +1,4 @@ -# (c) 2007 The Board of Trustees of the University of Illinois. +# (c) 2006 The Board of Trustees of the University of Illinois. # This module takes care of parsing options for the Parboil driver. # @@ -8,7 +8,8 @@ from sys import stdout from optparse import OptionParser - +import os +import tempfile import actions import globals @@ -130,7 +131,6 @@ def compile_options(progname, cmd, args): def run(): (opts, pos) = parser.parse_args(args) globals.verbose = opts.verbose - print (progname,cmd, args) if not len(pos) in [2, 3]: print "Expecting two or three parameters after 'compile'" @@ -207,68 +207,113 @@ def debug_options(progname, cmd, args): return OptionGetter(parser.print_help, run) def time_options(progname, cmd, args): - usage_string = progname + " time_options BENCHMARK VERSION INPUT" + globals.log = True + usage_string = progname + " time [-v]" parser = OptionParser(usage = usage_string) #parser.add_option('-C', "--no-check", # action="store_false", dest="check", default=True, # help="Skip the output check for this benchmark") - #parser.add_option('-v', "--verbose", - # action="store_true", dest="verbose", default=False, - # help="Produce verbose status messages") + parser.add_option('-v', "--verbose", + action="store_true", dest="verbose", default=False, + help="Produce verbose status messages") + + def dump(data, filename): + f = open(filename, "w") + f.write(data) + + def dump_cleanLog(dirname): + dump(globals.outlog, dirname+"/clean-stdout") + dump(globals.errlog, dirname+"/clean-stderr") + + def dump_buildLog(dirname): + dump(globals.outlog, dirname+"/build-stdout") + dump(globals.errlog, dirname+"/build-stderr") + + def dump_runLog(dirname,test): + dump(globals.outlog, dirname+"/run-"+test+"-stdout") + dump(globals.errlog, dirname+"/run-"+test+"-stderr") def run(): - configs = [ ('sgemm', { 'VERSION' : ["visc", "opencl_base"], - 'TEST' : ["small"]#, "medium", "large"] + (opts, pos) = parser.parse_args(args) + globals.verbose = opts.verbose + + configs = [ ('sgemm', { 'VERSION' : ["visc", "opencl_base"], + 'TEST' : ["small", "medium"] } - ), - ('spmv', { 'VERSION' : ["visc", "opencl_nvidia"], - 'TEST' : ["small"]#, "medium"] + ) + ,('spmv', { 'VERSION' : ["visc", "opencl_nvidia"], + 'TEST' : ["small", "medium", "large"] } - ), - ('lbm', { 'VERSION' : ["visc", "opencl_nvidia"], + ) + ,('lbm', { 'VERSION' : ["visc", "opencl_nvidia"], 'TEST' : ["short", "long"] } - ), - ('stencil', { 'VERSION' : ["visc", "opencl_base"], + ) + ,('stencil', { 'VERSION' : ["visc", "opencl_base"], 'TEST' : ["small", "default"] } ) ] + log_dir = tempfile.mkdtemp(prefix = 'LOG-', dir = ".") + print "Logs stored at: " + log_dir for (app, app_config) in configs: - print "Printing Application Data" - print app - print app_config['VERSION'] - print app_config['TEST'] + print + print "=========== APPLICATION CONFIGURATION ===========" + print "App Name:\t" + app + print "Version(s):\t" + "\t".join(app_config['VERSION']) + print "Test(s):\t" + "\t".join(app_config['TEST']) + print "=================================================" + + app_dir = log_dir+"/"+app + os.makedirs(app_dir) + arguments = [app] - print arguments for ver in app_config['VERSION']: + + ver_dir = app_dir+"/"+ver + os.makedirs(ver_dir) + arguments.append(ver) + if globals.verbose: + arguments.append("-v") + + print "Cleaning " + app + " " + ver action = clean_options(progname, 'clean', arguments).run() if action: action() else: print "Could not clean: " + app + + dump_cleanLog(ver_dir) + + print "Compiling " + app + " " + ver action = compile_options(progname, 'compile', arguments).run() if action: action() else: print "Could not compile: " + app + dump_buildLog(ver_dir) + + if globals.verbose: + arguments.pop() + for test in app_config['TEST']: + print "Running " + app + "-" + ver + " with test " + test arguments.append(test) + if globals.verbose: + arguments.append("-v") action = run_options(progname, 'run', arguments).run() if action: action() else: print "Could not run: " + app - arguments.remove(test) - arguments.remove(ver) - + dump_runLog(ver_dir, test) + if globals.verbose: + arguments.pop() + arguments.pop() - #if not len(pos) in [1, 2]: - # print "Expecting one or two parameters after time" - # return None - #else: + arguments.pop() return None return OptionGetter(parser.print_help, run) diff --git a/llvm/test/VISC/parboil/driver/process.py b/llvm/test/VISC/parboil/driver/process.py index b8933fb56a711f489a53a72a261226586a5b018a..27dfa9a2e597edf79c77eed1d314383b40496ffb 100644 --- a/llvm/test/VISC/parboil/driver/process.py +++ b/llvm/test/VISC/parboil/driver/process.py @@ -3,6 +3,7 @@ # Process-management and directory management routines are collected here. import os +import subprocess import os.path as path import stat import parboilfile as pbf @@ -58,7 +59,7 @@ def with_path(wd, action): try: result = action() finally: os.chdir(cwd) return result - + def makefile(target=None, action=None, filepath=None, env={}): """Run a makefile. An optional command, makefile path, and dictionary of variables to define on the command line may be defined. The return code @@ -69,34 +70,69 @@ def makefile(target=None, action=None, filepath=None, env={}): A 'q' action queries whether the target needs to be rebuilt. True is returned if the target is up to date.""" - +# p = subprocess.Popen(["echo", "This works!"], stdout=subprocess.PIPE) +# out, err = p.communicate() +# if out: +# print "Output of shell process is " + out +# if err: +# print "Error of shell process is " + err args = ["make"] if action is 'build': def run(): args.append('default') - rc = os.spawnvp(os.P_WAIT, "make", args) - return rc == 0 + #rc = os.spawnvp(os.P_WAIT, "make", args) + if globals.log: + p = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + else: + p = subprocess.Popen(args) + globals.outlog, globals.errlog = p.communicate() + rc = p.returncode + return rc==0 elif action is 'clean': def run(): args.append('clean') - rc = os.spawnvp(os.P_WAIT, "make", args) + #rc = os.spawnvp(os.P_WAIT, "make", args) + if globals.log: + p = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + else: + p = subprocess.Popen(args) + globals.outlog, globals.errlog = p.communicate() + rc = p.returncode return rc == 0 elif action is 'run': def run(): args.append('run') - rc = os.spawnvp(os.P_WAIT, "make", args) + #rc = os.spawnvp(os.P_WAIT, "make", args) + if globals.log: + p = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + else: + p = subprocess.Popen(args) + globals.outlog, globals.errlog = p.communicate() + rc = p.returncode return rc == 0 elif action is 'debug': def run(): args.append('debug') - rc = os.spawnvp(os.P_WAIT, "make", args) + #rc = os.spawnvp(os.P_WAIT, "make", args) + if globals.log: + p = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + else: + p = subprocess.Popen(args) + globals.outlog, globals.errlog = p.communicate() + rc = p.returncode return rc == 0 elif action in ['q']: args.append('-q') def run(): - rc = os.spawnvp(os.P_WAIT, "make", args) + #rc = os.spawnvp(os.P_WAIT, "make", args) + if globals.log: + p = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + else: + p = subprocess.Popen(args) + globals.outlog, globals.errlog = p.communicate() + rc = p.returncode if rc == 0: # Up-to-date return True @@ -123,7 +159,6 @@ def makefile(target=None, action=None, filepath=None, env={}): # Print a status message, if running in verbose mode if globals.verbose: - print "Running '" + " ".join(args) + "' in " + os.getcwd() # Run the makefile and return result info @@ -145,7 +180,13 @@ def spawnwaitv(prog, args): raise OSError, "Cannot execute '" + prog + "'" # Run the program - return os.spawnve(os.P_WAIT, prog, args, env) + # return os.spawnve(os.P_WAIT, prog, args, env) + if globals.log: + p = subprocess.Popen(args, env = env, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + else: + p = subprocess.Popen(args, env = env) + globals.outlog, globals.errlog = p.communicate() + return p.returncode def spawnwaitl(prog, *argl): """Spawn a program and wait for it to complete. The program is