diff options
author | 2011-08-17 16:38:10 +0200 | |
---|---|---|
committer | 2011-08-17 16:38:10 +0200 | |
commit | 21af760fe7de8000f27d7f34b1188568957b3e12 (patch) | |
tree | 95840fc53d345d7c5ed7a6cc21f95f652ea005a4 | |
parent | Added informations and solved bug within benchprint. (diff) | |
download | auto-numerical-bench-21af760fe7de8000f27d7f34b1188568957b3e12.tar.gz auto-numerical-bench-21af760fe7de8000f27d7f34b1188568957b3e12.tar.bz2 auto-numerical-bench-21af760fe7de8000f27d7f34b1188568957b3e12.zip |
Added load average, childs killing, signal handler.
-rw-r--r-- | numbench/basemodule.py | 3 | ||||
-rw-r--r-- | numbench/benchchilds.py | 13 | ||||
-rw-r--r-- | numbench/benchload.py | 44 | ||||
-rw-r--r-- | numbench/blas_accuracy.py | 2 | ||||
-rw-r--r-- | numbench/btlbase.py | 19 | ||||
-rw-r--r-- | numbench/lapack_accuracy.py | 2 | ||||
-rwxr-xr-x | numbench/main.py | 19 | ||||
-rw-r--r-- | numbench/metis.py | 2 | ||||
-rw-r--r-- | numbench/testdescr.py | 8 |
9 files changed, 107 insertions, 5 deletions
diff --git a/numbench/basemodule.py b/numbench/basemodule.py index c04b56c..332e528 100644 --- a/numbench/basemodule.py +++ b/numbench/basemodule.py @@ -10,6 +10,7 @@ from benchutils import mkdir, run_cmd from benchprint import Print import benchpkgconfig as pc from testdescr import testdescr +import benchload as load try: if not locals().has_key('initialized'): @@ -219,6 +220,7 @@ class BaseTest: return shlex.split(flags) def run_test(self, changes={}): + load.start() self.changes = changes # Convenient renames and definition of report files @@ -267,5 +269,6 @@ class BaseTest: Print("Test successful") # Return + load.stop() return self._generateResults() diff --git a/numbench/benchchilds.py b/numbench/benchchilds.py new file mode 100644 index 0000000..87e9ac9 --- /dev/null +++ b/numbench/benchchilds.py @@ -0,0 +1,13 @@ +try: + copy = procs + del copy +except: + procs = [] + +def terminate(): + for p in procs: + if p.poll() is None: + p.kill() + +def append(proc): + procs.append(proc)
\ No newline at end of file diff --git a/numbench/benchload.py b/numbench/benchload.py new file mode 100644 index 0000000..f226656 --- /dev/null +++ b/numbench/benchload.py @@ -0,0 +1,44 @@ +import sys, shlex, threading, time, subprocess as sp + +class PrintLoad(threading.Thread): + + _active = False + _continue = True + + def run(self): + while self._continue: + if self._active: + out = sp.check_output('uptime') + printstr = ' '.join(shlex.split(out)[-5:]) + sys.stdout.flush() + sys.stdout.write(printstr + '\r') + sys.stdout.flush() + time.sleep(.5) + + def setActive(self, active=True): + self._active = active + + def stop(self): + self._continue = False + + + +def start(): + printLoadThread.setActive(True) + +def stop(): + printLoadThread.setActive(False) + +def close(): + printLoadThread.stop() + +try: + needsinitialization = not initialized +except: + needsinitialization = True + +if needsinitialization: + printLoadThread = PrintLoad() + printLoadThread.start() + +initialized = True
\ No newline at end of file diff --git a/numbench/blas_accuracy.py b/numbench/blas_accuracy.py index 021ac12..de90ffa 100644 --- a/numbench/blas_accuracy.py +++ b/numbench/blas_accuracy.py @@ -7,6 +7,7 @@ from benchprint import Print from htmlreport import HTMLreport import basemodule import benchconfig as cfg +import benchchilds class Module(basemodule.BaseModule): @@ -123,6 +124,7 @@ class BLAS_accuracyTest(basemodule.BaseTest): logfile.write(80*'-' + '\n') proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE, env=self.runenv, cwd=self.testdir) + benchchilds.append(proc) # Interpret output Print.down() diff --git a/numbench/btlbase.py b/numbench/btlbase.py index d64b1ed..d8b4f4a 100644 --- a/numbench/btlbase.py +++ b/numbench/btlbase.py @@ -7,6 +7,7 @@ from benchprint import Print from htmlreport import HTMLreport import basemodule import benchconfig as cfg +import benchchilds from testdescr import testdescr @@ -126,6 +127,7 @@ class BTLTest(basemodule.BaseTest): logfile.write(80*'-' + '\n') proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE, env=self.runenv, cwd=self.testdir) + benchchilds.append(proc) # Interpret output while True: @@ -138,9 +140,11 @@ class BTLTest(basemodule.BaseTest): testname = resfile[6:-5-len(self.libname)] Print(resfile) - # 100 different sizes for each operation test + # Many different sizes for each operation test Print.down() - for i in xrange(100): + cur = 0 + tot = 1 + while cur != tot: outline = proc.stdout.readline() # If the line is void, something gone wrong if not outline: @@ -148,8 +152,15 @@ class BTLTest(basemodule.BaseTest): Print('Execution error') return 1 logfile.write(outline) - logfile.flush() - Print(outline.strip()) + logfile.flush() + + # Interpret line + outline = outline.strip() + (cur, tot) = shlex.split(outline)[-1][1:-1].split('/') + cur = int(cur); tot = int(tot) + Print(outline) + + Print.up() logfile.close() proc.wait() diff --git a/numbench/lapack_accuracy.py b/numbench/lapack_accuracy.py index f38709e..5e3d4c1 100644 --- a/numbench/lapack_accuracy.py +++ b/numbench/lapack_accuracy.py @@ -7,6 +7,7 @@ from benchprint import Print from htmlreport import HTMLreport import basemodule import benchconfig as cfg +import benchchilds class Module(basemodule.BaseModule): @@ -128,6 +129,7 @@ class LAPACK_accuracyTest(basemodule.BaseTest): logfile.write(80*'-' + '\n') proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=logfile, env=self.runenv, cwd=self.testdir) + benchchilds.append(proc) # Interpret output Print.down() diff --git a/numbench/main.py b/numbench/main.py index 3eb8da1..5bdacd2 100755 --- a/numbench/main.py +++ b/numbench/main.py @@ -1,9 +1,22 @@ #! /usr/bin/env python2 -import os, sys, shlex, time +import os, sys, signal, shlex, time from os.path import join as pjoin import subprocess as sp +# Set the signal handler +def close(*args): + load.close() + benchchilds.terminate() + Print._level = 0 + Print() + Print(80*'-') + Print("INTERRUPT TRIGGERED") + Print("Exiting") + exit(0) +signal.signal(signal.SIGINT, close) + + def print_usage(): print "Usage: numbench [blas|cblas|lapack|scalapack|fftw|metis|" + \ "blas_accuracy|lapack_accuracy] file args" @@ -65,6 +78,7 @@ def tests_from_input(input): ########################## import benchconfig as cfg +import benchchilds # If no argument is given, print the help if (len(sys.argv) < 2): @@ -108,6 +122,7 @@ except IndexError: from PortageUtils import * from benchprint import Print +import benchload as load @@ -241,6 +256,8 @@ for tn,(name,test) in enumerate(cfg.tests.items(),1): print +load.close() + # Save the results (first re-order them) results = {} for (name,test) in cfg.tests.items(): diff --git a/numbench/metis.py b/numbench/metis.py index f3ad768..8e6940f 100644 --- a/numbench/metis.py +++ b/numbench/metis.py @@ -6,6 +6,7 @@ import basemodule import benchconfig as cfg from benchutils import mkdir from benchprint import Print +import benchchilds inputsdir = pjoin(cfg.testsdir, 'metis-input') mkdir(inputsdir) @@ -117,6 +118,7 @@ class MetisTest: logname = pjoin(self.logdir, t + '_%i.log' % size) cmd = [exe, inputfile, parts] pr = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.STDOUT, env=env) + benchchilds.append(pr) lines = pr.communicate()[0].split('\n') # Interpret output diff --git a/numbench/testdescr.py b/numbench/testdescr.py index edadd06..1185c01 100644 --- a/numbench/testdescr.py +++ b/numbench/testdescr.py @@ -30,6 +30,14 @@ testdescr = { 'FFTW_1D_Backward_Measure': 'FFTW 1D Backward (Measure)', 'FFTW_1D_Forward_Estimate': 'FFTW 1D Forward (Estimate)', 'FFTW_1D_Backward_Estimate': 'FFTW 1D Backward (Estimate)', +'FFTW_2D_Forward_Measure': 'FFTW 2D Forward (Measure)', +'FFTW_2D_Backward_Measure': 'FFTW 2D Backward (Measure)', +'FFTW_2D_Forward_Estimate': 'FFTW 2D Forward (Estimate)', +'FFTW_2D_Backward_Estimate': 'FFTW 2D Backward (Estimate)', +'FFTW_3D_Forward_Measure': 'FFTW 3D Forward (Measure)', +'FFTW_3D_Backward_Measure': 'FFTW 3D Backward (Measure)', +'FFTW_3D_Forward_Estimate': 'FFTW 3D Forward (Estimate)', +'FFTW_3D_Backward_Estimate': 'FFTW 3D Backward (Estimate)', # METIS 'pmetis-8': 'Graph partitioning using pmetis - 8 partitions', |