summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Arteaga <andyspiros@gmail.com>2011-08-20 01:11:22 +0200
committerAndrea Arteaga <andyspiros@gmail.com>2011-08-20 01:11:22 +0200
commiteab48a80b9a8a80d3115d9ac13b68f55a938de84 (patch)
tree7b8a6c3107bdcc61303cd51f5ac1348aa3093ad7
parentUpdated documentation and allow more environment bash files. (diff)
downloadauto-numerical-bench-eab48a80b9a8a80d3115d9ac13b68f55a938de84.tar.gz
auto-numerical-bench-eab48a80b9a8a80d3115d9ac13b68f55a938de84.tar.bz2
auto-numerical-bench-eab48a80b9a8a80d3115d9ac13b68f55a938de84.zip
Added purge. Added -N to BTL for samples num.
-rw-r--r--numbench/benchconfig.py11
-rw-r--r--numbench/benchutils.py7
-rw-r--r--numbench/blasbase.py7
-rw-r--r--numbench/btlbase.py9
-rw-r--r--numbench/fftw.py6
-rw-r--r--numbench/lapack.py8
-rwxr-xr-xnumbench/main.py18
-rw-r--r--numbench/scalapack.py8
8 files changed, 58 insertions, 16 deletions
diff --git a/numbench/benchconfig.py b/numbench/benchconfig.py
index ede97ef..f5f30d4 100644
--- a/numbench/benchconfig.py
+++ b/numbench/benchconfig.py
@@ -44,8 +44,7 @@ if needsinitialization:
rootsdir = os.environ['HOME'] + "/.benchmarks/roots/"
pkgsdir = os.environ['HOME'] + "/.benchmarks/packages/"
reportdirb = os.environ['HOME'] + "/.benchmarks/reports/"
- logdirb = pjoin(os.environ['HOME'], ".benchmarks/log",
- modname + "_" + time.strftime('%Y-%m-%d'))
+ logdirb = pjoin(os.environ['HOME'], ".benchmarks/log/")
# Report directory
reportdirb += modname + "_" + time.strftime('%Y-%m-%d')
@@ -61,6 +60,7 @@ if needsinitialization:
del reportdirb
# Logs directory
+ logdirb += modname + "_" + time.strftime('%Y-%m-%d')
if os.path.exists(logdirb):
n = 1
while True:
@@ -79,6 +79,13 @@ def makedirs():
bu.mkdir(reportdir)
bu.mkdir(logdir)
+def purgedirs():
+ bu.rmdir(rootsdir)
+ bu.rmdir(testsdir)
+ bu.rmdir(pkgsdir)
+ bu.rmdir(pjoin(reportdir, '..'))
+ bu.rmdir(pjoin(logdir, '..'))
+
inizialized = True
diff --git a/numbench/benchutils.py b/numbench/benchutils.py
index 7f2542d..a15d9c3 100644
--- a/numbench/benchutils.py
+++ b/numbench/benchutils.py
@@ -1,4 +1,4 @@
-import os, sys, string, random
+import os, sys, shutil, string, random
import subprocess as sp
__all__ = ['mkdir', 'tmpfile', 'run_cmd']
@@ -6,6 +6,11 @@ __all__ = ['mkdir', 'tmpfile', 'run_cmd']
def mkdir(dir):
if not os.path.exists(dir):
os.makedirs(dir)
+
+def rmdir(dir):
+ if os.path.isdir(dir):
+ shutil.rmtree(dir, True)
+
def tmpfile(dir="/var/tmp"):
"""Returns the path of a free temporary file within the given directory."""
diff --git a/numbench/blasbase.py b/numbench/blasbase.py
index 2f2b84e..f7c1d33 100644
--- a/numbench/blasbase.py
+++ b/numbench/blasbase.py
@@ -18,7 +18,8 @@ class BLASBase(btlbase.BTLBase):
def _initialize(self):
pass
- def _parse_args(self, args):
+ def _parse_args(self, args):
+ passargs = []
# Parse arguments
tests = []
for i in args:
@@ -34,7 +35,7 @@ class BLASBase(btlbase.BTLBase):
if i in self.avail:
tests.append(i)
continue
- raise Exception("Argument not recognized: " + i)
+ passargs.append(i)
# Sort tests
self.tests = [i for i in self.avail if i in tests]
@@ -44,7 +45,7 @@ class BLASBase(btlbase.BTLBase):
self.tests = ['axpy', 'matrix_vector', \
'trisolve_vector', 'matrix_matrix']
- btlbase.BTLBase._parse_args(self, args)
+ btlbase.BTLBase._parse_args(self, passargs)
@staticmethod
def _testClass():
diff --git a/numbench/btlbase.py b/numbench/btlbase.py
index d8b4f4a..8e2e1e1 100644
--- a/numbench/btlbase.py
+++ b/numbench/btlbase.py
@@ -10,7 +10,6 @@ import benchconfig as cfg
import benchchilds
from testdescr import testdescr
-
class BTLBase(basemodule.BaseModule):
@classmethod
@@ -27,6 +26,12 @@ class BTLBase(basemodule.BaseModule):
# Generate list of dat (result) files, relative to the testdir
self.files = [pjoin('bench_%s_%s.dat' % (op, self.libname)) \
for op in self.tests]
+
+ for i in args:
+ if i[:2] == '-N':
+ BTLTest.N = i[2:]
+ continue
+ raise Exception("Argument not recognized: " + i)
def save_results(self, results):
basemodule.BaseModule.save_results(self, results, 'semilogx')
@@ -121,6 +126,8 @@ class BTLTest(basemodule.BaseTest):
# Open pipe
logfile = file(logfile, 'w')
args = preargs + [exe] + list(self.tests)
+ if self.N is not None:
+ args.append('-N' + self.N)
logfile.write(' '.join( \
[n + '="'+v+'"' for n,v in self.runenv.items()] ) + ' ')
logfile.write(' '.join(args) + '\n')
diff --git a/numbench/fftw.py b/numbench/fftw.py
index 1596921..829b89d 100644
--- a/numbench/fftw.py
+++ b/numbench/fftw.py
@@ -16,13 +16,15 @@ class Module(btlbase.BTLBase):
)
def _parse_args(self, args):
+ passargs = []
+
# Parse arguments
tests = []
for i in args:
if i in self.avail:
tests.append(i)
continue
- raise Exception("Argument not recognized: " + i)
+ passargs.append(i)
# Sort tests
self.tests = [i for i in self.avail if i in tests]
@@ -31,7 +33,7 @@ class Module(btlbase.BTLBase):
if len(self.tests) == 0:
self.tests = self.avail
- btlbase.BTLBase._parse_args(self, args)
+ btlbase.BTLBase._parse_args(self, passargs)
@staticmethod
def get_impls(root):
diff --git a/numbench/lapack.py b/numbench/lapack.py
index ae318fa..2f48150 100644
--- a/numbench/lapack.py
+++ b/numbench/lapack.py
@@ -11,14 +11,16 @@ class Module(btlbase.BTLBase):
def _initialize(self):
pass
- def _parse_args(self, args):
+ def _parse_args(self, args):
+ passargs = []
+
# Parse arguments
tests = []
for i in args:
if i in self.avail:
tests.append(i)
continue
- raise Exception("Argument not recognized: " + i)
+ passargs.append(i)
# Sort tests
self.tests = [i for i in self.avail if i in tests]
@@ -28,7 +30,7 @@ class Module(btlbase.BTLBase):
self.tests = ['lu_decomp', 'cholesky', 'qr_decomp', 'svd_decomp',\
'syev', 'stev']
- btlbase.BTLBase._parse_args(self, args)
+ btlbase.BTLBase._parse_args(self, passargs)
@staticmethod
def _testClass():
diff --git a/numbench/main.py b/numbench/main.py
index bab534f..f0fe489 100755
--- a/numbench/main.py
+++ b/numbench/main.py
@@ -26,6 +26,10 @@ def print_help():
print " numbench [ -h | --help ]"
print " numbench module [ -h | --help ]"
print
+ print "Options:"
+ print " [ -p | --purge ] - Remove old results, logs, tests and packages"
+ print " [ -h | --help ] - Display an help message"
+ print
print "Modules:"
print " blas - Test BLAS implementations"
print " cblas - Test CBLAS implementations"
@@ -142,11 +146,23 @@ try:
exit(0)
# Normal run: import module
+
+ # Catch command-line arguments
+ passargs = []
+ purge = False
+ for v in sys.argv[3:]:
+ if v in ('-p', '--purge'):
+ purge = True
+ else:
+ passargs.append(v)
+
cfg.inputfile = os.path.abspath(sys.argv[2])
os.chdir(cfg.scriptdir)
tmp = __import__('numbench.'+cfg.modulename, fromlist = ['Module'])
- mod = tmp.Module(sys.argv[3:])
+ mod = tmp.Module(passargs)
del tmp
+ if purge:
+ cfg.purgedirs()
cfg.makedirs()
except ImportError as e:
diff --git a/numbench/scalapack.py b/numbench/scalapack.py
index 54f79cb..827417a 100644
--- a/numbench/scalapack.py
+++ b/numbench/scalapack.py
@@ -8,7 +8,9 @@ class Module(btlbase.BTLBase):
self.avail = ['axpy', 'matrix_vector', 'lu_decomp', 'cholesky',
'qr_decomp', 'svd_decomp', 'symm_ev']
- def _parse_args(self, args):
+ def _parse_args(self, args):
+ passargs = []
+
# Parse arguments
tests = []
skip = 0
@@ -24,7 +26,7 @@ class Module(btlbase.BTLBase):
if a in self.avail:
tests.append(a)
continue
- raise Exception("Argument not recognized: " + a)
+ passargs.append(a)
# Sort tests
self.tests = [i for i in self.avail if i in tests]
@@ -33,7 +35,7 @@ class Module(btlbase.BTLBase):
if len(self.tests) == 0:
self.tests = self.avail
- btlbase.BTLBase._parse_args(self, args)
+ btlbase.BTLBase._parse_args(self, passargs)
@staticmethod
def _testClass():