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 1Qdqrp-0006GU-M7 for garchives@archives.gentoo.org; Mon, 04 Jul 2011 21:39:47 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3558121C0E0; Mon, 4 Jul 2011 21:39:01 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BA91821C0E0 for ; Mon, 4 Jul 2011 21:39:00 +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 F1A2B1B4003 for ; Mon, 4 Jul 2011 21:38:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 5E92E8003D for ; Mon, 4 Jul 2011 21:38:59 +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: app-benchmarks/autobench/files/python/ X-VCS-Repository: proj/auto-numerical-bench X-VCS-Files: app-benchmarks/autobench/files/python/basemodule.py app-benchmarks/autobench/files/python/blas_accuracy.py app-benchmarks/autobench/files/python/blasbase.py app-benchmarks/autobench/files/python/btlbase.py app-benchmarks/autobench/files/python/lapack.py X-VCS-Directories: app-benchmarks/autobench/files/python/ X-VCS-Committer: spiros X-VCS-Committer-Name: Andrea Arteaga X-VCS-Revision: c2093208c4f1e989a4f0041e33ee3bafd72a2ae6 Date: Mon, 4 Jul 2011 21:38:59 +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: b7e0e176f558e83b041fd4883fdd405e commit: c2093208c4f1e989a4f0041e33ee3bafd72a2ae6 Author: spiros gmail com> AuthorDate: Mon Jul 4 09:35:40 2011 +0000 Commit: Andrea Arteaga gmail com> CommitDate: Mon Jul 4 09:35:40 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/auto-numerica= l-bench.git;a=3Dcommit;h=3Dc2093208 BaseModule introduced. Work on accuracy module. --- .../python/{blas_accuracy.py =3D> basemodule.py} | 153 ++++++++----= ----- .../autobench/files/python/blas_accuracy.py | 179 +++-----------= ----- app-benchmarks/autobench/files/python/blasbase.py | 23 +--- app-benchmarks/autobench/files/python/btlbase.py | 188 +++-----------= ------ app-benchmarks/autobench/files/python/lapack.py | 26 +--- 5 files changed, 128 insertions(+), 441 deletions(-) diff --git a/app-benchmarks/autobench/files/python/blas_accuracy.py b/app= -benchmarks/autobench/files/python/basemodule.py similarity index 60% copy from app-benchmarks/autobench/files/python/blas_accuracy.py copy to app-benchmarks/autobench/files/python/basemodule.py index 9e13ed2..5a35cc7 100644 --- a/app-benchmarks/autobench/files/python/blas_accuracy.py +++ b/app-benchmarks/autobench/files/python/basemodule.py @@ -1,8 +1,8 @@ -from pprint import pprint from os.path import join as pjoin import subprocess as sp import shlex, os from htmlreport import HTMLreport +import basemodule =20 try: import matplotlib.pyplot as plt @@ -16,7 +16,7 @@ except ImportError: =20 run_cmd =3D lambda c : sp.Popen(c, stdout=3Dsp.PIPE).communicate()[0] =20 -class Module: +class BaseModule: def __init__(self, Print, libdir, args): self.Print =3D Print self.libdir =3D libdir @@ -37,31 +37,14 @@ class Module: passargs +=3D [i] =20 self._parse_args(passargs) - =20 - def _initialize(self): - self.libname =3D 'blas' - self.avail=3D['axpy', 'matrix_vector', 'trisolve_vector', 'matri= x_matrix'] - =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, then do everything - if len(self.tests) =3D=3D 0: - self.tests =3D self.avail =20 + # Alternatives-2 version with pkg-config def _get_flags(self, root, impl, libdir): + while libdir[0] =3D=3D '/': + libdir =3D libdir[1:] # Retrieve pkgconfig settings and map the directories to the new= root path =3D pjoin(root, "etc/env.d/alternatives", \ - self.libname, impl, libdir, "pkgconfig") + self.libname,impl,libdir, "pkgconfig") cmd =3D ['pkg-config', '--libs', '--cflags', self.libname] env =3D {'PKG_CONFIG_PATH':path} pkgconf =3D sp.Popen(cmd, stdout=3Dsp.PIPE, env=3Denv).communica= te()[0] @@ -69,41 +52,60 @@ class Module: pkgconf =3D pkgconf.replace('-I/', '-I'+root+'/') return shlex.split(pkgconf) =20 + # Alternatives-2 version def get_impls(self, root): output =3D sp.Popen( - ['eselect', '--no-color', '--brief', 'blas', 'list'], - env=3D{'ROOT' : root}, stdout=3Dsp.PIPE - ).communicate()[0] + ['eselect', '--no-color', '--brief', self.libname, 'list'], + env=3D{'ROOT' : root}, stdout=3Dsp.PIPE).communicate()[0] return output.strip().split('\n') + =20 + # Base version + def _generateResults(self, files): + return dict(zip(self.tests, files)) =20 def run_test(self, root, impl, testdir, env, logdir): + # Convenient renames and definition of report files Print =3D self.Print - libdir =3D self.libdir name =3D self.libname - files =3D [pjoin(testdir, 'accuracy_%s_%s.dat' % (op, name)) \ - for op in self.tests] + files =3D [pjoin(testdir,f) for f in self.files] + if self.libdir[0] =3D=3D '/': + libdir =3D root+self.libdir + else: + libdir =3D pjoin(root, self.libdir) + =20 + # 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]) + else: + os.makedirs(testdir) + runtests =3D True + =20 + if not runtests: + Print("Not testing: results exist") + return self._generateResults(files) =20 - results =3D {} - for op in self.tests: - results[op] =3D pjoin(testdir, 'accuracy_%s_%s.dat' % (op, n= ame)) + 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 pjoin(root,libdir) + ":" + env['LIBR= ARY_PATH'] + env['LIBRARY_PATH'] =3D libdir + ":" + env['LIBRARY_PATH'] else: - env['LIBRARY_PATH'] =3D pjoin(root, libdir) + env['LIBRARY_PATH'] =3D libdir =20 if env.has_key('INCLUDE_PATH'): env['INCLUDE_PATH'] =3D \ - pjoin(root, "/usr/include") + ":" + env['INCLUDE_PATH'] + pjoin(root, "usr/include") + ":" + env['INCLUDE_PATH'] else: - env['INCLUDE_PATH'] =3D pjoin(root, "/usr/include") + env['INCLUDE_PATH'] =3D pjoin(root, "usr/include") =20 if env.has_key('LD_LIBRARY_PATH'): env['LD_LIBRARY_PATH'] =3D \ - pjoin(root, libdir) + ":" + env['LD_LIBRARY_PATH'] + libdir + ":" + env['LD_LIBRARY_PATH'] else: - env['LD_LIBRARY_PATH'] =3D pjoin(root, libdir) + env['LD_LIBRARY_PATH'] =3D libdir =20 # Backup the environment oldenv =3D {} @@ -111,60 +113,51 @@ class Module: oldenv[k] =3D \ (os.environ.has_key(k) and (os.environ[k],) or (None,))[0] =20 - # Set the environment + # Set the new environment for k,v in env.items(): os.environ[k] =3D v =20 # Compile test suite - exe =3D pjoin(testdir, 'test') - source =3D "accuracy/main_blas.cpp" - flags =3D self._get_flags(root, impl, libdir) - cxxflags =3D run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip() - cxx =3D 'g++' - cmd =3D [cxx, '-o', exe, source] + flags + shlex.split(cxxflags) - logfile =3D pjoin(logdir, 'compile.log') - p =3D sp.Popen(cmd, stdout=3Dfile(logfile, 'w'), stderr=3Dsp.STD= OUT) - p.wait() - if p.returncode !=3D 0: + logfile =3D os.path.join(logdir, name+"_comp.log") + returncode, exe =3D self._compileTest(logfile=3Dlogfile, testdir= =3Dtestdir, \ + root=3Droot, impl=3Dimpl, libdir=3Dlibdir) + if returncode !=3D 0: Print("Compilation failed") Print("See log: " + logfile) return Print("Compilation successful") =20 # Run test - logfile =3D file(pjoin(logdir, name+"_run.log"), 'w') - cmd =3D [pjoin(testdir,"test")] + self.tests - proc =3D sp.Popen(cmd, bufsize=3D1, stdout=3Dsp.PIPE, stderr=3Ds= p.PIPE, - cwd=3Dtestdir) - Print.down() - while True: - line =3D proc.stdout.readline() - if not line: - break - logfile.write(line) - if len(line.strip()) =3D=3D 0: - continue - if line[0] !=3D ' ': - Print.up() - Print(line.strip().split()[-1]) - Print.down() - else: - Print(line.strip()) - Print.up() =20 - logfile.close() =20 - proc.wait() - if proc.returncode !=3D 0: - Print('Test failed') - else: - Print('Test successful') - =20 - return results + logfile =3D pjoin(logdir, name+"_run.log") + retcode =3D self._executeTest(logfile=3Dlogfile, exe=3Dexe, test= dir=3Dtestdir) + if returncode !=3D 0: + Print("Test failed") + Print("See log: " + logfile) + return + Print("Test successful") =20 + # 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] + =20 + # Return + return self._generateResults(files) + =20 =20 - def save_results(self, results, figdir): + def save_results(self, results, figdir, plottype=3D'plot'): if not with_images: self.Print("Report generation skipped - missing libraries") return + =20 + if plottype =3D=3D 'plot': plotf =3D plt.plot + elif plottype =3D=3D 'semilogx': plotf =3D plt.semilogx + elif plottype =3D=3D 'semilogy': plotf =3D plt.semilogy + elif plottype =3D=3D 'loglog': plotf =3D plt.loglog + else: + raise Exception('Unrecognized plot type: "' + plottype + '"'= ) =20 # Re-order the result dictionary newresults =3D {} @@ -189,7 +182,7 @@ class Module: plt.title(test) for impl in newresults[test]: x,y =3D np.loadtxt(newresults[test][impl], unpack=3D= True) - plt.loglog(x,y, label=3Dimpl, hold=3DTrue) + plotf(x,y, label=3Dimpl, hold=3DTrue) plt.legend(loc=3D'best') plt.grid(True) fname =3D pjoin(figdir, 'summary.png') @@ -203,7 +196,7 @@ class Module: plt.figure(figsize=3D(12,9), dpi=3D300) for impl in newresults[test]: x,y =3D np.loadtxt(newresults[test][impl], unpack=3D= True) - plt.loglog(x,y, label=3Dimpl, hold=3DTrue) + plotf(x,y, label=3Dimpl, hold=3DTrue) plt.legend(loc=3D'best') plt.grid(True) fname =3D pjoin(figdir, test+".png") @@ -212,5 +205,3 @@ class Module: self.Print('Figure ' + fname + ' saved') =20 html.close() - =20 - =20 diff --git a/app-benchmarks/autobench/files/python/blas_accuracy.py b/app= -benchmarks/autobench/files/python/blas_accuracy.py index 9e13ed2..edbf343 100644 --- a/app-benchmarks/autobench/files/python/blas_accuracy.py +++ b/app-benchmarks/autobench/files/python/blas_accuracy.py @@ -1,8 +1,8 @@ -from pprint import pprint from os.path import join as pjoin import subprocess as sp import shlex, os from htmlreport import HTMLreport +import basemodule =20 try: import matplotlib.pyplot as plt @@ -16,27 +16,7 @@ except ImportError: =20 run_cmd =3D lambda c : sp.Popen(c, stdout=3Dsp.PIPE).communicate()[0] =20 -class Module: - def __init__(self, Print, libdir, args): - self.Print =3D Print - self.libdir =3D libdir - self.summary =3D False - self.summary_only =3D False - =20 - self._initialize() - =20 - passargs =3D [] - for i in args: - if i =3D=3D '-S': - self.summary_only =3D True - continue - elif i =3D=3D '-s': - self.summary =3D True - continue - else: - passargs +=3D [i] - =20 - self._parse_args(passargs) +class Module(basemodule.BaseModule): =20 def _initialize(self): self.libname =3D 'blas' @@ -57,86 +37,29 @@ class Module: # If no test is specified, then do everything if len(self.tests) =3D=3D 0: self.tests =3D self.avail - =20 - def _get_flags(self, root, impl, libdir): - # Retrieve pkgconfig settings and map the directories to the new= root - path =3D pjoin(root, "etc/env.d/alternatives", \ - self.libname, impl, libdir, "pkgconfig") - cmd =3D ['pkg-config', '--libs', '--cflags', self.libname] - env =3D {'PKG_CONFIG_PATH':path} - pkgconf =3D sp.Popen(cmd, stdout=3Dsp.PIPE, env=3Denv).communica= te()[0] - pkgconf =3D pkgconf.replace('-L/', '-L'+root+'/') - pkgconf =3D pkgconf.replace('-I/', '-I'+root+'/') - return shlex.split(pkgconf) - =20 - def get_impls(self, 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') - =20 - def run_test(self, root, impl, testdir, env, logdir): - Print =3D self.Print - libdir =3D self.libdir - name =3D self.libname - files =3D [pjoin(testdir, 'accuracy_%s_%s.dat' % (op, name)) \ + =20 + # Generate list of dat (result) files, relative to the testdir + self.files =3D [pjoin('accuracy_%s_%s.dat' % (op, name)) \ for op in self.tests] =20 - results =3D {} - for op in self.tests: - results[op] =3D pjoin(testdir, 'accuracy_%s_%s.dat' % (op, n= ame)) - =20 - # Prepare the environment - if env.has_key('LIBRARY_PATH'): - env['LIBRARY_PATH'] =3D pjoin(root,libdir) + ":" + env['LIBR= ARY_PATH'] - else: - env['LIBRARY_PATH'] =3D pjoin(root, libdir) - =20 - if env.has_key('INCLUDE_PATH'): - env['INCLUDE_PATH'] =3D \ - pjoin(root, "/usr/include") + ":" + env['INCLUDE_PATH'] - else: - env['INCLUDE_PATH'] =3D pjoin(root, "/usr/include") - =20 - if env.has_key('LD_LIBRARY_PATH'): - env['LD_LIBRARY_PATH'] =3D \ - pjoin(root, libdir) + ":" + env['LD_LIBRARY_PATH'] - else: - env['LD_LIBRARY_PATH'] =3D pjoin(root, libdir) - =20 - # Backup the environment - oldenv =3D {} - 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 test suite + def _compileTest(self, logfile, testdir, root, impl, *args, **kwargs= ): exe =3D pjoin(testdir, 'test') source =3D "accuracy/main_blas.cpp" - flags =3D self._get_flags(root, impl, libdir) + flags =3D self._get_flags(root, impl, self.libdir) cxxflags =3D run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip() cxx =3D 'g++' cmd =3D [cxx, '-o', exe, source] + flags + shlex.split(cxxflags) - logfile =3D pjoin(logdir, 'compile.log') - p =3D sp.Popen(cmd, stdout=3Dfile(logfile, 'w'), stderr=3Dsp.STD= OUT) - p.wait() - if p.returncode !=3D 0: - Print("Compilation failed") - Print("See log: " + logfile) - return - Print("Compilation successful") - =20 - # Run test - logfile =3D file(pjoin(logdir, name+"_run.log"), 'w') - cmd =3D [pjoin(testdir,"test")] + self.tests + proc =3D sp.Popen(cmd, stdout=3Dfile(logfile, 'w'), stderr=3Dsp.= STDOUT) + proc.wait() + return proc.returncode, exe + =20 + def _executeTest(self, logfile, exe, testdir): + # TODO: control objdump and nm + logfile =3D file(logfile, 'w') + cmd =3D [exe] + self.tests proc =3D sp.Popen(cmd, bufsize=3D1, stdout=3Dsp.PIPE, stderr=3Ds= p.PIPE, cwd=3Dtestdir) - Print.down() + self.Print.down() while True: line =3D proc.stdout.readline() if not line: @@ -145,72 +68,18 @@ class Module: if len(line.strip()) =3D=3D 0: continue if line[0] !=3D ' ': - Print.up() - Print(line.strip().split()[-1]) - Print.down() + self.Print.up() + self.Print(line.strip().split()[-1]) + self.Print.down() else: - Print(line.strip()) - Print.up() =20 + self.Print(line.strip()) + self.Print.up() =20 logfile.close() =20 proc.wait() - if proc.returncode !=3D 0: - Print('Test failed') - else: - Print('Test successful') - =20 - return results - =20 + return proc.returncode + =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 {} - for nameimpl in results: - nameimplstr =3D pjoin(*nameimpl) - resdat =3D results[nameimpl][test] - newresults[test][nameimplstr] =3D resdat - =20 - # Begin the HTML report - htmlfname =3D pjoin(figdir, 'index.html') - html =3D HTMLreport(htmlfname) - =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 - plt.figure(figsize=3D(16,6*sprows), dpi=3D300) - for i, test in enumerate(self.tests, 1): - plt.subplot(sprows, 2, i) - plt.title(test) - for impl in newresults[test]: - x,y =3D np.loadtxt(newresults[test][impl], unpack=3D= True) - plt.loglog(x,y, label=3Dimpl, hold=3DTrue) - plt.legend(loc=3D'best') - plt.grid(True) - fname =3D pjoin(figdir, 'summary.png') - plt.savefig(fname, format=3D'png') - html.addFig("Summary", image=3Dos.path.basename(fname), widt= h=3D'95%') - 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) - for impl in newresults[test]: - x,y =3D np.loadtxt(newresults[test][impl], unpack=3D= True) - plt.loglog(x,y, label=3Dimpl, hold=3DTrue) - plt.legend(loc=3D'best') - plt.grid(True) - fname =3D pjoin(figdir, test+".png") - plt.savefig(fname, format=3D'png') - html.addFig(test, image=3Dos.path.basename(fname)) - self.Print('Figure ' + fname + ' saved') - =20 - html.close() + basemodule.BaseModule.save_results(self, results,figdir, 'loglog= ') =20 =20 diff --git a/app-benchmarks/autobench/files/python/blasbase.py b/app-benc= hmarks/autobench/files/python/blasbase.py index 2ca9070..d2e4edd 100644 --- a/app-benchmarks/autobench/files/python/blasbase.py +++ b/app-benchmarks/autobench/files/python/blasbase.py @@ -36,6 +36,8 @@ class BLASBase(btlbase.BTLBase): if len(self.tests) =3D=3D 0: self.tests =3D ['axpy', 'matrix_vector', \ 'trisolve_vector', 'matrix_matrix'] + =20 + btlbase.BTLBase._parse_args(self, args) =20 @staticmethod def _btl_source(): @@ -47,24 +49,3 @@ class BLASBase(btlbase.BTLBase): =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 pjoin(root, "etc/env.d/alternatives", \ - self.libname,impl,libdir, "pkgconfig") - cmd =3D ['pkg-config', '--libs', '--cflags', self.libname] - env =3D {'PKG_CONFIG_PATH':path} - pkgconf =3D sp.Popen(cmd, stdout=3Dsp.PIPE, env=3Denv).communica= te()[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 btlbase diff --git a/app-benchmarks/autobench/files/python/btlbase.py b/app-bench= marks/autobench/files/python/btlbase.py index 1c6f8aa..5e07178 100644 --- a/app-benchmarks/autobench/files/python/btlbase.py +++ b/app-benchmarks/autobench/files/python/btlbase.py @@ -3,6 +3,7 @@ import commands as cmd import subprocess as sp from os.path import join as pjoin from htmlreport import HTMLreport +import basemodule =20 try: import matplotlib.pyplot as plt @@ -95,110 +96,36 @@ def btlcompile(exe, source, btldir, includes, define= s, libs, libdirs, other, \ return cp.returncode =20 =20 -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 - self._initialize() - =20 - passargs =3D [] - for i in args: - if i =3D=3D '-S': - self.summary_only =3D True - continue - elif i =3D=3D '-s': - self.summary =3D True - continue - else: - passargs +=3D [i] - =20 - self._parse_args(passargs) - =20 - =20 - def run_test(self, root, impl, testdir, env, logdir): - # Convenient renames and definition of report files=20 - Print =3D self.Print - libdir =3D self.libdir - name =3D self.libname - files =3D [pjoin(testdir, 'bench_%s_%s.dat' % (op, name)) \ +class BTLBase(basemodule.BaseModule): + =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)) \ for op in self.tests] - =20 - # 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]) - else: - os.makedirs(testdir) - runtests =3D True - =20 - if not runtests: - Print("Not testing: results exist") - results =3D {} - for op in self.tests: - results[op] =3D pjoin(testdir, 'bench_%s_%s.dat'%(op,nam= e)) - return results - =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 pjoin(root,libdir) + ":" + env['LIBR= ARY_PATH'] - else: - env['LIBRARY_PATH'] =3D pjoin(root, libdir) - =20 - if env.has_key('INCLUDE_PATH'): - env['INCLUDE_PATH'] =3D \ - pjoin(root, "/usr/include") + ":" + env['INCLUDE_PATH'] - else: - env['INCLUDE_PATH'] =3D pjoin(root, "/usr/include") - =20 - if env.has_key('LD_LIBRARY_PATH'): - env['LD_LIBRARY_PATH'] =3D \ - pjoin(root, libdir) + ":" + env['LD_LIBRARY_PATH'] - else: - env['LD_LIBRARY_PATH'] =3D pjoin(root, libdir) - =20 - # Backup the environment - oldenv =3D {} - 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 test suite + =20 + def _compileTest(self, logfile, testdir, root, impl, libdir, \ + *args, **kwargs): btldir =3D 'btl/' - logfile =3D os.path.join(logdir, name+"_comp.log") + exe =3D pjoin(testdir, "test") returncode =3D btlcompile( - exe =3D pjoin(testdir, "test"), + exe =3D exe, source =3D pjoin(btldir, self._btl_source()), btldir =3D btldir, includes =3D [pjoin(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), + libdirs =3D [libdir], + other =3D self._get_flags(root, impl, self.libdir), logfile =3D logfile ) - if returncode !=3D 0: - Print("Compilation failed") - Print("See log: " + logfile) - return - Print("Compilation successful") - =20 - # Run test - logfile =3D file(pjoin(logdir, name+"_run.log"), 'w') - args =3D [pjoin(testdir,"test")] + self.tests + return returncode, exe + =20 + def _executeTest(self, logfile, exe, testdir): + # TODO: control objdump and nm + logfile =3D file(logfile, 'w') + args =3D [exe] + self.tests proc =3D sp.Popen(args, bufsize=3D1, stdout=3Dsp.PIPE, stderr=3D= sp.PIPE,=20 cwd =3D testdir) - results =3D {} while True: # Each operation test begins with a line on stderr errline =3D proc.stderr.readline() @@ -206,82 +133,19 @@ class BTLBase: break logfile.write(errline) resfile =3D errline.split()[-1] - testname =3D resfile[6:-5-len(name)] - results[testname] =3D pjoin(testdir, resfile) - Print(resfile) + testname =3D resfile[6:-5-len(self.libname)] + self.Print(resfile) =20 # 100 different sizes for each operation test - Print.down() + self.Print.down() for i in xrange(100): outline =3D proc.stdout.readline() logfile.write(outline) - Print(outline.rstrip()) - Print.up() + self.Print(outline.strip()) + self.Print.up() logfile.close() proc.wait() - if proc.returncode !=3D 0: - Print('Test failed') - else: - Print('Test successful') - =20 - # 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 + return proc.returncode =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 {} - for nameimpl in results: - nameimplstr =3D pjoin(*nameimpl) - resdat =3D results[nameimpl][test] - newresults[test][nameimplstr] =3D resdat - =20 - # Begin the HTML report - htmlfname =3D pjoin(figdir, 'index.html') - html =3D HTMLreport(htmlfname) - =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 - plt.figure(figsize=3D(16,6*sprows), dpi=3D300) - for i, test in enumerate(self.tests, 1): - plt.subplot(sprows, 2, i) - plt.title(test) - for impl in newresults[test]: - x,y =3D np.loadtxt(newresults[test][impl], unpack=3D= True) - plt.semilogx(x,y, label=3Dimpl, hold=3DTrue) - plt.legend(loc=3D'best') - plt.grid(True) - fname =3D pjoin(figdir, 'summary.png') - plt.savefig(fname, format=3D'png') - html.addFig("Summary", image=3Dos.path.basename(fname), widt= h=3D'95%') - 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) - for impl in newresults[test]: - x,y =3D np.loadtxt(newresults[test][impl], unpack=3D= True) - plt.semilogx(x,y, label=3Dimpl, hold=3DTrue) - plt.legend(loc=3D'best') - plt.grid(True) - fname =3D pjoin(figdir, test+".png") - plt.savefig(fname, format=3D'png') - html.addFig(test, image=3Dos.path.basename(fname)) - self.Print('Figure ' + fname + ' saved') - =20 - html.close() - =20 - =20 + basemodule.BaseModule.save_results(self, results,figdir, 'semilo= gx') diff --git a/app-benchmarks/autobench/files/python/lapack.py b/app-benchm= arks/autobench/files/python/lapack.py index ec98cd5..136d837 100644 --- a/app-benchmarks/autobench/files/python/lapack.py +++ b/app-benchmarks/autobench/files/python/lapack.py @@ -23,34 +23,16 @@ class Module(btlbase.BTLBase): # If no test is specified, run everything if len(self.tests) =3D=3D 0: self.tests =3D self.avail + =20 + btlbase.BTLBase._parse_args(self, args) =20 @staticmethod def _btl_source(): - return "/libs/LAPACK/main.cpp" + return "libs/LAPACK/main.cpp" =20 @staticmethod def _btl_includes(): - return ["/libs/BLAS", "libs/LAPACK"] + 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 btlbase