From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Qs0ey-0001oj-U5 for garchives@archives.gentoo.org; Fri, 12 Aug 2011 22:57:01 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A5BF721C149; Fri, 12 Aug 2011 22:56:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 4E7D621C149 for ; Fri, 12 Aug 2011 22:56:52 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9DE671B4019 for ; Fri, 12 Aug 2011 22:56:51 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id A6EF280040 for ; Fri, 12 Aug 2011 22:56:50 +0000 (UTC) From: "Andrea Arteaga" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andrea Arteaga" Message-ID: Subject: [gentoo-commits] proj/auto-numerical-bench:master commit in: / X-VCS-Repository: proj/auto-numerical-bench X-VCS-Files: basemodule.py benchconfig.py benchprint.py blasbase.py btlbase.py lapack.py main.py X-VCS-Directories: / X-VCS-Committer: spiros X-VCS-Committer-Name: Andrea Arteaga X-VCS-Revision: a0bba3e031348a0d5274708b4c6e401e9ae68ed0 Date: Fri, 12 Aug 2011 22:56:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: a12be4dfe9f26f1c2bc956e0d51c3462 commit: a0bba3e031348a0d5274708b4c6e401e9ae68ed0 Author: spiros gmail com> AuthorDate: Fri Aug 12 22:55:56 2011 +0000 Commit: Andrea Arteaga gmail com> CommitDate: Fri Aug 12 22:55:56 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/auto-numerica= l-bench.git;a=3Dcommit;h=3Da0bba3e0 Some help added. --- basemodule.py | 13 +++++ benchconfig.py | 4 -- benchprint.py | 15 ++++-- blasbase.py | 17 +++++-- btlbase.py | 11 ++++ lapack.py | 9 ++- 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 +=3D [i] =20 self._parse_args(passargs) + =20 + @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 re= sults" + 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 =20 # 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 =3D pjoin(os.environ['HOME'], ".benchmarks/log", modname + "_" + time.strftime('%Y-%m-%d')) =20 - bu.mkdir(testsdir) - bu.mkdir(rootsdir) - bu.mkdir(pkgsdir) - =20 # Report directory reportdirb +=3D 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=3D10): self._level =3D 0 self._maxlevel =3D maxlevel - bu.mkdir(dirname(logfile)) - self._logfile =3D file(logfile, 'w') + self._logfile =3D logfile =20 def __call__(self, arg): if self._level > self._maxlevel: @@ -21,14 +20,18 @@ if needsinitialization: =20 if self._level <=3D 0: print str(arg) - print >> self._logfile, str(arg) - self._logfile.flush() + bu.mkdir(dirname(logfile)) + logfile =3D file(self._logfile, 'a') + print >> logfile, str(arg) + logfile.close() return =20 printstr =3D (self._level-1)*" " + "-- " + str(arg) if self._level <=3D self._maxlevel-1: - print >> self._logfile, printstr - self._logfile.flush() + bu.mkdir(dirname(logfile)) + logfile =3D file(self._logfile, 'a') + print >> logfile, printstr + logfile.close() print printstr =20 def up(self, n=3D1): 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 =20 +avail1 =3D ['axpy', 'axpby', 'rot'] +avail2 =3D ['matrix_vector','atv','symv', 'ger', 'syr2', + 'trisolve_vector'] +avail3 =3D ['matrix_matrix', 'aat', 'trisolve_matrix', 'trmm'] + class BLASBase(btlbase.BTLBase): + =20 + avail1 =3D avail1 + avail2 =3D avail2 + avail3 =3D avail3 + avail =3D avail1 + avail2 + avail3 + =20 def _initialize(self): - self.avail1 =3D ['axpy', 'axpby', 'rot'] - self.avail2 =3D ['matrix_vector','atv','symv', 'ger', 'syr2', - 'trisolve_vector'] - self.avail3 =3D ['matrix_matrix', 'aat', 'trisolve_matrix', 'trm= m'] - self.avail =3D self.avail1 + self.avail2 + self.avail3 + pass =20 def _parse_args(self, args): =20 # Parse arguments diff --git a/btlbase.py b/btlbase.py index 5a7c555..4947555 100644 --- a/btlbase.py +++ b/btlbase.py @@ -7,10 +7,21 @@ from benchprint import Print from htmlreport import HTMLreport import basemodule import benchconfig as cfg +from testdescr import testdescr =20 =20 class BTLBase(basemodule.BaseModule): =20 + @classmethod + def printHelp(cls): + basemodule.BaseModule.printHelp() + =20 + print "Tests:" + for i in cls.avail: + print " " + i + ":" + print " " + testdescr[i] + print + =20 def _parse_args(self, args): # Generate list of dat (result) files, relative to the testdir self.files =3D [pjoin('bench_%s_%s.dat' % (op, self.libname)) \ diff --git a/lapack.py b/lapack.py index 677603e..ae318fa 100644 --- a/lapack.py +++ b/lapack.py @@ -3,11 +3,14 @@ import subprocess as sp import shlex =20 class Module(btlbase.BTLBase): - def _initialize(self): - self.libname =3D "lapack" - self.avail =3D ['general_solve', 'least_squares', 'lu_decomp', \ + =20 + libname =3D "lapack" + avail =3D ['general_solve', 'least_squares', 'lu_decomp', \ 'cholesky', 'qr_decomp', 'svd_decomp', 'syev', 'stev', 'symm_e= v'] =20 + def _initialize(self): + pass + =20 def _parse_args(self, args): =20 # Parse arguments tests =3D [] diff --git a/main.py b/main.py index 0bd842f..4be9802 100755 --- a/main.py +++ b/main.py @@ -5,33 +5,89 @@ from os.path import join as pjoin import subprocess as sp =20 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" =20 -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 =3D os.path.abspath(sys.argv[2]) - os.chdir(cfg.scriptdir) - tmp =3D __import__(sys.argv[1], fromlist =3D ['Module']) - mod =3D 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) - =20 +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 co= mmon" + print "libraries that run faster on the machine and are more accurat= e." + print "The script makes use of the portage features in order to down= load," + 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 comm= and:" + print " numbench module --help" + print + print + print "Config file:" + print "In order to run a test, a configuration file has to be provid= ed." + 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 compi= le-time" + print "environment; for each different version or environment, a dif= ferent" + print "line has to be written." + print + print "Each line begins with an identification token of the test. Th= is" + print "identification can contain any characters, but it is recommen= ded" + 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 or= der" + print "to do that, the user has to use the KEY=3DVALUE format. If th= e value" + print "contains a whitespace, the single or double quoting marks hav= e to be" + print "used. The following are two valid configuration lines that de= fine" + print "the tests for the sci-libs/atlas package with different compi= lers" + print "and CFLAGS:" + print + print "atlas-gcc sci-libs/atlas-3.9.46 CC=3Dgcc CFLAGS=3D-O2" + print "atlas-gcc-4.6.1 sci-libs/atlas-3.9.46 CC=3Dgcc-4.6.1", + print "CFLAGS=3D\"-O3 -march=3Dnative\"" + 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 instanc= e, 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 quot= ing" + print "marks); then the script will skip the implementation. The fol= lowing" + print "is an example where the 32-bit implementations of the acml ar= e" + print "skipped:" + print + print "acml sci-libs/acml-4.4.0 -acml32-gfortran -acml32-gfortran-op= enmp" + print + print "The last configuration option that can be used is for librari= es 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 speci= fic" + print "BLAS implementation through the 'blas:implementation' (withou= t" + 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 instal= led for" + print "this to work):" + print + print "atlas sci-libs/atlas-3.9.46 blas:openblas" =20 def tests_from_input(input): tests =3D {} @@ -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); =20 + cfg.modulename =3D sys.argv[1] + =20 + # Print module help + if (sys.argv[2] in ('-h', '--help')): + os.chdir(cfg.scriptdir) + cfg.inputfile =3D '' + tmp =3D __import__(cfg.modulename, fromlist =3D ['Module']) + tmp.Module.printHelp() + exit(0) + =20 + # Normal run: import module + cfg.inputfile =3D os.path.abspath(sys.argv[2]) + os.chdir(cfg.scriptdir) + tmp =3D __import__(sys.argv[1], fromlist =3D ['Module']) + mod =3D tmp.Module(sys.argv[3:]) + del tmp + cfg.makedirs() + =20 +except ImportError as e: + print e + print_usage() + exit(1) +except IndexError: + print_usage() + exit(1) + =20 +from PortageUtils import * +from benchprint import Print =20 =20 =20