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 1QWpe1-00060h-LZ for garchives@archives.gentoo.org; Wed, 15 Jun 2011 12:56:30 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AFFE31C095; Wed, 15 Jun 2011 12:56:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 6069B1C095 for ; Wed, 15 Jun 2011 12:56:20 +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 AF62C1BC011 for ; Wed, 15 Jun 2011 12:56:19 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 0D9FD8003C for ; Wed, 15 Jun 2011 12:56:19 +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: blas.py blasbase.py btlbase.py cblas.py lapack.py lapacktests.in main.py X-VCS-Directories: / X-VCS-Committer: spiros X-VCS-Committer-Name: Andrea Arteaga X-VCS-Revision: bb92ba7dd4ebb313038d5ea0452c06787d3998c0 Date: Wed, 15 Jun 2011 12:56:19 +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: ad22ba9f4893d18975e4cdd2cd02607b commit: bb92ba7dd4ebb313038d5ea0452c06787d3998c0 Author: spiros gmail com> AuthorDate: Wed Jun 15 12:55:43 2011 +0000 Commit: Andrea Arteaga gmail com> CommitDate: Wed Jun 15 12:55:43 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/auto-numerica= l-bench.git;a=3Dcommit;h=3Dbb92ba7d Introduced LAPACK, cleanup of btlbase (former blasbase). Some changes to main. --- blas.py | 70 ++++++++++++++++++++++++----- blasbase.py =3D> btlbase.py | 109 ++++++++++++++++++++++++-------------= -------- cblas.py | 72 ++++++++++++++++++++++++----- lapack.py | 56 +++++++++++++++++++++++ lapacktests.in | 2 + main.py | 26 +++++----- 6 files changed, 246 insertions(+), 89 deletions(-) diff --git a/blas.py b/blas.py index b9d6ed8..52bb221 100644 --- a/blas.py +++ b/blas.py @@ -1,23 +1,69 @@ -import os, blasbase +import os, btlbase import subprocess as sp +import shlex =20 -class Module(blasbase.ModuleBase):=20 +class Module(btlbase.BTLBase): + def _initialize(self): + self.libname =3D "blas" + self.avail1 =3D ['axpy', 'axpby', 'rot'] + self.avail2 =3D ['matrix_vector','atv','symv','syr2','ger', + 'trisolve_vector'] + self.avail3 =3D ['matrix_matrix', 'aat', 'trisolve_matrix', 'trm= m'] + self.avail =3D self.avail1 + self.avail2 + self.avail3 + =20 + def _parse_args(self, args): =20 + # Parse arguments + tests =3D [] + for i in args: + if i =3D=3D '1': + tests +=3D avail1 + continue + if i =3D=3D '2': + tests +=3D avail2 + continue + if i =3D=3D '3': + tests +=3D avail3 + continue + if i in self.avail: + tests.append(i) + continue + raise Exception("Argument not recognized: " + i) + =20 + # Sort tests + self.tests =3D [i for i in self.avail if i in tests] + =20 + # If no test is specified, then choose four standard tests + if len(self.tests) =3D=3D 0: + self.tests =3D ['axpy', 'matrix_vector', \ + 'trisolve_vector', 'matrix_matrix'] + =20 @staticmethod - def get_impls(root): - output =3D sp.Popen( - ['eselect', '--no-color', '--brief', 'blas', 'list'], - env=3D{'ROOT' : root}, stdout=3Dsp.PIPE - ).communicate()[0] - return output.strip().split('\n') + def _btl_source(): + return "/libs/BLAS/main.cpp" + =20 + @staticmethod + def _btl_includes(): + return ["/libs/BLAS"] + =20 + def _btl_defines(self): + return ["CBLASNAME=3D" + self.libname, "BLAS_INTERFACE"] =20 def _get_flags(self, root, impl, libdir): # Retrieve pkgconfig settings and map the directories to the new= root - path =3D \ - "%s/etc/env.d/alternatives/blas/%s/%s/pkgconfig" % (root,impl,= libdir) + path =3D "%s/etc/env.d/alternatives/%s/%s/%s/pkgconfig" % \ + (root, self.libname, impl, libdir) pkgconf =3D sp.Popen('pkg-config --libs --cflags blas', shell=3D= True, \ stdout=3Dsp.PIPE, env=3D{'PKG_CONFIG_PATH':path}).communicate(= )[0] pkgconf =3D pkgconf.replace('-L/', '-L'+root+'/') pkgconf =3D pkgconf.replace('-I/', '-I'+root+'/') - return pkgconf + " -DBLAS_INTERFACE" + return shlex.split(pkgconf) + =20 + =20 + def get_impls(self, root): + output =3D sp.Popen( + ['eselect', '--no-color', '--brief', self.libname, 'list'], + env=3D{'ROOT' : root}, stdout=3Dsp.PIPE + ).communicate()[0] + return output.strip().split('\n') =20 -del blasbase +del btlbase diff --git a/blasbase.py b/btlbase.py similarity index 66% rename from blasbase.py rename to btlbase.py index 36413c7..ecb74d9 100644 --- a/blasbase.py +++ b/btlbase.py @@ -5,62 +5,49 @@ import subprocess as sp try: import matplotlib.pyplot as plt import numpy as np + with_images =3D True except ImportError: sys.stderr.write('Error: matplotlib and numpy are needed' + \ 'in order to generate the reports!\n') - sys.stderr.write('Continue anyway.\n') =20 + sys.stderr.write('Continue anyway.\n\n') =20 + with_images =3D False =20 import btlutils as btl =20 run_cmd =3D lambda c : sp.Popen(c, stdout=3Dsp.PIPE).communicate()[0] =20 -class ModuleBase: +class BTLBase: def __init__(self, Print, libdir, args): self.Print =3D Print self.libdir =3D libdir self.summary =3D False self.summary_only =3D False =20 - avail1 =3D ['axpy', 'axpby', 'rot'] - avail2 =3D ['matrix_vector','atv','symv','syr2','ger','trisolve_= vector'] - avail3 =3D ['matrix_matrix', 'aat', 'trisolve_matrix', 'trmm'] + self._initialize() =20 - tests =3D [] + passargs =3D [] for i in args: if i =3D=3D '-S': self.summary_only =3D True continue - if i =3D=3D '-s': + elif i =3D=3D '-s': self.summary =3D True continue - if i =3D=3D '1': - tests +=3D avail1 - continue - if i =3D=3D '2': - tests +=3D avail2 - continue - if i =3D=3D '3': - tests +=3D avail3 - continue - if i in avail1 + avail2 + avail3: - tests.append(i) - continue - raise Exception("Argument not recognized: " + i) - self.tests =3D [i for i in avail1+avail2+avail3 if i in tests] + else: + passargs +=3D [i] =20 - if len(self.tests) =3D=3D 0: - self.tests =3D ['axpy', 'matrix_vector', \ - 'trisolve_vector', 'matrix_matrix'] + self._parse_args(passargs) =20 =20 - def run_test(self, root, impl, testdir): + def run_test(self, root, impl, testdir, env): + # Convenient renames and definition of report files=20 Print =3D self.Print libdir =3D self.libdir - name =3D 'blas' + name =3D self.libname files =3D ['%s/bench_%s_%s.dat' %(testdir, op, name) for op in s= elf.tests] =20 - # Create dir. If all results already exist use them, otherwise - # remove old results + # Create dir. If all results already exist use them and do not p= erform + # the tests, otherwise remove every old results. runtests =3D False if os.path.exists(testdir): runtests =3D not all([os.path.exists(i) for i in files]) @@ -77,31 +64,44 @@ class ModuleBase: =20 for i in files: if os.path.exists(i): os.remove(i) + =20 + # Prepare the environment + if env.has_key('LIBRARY_PATH'): + env['LIBRARY_PATH'] =3D root+libdir + ":" + env['LIBRARY_PAT= H'] + else: + env['LIBRARY_PATH'] =3D root+libdir + =20 + if env.has_key('INCLUDE_PATH'): + env['INCLUDE_PATH'] =3D root+"/usr/include" +":"+ env['INCLU= DE_PATH'] + else: + env['INCLUDE_PATH'] =3D root+"/usr/include" + =20 + if env.has_key('LD_LIBRARY_PATH'): + env['LD_LIBRARY_PATH'] =3D root+libdir + ":" + env['LD_LIBRA= RY_PATH'] + else: + env['LD_LIBRARY_PATH'] =3D root+libdir =20 - # Setup environment for testing + # Backup the environment oldenv =3D {} - for v in ('LIBRARY_PATH', 'INCLUDE_PATH', 'LD_LIBRARY_PATH'): - # Backup old environment variables - oldenv[v] =3D \ - (os.environ.has_key(v) and (os.environ[v],) or (None,))[0] - os.environ['LIBRARY_PATH'] =3D root + libdir - os.environ['INCLUDE_PATH'] =3D root + '/usr/include' - if oldenv['LD_LIBRARY_PATH'] !=3D None: - os.environ['LD_LIBRARY_PATH'] =3D \ - root + libdir + ":" + oldenv['LD_LIBRARY_PATH'] - else: - os.environ['LD_LIBRARY_PATH'] =3D root + libdir + for k in env.keys(): + oldenv[k] =3D \ + (os.environ.has_key(k) and (os.environ[k],) or (None,))[0] + =20 + # Set the environment + for k,v in env.items(): + os.environ[k] =3D v =20 # Compile + btldir =3D 'btl/' returncode, compilecl =3D btl.btlcompile( exe =3D testdir + "/test", - source =3D "btl/libs/BLAS/main.cpp", - btldir =3D 'btl/', - includes =3D ['btl/libs/BLAS'], - defines =3D ["CBLASNAME=3D" + name], + source =3D btldir + self._btl_source(), + btldir =3D btldir, + includes =3D [btldir+d for d in self._btl_includes()], + defines =3D self._btl_defines(), libs =3D [], libdirs =3D [root+libdir], - other =3D [self._get_flags(root, impl, libdir)] + other =3D self._get_flags(root, impl, libdir) ) if returncode !=3D 0: raise Exception("Compilation failed: " + compilecl) @@ -132,15 +132,20 @@ class ModuleBase: else: Print('Test successful') =20 - # Restore old environment variables - for v in ('LIBRARY_PATH', 'INCLUDE_PATH', 'LD_LIBRARY_PATH'): - if oldenv[v] !=3D None: - os.environ[v] =3D oldenv[v] - elif os.environ.has_key(v): - del os.environ[v] + # Restore the old environment + for k in env.keys(): + if oldenv[k] !=3D None: + os.environ[k] =3D oldenv[k] + elif os.environ.has_key(k): + del os.environ[k] return results =20 def save_results(self, results, figdir): + if not with_images: + self.Print("Report generation skipped - missing libraries") + return + =20 + # Re-order the result dictionary newresults =3D {} for test in self.tests: newresults[test] =3D {} @@ -149,6 +154,7 @@ class ModuleBase: resdat =3D results[nameimpl][test] newresults[test][nameimplstr] =3D resdat =20 =20 + # Generate summary - a single image with all plots if self.summary or self.summary_only: # Save summary figure sprows =3D (len(self.tests)+1)/2 @@ -165,6 +171,7 @@ class ModuleBase: plt.savefig(fname, format=3D'png') self.Print('Summary figure saved: ' + fname) =20 + # Generate plots if not self.summary_only: for test in self.tests: plt.figure(figsize=3D(12,9), dpi=3D300) diff --git a/cblas.py b/cblas.py index ad47c65..c3d0342 100644 --- a/cblas.py +++ b/cblas.py @@ -1,23 +1,69 @@ -import os, blasbase +import os, btlbase import subprocess as sp +import shlex =20 -class Module(blasbase.ModuleBase): +class Module(btlbase.BTLBase): + def _initialize(self): + self.libname =3D "cblas" + self.avail1 =3D ['axpy', 'axpby', 'rot'] + self.avail2 =3D ['matrix_vector','atv','symv','syr2','ger', + 'trisolve_vector'] + self.avail3 =3D ['matrix_matrix', 'aat', 'trisolve_matrix', 'trm= m'] + self.avail =3D self.avail1 + self.avail2 + self.avail3 + =20 + def _parse_args(self, args): =20 + # Parse arguments + tests =3D [] + for i in args: + if i =3D=3D '1': + tests +=3D avail1 + continue + if i =3D=3D '2': + tests +=3D avail2 + continue + if i =3D=3D '3': + tests +=3D avail3 + continue + if i in self.avail: + tests.append(i) + continue + raise Exception("Argument not recognized: " + i) + =20 + # Sort tests + self.tests =3D [i for i in self.avail if i in tests] + =20 + # If no test is specified, then choose four standard tests + if len(self.tests) =3D=3D 0: + self.tests =3D ['axpy', 'matrix_vector', \ + 'trisolve_vector', 'matrix_matrix'] + =20 @staticmethod - def get_impls(root): - output =3D sp.Popen( - ['eselect', '--no-color', '--brief', 'cblas', 'list'], - env=3D{'ROOT' : root}, stdout=3Dsp.PIPE - ).communicate()[0] - return output.strip().split('\n') - =20 + def _btl_source(): + return "/libs/BLAS/main.cpp" + =20 + @staticmethod + def _btl_includes(): + return ["/libs/BLAS"] + =20 + def _btl_defines(self): + return ["CBLASNAME=3D" + self.libname, "CBLAS_INTERFACE"] + =20 def _get_flags(self, root, impl, libdir): # Retrieve pkgconfig settings and map the directories to the new= root - path =3D \ - "%s/etc/env.d/alternatives/cblas/%s/%s/pkgconfig" % (root,impl= ,libdir) + path =3D "%s/etc/env.d/alternatives/%s/%s/%s/pkgconfig" % \ + (root, self.libname, impl, libdir) pkgconf =3D sp.Popen('pkg-config --libs --cflags cblas', shell=3D= True, \ stdout=3Dsp.PIPE, env=3D{'PKG_CONFIG_PATH':path}).communicate(= )[0] pkgconf =3D pkgconf.replace('-L/', '-L'+root+'/') pkgconf =3D pkgconf.replace('-I/', '-I'+root+'/') - return pkgconf + " -DCBLAS_INTERFACE" + return shlex.split(pkgconf) + =20 + =20 + def get_impls(self, root): + output =3D sp.Popen( + ['eselect', '--no-color', '--brief', self.libname, 'list'], + env=3D{'ROOT' : root}, stdout=3Dsp.PIPE + ).communicate()[0] + return output.strip().split('\n') =20 -del blasbase +del btlbase diff --git a/lapack.py b/lapack.py new file mode 100644 index 0000000..1d2f3cb --- /dev/null +++ b/lapack.py @@ -0,0 +1,56 @@ +import os, blasbase +import subprocess as sp +import shlex + +class Module(blasbase.BTLBase): + def _initialize(self): + self.libname =3D "lapack" + self.avail =3D ['general_solve', 'least_squares', 'lu_decomp', \ + 'cholesky', 'symm_ev'] + =20 + def _parse_args(self, args): =20 + # Parse arguments + tests =3D [] + for i in args: + if i in self.avail: + tests.append(i) + continue + raise Exception("Argument not recognized: " + i) + =20 + # Sort tests + self.tests =3D [i for i in self.avail if i in tests] + =20 + # If no test is specified, run everything + if len(self.tests) =3D=3D 0: + self.tests =3D self.avail + =20 + @staticmethod + def _btl_source(): + return "/libs/LAPACK/main.cpp" + =20 + @staticmethod + def _btl_includes(): + return ["/libs/BLAS", "libs/LAPACK"] + =20 + def _btl_defines(self): + return ["LAPACKNAME=3D" + self.libname] + =20 + def _get_flags(self, root, impl, libdir): + # Retrieve pkgconfig settings and map the directories to the new= root + path =3D "%s/etc/env.d/alternatives/%s/%s/%s/pkgconfig" % \ + (root, self.libname, impl, libdir) + pkgconf =3D sp.Popen('pkg-config --libs --cflags lapack', shell=3D= True, \ + stdout=3Dsp.PIPE, env=3D{'PKG_CONFIG_PATH':path}).communicate(= )[0] + pkgconf =3D pkgconf.replace('-L/', '-L'+root+'/') + pkgconf =3D pkgconf.replace('-I/', '-I'+root+'/') + return shlex.split(pkgconf) + =20 + =20 + def get_impls(self, root): + output =3D sp.Popen( + ['eselect', '--no-color', '--brief', self.libname, 'list'], + env=3D{'ROOT' : root}, stdout=3Dsp.PIPE + ).communicate()[0] + return output.strip().split('\n') + +del blasbase diff --git a/lapacktests.in b/lapacktests.in new file mode 100644 index 0000000..1dfcfb6 --- /dev/null +++ b/lapacktests.in @@ -0,0 +1,2 @@ +reference-O2 sci-libs/lapack-reference-3.3.1-r1 FFLAGS=3D-O2 +reference-O3 sci-libs/lapack-reference-3.3.1-r1 FFLAGS=3D-O3 diff --git a/main.py b/main.py index feeef86..8933834 100644 --- a/main.py +++ b/main.py @@ -80,11 +80,6 @@ try: except ImportError, IndexError: print_usage() exit(1) - =20 -#tmp =3D __import__(sys.argv[1], fromlist =3D ['Module']) -#mod =3D tmp.Module(Print, libdir, sys.argv[3:]) -#del tmp -#testsfname =3D sys.argv[2] =20 =20 """ @@ -102,22 +97,22 @@ After the tests every successful tested item will co= ntain the item "result", which can contain any type of data and will be used for the final report= . """ #tests =3D { -# "abcde" : { +# "reference-gfortran" : { # "package" : ('sci-libs', 'blas-reference', '3.3.1', 'r1'), # "env" : {'FC' : 'gfortran'} # }, # =20 -# "fghij" : { +# "eigen-gcc" : { # "package" : ('dev-cpp', 'eigen', '3.0.0', 'r1'), -# "env" : {'CXX' : 'gcc', 'CXXFLAGS' : '-O2'} +# "env" : {'CXX' : 'g++', 'CXXFLAGS' : '-O2'} # }, # =20 -# "klmno" : { +# "eigen-icc" : { # "package" : ('dev-cpp', 'eigen', '3.0.0', 'r1'), # "env" : {'CXX' : 'icc', 'CXXFLAGS' : '-O3'} # }, # -# "pqrst" : { +# "reference-ifort" : { # "package" : ('sci-libs', 'blas-reference', '3.3.1', 'r1'), # "env" : {'FC' : 'ifort'} # } @@ -136,13 +131,17 @@ dictionary; the line has to contain: input =3D file(testsfname).read() tests =3D tests_from_input(input) =20 +# Write summary +print 60*'=3D' print "The following tests will be run:" for tname, ttest in tests.items(): - print "Tests: " + tname + print "Test: " + tname print " - Package: " + "%s/%s-%s-%s" % ttest['package'] print " - Environment: " + \ ' '.join([n+'=3D"'+v+'"' for n,v in ttest['env'].items()]) print +print 60*'=3D' +print =20 for tn,(name,test) in enumerate(tests.items(),1): Print("BEGIN TEST %i - %s" % (tn, name)) @@ -187,9 +186,10 @@ for tn,(name,test) in enumerate(tests.items(),1): Print("Testing " + impl) Print.down() =20 - # Compile/link the test suite against the library + # Run the test suite testdir =3D "%s/%s/%s" % (testsdir, name, impl) - test['results'][impl] =3D mod.run_test(root, impl, testdir) + test['results'][impl] =3D \ + mod.run_test(root=3Droot, impl=3Dimpl, testdir=3Dtestdir, env=3D= test['env']) Print.up() =20 Print.up()