diff options
author | spiros <andyspiros@gmail.com> | 2011-08-13 00:55:56 +0200 |
---|---|---|
committer | spiros <andyspiros@gmail.com> | 2011-08-13 00:55:56 +0200 |
commit | a0bba3e031348a0d5274708b4c6e401e9ae68ed0 (patch) | |
tree | f0371e3a37b30d5f5fed7c80c2755839c4cf2123 | |
parent | Added main logging. Solved issues with utils and Portage. (diff) | |
download | auto-numerical-bench-a0bba3e031348a0d5274708b4c6e401e9ae68ed0.tar.gz auto-numerical-bench-a0bba3e031348a0d5274708b4c6e401e9ae68ed0.tar.bz2 auto-numerical-bench-a0bba3e031348a0d5274708b4c6e401e9ae68ed0.zip |
Some help added.
-rw-r--r-- | basemodule.py | 13 | ||||
-rw-r--r-- | benchconfig.py | 4 | ||||
-rw-r--r-- | benchprint.py | 15 | ||||
-rw-r--r-- | blasbase.py | 17 | ||||
-rw-r--r-- | btlbase.py | 11 | ||||
-rw-r--r-- | lapack.py | 9 | ||||
-rwxr-xr-x | main.py | 147 |
7 files changed, 172 insertions, 44 deletions
diff --git a/basemodule.py b/basemodule.py index b55adfc..6185774 100644 --- a/basemodule.py +++ b/basemodule.py @@ -45,6 +45,19 @@ class BaseModule: passargs += [i] self._parse_args(passargs) + + @classmethod + def printHelp(cls): + print "Usage: numbench " + cfg.modulename + " [options] [tests]" + print + print "Generic options:" + print " -s -summary" + print " Generate a summary image that contains all tests results" + print " and show it on the HTML report page." + print + print " -S -summary-only" + print " Only generate the summary image and skip all other plots." + print # Alternatives-2 version def get_impls(self, root): diff --git a/benchconfig.py b/benchconfig.py index f707959..6769e8d 100644 --- a/benchconfig.py +++ b/benchconfig.py @@ -43,10 +43,6 @@ if needsinitialization: logdirb = pjoin(os.environ['HOME'], ".benchmarks/log", modname + "_" + time.strftime('%Y-%m-%d')) - bu.mkdir(testsdir) - bu.mkdir(rootsdir) - bu.mkdir(pkgsdir) - # Report directory reportdirb += modname + "_" + time.strftime('%Y-%m-%d') if os.path.exists(reportdirb): diff --git a/benchprint.py b/benchprint.py index e4b7e41..8c394e2 100644 --- a/benchprint.py +++ b/benchprint.py @@ -12,8 +12,7 @@ if needsinitialization: def __init__(self, logfile, maxlevel=10): self._level = 0 self._maxlevel = maxlevel - bu.mkdir(dirname(logfile)) - self._logfile = file(logfile, 'w') + self._logfile = logfile def __call__(self, arg): if self._level > self._maxlevel: @@ -21,14 +20,18 @@ if needsinitialization: if self._level <= 0: print str(arg) - print >> self._logfile, str(arg) - self._logfile.flush() + bu.mkdir(dirname(logfile)) + logfile = file(self._logfile, 'a') + print >> logfile, str(arg) + logfile.close() return printstr = (self._level-1)*" " + "-- " + str(arg) if self._level <= self._maxlevel-1: - print >> self._logfile, printstr - self._logfile.flush() + bu.mkdir(dirname(logfile)) + logfile = file(self._logfile, 'a') + print >> logfile, printstr + logfile.close() print printstr def up(self, n=1): diff --git a/blasbase.py b/blasbase.py index b5d899c..2f2b84e 100644 --- a/blasbase.py +++ b/blasbase.py @@ -3,13 +3,20 @@ import subprocess as sp import shlex from os.path import join as pjoin +avail1 = ['axpy', 'axpby', 'rot'] +avail2 = ['matrix_vector','atv','symv', 'ger', 'syr2', + 'trisolve_vector'] +avail3 = ['matrix_matrix', 'aat', 'trisolve_matrix', 'trmm'] + class BLASBase(btlbase.BTLBase): + + avail1 = avail1 + avail2 = avail2 + avail3 = avail3 + avail = avail1 + avail2 + avail3 + def _initialize(self): - self.avail1 = ['axpy', 'axpby', 'rot'] - self.avail2 = ['matrix_vector','atv','symv', 'ger', 'syr2', - 'trisolve_vector'] - self.avail3 = ['matrix_matrix', 'aat', 'trisolve_matrix', 'trmm'] - self.avail = self.avail1 + self.avail2 + self.avail3 + pass def _parse_args(self, args): # Parse arguments @@ -7,10 +7,21 @@ from benchprint import Print from htmlreport import HTMLreport import basemodule import benchconfig as cfg +from testdescr import testdescr class BTLBase(basemodule.BaseModule): + @classmethod + def printHelp(cls): + basemodule.BaseModule.printHelp() + + print "Tests:" + for i in cls.avail: + print " " + i + ":" + print " " + testdescr[i] + print + def _parse_args(self, args): # Generate list of dat (result) files, relative to the testdir self.files = [pjoin('bench_%s_%s.dat' % (op, self.libname)) \ @@ -3,11 +3,14 @@ import subprocess as sp import shlex class Module(btlbase.BTLBase): - def _initialize(self): - self.libname = "lapack" - self.avail = ['general_solve', 'least_squares', 'lu_decomp', \ + + libname = "lapack" + avail = ['general_solve', 'least_squares', 'lu_decomp', \ 'cholesky', 'qr_decomp', 'svd_decomp', 'syev', 'stev', 'symm_ev'] + def _initialize(self): + pass + def _parse_args(self, args): # Parse arguments tests = [] @@ -5,33 +5,89 @@ from os.path import join as pjoin import subprocess as sp def print_usage(): - print "Usage: benchmarks [blas|cblas|lapack] file args" + print "Usage: numbench [blas|cblas|lapack|scalapack|fftw|metis|" + \ + "blas_accuracy|lapack_accuracy] file args" -if len(sys.argv) < 3: - print_usage() - exit(1) - -from PortageUtils import * -import benchconfig as cfg -from benchprint import Print - - -# Import the desired module or print help and exit -try: - cfg.inputfile = os.path.abspath(sys.argv[2]) - os.chdir(cfg.scriptdir) - tmp = __import__(sys.argv[1], fromlist = ['Module']) - mod = tmp.Module(sys.argv[3:]) - del tmp - cfg.makedirs() -except ImportError as e: - print e - print_usage() - exit(1) -except IndexError: - print_usage() - exit(1) - +def print_help(): + print "Usage: numbench module conffile [options]" + print " numbench module [-h|--help]" + print + print "numbench is a tool for compiling and benchmarking numerical" + print "libraries. It is useful to find out the implementations of common" + print "libraries that run faster on the machine and are more accurate." + print "The script makes use of the portage features in order to download," + print "compile, install and test the packages" + print + print + print "Modules:" + print "The following modules are available:" + print " blas - Test BLAS implementations" + print " cblas - Test CBLAS implementations" + print " lapack - Test LAPACK implementations" + print " scalapack - Test the ScaLAPACK library" + print " blas_accuracy - Test BLAS implementations for accuracy" + print " lapack_accuracy - Test LAPACK implementations for accuracy" + print " fftw - Test the FFTW library" + print " metis - Test the METIS tools" + print + print "More information about a module is available through the command:" + print " numbench module --help" + print + print + print "Config file:" + print "In order to run a test, a configuration file has to be provided." + print "Each line of this file defines a package that is to be tested." + print "It is possible to test different versions of the same package, or" + print "even to test many times the same package with different compile-time" + print "environment; for each different version or environment, a different" + print "line has to be written." + print + print "Each line begins with an identification token of the test. This" + print "identification can contain any characters, but it is recommended" + print "that it only contains alphanumeric digits, the period . , the minus" + print "sign - and the underscore _ ." + print "After the identification word, the package has to be provided. The" + print "package specification should be fully provided, in the usual" + print "category/package-version[-revision] format. For instance" + print "sci-libs/lapack-reference-3.3.1-r1. However, the script will try to" + print "choose the best package in case of lacking information." + print "After the package, the environment has to be specified. In order" + print "to do that, the user has to use the KEY=VALUE format. If the value" + print "contains a whitespace, the single or double quoting marks have to be" + print "used. The following are two valid configuration lines that define" + print "the tests for the sci-libs/atlas package with different compilers" + print "and CFLAGS:" + print + print "atlas-gcc sci-libs/atlas-3.9.46 CC=gcc CFLAGS=-O2" + print "atlas-gcc-4.6.1 sci-libs/atlas-3.9.46 CC=gcc-4.6.1", + print "CFLAGS=\"-O3 -march=native\"" + print + print "Variables that affect the emerge process, such as USE, can be used" + print "and are effective." + print "More configuration options are available. As each package can" + print "install many implementations of the same library (for instance, the" + print "sci-libs/atlas package installs the serial version and the" + print "parallelized version with threads or openmp, depending on the USE" + print "flags), each implementation is tested; but if you do not want to" + print "test a specific implementation, you can mask it by adding to the" + print "configuration line the string '-implementation' (without quoting" + print "marks); then the script will skip the implementation. The following" + print "is an example where the 32-bit implementations of the acml are" + print "skipped:" + print + print "acml sci-libs/acml-4.4.0 -acml32-gfortran -acml32-gfortran-openmp" + print + print "The last configuration option that can be used is for libraries that" + print "internally use other libraries. For example, most LAPACK" + print "implementations lie on BLAS and/or CBLAS implementations. It is" + print "possible to make the tested LAPACK implementation use a specific" + print "BLAS implementation through the 'blas:implementation' (without" + print "quotation marks) format. For instance, the following line" + print "defines a test where the atlas LAPACK implementation uses the" + print "openblas library as BLAS and CBLAS (openblas has to be installed for" + print "this to work):" + print + print "atlas sci-libs/atlas-3.9.46 blas:openblas" def tests_from_input(input): tests = {} @@ -69,7 +125,46 @@ def tests_from_input(input): else: sys.stderr.write('Error: package ' + spl[1] + ' not found\n') return tests + +import benchconfig as cfg + + +# Import the desired module or print help and exit +try: + + # Print main help + if (sys.argv[1] in ('-h', '--help')): + print_help() + exit(0); + cfg.modulename = sys.argv[1] + + # Print module help + if (sys.argv[2] in ('-h', '--help')): + os.chdir(cfg.scriptdir) + cfg.inputfile = '' + tmp = __import__(cfg.modulename, fromlist = ['Module']) + tmp.Module.printHelp() + exit(0) + + # Normal run: import module + cfg.inputfile = os.path.abspath(sys.argv[2]) + os.chdir(cfg.scriptdir) + tmp = __import__(sys.argv[1], fromlist = ['Module']) + mod = tmp.Module(sys.argv[3:]) + del tmp + cfg.makedirs() + +except ImportError as e: + print e + print_usage() + exit(1) +except IndexError: + print_usage() + exit(1) + +from PortageUtils import * +from benchprint import Print |