* [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/
@ 2011-07-01 12:28 Andrea Arteaga
0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arteaga @ 2011-07-01 12:28 UTC (permalink / raw
To: gentoo-commits
commit: 1599222a06e321570be756d36e03132bd8359d3b
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Fri Jul 1 12:27:51 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Fri Jul 1 12:27:51 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=1599222a
Emerge, compilation and run are logged. More readable output.
---
.../autobench/files/python/PortageUtils.py | 23 +++++++++++++++---
app-benchmarks/autobench/files/python/btlbase.py | 22 ++++++++++++-----
app-benchmarks/autobench/files/python/btlutils.py | 14 +++++++++-
app-benchmarks/autobench/files/python/main.py | 25 ++++++++++++++++---
4 files changed, 67 insertions(+), 17 deletions(-)
diff --git a/app-benchmarks/autobench/files/python/PortageUtils.py b/app-benchmarks/autobench/files/python/PortageUtils.py
index 4877cbd..c162e1d 100644
--- a/app-benchmarks/autobench/files/python/PortageUtils.py
+++ b/app-benchmarks/autobench/files/python/PortageUtils.py
@@ -1,4 +1,5 @@
import commands as cmd
+import subprocess as sp
import portage
import os
@@ -17,7 +18,8 @@ def available_packages(pattern):
for l in cmd.getoutput('equery -q list -po ' + pattern).split()]
-def install_package(package, env={}, root='/', pkgdir='usr/portage/packages'):
+def install_package(package, env={}, root='/', pkgdir='usr/portage/packages',
+ logfile=None):
"""Emerge a package in the given root.
package is the package to be emerged. It has to be a tuple
@@ -50,9 +52,22 @@ def install_package(package, env={}, root='/', pkgdir='usr/portage/packages'):
envl += i + '="' + env[i] + '" '
cl = envl + 'emerge --ignore-default-opts -OB "=' + pkg + '"'
- # Execute emerge command
- so = cmd.getstatusoutput(cl)
- if so[0] != 0:
+ # Execute emerge command and log the results
+ if logfile is not None:
+ fout = file(logfile, 'w')
+ fout.write(cl+'\n'+80*'-'+'\n')
+ fout.flush()
+ else:
+ fout = sp.PIPE
+ p = sp.Popen( \
+ ['emerge', '--ignore-default-opts', '-OB', '=' + pkg], \
+ env = env, \
+ stdout = fout, stderr = fout \
+ )
+ p.wait()
+ if logfile is not None:
+ fout.close()
+ if p.returncode != 0:
# In case of error, print the whole emerge command
raise InstallException(cl)
diff --git a/app-benchmarks/autobench/files/python/btlbase.py b/app-benchmarks/autobench/files/python/btlbase.py
index a8d8c1e..a8dc3f4 100644
--- a/app-benchmarks/autobench/files/python/btlbase.py
+++ b/app-benchmarks/autobench/files/python/btlbase.py
@@ -39,7 +39,7 @@ class BTLBase:
self._parse_args(passargs)
- def run_test(self, root, impl, testdir, env):
+ def run_test(self, root, impl, testdir, env, logdir):
# Convenient renames and definition of report files
Print = self.Print
libdir = self.libdir
@@ -94,6 +94,7 @@ class BTLBase:
# Compile
# TODO: use CXX instead of g++
btldir = 'btl/'
+ logfile = os.path.join(logdir, name+"_comp.log")
returncode, compilecl = btl.btlcompile(
exe = testdir + "/test",
source = btldir + self._btl_source(),
@@ -102,19 +103,24 @@ class BTLBase:
defines = self._btl_defines(),
libs = [],
libdirs = [root+libdir],
- other = self._get_flags(root, impl, libdir)
+ other = self._get_flags(root, impl, libdir),
+ logfile = logfile
)
if returncode != 0:
- raise Exception("Compilation failed: " + compilecl)
- Print("Compilation successful: " + compilecl)
+ Print("Compilation failed")
+ Print("See log: " + logfile)
+ return
+ Print("Compilation successful")
# Run test
- args = [testdir + "/test"] + self.tests
+ logfile = file(os.path.join(logdir, name+"_run.log"), 'w')
+ args = [os.path.join(testdir,"test")] + self.tests
proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE,
cwd = testdir)
results = {}
while True:
errline = proc.stderr.readline()
+ logfile.write(errline)
if not errline:
break
resfile = errline.split()[-1]
@@ -123,11 +129,13 @@ class BTLBase:
Print(resfile)
Print.down()
for i in xrange(100):
- outline = proc.stdout.readline().rstrip()
- Print(outline)
+ outline = proc.stdout.readline()
+ logfile.write(outline)
+ Print(outline.rstrip())
Print.up()
Print.up()
proc.wait()
+ logfile.close()
if proc.returncode != 0:
Print('Test failed')
else:
diff --git a/app-benchmarks/autobench/files/python/btlutils.py b/app-benchmarks/autobench/files/python/btlutils.py
index 752096e..d2207cd 100644
--- a/app-benchmarks/autobench/files/python/btlutils.py
+++ b/app-benchmarks/autobench/files/python/btlutils.py
@@ -3,7 +3,8 @@ import shlex
run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
-def btlcompile(exe, source, btldir, includes, defines, libs, libdirs, other):
+def btlcompile(exe, source, btldir, includes, defines, libs, libdirs, other, \
+ logfile=None):
incs = (
"%s/actions" % btldir,
"%s/generic_bench" % btldir,
@@ -25,7 +26,16 @@ def btlcompile(exe, source, btldir, includes, defines, libs, libdirs, other):
# TODO: use CXX instead of g++
cl = "g++ -o %s %s %s %s %s %s %s %s" \
% (exe, source, incs, defs, libs, libdirs, cxxflags, otherflags)
+
+ if logfile is None:
+ fout = sp.PIPE
+ else:
+ fout = file(logfile, 'w')
+ fout.write(cl + "\n" + 80*'-' + "\n")
+ fout.flush()
cl = shlex.split(cl)
- cp = sp.Popen(cl, stdout=sp.PIPE, stderr=sp.PIPE)
+ cp = sp.Popen(cl, stdout=fout, stderr=sp.STDOUT)
cp.communicate()
+ if logfile is not None:
+ fout.close()
return (cp.returncode, ' '.join(cl))
diff --git a/app-benchmarks/autobench/files/python/main.py b/app-benchmarks/autobench/files/python/main.py
index 474f9bd..21e3c34 100644
--- a/app-benchmarks/autobench/files/python/main.py
+++ b/app-benchmarks/autobench/files/python/main.py
@@ -20,6 +20,17 @@ testsdir = "/var/tmp/benchmarks/tests/"
libdir = sp.Popen \
('ABI=$(portageq envvar ABI); echo /usr/`portageq envvar LIBDIR_$ABI`/', \
stdout=sp.PIPE, shell=True).communicate()[0].strip()
+logdir = "/var/log/benchmarks/" + time.strftime('%Y-%m-%d')
+if os.path.exists(logdir):
+ n = 1
+ while True:
+ logdir = "/var/log/benchmarks/" + time.strftime('%Y-%m-%d') + "_%i"%n
+ if not os.path.exists(logdir):
+ os.makedirs(logdir)
+ break
+ n += 1
+else:
+ os.makedirs(logdir)
def print_usage():
print "Usage: benchmarks [blas|cblas|lapack] file args"
@@ -150,6 +161,8 @@ for tn,(name,test) in enumerate(tests.items(),1):
pkgdir = "%s/%s/" % (pkgsdir, name)
root = "%s/%s/" % (rootsdir, name)
+ tlogdir = os.path.join(logdir, name)
+ os.path.exists(tlogdir) or os.makedirs(tlogdir)
# Emerge package
Print.down()
@@ -160,8 +173,11 @@ for tn,(name,test) in enumerate(tests.items(),1):
Print("Package already emerged - skipping")
else:
try:
+ logfile = os.path.join(tlogdir, 'emerge.log')
install_package( \
- test['package'], env=test['env'], root=root, pkgdir=pkgdir)
+ test['package'], env=test['env'], root=root, pkgdir=pkgdir, \
+ logfile=logfile
+ )
# Unpack the archive onto the given root directory
archive = pkgdir + package + '.tbz2'
os.path.exists(root) or os.makedirs(root)
@@ -172,7 +188,8 @@ for tn,(name,test) in enumerate(tests.items(),1):
raise InstallException(tarcmd)
except InstallException as e:
- Print("Package %s failed to emerge: %s" % (package, e.command))
+ Print("Package %s failed to emerge" % package)
+ Print("See emerge log: " + logfile)
Print.up()
print
continue
@@ -181,7 +198,7 @@ for tn,(name,test) in enumerate(tests.items(),1):
# Find implementations
impls = mod.get_impls(root)
test['implementations'] = impls
-
+
# Test every implementation
test['results'] = {}
for impl in impls:
@@ -191,7 +208,7 @@ for tn,(name,test) in enumerate(tests.items(),1):
# Run the test suite
testdir = "%s/%s/%s" % (testsdir, name, impl)
test['results'][impl] = \
- mod.run_test(root=root, impl=impl, testdir=testdir, env=test['env'])
+ mod.run_test(root, impl, testdir, env=test['env'], logdir=tlogdir)
Print.up()
Print.up()
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/
@ 2011-07-01 16:06 Andrea Arteaga
0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arteaga @ 2011-07-01 16:06 UTC (permalink / raw
To: gentoo-commits
commit: ec1374ad483c4d7a71df5fdc4e2a983c7471bb0b
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Fri Jul 1 16:05:49 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Fri Jul 1 16:05:49 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=ec1374ad
More logging (almost everything), bugs solved (multiple execution for
figures, wrong packages with no revision).
---
.../autobench/files/python/PortageUtils.py | 16 +++--
app-benchmarks/autobench/files/python/btlbase.py | 12 ++--
app-benchmarks/autobench/files/python/main.py | 66 ++++++++++++-------
3 files changed, 59 insertions(+), 35 deletions(-)
diff --git a/app-benchmarks/autobench/files/python/PortageUtils.py b/app-benchmarks/autobench/files/python/PortageUtils.py
index c162e1d..66d0b80 100644
--- a/app-benchmarks/autobench/files/python/PortageUtils.py
+++ b/app-benchmarks/autobench/files/python/PortageUtils.py
@@ -4,8 +4,9 @@ import portage
import os
class InstallException(Exception):
- def __init__(self, command):
+ def __init__(self, command, logfile):
self.command = command
+ self.logfile = logfile
def available_packages(pattern):
"""Returns a list of packages matching the given pattern.
@@ -16,6 +17,12 @@ def available_packages(pattern):
"""
return [portage.catpkgsplit(l) \
for l in cmd.getoutput('equery -q list -po ' + pattern).split()]
+
+def normalize_cpv(cpv):
+ if cpv[-1] != 'r0':
+ return '%s/%s-%s-%s' % cpv
+ else:
+ return '%s/%s-%s' % cpv[:-1]
def install_package(package, env={}, root='/', pkgdir='usr/portage/packages',
@@ -40,10 +47,7 @@ def install_package(package, env={}, root='/', pkgdir='usr/portage/packages',
"""
# Retrieve package string
- if package[-1] != 'r0':
- pkg = '%s/%s-%s-%s' % package
- else:
- pkg = '%s/%s-%s' % package[:-1]
+ pkg = normalize_cpv(package)
# Setup command line
env['PKGDIR'] = pkgdir
@@ -69,7 +73,7 @@ def install_package(package, env={}, root='/', pkgdir='usr/portage/packages',
fout.close()
if p.returncode != 0:
# In case of error, print the whole emerge command
- raise InstallException(cl)
+ raise InstallException(cl, logfile)
if __name__ == '__main__':
# Just a test
diff --git a/app-benchmarks/autobench/files/python/btlbase.py b/app-benchmarks/autobench/files/python/btlbase.py
index a8dc3f4..d9a911a 100644
--- a/app-benchmarks/autobench/files/python/btlbase.py
+++ b/app-benchmarks/autobench/files/python/btlbase.py
@@ -1,6 +1,7 @@
import sys, os, shlex
import commands as cmd
import subprocess as sp
+from os.path import join as pjoin
try:
import matplotlib.pyplot as plt
@@ -44,7 +45,8 @@ class BTLBase:
Print = self.Print
libdir = self.libdir
name = self.libname
- files = ['%s/bench_%s_%s.dat' %(testdir, op, name) for op in self.tests]
+ files = [pjoin(testdir, 'bench_%s_%s.dat' % (op, name)) \
+ for op in self.tests]
# Create dir. If all results already exist use them and do not perform
# the tests, otherwise remove every old results.
@@ -58,8 +60,8 @@ class BTLBase:
if not runtests:
Print("Not testing: results exist")
results = {}
- for i in self.tests:
- results[i] = '%s/bench_%s_%s.dat' %(testdir, i, name)
+ for op in self.tests:
+ results[op] = pjoin(testdir, 'bench_%s_%s.dat'%(op,name))
return results
for i in files:
@@ -125,7 +127,7 @@ class BTLBase:
break
resfile = errline.split()[-1]
testname = resfile[6:-5-len(name)]
- results[testname] = resfile
+ results[testname] = pjoin(testdir, resfile)
Print(resfile)
Print.down()
for i in xrange(100):
@@ -190,7 +192,7 @@ class BTLBase:
plt.semilogx(x,y, label=impl, hold=True)
plt.legend(loc='best')
plt.grid(True)
- fname = figdir + '/' + test + '.png'
+ fname = os.path.join(figdir, test+".png")
plt.savefig(fname, format='png')
self.Print('Figure ' + fname + ' saved')
diff --git a/app-benchmarks/autobench/files/python/main.py b/app-benchmarks/autobench/files/python/main.py
index 21e3c34..991d735 100644
--- a/app-benchmarks/autobench/files/python/main.py
+++ b/app-benchmarks/autobench/files/python/main.py
@@ -1,6 +1,7 @@
#! /usr/bin/env python2
import os, sys, shlex
+from os.path import join as pjoin
from PortageUtils import *
import subprocess as sp
import time
@@ -8,18 +9,34 @@ import time
# Retrieve relevant files/directories
curdir = os.path.abspath('.')
scriptdir = os.path.dirname(os.path.realpath(__file__))
+rootsdir = "/var/tmp/benchmarks/roots/"
+testsdir = "/var/tmp/benchmarks/tests/"
if os.getuid() == 0:
pkgsdir = "/var/cache/benchmarks/packages/"
- figdir = "/var/cache/benchmarks/results/"
+ figdirb = "/var/cache/benchmarks/results/"
else:
pkgsdir = os.environ['HOME'] + "/.benchmarks/packages/"
- figdir = os.environ['HOME'] + "/.benchmarks/results/"
-figdir += time.strftime('%Y%m%d-%H%M') + '/'
-rootsdir = "/var/tmp/benchmarks/roots/"
-testsdir = "/var/tmp/benchmarks/tests/"
+ figdirb = os.environ['HOME'] + "/.benchmarks/results/"
+
+# Library directory (lib32 vs. lib64)
libdir = sp.Popen \
('ABI=$(portageq envvar ABI); echo /usr/`portageq envvar LIBDIR_$ABI`/', \
stdout=sp.PIPE, shell=True).communicate()[0].strip()
+
+# Figures directory
+figdir = figdirb + time.strftime('%Y-%m-%d')
+if os.path.exists(figdir):
+ n = 1
+ while True:
+ figdir = figdirb + time.strftime('%Y-%m-%d') + "_%i"%n
+ if not os.path.exists(figdir):
+ os.makedirs(figdir)
+ break
+ n += 1
+else:
+ os.makedirs(figdir)
+
+# Logs directory
logdir = "/var/log/benchmarks/" + time.strftime('%Y-%m-%d')
if os.path.exists(logdir):
n = 1
@@ -145,51 +162,54 @@ input = file(testsfname).read()
tests = tests_from_input(input)
# Write summary
-print 60*'='
+print 80*'='
print "The following tests will be run:"
for tname, ttest in tests.items():
print "Test: " + tname
- print " - Package: " + "%s/%s-%s-%s" % ttest['package']
+ print " - Package: " + normalize_cpv(ttest['package'])
print " - Environment: " + \
' '.join([n+'="'+v+'"' for n,v in ttest['env'].items()])
print
-print 60*'='
+print 80*'='
print
for tn,(name,test) in enumerate(tests.items(),1):
Print("BEGIN TEST %i - %s" % (tn, name))
- pkgdir = "%s/%s/" % (pkgsdir, name)
- root = "%s/%s/" % (rootsdir, name)
- tlogdir = os.path.join(logdir, name)
+ pkgdir = pjoin(pkgsdir, name)
+ root = pjoin(rootsdir, name)
+ tlogdir = pjoin(logdir, name)
os.path.exists(tlogdir) or os.makedirs(tlogdir)
# Emerge package
Print.down()
- package = "%s/%s-%s-%s" % test['package']
- archive = pkgdir+package+".tbz2"
+ package = normalize_cpv(test['package'])
+ archive = pjoin(pkgdir, package+".tbz2")
Print("Emerging package %s" % package)
if os.path.exists(archive):
Print("Package already emerged - skipping")
else:
try:
- logfile = os.path.join(tlogdir, 'emerge.log')
+ logfile = pjoin(tlogdir, 'emerge.log')
+ Print("(Run 'tail -f " + logfile + " | less' on another terminal" \
+ + " to see the progress)")
install_package( \
test['package'], env=test['env'], root=root, pkgdir=pkgdir, \
logfile=logfile
)
# Unpack the archive onto the given root directory
- archive = pkgdir + package + '.tbz2'
os.path.exists(root) or os.makedirs(root)
- tarcmd = "tar xjf " + archive + " -C " + root
- tarp = sp.Popen(tarcmd, stdout=sp.PIPE, stderr=sp.PIPE, shell=True)
- tarp.communicate()
+ tarcmd = ['tar', 'xjf', archive, '-C', root]
+ logfile = file(pjoin(tlogdir, 'tar.log'), 'w')
+ tarp = sp.Popen(tarcmd, stdout=logfile, stderr=sp.STDOUT)
+ tarp.wait()
+ logfile.close()
if tarp.returncode != 0:
- raise InstallException(tarcmd)
+ raise InstallException(tarcmd, logfile.name)
except InstallException as e:
Print("Package %s failed to emerge" % package)
- Print("See emerge log: " + logfile)
+ Print("Error log: " + e.logfile)
Print.up()
print
continue
@@ -206,7 +226,7 @@ for tn,(name,test) in enumerate(tests.items(),1):
Print.down()
# Run the test suite
- testdir = "%s/%s/%s" % (testsdir, name, impl)
+ testdir = os.path.join(testsdir, name, impl)
test['results'][impl] = \
mod.run_test(root, impl, testdir, env=test['env'], logdir=tlogdir)
Print.up()
@@ -216,9 +236,7 @@ for tn,(name,test) in enumerate(tests.items(),1):
# Reports will be saved in figdir
-if not os.path.exists(figdir):
- os.makedirs(figdir)
-
+os.path.exists(figdir) or os.makedirs(figdir)
results = {}
for (name,test) in tests.items():
if test.has_key('implementations'):
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/
@ 2011-07-04 21:38 Andrea Arteaga
0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arteaga @ 2011-07-04 21:38 UTC (permalink / raw
To: gentoo-commits
commit: 30b1b4ec2c495adaab4a7c33656ce994a661b4ea
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Mon Jul 4 21:38:32 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Mon Jul 4 21:38:32 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=30b1b4ec
Introduced benchconfig: configuration module; benchutils and
benchprint: common utilities. New classes *Test: facilities splitted
between Modules and Tests. Unified paths, logs, output.
---
.../autobench/files/python/basemodule.py | 250 +++++++++++---------
.../autobench/files/python/benchconfig.py | 75 ++++++
.../autobench/files/python/benchprint.py | 28 +++
.../autobench/files/python/benchutils.py | 8 +
.../autobench/files/python/blas_accuracy.py | 138 ++++++++---
app-benchmarks/autobench/files/python/blasbase.py | 10 +-
app-benchmarks/autobench/files/python/btlbase.py | 225 ++++++++----------
app-benchmarks/autobench/files/python/lapack.py | 13 +-
app-benchmarks/autobench/files/python/main.py | 103 ++-------
9 files changed, 494 insertions(+), 356 deletions(-)
diff --git a/app-benchmarks/autobench/files/python/basemodule.py b/app-benchmarks/autobench/files/python/basemodule.py
index 5a35cc7..d84d27b 100644
--- a/app-benchmarks/autobench/files/python/basemodule.py
+++ b/app-benchmarks/autobench/files/python/basemodule.py
@@ -1,8 +1,12 @@
from os.path import join as pjoin
import subprocess as sp
import shlex, os
+
+import benchconfig as cfg
from htmlreport import HTMLreport
import basemodule
+from benchutils import *
+from benchprint import Print
try:
import matplotlib.pyplot as plt
@@ -14,12 +18,9 @@ except ImportError:
sys.stderr.write('Continue anyway.\n\n')
with_images = False
-run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
class BaseModule:
- def __init__(self, Print, libdir, args):
- self.Print = Print
- self.libdir = libdir
+ def __init__(self, args):
self.summary = False
self.summary_only = False
@@ -37,119 +38,26 @@ class BaseModule:
passargs += [i]
self._parse_args(passargs)
-
- # Alternatives-2 version with pkg-config
- def _get_flags(self, root, impl, libdir):
- while libdir[0] == '/':
- libdir = libdir[1:]
- # Retrieve pkgconfig settings and map the directories to the new root
- path = pjoin(root, "etc/env.d/alternatives", \
- self.libname,impl,libdir, "pkgconfig")
- cmd = ['pkg-config', '--libs', '--cflags', self.libname]
- env = {'PKG_CONFIG_PATH':path}
- pkgconf = sp.Popen(cmd, stdout=sp.PIPE, env=env).communicate()[0]
- pkgconf = pkgconf.replace('-L/', '-L'+root+'/')
- pkgconf = pkgconf.replace('-I/', '-I'+root+'/')
- return shlex.split(pkgconf)
# Alternatives-2 version
+
def get_impls(self, root):
output = sp.Popen(
['eselect', '--no-color', '--brief', self.libname, 'list'],
env={'ROOT' : root}, stdout=sp.PIPE).communicate()[0]
return output.strip().split('\n')
-
- # Base version
- def _generateResults(self, files):
- return dict(zip(self.tests, files))
-
- def run_test(self, root, impl, testdir, env, logdir):
- # Convenient renames and definition of report files
- Print = self.Print
- name = self.libname
- files = [pjoin(testdir,f) for f in self.files]
- if self.libdir[0] == '/':
- libdir = root+self.libdir
- else:
- libdir = pjoin(root, self.libdir)
-
- # Create dir. If all results already exist use them and do not perform
- # the tests, otherwise remove every old results.
- runtests = False
- if os.path.exists(testdir):
- runtests = not all([os.path.exists(i) for i in files])
- else:
- os.makedirs(testdir)
- runtests = True
-
- if not runtests:
- Print("Not testing: results exist")
- return self._generateResults(files)
-
- for i in files:
- if os.path.exists(i): os.remove(i)
-
- # Prepare the environment
- if env.has_key('LIBRARY_PATH'):
- env['LIBRARY_PATH'] = libdir + ":" + env['LIBRARY_PATH']
- else:
- env['LIBRARY_PATH'] = libdir
-
- if env.has_key('INCLUDE_PATH'):
- env['INCLUDE_PATH'] = \
- pjoin(root, "usr/include") + ":" + env['INCLUDE_PATH']
- else:
- env['INCLUDE_PATH'] = pjoin(root, "usr/include")
-
- if env.has_key('LD_LIBRARY_PATH'):
- env['LD_LIBRARY_PATH'] = \
- libdir + ":" + env['LD_LIBRARY_PATH']
- else:
- env['LD_LIBRARY_PATH'] = libdir
-
- # Backup the environment
- oldenv = {}
- for k in env.keys():
- oldenv[k] = \
- (os.environ.has_key(k) and (os.environ[k],) or (None,))[0]
-
- # Set the new environment
- for k,v in env.items():
- os.environ[k] = v
-
- # Compile test suite
- logfile = os.path.join(logdir, name+"_comp.log")
- returncode, exe = self._compileTest(logfile=logfile, testdir=testdir, \
- root=root, impl=impl, libdir=libdir)
- if returncode != 0:
- Print("Compilation failed")
- Print("See log: " + logfile)
- return
- Print("Compilation successful")
-
- # Run test
- logfile = pjoin(logdir, name+"_run.log")
- retcode = self._executeTest(logfile=logfile, exe=exe, testdir=testdir)
- if returncode != 0:
- Print("Test failed")
- Print("See log: " + logfile)
- return
- Print("Test successful")
-
- # Restore the old environment
- for k in env.keys():
- if oldenv[k] != None:
- os.environ[k] = oldenv[k]
- elif os.environ.has_key(k):
- del os.environ[k]
-
- # Return
- return self._generateResults(files)
-
+
+ def getTest(self, root, impl, testdir, logdir):
+ TestClass = self._testClass()
+ t = TestClass(root, impl, testdir, logdir)
+ t.libname = self.libname
+ t.tests = self.tests
+ t.files = self.files
+ return t
- def save_results(self, results, figdir, plottype='plot'):
+ def save_results(self, results, plottype='plot'):
if not with_images:
- self.Print("Report generation skipped - missing libraries")
+ Print("Report generation skipped - missing libraries")
return
if plottype == 'plot': plotf = plt.plot
@@ -165,11 +73,13 @@ class BaseModule:
newresults[test] = {}
for nameimpl in results:
nameimplstr = pjoin(*nameimpl)
+ if results[nameimpl] == None:
+ continue
resdat = results[nameimpl][test]
newresults[test][nameimplstr] = resdat
# Begin the HTML report
- htmlfname = pjoin(figdir, 'index.html')
+ htmlfname = pjoin(cfg.reportdir, 'index.html')
html = HTMLreport(htmlfname)
# Generate summary - a single image with all plots
@@ -185,10 +95,10 @@ class BaseModule:
plotf(x,y, label=impl, hold=True)
plt.legend(loc='best')
plt.grid(True)
- fname = pjoin(figdir, 'summary.png')
+ fname = pjoin(cfg.reportdir, 'summary.png')
plt.savefig(fname, format='png')
html.addFig("Summary", image=os.path.basename(fname), width='95%')
- self.Print('Summary figure saved: ' + fname)
+ Print('Summary figure saved: ' + fname)
# Generate plots
if not self.summary_only:
@@ -199,9 +109,123 @@ class BaseModule:
plotf(x,y, label=impl, hold=True)
plt.legend(loc='best')
plt.grid(True)
- fname = pjoin(figdir, test+".png")
+ fname = pjoin(cfg.reportdir, test+".png")
plt.savefig(fname, format='png')
html.addFig(test, image=os.path.basename(fname))
- self.Print('Figure ' + fname + ' saved')
+ Print('Figure ' + fname + ' saved')
html.close()
+ Print('HTML report generated: ' + htmlfname)
+
+class CompilationError(Exception):
+ def __init__(self, logfile):
+ self.logfile = logfile
+
+
+class BaseTest:
+ libname = None
+ tests = None
+ files = None
+
+ def __init__(self, root, impl, testdir, logdir):
+ self.root = root
+ self.impl = impl
+ self.testdir = testdir
+ self.logdir = pjoin(logdir, impl)
+ self.compileenv = {}
+ self.runenv = {}
+
+ mkdir(self.logdir)
+
+ self.libdir = cfg.libdir
+ while self.libdir[0] == '/':
+ self.libdir = self.libdir[1:]
+ self.libdir = pjoin(self.root, self.libdir)
+
+ # Base version
+ def _generateResults(self):
+ return dict(zip(self.tests, self.files))
+
+ # Alternatives-2 version with pkg-config
+ def _get_flags(self):
+ libdir = cfg.libdir
+ while libdir[0] == '/':
+ libdir = libdir[1:]
+
+ # Retrieve pkgconfig settings and map the directories to the new root
+ path = pjoin(self.root, "etc/env.d/alternatives", \
+ self.libname, self.impl, libdir, "pkgconfig")
+ cmd = ['pkg-config', '--libs', '--cflags', self.libname]
+ env = {
+ 'PKG_CONFIG_PATH' : path,
+ 'PKG_CONFIG_LIBDIR' : '',
+ 'PKG_CONFIG_SYSROOT_DIR' : self.root
+ }
+ proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.STDOUT, env=env)
+ pkgconf = proc.communicate()[0]
+
+ # Write logfile
+ logfname = pjoin(self.logdir, 'pkgconfig.log')
+ logfile = file(logfname, 'w')
+ logfile.write('PKG_CONFIG_PATH='+path + '\n')
+ logfile.write('PKG_CONFIG_LIBDIR=""' + '\n')
+ logfile.write('PKG_CONFIG_SYSROOT_DIR='+self.root + '\n')
+ logfile.write(' '.join(cmd) + '\n')
+ logfile.write(80*'-' + '\n')
+ logfile.write(pkgconf)
+ logfile.close()
+
+ if proc.returncode != 0:
+ raise CompilationError(logfname)
+
+ return shlex.split(pkgconf)
+
+ def run_test(self):
+ # Convenient renames and definition of report files
+ name = self.libname
+ root = self.root
+ testdir = self.testdir
+ self.files = [pjoin(testdir,f) for f in self.files]
+ env = {} # TODO: remove this
+ if cfg.libdir[0] == '/':
+ libdir = root+cfg.libdir
+ else:
+ libdir = pjoin(root, cfg.libdir)
+
+ # Create dir. If all results already exist use them and do not perform
+ # the tests, otherwise remove every old results.
+ runtests = False
+ if os.path.exists(testdir):
+ runtests = not all([os.path.exists(i) for i in self.files])
+ else:
+ os.makedirs(testdir)
+ runtests = True
+ if not runtests:
+ Print("Not testing: results exist")
+ return self._generateResults()
+ for i in self.files:
+ if os.path.exists(i): os.remove(i)
+
+ # Compile test suite
+ try:
+ returncode, exe, logfile = self._compileTest()
+ if returncode != 0:
+ raise CompilationError(logfile)
+ except CompilationError as e:
+ Print("Compilation failed")
+ Print("See log: " + e.logfile)
+ return
+ Print("Compilation successful")
+
+ # Run test
+ logfile = pjoin(self.logdir, name+"_run.log")
+ retcode = self._executeTest(exe)
+ if returncode != 0:
+ Print("Test failed")
+ Print("See log: " + logfile)
+ return
+ Print("Test successful")
+
+ # Return
+ return self._generateResults()
+
\ No newline at end of file
diff --git a/app-benchmarks/autobench/files/python/benchconfig.py b/app-benchmarks/autobench/files/python/benchconfig.py
new file mode 100644
index 0000000..3b941db
--- /dev/null
+++ b/app-benchmarks/autobench/files/python/benchconfig.py
@@ -0,0 +1,75 @@
+import sys, os, time
+import subprocess as sp
+from benchutils import *
+
+try:
+ needsinitialization = not initialized
+except NameError:
+ needsinitialization = True
+
+
+if needsinitialization:
+ isroot = os.getuid() == 0
+ modname = sys.argv[1]
+
+ # Script directories
+ curdir = os.path.abspath('.')
+ scriptdir = os.path.dirname(os.path.realpath(__file__))
+ btldir = 'btl'
+
+ # Invariant directories:
+ # roots, tests
+ rootsdir = "/var/tmp/benchmarks/roots/"
+ testsdir = "/var/tmp/benchmarks/tests/"
+
+ # Library directory (lib32 vs. lib64)
+ libdir = sp.Popen \
+ ('ABI=$(portageq envvar ABI); echo /usr/`portageq envvar LIBDIR_$ABI`/', \
+ stdout=sp.PIPE, shell=True).communicate()[0].strip()
+
+ # Packages directory
+ if isroot:
+ pkgsdir = "/var/cache/benchmarks/packages/"
+ else:
+ pkgsdir = os.environ['HOME'] + "/.benchmarks/packages/"
+
+ # Report directory
+ if isroot:
+ reportdirb = "/var/cache/benchmarks/reports/"
+ else:
+ reportdirb = os.environ['HOME'] + "/.benchmarks/reports/"
+ reportdirb += modname + "_" + time.strftime('%Y-%m-%d')
+ if os.path.exists(reportdirb):
+ n = 1
+ while True:
+ reportdir = reportdirb + "_%i" % n
+ if not os.path.exists(reportdir):
+ break
+ n += 1
+ else:
+ reportdir = reportdirb
+ del reportdirb
+
+ # Logs directory
+ logdirb = "/var/log/benchmarks/" + modname + "_" + time.strftime('%Y-%m-%d')
+ if os.path.exists(logdirb):
+ n = 1
+ while True:
+ logdir = logdirb + "_%i"%n
+ if not os.path.exists(logdir):
+ break
+ n += 1
+ else:
+ logdir = logdirb
+ del logdirb
+
+def makedirs():
+ mkdir(rootsdir)
+ mkdir(testsdir)
+ mkdir(pkgsdir)
+ mkdir(reportdir)
+ mkdir(logdir)
+
+
+
+inizialized = True
\ No newline at end of file
diff --git a/app-benchmarks/autobench/files/python/benchprint.py b/app-benchmarks/autobench/files/python/benchprint.py
new file mode 100644
index 0000000..b91da66
--- /dev/null
+++ b/app-benchmarks/autobench/files/python/benchprint.py
@@ -0,0 +1,28 @@
+try:
+ needsinitialization = not initialized
+except NameError:
+ needsinitialization = True
+
+
+if needsinitialization:
+ class _Print:
+ def __init__(self, maxlevel=10):
+ self._level = 0
+ self._maxlevel = maxlevel
+
+ def __call__(self, arg):
+ if self._level > self._maxlevel:
+ return
+ if self._level <= 0:
+ print str(arg)
+ return
+ print (self._level-1)*" " + "-- " + str(arg)
+
+ def up(self, n=1):
+ self._level = max(self._level-n, 0)
+
+ def down(self, n=1):
+ self._level = max(self._level+n, 0)
+ Print = _Print(3)
+
+initialized = True
\ No newline at end of file
diff --git a/app-benchmarks/autobench/files/python/benchutils.py b/app-benchmarks/autobench/files/python/benchutils.py
new file mode 100644
index 0000000..824d441
--- /dev/null
+++ b/app-benchmarks/autobench/files/python/benchutils.py
@@ -0,0 +1,8 @@
+import os
+import subprocess as sp
+
+def mkdir(dir):
+ if not os.path.exists(dir):
+ os.makedirs(dir)
+
+run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
\ No newline at end of file
diff --git a/app-benchmarks/autobench/files/python/blas_accuracy.py b/app-benchmarks/autobench/files/python/blas_accuracy.py
index edbf343..890aa1e 100644
--- a/app-benchmarks/autobench/files/python/blas_accuracy.py
+++ b/app-benchmarks/autobench/files/python/blas_accuracy.py
@@ -1,20 +1,12 @@
-from os.path import join as pjoin
import subprocess as sp
import shlex, os
+from os.path import join as pjoin
+
+from benchutils import *
+from benchprint import Print
from htmlreport import HTMLreport
import basemodule
-
-try:
- import matplotlib.pyplot as plt
- import numpy as np
- with_images = 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\n')
- with_images = False
-
-run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
+import benchconfig as cfg
class Module(basemodule.BaseModule):
@@ -39,27 +31,101 @@ class Module(basemodule.BaseModule):
self.tests = self.avail
# Generate list of dat (result) files, relative to the testdir
- self.files = [pjoin('accuracy_%s_%s.dat' % (op, name)) \
+ self.files = [pjoin('accuracy_%s_%s.dat' % (op, self.libname)) \
for op in self.tests]
- def _compileTest(self, logfile, testdir, root, impl, *args, **kwargs):
- exe = pjoin(testdir, 'test')
+ @staticmethod
+ def _testClass():
+ return BLAS_accuracyTest
+
+
+ def save_results(self, results):
+ basemodule.BaseModule.save_results(self, results, 'loglog')
+
+class BLAS_accuracyTest(basemodule.BaseTest):
+
+ compileenv = {}
+ runenv = {}
+
+ def _compileTest(self):
+ self.compileenv = {}
+
+ # Flags and envvars lists
+ includes = [pjoin(self.root, 'usr/include')]
+ libraries = []
+ libdirs = [self.libdir]
+ defines = ['NDEBUG']
+ flags = []
+
+ ## Interpret flags
+ for flag in self._get_flags() + \
+ shlex.split(run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip()):
+ flag = flag.strip()
+ if flag[:2] == '-l':
+ libraries.append(flag[2:])
+ elif flag[:2] == '-L':
+ libdirs.append(flag[2:])
+ elif flag[:2] == '-I':
+ includes.append(flag[2:])
+ else:
+ flags.append(flag)
+
+ # Set compile environment
+ self.compileenv['INCLUDE_PATH'] = ':'.join(includes)
+ self.compileenv['LIBRARY_PATH'] = ':'.join(libdirs)
+ self.compileenv['LD_LIBRARY_PATH'] = ':'.join(libdirs)
+ self.runenv['LD_LIBRARY_PATH'] = ':'.join(libdirs)
+
+ exe = pjoin(self.testdir, "test")
source = "accuracy/main_blas.cpp"
- flags = self._get_flags(root, impl, self.libdir)
- cxxflags = run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip()
+
+ # Retrieve compiler
cxx = 'g++'
- cmd = [cxx, '-o', exe, source] + flags + shlex.split(cxxflags)
- proc = sp.Popen(cmd, stdout=file(logfile, 'w'), stderr=sp.STDOUT)
+ cxx_portage = run_cmd(['portageq', 'envvar', 'CXX']).strip()
+ if cxx_portage != '':
+ cxx = cxx_portage
+ if os.environ.has_key('CXX'):
+ cxx = os.environ['CXX']
+
+ # Form command line arguments
+ args = [cxx, source, '-o', exe]
+ args += ['-I'+I for I in includes]
+ args += ['-l'+l for l in libraries]
+ args += ['-L'+L for L in libdirs]
+ args += ['-D'+D for D in defines]
+ args += flags
+
+ # Open logfile or redirect to PIPE
+ logfile = file(pjoin(self.logdir, "compile.log"), 'w')
+ logfile.write(' '.join([n+'='+v for n,v in self.compileenv.items()]))
+ logfile.write(' ' + ' '.join(args) + '\n' + 80*'-' + '\n')
+ logfile.flush()
+
+ # Execute
+ proc=sp.Popen(args,stdout=logfile,stderr=sp.STDOUT,env=self.compileenv)
proc.wait()
- return proc.returncode, exe
+
+ # Close, return
+ logfile.close()
+ return proc.returncode, exe, logfile.name
+
- def _executeTest(self, logfile, exe, testdir):
- # TODO: control objdump and nm
- logfile = file(logfile, 'w')
- cmd = [exe] + self.tests
- proc = sp.Popen(cmd, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE,
- cwd=testdir)
- self.Print.down()
+ def _executeTest(self, exe):
+ # Log dynamic link
+ lddlogfile = file(pjoin(self.logdir, 'ldd.log'), 'w')
+ sp.Popen(['ldd', '-v', exe], stdout=lddlogfile, env=self.runenv).wait()
+
+ # Open pipe
+ logfile = file(pjoin(self.logdir, 'run.log'), 'w')
+ args = [exe] + self.tests
+ logfile.write(' '.join([n+'='+v for n,v in self.runenv.items()]) + ' ')
+ logfile.write(' '.join(args) + '\n')
+ logfile.write(80*'-' + '\n')
+ proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE,
+ env=self.runenv, cwd=self.testdir)
+
+ # Interpret output
+ Print.down()
while True:
line = proc.stdout.readline()
if not line:
@@ -68,18 +134,12 @@ class Module(basemodule.BaseModule):
if len(line.strip()) == 0:
continue
if line[0] != ' ':
- self.Print.up()
- self.Print(line.strip().split()[-1])
- self.Print.down()
+ Print.up()
+ Print(line.strip().split()[-1])
+ Print.down()
else:
- self.Print(line.strip())
- self.Print.up()
+ Print(line.strip())
+ Print.up()
logfile.close()
proc.wait()
return proc.returncode
-
-
- def save_results(self, results, figdir):
- basemodule.BaseModule.save_results(self, results,figdir, 'loglog')
-
-
diff --git a/app-benchmarks/autobench/files/python/blasbase.py b/app-benchmarks/autobench/files/python/blasbase.py
index d2e4edd..664d706 100644
--- a/app-benchmarks/autobench/files/python/blasbase.py
+++ b/app-benchmarks/autobench/files/python/blasbase.py
@@ -38,7 +38,13 @@ class BLASBase(btlbase.BTLBase):
'trisolve_vector', 'matrix_matrix']
btlbase.BTLBase._parse_args(self, args)
-
+
+ @staticmethod
+ def _testClass():
+ return BLASTest
+
+
+class BLASTest(btlbase.BTLTest):
@staticmethod
def _btl_source():
return "libs/BLAS/main.cpp"
@@ -48,4 +54,4 @@ class BLASBase(btlbase.BTLBase):
return ["libs/BLAS"]
def _btl_defines(self):
- return ["CBLASNAME=" + self.libname, "BLAS_INTERFACE"]
+ return ["CBLASNAME=" + self.libname, "BLAS_INTERFACE"]
\ No newline at end of file
diff --git a/app-benchmarks/autobench/files/python/btlbase.py b/app-benchmarks/autobench/files/python/btlbase.py
index 5e07178..1bcc529 100644
--- a/app-benchmarks/autobench/files/python/btlbase.py
+++ b/app-benchmarks/autobench/files/python/btlbase.py
@@ -1,99 +1,12 @@
import sys, os, shlex
-import commands as cmd
import subprocess as sp
from os.path import join as pjoin
+
+from benchutils import *
+from benchprint import Print
from htmlreport import HTMLreport
import basemodule
-
-try:
- import matplotlib.pyplot as plt
- import numpy as np
- with_images = 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\n')
- with_images = False
-
-run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
-
-def btlcompile(exe, source, btldir, includes, defines, libs, libdirs, other, \
- logfile=None):
- """
- Helper function that compiles a C++ source based on btl. The function
- sets the compiler flags that are needed by btl (include directives, link
- with rt,...). More options are accepted as arguments:
-
- exe: the generated executable
-
- source: the C++ source
-
- btldir: the base directory of the btl sources
-
- includes: an iterable containing the include directories (without -I)
-
- defines: an iterable of strings with define directives (without -D). In case
- of key-value pairs, the equal sign and the value have to be in the same
- string as the key: ['NDEBUG', 'FOO=BAR'] is transormed to
- '-DNDEBUD -DFOO=BAR'
-
- libs: the libraries to link against (without -l)
-
- libdirs: the directories where the libraries are seeked (without -L)
-
- other: an iterable with compiler flags
-
- logfile: the path of the file where the log is saved. The directory must
- exist. If None, no log is generated.
- """
-
- # Compile flags
- incs = (
- "%s/actions" % btldir,
- "%s/generic_bench" % btldir,
- "%s/generic_bench/utils" % btldir,
- "%s/libs/STL" % btldir
- ) + tuple(includes)
- incs = ['-I'+i for i in incs]
-
- defs = ['-D'+d for d in ["NDEBUG"] + defines]
-
- libs = ['-l'+l for l in ["rt"] + libs]
-
- libdirs = ['-L'+L for L in libdirs]
-
- cxxflags = shlex.split(run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip())
-
- otherfl = other
-
- # Retrieve compiler
- cxx = 'g++'
- cxx_portage = run_cmd(['portageq', 'envvar', 'CXX']).strip()
- if cxx_portage != '':
- cxx = cxx_portage
- if os.environ.has_key('CXX'):
- cxx = os.environ['CXX']
-
- # Compile command
- cl = [cxx, '-o', exe, source]+incs+defs+libs+libdirs+cxxflags+other
-
- # Open logfile or redirect to PIPE
- if logfile is None:
- fout = sp.PIPE
- else:
- fout = file(logfile, 'w')
- fout.write(str(cl) + "\n" + 80*'-' + "\n")
- fout.flush()
-
- # Execute command
- cp = sp.Popen(cl, stdout=fout, stderr=sp.STDOUT)
- cp.wait()
-
- # Close the log file (if any)
- if logfile is not None:
- fout.close()
-
- return cp.returncode
+import benchconfig as cfg
class BTLBase(basemodule.BaseModule):
@@ -103,29 +16,101 @@ class BTLBase(basemodule.BaseModule):
self.files = [pjoin('bench_%s_%s.dat' % (op, self.libname)) \
for op in self.tests]
- def _compileTest(self, logfile, testdir, root, impl, libdir, \
- *args, **kwargs):
- btldir = 'btl/'
- exe = pjoin(testdir, "test")
- returncode = btlcompile(
- exe = exe,
- source = pjoin(btldir, self._btl_source()),
- btldir = btldir,
- includes = [pjoin(btldir, d) for d in self._btl_includes()],
- defines = self._btl_defines(),
- libs = [],
- libdirs = [libdir],
- other = self._get_flags(root, impl, self.libdir),
- logfile = logfile
- )
- return returncode, exe
-
- def _executeTest(self, logfile, exe, testdir):
- # TODO: control objdump and nm
- logfile = file(logfile, 'w')
+ def save_results(self, results):
+ basemodule.BaseModule.save_results(self, results, 'semilogx')
+
+
+class BTLTest(basemodule.BaseTest):
+
+ compileenv = {}
+ runenv = {}
+
+ def _compileTest(self):
+ self.compileenv = {}
+
+ # Includes
+ includes = [pjoin(cfg.btldir, i) for i in \
+ ('actions', 'generic_bench', 'generic_bench/utils', 'libs/STL') + \
+ tuple(self._btl_includes())] + [pjoin(self.root, 'usr/include')]
+
+ # Libraries
+ libraries = ['rt']
+
+ # Libdirs
+ libdirs = [self.libdir]
+
+ # Defines
+ defines = ['NDEBUG'] + self._btl_defines()
+
+ # Flags
+ flags = []
+
+ ## Interpret flags
+ for flag in self._get_flags() + \
+ shlex.split(run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip()):
+ flag = flag.strip()
+ if flag[:2] == '-l':
+ libraries.append(flag[2:])
+ elif flag[:2] == '-L':
+ libdirs.append(flag[2:])
+ elif flag[:2] == '-I':
+ includes.append(flag[2:])
+ else:
+ flags.append(flag)
+
+ # Set compile environment
+ self.compileenv['INCLUDE_PATH'] = ':'.join(includes)
+ self.compileenv['LIBRARY_PATH'] = ':'.join(libdirs)
+ self.compileenv['LD_LIBRARY_PATH'] = ':'.join(libdirs)
+ self.runenv['LD_LIBRARY_PATH'] = ':'.join(libdirs)
+
+ exe = pjoin(self.testdir, "test")
+
+ # Retrieve compiler
+ cxx = 'g++'
+ cxx_portage = run_cmd(['portageq', 'envvar', 'CXX']).strip()
+ if cxx_portage != '':
+ cxx = cxx_portage
+ if os.environ.has_key('CXX'):
+ cxx = os.environ['CXX']
+
+ # Form command line arguments
+ args = [cxx, pjoin(cfg.btldir, self._btl_source()), '-o', exe]
+ args += ['-I'+I for I in includes]
+ args += ['-l'+l for l in libraries]
+ args += ['-L'+L for L in libdirs]
+ args += ['-D'+D for D in defines]
+ args += flags
+
+ # Open logfile or redirect to PIPE
+ logfile = file(pjoin(self.logdir, "compile.log"), 'w')
+ logfile.write(' '.join([n+'='+v for n,v in self.compileenv.items()]))
+ logfile.write(' ' + ' '.join(args) + '\n' + 80*'-' + '\n')
+ logfile.flush()
+
+ # Execute
+ proc=sp.Popen(args,stdout=logfile,stderr=sp.STDOUT,env=self.compileenv)
+ proc.wait()
+
+ # Close, return
+ logfile.close()
+ return proc.returncode, exe, logfile.name
+
+ def _executeTest(self, exe):
+ # Log dynamic link
+ lddlogfile = file(pjoin(self.logdir, 'ldd.log'), 'w')
+ sp.Popen(['ldd', '-v', exe], stdout=lddlogfile, env=self.runenv).wait()
+
+ # Open pipe
+ logfile = file(pjoin(self.logdir, 'btlrun.log'), 'w')
args = [exe] + self.tests
+ logfile.write(' '.join([n+'='+v for n,v in self.runenv.items()]) + ' ')
+ logfile.write(' '.join(args) + '\n')
+ logfile.write(80*'-' + '\n')
proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE,
- cwd = testdir)
+ env=self.runenv, cwd=self.testdir)
+
+ # Interpret output
while True:
# Each operation test begins with a line on stderr
errline = proc.stderr.readline()
@@ -134,18 +119,18 @@ class BTLBase(basemodule.BaseModule):
logfile.write(errline)
resfile = errline.split()[-1]
testname = resfile[6:-5-len(self.libname)]
- self.Print(resfile)
+ Print(resfile)
# 100 different sizes for each operation test
- self.Print.down()
+ Print.down()
for i in xrange(100):
outline = proc.stdout.readline()
+ # If the line is void, something gone wrong
+ if not outline:
+ return 1
logfile.write(outline)
- self.Print(outline.strip())
- self.Print.up()
+ Print(outline.strip())
+ Print.up()
logfile.close()
proc.wait()
- return proc.returncode
-
- def save_results(self, results, figdir):
- basemodule.BaseModule.save_results(self, results,figdir, 'semilogx')
+ return proc.returncode
\ No newline at end of file
diff --git a/app-benchmarks/autobench/files/python/lapack.py b/app-benchmarks/autobench/files/python/lapack.py
index 136d837..e618380 100644
--- a/app-benchmarks/autobench/files/python/lapack.py
+++ b/app-benchmarks/autobench/files/python/lapack.py
@@ -27,6 +27,13 @@ class Module(btlbase.BTLBase):
btlbase.BTLBase._parse_args(self, args)
@staticmethod
+ def _testClass():
+ return LapackTest
+
+
+
+class LapackTest(btlbase.BTLTest):
+ @staticmethod
def _btl_source():
return "libs/LAPACK/main.cpp"
@@ -34,5 +41,7 @@ class Module(btlbase.BTLBase):
def _btl_includes():
return ["libs/BLAS", "libs/LAPACK"]
- def _btl_defines(self):
- return ["LAPACKNAME=" + self.libname]
+ @staticmethod
+ def _btl_defines():
+ return ["LAPACKNAME=lapack"]
+
\ No newline at end of file
diff --git a/app-benchmarks/autobench/files/python/main.py b/app-benchmarks/autobench/files/python/main.py
index 3a02791..79b41e9 100644
--- a/app-benchmarks/autobench/files/python/main.py
+++ b/app-benchmarks/autobench/files/python/main.py
@@ -1,85 +1,29 @@
#! /usr/bin/env python2
-import os, sys, shlex
+import os, sys, shlex, time
from os.path import join as pjoin
-from PortageUtils import *
import subprocess as sp
-import time
-
-# Retrieve relevant files/directories
-# TODO: use external config module to share these variables (or use environ?)
-curdir = os.path.abspath('.')
-scriptdir = os.path.dirname(os.path.realpath(__file__))
-rootsdir = "/var/tmp/benchmarks/roots/"
-testsdir = "/var/tmp/benchmarks/tests/"
-if os.getuid() == 0:
- pkgsdir = "/var/cache/benchmarks/packages/"
- figdirb = "/var/cache/benchmarks/results/"
-else:
- pkgsdir = os.environ['HOME'] + "/.benchmarks/packages/"
- figdirb = os.environ['HOME'] + "/.benchmarks/results/"
-
-# Library directory (lib32 vs. lib64)
-libdir = sp.Popen \
- ('ABI=$(portageq envvar ABI); echo /usr/`portageq envvar LIBDIR_$ABI`/', \
- stdout=sp.PIPE, shell=True).communicate()[0].strip()
-
-# Figures directory
-figdir = figdirb + time.strftime('%Y-%m-%d')
-if os.path.exists(figdir):
- n = 1
- while True:
- figdir = figdirb + time.strftime('%Y-%m-%d') + "_%i"%n
- if not os.path.exists(figdir):
- os.makedirs(figdir)
- break
- n += 1
-else:
- os.makedirs(figdir)
-
-# Logs directory
-logdir = "/var/log/benchmarks/" + time.strftime('%Y-%m-%d')
-if os.path.exists(logdir):
- n = 1
- while True:
- logdir = "/var/log/benchmarks/" + time.strftime('%Y-%m-%d') + "_%i"%n
- if not os.path.exists(logdir):
- os.makedirs(logdir)
- break
- n += 1
-else:
- os.makedirs(logdir)
def print_usage():
- print "Usage: benchmarks [blas|cblas|lapack] file args"
-
-class _Print:
- def __init__(self, maxlevel=10):
- self._level = 0
- self._maxlevel = maxlevel
-
- def __call__(self, arg):
- if self._level > self._maxlevel:
- return
- if self._level <= 0:
- print str(arg)
- return
- print (self._level-1)*" " + "-- " + str(arg)
-
- def up(self, n=1):
- self._level = max(self._level-n, 0)
-
- def down(self, n=1):
- self._level = max(self._level+n, 0)
-Print = _Print(3)
+ print "Usage: benchmarks [blas|cblas|lapack] 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:
testsfname = os.path.abspath(sys.argv[2])
- os.chdir(scriptdir)
+ os.chdir(cfg.scriptdir)
tmp = __import__(sys.argv[1], fromlist = ['Module'])
- mod = tmp.Module(Print, libdir, sys.argv[3:])
+ mod = tmp.Module(sys.argv[3:])
del tmp
+ cfg.makedirs()
except ImportError, IndexError:
print_usage()
exit(1)
@@ -177,9 +121,9 @@ print
for tn,(name,test) in enumerate(tests.items(),1):
Print("BEGIN TEST %i - %s" % (tn, name))
- pkgdir = pjoin(pkgsdir, name)
- root = pjoin(rootsdir, name)
- tlogdir = pjoin(logdir, name)
+ pkgdir = pjoin(cfg.pkgsdir, name)
+ root = pjoin(cfg.rootsdir, name)
+ tlogdir = pjoin(cfg.logdir, name)
os.path.exists(tlogdir) or os.makedirs(tlogdir)
# Emerge package
@@ -227,27 +171,26 @@ for tn,(name,test) in enumerate(tests.items(),1):
Print.down()
# Run the test suite
- testdir = os.path.join(testsdir, name, impl)
- test['results'][impl] = \
- mod.run_test(root, impl, testdir, env=test['env'], logdir=tlogdir)
+ testdir = os.path.join(cfg.testsdir, name, impl)
+ t = mod.getTest(root, impl, testdir, logdir=tlogdir)
+ test['results'][impl] = t.run_test()
Print.up()
Print.up()
print
-# Reports will be saved in figdir
+# Reports will be saved in cfg.reportdir
# Results are reordered:
# results
# |-(name1, impl1) -> resultobject11
# |-(name1, impl2) -> resultobject12
-# |-(name2, impl1) -> resultobject21
-os.path.exists(figdir) or os.makedirs(figdir)
+# |-(name2, impl1) -> resultobject21
results = {}
for (name,test) in tests.items():
if test.has_key('implementations'):
for impl in test['implementations']:
results[(name, impl)] = test['results'][impl]
-mod.save_results(results, figdir)
+mod.save_results(results)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/
@ 2011-07-04 21:38 Andrea Arteaga
0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arteaga @ 2011-07-04 21:38 UTC (permalink / raw
To: gentoo-commits
commit: c2093208c4f1e989a4f0041e33ee3bafd72a2ae6
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Mon Jul 4 09:35:40 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Mon Jul 4 09:35:40 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=c2093208
BaseModule introduced. Work on accuracy module.
---
.../python/{blas_accuracy.py => 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
try:
import matplotlib.pyplot as plt
@@ -16,7 +16,7 @@ except ImportError:
run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
-class Module:
+class BaseModule:
def __init__(self, Print, libdir, args):
self.Print = Print
self.libdir = libdir
@@ -37,31 +37,14 @@ class Module:
passargs += [i]
self._parse_args(passargs)
-
- def _initialize(self):
- self.libname = 'blas'
- self.avail=['axpy', 'matrix_vector', 'trisolve_vector', 'matrix_matrix']
-
- def _parse_args(self, args):
- # Parse arguments
- tests = []
- for i in args:
- if i in self.avail:
- tests.append(i)
- continue
- raise Exception("Argument not recognized: " + i)
-
- # Sort tests
- self.tests = [i for i in self.avail if i in tests]
-
- # If no test is specified, then do everything
- if len(self.tests) == 0:
- self.tests = self.avail
+ # Alternatives-2 version with pkg-config
def _get_flags(self, root, impl, libdir):
+ while libdir[0] == '/':
+ libdir = libdir[1:]
# Retrieve pkgconfig settings and map the directories to the new root
path = pjoin(root, "etc/env.d/alternatives", \
- self.libname, impl, libdir, "pkgconfig")
+ self.libname,impl,libdir, "pkgconfig")
cmd = ['pkg-config', '--libs', '--cflags', self.libname]
env = {'PKG_CONFIG_PATH':path}
pkgconf = sp.Popen(cmd, stdout=sp.PIPE, env=env).communicate()[0]
@@ -69,41 +52,60 @@ class Module:
pkgconf = pkgconf.replace('-I/', '-I'+root+'/')
return shlex.split(pkgconf)
+ # Alternatives-2 version
def get_impls(self, root):
output = sp.Popen(
- ['eselect', '--no-color', '--brief', 'blas', 'list'],
- env={'ROOT' : root}, stdout=sp.PIPE
- ).communicate()[0]
+ ['eselect', '--no-color', '--brief', self.libname, 'list'],
+ env={'ROOT' : root}, stdout=sp.PIPE).communicate()[0]
return output.strip().split('\n')
+
+ # Base version
+ def _generateResults(self, files):
+ return dict(zip(self.tests, files))
def run_test(self, root, impl, testdir, env, logdir):
+ # Convenient renames and definition of report files
Print = self.Print
- libdir = self.libdir
name = self.libname
- files = [pjoin(testdir, 'accuracy_%s_%s.dat' % (op, name)) \
- for op in self.tests]
+ files = [pjoin(testdir,f) for f in self.files]
+ if self.libdir[0] == '/':
+ libdir = root+self.libdir
+ else:
+ libdir = pjoin(root, self.libdir)
+
+ # Create dir. If all results already exist use them and do not perform
+ # the tests, otherwise remove every old results.
+ runtests = False
+ if os.path.exists(testdir):
+ runtests = not all([os.path.exists(i) for i in files])
+ else:
+ os.makedirs(testdir)
+ runtests = True
+
+ if not runtests:
+ Print("Not testing: results exist")
+ return self._generateResults(files)
- results = {}
- for op in self.tests:
- results[op] = pjoin(testdir, 'accuracy_%s_%s.dat' % (op, name))
+ for i in files:
+ if os.path.exists(i): os.remove(i)
# Prepare the environment
if env.has_key('LIBRARY_PATH'):
- env['LIBRARY_PATH'] = pjoin(root,libdir) + ":" + env['LIBRARY_PATH']
+ env['LIBRARY_PATH'] = libdir + ":" + env['LIBRARY_PATH']
else:
- env['LIBRARY_PATH'] = pjoin(root, libdir)
+ env['LIBRARY_PATH'] = libdir
if env.has_key('INCLUDE_PATH'):
env['INCLUDE_PATH'] = \
- pjoin(root, "/usr/include") + ":" + env['INCLUDE_PATH']
+ pjoin(root, "usr/include") + ":" + env['INCLUDE_PATH']
else:
- env['INCLUDE_PATH'] = pjoin(root, "/usr/include")
+ env['INCLUDE_PATH'] = pjoin(root, "usr/include")
if env.has_key('LD_LIBRARY_PATH'):
env['LD_LIBRARY_PATH'] = \
- pjoin(root, libdir) + ":" + env['LD_LIBRARY_PATH']
+ libdir + ":" + env['LD_LIBRARY_PATH']
else:
- env['LD_LIBRARY_PATH'] = pjoin(root, libdir)
+ env['LD_LIBRARY_PATH'] = libdir
# Backup the environment
oldenv = {}
@@ -111,60 +113,51 @@ class Module:
oldenv[k] = \
(os.environ.has_key(k) and (os.environ[k],) or (None,))[0]
- # Set the environment
+ # Set the new environment
for k,v in env.items():
os.environ[k] = v
# Compile test suite
- exe = pjoin(testdir, 'test')
- source = "accuracy/main_blas.cpp"
- flags = self._get_flags(root, impl, libdir)
- cxxflags = run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip()
- cxx = 'g++'
- cmd = [cxx, '-o', exe, source] + flags + shlex.split(cxxflags)
- logfile = pjoin(logdir, 'compile.log')
- p = sp.Popen(cmd, stdout=file(logfile, 'w'), stderr=sp.STDOUT)
- p.wait()
- if p.returncode != 0:
+ logfile = os.path.join(logdir, name+"_comp.log")
+ returncode, exe = self._compileTest(logfile=logfile, testdir=testdir, \
+ root=root, impl=impl, libdir=libdir)
+ if returncode != 0:
Print("Compilation failed")
Print("See log: " + logfile)
return
Print("Compilation successful")
# Run test
- logfile = file(pjoin(logdir, name+"_run.log"), 'w')
- cmd = [pjoin(testdir,"test")] + self.tests
- proc = sp.Popen(cmd, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE,
- cwd=testdir)
- Print.down()
- while True:
- line = proc.stdout.readline()
- if not line:
- break
- logfile.write(line)
- if len(line.strip()) == 0:
- continue
- if line[0] != ' ':
- Print.up()
- Print(line.strip().split()[-1])
- Print.down()
- else:
- Print(line.strip())
- Print.up()
- logfile.close()
- proc.wait()
- if proc.returncode != 0:
- Print('Test failed')
- else:
- Print('Test successful')
-
- return results
+ logfile = pjoin(logdir, name+"_run.log")
+ retcode = self._executeTest(logfile=logfile, exe=exe, testdir=testdir)
+ if returncode != 0:
+ Print("Test failed")
+ Print("See log: " + logfile)
+ return
+ Print("Test successful")
+ # Restore the old environment
+ for k in env.keys():
+ if oldenv[k] != None:
+ os.environ[k] = oldenv[k]
+ elif os.environ.has_key(k):
+ del os.environ[k]
+
+ # Return
+ return self._generateResults(files)
+
- def save_results(self, results, figdir):
+ def save_results(self, results, figdir, plottype='plot'):
if not with_images:
self.Print("Report generation skipped - missing libraries")
return
+
+ if plottype == 'plot': plotf = plt.plot
+ elif plottype == 'semilogx': plotf = plt.semilogx
+ elif plottype == 'semilogy': plotf = plt.semilogy
+ elif plottype == 'loglog': plotf = plt.loglog
+ else:
+ raise Exception('Unrecognized plot type: "' + plottype + '"')
# Re-order the result dictionary
newresults = {}
@@ -189,7 +182,7 @@ class Module:
plt.title(test)
for impl in newresults[test]:
x,y = np.loadtxt(newresults[test][impl], unpack=True)
- plt.loglog(x,y, label=impl, hold=True)
+ plotf(x,y, label=impl, hold=True)
plt.legend(loc='best')
plt.grid(True)
fname = pjoin(figdir, 'summary.png')
@@ -203,7 +196,7 @@ class Module:
plt.figure(figsize=(12,9), dpi=300)
for impl in newresults[test]:
x,y = np.loadtxt(newresults[test][impl], unpack=True)
- plt.loglog(x,y, label=impl, hold=True)
+ plotf(x,y, label=impl, hold=True)
plt.legend(loc='best')
plt.grid(True)
fname = pjoin(figdir, test+".png")
@@ -212,5 +205,3 @@ class Module:
self.Print('Figure ' + fname + ' saved')
html.close()
-
-
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
try:
import matplotlib.pyplot as plt
@@ -16,27 +16,7 @@ except ImportError:
run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
-class Module:
- def __init__(self, Print, libdir, args):
- self.Print = Print
- self.libdir = libdir
- self.summary = False
- self.summary_only = False
-
- self._initialize()
-
- passargs = []
- for i in args:
- if i == '-S':
- self.summary_only = True
- continue
- elif i == '-s':
- self.summary = True
- continue
- else:
- passargs += [i]
-
- self._parse_args(passargs)
+class Module(basemodule.BaseModule):
def _initialize(self):
self.libname = 'blas'
@@ -57,86 +37,29 @@ class Module:
# If no test is specified, then do everything
if len(self.tests) == 0:
self.tests = self.avail
-
- def _get_flags(self, root, impl, libdir):
- # Retrieve pkgconfig settings and map the directories to the new root
- path = pjoin(root, "etc/env.d/alternatives", \
- self.libname, impl, libdir, "pkgconfig")
- cmd = ['pkg-config', '--libs', '--cflags', self.libname]
- env = {'PKG_CONFIG_PATH':path}
- pkgconf = sp.Popen(cmd, stdout=sp.PIPE, env=env).communicate()[0]
- pkgconf = pkgconf.replace('-L/', '-L'+root+'/')
- pkgconf = pkgconf.replace('-I/', '-I'+root+'/')
- return shlex.split(pkgconf)
-
- def get_impls(self, root):
- output = sp.Popen(
- ['eselect', '--no-color', '--brief', 'blas', 'list'],
- env={'ROOT' : root}, stdout=sp.PIPE
- ).communicate()[0]
- return output.strip().split('\n')
-
- def run_test(self, root, impl, testdir, env, logdir):
- Print = self.Print
- libdir = self.libdir
- name = self.libname
- files = [pjoin(testdir, 'accuracy_%s_%s.dat' % (op, name)) \
+
+ # Generate list of dat (result) files, relative to the testdir
+ self.files = [pjoin('accuracy_%s_%s.dat' % (op, name)) \
for op in self.tests]
- results = {}
- for op in self.tests:
- results[op] = pjoin(testdir, 'accuracy_%s_%s.dat' % (op, name))
-
- # Prepare the environment
- if env.has_key('LIBRARY_PATH'):
- env['LIBRARY_PATH'] = pjoin(root,libdir) + ":" + env['LIBRARY_PATH']
- else:
- env['LIBRARY_PATH'] = pjoin(root, libdir)
-
- if env.has_key('INCLUDE_PATH'):
- env['INCLUDE_PATH'] = \
- pjoin(root, "/usr/include") + ":" + env['INCLUDE_PATH']
- else:
- env['INCLUDE_PATH'] = pjoin(root, "/usr/include")
-
- if env.has_key('LD_LIBRARY_PATH'):
- env['LD_LIBRARY_PATH'] = \
- pjoin(root, libdir) + ":" + env['LD_LIBRARY_PATH']
- else:
- env['LD_LIBRARY_PATH'] = pjoin(root, libdir)
-
- # Backup the environment
- oldenv = {}
- for k in env.keys():
- oldenv[k] = \
- (os.environ.has_key(k) and (os.environ[k],) or (None,))[0]
-
- # Set the environment
- for k,v in env.items():
- os.environ[k] = v
-
- # Compile test suite
+ def _compileTest(self, logfile, testdir, root, impl, *args, **kwargs):
exe = pjoin(testdir, 'test')
source = "accuracy/main_blas.cpp"
- flags = self._get_flags(root, impl, libdir)
+ flags = self._get_flags(root, impl, self.libdir)
cxxflags = run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip()
cxx = 'g++'
cmd = [cxx, '-o', exe, source] + flags + shlex.split(cxxflags)
- logfile = pjoin(logdir, 'compile.log')
- p = sp.Popen(cmd, stdout=file(logfile, 'w'), stderr=sp.STDOUT)
- p.wait()
- if p.returncode != 0:
- Print("Compilation failed")
- Print("See log: " + logfile)
- return
- Print("Compilation successful")
-
- # Run test
- logfile = file(pjoin(logdir, name+"_run.log"), 'w')
- cmd = [pjoin(testdir,"test")] + self.tests
+ proc = sp.Popen(cmd, stdout=file(logfile, 'w'), stderr=sp.STDOUT)
+ proc.wait()
+ return proc.returncode, exe
+
+ def _executeTest(self, logfile, exe, testdir):
+ # TODO: control objdump and nm
+ logfile = file(logfile, 'w')
+ cmd = [exe] + self.tests
proc = sp.Popen(cmd, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE,
cwd=testdir)
- Print.down()
+ self.Print.down()
while True:
line = proc.stdout.readline()
if not line:
@@ -145,72 +68,18 @@ class Module:
if len(line.strip()) == 0:
continue
if line[0] != ' ':
- 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()
+ self.Print(line.strip())
+ self.Print.up()
logfile.close()
proc.wait()
- if proc.returncode != 0:
- Print('Test failed')
- else:
- Print('Test successful')
-
- return results
-
+ return proc.returncode
+
def save_results(self, results, figdir):
- if not with_images:
- self.Print("Report generation skipped - missing libraries")
- return
-
- # Re-order the result dictionary
- newresults = {}
- for test in self.tests:
- newresults[test] = {}
- for nameimpl in results:
- nameimplstr = pjoin(*nameimpl)
- resdat = results[nameimpl][test]
- newresults[test][nameimplstr] = resdat
-
- # Begin the HTML report
- htmlfname = pjoin(figdir, 'index.html')
- html = HTMLreport(htmlfname)
-
- # Generate summary - a single image with all plots
- if self.summary or self.summary_only:
- # Save summary figure
- sprows = (len(self.tests)+1)/2
- plt.figure(figsize=(16,6*sprows), dpi=300)
- for i, test in enumerate(self.tests, 1):
- plt.subplot(sprows, 2, i)
- plt.title(test)
- for impl in newresults[test]:
- x,y = np.loadtxt(newresults[test][impl], unpack=True)
- plt.loglog(x,y, label=impl, hold=True)
- plt.legend(loc='best')
- plt.grid(True)
- fname = pjoin(figdir, 'summary.png')
- plt.savefig(fname, format='png')
- html.addFig("Summary", image=os.path.basename(fname), width='95%')
- self.Print('Summary figure saved: ' + fname)
-
- # Generate plots
- if not self.summary_only:
- for test in self.tests:
- plt.figure(figsize=(12,9), dpi=300)
- for impl in newresults[test]:
- x,y = np.loadtxt(newresults[test][impl], unpack=True)
- plt.loglog(x,y, label=impl, hold=True)
- plt.legend(loc='best')
- plt.grid(True)
- fname = pjoin(figdir, test+".png")
- plt.savefig(fname, format='png')
- html.addFig(test, image=os.path.basename(fname))
- self.Print('Figure ' + fname + ' saved')
-
- html.close()
+ basemodule.BaseModule.save_results(self, results,figdir, 'loglog')
diff --git a/app-benchmarks/autobench/files/python/blasbase.py b/app-benchmarks/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) == 0:
self.tests = ['axpy', 'matrix_vector', \
'trisolve_vector', 'matrix_matrix']
+
+ btlbase.BTLBase._parse_args(self, args)
@staticmethod
def _btl_source():
@@ -47,24 +49,3 @@ class BLASBase(btlbase.BTLBase):
def _btl_defines(self):
return ["CBLASNAME=" + self.libname, "BLAS_INTERFACE"]
-
- def _get_flags(self, root, impl, libdir):
- # Retrieve pkgconfig settings and map the directories to the new root
- path = pjoin(root, "etc/env.d/alternatives", \
- self.libname,impl,libdir, "pkgconfig")
- cmd = ['pkg-config', '--libs', '--cflags', self.libname]
- env = {'PKG_CONFIG_PATH':path}
- pkgconf = sp.Popen(cmd, stdout=sp.PIPE, env=env).communicate()[0]
- pkgconf = pkgconf.replace('-L/', '-L'+root+'/')
- pkgconf = pkgconf.replace('-I/', '-I'+root+'/')
- return shlex.split(pkgconf)
-
-
- def get_impls(self, root):
- output = sp.Popen(
- ['eselect', '--no-color', '--brief', self.libname, 'list'],
- env={'ROOT' : root}, stdout=sp.PIPE
- ).communicate()[0]
- return output.strip().split('\n')
-
-del btlbase
diff --git a/app-benchmarks/autobench/files/python/btlbase.py b/app-benchmarks/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
try:
import matplotlib.pyplot as plt
@@ -95,110 +96,36 @@ def btlcompile(exe, source, btldir, includes, defines, libs, libdirs, other, \
return cp.returncode
-class BTLBase:
- def __init__(self, Print, libdir, args):
- self.Print = Print
- self.libdir = libdir
- self.summary = False
- self.summary_only = False
-
- self._initialize()
-
- passargs = []
- for i in args:
- if i == '-S':
- self.summary_only = True
- continue
- elif i == '-s':
- self.summary = True
- continue
- else:
- passargs += [i]
-
- self._parse_args(passargs)
-
-
- def run_test(self, root, impl, testdir, env, logdir):
- # Convenient renames and definition of report files
- Print = self.Print
- libdir = self.libdir
- name = self.libname
- files = [pjoin(testdir, 'bench_%s_%s.dat' % (op, name)) \
+class BTLBase(basemodule.BaseModule):
+
+ 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)) \
for op in self.tests]
-
- # Create dir. If all results already exist use them and do not perform
- # the tests, otherwise remove every old results.
- runtests = False
- if os.path.exists(testdir):
- runtests = not all([os.path.exists(i) for i in files])
- else:
- os.makedirs(testdir)
- runtests = True
-
- if not runtests:
- Print("Not testing: results exist")
- results = {}
- for op in self.tests:
- results[op] = pjoin(testdir, 'bench_%s_%s.dat'%(op,name))
- return results
-
- for i in files:
- if os.path.exists(i): os.remove(i)
-
- # Prepare the environment
- if env.has_key('LIBRARY_PATH'):
- env['LIBRARY_PATH'] = pjoin(root,libdir) + ":" + env['LIBRARY_PATH']
- else:
- env['LIBRARY_PATH'] = pjoin(root, libdir)
-
- if env.has_key('INCLUDE_PATH'):
- env['INCLUDE_PATH'] = \
- pjoin(root, "/usr/include") + ":" + env['INCLUDE_PATH']
- else:
- env['INCLUDE_PATH'] = pjoin(root, "/usr/include")
-
- if env.has_key('LD_LIBRARY_PATH'):
- env['LD_LIBRARY_PATH'] = \
- pjoin(root, libdir) + ":" + env['LD_LIBRARY_PATH']
- else:
- env['LD_LIBRARY_PATH'] = pjoin(root, libdir)
-
- # Backup the environment
- oldenv = {}
- for k in env.keys():
- oldenv[k] = \
- (os.environ.has_key(k) and (os.environ[k],) or (None,))[0]
-
- # Set the environment
- for k,v in env.items():
- os.environ[k] = v
-
- # Compile test suite
+
+ def _compileTest(self, logfile, testdir, root, impl, libdir, \
+ *args, **kwargs):
btldir = 'btl/'
- logfile = os.path.join(logdir, name+"_comp.log")
+ exe = pjoin(testdir, "test")
returncode = btlcompile(
- exe = pjoin(testdir, "test"),
+ exe = exe,
source = pjoin(btldir, self._btl_source()),
btldir = btldir,
includes = [pjoin(btldir, d) for d in self._btl_includes()],
defines = self._btl_defines(),
libs = [],
- libdirs = [root+libdir],
- other = self._get_flags(root, impl, libdir),
+ libdirs = [libdir],
+ other = self._get_flags(root, impl, self.libdir),
logfile = logfile
)
- if returncode != 0:
- Print("Compilation failed")
- Print("See log: " + logfile)
- return
- Print("Compilation successful")
-
- # Run test
- logfile = file(pjoin(logdir, name+"_run.log"), 'w')
- args = [pjoin(testdir,"test")] + self.tests
+ return returncode, exe
+
+ def _executeTest(self, logfile, exe, testdir):
+ # TODO: control objdump and nm
+ logfile = file(logfile, 'w')
+ args = [exe] + self.tests
proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE,
cwd = testdir)
- results = {}
while True:
# Each operation test begins with a line on stderr
errline = proc.stderr.readline()
@@ -206,82 +133,19 @@ class BTLBase:
break
logfile.write(errline)
resfile = errline.split()[-1]
- testname = resfile[6:-5-len(name)]
- results[testname] = pjoin(testdir, resfile)
- Print(resfile)
+ testname = resfile[6:-5-len(self.libname)]
+ self.Print(resfile)
# 100 different sizes for each operation test
- Print.down()
+ self.Print.down()
for i in xrange(100):
outline = 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 != 0:
- Print('Test failed')
- else:
- Print('Test successful')
-
- # Restore the old environment
- for k in env.keys():
- if oldenv[k] != None:
- os.environ[k] = oldenv[k]
- elif os.environ.has_key(k):
- del os.environ[k]
- return results
+ return proc.returncode
def save_results(self, results, figdir):
- if not with_images:
- self.Print("Report generation skipped - missing libraries")
- return
-
- # Re-order the result dictionary
- newresults = {}
- for test in self.tests:
- newresults[test] = {}
- for nameimpl in results:
- nameimplstr = pjoin(*nameimpl)
- resdat = results[nameimpl][test]
- newresults[test][nameimplstr] = resdat
-
- # Begin the HTML report
- htmlfname = pjoin(figdir, 'index.html')
- html = HTMLreport(htmlfname)
-
- # Generate summary - a single image with all plots
- if self.summary or self.summary_only:
- # Save summary figure
- sprows = (len(self.tests)+1)/2
- plt.figure(figsize=(16,6*sprows), dpi=300)
- for i, test in enumerate(self.tests, 1):
- plt.subplot(sprows, 2, i)
- plt.title(test)
- for impl in newresults[test]:
- x,y = np.loadtxt(newresults[test][impl], unpack=True)
- plt.semilogx(x,y, label=impl, hold=True)
- plt.legend(loc='best')
- plt.grid(True)
- fname = pjoin(figdir, 'summary.png')
- plt.savefig(fname, format='png')
- html.addFig("Summary", image=os.path.basename(fname), width='95%')
- self.Print('Summary figure saved: ' + fname)
-
- # Generate plots
- if not self.summary_only:
- for test in self.tests:
- plt.figure(figsize=(12,9), dpi=300)
- for impl in newresults[test]:
- x,y = np.loadtxt(newresults[test][impl], unpack=True)
- plt.semilogx(x,y, label=impl, hold=True)
- plt.legend(loc='best')
- plt.grid(True)
- fname = pjoin(figdir, test+".png")
- plt.savefig(fname, format='png')
- html.addFig(test, image=os.path.basename(fname))
- self.Print('Figure ' + fname + ' saved')
-
- html.close()
-
-
+ basemodule.BaseModule.save_results(self, results,figdir, 'semilogx')
diff --git a/app-benchmarks/autobench/files/python/lapack.py b/app-benchmarks/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) == 0:
self.tests = self.avail
+
+ btlbase.BTLBase._parse_args(self, args)
@staticmethod
def _btl_source():
- return "/libs/LAPACK/main.cpp"
+ return "libs/LAPACK/main.cpp"
@staticmethod
def _btl_includes():
- return ["/libs/BLAS", "libs/LAPACK"]
+ return ["libs/BLAS", "libs/LAPACK"]
def _btl_defines(self):
return ["LAPACKNAME=" + self.libname]
-
- def _get_flags(self, root, impl, libdir):
- # Retrieve pkgconfig settings and map the directories to the new root
- path = "%s/etc/env.d/alternatives/%s/%s/%s/pkgconfig" % \
- (root, self.libname, impl, libdir)
- pkgconf = sp.Popen('pkg-config --libs --cflags lapack', shell=True, \
- stdout=sp.PIPE, env={'PKG_CONFIG_PATH':path}).communicate()[0]
- pkgconf = pkgconf.replace('-L/', '-L'+root+'/')
- pkgconf = pkgconf.replace('-I/', '-I'+root+'/')
- return shlex.split(pkgconf)
-
-
- def get_impls(self, root):
- output = sp.Popen(
- ['eselect', '--no-color', '--brief', self.libname, 'list'],
- env={'ROOT' : root}, stdout=sp.PIPE
- ).communicate()[0]
- return output.strip().split('\n')
-
-del btlbase
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/
@ 2011-07-12 15:08 Andrea Arteaga
0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arteaga @ 2011-07-12 15:08 UTC (permalink / raw
To: gentoo-commits
commit: f88db2f6927c447ec5be02a2d4d9bd2e2391f87f
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Tue Jul 12 15:02:10 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Tue Jul 12 15:02:10 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=f88db2f6
Better reports (work on images and HTML).
---
.../autobench/files/python/basemodule.py | 22 +++++++++++-----
app-benchmarks/autobench/files/python/blasbase.py | 2 +-
.../autobench/files/python/htmlreport.py | 27 +++++++++++++++----
app-benchmarks/autobench/files/python/main.py | 2 +
4 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/app-benchmarks/autobench/files/python/basemodule.py b/app-benchmarks/autobench/files/python/basemodule.py
index 93b5a77..f3ee50b 100644
--- a/app-benchmarks/autobench/files/python/basemodule.py
+++ b/app-benchmarks/autobench/files/python/basemodule.py
@@ -29,10 +29,10 @@ class BaseModule:
passargs = []
for i in args:
- if i == '-S':
+ if i in ('-S', '--summary-only'):
self.summary_only = True
continue
- elif i == '-s':
+ elif i in ('-s', '--summary'):
self.summary = True
continue
else:
@@ -45,7 +45,11 @@ class BaseModule:
output = sp.Popen(
['eselect', '--no-color', '--brief', self.libname, 'list'],
env={'ROOT' : root}, stdout=sp.PIPE).communicate()[0]
- return output.strip().split('\n')
+ output = output.strip()
+ if '(none found)' in output:
+ return []
+ else:
+ return [i.split()[0] for i in output.split('\n')]
def getTest(self, root, impl, testdir, logdir):
TestClass = self._testClass()
@@ -94,19 +98,22 @@ class BaseModule:
# Save summary figure
sprows = (len(self.tests)+1)/2
plt.figure(figsize=(16,6*sprows), dpi=300)
+ plt.subplots_adjust(wspace=.4, hspace=.4)
for i, test in enumerate(self.tests, 1):
plt.subplot(sprows, 2, i)
plt.title(test)
for impl in newresults[test]:
x,y = np.loadtxt(newresults[test][impl], unpack=True)
plotf(x,y, label=impl, hold=True)
- plt.legend(loc='best')
+ if self.summary_only:
+ plt.legend(loc='best')
plt.xlabel('size')
plt.ylabel('MFlops')
plt.grid(True)
fname = pjoin(cfg.reportdir, 'summary.png')
- plt.savefig(fname, format='png')
- html.addFig("Summary", image=os.path.basename(fname), width='95%')
+ plt.savefig(fname, format='png', bbox_inches='tight', \
+ transparent=True)
+ html.addFig("Summary", image=os.path.basename(fname), width='90%')
Print('Summary figure saved: ' + fname)
# Generate plots
@@ -121,7 +128,8 @@ class BaseModule:
plt.ylabel('MFlops')
plt.grid(True)
fname = pjoin(cfg.reportdir, test+".png")
- plt.savefig(fname, format='png')
+ plt.savefig(fname, format='png', bbox_inches='tight', \
+ transparent=True)
html.addFig(test, image=os.path.basename(fname))
Print('Figure ' + fname + ' saved')
diff --git a/app-benchmarks/autobench/files/python/blasbase.py b/app-benchmarks/autobench/files/python/blasbase.py
index 664d706..e2c14ff 100644
--- a/app-benchmarks/autobench/files/python/blasbase.py
+++ b/app-benchmarks/autobench/files/python/blasbase.py
@@ -54,4 +54,4 @@ class BLASTest(btlbase.BTLTest):
return ["libs/BLAS"]
def _btl_defines(self):
- return ["CBLASNAME=" + self.libname, "BLAS_INTERFACE"]
\ No newline at end of file
+ return ["CBLASNAME="+self.libname, self.libname.upper()+"_INTERFACE"]
\ No newline at end of file
diff --git a/app-benchmarks/autobench/files/python/htmlreport.py b/app-benchmarks/autobench/files/python/htmlreport.py
index cb51da2..5e563fe 100644
--- a/app-benchmarks/autobench/files/python/htmlreport.py
+++ b/app-benchmarks/autobench/files/python/htmlreport.py
@@ -13,15 +13,14 @@ body {
}
img {
- width:80%;
+ height:80%;
}
-h1, h2, .plot, .descr, .date {
+h1, h2, .plot, .descr, .info {
text-align: center;
}
.fig {
- background-color: #CCCCCC;
margin-bottom: 50px;
padding-top: 20px;
padding-bottom: 20px;
@@ -33,7 +32,23 @@ h1, h2, .plot, .descr, .date {
"""
self.content += title + "</h1>"
date = time.strftime('%Y-%m-%d, %I:%M %p')
- self.content += '<p class="date">Generated on ' + date + '</p>'
+ self.content += '<p class="info">Generated on ' + date + '</p>'
+
+ cpuinfo = file('/proc/cpuinfo', 'r').readlines()
+ cpu = None
+ for l in cpuinfo:
+ if l[:10] == 'model name':
+ cpu = l.split(':',1)[1].strip()
+ if cpu:
+ self.content += '<p class="info">CPU: ' + cpu + '</p>'
+
+ meminfo = file('/proc/meminfo', 'r').readlines()
+ mem = None
+ for l in meminfo:
+ if l[:8] == 'MemTotal':
+ mem = l.split(':',1)[1].strip()
+ if mem:
+ self.content += '<p class="info">Total memory: ' + mem + '</p>'
def addFig(self, title, image, descr='', alt='', width=None):
@@ -45,10 +60,10 @@ h1, h2, .plot, .descr, .date {
self.content += '<a href="' + image + '">'
self.content += '<img src="' + image + '" alt="' + alt + '"'
if width is not None:
- self.content += ' style="width:' + str(width) + '"'
+ self.content += ' style="width:' + str(width) + '; height:auto"'
self.content += ' /></a>'
self.content += '</div>'
- self.content += '</div>'
+ self.content += '</div><hr />'
def close(self):
self.content += "</body></html>"
diff --git a/app-benchmarks/autobench/files/python/main.py b/app-benchmarks/autobench/files/python/main.py
index 86c555a..8994168 100644
--- a/app-benchmarks/autobench/files/python/main.py
+++ b/app-benchmarks/autobench/files/python/main.py
@@ -190,6 +190,8 @@ for tn,(name,test) in enumerate(tests.items(),1):
# Test every implementation
test['results'] = {}
+ if len(impls) == 0:
+ Print("No implementation found")
for impl in impls:
Print("Testing " + impl)
Print.down()
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/
@ 2011-07-13 0:01 Andrea Arteaga
0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arteaga @ 2011-07-13 0:01 UTC (permalink / raw
To: gentoo-commits
commit: 90ef6c1929aa217b96cffc5caed28e53f28201da
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Tue Jul 12 20:10:29 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Tue Jul 12 20:10:29 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=90ef6c19
Added descriptions for the tests.
---
.../autobench/files/python/basemodule.py | 5 ++-
app-benchmarks/autobench/files/python/testdescr.py | 29 ++++++++++++++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/app-benchmarks/autobench/files/python/basemodule.py b/app-benchmarks/autobench/files/python/basemodule.py
index f3ee50b..77ce1ab 100644
--- a/app-benchmarks/autobench/files/python/basemodule.py
+++ b/app-benchmarks/autobench/files/python/basemodule.py
@@ -8,6 +8,7 @@ import basemodule
from benchutils import mkdir, run_cmd
from benchprint import Print
import benchpkgconfig as pc
+from testdescr import testdescr
try:
import matplotlib.pyplot as plt
@@ -101,7 +102,7 @@ class BaseModule:
plt.subplots_adjust(wspace=.4, hspace=.4)
for i, test in enumerate(self.tests, 1):
plt.subplot(sprows, 2, i)
- plt.title(test)
+ plt.title(testdescr[test])
for impl in newresults[test]:
x,y = np.loadtxt(newresults[test][impl], unpack=True)
plotf(x,y, label=impl, hold=True)
@@ -130,7 +131,7 @@ class BaseModule:
fname = pjoin(cfg.reportdir, test+".png")
plt.savefig(fname, format='png', bbox_inches='tight', \
transparent=True)
- html.addFig(test, image=os.path.basename(fname))
+ html.addFig(testdescr[test], image=os.path.basename(fname))
Print('Figure ' + fname + ' saved')
html.close()
diff --git a/app-benchmarks/autobench/files/python/testdescr.py b/app-benchmarks/autobench/files/python/testdescr.py
new file mode 100644
index 0000000..ae63578
--- /dev/null
+++ b/app-benchmarks/autobench/files/python/testdescr.py
@@ -0,0 +1,29 @@
+testdescr = {
+# (C)BLAS
+'axpy' : 'y = a*x + y',
+'axpby' : 'y = a*x + b*y',
+'rot': 'Apply Givens rotation',
+'matrix_vector': 'Matrix-Vector multiply',
+'atv': 'Transposed Matrix-Vector multiply (A\' * x)',
+'symv': 'Symmetric Matrix-Vector multiply',
+'ger': 'Rank-1 update',
+'syr2': 'Symmetric Rank-2 update',
+'trisolve_vector': 'Triangular system solution',
+'matrix_matrix': 'Matrix-Matrix multiply',
+'aat': 'Symmetric Rank-n update',
+'trisolve_matrix': 'Triangular system solution with n right hand side vectors',
+'trmm': 'Triangular Matrix-Matrix multiply',
+
+# LAPACK
+'general_solve': 'Solution of a generic linear system of equations',
+'least_squares': 'Least squares solution',
+'lu_decomp': 'LU-decomposition',
+'cholesky': 'Cholesky decomposition',
+'symm_ev': 'Symmetric Eigenvalue computation',
+
+# FFTW
+'FFTW_1D_Forward_Measure': 'FFTW 1D Forward (Measure)',
+'FFTW_1D_Backward_Measure': 'FFTW 1D Backward (Measure)',
+'FFTW_1D_Forward_Estimate': 'FFTW 1D Forward (Estimate)',
+'FFTW_1D_Backward_Estimate': 'FFTW 1D Backward (Estimate)'
+}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/
@ 2011-07-13 10:01 Andrea Arteaga
0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arteaga @ 2011-07-13 10:01 UTC (permalink / raw
To: gentoo-commits
commit: fb65f8feeb8a6d2fa0a293a38678f325afc75139
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Wed Jul 13 09:57:21 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Wed Jul 13 09:57:21 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=fb65f8fe
Some changes.
---
.../autobench/files/python/PortageUtils.py | 2 +-
.../autobench/files/python/benchutils.py | 25 +-------------------
app-benchmarks/autobench/files/python/blastests.in | 2 +-
app-benchmarks/autobench/files/python/main.py | 6 ++--
4 files changed, 6 insertions(+), 29 deletions(-)
diff --git a/app-benchmarks/autobench/files/python/PortageUtils.py b/app-benchmarks/autobench/files/python/PortageUtils.py
index 66d0b80..5bd4c1d 100644
--- a/app-benchmarks/autobench/files/python/PortageUtils.py
+++ b/app-benchmarks/autobench/files/python/PortageUtils.py
@@ -66,7 +66,7 @@ def install_package(package, env={}, root='/', pkgdir='usr/portage/packages',
p = sp.Popen( \
['emerge', '--ignore-default-opts', '-OB', '=' + pkg], \
env = env, \
- stdout = fout, stderr = fout \
+ stdout = fout, stderr = sp.STDOUT \
)
p.wait()
if logfile is not None:
diff --git a/app-benchmarks/autobench/files/python/benchutils.py b/app-benchmarks/autobench/files/python/benchutils.py
index 3122f0f..748f928 100644
--- a/app-benchmarks/autobench/files/python/benchutils.py
+++ b/app-benchmarks/autobench/files/python/benchutils.py
@@ -8,27 +8,4 @@ def mkdir(dir):
if not os.path.exists(dir):
os.makedirs(dir)
-run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
-
-
-if __name__ == '__main__':
- cfg.libdir = '/usr/lib64'
- root = '/var/tmp/benchmarks/roots/atlas'
- pfile = pc.GetFile('lapack', 'atlas', root)
- print pc.Run(pfile, root, False)
-
- print pfile
- req = pc.Requires(pfile)
- print req
- change = sys.argv[1:]
- print change
- changes = dict([k.split(':',1) for k in change])
- deps = []
- for r in req:
- if r in changes.keys():
- impl = changes[r]
- pfile = pc.GetFile(r, changes[r])
- print pc.Run(pfile)
- else:
- print pc.Run(r)
-
\ No newline at end of file
+run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
\ No newline at end of file
diff --git a/app-benchmarks/autobench/files/python/blastests.in b/app-benchmarks/autobench/files/python/blastests.in
index d7b1a41..4a6900d 100644
--- a/app-benchmarks/autobench/files/python/blastests.in
+++ b/app-benchmarks/autobench/files/python/blastests.in
@@ -1,6 +1,6 @@
# Testing almost all implementations using gcc-4.6.1 and enabling vectorization
-blas-reference sci-libs/blas-reference-3.3.1-r1 FC=gfortran-4.6.1 FFLAGS="-O3 -pipe -march=native -msse3 -msse4.1 -msse4.2"
+blas-reference sci-libs/blas-reference-3.3.1-r1 FC=gfortran-4.5.2 FFLAGS="-O3 -pipe -march=native -msse3 -msse4.1 -msse4.2"
acml sci-libs/acml-4.4.0-r1 -acml32-gfortran -acml32-gfortran-openmp -acml64-gfortran-openmp
goto sci-libs/gotoblas2-1.13 CFLAGS="-O3 -march=native" USE='incblas' TARGET=NEHALEM
atlas sci-libs/atlas-3.9.41 CC=gcc-4.6.1 CFLAGS="-O3 -pipe -march=native -msse3 -msse4.1 -msse4.2"
diff --git a/app-benchmarks/autobench/files/python/main.py b/app-benchmarks/autobench/files/python/main.py
index 10a2091..47d72eb 100644
--- a/app-benchmarks/autobench/files/python/main.py
+++ b/app-benchmarks/autobench/files/python/main.py
@@ -121,12 +121,12 @@ if not os.path.exists(cfg.inputfile):
print_usage()
exit(1)
input = file(cfg.inputfile).read()
-tests = tests_from_input(input)
+cfg.tests = tests_from_input(input)
# Write summary
print 80*'='
print "The following tests will be run:"
-for tname, ttest in tests.items():
+for tname, ttest in cfg.tests.items():
print "Test: " + tname
if ttest['descr'] is not None:
print " - Description: " + ttest['descr']
@@ -145,7 +145,7 @@ for tname, ttest in tests.items():
print 80*'='
print
-for tn,(name,test) in enumerate(tests.items(),1):
+for tn,(name,test) in enumerate(cfg.tests.items(),1):
Print._level = 0
Print("BEGIN TEST %i - %s" % (tn, name))
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/
2011-07-13 16:05 [gentoo-commits] proj/auto-numerical-bench:mid-term " Andrea Arteaga
@ 2011-07-13 16:00 ` Andrea Arteaga
0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arteaga @ 2011-07-13 16:00 UTC (permalink / raw
To: gentoo-commits
commit: 0bbfc37d7de3f0a2450fb7423168954b0f28fb83
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Wed Jul 13 15:55:13 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Wed Jul 13 15:55:13 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=0bbfc37d
Bugfix
---
app-benchmarks/autobench/files/python/main.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/app-benchmarks/autobench/files/python/main.py b/app-benchmarks/autobench/files/python/main.py
index 47d72eb..561d5d9 100644
--- a/app-benchmarks/autobench/files/python/main.py
+++ b/app-benchmarks/autobench/files/python/main.py
@@ -218,7 +218,7 @@ for tn,(name,test) in enumerate(cfg.tests.items(),1):
# |-(name1, impl2) -> resultobject12
# |-(name2, impl1) -> resultobject21
results = {}
-for (name,test) in tests.items():
+for (name,test) in cfg.tests.items():
if test.has_key('implementations'):
for impl in test['implementations']:
results[(name, impl)] = test['results'][impl]
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-07-13 16:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-04 21:38 [gentoo-commits] proj/auto-numerical-bench:master commit in: app-benchmarks/autobench/files/python/ Andrea Arteaga
-- strict thread matches above, loose matches on Subject: below --
2011-07-13 16:05 [gentoo-commits] proj/auto-numerical-bench:mid-term " Andrea Arteaga
2011-07-13 16:00 ` [gentoo-commits] proj/auto-numerical-bench:master " Andrea Arteaga
2011-07-13 10:01 Andrea Arteaga
2011-07-13 0:01 Andrea Arteaga
2011-07-12 15:08 Andrea Arteaga
2011-07-04 21:38 Andrea Arteaga
2011-07-01 16:06 Andrea Arteaga
2011-07-01 12:28 Andrea Arteaga
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox